aboutsummaryrefslogtreecommitdiff
path: root/fixincludes/fixincl.c
diff options
context:
space:
mode:
authorTadek Kijkowski <tkijkowski@gmail.com>2016-09-30 16:36:18 +0000
committerJeff Law <law@gcc.gnu.org>2016-09-30 10:36:18 -0600
commit716028e405fab6526e3580bd060f896bb3672681 (patch)
tree05fe6333f5ee57032bb8dc163aabf2e6c703115d /fixincludes/fixincl.c
parentaf2d4873785d2638c293edf822b26d532d3201aa (diff)
downloadgcc-716028e405fab6526e3580bd060f896bb3672681.zip
gcc-716028e405fab6526e3580bd060f896bb3672681.tar.gz
gcc-716028e405fab6526e3580bd060f896bb3672681.tar.bz2
check.tpl: Convert line endings to unix on test outputs
2016-09-30 Tadek Kijkowski <tkijkowski@gmail.com> * check.tpl: Convert line endings to unix on test outputs * fixfixes.c: Fixed passing file name to apply_fix when SEPARATE_FIX_PROC is defined * fixincl.c: Use system_with_shell, fixes for MinGW and DJGPP * fixlib.c, fixlib.h: Added system_with_shell and fix_path_separators From-SVN: r240664
Diffstat (limited to 'fixincludes/fixincl.c')
-rw-r--r--fixincludes/fixincl.c67
1 files changed, 60 insertions, 7 deletions
diff --git a/fixincludes/fixincl.c b/fixincludes/fixincl.c
index 98bb98d..6dba2f6 100644
--- a/fixincludes/fixincl.c
+++ b/fixincludes/fixincl.c
@@ -74,9 +74,12 @@ int altered_ct = 0;
#endif /* DO_STATS */
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;
+#ifndef SEPARATE_FIX_PROC
+tSCC z_fork_err[] = "Error %d (%s) starting filter process for %s\n";
+#endif
+
static void do_version (void) ATTRIBUTE_NORETURN;
char *load_file (const char *);
void run_compiles (void);
@@ -188,7 +191,7 @@ do_version (void)
puts (zBuf + 5);
exit (strcmp (run_shell (zBuf), program_id));
#else
- exit (system (zBuf));
+ exit (system_with_shell (zBuf));
#endif
}
@@ -275,6 +278,11 @@ initialize ( int argc, char** argv )
/* NULL as the first argument to `tempnam' causes it to DTRT
wrt the temporary directory where the file will be created. */
pz_temp_file = tempnam( NULL, "fxinc" );
+
+#if defined(__MINGW32__)
+ fix_path_separators (pz_temp_file);
+#endif
+
# endif
signal (SIGQUIT, SIG_IGN);
@@ -566,6 +574,26 @@ fi";
free ((void *) pz_res);
return res;
}
+#elif defined(__MINGW32__) || defined(__DJGPP__)
+static int
+test_test (tTestDesc* p_test, char* pz_test_file)
+{
+ tSCC cmd_fmt[] =
+#if defined(__DJGPP__)
+ "file=%s; test %s >/dev/null 2>/dev/null";
+#else
+ "file=%s; test %s > /dev/null 2>&1";
+#endif
+ int res;
+
+ char *cmd_buf = XNEWVEC (char, strlen(cmd_fmt) + strlen(pz_test_file) + strlen(p_test->pz_test_text));
+
+ sprintf (cmd_buf, cmd_fmt, pz_test_file, p_test->pz_test_text);
+ res = system_with_shell (cmd_buf);
+
+ free (cmd_buf);
+ return res ? SKIP_FIX : APPLY_FIX;
+}
#else
/*
* IF we are in MS-DOS land, then whatever shell-type test is required
@@ -887,7 +915,7 @@ fix_with_system (tFixDesc* p_fixd,
else /* NOT an "internal" fix: */
{
size_t parg_size;
-#ifdef __MSDOS__
+#if defined(__MSDOS__) && !defined(__DJGPP__)
/* Don't use the "src > dstX; rm -f dst; mv -f dstX dst" trick:
dst is a temporary file anyway, so we know there's no other
file by that name; and DOS's system(3) doesn't mind to
@@ -906,12 +934,18 @@ fix_with_system (tFixDesc* p_fixd,
implementations cannot cope :-(. */
tSCC z_cmd_fmt[] = " %s > %sX ; rm -f %s; mv -f %sX %s";
#endif
+ tSCC z_subshell_start[] = "( ";
+ tSCC z_subshell_end[] = " ) < ";
tCC** ppArgs = p_fixd->patch_args;
argsize = sizeof( z_cmd_fmt ) + strlen( pz_temp_file )
+ strlen( pz_file_source );
parg_size = argsize;
+ if (p_fixd->fd_flags & FD_SHELL_SCRIPT)
+ {
+ argsize += strlen( z_subshell_start ) + strlen ( z_subshell_end );
+ }
/*
* Compute the size of the command line. Add lotsa extra space
@@ -937,6 +971,16 @@ fix_with_system (tFixDesc* p_fixd,
ppArgs = p_fixd->patch_args;
/*
+ * If it's shell script, enclose it in parentheses and skip "sh -c".
+ */
+ if (p_fixd->fd_flags & FD_SHELL_SCRIPT)
+ {
+ strcpy (pz_scan, z_subshell_start);
+ pz_scan += strlen (z_subshell_start);
+ ppArgs += 2;
+ }
+
+ /*
* Copy the program name, unquoted
*/
{
@@ -978,17 +1022,26 @@ fix_with_system (tFixDesc* p_fixd,
}
/*
+ * Close parenthesis if it's shell script.
+ */
+ if (p_fixd->fd_flags & FD_SHELL_SCRIPT)
+ {
+ strcpy (pz_scan, z_subshell_end);
+ pz_scan += strlen (z_subshell_end);
+ }
+
+ /*
* add the file machinations.
*/
-#ifdef __MSDOS__
+#if defined(__MSDOS__) && !defined(__DJGPP__)
sprintf (pz_scan, z_cmd_fmt, pz_file_source, pz_temp_file );
#else
sprintf (pz_scan, z_cmd_fmt, pz_file_source, pz_temp_file,
pz_temp_file, pz_temp_file, pz_temp_file);
#endif
}
- system( pz_cmd );
- free( (void*)pz_cmd );
+ system_with_shell (pz_cmd);
+ free (pz_cmd);
}
/* * * * * * * * * * * * *
@@ -1090,7 +1143,7 @@ fix_applies (tFixDesc* p_fixd)
t_bool saw_sum_test = BOOL_FALSE;
t_bool one_sum_passed = BOOL_FALSE;
-#ifdef SEPARATE_FIX_PROC
+#if defined(__MSDOS__) && !defined(__DJGPP__)
/*
* There is only one fix that uses a shell script as of this writing.
* I hope to nuke it anyway, it does not apply to DOS and it would