diff options
author | korbb <korbb@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-12-29 22:59:16 +0000 |
---|---|---|
committer | korbb <korbb@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-12-29 22:59:16 +0000 |
commit | a98784e983c20f5456f8ee49c48689f8b192a04f (patch) | |
tree | c4e23ad9f2c67f5888e05f1a4d0b688badf2042b /gcc/fixinc/fixlib.c | |
parent | c2fc7e5a10f4f0d10bbbd327b33cd5d8f3cd03b6 (diff) | |
download | gcc-a98784e983c20f5456f8ee49c48689f8b192a04f.tar.gz |
C++ file type checking
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31125 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fixinc/fixlib.c')
-rw-r--r-- | gcc/fixinc/fixlib.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/gcc/fixinc/fixlib.c b/gcc/fixinc/fixlib.c index 85f92421222..e5319b9622a 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; +} |