summaryrefslogtreecommitdiff
path: root/gcc/fixinc
diff options
context:
space:
mode:
authorkorbb <korbb@138bc75d-0d04-0410-961f-82ee72b054a4>1999-06-02 07:08:54 +0000
committerkorbb <korbb@138bc75d-0d04-0410-961f-82ee72b054a4>1999-06-02 07:08:54 +0000
commita99c7b9803f746ec7ecd8d547f2fa8d1f0536125 (patch)
tree40e7e241f1d7dc9975e52f8940866a9742e6cb47 /gcc/fixinc
parentedf2430c4198a7b6f377b0cb047a2f400f63f036 (diff)
downloadgcc-a99c7b9803f746ec7ecd8d547f2fa8d1f0536125.tar.gz
Remove references to setenv/putenv
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@27312 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fixinc')
-rw-r--r--gcc/fixinc/fixincl.c119
-rw-r--r--gcc/fixinc/fixincl.tpl2
-rw-r--r--gcc/fixinc/fixincl.x18
3 files changed, 78 insertions, 61 deletions
diff --git a/gcc/fixinc/fixincl.c b/gcc/fixinc/fixincl.c
index 69533a84df0..036c6fa9d03 100644
--- a/gcc/fixinc/fixincl.c
+++ b/gcc/fixinc/fixincl.c
@@ -104,6 +104,7 @@ typedef struct patch_desc tPatchDesc;
*/
#define FD_MACH_ONLY 0x0000
#define FD_MACH_IFNOT 0x0001
+#define FD_SHELL_SCRIPT 0x0002
#define FD_SKIP_TEST 0x8000
typedef struct fix_desc tFixDesc;
@@ -910,6 +911,70 @@ extract_quoted_files (pz_data, pz_file_name, p_re_match)
}
+
+/* * * * * * * * * * * * *
+
+ This loop should only cycle for 1/2 of one loop.
+ "chain_open" starts a process that uses "read_fd" as
+ its stdin and returns the new fd this process will use
+ for stdout. */
+
+int
+start_fixer (read_fd, p_fixd, pz_file_name)
+ int read_fd;
+ tFixDesc* p_fixd;
+ char* pz_file_name;
+{
+ tSCC z_err[] = "Error %d (%s) starting filter process for %s\n";
+ tCC* pz_cmd_save;
+ char* pz_cmd;
+
+ if ((p_fixd->fd_flags & FD_SHELL_SCRIPT) == 0)
+ pz_cmd = (char*)NULL;
+ else
+ {
+ tSCC z_cmd_fmt[] = "file='%s'\n%s";
+ pz_cmd = (char*)xmalloc (strlen (p_fixd->patch_args[2])
+ + sizeof( z_cmd_fmt )
+ + strlen( pz_file_name ));
+ sprintf (pz_cmd, z_cmd_fmt, pz_file_name, p_fixd->patch_args[2]);
+ pz_cmd_save = p_fixd->patch_args[2];
+ p_fixd->patch_args[2] = pz_cmd;
+ }
+
+ for (;;)
+ {
+ static int failCt = 0;
+ int fd;
+
+ fd = chain_open (read_fd,
+ (t_pchar *) p_fixd->patch_args,
+ (process_chain_head == -1)
+ ? &process_chain_head : (pid_t *) NULL);
+
+ if (fd != -1)
+ {
+ read_fd = fd;
+ break;
+ }
+
+ fprintf (stderr, z_err, errno, strerror (errno),
+ p_fixd->fix_name);
+
+ if ((errno != EAGAIN) || (++failCt > 10))
+ exit (EXIT_FAILURE);
+ sleep (1);
+ }
+
+ if (pz_cmd != (char*)NULL)
+ {
+ free ((void*)pz_cmd);
+ p_fixd->patch_args[2] = pz_cmd_save;
+ }
+
+ return read_fd;
+}
+
/* * * * * * * * * * * * *
Process the potential fixes for a particular include file.
@@ -927,30 +992,6 @@ process (pz_data, pz_file_name)
int read_fd = -1;
int num_children = 0;
- /* IF this is the first time through,
- THEN put the 'file' environment variable into the environment.
- This is used by some of the subject shell scripts and tests. */
-
- if (env_current_file[0] == NUL) {
- strcpy (env_current_file, "file=");
- putenv (env_current_file);
- }
-
- /*
- Ghastly as it is, this actually updates the value of the variable:
-
- putenv(3C) C Library Functions putenv(3C)
-
- DESCRIPTION
- putenv() makes the value of the environment variable name
- equal to value by altering an existing variable or creating
- a new one. In either case, the string pointed to by string
- becomes part of the environment, so altering the string will
- change the environment. string points to a string of the
- form ``name=value.'' The space used by string is no longer
- used once a new string-defining name is passed to putenv().
- */
- strcpy (env_current_file + 5, pz_file_name);
process_chain_head = NOPROCESS;
fprintf (stderr, "%-50s \r", pz_file_name );
/* For every fix in our fix list, ... */
@@ -1059,34 +1100,8 @@ process (pz_data, pz_file_name)
}
}
- /* This loop should only cycle for 1/2 of one loop.
- "chain_open" starts a process that uses "read_fd" as
- its stdin and returns the new fd this process will use
- for stdout. */
-
- for (;;)
- {
- tSCC z_err[] = "Error %d (%s) starting filter process for %s\n";
- static int failCt = 0;
- int fd = chain_open (read_fd,
- (t_pchar *) p_fixd->patch_args,
- (process_chain_head == -1)
- ? &process_chain_head : (pid_t *) NULL);
-
- if (fd != -1)
- {
- read_fd = fd;
- num_children++;
- break;
- }
-
- fprintf (stderr, z_err, errno, strerror (errno),
- p_fixd->fix_name);
-
- if ((errno != EAGAIN) || (++failCt > 10))
- exit (EXIT_FAILURE);
- sleep (1);
- }
+ read_fd = start_fixer (read_fd, p_fixd, pz_file_name);
+ num_children++;
next_fix:
;
diff --git a/gcc/fixinc/fixincl.tpl b/gcc/fixinc/fixincl.tpl
index c9064b1391e..afdd131c66e 100644
--- a/gcc/fixinc/fixincl.tpl
+++ b/gcc/fixinc/fixincl.tpl
@@ -179,6 +179,8 @@ _FOR fix ",\n" =]
[=hackname _up=]_TEST_CT, [=
_IF not_machine _exist =]FD_MACH_IFNOT[=
_ELSE =]FD_MACH_ONLY[=
+ _ENDIF =][=
+ _IF shell _exist =] | FD_SHELL_SCRIPT[=
_ENDIF =],
a[=hackname _cap=]Tests, apz[=hackname _cap=]Patch }[=
diff --git a/gcc/fixinc/fixincl.x b/gcc/fixinc/fixincl.x
index 9490edfcbe6..5b820f93a44 100644
--- a/gcc/fixinc/fixincl.x
+++ b/gcc/fixinc/fixincl.x
@@ -4039,7 +4039,7 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
{ zM88k_Multi_InclName, zM88k_Multi_InclList,
apzM88k_Multi_InclMachs, (regex_t*)NULL,
- M88K_MULTI_INCL_TEST_CT, FD_MACH_ONLY,
+ M88K_MULTI_INCL_TEST_CT, FD_MACH_ONLY | FD_SHELL_SCRIPT,
aM88k_Multi_InclTests, apzM88k_Multi_InclPatch },
{ zMachine_NameName, zMachine_NameList,
@@ -4054,7 +4054,7 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
{ zMath_Gcc_IfndefsName, zMath_Gcc_IfndefsList,
apzMath_Gcc_IfndefsMachs, (regex_t*)NULL,
- MATH_GCC_IFNDEFS_TEST_CT, FD_MACH_ONLY,
+ MATH_GCC_IFNDEFS_TEST_CT, FD_MACH_ONLY | FD_SHELL_SCRIPT,
aMath_Gcc_IfndefsTests, apzMath_Gcc_IfndefsPatch },
{ zNested_CommentName, zNested_CommentList,
@@ -4134,7 +4134,7 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
{ zStdio_Va_ListName, zStdio_Va_ListList,
apzStdio_Va_ListMachs, (regex_t*)NULL,
- STDIO_VA_LIST_TEST_CT, FD_MACH_ONLY,
+ STDIO_VA_LIST_TEST_CT, FD_MACH_ONLY | FD_SHELL_SCRIPT,
aStdio_Va_ListTests, apzStdio_Va_ListPatch },
{ zSun_Bogus_IfdefName, zSun_Bogus_IfdefList,
@@ -4309,31 +4309,31 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
{ zZzz_Ki_IfaceName, zZzz_Ki_IfaceList,
apzZzz_Ki_IfaceMachs, (regex_t*)NULL,
- ZZZ_KI_IFACE_TEST_CT, FD_MACH_ONLY,
+ ZZZ_KI_IFACE_TEST_CT, FD_MACH_ONLY | FD_SHELL_SCRIPT,
aZzz_Ki_IfaceTests, apzZzz_Ki_IfacePatch },
{ zZzz_KiName, zZzz_KiList,
apzZzz_KiMachs, (regex_t*)NULL,
- ZZZ_KI_TEST_CT, FD_MACH_ONLY,
+ ZZZ_KI_TEST_CT, FD_MACH_ONLY | FD_SHELL_SCRIPT,
aZzz_KiTests, apzZzz_KiPatch },
{ zZzz_Ki_CallsName, zZzz_Ki_CallsList,
apzZzz_Ki_CallsMachs, (regex_t*)NULL,
- ZZZ_KI_CALLS_TEST_CT, FD_MACH_ONLY,
+ ZZZ_KI_CALLS_TEST_CT, FD_MACH_ONLY | FD_SHELL_SCRIPT,
aZzz_Ki_CallsTests, apzZzz_Ki_CallsPatch },
{ zZzz_Ki_DefsName, zZzz_Ki_DefsList,
apzZzz_Ki_DefsMachs, (regex_t*)NULL,
- ZZZ_KI_DEFS_TEST_CT, FD_MACH_ONLY,
+ ZZZ_KI_DEFS_TEST_CT, FD_MACH_ONLY | FD_SHELL_SCRIPT,
aZzz_Ki_DefsTests, apzZzz_Ki_DefsPatch },
{ zZzz_Bad_FixesName, zZzz_Bad_FixesList,
apzZzz_Bad_FixesMachs, (regex_t*)NULL,
- ZZZ_BAD_FIXES_TEST_CT, FD_MACH_ONLY,
+ ZZZ_BAD_FIXES_TEST_CT, FD_MACH_ONLY | FD_SHELL_SCRIPT,
aZzz_Bad_FixesTests, apzZzz_Bad_FixesPatch },
{ zZzz_TimeName, zZzz_TimeList,
apzZzz_TimeMachs, (regex_t*)NULL,
- ZZZ_TIME_TEST_CT, FD_MACH_ONLY,
+ ZZZ_TIME_TEST_CT, FD_MACH_ONLY | FD_SHELL_SCRIPT,
aZzz_TimeTests, apzZzz_TimePatch }
};