GNU Binutils with patches for OS216
リビジョン | 25065fcd192d9958c03e107985aea41d651e4a16 (tree) |
---|---|
日時 | 2020-06-10 18:07:26 |
作者 | Ralf Habacker <ralf.habacker@free...> |
コミッター | Nick Clifton |
Fix the windmc program to conform to the behaviour of mc.exe by rejecting lines that reach end-of-file without a terminating newline character.
PR 26082
* mclex.c (yylex): Reject lines that reach end-of-file without a
terminating newline character.
@@ -1,3 +1,9 @@ | ||
1 | +2020-06-10 Ralf Habacker <ralf.habacker@freenet.de> | |
2 | + | |
3 | + PR 26082 | |
4 | + * mclex.c (yylex): Reject lines that reach end-of-file without a | |
5 | + terminating newline character. | |
6 | + | |
1 | 7 | 2020-06-08 Nick Clifton <nickc@redhat.com> |
2 | 8 | |
3 | 9 | PR 26093 |
@@ -323,6 +323,21 @@ mc_token (const unichar *t, size_t len) | ||
323 | 323 | return -1; |
324 | 324 | } |
325 | 325 | |
326 | +/* Skip characters in input_stream_pos up to and including a newline | |
327 | + character. Returns non-zero if the newline was found, zero otherwise. */ | |
328 | + | |
329 | +static int | |
330 | +skip_until_eol (void) | |
331 | +{ | |
332 | + while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n') | |
333 | + ++input_stream_pos; | |
334 | + if (input_stream_pos[0] == 0) | |
335 | + return 0; | |
336 | + if (input_stream_pos[0] == '\n') | |
337 | + ++input_stream_pos; | |
338 | + return 1; | |
339 | +} | |
340 | + | |
326 | 341 | int |
327 | 342 | yylex (void) |
328 | 343 | { |
@@ -334,29 +349,28 @@ yylex (void) | ||
334 | 349 | fatal ("Input stream not setuped.\n"); |
335 | 350 | return -1; |
336 | 351 | } |
352 | + | |
337 | 353 | if (mclex_want_line) |
338 | 354 | { |
339 | 355 | start_token = input_stream_pos; |
340 | 356 | if (input_stream_pos[0] == 0) |
341 | 357 | return -1; |
358 | + /* PR 26082: Reject a period followed by EOF. */ | |
359 | + if (input_stream_pos[0] == '.' && input_stream_pos[1] == 0) | |
360 | + return -1; | |
342 | 361 | if (input_stream_pos[0] == '.' |
343 | 362 | && (input_stream_pos[1] == '\n' |
344 | 363 | || (input_stream_pos[1] == '\r' && input_stream_pos[2] == '\n'))) |
345 | 364 | { |
346 | 365 | mclex_want_line = FALSE; |
347 | - while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n') | |
348 | - ++input_stream_pos; | |
349 | - if (input_stream_pos[0] == '\n') | |
350 | - ++input_stream_pos; | |
351 | - return MCENDLINE; | |
366 | + return skip_until_eol () ? MCENDLINE : -1; | |
352 | 367 | } |
353 | - while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n') | |
354 | - ++input_stream_pos; | |
355 | - if (input_stream_pos[0] == '\n') | |
356 | - ++input_stream_pos; | |
368 | + if (!skip_until_eol ()) | |
369 | + return -1; | |
357 | 370 | yylval.ustr = get_diff (input_stream_pos, start_token); |
358 | 371 | return MCLINE; |
359 | 372 | } |
373 | + | |
360 | 374 | while ((ch = input_stream_pos[0]) <= 0x20) |
361 | 375 | { |
362 | 376 | if (ch == 0) |
@@ -404,10 +418,8 @@ yylex (void) | ||
404 | 418 | { |
405 | 419 | case ';': |
406 | 420 | ++start_token; |
407 | - while (input_stream_pos[0] != '\n' && input_stream_pos[0] != 0) | |
408 | - ++input_stream_pos; | |
409 | - if (input_stream_pos[0] == '\n') | |
410 | - input_stream_pos++; | |
421 | + if (!skip_until_eol ()) | |
422 | + return -1; | |
411 | 423 | yylval.ustr = get_diff (input_stream_pos, start_token); |
412 | 424 | return MCCOMMENT; |
413 | 425 | case '=': |