2000-09-02 11:35:22 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
2013-05-09 11:56:54 +00:00
|
|
|
/* feature.c */
|
2000-09-02 11:35:22 +00:00
|
|
|
/* */
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Subroutines for the emulation features */
|
2000-09-02 11:35:22 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2013-01-12 19:07:31 +00:00
|
|
|
/* (C) 2000-2013, Ullrich von Bassewitz */
|
2012-01-18 19:50:34 +00:00
|
|
|
/* Roemerstrasse 52 */
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
/* EMail: uz@cc65.org */
|
2000-09-02 11:35:22 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/* ca65 */
|
|
|
|
#include "global.h"
|
|
|
|
#include "feature.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Data */
|
2000-09-02 11:35:22 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Names of the features */
|
2017-06-28 18:43:31 +00:00
|
|
|
static const char* const FeatureKeys[FEAT_COUNT] = {
|
2000-09-02 11:35:22 +00:00
|
|
|
"dollar_is_pc",
|
|
|
|
"labels_without_colons",
|
|
|
|
"loose_string_term",
|
2000-09-02 12:01:40 +00:00
|
|
|
"loose_char_term",
|
2000-09-02 11:35:22 +00:00
|
|
|
"at_in_identifiers",
|
|
|
|
"dollar_in_identifiers",
|
2002-02-14 10:05:51 +00:00
|
|
|
"leading_dot_in_identifiers",
|
2007-08-23 19:48:43 +00:00
|
|
|
"org_per_seg",
|
2000-09-02 11:35:22 +00:00
|
|
|
"pc_assignment",
|
2004-03-29 15:58:34 +00:00
|
|
|
"missing_char_term",
|
2004-04-20 12:49:36 +00:00
|
|
|
"ubiquitous_idents",
|
2008-08-21 19:35:39 +00:00
|
|
|
"c_comments",
|
2012-01-18 19:50:34 +00:00
|
|
|
"force_range",
|
2013-01-12 19:07:31 +00:00
|
|
|
"underline_in_numbers",
|
2015-04-20 03:21:56 +00:00
|
|
|
"addrsize",
|
2016-02-25 20:40:31 +00:00
|
|
|
"bracket_as_indirect",
|
2019-01-05 19:29:54 +00:00
|
|
|
"string_escapes",
|
2023-02-21 09:00:34 +00:00
|
|
|
"long_jsr_jmp_rts",
|
2023-09-23 11:19:11 +00:00
|
|
|
"line_continuations",
|
2000-09-02 11:35:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Code */
|
2000-09-02 11:35:22 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-31 20:54:45 +00:00
|
|
|
feature_t FindFeature (const StrBuf* Key)
|
2000-09-02 11:35:22 +00:00
|
|
|
/* Find the feature in a table and return the corresponding enum value. If the
|
2014-06-30 09:10:35 +00:00
|
|
|
** feature is invalid, return FEAT_UNKNOWN.
|
|
|
|
*/
|
2000-09-02 11:35:22 +00:00
|
|
|
{
|
|
|
|
feature_t F;
|
|
|
|
|
|
|
|
/* This is not time critical, so do a linear search */
|
|
|
|
for (F = (feature_t) 0; F < FEAT_COUNT; ++F) {
|
2013-05-09 11:56:54 +00:00
|
|
|
if (SB_CompareStr (Key, FeatureKeys[F]) == 0) {
|
|
|
|
/* Found, index is enum value */
|
|
|
|
return F;
|
|
|
|
}
|
2000-09-02 11:35:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Not found */
|
|
|
|
return FEAT_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-24 23:00:58 +00:00
|
|
|
void SetFeature (feature_t Feature, unsigned char On)
|
|
|
|
/* Set the corresponding feature flag if Feature is valid.
|
2014-06-30 09:10:35 +00:00
|
|
|
*/
|
2000-09-02 11:35:22 +00:00
|
|
|
{
|
|
|
|
/* Set the flags */
|
|
|
|
switch (Feature) {
|
2023-02-24 23:00:58 +00:00
|
|
|
case FEAT_DOLLAR_IS_PC: DollarIsPC = On; break;
|
|
|
|
case FEAT_LABELS_WITHOUT_COLONS: NoColonLabels = On; break;
|
|
|
|
case FEAT_LOOSE_STRING_TERM: LooseStringTerm = On; break;
|
|
|
|
case FEAT_LOOSE_CHAR_TERM: LooseCharTerm = On; break;
|
|
|
|
case FEAT_AT_IN_IDENTIFIERS: AtInIdents = On; break;
|
|
|
|
case FEAT_DOLLAR_IN_IDENTIFIERS: DollarInIdents = On; break;
|
|
|
|
case FEAT_LEADING_DOT_IN_IDENTIFIERS: LeadingDotInIdents= On; break;
|
|
|
|
case FEAT_ORG_PER_SEG: OrgPerSeg = On; break;
|
|
|
|
case FEAT_PC_ASSIGNMENT: PCAssignment = On; break;
|
|
|
|
case FEAT_MISSING_CHAR_TERM: MissingCharTerm = On; break;
|
|
|
|
case FEAT_UBIQUITOUS_IDENTS: UbiquitousIdents = On; break;
|
|
|
|
case FEAT_C_COMMENTS: CComments = On; break;
|
|
|
|
case FEAT_FORCE_RANGE: ForceRange = On; break;
|
|
|
|
case FEAT_UNDERLINE_IN_NUMBERS: UnderlineInNumbers= On; break;
|
|
|
|
case FEAT_BRACKET_AS_INDIRECT: BracketAsIndirect = On; break;
|
|
|
|
case FEAT_STRING_ESCAPES: StringEscapes = On; break;
|
|
|
|
case FEAT_LONG_JSR_JMP_RTS: LongJsrJmpRts = On; break;
|
2023-09-23 11:19:11 +00:00
|
|
|
case FEAT_LINE_CONTINUATIONS: LineCont = On; break;
|
2023-02-24 23:00:58 +00:00
|
|
|
default: break;
|
2002-02-14 10:05:51 +00:00
|
|
|
}
|
2000-09-02 11:35:22 +00:00
|
|
|
}
|