Mercurial > hg > index.cgi
comparison lwasm/pseudo.c @ 561:a6a9d46f071f
Make ifdef and ifndef complain if they aren't given a symbol
If makes no sense to test "nothing" for definedness. If no symbol is
provided to ifdef or ifndef, complain about a bad operand.
author | William Astle <lost@l-w.ca> |
---|---|
date | Thu, 30 Nov 2023 16:54:12 -0700 |
parents | ddc7b05a5675 |
children | 87f904e2b304 |
comparison
equal
deleted
inserted
replaced
560:dba08c7dff96 | 561:a6a9d46f071f |
---|---|
1340 } | 1340 } |
1341 | 1341 |
1342 again: | 1342 again: |
1343 for (i = 0; (*p)[i] && !isspace((*p)[i]) && (*p)[i] != '|' && (*p)[i] != '&'; i++) | 1343 for (i = 0; (*p)[i] && !isspace((*p)[i]) && (*p)[i] != '|' && (*p)[i] != '&'; i++) |
1344 /* do nothing */ ; | 1344 /* do nothing */ ; |
1345 | |
1346 if (i == 0) | |
1347 { | |
1348 lwasm_register_error(as, l, E_OPERAND_BAD); | |
1349 return; | |
1350 } | |
1345 | 1351 |
1346 sym = lw_strndup(*p, i); | 1352 sym = lw_strndup(*p, i); |
1347 (*p) += i; | 1353 (*p) += i; |
1348 | 1354 |
1349 s = lookup_symbol(as, l, sym); | 1355 s = lookup_symbol(as, l, sym); |
1380 return; | 1386 return; |
1381 } | 1387 } |
1382 for (i = 0; (*p)[i] && !isspace((*p)[i]) && (*p)[i] != '&' && (*p)[i] != '|'; i++) | 1388 for (i = 0; (*p)[i] && !isspace((*p)[i]) && (*p)[i] != '&' && (*p)[i] != '|'; i++) |
1383 /* do nothing */ ; | 1389 /* do nothing */ ; |
1384 | 1390 |
1391 if (i == 0) | |
1392 { | |
1393 lwasm_register_error(as, l, E_OPERAND_BAD); | |
1394 return; | |
1395 } | |
1396 | |
1385 sym = lw_strndup(*p, i); | 1397 sym = lw_strndup(*p, i); |
1386 (*p) += i; | 1398 (*p) += i; |
1387 | 1399 |
1388 s = lookup_symbol(as, l, sym); | 1400 s = lookup_symbol(as, l, sym); |
1389 | 1401 |