Mercurial > hg > index.cgi
comparison lwasm/macro.c @ 524:a4a58c4c7a41
Fix parsing {} macro argument expansion sequences
{nn} sequences were consuming one too many characters which caused
unpredictable and definitely incorrect behaviour if the {nn} sequence
terminated the line. It also caused the next character after the } to be
ignored if used in the middle of an argument sequence.
author | William Astle <lost@l-w.ca> |
---|---|
date | Tue, 25 Jan 2022 21:25:12 -0700 |
parents | 5524649f4784 |
children | 4536f0e61425 |
comparison
equal
deleted
inserted
replaced
523:1744f2d1a821 | 524:a4a58c4c7a41 |
---|---|
275 if (n2 < 0 || n2 > 9) | 275 if (n2 < 0 || n2 > 9) |
276 n2 = 0; | 276 n2 = 0; |
277 n = n * 10 + n2; | 277 n = n * 10 + n2; |
278 p2++; | 278 p2++; |
279 } | 279 } |
280 if (*p2 == '}') | 280 // compensate for the autoinc on p2 if no } is present |
281 p2++; | 281 // to prevent overconsuming input characters |
282 if (*p2 != '}') | |
283 p2--; | |
282 | 284 |
283 if (n == 0) | 285 if (n == 0) |
284 { | 286 { |
285 for (p3 = m -> name; *p3; p3++) | 287 for (p3 = m -> name; *p3; p3++) |
286 macro_add_to_buff(&linebuff, &bloc, &blen, *p3); | 288 macro_add_to_buff(&linebuff, &bloc, &blen, *p3); |