mirror of
https://git.wuffs.org/MWCC
synced 2025-12-12 14:46:09 +00:00
fix various inaccuracies exposed by the mach ppc plugin
This commit is contained in:
@@ -51,8 +51,10 @@ static void prepmacro(Macro *macro);
|
||||
static void prepifskip(void);
|
||||
static void gotonexttoken(void);
|
||||
|
||||
#ifdef CW_CLT
|
||||
extern SInt16 *CLT_filesp;
|
||||
extern CPrepFileInfo **CLT_filestack;
|
||||
#endif
|
||||
|
||||
struct CompilerOption {
|
||||
char *name;
|
||||
@@ -390,8 +392,10 @@ Boolean setupprep(void) {
|
||||
tokenstacklevel = 0;
|
||||
cprep_cursymfile = 0;
|
||||
cprep_files = 0;
|
||||
#ifdef CW_CLT
|
||||
CLT_filesp = &filesp;
|
||||
CLT_filestack = filestack;
|
||||
#endif
|
||||
anyerrors = 0;
|
||||
fatalerrors = 0;
|
||||
was_prep_error = 0;
|
||||
@@ -403,11 +407,9 @@ Boolean setupprep(void) {
|
||||
if (InitGList(&mlist, 10000))
|
||||
CError_NoMem();
|
||||
|
||||
stringmem = COS_NewHandle(256);
|
||||
if (!stringmem)
|
||||
if (!(stringmem = COS_NewHandle(256)))
|
||||
CError_NoMem();
|
||||
ts_buffer = COS_NewHandle(1024 * sizeof(TStreamElement));
|
||||
if (!ts_buffer)
|
||||
if (!(ts_buffer = COS_NewHandle(1024 * sizeof(TStreamElement))))
|
||||
CError_NoMem();
|
||||
COS_LockHandleHi(ts_buffer);
|
||||
ts_first = (TStreamElement *) *ts_buffer;
|
||||
@@ -495,7 +497,7 @@ static Boolean setupfile(StringPtr filename, Boolean flag1, Boolean flag2) {
|
||||
SInt16 refnum;
|
||||
SInt16 file_vrefnum;
|
||||
char *extpos;
|
||||
unsigned char *src;
|
||||
char *src;
|
||||
char *append;
|
||||
char *dst;
|
||||
int len;
|
||||
@@ -519,7 +521,7 @@ static Boolean setupfile(StringPtr filename, Boolean flag1, Boolean flag2) {
|
||||
if (CWFindAndLoadFile(cparamblkptr->context, myfilename, &fileinfo) != cwNoErr) {
|
||||
if (filename[0] + strlen(".framework/Headers") < 255) {
|
||||
if ((extpos = strchr(myfilename, '/'))) {
|
||||
src = filename + 1;
|
||||
src = (char *) filename + 1;
|
||||
append = ".framework/Headers";
|
||||
dst = myfilename;
|
||||
len = filename[0];
|
||||
@@ -804,8 +806,8 @@ loop:
|
||||
|
||||
void CPrep_StreamGetBlock(TokenStream *stream, CPrepStreamFuncPtr func, int arg) {
|
||||
Boolean save_eoltokens;
|
||||
SInt32 start_offset;
|
||||
Boolean tryflag;
|
||||
SInt32 start_offset;
|
||||
SInt32 count;
|
||||
|
||||
start_offset = ts_current - ts_first - 1;
|
||||
@@ -997,8 +999,8 @@ void CPrep_TokenStreamFlush(void) {
|
||||
ts_current = ts_first;
|
||||
}
|
||||
|
||||
static int CPrep_TokenSize(char *str) {
|
||||
int len;
|
||||
static short CPrep_TokenSize(char *str) {
|
||||
short len;
|
||||
int c;
|
||||
|
||||
if ((str[0] >= 'a' && str[0] <= 'z') || (str[0] >= 'A' && str[0] <= 'Z') || (str[0] == '_')) {
|
||||
@@ -1028,16 +1030,31 @@ static int CPrep_TokenSize(char *str) {
|
||||
if (str[1] == '=' || str[1] == '+') return 2;
|
||||
break;
|
||||
case '-':
|
||||
if (str[1] == '>') return (str[2] == '*') ? 3 : 2;
|
||||
if (str[1] == '>') {
|
||||
if (str[2] == '*')
|
||||
return 3;
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
if (str[1] == '=' || str[1] == '-') return 2;
|
||||
break;
|
||||
case '<':
|
||||
if (str[1] == '=') return 2;
|
||||
if (str[1] == '<') return (str[2] == '=') ? 3 : 2;
|
||||
if (str[1] == '<') {
|
||||
if (str[2] == '=')
|
||||
return 3;
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
case '>':
|
||||
if (str[1] == '=') return 2;
|
||||
if (str[1] == '>') return (str[2] == '=') ? 3 : 2;
|
||||
if (str[1] == '>') {
|
||||
if (str[2] == '=')
|
||||
return 3;
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
case '&':
|
||||
if (str[1] == '=' || str[1] == '&') return 2;
|
||||
@@ -1087,7 +1104,7 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn
|
||||
int r5;
|
||||
int r6;
|
||||
char *r7;
|
||||
char *r5x;
|
||||
const char *r5x;
|
||||
SInt16 c;
|
||||
|
||||
if (token && !token->tokenfile)
|
||||
@@ -1129,7 +1146,7 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn
|
||||
if (!cprep_hasprepline) {
|
||||
line = 1;
|
||||
for (i = 0; i < p; i++) {
|
||||
if (filedata[i] == '\r')
|
||||
if (filedata[i] == 13)
|
||||
line++;
|
||||
}
|
||||
*plinenumber = line;
|
||||
@@ -1148,17 +1165,19 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn
|
||||
}
|
||||
*tokenoffset = 0;
|
||||
r5 = 1;
|
||||
while (r5 < 80 && (r7 - r5) >= r4 && r7[-r5] != '\r')
|
||||
while (r5 < 80 && (r7 - r5) >= r4 && r7[-r5] != 13)
|
||||
r5++;
|
||||
r5--;
|
||||
while ((c = r7[-r5]) && (c == ' ' || c == '\t' || c == TK_4))
|
||||
r5--;
|
||||
r6 = 0;
|
||||
while ((c = r7[-r5]) != '\r' && c && r6 < 126) {
|
||||
while ((c = r7[-r5]) != 13 && c && r6 < 126) {
|
||||
if (!r5)
|
||||
*tokenoffset = r6;
|
||||
if (c != TK_4) {
|
||||
buf1[r6++] = (c != '\t') ? c : ' ';
|
||||
if (c == '\t')
|
||||
c = ' ';
|
||||
buf1[r6++] = c;
|
||||
}
|
||||
r5--;
|
||||
}
|
||||
@@ -1179,8 +1198,8 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn
|
||||
r5x = filedata;
|
||||
*lastarg = p;
|
||||
}
|
||||
for (i = 0; i < 31 && *r5x; i++) {
|
||||
buf2[i] = *(r5x++);
|
||||
for (i = 0; i < 31 && r5x[i]; i++) {
|
||||
buf2[i] = r5x[i];
|
||||
}
|
||||
buf2[i] = 0;
|
||||
|
||||
@@ -1577,7 +1596,7 @@ static Boolean is_nextchar(short t) {
|
||||
return 0;
|
||||
p = tokenstack[--level].pos;
|
||||
continue;
|
||||
case '\r':
|
||||
case 13:
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
@@ -1765,7 +1784,7 @@ loop:
|
||||
}
|
||||
pos = nextcharpos;
|
||||
goto loop;
|
||||
case '\r':
|
||||
case 13:
|
||||
newline();
|
||||
pos = nextcharpos;
|
||||
goto loop;
|
||||
@@ -1794,7 +1813,7 @@ loop:
|
||||
poptokenseq();
|
||||
goto loop;
|
||||
}
|
||||
case '\r':
|
||||
case 13:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2159,7 +2178,7 @@ static Boolean CPrep_CheckTarget(void) {
|
||||
}
|
||||
|
||||
static Boolean CPrep_CheckOption(void) {
|
||||
UInt16 offset;
|
||||
UInt32 offset;
|
||||
UInt8 *ptr;
|
||||
struct CompilerOption *option;
|
||||
Boolean result;
|
||||
@@ -2381,7 +2400,7 @@ char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2) {
|
||||
FSSpec spec;
|
||||
Str255 filename;
|
||||
int size;
|
||||
char *src;
|
||||
StringPtr src;
|
||||
char *dst;
|
||||
|
||||
COS_FileGetFSSpecInfo(&filestack[flag1 ? 0 : filesp]->textfile, NULL, NULL, filename);
|
||||
@@ -2395,7 +2414,7 @@ char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2) {
|
||||
if (flag2)
|
||||
*(dst++) = '"';
|
||||
|
||||
src = (char *) filename;
|
||||
src = filename;
|
||||
while (size-- > 0)
|
||||
*(dst++) = *(++src);
|
||||
|
||||
@@ -2759,32 +2778,29 @@ void CPrep_PopOption(SInt32 id) {
|
||||
}
|
||||
|
||||
static void CPrep_PragmaImExport(int flags) {
|
||||
// does not match - weirdness with the branching inside the loop
|
||||
NameSpaceObjectList *list;
|
||||
|
||||
do {
|
||||
if (!notendofline())
|
||||
break;
|
||||
if (plex() != TK_IDENTIFIER)
|
||||
if (
|
||||
!notendofline() ||
|
||||
plex() != TK_IDENTIFIER ||
|
||||
!(list = CScope_GetLocalObject(cscope_root, tkidentifier))
|
||||
)
|
||||
break;
|
||||
|
||||
if (!(list = CScope_GetLocalObject(cscope_root, tkidentifier))) {
|
||||
break;
|
||||
} else {
|
||||
while (list) {
|
||||
if (list->object->otype == OT_OBJECT) {
|
||||
switch (OBJECT(list->object)->datatype) {
|
||||
case DDATA:
|
||||
case DFUNC:
|
||||
OBJECT(list->object)->flags |= flags;
|
||||
break;
|
||||
default:
|
||||
CPrep_Warning(CErrorStr186);
|
||||
return;
|
||||
}
|
||||
while (list) {
|
||||
if (list->object->otype == OT_OBJECT) {
|
||||
switch (OBJECT(list->object)->datatype) {
|
||||
case DDATA:
|
||||
case DFUNC:
|
||||
OBJECT(list->object)->flags |= flags;
|
||||
break;
|
||||
default:
|
||||
CPrep_Warning(CErrorStr186);
|
||||
return;
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
if (!notendofline())
|
||||
@@ -2839,24 +2855,25 @@ static void pragma_on_off_reset(UInt32 bits) {
|
||||
}
|
||||
|
||||
static HashNameNode *CPrep_PragmaOnceName(StringPtr name, Boolean flag) {
|
||||
// does not match, can't be bothered to fix it atm
|
||||
short len;
|
||||
char myname[256];
|
||||
unsigned char *src;
|
||||
char buf[256];
|
||||
char *myname;
|
||||
char *src;
|
||||
char *dst;
|
||||
short len;
|
||||
|
||||
len = name[0];
|
||||
if (len > 250)
|
||||
len = 250;
|
||||
|
||||
dst = &myname[1];
|
||||
src = &name[1];
|
||||
myname = &buf[1];
|
||||
dst = myname;
|
||||
src = (char *) &name[1];
|
||||
while (len-- > 0) {
|
||||
*(dst++) = tolower(*(src++));
|
||||
}
|
||||
*dst = 0;
|
||||
|
||||
myname[0] = (copts.syspath_once && flag) ? '$' : -'\\';
|
||||
*(--myname) = (copts.syspath_once && flag) ? '$' : -'\\';
|
||||
return GetHashNameNodeExport(myname);
|
||||
}
|
||||
|
||||
@@ -2935,7 +2952,7 @@ static void CPrep_PragmaUnused(void) {
|
||||
|
||||
list = CScope_GetLocalObject(nspace, tkidentifier);
|
||||
if (list && list->object->otype == OT_OBJECT && OBJECT(list->object)->datatype == DLOCAL) {
|
||||
OBJECT(list->object)->flags |= OBJECT_FLAGS_1;
|
||||
OBJECT(list->object)->flags = OBJECT(list->object)->flags | OBJECT_FLAGS_1;
|
||||
if (notendofline()) {
|
||||
t = plex();
|
||||
if (t == ')')
|
||||
@@ -2966,10 +2983,13 @@ static void CPrep_PragmaInlineDepth(void) {
|
||||
break;
|
||||
case TK_INTCONST:
|
||||
lv = CInt64_GetULong(&tkintconst);
|
||||
if (lv >= 0 && lv <= 1024)
|
||||
copts.inlinelevel = lv ? lv : -1;
|
||||
else
|
||||
if (lv >= 0 && lv <= 1024) {
|
||||
if (!lv)
|
||||
lv = -1;
|
||||
copts.inlinelevel = lv;
|
||||
} else {
|
||||
CPrep_Warning(CErrorStr186);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
CPrep_Warning(CErrorStr186);
|
||||
@@ -4168,7 +4188,7 @@ static void prepifskip(void) {
|
||||
CPrep_Error(CErrorStr105);
|
||||
}
|
||||
goto restart;
|
||||
case '\r':
|
||||
case 13:
|
||||
newline();
|
||||
goto restart;
|
||||
case '"':
|
||||
@@ -4181,7 +4201,7 @@ static void prepifskip(void) {
|
||||
t = prepskipnextchar();
|
||||
pos = nextcharpos;
|
||||
switch (t) {
|
||||
case '\r':
|
||||
case 13:
|
||||
goto restart;
|
||||
case 0:
|
||||
CPrep_Error(CErrorStr102);
|
||||
@@ -4227,7 +4247,7 @@ void preprocessor(void) {
|
||||
switch (t) {
|
||||
case 0:
|
||||
CPrep_Error(CErrorStr102);
|
||||
case '\r':
|
||||
case 13:
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,11 @@ loop:
|
||||
goto loop;
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case LF:
|
||||
case '\v':
|
||||
case '\f':
|
||||
spaceskip = 1;
|
||||
p++;
|
||||
spaceskip = 1;
|
||||
goto loop;
|
||||
case ';':
|
||||
pos = (char *) p++;
|
||||
@@ -64,17 +64,17 @@ loop:
|
||||
case '/':
|
||||
pos = (char *) p++;
|
||||
if (copts.multibyteaware) {
|
||||
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
|
||||
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
}
|
||||
} else {
|
||||
while (p[0] == '\\' && p[1] == '\r') {
|
||||
while (p[0] == '\\' && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
@@ -99,17 +99,17 @@ loop:
|
||||
}
|
||||
if (c == '*') {
|
||||
if (copts.multibyteaware) {
|
||||
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
|
||||
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
}
|
||||
} else {
|
||||
while (p[0] == '\\' && p[1] == '\r') {
|
||||
while (p[0] == '\\' && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
@@ -120,7 +120,7 @@ loop:
|
||||
goto loop;
|
||||
}
|
||||
}
|
||||
if (c == '\r')
|
||||
if (c == CR)
|
||||
foundnl();
|
||||
}
|
||||
}
|
||||
@@ -138,10 +138,10 @@ loop:
|
||||
case '\\':
|
||||
pos = (char *) p++;
|
||||
mid_backslash:
|
||||
if (*p == '\r') {
|
||||
if (*p == CR) {
|
||||
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
|
||||
foundnl();
|
||||
if (p[1] == '\n')
|
||||
if (p[1] == LF)
|
||||
p += 2;
|
||||
else
|
||||
p += 1;
|
||||
@@ -208,17 +208,17 @@ loop:
|
||||
return c;
|
||||
case '/':
|
||||
if (copts.multibyteaware) {
|
||||
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
|
||||
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
}
|
||||
} else {
|
||||
while (p[0] == '\\' && p[1] == '\r') {
|
||||
while (p[0] == '\\' && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
@@ -242,17 +242,17 @@ loop:
|
||||
}
|
||||
if (c == '*') {
|
||||
if (copts.multibyteaware) {
|
||||
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
|
||||
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
}
|
||||
} else {
|
||||
while (p[0] == '\\' && p[1] == '\r') {
|
||||
while (p[0] == '\\' && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
@@ -261,7 +261,7 @@ loop:
|
||||
if (*p == '/')
|
||||
break;
|
||||
}
|
||||
if (c == '\r')
|
||||
if (c == CR)
|
||||
foundnl();
|
||||
}
|
||||
pos = (char *) p + 1;
|
||||
@@ -272,10 +272,10 @@ loop:
|
||||
}
|
||||
case '\\':
|
||||
backslash:
|
||||
if (*p == '\r') {
|
||||
if (*p == CR) {
|
||||
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
|
||||
foundnl();
|
||||
if (p[1] == '\n')
|
||||
if (p[1] == LF)
|
||||
p += 2;
|
||||
else
|
||||
p += 1;
|
||||
@@ -345,12 +345,12 @@ loop:
|
||||
return c;
|
||||
case '\\':
|
||||
backslash:
|
||||
if (p[0] == '\r' && (!copts.multibyteaware || !COS_IsMultiByte(str, p - 1))) {
|
||||
if (p[0] == CR && (!copts.multibyteaware || !COS_IsMultiByte(str, p - 1))) {
|
||||
if (flag)
|
||||
foundnl();
|
||||
else
|
||||
prepnextstringchar_foundnl = 1;
|
||||
if (p[1] == '\n')
|
||||
if (p[1] == LF)
|
||||
p += 2;
|
||||
else
|
||||
p += 1;
|
||||
@@ -421,11 +421,11 @@ loop:
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == '\r') {
|
||||
if (c == CR) {
|
||||
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
|
||||
if (flag)
|
||||
foundnl();
|
||||
if (*p == '\n')
|
||||
if (*p == LF)
|
||||
p++;
|
||||
CPrep_Error(CErrorStr112);
|
||||
pos = p;
|
||||
@@ -445,8 +445,8 @@ loop:
|
||||
case '<':
|
||||
case '=':
|
||||
case '>':
|
||||
haveBackslash = 0;
|
||||
p += 2;
|
||||
haveBackslash = 0;
|
||||
goto loop;
|
||||
case '/':
|
||||
p += 2;
|
||||
@@ -456,10 +456,10 @@ loop:
|
||||
|
||||
if (c == '\\' && !haveBackslash && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) {
|
||||
backslash:
|
||||
if (*p == '\r') {
|
||||
if (*p == CR) {
|
||||
if (flag)
|
||||
foundnl();
|
||||
if (*(++p) == '\n')
|
||||
if (*(++p) == LF)
|
||||
p++;
|
||||
haveBackslash = 0;
|
||||
} else {
|
||||
@@ -496,11 +496,11 @@ loop:
|
||||
return p - 1;
|
||||
}
|
||||
|
||||
if (c == '\r') {
|
||||
if (c == CR) {
|
||||
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
|
||||
if (flag)
|
||||
foundnl();
|
||||
if (*p == '\n')
|
||||
if (*p == LF)
|
||||
p++;
|
||||
CPrep_Error(CErrorStr112);
|
||||
return p;
|
||||
@@ -519,8 +519,8 @@ loop:
|
||||
case '<':
|
||||
case '=':
|
||||
case '>':
|
||||
haveBackslash = 0;
|
||||
p += 2;
|
||||
haveBackslash = 0;
|
||||
goto loop;
|
||||
case '/':
|
||||
p += 2;
|
||||
@@ -530,10 +530,10 @@ loop:
|
||||
|
||||
if (c == '\\' && !haveBackslash && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) {
|
||||
backslash:
|
||||
if (*p == '\r') {
|
||||
if (*p == CR) {
|
||||
if (flag)
|
||||
foundnl();
|
||||
if (*(++p) == '\n')
|
||||
if (*(++p) == LF)
|
||||
p++;
|
||||
haveBackslash = 0;
|
||||
} else {
|
||||
@@ -582,7 +582,7 @@ static void prepcurstringchar_skip(void) {
|
||||
}
|
||||
|
||||
char *ReadIdentifier(const char *p) {
|
||||
char buf[256];
|
||||
unsigned char buf[256];
|
||||
const char *start;
|
||||
unsigned int ch;
|
||||
int len;
|
||||
@@ -590,15 +590,15 @@ char *ReadIdentifier(const char *p) {
|
||||
start = p;
|
||||
len = 0;
|
||||
for (;;) {
|
||||
ch = (unsigned char) *p;
|
||||
if (cprep_idarray[ch]) {
|
||||
ch = *p;
|
||||
if (cprep_idarray[(unsigned char) *p]) {
|
||||
if (len < 255)
|
||||
buf[len++] = *p;
|
||||
p++;
|
||||
} else {
|
||||
if (copts.multibyteaware) {
|
||||
if ((unsigned char) *p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
|
||||
if (p[2] == '\n')
|
||||
if ((unsigned char) *p == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
@@ -607,8 +607,8 @@ char *ReadIdentifier(const char *p) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((unsigned char) *p == '\\' && p[1] == '\r') {
|
||||
if (p[2] == '\n')
|
||||
if ((unsigned char) *p == '\\' && p[1] == CR) {
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
@@ -621,7 +621,7 @@ char *ReadIdentifier(const char *p) {
|
||||
}
|
||||
|
||||
buf[len] = 0;
|
||||
tkidentifier = GetHashNameNodeExport(buf);
|
||||
tkidentifier = GetHashNameNodeExport((char *) buf);
|
||||
return (char *) p;
|
||||
}
|
||||
|
||||
@@ -807,14 +807,14 @@ static SInt32 nextchar(StringPtr str) {
|
||||
case 'f': return 12;
|
||||
case 'n':
|
||||
if (copts.mpwc_newline)
|
||||
return 13;
|
||||
return CR;
|
||||
else
|
||||
return 10;
|
||||
return LF;
|
||||
case 'r':
|
||||
if (copts.mpwc_newline)
|
||||
return 10;
|
||||
return LF;
|
||||
else
|
||||
return 13;
|
||||
return CR;
|
||||
case 'e': return 27;
|
||||
case 'x':
|
||||
chr = tohex(prepnextstringchar(str, 1));
|
||||
@@ -874,26 +874,26 @@ StringPtr CPrep_SkipNewComment(StringPtr str) {
|
||||
p[-1] = ' ';
|
||||
continue;
|
||||
|
||||
case '\r':
|
||||
CPrep_SkipNewCommentChar = '\r';
|
||||
case CR:
|
||||
CPrep_SkipNewCommentChar = CR;
|
||||
return p;
|
||||
|
||||
case '\\':
|
||||
if (copts.multibyteaware && COS_IsMultiByte(str, p - 1))
|
||||
continue;
|
||||
|
||||
if (*p == '\r') {
|
||||
if (*p == CR) {
|
||||
++p;
|
||||
foundnl();
|
||||
}
|
||||
|
||||
if (*p == '\n')
|
||||
if (*p == LF)
|
||||
p++;
|
||||
continue;
|
||||
|
||||
case '"':
|
||||
if (InlineAsm_gccmode) {
|
||||
CPrep_SkipNewCommentChar = '\r';
|
||||
CPrep_SkipNewCommentChar = CR;
|
||||
return p - 1;
|
||||
}
|
||||
continue;
|
||||
@@ -910,7 +910,7 @@ Boolean skipendoflinematch(StringPtr str, short token) {
|
||||
while (1) {
|
||||
switch (*(str++)) {
|
||||
case 0:
|
||||
case '\r':
|
||||
case CR:
|
||||
pos = (char *) str - 1;
|
||||
return 0;
|
||||
|
||||
@@ -937,16 +937,16 @@ Boolean skipendoflinematch(StringPtr str, short token) {
|
||||
pos = (char *) str - 1;
|
||||
return 0;
|
||||
|
||||
case '\r':
|
||||
case CR:
|
||||
foundnl();
|
||||
if (*str == '\n')
|
||||
if (*str == LF)
|
||||
str++;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case '?':
|
||||
if (copts.trigraphs && str[0] == '?' && str[1] == '/' && str[2] == '\r') {
|
||||
if (copts.trigraphs && str[0] == '?' && str[1] == '/' && str[2] == CR) {
|
||||
foundnl();
|
||||
str += 3;
|
||||
}
|
||||
@@ -966,7 +966,7 @@ void skipendofline(void) {
|
||||
while (1) {
|
||||
switch (*(p++)) {
|
||||
case 0:
|
||||
case '\r':
|
||||
case CR:
|
||||
pos = (char *) p - 1;
|
||||
return;
|
||||
|
||||
@@ -984,17 +984,17 @@ void skipendofline(void) {
|
||||
|
||||
case '/':
|
||||
if (copts.multibyteaware) {
|
||||
while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
|
||||
while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
}
|
||||
} else {
|
||||
while (*p == '\\' && p[1] == '\r') {
|
||||
while (*p == '\\' && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
@@ -1004,7 +1004,7 @@ void skipendofline(void) {
|
||||
if (*p == '/' && (!copts.ANSIstrict || copts.cplusplus)) {
|
||||
// EOL comment
|
||||
pos = (char *) CPrep_SkipNewComment(p + 1);
|
||||
if (CPrep_SkipNewCommentChar == '\r')
|
||||
if (CPrep_SkipNewCommentChar == CR)
|
||||
pos--;
|
||||
return;
|
||||
}
|
||||
@@ -1026,17 +1026,17 @@ void skipendofline(void) {
|
||||
|
||||
if (ch == '*') {
|
||||
if (copts.multibyteaware) {
|
||||
while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
|
||||
while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
}
|
||||
} else {
|
||||
while (*p == '\\' && p[1] == '\r') {
|
||||
while (*p == '\\' && p[1] == CR) {
|
||||
foundnl();
|
||||
if (p[2] == '\n')
|
||||
if (p[2] == LF)
|
||||
p += 3;
|
||||
else
|
||||
p += 2;
|
||||
@@ -1049,7 +1049,7 @@ void skipendofline(void) {
|
||||
}
|
||||
}
|
||||
|
||||
if (ch == '\r')
|
||||
if (ch == CR)
|
||||
foundnl();
|
||||
}
|
||||
}
|
||||
@@ -1059,9 +1059,9 @@ void skipendofline(void) {
|
||||
if (copts.multibyteaware && COS_IsMultiByte(start, p - 1))
|
||||
continue;
|
||||
|
||||
if (*p == '\r') {
|
||||
if (*p == CR) {
|
||||
foundnl();
|
||||
if (p[1] == '\n')
|
||||
if (p[1] == LF)
|
||||
p += 2;
|
||||
else
|
||||
p += 1;
|
||||
@@ -1069,7 +1069,7 @@ void skipendofline(void) {
|
||||
break;
|
||||
|
||||
case '?':
|
||||
if (copts.trigraphs && p[0] == '?' && p[1] == '/' && p[2] == '\r') {
|
||||
if (copts.trigraphs && p[0] == '?' && p[1] == '/' && p[2] == CR) {
|
||||
foundnl();
|
||||
p += 3;
|
||||
}
|
||||
@@ -1106,7 +1106,7 @@ static short tapos(short _t) {
|
||||
|
||||
start = (StringPtr) pos;
|
||||
t = nextchar((StringPtr) pos);
|
||||
if ((t == '\'' || t == 0 || t == '\r') && !was_escchar) {
|
||||
if ((t == '\'' || t == 0 || t == CR) && !was_escchar) {
|
||||
CPrep_Error(CErrorStr100);
|
||||
tkintconst = cint64_zero;
|
||||
tksize = IT_INT;
|
||||
@@ -1169,7 +1169,7 @@ static short tapos(short _t) {
|
||||
i = bytecount;
|
||||
|
||||
while (1) {
|
||||
if ((t2 == 0 || t2 == '\r') && !was_escchar) {
|
||||
if ((t2 == 0 || t2 == CR) && !was_escchar) {
|
||||
CPrep_Error(CErrorStr100);
|
||||
break;
|
||||
}
|
||||
@@ -1201,7 +1201,7 @@ static short tapos(short _t) {
|
||||
|
||||
static short tquot(short t) {
|
||||
Type *type;
|
||||
StringPtr string_ptr;
|
||||
char *string_ptr;
|
||||
SInt32 size;
|
||||
short c;
|
||||
StringPtr save_pos;
|
||||
@@ -1213,7 +1213,7 @@ static short tquot(short t) {
|
||||
if (cprep_nostring)
|
||||
return '"';
|
||||
|
||||
string_ptr = (StringPtr) *stringmem;
|
||||
string_ptr = *stringmem;
|
||||
ispascalstring = 0;
|
||||
size = 0;
|
||||
if (widestring)
|
||||
@@ -1235,7 +1235,7 @@ static short tquot(short t) {
|
||||
|
||||
while (1) {
|
||||
c = nextchar(start_pos);
|
||||
if ((c == '"' || c == '\r' || c == 0) && !was_escchar) {
|
||||
if ((c == '"' || c == CR || c == 0) && !was_escchar) {
|
||||
if (c == 0 && (tokenstacklevel > 0 || pos >= prep_file_end))
|
||||
CPrep_Error(CErrorStr102);
|
||||
else if (c != '"')
|
||||
@@ -1243,10 +1243,10 @@ static short tquot(short t) {
|
||||
break;
|
||||
}
|
||||
if ((size + type->size) >= maxstringsize) {
|
||||
SInt32 offset = string_ptr - (StringPtr) *stringmem;
|
||||
SInt32 offset = string_ptr - *stringmem;
|
||||
if (!COS_ResizeHandle(stringmem, maxstringsize += 256))
|
||||
CError_NoMem();
|
||||
string_ptr = (StringPtr) *stringmem + offset;
|
||||
string_ptr = *stringmem + offset;
|
||||
}
|
||||
if (type->size != 1) {
|
||||
CInt64_SetLong(&ch64, c);
|
||||
@@ -2242,7 +2242,7 @@ typedef struct StringChunk {
|
||||
} StringChunk;
|
||||
|
||||
static void CPrep_StringConCat(Boolean flag) {
|
||||
StringPtr buffer;
|
||||
char *buffer;
|
||||
StringChunk *chunks;
|
||||
StringChunk *chunk;
|
||||
char *saveString;
|
||||
@@ -2287,7 +2287,7 @@ static void CPrep_StringConCat(Boolean flag) {
|
||||
}
|
||||
|
||||
elem = ts_current - 1;
|
||||
elem->data.tkstring.data = (char *) buffer;
|
||||
elem->data.tkstring.data = buffer;
|
||||
elem->data.tkstring.size = offset;
|
||||
elem->subtype = ispascalstring;
|
||||
cprep_strconcat = 0;
|
||||
|
||||
@@ -1442,7 +1442,7 @@ Type *CScope_GetTagType(NameSpace *nspace, HashNameNode *name) {
|
||||
|
||||
static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTemplDep *ttempldep, Boolean flag1, Boolean flag2) {
|
||||
SInt32 streamstate;
|
||||
short token;
|
||||
int token;
|
||||
TypeTemplDep *newtype;
|
||||
TypeTemplDep *newtype2;
|
||||
|
||||
@@ -2537,30 +2537,30 @@ void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, Hash
|
||||
|
||||
void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access, Boolean flag) {
|
||||
NameSpace *saveNSpace;
|
||||
Boolean flag_r27;
|
||||
Boolean flag_r26;
|
||||
Boolean isTemplate;
|
||||
Boolean isTypename;
|
||||
NameSpaceObjectList *scan;
|
||||
CScopeParseResult result;
|
||||
|
||||
if (nspace->theclass) {
|
||||
flag_r27 = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) ? 1 : 0;
|
||||
flag_r26 = 0;
|
||||
isTemplate = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) != 0;
|
||||
isTypename = 0;
|
||||
if (tk == TK_TYPENAME) {
|
||||
if (!flag_r27)
|
||||
if (!isTemplate)
|
||||
CError_Error(CErrorStr200);
|
||||
flag_r26 = 1;
|
||||
isTypename = 1;
|
||||
tk = lex();
|
||||
}
|
||||
|
||||
if (!CScope_ParseMemberName(nspace->theclass, &result, flag_r27)) {
|
||||
if (!CScope_ParseMemberName(nspace->theclass, &result, isTemplate)) {
|
||||
CError_Error(CErrorStr200);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.x8 && IS_TYPE_TEMPLATE(result.x8) && TYPE_TEMPLATE(result.x8)->dtype == TEMPLDEP_QUALNAME) {
|
||||
CError_ASSERT(3578, flag_r27);
|
||||
CError_ASSERT(3578, isTemplate);
|
||||
|
||||
if (flag_r26) {
|
||||
if (isTypename) {
|
||||
ObjType *objtype = galloc(sizeof(ObjType));
|
||||
memclrw(objtype, sizeof(ObjType));
|
||||
objtype->otype = OT_TYPE;
|
||||
|
||||
Reference in New Issue
Block a user