aboutsummaryrefslogtreecommitdiff
path: root/gcc/fixinc/fixlib.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2000-01-17 21:45:29 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-01-17 21:45:29 +0000
commitb51207a4d29a4ab03968c8a34e92391c69886c82 (patch)
treeeb8d5bb67e01ca5f5c9b7fbe503fe8f52efafc50 /gcc/fixinc/fixlib.c
parent051e6fd745109c9de4d707ccd949722904a74987 (diff)
downloadgcc-b51207a4d29a4ab03968c8a34e92391c69886c82.zip
gcc-b51207a4d29a4ab03968c8a34e92391c69886c82.tar.gz
gcc-b51207a4d29a4ab03968c8a34e92391c69886c82.tar.bz2
fixlib.c: Add copyright notice.
* fixinc/fixlib.c: Add copyright notice. (compile_re): New function. * fixinc/fixlib.h: Prototype compile_re. * fixinc/fixfixes.c, fixinc/fixtests.c, fixinc/fixincl.c: Use compile_re to compile regular expressions. * fixinc/fixincl.c (egrep_test): Don't bother asking regexec where the pattern matched. * fixinc/inclhack.def (sun_memcpy): Move to AAB_sun_memcpy, use 'replace'. (ultrix_ansi_compat): Likewise. (interactv_add1): Rename to 'isc_omits_with_stdc', remove shell test, add egrep test. (interactv_add2, interactv_add3): Delete. (x11_sprintf): Don't use filename glob. * fixinc/fixincl.x, fixinc/inclhack.sh, fixinc/fixincl.sh: Regenerate. From-SVN: r31474
Diffstat (limited to 'gcc/fixinc/fixlib.c')
-rw-r--r--gcc/fixinc/fixlib.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/gcc/fixinc/fixlib.c b/gcc/fixinc/fixlib.c
index e5319b9..190f49d 100644
--- a/gcc/fixinc/fixlib.c
+++ b/gcc/fixinc/fixlib.c
@@ -1,4 +1,27 @@
+/* Install modified versions of certain ANSI-incompatible system header
+ files which are fixed to work correctly with ANSI C and placed in a
+ directory that GNU C will search.
+
+ Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
#include "fixlib.h"
/* * * * * * * * * * * * *
@@ -128,3 +151,39 @@ is_cxx_header (fname, text)
return BOOL_FALSE;
}
+
+/* * * * * * * * * * * * *
+
+ Compile one regular expression pattern for later use. PAT contains
+ the pattern, RE points to a regex_t structure (which should have
+ been bzeroed). MATCH is 1 if we need to know where the regex
+ matched, 0 if not. If regcomp fails, prints an error message and
+ aborts; E1 and E2 are strings to shove into the error message.
+
+ The patterns we search for are all egrep patterns.
+ REG_EXTENDED|REG_NEWLINE produces identical regex syntax/semantics
+ to egrep (verified from 4.4BSD Programmer's Reference Manual). */
+void
+compile_re( pat, re, match, e1, e2 )
+ tCC *pat;
+ regex_t *re;
+ int match;
+ tCC *e1;
+ tCC *e2;
+{
+ tSCC z_bad_comp[] = "fixincl ERROR: cannot compile %s regex for %s\n\
+\texpr = `%s'\n\terror %s\n";
+ int flags, err;
+
+ flags = (match ? REG_EXTENDED|REG_NEWLINE
+ : REG_EXTENDED|REG_NEWLINE|REG_NOSUB);
+ err = regcomp (re, pat, flags);
+
+ if (err)
+ {
+ char rerrbuf[1024];
+ regerror (err, re, rerrbuf, 1024);
+ fprintf (stderr, z_bad_comp, e1, e2, pat, rerrbuf);
+ exit (EXIT_FAILURE);
+ }
+}