aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2000-04-30 17:30:25 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-04-30 17:30:25 +0000
commit6d2c2047b5760b68cc9eb98fba1ad00a2539fc12 (patch)
treeb4d768db6e949f31e3dc54159c98b6eb77a9dea5 /gcc/cpplex.c
parent638d694d84aedb360309dd956b261e428d85f092 (diff)
downloadgcc-6d2c2047b5760b68cc9eb98fba1ad00a2539fc12.zip
gcc-6d2c2047b5760b68cc9eb98fba1ad00a2539fc12.tar.gz
gcc-6d2c2047b5760b68cc9eb98fba1ad00a2539fc12.tar.bz2
cpplex.c (cpp_idcmp): New function.
* cpplex.c (cpp_idcmp): New function. * cpplib.h: Prototype it. * scan_decls.c (scan_decls): Use it to inspect token names. * fix-header.c (read_scan_file): Likewise. Set system_header_p on the file being run through the preprocessor. (check_macro_names): Provide length of token to cpp_defined. * Makefile.in: Remove stale warning message. From-SVN: r33552
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 182ab25..59d9665 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -2048,6 +2048,37 @@ _cpp_init_input_buffer (pfile)
pfile->input_buffer_len = 8192;
}
+/* Utility routine:
+ Compares, in the manner of strcmp(3), the token beginning at TOKEN
+ and extending for LEN characters to the NUL-terminated string
+ STRING. Typical usage:
+
+ if (! cpp_idcmp (pfile->token_buffer + here, CPP_WRITTEN (pfile) - here,
+ "inline"))
+ { ... }
+ */
+
+int
+cpp_idcmp (token, len, string)
+ const U_CHAR *token;
+ size_t len;
+ const char *string;
+{
+ size_t len2 = strlen (string);
+ int r;
+
+ if ((r = memcmp (token, string, MIN (len, len2))))
+ return r;
+
+ /* The longer of the two strings sorts after the shorter. */
+ if (len == len2)
+ return 0;
+ else if (len < len2)
+ return -1;
+ else
+ return 1;
+}
+
#if 0
/* Lexing algorithm.