char *pz_machine = NULL;
int find_base_len = 0;
+typedef enum {
+ VERB_SILENT = 0,
+ VERB_FIXES,
+ VERB_APPLIES,
+ VERB_PROGRESS,
+ VERB_TESTS,
+ VERB_EVERYTHING
+} te_verbose;
+
+te_verbose verbose_level = VERB_PROGRESS;
+
+#define VLEVEL(l) (verbose_level >= l)
+#define NOT_SILENT VLEVEL(VERB_FIXES)
+
pid_t process_chain_head = (pid_t) -1;
char* pz_curr_file; /* name of the current file under test/fix */
} /* for (;;) */
#ifdef DO_STATS
- {
+ if (VLEVEL( VERB_PROGRESS )) {
tSCC zFmt[] =
"\
Processed %5d files containing %d bytes \n\
}
}
+ {
+ 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;
+ }
+ }
+ }
+
{
static const char var[] = "FIND_BASE";
char *pz = getenv (var);
{
if (! WIFEXITED( status ))
{
- fprintf (stderr, "child process %d is hung on signal %d\n",
- child, WSTOPSIG( status ));
+ if (NOT_SILENT)
+ fprintf (stderr, "child process %d is hung on signal %d\n",
+ child, WSTOPSIG( status ));
exit (EXIT_FAILURE);
}
if (WEXITSTATUS( status ) != 0)
{
- fprintf (stderr, "child process %d exited with status %d\n",
- child, WEXITSTATUS( status ));
+ if (NOT_SILENT)
+ fprintf (stderr, "child process %d exited with status %d\n",
+ child, WEXITSTATUS( status ));
exit (EXIT_FAILURE);
}
break; /* normal child completion */
break;
default:
- fprintf (stderr, "Error %d (%s) waiting for %d to finish\n",
- errno, strerror( errno ), child );
+ if (NOT_SILENT)
+ fprintf (stderr, "Error %d (%s) waiting for %d to finish\n",
+ errno, strerror( errno ), child );
/* FALLTHROUGH */
case ECHILD: /* no children to wait for?? */
if (stat (fname, &stbf) != 0)
{
- fprintf (stderr, "error %d (%s) stat-ing %s\n",
- errno, strerror (errno), fname );
+ if (NOT_SILENT)
+ fprintf (stderr, "error %d (%s) stat-ing %s\n",
+ errno, strerror (errno), fname );
return (char *) NULL;
}
if (stbf.st_size == 0)
if (data_map_fd < 0)
{
- fprintf (stderr, "error %d (%s) opening %s for read\n",
- errno, strerror (errno), fname);
+ if (NOT_SILENT)
+ fprintf (stderr, "error %d (%s) opening %s for read\n",
+ errno, strerror (errno), fname);
return (char*)NULL;
}
errno, strerror (errno), fname);
exit (EXIT_FAILURE);
}
- fprintf (stderr, "Fixed: %s\n", pz_curr_file);
+ if (NOT_SILENT)
+ fprintf (stderr, "Fixed: %s\n", pz_curr_file);
pf = fdopen (fd, "w");
#ifdef LATER
char *pz_dir_end = strrchr (pz_fixed_file, '/');
char *pz_incl_quot = pz_data;
- fprintf (stderr, "Quoted includes in %s\n", pz_fixed_file);
+ if (VLEVEL( VERB_APPLIES ))
+ fprintf (stderr, "Quoted includes in %s\n", pz_fixed_file);
/* Set "pz_fixed_file" to point to the containing subdirectory of the source
If there is none, then it is in our current directory, ".". */
p_fixd->patch_args[2] = pz_cmd;
}
+ /* Start a fix process, handing off the previous read fd for its
+ stdin and getting a new fd that reads from the fix process' stdout.
+ We normally will not loop, but we will up to 10 times if we keep
+ getting "EAGAIN" errors.
+
+ */
for (;;)
{
static int failCt = 0;
sleep (1);
}
+ /* IF we allocated a shell script command,
+ THEN free it and restore the command format to the fix description */
if (pz_cmd != (char*)NULL)
{
free ((void*)pz_cmd);
fix_applies (p_fixd)
tFixDesc *p_fixd;
{
+#ifdef DEBUG
+ static const char z_failed[] = "not applying %s to %s - test %d failed\n";
+#endif
int test_ct;
tTestDesc *p_test;
pz_scan = strstr (pz_scan + 1, pz_fname);
/* IF we can't match the string at all,
THEN bail */
- if (pz_scan == (char *) NULL)
+ if (pz_scan == (char *) NULL) {
+#ifdef DEBUG
+ if (VLEVEL( VERB_EVERYTHING ))
+ fprintf (stderr, "file %s not in list for %s\n",
+ pz_fname, p_fixd->fix_name );
+#endif
return BOOL_FALSE;
+ }
/* IF the match is surrounded by the '|' markers,
THEN we found a full match -- time to run the tests */
switch (p_test->type)
{
case TT_TEST:
- if (test_test (p_test, pz_curr_file) != APPLY_FIX)
+ if (test_test (p_test, pz_curr_file) != APPLY_FIX) {
+#ifdef DEBUG
+ if (VLEVEL( VERB_EVERYTHING ))
+ fprintf (stderr, z_failed, p_fixd->fix_name, pz_fname,
+ p_fixd->test_ct - test_ct);
+#endif
return BOOL_FALSE;
+ }
break;
case TT_EGREP:
- if (egrep_test (pz_curr_data, p_test) != APPLY_FIX)
+ if (egrep_test (pz_curr_data, p_test) != APPLY_FIX) {
+#ifdef DEBUG
+ if (VLEVEL( VERB_EVERYTHING ))
+ fprintf (stderr, z_failed, p_fixd->fix_name, pz_fname,
+ p_fixd->test_ct - test_ct);
+#endif
return BOOL_FALSE;
+ }
break;
case TT_NEGREP:
- if (egrep_test (pz_curr_data, p_test) == APPLY_FIX)
+ if (egrep_test (pz_curr_data, p_test) == APPLY_FIX) {
+#ifdef DEBUG
+ if (VLEVEL( VERB_EVERYTHING ))
+ fprintf (stderr, z_failed, p_fixd->fix_name, pz_fname,
+ p_fixd->test_ct - test_ct);
+#endif
/* Negated sense */
return BOOL_FALSE;
+ }
break;
case TT_FUNCTION:
if (run_test (p_test->pz_test_text, pz_curr_file, pz_curr_data)
- != APPLY_FIX)
+ != APPLY_FIX) {
+#ifdef DEBUG
+ if (VLEVEL( VERB_EVERYTHING ))
+ fprintf (stderr, z_failed, p_fixd->fix_name, pz_fname,
+ p_fixd->test_ct - test_ct);
+#endif
return BOOL_FALSE;
+ }
break;
}
}
#ifdef DO_STATS
process_ct++;
#endif
- fprintf (stderr, "%6d %-50s \r", data_map_size, pz_curr_file );
+ if (VLEVEL( VERB_PROGRESS ))
+ fprintf (stderr, "%6d %-50s \r", data_map_size, pz_curr_file );
if (strstr (pz_curr_data, gnu_lib_mark) != (char *) NULL)
{
UNLOAD_DATA();
if (! fix_applies (p_fixd))
continue;
- fprintf (stderr, "Applying %-24s to %s\n",
- p_fixd->fix_name, pz_curr_file);
+ if (VLEVEL( VERB_APPLIES ))
+ fprintf (stderr, "Applying %-24s to %s\n",
+ p_fixd->fix_name, pz_curr_file);
if (p_fixd->fd_flags & FD_REPLACEMENT)
{