Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: eliminate forward declaration for ...



details:   https://anonhg.NetBSD.org/src/rev/2c9412bf9a39
branches:  trunk
changeset: 373141:2c9412bf9a39
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 21 09:42:12 2023 +0000

description:
lint: eliminate forward declaration for get_escaped_char

No functional change.

diffstat:

 usr.bin/xlint/lint1/lex.c |  97 +++++++++++++++++++++++-----------------------
 1 files changed, 48 insertions(+), 49 deletions(-)

diffs (139 lines):

diff -r 64ec561a3015 -r 2c9412bf9a39 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sat Jan 21 09:16:33 2023 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sat Jan 21 09:42:12 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.137 2023/01/21 09:16:33 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.138 2023/01/21 09:42:12 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: lex.c,v 1.137 2023/01/21 09:16:33 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.138 2023/01/21 09:42:12 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -183,9 +183,6 @@
 symt_t symtyp;
 
 
-static int     get_escaped_char(int);
-
-
 static unsigned int
 hash(const char *s)
 {
@@ -848,7 +845,7 @@
        case 'x':
                return read_escaped_hex(c);
        case '\n':
-               return get_escaped_char(delim);
+               return -3;
        case EOF:
                return -2;
        default:
@@ -863,6 +860,51 @@
        }
 }
 
+/*
+ * Read a character which is part of a character constant or of a string
+ * and handle escapes.
+ *
+ * The argument is the character which delimits the character constant or
+ * string.
+ *
+ * Returns -1 if the end of the character constant or string is reached,
+ * -2 if the EOF is reached, and the character otherwise.
+ */
+static int
+get_escaped_char(int delim)
+{
+       int c;
+
+       if (prev_byte == -1) {
+               c = read_byte();
+       } else {
+               c = prev_byte;
+               prev_byte = -1;
+       }
+       if (c == delim)
+               return -1;
+       switch (c) {
+       case '\n':
+               if (!allow_c90) {
+                       /* newline in string or char constant */
+                       error(254);
+                       return -2;
+               }
+               return c;
+       case '\0':
+               /* syntax error '%s' */
+               error(249, "EOF or null byte in literal");
+               return -2;
+       case EOF:
+               return -2;
+       case '\\':
+               c = read_escaped_backslash(delim);
+               if (c == -3)
+                       return get_escaped_char(delim);
+       }
+       return c;
+}
+
 /* Called if lex found a leading "'". */
 int
 lex_character_constant(void)
@@ -948,49 +990,6 @@
        return T_CON;
 }
 
-/*
- * Read a character which is part of a character constant or of a string
- * and handle escapes.
- *
- * The argument is the character which delimits the character constant or
- * string.
- *
- * Returns -1 if the end of the character constant or string is reached,
- * -2 if the EOF is reached, and the character otherwise.
- */
-static int
-get_escaped_char(int delim)
-{
-       int c;
-
-       if (prev_byte == -1) {
-               c = read_byte();
-       } else {
-               c = prev_byte;
-               prev_byte = -1;
-       }
-       if (c == delim)
-               return -1;
-       switch (c) {
-       case '\n':
-               if (!allow_c90) {
-                       /* newline in string or char constant */
-                       error(254);
-                       return -2;
-               }
-               return c;
-       case '\0':
-               /* syntax error '%s' */
-               error(249, "EOF or null byte in literal");
-               return -2;
-       case EOF:
-               return -2;
-       case '\\':
-               return read_escaped_backslash(delim);
-       }
-       return c;
-}
-
 /* See https://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html */
 static void
 parse_line_directive_flags(const char *p,



Home | Main Index | Thread Index | Old Index