| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: lexi.c,v 1.32 2021/03/11 21:47:36 rillig Exp $ */ | | 1 | /* $NetBSD: lexi.c,v 1.33 2021/03/11 22:15:44 rillig Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * SPDX-License-Identifier: BSD-4-Clause | | 4 | * SPDX-License-Identifier: BSD-4-Clause |
5 | * | | 5 | * |
6 | * Copyright (c) 1985 Sun Microsystems, Inc. | | 6 | * Copyright (c) 1985 Sun Microsystems, Inc. |
7 | * Copyright (c) 1980, 1993 | | 7 | * Copyright (c) 1980, 1993 |
8 | * The Regents of the University of California. All rights reserved. | | 8 | * The Regents of the University of California. All rights reserved. |
9 | * All rights reserved. | | 9 | * All rights reserved. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -36,27 +36,27 @@ | | | @@ -36,27 +36,27 @@ |
36 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 36 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
37 | * SUCH DAMAGE. | | 37 | * SUCH DAMAGE. |
38 | */ | | 38 | */ |
39 | | | 39 | |
40 | #if 0 | | 40 | #if 0 |
41 | #ifndef lint | | 41 | #ifndef lint |
42 | static char sccsid[] = "@(#)lexi.c 8.1 (Berkeley) 6/6/93"; | | 42 | static char sccsid[] = "@(#)lexi.c 8.1 (Berkeley) 6/6/93"; |
43 | #endif /* not lint */ | | 43 | #endif /* not lint */ |
44 | #endif | | 44 | #endif |
45 | | | 45 | |
46 | #include <sys/cdefs.h> | | 46 | #include <sys/cdefs.h> |
47 | #ifndef lint | | 47 | #ifndef lint |
48 | #if defined(__NetBSD__) | | 48 | #if defined(__NetBSD__) |
49 | __RCSID("$NetBSD: lexi.c,v 1.32 2021/03/11 21:47:36 rillig Exp $"); | | 49 | __RCSID("$NetBSD: lexi.c,v 1.33 2021/03/11 22:15:44 rillig Exp $"); |
50 | #elif defined(__FreeBSD__) | | 50 | #elif defined(__FreeBSD__) |
51 | __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $"); | | 51 | __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $"); |
52 | #endif | | 52 | #endif |
53 | #endif | | 53 | #endif |
54 | | | 54 | |
55 | /* | | 55 | /* |
56 | * Here we have the token scanner for indent. It scans off one token and puts | | 56 | * Here we have the token scanner for indent. It scans off one token and puts |
57 | * it in the global variable "token". It returns a code, indicating the type | | 57 | * it in the global variable "token". It returns a code, indicating the type |
58 | * of token scanned. | | 58 | * of token scanned. |
59 | */ | | 59 | */ |
60 | | | 60 | |
61 | #include <assert.h> | | 61 | #include <assert.h> |
62 | #include <err.h> | | 62 | #include <err.h> |
| @@ -321,27 +321,27 @@ lexi(struct parser_state *state) | | | @@ -321,27 +321,27 @@ lexi(struct parser_state *state) |
321 | } | | 321 | } |
322 | s = table[i][s - 'A']; | | 322 | s = table[i][s - 'A']; |
323 | check_size_token(1); | | 323 | check_size_token(1); |
324 | *e_token++ = inbuf_next(); | | 324 | *e_token++ = inbuf_next(); |
325 | } | | 325 | } |
326 | /* s now indicates the type: f(loating), i(integer), u(nknown) */ | | 326 | /* s now indicates the type: f(loating), i(integer), u(nknown) */ |
327 | } | | 327 | } |
328 | else | | 328 | else |
329 | while (isalnum((unsigned char)*buf_ptr) || | | 329 | while (isalnum((unsigned char)*buf_ptr) || |
330 | *buf_ptr == '\\' || | | 330 | *buf_ptr == '\\' || |
331 | *buf_ptr == '_' || *buf_ptr == '$') { | | 331 | *buf_ptr == '_' || *buf_ptr == '$') { |
332 | /* fill_buffer() terminates buffer with newline */ | | 332 | /* fill_buffer() terminates buffer with newline */ |
333 | if (*buf_ptr == '\\') { | | 333 | if (*buf_ptr == '\\') { |
334 | if (*(buf_ptr + 1) == '\n') { | | 334 | if (buf_ptr[1] == '\n') { |
335 | buf_ptr += 2; | | 335 | buf_ptr += 2; |
336 | if (buf_ptr >= buf_end) | | 336 | if (buf_ptr >= buf_end) |
337 | fill_buffer(); | | 337 | fill_buffer(); |
338 | } else | | 338 | } else |
339 | break; | | 339 | break; |
340 | } | | 340 | } |
341 | check_size_token(1); | | 341 | check_size_token(1); |
342 | *e_token++ = inbuf_next(); | | 342 | *e_token++ = inbuf_next(); |
343 | } | | 343 | } |
344 | *e_token = '\0'; | | 344 | *e_token = '\0'; |
345 | | | 345 | |
346 | if (s_token[0] == 'L' && s_token[1] == '\0' && | | 346 | if (s_token[0] == 'L' && s_token[1] == '\0' && |
347 | (*buf_ptr == '"' || *buf_ptr == '\'')) | | 347 | (*buf_ptr == '"' || *buf_ptr == '\'')) |
| @@ -640,27 +640,27 @@ stop_lit: | | | @@ -640,27 +640,27 @@ stop_lit: |
640 | } | | 640 | } |
641 | code = unary_op; | | 641 | code = unary_op; |
642 | break; | | 642 | break; |
643 | | | 643 | |
644 | default: | | 644 | default: |
645 | if (token[0] == '/' && (*buf_ptr == '*' || *buf_ptr == '/')) { | | 645 | if (token[0] == '/' && (*buf_ptr == '*' || *buf_ptr == '/')) { |
646 | /* it is start of comment */ | | 646 | /* it is start of comment */ |
647 | *e_token++ = inbuf_next(); | | 647 | *e_token++ = inbuf_next(); |
648 | | | 648 | |
649 | code = comment; | | 649 | code = comment; |
650 | unary_delim = state->last_u_d; | | 650 | unary_delim = state->last_u_d; |
651 | break; | | 651 | break; |
652 | } | | 652 | } |
653 | while (*(e_token - 1) == *buf_ptr || *buf_ptr == '=') { | | 653 | while (e_token[-1] == *buf_ptr || *buf_ptr == '=') { |
654 | /* | | 654 | /* |
655 | * handle ||, &&, etc, and also things as in int *****i | | 655 | * handle ||, &&, etc, and also things as in int *****i |
656 | */ | | 656 | */ |
657 | check_size_token(1); | | 657 | check_size_token(1); |
658 | *e_token++ = inbuf_next(); | | 658 | *e_token++ = inbuf_next(); |
659 | } | | 659 | } |
660 | code = (state->last_u_d ? unary_op : binary_op); | | 660 | code = (state->last_u_d ? unary_op : binary_op); |
661 | unary_delim = true; | | 661 | unary_delim = true; |
662 | | | 662 | |
663 | | | 663 | |
664 | } /* end of switch */ | | 664 | } /* end of switch */ |
665 | if (buf_ptr >= buf_end) /* check for input buffer empty */ | | 665 | if (buf_ptr >= buf_end) /* check for input buffer empty */ |
666 | fill_buffer(); | | 666 | fill_buffer(); |