This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

formatted include fixing + tests


 

2000-05-20  Bruce Korb  <bkorb@gnu.org>

	* fixinc/inclhack.def:  more applications of c_fix=format + tests
	* fixinc/check.diff:  regenerated
	* fixinc/fixincl.x:  regenerated

Index: inclhack.def
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/inclhack.def,v
retrieving revision 1.69
diff -u -r1.69 inclhack.def
--- inclhack.def	2000/05/20 18:54:33	1.69
+++ inclhack.def	2000/05/20 21:21:50
@@ -611,8 +611,11 @@
     hackname = arm_wchar;
     files  = stdlib.h;
     select = "#[ \t]*define[ \t]*__wchar_t";
-    sed    = "s/\\(#[ \t]*ifndef[ \t]*\\)__wchar_t/\\1_GCC_WCHAR_T/";
-    sed    = "s/\\(#[ \t]*define[ \t]*\\)__wchar_t/\\1_GCC_WCHAR_T/";
+
+    c_fix     = format;
+    c_fix_arg = "%1_GCC_WCHAR_T";
+    c_fix_arg = "(#[ \t]*(ifndef|define)[ \t]+)__wchar_t";
+
     test_text =
     "# ifndef \t __wchar_t /* we don't have wchar_t yet, ... */\n"
     "#  define  __wchar_t  short\n"
@@ -651,6 +654,7 @@
     files     = tinfo.h;
 
     select    = "#[ \t]*define[ \t]+bool[ \t]";
+    bypass    = "we must use the C\\+\\+ compiler's type";
 
     c_fix     = format;
     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
@@ -667,6 +671,7 @@
     files    = tinfo.h;
 
     select    = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
+    bypass    = "we must use the C\\+\\+ compiler's type";
 
     c_fix     = format;
     c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
@@ -684,6 +689,12 @@
  *  properly in most cases, they don't allow you to take a pointer to the
  *  "something" being modified.  To get around this limitation, change these
  *  statements to be of the form '#define something _FOOsomething'.
+ *
+ *  sed ain't egrep, lesson 2463:  sed can use self-referential
+ *  regular expressions.  In the substitute expression below,
+ *  "\\1" and "\\2" refer to subexpressions found earlier in the
+ *  same match.  So, we continue to use sed.  "extern_prefix" will
+ *  be a rare match anyway...
  */
 fix = {
     hackname = bad_lval;
@@ -1012,6 +1023,23 @@
 
 
 /*
+ *  Fix return type of abort and free
+ */
+fix = {
+    hackname  = int_abort_free_and_exit;
+    files     = stdlib.h;
+    select    = "int[ \t]+(abort|free|exit)[ \t]*\\(";
+
+    c_fix     = format;
+    c_fix_arg = "void\t%1(";
+
+    test_text = "extern int abort(int);\n"
+                "extern int free(void*);\n"
+                "extern int exit(void*);";
+};
+
+
+/*
  *  On Interactive Unix 2.2, certain traditional Unix definitions
  *  (notably getc and putc in stdio.h) are omitted if __STDC__ is
  *  defined, not just if _POSIX_SOURCE is defined.  This makes it
@@ -1096,7 +1124,10 @@
     hackname = hpux_systime;
     files    = sys/time.h;
     select   = "^extern struct sigevent;";
-    sed      = "s/^extern struct sigevent;/struct sigevent;/";
+
+    c_fix     = format;
+    c_fix_arg = "struct sigevent;";
+
     test_text = 'extern struct sigevent;';
 };
 
@@ -1210,10 +1241,9 @@
     bypass = "ifndef[ \t]+FLT_MIN";
 
     c_fix     = format;
-    c_fix_arg = "#ifndef %1\n%0#endif\n";
+    c_fix_arg = "#ifndef %1\n%0\n#endif";
     c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+"
-                "((FLT|DBL)_(MIN|MAX|DIG))"
-                "[ \t][^\n]*\n";
+                "((FLT|DBL)_(MIN|MAX|DIG))[ \t].*";
     test_text = " #\tdefine\tDBL_DIG \t 0  /* somthin' */";
 };
 
@@ -1312,10 +1342,14 @@
 fix = {
     hackname = machine_ansi_h_va_list;
     files    = machine/ansi.h;
-    select   = '_BSD_VA_LIST_';
+    select   = "define[ \t]+_BSD_VA_LIST_[ \t]";
     bypass   = '__builtin_va_list';
 
-    sed	     = "s/\\(_BSD_VA_LIST_[ \t][ \t]*\\).*$/\\1__builtin_va_list/";
+    c_fix     = format;
+    c_fix_arg = "%1__builtin_va_list";
+    c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
+
+    test_text = " # define _BSD_VA_LIST_\tchar**";
 };
 
 
@@ -1326,11 +1360,9 @@
     hackname  = machine_name;
     c_test    = machine_name;
     c_fix     = machine_name;
-    test_text =
-    "#if /* MACH_DIFF: */ \\\n"
-    "\t   defined( i386 ) \\\n"
-    "\t|| defined( sparc ) /*\n"
-    "no uniform test, so be careful  :-) */";
+    test_text = "/* MACH_DIFF: */\n"
+    "#if defined( i386 ) || defined( sparc ) || defined( vax )"
+    "\n/* no uniform test, so be careful  :-) */";
 };
 
 
@@ -1347,7 +1379,7 @@
     hackname  = math_exception;
     files     = math.h;
     select    = "struct exception";
-    bypass    = "We have a problem when using C\\+\\+";
+    bypass    = 'We have a problem when using C\+\+';
     c_fix     = wrap;
 
     c_fix_arg = "#ifdef __cplusplus\n"
@@ -1361,6 +1393,13 @@
     test_text = "typedef struct exception t_math_exception;";
 };
 
+
+/*
+ *  This looks pretty broken to me.  ``dbl_max_def'' will contain
+ *  "define DBL_MAX " at the start, when what we really want is just
+ *  the value portion.  Can't figure out how to write a test case
+ *  for this either  :-(
+ */
 fix = {
     hackname = math_huge_val_from_dbl_max;
     files    = math.h;
@@ -1387,16 +1426,21 @@
     "\tfi";
 };
 
+
 /*
  * In any case, put #ifndef .. #endif around #define HUGE_VAL in math.h.
  */
 fix = {
     hackname = math_huge_val_ifndef;
+    files    = math.h;
     files    = math/math.h;
-    select   = "define[ \t]*HUGE_VAL";
+    select   = "define[ \t]+HUGE_VAL";
 
-    sed      = "/define[ \t]HUGE_VAL[ \t]/i\\\n#ifndef HUGE_VAL\n";
-    sed      = "/define[ \t]HUGE_VAL[ \t]/a\\\n#endif\n";
+    c_fix     = format;
+    c_fix_arg = "#ifndef HUGE_VAL\n%0\n#endif";
+    c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*";
+
+    test_text = "# define\tHUGE_VAL 3.4e+40";
 };
 
 
@@ -1457,11 +1501,11 @@
 fix = {
     hackname = news_os_recursion;
     files    = stdlib.h;
-    select   = "#include <stdlib.h>";
-    sed      = "/^#include <stdlib.h>/i\\\n"
-                    "#ifdef BOGUS_RECURSION\n";
-    sed      = "/^#include <stdlib.h>/a\\\n"
-                    "#endif\n";
+    select   = "[ \t]*#include <stdlib\\.h>.*";
+
+    c_fix     = format;
+    c_fix_arg = "#ifdef BOGUS_RECURSION\n%0\n#endif";
+    test_text = "#include <stdlib.h>";
 };
 
 
@@ -1470,32 +1514,32 @@
  *  These conflict with the built-in functions.
  */
 fix = {
-    hackname = next_math_prefix;
-    files    = ansi/math.h;
-    select   = "^extern.*double.*__const__.*";
-
-    sed = "/^extern.*double.*__const__.*sqrt(/s/__const__//";
-    sed = "/^extern.*double.*__const__.*fabs(/s/__const__//";
-    sed = "/^extern.*double.*__const__.*cos(/s/__const__//";
-    sed = "/^extern.*double.*__const__.*hypot(/s/__const__//";
-    sed = "/^extern.*double.*__const__.*sin(/s/__const__//";
+    hackname  = next_math_prefix;
+    files     = ansi/math.h;
+    select    = "^extern[ \t]+double[ \t]+__const__[ \t]";
+
+    c_fix     = format;
+    c_fix_arg = "extern double %1(";
+    c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
+
+    test_text = "extern\tdouble\t__const__\tmumble();";
 };
 
 
 /*
  *  NeXT 3.2 uses the word "template" as a parameter for some
  *  functions. GCC reports an invalid use of a reserved key word
- *  with the built-in functions. NeXT 3.2 includes the keyword
- *  volatile in the prototype for abort(). This conflicts with
- *  the built-in definition.
+ *  with the built-in functions.
  */
 fix = {
     hackname = next_template;
     files    = bsd/libc.h;
-    select   = template;
+    select   = "[ \t]template\\)";
 
-    sed = '/\(.*template\)/s/template//';
-    sed = "/extern.*volatile.*void.*abort/s/volatile//";
+    c_fix     = format;
+    c_fix_arg = "(%1)";
+    c_fix_arg = "\\(([^)]*)[ \t]template\\)";
+    test_text = "extern mumble( char * template); /* fix */";
 };
 
 
@@ -1506,10 +1550,13 @@
 fix = {
     hackname = next_volitile;
     files    = ansi/stdlib.h;
-    select   = volatile;
+    select   = "^extern[ \t]+volatile[ \t]+void[ \t]";
 
-    sed    = "/extern.*volatile.*void.*exit/s/volatile//";
-    sed    = "/extern.*volatile.*void.*abort/s/volatile//";
+    c_fix     = format;
+    c_fix_arg = "extern void %1(";
+    c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
+
+    test_text = "extern\tvolatile\tvoid\tabort();";
 };
 
 
@@ -1520,12 +1567,13 @@
  *  conditional, so it doesn't need this fix.  So everything is okay.
  */
 fix = {
-    hackname = next_wait_union;
-    files    = sys/wait.h;
+    hackname  = next_wait_union;
+    files     = sys/wait.h;
 
-    select = 'wait\(union wait';
-
-    sed = "s@wait(union wait@wait(void@";
+    select    = 'wait\(union wait';
+    c_fix     = format;
+    c_fix_arg = "wait(void";
+    test_text = "extern pid_d wait(union wait*);";
 };
 
 
@@ -1533,9 +1581,12 @@
  *  a missing semi-colon at the end of the nodeent structure definition.
  */
 fix = {
-    hackname = nodeent_syntax;
-    files    = netdnet/dnetdb.h;
-    sed      = "s/char.*na_addr *$/char *na_addr;/";
+    hackname  = nodeent_syntax;
+    files     = netdnet/dnetdb.h;
+    select    = "char[ \t]*\\*na_addr[ \t]*$";
+    c_fix     = format;
+    c_fix_arg = "%0;";
+    test_text = "char *na_addr\t";
 };
 
 
@@ -1552,24 +1603,34 @@
     test     = " -r sys/lc_core.h";
     test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
     test     = " -z \"`grep __regex_t regex.h`\"";
+
+    c_fix     = format;
+    c_fix_arg = "__%0";
+    c_fix_arg = "reg(ex|off|match)_t[^;]";
 
-    sed      = "s/regex_t/__regex_t/g";
-    sed      = "s/regoff_t/__regoff_t/g";
-    sed      = "s/regmatch_t/__regmatch_t/g";
+    test_text = "`touch inc/sys/lc_core.h`"
+    "typedef struct {\n  int stuff, mo_suff;\n} regex_t;\n"
+    "extern regex_t    re;\n"
+    "extern regoff_t   ro;\n"
+    "extern regmatch_t rm;\n";
 };
 
 fix = {
-    hackname = osf_namespace_b;
+    hackname = osf_namespace_c;
     files    = regex.h;
     test     = " -r reg_types.h";
     test     = " -r sys/lc_core.h";
     test     = " -n \"`grep '} regex_t;' reg_types.h`\"";
     test     = " -z \"`grep __regex_t regex.h`\"";
+
+    select    = "#include <reg_types\.h>.*";
+    c_fix     = format;
+    c_fix_arg = "%0\n"
+                "typedef __regex_t\tregex_t;\n"
+                "typedef __regoff_t\tregoff_t;\n"
+                "typedef __regmatch_t\tregmatch_t;";
 
-    sed      = "/#include <reg_types.h>/a\\\n"
-               "typedef __regex_t\tregex_t;\\\n"
-               "typedef __regoff_t\tregoff_t;\\\n"
-               "typedef __regmatch_t\tregmatch_t;\n";
+    test_text = "#include <reg_types.h>";
 };
 
 
@@ -1579,10 +1640,12 @@
  *  This is the default for all ANSI standard C++ compilers.
  */
 fix = {
-    hackname = pthread_page_size;
-    files    = pthread.h;
-    select   = "^int __page_size";
-    sed      = "s/^int __page_size/extern int __page_size/";
+    hackname  = pthread_page_size;
+    files     = pthread.h;
+    select    = "^int __page_size";
+    c_fix     = format;
+    c_fix_arg = "extern %0";
+    test_text = "int __page_size;";
 };
 
 
@@ -1593,9 +1656,11 @@
     hackname = read_ret_type;
     files    = stdio.h;
     select   = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
-    sed      = "s/^\\(extern int\tfclose(), fflush()\\), "
-                 "\\(fread(), fwrite()\\)\\(.*\\)$"
-               "/extern unsigned int\t\\2;\\\n\\1\\3/";
+    c_fix     = format;
+    c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
+    c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
+
+    test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
 };
 
 
@@ -1603,12 +1668,15 @@
  *  function class(double x) conflicts with C++ keyword on rs/6000 
  */
 fix = {
-    hackname = rs6000_double;
-    files    = math.h;
-    select   = '[^a-zA-Z_]class\(';
-    
-    sed   = "/class[(]/i\\\n#ifndef __cplusplus\n";
-    sed   = "/class[(]/a\\\n#endif\n";
+    hackname  = rs6000_double;
+    files     = math.h;
+    select    = '[^a-zA-Z_]class\(';
+
+    c_fix     = format;
+    c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
+    c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
+
+    test_text = "extern int class();";
 };
 
 
@@ -1616,10 +1684,12 @@
  *  Wrong fchmod prototype on RS/6000.
  */
 fix = {
-    hackname = rs6000_fchmod;
-    files    = sys/stat.h;
-    select   = 'fchmod\(char';
-    sed      = 's/fchmod(char \*/fchmod(int/';
+    hackname  = rs6000_fchmod;
+    files     = sys/stat.h;
+    select    = 'fchmod\(char \*';
+    c_fix     = format;
+    c_fix_arg = "fchmod(int";
+    test_text = "extern int fchmod(char *, mode_t);";
 };
 
 
@@ -1627,13 +1697,15 @@
  *  parameters conflict with C++ new on rs/6000 
  */
 fix = {
-    hackname = rs6000_param;
-    files  = "stdio.h";
-    files  = "unistd.h";
-    select = 'const char new';
+    hackname  = rs6000_param;
+    files     = "stdio.h";
+    files     = "unistd.h";
 
-    sed = 's@rename(const char \*old, const char \*new)@'
-            'rename(const char *_old, const char *_new)@';
+    select    = 'rename\(const char \*old, const char \*new\)';
+    c_fix     = format;
+    c_fix_arg = 'rename(const char *_old, const char *_new)';
+
+    test_text = 'extern int rename(const char *old, const char *new);';
 };
 
 
@@ -1659,6 +1731,20 @@
                "#if __cplusplus\\\n"
                " }\\\n"
                "#endif /* __cplusplus */";
+
+    test_text =
+    "#ifdef __STDC__\n"
+    "static int\tstat(const char *__f, struct stat *__p) {\n"
+    "\treturn __stat32(__f, __p);\n"
+    "}\n\n#  else /* !__STDC__ */\n"
+
+    "static int\tstat(__f, __p)\n"
+    "\tchar *__f;\n"
+    "\tstruct stat *__p;\n"
+    "{\n"
+    "\treturn __stat32(__f, __p);\n"
+    "}\n"
+    "#endif";
 };
 
 
@@ -1669,7 +1755,12 @@
     hackname = sco_strict_ansi;
     mach     = "i?86-*-sco3.2*";
     select   = "^[ \t]*#[ \t]*if.*!__STDC__";
-    sed      = 's/!__STDC__/!defined(__STRICT_ANSI__)/g';
+
+    c_fix     = format;
+    c_fix_arg = "%1defined(__STRICT_ANSI__)%2";
+    c_fix_arg = "^([ \t]*#[ \t]*if[ \t].*!)__STDC__(.*)";
+
+    test_text = "#if !__STDC__ /* not standard C */\nint foo;\n#endif";
 };
 
 
@@ -1678,12 +1769,15 @@
  *  In 3.2v4.0 the const is missing.
  */
 fix = {
-    hackname = sco_utime;
-    files    = sys/times.h;
-    mach     = "i?86-*-sco3.2v4*";
-    select   = "\(const char \*, struct utimbuf \*\);";
-    sed      = 's/(const char \*, struct utimbuf \*);/'
-                 '(const char *, const struct utimbuf *);/';
+    hackname  = sco_utime;
+    files     = sys/times.h;
+    mach      = "i?86-*-sco3.2v4*";
+
+    select    = '\(const char \*, struct utimbuf \*\);';
+    c_fix     = format;
+    c_fix_arg = '(const char *, const struct utimbuf *);';
+
+    test_text = "extern int utime(const char *, struct utimbuf *);";
 };
 
 
@@ -1700,6 +1794,23 @@
 };
 #endif
 
+
+/*
+ *  Sony NEWSOS 5.0 does not support the complete ANSI C standard.
+ */
+#ifdef SONY
+fix = {
+    hackname = sony_stdio;
+    files    = stdio.h;
+    test     = " -x /bin/sony";
+    test     = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
+    sed      = "s/__filbuf/_filbuf/g\n"
+               "s/__flsbuf/_flsbuf/g\n"
+               "s/__iob/_iob/g";
+};
+#endif
+
+
 /*
  *  Incorrect #include in Sony News-OS 3.2.
  */
@@ -1726,6 +1837,7 @@
 };
 #endif
 
+
 /*
  *  Add a `static' declaration of `getrnge' into <regexp.h>.
  *
@@ -1749,10 +1861,12 @@
  *  a missing semi-colon at the end of the statsswtch structure definition.
  */
 fix = {
-    hackname = statsswtch;
-    files    = rpcsvc/rstat.h;
-    select   = "boottime$";
-    sed      = "s/boottime$/boottime;/";
+    hackname  = statsswtch;
+    files     = rpcsvc/rstat.h;
+    select    = "boottime$";
+    c_fix     = format;
+    c_fix_arg = "boottime;";
+    test_text = "struct statswtch {\n  int boottime\n};";
 };
 
 
@@ -1864,28 +1978,17 @@
     /*
      *  Select those files containing '(*name)()'.
      */
-    select   = '\(\*[a-z][a-z_]*\)\(\)';
-    sed      = 's'
-                '/^\(.*(\*[a-z][a-z_]*)(\)'      '\();.*\)'
-                "/\\\n"
-                    "#ifdef __cplusplus\\\n"
-                    '\1...\2' "\\\n"
-                    "#else\\\n"
-                    '\1\2' "\\\n"
-                    "#endif"
-                "/";
-};
+    select    = '\(\*[a-z][a-z_]*\)\(\)';
 
+    c_fix     = format;
+    c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
+                "#else\n%1();%2\n#endif";
+    c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
 
-/*
- *  Fix bogus #ifdef on SunOS 4.1.
- */
-fix = {
-    hackname = sun_bogus_ifdef;
-    files  = "hsfs/hsfs_spec.h";
-    files  = "hsfs/iso_spec.h";
-    select = '#ifdef __i386__ || __vax__';
-    sed    = "s/\\#ifdef __i386__ || __vax__/\\#if __i386__ || __vax__/g";
+    test_text =
+    "struct auth_t {\n"
+    "    int (*name)(); /* C++ bad */\n"
+    "};";
 };
 
 
@@ -1893,10 +1996,14 @@
  *  Fix bogus #ifdef on SunOS 4.1.
  */
 fix = {
-    hackname = sun_bogus_ifdef_sun4c;
-    files  = "hsfs/hsnode.h";
-    select = '#ifdef __i386__ || __sun4c__';
-    sed    = "s/\\#ifdef __i386__ || __sun4c__/\\#if __i386__ || __sun4c__/g";
+    hackname  = sun_bogus_ifdef;
+    files     = "hsfs/hsfs_spec.h";
+    files     = "hsfs/iso_spec.h";
+    select    = '#ifdef(.*\|\|.*)';
+    c_fix     = format;
+    c_fix_arg = "#if%1";
+
+    test_text = "#ifdef  __i386__ || __vax__ || __sun4c__";
 };
 
 
@@ -1904,16 +2011,18 @@
  *  Fix the CAT macro in SunOS memvar.h.
  */
 fix = {
-    hackname = sun_catmacro;
-    files  = pixrect/memvar.h;
-    select = "^#define[ \t]+CAT\\(a,b\\)";
-    sed    = "/^#define[ \t]CAT(a,b)/ i\\\n"
-                 "#ifdef __STDC__ \\\n"
-                 "#define CAT(a,b) a##b\\\n"
-                 "#else\n";
+    hackname  = sun_catmacro;
+    files     = pixrect/memvar.h;
+    select    = "^#define[ \t]+CAT\\(a,b\\).*";
+    c_fix     = format;
 
-    sed    = "/^#define[ \t]CAT(a,b)/ a\\\n"
-                 "#endif\n";
+    c_fix_arg =
+    "#ifdef __STDC__\n"
+    "#  define CAT(a,b) a##b\n"
+    "#else\n%0\n#endif";
+
+    test_text =
+    "#define CAT(a,b)\ta/**/b";
 };
 
 
@@ -1929,6 +2038,12 @@
     sed   = "s/int[ \t][ \t]*free/void\tfree/g";
     sed   = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
     sed   = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
+
+    test_text =
+    "typedef char *\tmalloc_t;\n"
+    "int \tfree();\n"
+    "char*\tmalloc();\n"
+    "char*\trealloc();";
 };
 
 
@@ -1940,6 +2055,7 @@
     files    = rpcsvc/rusers.h;
     select   = "_cnt$";
     sed      = "/^struct/,/^};/s/_cnt$/_cnt;/";
+    test_text = "struct mumble\n  int _cnt\n};";
 };
 
 
@@ -1951,15 +2067,15 @@
     hackname = sun_signal;
     files    = sys/signal.h;
     files    = signal.h;
-    select   = "^void\t" '\(\*signal\(\)\)\(\);';
+    select   = "^void\t" '\(\*signal\(\)\)\(\);.*';
 
-    sed = "/^void\t" '(\*signal())();$/i'  "\\\n"
-          "#ifdef __cplusplus"             "\\\n"
-          "void\t(*signal(...))(...);"     "\\\n"
-          "#else"                          "\n";
+    c_fix     = format;
+    c_fix_arg =
+          "#ifdef __cplusplus\n"
+          "void\t(*signal(...))(...);\n"
+          "#else\n%0\n#endif";
 
-    sed = "/^void\t" '(\*signal())();$/a'  "\\\n"
-          '#endif'                         "\n";
+    test_text = "void\t(*signal())();";
 };
 
 
@@ -1968,16 +2084,17 @@
  *  of struct exception, so the prototype (added by fixproto) causes havoc.
  */
 fix = {
-    hackname = sunos_matherr_decl;
-    files    = math.h;
+    hackname  = sunos_matherr_decl;
+    files     = math.h;
+
     /*  If matherr has a prototype already, the header needs no fix.  */
-    bypass   = 'matherr.*struct exception';
-    /*
-     *  Once a declaration for 'struct exception' is found,
-     *  stop trying to insert a forward reference for it.
-     */
-    sed = "/^struct exception/,$b";
-    sed = "/matherr/i\\\nstruct exception;\n";
+    bypass    = 'matherr.*struct exception';
+    select    = matherr;
+
+    c_fix     = wrap;
+    c_fix_arg = "struct exception;\n";
+
+    test_text = "extern int matherr();";
 };
 
 
@@ -1987,8 +2104,10 @@
 fix = {
     hackname = sunos_strlen;
     files    = strings.h;
-    select   = "int[ \t]*strlen";
-    sed = "s/int[ \t]*strlen();/__SIZE_TYPE__ strlen();/";
+    select   = "int[ \t]*strlen\\(\\);(.*)";
+    c_fix     = format;
+    c_fix_arg = "__SIZE_TYPE__ strlen();%1";
+    test_text = " int\tstrlen(); /* string length */";
 };
 
 
@@ -1997,17 +2116,18 @@
  *  which conflicts with the fixproto definition.  The fixproto
  *  definition and the Solaris definition are used the same way.
  */
-#ifdef SVR4
 fix = {
     hackname = svr4__p;
     files    = math.h;
     files    = floatingpoint.h;
-    select   = "^#define[ \t]*__P";
-    sed      = "/^#define[ \t]*__P/i\\\n#ifndef __P\n";
-    sed      = "/^#define[ \t]*__P/a\\\n#endif\n";
+    select   = "^#define[ \t]+__P.*";
+    c_fix     = format;
+    c_fix_arg = "#ifndef __P\n%0\n#endif";
+
+    test_text = "#define __P(a) a";
 };
-#endif
 
+
 /*
  *  Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
  *  that is visible to any ANSI compiler using this include.  Simply
@@ -2126,8 +2246,11 @@
     files    = unistd.h;
     files    = prototypes.h;
     select   = 'getcwd\(char \*, int\)';
+
+    c_fix     = format;
+    c_fix_arg = "getcwd(char *, size_t)";
 
-    sed = 's/getcwd(char \*, int)/getcwd(char *, size_t)/';
+    test_text = "extern char* getcwd(char *, int);";
 };
 
 
@@ -2181,9 +2304,9 @@
     files    = sys/mkdev.h;
     select   = '^static';
 
-    sed	     = "/^dev_t makedev(/s/^/static /";
-    sed	     = "/^major_t major(/s/^/static /";
-    sed	     = "/^minor_t minor(/s/^/static /";
+    sed      = "/^dev_t makedev(/s/^/static /";
+    sed      = "/^major_t major(/s/^/static /";
+    sed      = "/^minor_t minor(/s/^/static /";
 };
 #endif /* SVR5 */
 
@@ -2223,9 +2346,13 @@
     files    = stdlib.h;
     files    = unistd.h;
 
-    sed = 's/profil(unsigned short \*, unsigned int, '
-                         'unsigned int, unsigned int)'
-           '/profil(unsigned short *, size_t, int, unsigned)/';
+    select    =
+    'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
+    c_fix     = format;
+    c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
+
+    test_text =
+    'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
 };
 
 
@@ -2386,15 +2513,15 @@
     hackname = systypes_stdlib_size_t;
     files    = sys/types.h;
     files    = stdlib.h;
-    select   = "typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t";
+    select   = "typedef[ \t]+[A-Za-z_][ \tA-Za-z_]*[ \t]size_t.*";
     bypass   = "_(GCC|BSD)_SIZE_T";
 
-    sed    = "/typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t/i\\\n"
-                 "#ifndef _GCC_SIZE_T\\\n"
-                 "#define _GCC_SIZE_T\n";
+    c_fix     = format;
+    c_fix_arg =
+    "#ifndef _GCC_SIZE_T\n"
+    "#define _GCC_SIZE_T\n%0\n#endif";
 
-    sed    = "/typedef[ \t][ \t]*[A-Za-z_][ \tA-Za-z_]*[ \t]size_t/a\\\n"
-                 "#endif\n";
+    test_text = "typedef unsigned int size_t; /* size of something */";
 };
 
 
@@ -2424,19 +2551,21 @@
 
 
 /*
- *  Fix return type of exit and abort in <stdlib.h>
+ *  Fix return type of calloc, malloc, realloc, bsearch and exit
  */
 fix = {
     hackname = sysz_stdlib_for_sun;
     files    = stdlib.h;
 
-    sed   = "s/int\tabort/void\tabort/g";
-    sed   = "s/int\tfree/void\tfree/g";
-    sed   = "s/char[ \t]*\\*[ \t]*calloc/void \\*\tcalloc/g";
-    sed   = "s/char[ \t]*\\*[ \t]*malloc/void \\*\tmalloc/g";
-    sed   = "s/char[ \t]*\\*[ \t]*realloc/void \\*\trealloc/g";
-    sed   = "s/char[ \t]*\\*[ \t]*bsearch/void \\*\tbsearch/g";
-    sed   = "s/int[ \t][ \t]*exit/void\texit/g";
+    select    = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
+    c_fix     = format;
+    c_fix_arg = "void *\t%1(";
+
+    test_text =
+    "extern char*\tcalloc(size_t);\n"
+    "extern char*\tmalloc(size_t);\n"
+    "extern char*\trealloc(void*,size_t);\n"
+    "extern char*\tbsearch(void*,size_t,size_t);\n";
 };
 
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]