removed debug code

fixed defined() not working with no spaces afterward.
fixed preprocessor not ignoring string literals

--HG--
branch : dvander
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/dvander%4012
This commit is contained in:
David Anderson 2006-07-14 05:51:25 +00:00
parent 4825f2ce40
commit cc6e3f9fab

View File

@ -715,7 +715,7 @@ static int ftoi(cell *val,const unsigned char *curptr)
#if PAWN_CELL_SIZE==32 #if PAWN_CELL_SIZE==32
float value=(float)fnum; float value=(float)fnum;
*val=*((cell *)&value); *val=*((cell *)&value);
#if !defined NDEBUG #if 0 /* SourceMod - not needed */
/* I assume that the C/C++ compiler stores "float" values in IEEE 754 /* I assume that the C/C++ compiler stores "float" values in IEEE 754
* format (as mandated in the ANSI standard). Test this assumption * format (as mandated in the ANSI standard). Test this assumption
* anyway. * anyway.
@ -733,7 +733,7 @@ static int ftoi(cell *val,const unsigned char *curptr)
#endif #endif
#elif PAWN_CELL_SIZE==64 #elif PAWN_CELL_SIZE==64
*val=*((cell *)&fnum); *val=*((cell *)&fnum);
#if !defined NDEBUG #if 0 /* SourceMod - not needed */
/* I assume that the C/C++ compiler stores "double" values in IEEE 754 /* I assume that the C/C++ compiler stores "double" values in IEEE 754
* format (as mandated in the ANSI standard). * format (as mandated in the ANSI standard).
*/ */
@ -1456,7 +1456,7 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char
int prefixlen; int prefixlen;
const unsigned char *p,*s,*e; const unsigned char *p,*s,*e;
unsigned char *args[10]; unsigned char *args[10];
int match,arg,len; int match,arg,len,argsnum=0;
memset(args,0,sizeof args); memset(args,0,sizeof args);
@ -1496,6 +1496,8 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char
/* store the parameter (overrule any earlier) */ /* store the parameter (overrule any earlier) */
if (args[arg]!=NULL) if (args[arg]!=NULL)
free(args[arg]); free(args[arg]);
else
argsnum++;
len=(int)(e-s); len=(int)(e-s);
args[arg]=(unsigned char*)malloc(len+1); args[arg]=(unsigned char*)malloc(len+1);
if (args[arg]==NULL) if (args[arg]==NULL)
@ -1551,14 +1553,15 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char
if (match) { if (match) {
/* calculate the length of the substituted string */ /* calculate the length of the substituted string */
for (e=(unsigned char*)substitution,len=0; *e!='\0'; e++) { for (e=(unsigned char*)substitution,len=0; *e!='\0'; e++) {
if (*e=='%' && isdigit(*(e+1))) { if (*e=='%' && isdigit(*(e+1)) && argsnum) {
arg=*(e+1)-'0'; arg=*(e+1)-'0';
assert(arg>=0 && arg<=9); assert(arg>=0 && arg<=9);
if (args[arg]!=NULL) if (args[arg]!=NULL) {
len+=strlen((char*)args[arg]); len+=strlen((char*)args[arg]);
else e++;
len+=2; /* copy '%' plus digit */ } else {
e++; /* skip %, digit is skipped later */ len++;
}
} else { } else {
len++; len++;
} /* if */ } /* if */
@ -1576,12 +1579,23 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char
if (args[arg]!=NULL) { if (args[arg]!=NULL) {
strins((char*)s,(char*)args[arg],strlen((char*)args[arg])); strins((char*)s,(char*)args[arg],strlen((char*)args[arg]));
s+=strlen((char*)args[arg]); s+=strlen((char*)args[arg]);
e++;
} else { } else {
error(236); /* parameter does not exist, incorrect #define pattern */ error(236); /* parameter does not exist, incorrect #define pattern */
strins((char*)s,(char*)e,2); strins((char*)s,(char*)e,2);
s+=2; s+=2;
} /* if */ } /* if */
e++; /* skip %, digit is skipped later */ e++; /* skip %, digit is skipped later */
} else if (*e == '"') {
p=e;
if (is_startstring(e)) {
e=skipstring(e);
strins((char*)s,(char *)p,(e-p+1));
s+=(e-p+1);
} else {
strins((char*)s,(char*)e,1);
s++;
}
} else { } else {
strins((char*)s,(char*)e,1); strins((char*)s,(char*)e,1);
s++; s++;
@ -1620,7 +1634,7 @@ static void substallpatterns(unsigned char *line,int buffersize)
if (*start=='\0') if (*start=='\0')
break; /* abort loop on error */ break; /* abort loop on error */
/* if matching the operator "defined", skip it plus the symbol behind it */ /* if matching the operator "defined", skip it plus the symbol behind it */
if (strncmp((char*)start,"defined",7)==0 && *(start+7)<=' ') { if (strncmp((char*)start,"defined",7)==0 && !isalpha((char)*(start+7))) {
start+=7; /* skip "defined" */ start+=7; /* skip "defined" */
/* skip white space & parantheses */ /* skip white space & parantheses */
while (*start<=' ' && *start!='\0' || *start=='(') while (*start<=' ' && *start!='\0' || *start=='(')