compiler-init/sc2.c
branchdvander
changeset 11 da40c5d58f3a
parent 1 bf68e1639dba
child 12 eb7fdaaf48a3
     1.1 --- a/compiler-init/sc2.c	Fri Jul 14 04:51:58 2006 +0000
     1.2 +++ b/compiler-init/sc2.c	Fri Jul 14 05:51:25 2006 +0000
     1.3 @@ -715,7 +715,7 @@
     1.4      #if PAWN_CELL_SIZE==32
     1.5        float value=(float)fnum;
     1.6        *val=*((cell *)&value);
     1.7 -      #if !defined NDEBUG
     1.8 +      #if 0 /* SourceMod - not needed */
     1.9          /* I assume that the C/C++ compiler stores "float" values in IEEE 754
    1.10           * format (as mandated in the ANSI standard). Test this assumption
    1.11           * anyway.
    1.12 @@ -733,7 +733,7 @@
    1.13        #endif
    1.14      #elif PAWN_CELL_SIZE==64
    1.15        *val=*((cell *)&fnum);
    1.16 -      #if !defined NDEBUG
    1.17 +      #if 0 /* SourceMod - not needed */
    1.18          /* I assume that the C/C++ compiler stores "double" values in IEEE 754
    1.19           * format (as mandated in the ANSI standard).
    1.20           */
    1.21 @@ -1456,7 +1456,7 @@
    1.22    int prefixlen;
    1.23    const unsigned char *p,*s,*e;
    1.24    unsigned char *args[10];
    1.25 -  int match,arg,len;
    1.26 +  int match,arg,len,argsnum=0;
    1.27  
    1.28    memset(args,0,sizeof args);
    1.29  
    1.30 @@ -1496,6 +1496,8 @@
    1.31          /* store the parameter (overrule any earlier) */
    1.32          if (args[arg]!=NULL)
    1.33            free(args[arg]);
    1.34 +		else
    1.35 +          argsnum++;
    1.36          len=(int)(e-s);
    1.37          args[arg]=(unsigned char*)malloc(len+1);
    1.38          if (args[arg]==NULL)
    1.39 @@ -1551,14 +1553,15 @@
    1.40    if (match) {
    1.41      /* calculate the length of the substituted string */
    1.42      for (e=(unsigned char*)substitution,len=0; *e!='\0'; e++) {
    1.43 -      if (*e=='%' && isdigit(*(e+1))) {
    1.44 +      if (*e=='%' && isdigit(*(e+1)) && argsnum) {
    1.45          arg=*(e+1)-'0';
    1.46          assert(arg>=0 && arg<=9);
    1.47 -        if (args[arg]!=NULL)
    1.48 +        if (args[arg]!=NULL) {
    1.49            len+=strlen((char*)args[arg]);
    1.50 -        else
    1.51 -          len+=2;     /* copy '%' plus digit */
    1.52 -        e++;          /* skip %, digit is skipped later */
    1.53 +          e++;
    1.54 +        } else {
    1.55 +          len++;
    1.56 +        }
    1.57        } else {
    1.58          len++;
    1.59        } /* if */
    1.60 @@ -1576,12 +1579,23 @@
    1.61            if (args[arg]!=NULL) {
    1.62              strins((char*)s,(char*)args[arg],strlen((char*)args[arg]));
    1.63              s+=strlen((char*)args[arg]);
    1.64 +            e++;
    1.65            } else {
    1.66              error(236); /* parameter does not exist, incorrect #define pattern */
    1.67              strins((char*)s,(char*)e,2);
    1.68              s+=2;
    1.69            } /* if */
    1.70            e++;          /* skip %, digit is skipped later */
    1.71 +		} else if (*e == '"') {
    1.72 +			p=e;
    1.73 +			if (is_startstring(e)) {
    1.74 +				e=skipstring(e);
    1.75 +				strins((char*)s,(char *)p,(e-p+1));
    1.76 +				s+=(e-p+1);
    1.77 +			} else {
    1.78 +				strins((char*)s,(char*)e,1);
    1.79 +				s++;
    1.80 +			}
    1.81          } else {
    1.82            strins((char*)s,(char*)e,1);
    1.83            s++;
    1.84 @@ -1620,7 +1634,7 @@
    1.85      if (*start=='\0')
    1.86        break;            /* abort loop on error */
    1.87      /* if matching the operator "defined", skip it plus the symbol behind it */
    1.88 -    if (strncmp((char*)start,"defined",7)==0 && *(start+7)<=' ') {
    1.89 +	if (strncmp((char*)start,"defined",7)==0 && !isalpha((char)*(start+7))) {
    1.90        start+=7;         /* skip "defined" */
    1.91        /* skip white space & parantheses */
    1.92        while (*start<=' ' && *start!='\0' || *start=='(')