aboutsummaryrefslogtreecommitdiff
path: root/gcc/fixinc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fixinc')
-rw-r--r--gcc/fixinc/check.tpl3
-rw-r--r--gcc/fixinc/fixincl.c172
-rwxr-xr-xgcc/fixinc/fixincl.sh1
-rw-r--r--gcc/fixinc/fixlib.h27
4 files changed, 102 insertions, 101 deletions
diff --git a/gcc/fixinc/check.tpl b/gcc/fixinc/check.tpl
index 4142c43..249636b 100644
--- a/gcc/fixinc/check.tpl
+++ b/gcc/fixinc/check.tpl
@@ -18,8 +18,9 @@ DESTDIR=`pwd`/res
SRCDIR=`pwd`/inc
FIND_BASE='.'
VERBOSE=1
+INPUT=`pwd`
-export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE
+export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE INPUT
rm -rf ${DESTDIR} ${SRCDIR}
mkdir ${DESTDIR} ${SRCDIR}
diff --git a/gcc/fixinc/fixincl.c b/gcc/fixinc/fixincl.c
index 113827f..8deafa8 100644
--- a/gcc/fixinc/fixincl.c
+++ b/gcc/fixinc/fixincl.c
@@ -38,10 +38,21 @@ Boston, MA 02111-1307, USA. */
static const char program_id[] = "fixincl version 1.1";
+/* This format will be used at the start of every generated file */
+
+static const char z_std_preamble[] =
+"/* DO NOT EDIT THIS FILE.\n\n\
+ It has been auto-edited by fixincludes from:\n\n\
+\t\"%s/%s\"\n\n\
+ This had to be done to correct non-standard usages in the\n\
+ original, manufacturer supplied header file. */\n\n";
+
/* Working environment strings. Essentially, invocation 'options'. */
-char *pz_dest_dir = NULL;
-char *pz_src_dir = NULL;
-char *pz_machine = NULL;
+
+#define _ENV_(v,m,n,t) tCC* v = NULL;
+ENV_TABLE
+#undef _ENV_
+
int find_base_len = 0;
typedef enum {
@@ -67,6 +78,7 @@ t_bool curr_data_mapped;
int data_map_fd;
size_t data_map_size;
size_t ttl_data_size = 0;
+
#ifdef DO_STATS
int process_ct = 0;
int apply_ct = 0;
@@ -74,14 +86,6 @@ int fixed_ct = 0;
int altered_ct = 0;
#endif /* DO_STATS */
-#ifdef HAVE_MMAP_FILE
-#define UNLOAD_DATA() do { if (curr_data_mapped) { \
- munmap ((void*)pz_curr_data, data_map_size); close (data_map_fd); } \
- else free ((void*)pz_curr_data); } while(0)
-#else
-#define UNLOAD_DATA() free ((void*)pz_curr_data)
-#endif
-
const char incl_quote_pat[] = "^[ \t]*#[ \t]*include[ \t]*\"[^/]";
tSCC z_fork_err[] = "Error %d (%s) starting filter process for %s\n";
regex_t incl_quote_re;
@@ -203,8 +207,14 @@ initialize ( argc, argv )
char** argv;
{
static const char var_not_found[] =
- "fixincl ERROR: %s environment variable not defined\n\
-\tTARGET_MACHINE, DESTDIR, SRCDIR and FIND_BASE are required\n";
+ "fixincl ERROR: %s environment variable not defined\n"
+#ifdef __STDC__
+ "each of these must be defined:\n"
+#define _ENV_(v,m,n,t) "\t" n " - " t "\n"
+ENV_TABLE
+#undef _ENV_
+#endif
+ ;
xmalloc_set_program_name (argv[0]);
@@ -229,85 +239,48 @@ initialize ( argc, argv )
exit (EXIT_FAILURE);
}
- {
- static const char var[] = "TARGET_MACHINE";
- pz_machine = getenv (var);
- if (pz_machine == (char *) NULL)
- {
- fprintf (stderr, var_not_found, var);
- exit (EXIT_FAILURE);
- }
- }
+#define _ENV_(v,m,n,t) { tSCC var[] = n; \
+ v = getenv (var); if (m && (v == NULL)) { \
+ fprintf (stderr, var_not_found, var); \
+ exit (EXIT_FAILURE); } }
- {
- static const char var[] = "DESTDIR";
- pz_dest_dir = getenv (var);
- if (pz_dest_dir == (char *) NULL)
- {
- fprintf (stderr, var_not_found, var);
- exit (EXIT_FAILURE);
- }
- }
+ENV_TABLE
- {
- static const char var[] = "SRCDIR";
- pz_src_dir = getenv (var);
- if (pz_src_dir == (char *) NULL)
- {
- fprintf (stderr, var_not_found, var);
- exit (EXIT_FAILURE);
- }
- }
+#undef _ENV_
- {
- static const char var[] = "VERBOSE";
- char* pz = getenv (var);
- if (pz != (char *) NULL)
- {
- if (isdigit( *pz ))
- verbose_level = (te_verbose)atoi( pz );
- else
- switch (*pz) {
- case 's':
- case 'S':
- verbose_level = VERB_SILENT; break;
-
- case 'f':
- case 'F':
- verbose_level = VERB_FIXES; break;
-
- case 'a':
- case 'A':
- verbose_level = VERB_APPLIES; break;
-
- case 'p':
- case 'P':
- verbose_level = VERB_PROGRESS; break;
-
- case 't':
- case 'T':
- verbose_level = VERB_TESTS; break;
-
- case 'e':
- case 'E':
- verbose_level = VERB_EVERYTHING; break;
- }
- }
- }
+ if (isdigit( *pz_verbose ))
+ verbose_level = (te_verbose)atoi( pz_verbose );
+ else
+ switch (*pz_verbose) {
+ case 's':
+ case 'S':
+ verbose_level = VERB_SILENT; break;
+
+ case 'f':
+ case 'F':
+ verbose_level = VERB_FIXES; break;
+
+ case 'a':
+ case 'A':
+ verbose_level = VERB_APPLIES; break;
+
+ case 'p':
+ case 'P':
+ verbose_level = VERB_PROGRESS; break;
+
+ case 't':
+ case 'T':
+ verbose_level = VERB_TESTS; break;
+
+ case 'e':
+ case 'E':
+ verbose_level = VERB_EVERYTHING; break;
+ }
- {
- static const char var[] = "FIND_BASE";
- char *pz = getenv (var);
- if (pz == (char *) NULL)
- {
- fprintf (stderr, var_not_found, var);
- exit (EXIT_FAILURE);
- }
- while ((pz[0] == '.') && (pz[1] == '/'))
- pz += 2;
- if ((pz[0] != '.') || (pz[1] != NUL))
- find_base_len = strlen( pz );
- }
+ while ((pz_find_base[0] == '.') && (pz_find_base[1] == '/'))
+ pz_find_base += 2;
+ if ((pz_find_base[0] != '.') || (pz_find_base[1] != NUL))
+ find_base_len = strlen( pz_find_base );
/* Compile all the regular expressions now.
That way, it is done only once for the whole run.
@@ -584,17 +557,16 @@ create_file ()
fprintf (stderr, "Fixed: %s\n", pz_curr_file);
pf = fdopen (fd, "w");
-#ifdef LATER
- {
- static const char hdr[] =
- "/* DO NOT EDIT THIS FILE.\n\n"
- " It has been auto-edited by fixincludes from /usr/include/%s\n"
- " This had to be done to correct non-standard usages in the\n"
- " original, manufacturer supplied header file. */\n\n";
+ /*
+ * IF pz_machine is NULL, then we are in some sort of test mode.
+ * Do not insert the current directory name. Use a constant string.
+ */
+ fprintf (pf, z_std_preamble,
+ (pz_machine == NULL)
+ ? "fixinc/tests/inc"
+ : pz_input_dir,
+ pz_curr_file);
- fprintf (pf, hdr, pz_curr_file);
- }
-#endif
return pf;
}
@@ -953,8 +925,8 @@ fix_applies (p_fixd)
tFixDesc *p_fixd;
{
#ifdef DEBUG
- static const char z_failed[] = "not applying %s %s to %s - "
- "test %d failed\n";
+ static const char z_failed[] = "not applying %s %s to %s - \
+test %d failed\n";
#endif
const char *pz_fname = pz_curr_file;
const char *pz_scan = p_fixd->file_list;
diff --git a/gcc/fixinc/fixincl.sh b/gcc/fixinc/fixincl.sh
index 287e621..83e7b83 100755
--- a/gcc/fixinc/fixincl.sh
+++ b/gcc/fixinc/fixincl.sh
@@ -146,6 +146,7 @@ fi
cd ${INPUT}
INPUT=`${PWDCMD}`
+export INPUT
#
# # # # # # # # # # # # # # # # # # # # #
diff --git a/gcc/fixinc/fixlib.h b/gcc/fixinc/fixlib.h
index 8134158..dc422b1 100644
--- a/gcc/fixinc/fixlib.h
+++ b/gcc/fixinc/fixlib.h
@@ -96,6 +96,25 @@ typedef int apply_fix_p_t; /* Apply Fix Predicate Type */
#define _P_(p) ()
#endif
+#define ENV_TABLE \
+ _ENV_( pz_machine, BOOL_TRUE, "TARGET_MACHINE", \
+ "output from config.guess" ) \
+ \
+ _ENV_( pz_src_dir, BOOL_TRUE, "SRCDIR", \
+ "directory of original files" ) \
+ \
+ _ENV_( pz_input_dir, BOOL_TRUE, "INPUT", \
+ "current directory for fixincl" ) \
+ \
+ _ENV_( pz_dest_dir, BOOL_TRUE, "DESTDIR", \
+ "output directory" ) \
+ \
+ _ENV_( pz_verbose, BOOL_FALSE, "VERBOSE", \
+ "amount of user entertainment" ) \
+ \
+ _ENV_( pz_find_base, BOOL_TRUE, "FIND_BASE", \
+ "leader to trim from file names" )
+
/* Test Descriptor
Each fix may have associated tests that determine
@@ -161,6 +180,14 @@ typedef struct {
extern int gnu_type_map_ct;
+#ifdef HAVE_MMAP_FILE
+#define UNLOAD_DATA() do { if (curr_data_mapped) { \
+ munmap ((void*)pz_curr_data, data_map_size); close (data_map_fd); } \
+ else free ((void*)pz_curr_data); } while(0)
+#else
+#define UNLOAD_DATA() free ((void*)pz_curr_data)
+#endif
+
/*
* Exported procedures
*/