Commit b156894e by Richard Stallman

Simplify and fix handling of errno.h.

Now it no longer thinks errno.h always needs fixing.
(write_lbrac, write_rbrac):  Only write
extern "C" if that specifically is needed.

From-SVN: r5848
parent b3b08966
...@@ -85,7 +85,7 @@ sstring buf; ...@@ -85,7 +85,7 @@ sstring buf;
int verbose = 0; int verbose = 0;
int partial_count = 0; int partial_count = 0;
int missing_extern_C_count = 0; int missing_extern_C_count = 0;
int missing_extra_stuff = 0; int missing_errno = 0;
#include "xsys-protos.h" #include "xsys-protos.h"
...@@ -113,9 +113,6 @@ int seen_S_IFIFO = 0, seen_S_ISFIFO = 0; ...@@ -113,9 +113,6 @@ int seen_S_IFIFO = 0, seen_S_ISFIFO = 0;
int seen_S_IFLNK = 0, seen_S_ISLNK = 0; int seen_S_IFLNK = 0, seen_S_ISLNK = 0;
int seen_S_IFREG = 0, seen_S_ISREG = 0; int seen_S_IFREG = 0, seen_S_ISREG = 0;
/* The following are only used when handling errno.h */
int seen_errno = 0;
/* Wrapper around free, to avoid prototype clashes. */ /* Wrapper around free, to avoid prototype clashes. */
void xfree (ptr) void xfree (ptr)
...@@ -164,6 +161,8 @@ int required_unseen_count; ...@@ -164,6 +161,8 @@ int required_unseen_count;
int int
write_lbrac () write_lbrac ()
{ {
if (missing_extern_C_count + required_unseen_count > 0)
fprintf (outf, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); fprintf (outf, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
if (partial_count) if (partial_count)
...@@ -210,7 +209,7 @@ recognized_macro (fname) ...@@ -210,7 +209,7 @@ recognized_macro (fname)
switch (special_file_handling) switch (special_file_handling)
{ {
case errno_special: case errno_special:
if (strcmp (fname, "errno") == 0) seen_errno++; if (strcmp (fname, "errno") == 0) missing_errno = 0;
break; break;
case sys_stat_special: case sys_stat_special:
if (fname[0] == 'S' && fname[1] == '_') if (fname[0] == 'S' && fname[1] == '_')
...@@ -239,7 +238,7 @@ recognized_extern (name, type) ...@@ -239,7 +238,7 @@ recognized_extern (name, type)
switch (special_file_handling) switch (special_file_handling)
{ {
case errno_special: case errno_special:
if (strcmp (name, "errno") == 0) seen_errno++; if (strcmp (name, "errno") == 0) missing_errno = 0;
break; break;
} }
} }
...@@ -326,7 +325,7 @@ read_scan_file (scan_file) ...@@ -326,7 +325,7 @@ read_scan_file (scan_file)
scan_decls (scan_file); scan_decls (scan_file);
if (missing_extern_C_count + required_unseen_count + partial_count if (missing_extern_C_count + required_unseen_count + partial_count
+ missing_extra_stuff == 0) + missing_errno == 0)
{ {
if (verbose) if (verbose)
fprintf (stderr, "%s: OK, nothing needs to be done.\n", inc_filename); fprintf (stderr, "%s: OK, nothing needs to be done.\n", inc_filename);
...@@ -374,7 +373,7 @@ write_rbrac () ...@@ -374,7 +373,7 @@ write_rbrac ()
switch (special_file_handling) switch (special_file_handling)
{ {
case errno_special: case errno_special:
if (!seen_errno) if (missing_errno)
fprintf (outf, "extern int errno;\n"); fprintf (outf, "extern int errno;\n");
break; break;
case sys_stat_special: case sys_stat_special:
...@@ -400,6 +399,7 @@ write_rbrac () ...@@ -400,6 +399,7 @@ write_rbrac ()
} }
if (missing_extern_C_count + required_unseen_count > 0)
fprintf (outf, "#ifdef __cplusplus\n}\n#endif\n"); fprintf (outf, "#ifdef __cplusplus\n}\n#endif\n");
} }
...@@ -648,7 +648,7 @@ main (argc, argv) ...@@ -648,7 +648,7 @@ main (argc, argv)
if (strcmp (inc_filename, "sys/stat.h") == 0) if (strcmp (inc_filename, "sys/stat.h") == 0)
special_file_handling = sys_stat_special; special_file_handling = sys_stat_special;
else if (strcmp (inc_filename, "errno.h") == 0) else if (strcmp (inc_filename, "errno.h") == 0)
special_file_handling = errno_special, missing_extra_stuff++; special_file_handling = errno_special, missing_errno = 1;
/* Calculate an upper bound of the number of function names in argv[4] */ /* Calculate an upper bound of the number of function names in argv[4] */
for (i = 1, cptr = argv[4]; *cptr; cptr++) for (i = 1, cptr = argv[4]; *cptr; cptr++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment