Commit e02ecf39 by Bruce Korb Committed by Bruce Korb

activate the auto-edit marker on the fixed output files

From-SVN: r35133
parent ca2875c4
2000-07-19 Bruce Korb <bkorb@gnu.org>
* fixinc/fixincl.c: Convert to using a table of environment variables
and activate the auto-edit marker on the fixed output files.
* fixinc/fixlib.h: Define the environment table
* fixinc/fixincl.sh: export the ${INPUT} dir
* fixinc/check.tpl: likewise
2000-07-18 Zack Weinberg <zack@wolery.cumb.org> 2000-07-18 Zack Weinberg <zack@wolery.cumb.org>
* gcc.c (.h spec): Fix typo. * gcc.c (.h spec): Fix typo.
......
...@@ -18,8 +18,9 @@ DESTDIR=`pwd`/res ...@@ -18,8 +18,9 @@ DESTDIR=`pwd`/res
SRCDIR=`pwd`/inc SRCDIR=`pwd`/inc
FIND_BASE='.' FIND_BASE='.'
VERBOSE=1 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} rm -rf ${DESTDIR} ${SRCDIR}
mkdir ${DESTDIR} ${SRCDIR} mkdir ${DESTDIR} ${SRCDIR}
......
...@@ -38,10 +38,21 @@ Boston, MA 02111-1307, USA. */ ...@@ -38,10 +38,21 @@ Boston, MA 02111-1307, USA. */
static const char program_id[] = "fixincl version 1.1"; 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'. */ /* Working environment strings. Essentially, invocation 'options'. */
char *pz_dest_dir = NULL;
char *pz_src_dir = NULL; #define _ENV_(v,m,n,t) tCC* v = NULL;
char *pz_machine = NULL; ENV_TABLE
#undef _ENV_
int find_base_len = 0; int find_base_len = 0;
typedef enum { typedef enum {
...@@ -67,6 +78,7 @@ t_bool curr_data_mapped; ...@@ -67,6 +78,7 @@ t_bool curr_data_mapped;
int data_map_fd; int data_map_fd;
size_t data_map_size; size_t data_map_size;
size_t ttl_data_size = 0; size_t ttl_data_size = 0;
#ifdef DO_STATS #ifdef DO_STATS
int process_ct = 0; int process_ct = 0;
int apply_ct = 0; int apply_ct = 0;
...@@ -74,14 +86,6 @@ int fixed_ct = 0; ...@@ -74,14 +86,6 @@ int fixed_ct = 0;
int altered_ct = 0; int altered_ct = 0;
#endif /* DO_STATS */ #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]*\"[^/]"; const char incl_quote_pat[] = "^[ \t]*#[ \t]*include[ \t]*\"[^/]";
tSCC z_fork_err[] = "Error %d (%s) starting filter process for %s\n"; tSCC z_fork_err[] = "Error %d (%s) starting filter process for %s\n";
regex_t incl_quote_re; regex_t incl_quote_re;
...@@ -203,8 +207,14 @@ initialize ( argc, argv ) ...@@ -203,8 +207,14 @@ initialize ( argc, argv )
char** argv; char** argv;
{ {
static const char var_not_found[] = static const char var_not_found[] =
"fixincl ERROR: %s environment variable not defined\n\ "fixincl ERROR: %s environment variable not defined\n"
\tTARGET_MACHINE, DESTDIR, SRCDIR and FIND_BASE are required\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]); xmalloc_set_program_name (argv[0]);
...@@ -229,85 +239,48 @@ initialize ( argc, argv ) ...@@ -229,85 +239,48 @@ initialize ( argc, argv )
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
{ #define _ENV_(v,m,n,t) { tSCC var[] = n; \
static const char var[] = "TARGET_MACHINE"; v = getenv (var); if (m && (v == NULL)) { \
pz_machine = getenv (var); fprintf (stderr, var_not_found, var); \
if (pz_machine == (char *) NULL) exit (EXIT_FAILURE); } }
{
fprintf (stderr, var_not_found, var);
exit (EXIT_FAILURE);
}
}
{ ENV_TABLE
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);
}
}
{ #undef _ENV_
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);
}
}
{ if (isdigit( *pz_verbose ))
static const char var[] = "VERBOSE"; verbose_level = (te_verbose)atoi( pz_verbose );
char* pz = getenv (var); else
if (pz != (char *) NULL) switch (*pz_verbose) {
{ case 's':
if (isdigit( *pz )) case 'S':
verbose_level = (te_verbose)atoi( pz ); verbose_level = VERB_SILENT; break;
else
switch (*pz) { case 'f':
case 's': case 'F':
case 'S': verbose_level = VERB_FIXES; break;
verbose_level = VERB_SILENT; break;
case 'a':
case 'f': case 'A':
case 'F': verbose_level = VERB_APPLIES; break;
verbose_level = VERB_FIXES; break;
case 'p':
case 'a': case 'P':
case 'A': verbose_level = VERB_PROGRESS; break;
verbose_level = VERB_APPLIES; break;
case 't':
case 'p': case 'T':
case 'P': verbose_level = VERB_TESTS; break;
verbose_level = VERB_PROGRESS; break;
case 'e':
case 't': case 'E':
case 'T': verbose_level = VERB_EVERYTHING; break;
verbose_level = VERB_TESTS; break; }
case 'e':
case 'E':
verbose_level = VERB_EVERYTHING; break;
}
}
}
{ while ((pz_find_base[0] == '.') && (pz_find_base[1] == '/'))
static const char var[] = "FIND_BASE"; pz_find_base += 2;
char *pz = getenv (var); if ((pz_find_base[0] != '.') || (pz_find_base[1] != NUL))
if (pz == (char *) NULL) find_base_len = strlen( pz_find_base );
{
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 );
}
/* Compile all the regular expressions now. /* Compile all the regular expressions now.
That way, it is done only once for the whole run. That way, it is done only once for the whole run.
...@@ -584,17 +557,16 @@ create_file () ...@@ -584,17 +557,16 @@ create_file ()
fprintf (stderr, "Fixed: %s\n", pz_curr_file); fprintf (stderr, "Fixed: %s\n", pz_curr_file);
pf = fdopen (fd, "w"); pf = fdopen (fd, "w");
#ifdef LATER /*
{ * IF pz_machine is NULL, then we are in some sort of test mode.
static const char hdr[] = * Do not insert the current directory name. Use a constant string.
"/* DO NOT EDIT THIS FILE.\n\n" */
" It has been auto-edited by fixincludes from /usr/include/%s\n" fprintf (pf, z_std_preamble,
" This had to be done to correct non-standard usages in the\n" (pz_machine == NULL)
" original, manufacturer supplied header file. */\n\n"; ? "fixinc/tests/inc"
: pz_input_dir,
pz_curr_file);
fprintf (pf, hdr, pz_curr_file);
}
#endif
return pf; return pf;
} }
...@@ -953,8 +925,8 @@ fix_applies (p_fixd) ...@@ -953,8 +925,8 @@ fix_applies (p_fixd)
tFixDesc *p_fixd; tFixDesc *p_fixd;
{ {
#ifdef DEBUG #ifdef DEBUG
static const char z_failed[] = "not applying %s %s to %s - " static const char z_failed[] = "not applying %s %s to %s - \
"test %d failed\n"; test %d failed\n";
#endif #endif
const char *pz_fname = pz_curr_file; const char *pz_fname = pz_curr_file;
const char *pz_scan = p_fixd->file_list; const char *pz_scan = p_fixd->file_list;
......
...@@ -146,6 +146,7 @@ fi ...@@ -146,6 +146,7 @@ fi
cd ${INPUT} cd ${INPUT}
INPUT=`${PWDCMD}` INPUT=`${PWDCMD}`
export INPUT
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
......
...@@ -96,6 +96,25 @@ typedef int apply_fix_p_t; /* Apply Fix Predicate Type */ ...@@ -96,6 +96,25 @@ typedef int apply_fix_p_t; /* Apply Fix Predicate Type */
#define _P_(p) () #define _P_(p) ()
#endif #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 /* Test Descriptor
Each fix may have associated tests that determine Each fix may have associated tests that determine
...@@ -161,6 +180,14 @@ typedef struct { ...@@ -161,6 +180,14 @@ typedef struct {
extern int gnu_type_map_ct; 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 * Exported procedures
*/ */
......
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