aboutsummaryrefslogtreecommitdiff
path: root/gcc/fixinc/fixlib.c
diff options
context:
space:
mode:
authorBruce Korb <autogen@linuxbox.com>1999-12-29 22:59:16 +0000
committerBruce Korb <korbb@gcc.gnu.org>1999-12-29 22:59:16 +0000
commit87ad679bfb5aecb457aab8e7abf6030b82a020d6 (patch)
treec4e23ad9f2c67f5888e05f1a4d0b688badf2042b /gcc/fixinc/fixlib.c
parentec6bfc9b7ca1e855c15cc9b6875f718a5850f060 (diff)
downloadgcc-87ad679bfb5aecb457aab8e7abf6030b82a020d6.zip
gcc-87ad679bfb5aecb457aab8e7abf6030b82a020d6.tar.gz
gcc-87ad679bfb5aecb457aab8e7abf6030b82a020d6.tar.bz2
C++ file type checking
From-SVN: r31125
Diffstat (limited to 'gcc/fixinc/fixlib.c')
-rw-r--r--gcc/fixinc/fixlib.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/gcc/fixinc/fixlib.c b/gcc/fixinc/fixlib.c
index 85f9242..e5319b9 100644
--- a/gcc/fixinc/fixlib.c
+++ b/gcc/fixinc/fixlib.c
@@ -57,3 +57,74 @@ load_file_data (fp)
return pz_data;
}
+
+
+t_bool
+is_cxx_header (fname, text)
+ tCC *fname;
+ tCC *text;
+{
+ /* First, check to see if the file is in a C++ directory */
+ for (;;)
+ {
+ switch (*(fname++))
+ {
+ case 'C': /* check for "CC/" */
+ if ((fname[0] == 'C') && (fname[1] == '/'))
+ return BOOL_TRUE;
+ break;
+
+ case 'x': /* check for "xx/" */
+ if ((fname[0] == 'x') && (fname[1] == '/'))
+ return BOOL_TRUE;
+ break;
+
+ case '+': /* check for "++" */
+ if (fname[0] == '+')
+ return BOOL_TRUE;
+ break;
+
+ case NUL:
+ goto not_cxx_name;
+ }
+ } not_cxx_name:;
+
+ /* Or it might contain the phrase 'extern "C++"' */
+ for (;;)
+ {
+ tSCC zExtern[] = "extern";
+ tSCC zExtCxx[] = "\"C++\"";
+ tSCC zTemplate[] = "template";
+
+ switch (*(text++))
+ {
+ case 'e':
+ /* Check for "extern \"C++\"" */
+ if (strncmp (text, zExtern+1, sizeof( zExtern )-2) != 0)
+ break;
+ text += sizeof( zExtern )-2;
+ if (! isspace( *(text++)) )
+ break;
+ while (isspace( *text )) text++;
+ if (strncmp (text, zExtCxx, sizeof (zExtCxx) -1) == 0)
+ return BOOL_TRUE;
+ break;
+
+ case 't':
+ /* Check for "template<" */
+ if (strncmp (text, zTemplate+1, sizeof( zTemplate )-2) != 0)
+ break;
+ text += sizeof( zTemplate )-2;
+ while (isspace( *text )) text++;
+ if (*text == '<')
+ return BOOL_TRUE;
+ break;
+
+ case NUL:
+ goto text_done;
+ break;
+ }
+ } text_done:;
+
+ return BOOL_FALSE;
+}