comparison lwasm/pseudo.c @ 384:6ee9c67a0f8d

Add conditional for testing if a pragma is in effect An obvious addition that took someone else to notice... Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Mon, 13 Jul 2015 21:20:30 -0600
parents 80d615a6642c
children f2decd9b276d
comparison
equal deleted inserted replaced
383:04e11f6faead 384:6ee9c67a0f8d
1367 as -> skipcount = 1; 1367 as -> skipcount = 1;
1368 return; 1368 return;
1369 } 1369 }
1370 } 1370 }
1371 1371
1372 PARSEFUNC(pseudo_parse_ifpragma)
1373 {
1374 char *pstr;
1375 int i;
1376 int pragma;
1377 int compare;
1378
1379 l -> len = 0;
1380 l -> hideline = 1;
1381
1382 if (as -> skipcond && !(as -> skipmacro))
1383 {
1384 as -> skipcount++;
1385 skip_operand(p);
1386 return;
1387 }
1388
1389 again:
1390 for (i = 0; (*p)[i] && !isspace((*p)[i]) && (*p)[i] != '|' && (*p)[i] != '&'; i++)
1391 /* do nothing */;
1392
1393 pstr = lw_strndup(*p, i);
1394 (*p) += i;
1395
1396 pragma = parse_pragma_helper(pstr);
1397 if (!pragma) lwasm_register_error(as, l, E_PRAGMA_UNRECOGNIZED);
1398
1399 lw_free(pstr);
1400
1401 if (pragma & PRAGMA_CLEARBIT)
1402 {
1403 pragma &= ~PRAGMA_CLEARBIT; /* strip off flag bit */
1404 compare = l -> pragmas & pragma ? 0 : 1;
1405 }
1406 else
1407 {
1408 compare = l -> pragmas & pragma;
1409 }
1410
1411 if (!compare)
1412 {
1413 if (**p == '|')
1414 {
1415 (*p)++;
1416 goto again;
1417 }
1418 as -> skipcond = 1;
1419 as -> skipcount = 1;
1420 }
1421 skip_operand(p);
1422 }
1423
1372 PARSEFUNC(pseudo_parse_error) 1424 PARSEFUNC(pseudo_parse_error)
1373 { 1425 {
1374 lwasm_register_error2(as, l, E_USER_SPECIFIED, "%s", *p); 1426 lwasm_register_error2(as, l, E_USER_SPECIFIED, "%s", *p);
1375 skip_operand(p); 1427 skip_operand(p);
1376 } 1428 }