Skip to content

Commit e1c4ac1

Browse files
committed
CPreProcessor,refactor: make `enum eCppCharacters' CPreProcessor private
Except STRING_SYMBOL and CHAR_SYMBOL, the character names are used only in CPreProcessor. Signed-off-by: Masatake YAMATO <[email protected]>
1 parent daec427 commit e1c4ac1

File tree

8 files changed

+31
-32
lines changed

8 files changed

+31
-32
lines changed

parsers/asm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static bool collectCppMacroArguments (ptrArray *args)
399399
ptrArrayAdd (args, cstr);
400400
s = vStringNew ();
401401
}
402-
else if (c == STRING_SYMBOL || c == CHAR_SYMBOL)
402+
else if (c == CPP_STRING_SYMBOL || c == CPP_CHAR_SYMBOL)
403403
vStringPut (s, ' ');
404404
else
405405
vStringPut (s, c);
@@ -425,7 +425,7 @@ static bool expandCppMacro (cppMacroInfo *macroInfo)
425425
while (1)
426426
{
427427
c = cppGetc ();
428-
if (c == STRING_SYMBOL || c == CHAR_SYMBOL || !isspace (c))
428+
if (c == CPP_STRING_SYMBOL || c == CPP_CHAR_SYMBOL || !isspace (c))
429429
break;
430430
}
431431

@@ -519,7 +519,7 @@ static const unsigned char *readLineViaCpp (const char *commentChars)
519519
cont:
520520
while ((c = cppGetc()) != EOF)
521521
{
522-
if (c == STRING_SYMBOL || c == CHAR_SYMBOL)
522+
if (c == CPP_STRING_SYMBOL || c == CPP_CHAR_SYMBOL)
523523
{
524524
/* c == CHAR_SYMBOL is subtle condition.
525525
* If the last char of IDENTIFIER is [0-9a-f],

parsers/c-based.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2688,7 +2688,7 @@ static void parseGeneralToken (statementInfo *const st, const int c)
26882688
{
26892689
parseAtMarkStyleAnnotation (st);
26902690
}
2691-
else if (c == STRING_SYMBOL)
2691+
else if (c == CPP_STRING_SYMBOL)
26922692
{
26932693
setToken(st, TOKEN_NONE);
26942694
}

parsers/cpreprocessor.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@
3939
/*
4040
* DATA DECLARATIONS
4141
*/
42+
enum eCppCharacters {
43+
/* white space characters */
44+
SPACE = ' ',
45+
NEWLINE = '\n',
46+
CRETURN = '\r',
47+
FORMFEED = '\f',
48+
TAB = '\t',
49+
VTAB = '\v',
50+
51+
/* some hard to read characters */
52+
DOUBLE_QUOTE = '"',
53+
SINGLE_QUOTE = '\'',
54+
BACKSLASH = '\\',
55+
56+
/* symbolic representations, above 0xFF not to conflict with any byte */
57+
STRING_SYMBOL = CPP_STRING_SYMBOL,
58+
CHAR_SYMBOL = CPP_CHAR_SYMBOL
59+
};
60+
4261
typedef enum { COMMENT_NONE, COMMENT_C, COMMENT_CPLUS, COMMENT_D } Comment;
4362

4463
enum eCppLimits {

parsers/cpreprocessor.h

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,12 @@
1919
#include "types.h"
2020
#include "vstring.h"
2121

22-
/*
23-
* DATA DECLARATIONS
24-
*/
25-
26-
enum eCharacters {
27-
/* white space characters */
28-
SPACE = ' ',
29-
NEWLINE = '\n',
30-
CRETURN = '\r',
31-
FORMFEED = '\f',
32-
TAB = '\t',
33-
VTAB = '\v',
34-
35-
/* some hard to read characters */
36-
DOUBLE_QUOTE = '"',
37-
SINGLE_QUOTE = '\'',
38-
BACKSLASH = '\\',
39-
40-
/* symbolic representations, above 0xFF not to conflict with any byte */
41-
STRING_SYMBOL = ('S' + 0xff),
42-
CHAR_SYMBOL = ('C' + 0xff)
43-
};
44-
4522
/*
4623
* MACROS
4724
*/
25+
/* symbolic representations, above 0xFF not to conflict with any byte */
26+
#define CPP_STRING_SYMBOL ('S' + 0xff)
27+
#define CPP_CHAR_SYMBOL ('C' + 0xff)
4828

4929
/*
5030
* cppIs... macros are for the value returned from cppGetc(). Don't

parsers/cxx/cxx_parser_tokenizer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ bool cxxParserParseNextToken(void)
15301530
return true;
15311531
}
15321532
#else
1533-
if(g_cxx.iChar == STRING_SYMBOL)
1533+
if(g_cxx.iChar == CPP_STRING_SYMBOL)
15341534
{
15351535
t->eType = CXXTokenTypeStringConstant;
15361536
cStringPut(t->pszWord,g_cxx.iChar);
@@ -1576,7 +1576,7 @@ bool cxxParserParseNextToken(void)
15761576
return true;
15771577
}
15781578
#else
1579-
if(g_cxx.iChar == CHAR_SYMBOL)
1579+
if(g_cxx.iChar == CPP_CHAR_SYMBOL)
15801580
{
15811581
t->eType = CXXTokenTypeCharacterConstant;
15821582
cStringPut(t->pszWord,g_cxx.iChar);

parsers/ldscript.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static void readToken (tokenInfo *const token, void *data CTAGS_ATTR_UNUSED)
380380
if (prefix_count > 0)
381381
LDSCRIPT (token)->whitespacePrefixed = true;
382382
} while (c == ' ' || c== '\t' || c == '\f' || c == '\r' || c == '\n'
383-
|| c == STRING_SYMBOL || c == CHAR_SYMBOL);
383+
|| c == CPP_STRING_SYMBOL || c == CPP_CHAR_SYMBOL);
384384

385385
token->lineNumber = getInputLineNumber ();
386386
token->filePosition = getInputFilePosition ();

parsers/protobuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static void nextTokenFull (bool expectingStringLiteral)
206206
token.keyword = lookupCaseKeyword (vStringValue (token.value), Lang_protobuf);
207207
cppUngetc (c);
208208
}
209-
else if (expectingStringLiteral && c == STRING_SYMBOL)
209+
else if (expectingStringLiteral && c == CPP_STRING_SYMBOL)
210210
{
211211
token.type = TOKEN_STR;
212212
vStringCopy (token.value,

parsers/vera.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ static void parseGeneralToken (statementInfo *const st, const int c)
19141914
if (c2 != '=')
19151915
cppUngetc (c2);
19161916
}
1917-
else if (c == STRING_SYMBOL) {
1917+
else if (c == CPP_STRING_SYMBOL) {
19181918
setToken(st, TOKEN_NONE);
19191919
}
19201920
}

0 commit comments

Comments
 (0)