@@ -1213,11 +1213,11 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
1213
1213
case 'w' :
1214
1214
i = (int )strtol (option_value (ptr ),(char * * )& ptr ,10 );
1215
1215
if (* ptr == '-' )
1216
- pc_enablewarning (i ,0 );
1216
+ pc_enablewarning (i ,warnDISABLE );
1217
1217
else if (* ptr == '+' )
1218
- pc_enablewarning (i ,1 );
1218
+ pc_enablewarning (i ,warnENABLE );
1219
1219
else if (* ptr == '\0' )
1220
- pc_enablewarning (i ,2 );
1220
+ pc_enablewarning (i ,warnTOGGLE );
1221
1221
break ;
1222
1222
case 'X' :
1223
1223
if (* (ptr + 1 )== 'D' ) {
@@ -8165,7 +8165,6 @@ static void dopragma(void)
8165
8165
int tok ;
8166
8166
int bck_litidx ,bck_packstr ;
8167
8167
int i ;
8168
- int hasparams ;
8169
8168
cell val ;
8170
8169
char * str ;
8171
8170
@@ -8200,7 +8199,7 @@ static void dopragma(void)
8200
8199
assert (litidx > bck_litidx );
8201
8200
8202
8201
/* the user shouldn't prepend "!" to the option string */
8203
- if (litq [val ]<=UNPACKEDMAX ) {
8202
+ if (litq [val ]<=UNPACKEDMAX && litq [ val ] != 0 ) {
8204
8203
error (1 ,sc_tokens [tSTRING - tFIRST ],"!" );
8205
8204
goto next ;
8206
8205
} /* if */
@@ -8230,11 +8229,13 @@ static void dopragma(void)
8230
8229
8231
8230
/* split the option name from parameters */
8232
8231
str = (char * )& litq [val ];
8233
- for (i = 0 ; str [i ]!= '\0' && str [i ]!= ' ' ; i ++ ) {}
8234
- hasparams = (str [i ]!= '\0' );
8235
- str [i ]= '\0' ;
8236
- if (hasparams )
8237
- while (str [++ i ]== ' ' ) {}
8232
+ for (i = 0 ; str [i ]!= '\0' && str [i ]!= ' ' ; i ++ )
8233
+ /* nothing */ ;
8234
+ if (str [i ]!= '\0' ) {
8235
+ str [i ]= '\0' ;
8236
+ while (str [++ i ]== ' ' )
8237
+ /* nothing */ ;
8238
+ } /* if */
8238
8239
8239
8240
/* check the option name, set the corresponding attribute flag
8240
8241
* and parse the argument(s), if needed */
@@ -8246,15 +8247,48 @@ static void dopragma(void)
8246
8247
pc_attributes |= (1U << attrDEPRECATED );
8247
8248
} else if (!strcmp (str ,"unused" )) {
8248
8249
pc_attributes |= (1U << attrUNUSED );
8250
+ if (str [i ]!= '\0' ) goto unknown_pragma ;
8249
8251
} else if (!strcmp (str ,"unread" )) {
8250
8252
pc_attributes |= (1U << attrUNREAD );
8253
+ if (str [i ]!= '\0' ) goto unknown_pragma ;
8251
8254
} else if (!strcmp (str ,"unwritten" )) {
8252
8255
pc_attributes |= (1U << attrUNWRITTEN );
8256
+ if (str [i ]!= '\0' ) goto unknown_pragma ;
8253
8257
} else if (!strcmp (str ,"nodestruct" )) {
8254
8258
pc_attributes |= (1U << attrNODESTRUCT );
8259
+ if (str [i ]!= '\0' ) goto unknown_pragma ;
8255
8260
} else if (!strcmp (str ,"naked" )) {
8256
8261
pc_attributes |= (1U << attrNAKED );
8262
+ if (str [i ]!= '\0' ) goto unknown_pragma ;
8263
+ } else if (!strcmp (str ,"warning" )) {
8264
+ str += i ;
8265
+ while (* str == ' ' ) str ++ ;
8266
+ for (i = 0 ; str [i ]!= '\0' && str [i ]!= ' ' ; i ++ )
8267
+ /* nothing */ ;
8268
+ if (str [i ]!= '\0' ) {
8269
+ str [i ]= '\0' ;
8270
+ while (str [++ i ]== ' ' )
8271
+ /* nothing */ ;
8272
+ } /* if */
8273
+ if (strcmp (str ,"enable" )== 0 || strcmp (str ,"disable" )== 0 ) {
8274
+ int len = number (& val ,& str [i ]);
8275
+ if (len == 0 )
8276
+ goto unknown_pragma ;
8277
+ pc_enablewarning ((int )val ,(str [0 ]== 'e' ) ? warnENABLE : warnDISABLE );
8278
+ /* warn if there are extra characters after the warning number */
8279
+ for (i += len ; str [i ]== ' ' ; i ++ )
8280
+ /* nothing */ ;
8281
+ if (str [i ]!= '\0' )
8282
+ goto unknown_pragma ;
8283
+ } else if (strcmp (str ,"push" )== 0 && str [i ]== '\0' ) {
8284
+ pc_pushwarnings ();
8285
+ } else if (strcmp (str ,"pop" )== 0 && str [i ]== '\0' ) {
8286
+ pc_popwarnings ();
8287
+ } else {
8288
+ goto unknown_pragma ;
8289
+ } /* if */
8257
8290
} else {
8291
+ unknown_pragma :
8258
8292
error (207 ); /* unknown #pragma */
8259
8293
} /* if */
8260
8294
0 commit comments