* Various changes.

This commit is contained in:
Paul Smith 1999-08-22 17:50:57 +00:00
parent 4ff6c62456
commit 6fa76a7d15
6 changed files with 88 additions and 39 deletions

View file

@ -1,4 +1,21 @@
1999-08-13 Paul D. Smith <psmith@gnu.org>
1999-08-20 Paul D. Smith <psmith@gnu.org>
* variable.c (try_variable_definition): Allocate for variable
expansion in f_append with a simple variable: if we're looking at
target-specific variables we don't want to trash the buffer.
Noticed by Reiner Beninga <Reiner.Beninga@mchp.siemens.de>.
1999-08-16 Eli Zaretskii <eliz@is.elta.co.il>
* main.c (main) [__MSDOS__]: Mirror any backslashes in argv[0], to
avoid problems in shell commands that use backslashes as escape
characters.
1999-08-16 Paul D. Smith <psmith@gnu.org>
* Version 3.77.93 released.
1999-08-13 Paul D. Smith <psmith@gnu.org
* function.c (func_if): New function $(if ...) based on the
original by Han-Wen but reworked quite a bit.
@ -11,9 +28,9 @@
1999-08-12 Paul D. Smith <psmith@gnu.org>
Argh. Another jobserver algorithm change. We conveniently forgot
that the blocking bit is shared by all users of the pipe, it's not
a per-process setting. Since we have many make processes all
Another jobserver algorithm change. We conveniently forgot that
the blocking bit is shared by all users of the pipe, it's not a
per-process setting. Since we have many make processes all
sharing the pipe we can't use the blocking bit as a signal handler
flag. Instead, we'll dup the pipe's read FD and have the SIGCHLD
handler close the dup'd FD. This will cause the read() to fail

60
job.c
View file

@ -90,7 +90,7 @@ static int amiga_batch_file;
#endif
#ifdef HAVE_WAITPID
# define WAIT_NOHANG (status) waitpid (-1, (status), WNOHANG)
# define WAIT_NOHANG(status) waitpid (-1, (status), WNOHANG)
#else /* Don't have waitpid. */
# ifdef HAVE_WAIT3
# ifndef wait3
@ -326,13 +326,11 @@ child_handler (sig)
{
++dead_children;
#ifdef HAVE_JOBSERVER
if (job_rfd >= 0)
{
close (job_rfd);
job_rfd = -1;
}
#endif
if (debug_flag)
printf (_("Got a SIGCHLD; %u unreaped children.\n"), dead_children);
@ -348,19 +346,35 @@ extern int shell_function_pid, shell_function_completed;
complete child, waiting for it to die if necessary. If ERR is nonzero,
print an error message first. */
static int rc_block, rc_reap_all, rc_got_block, rc_start_rfd, rc_end_rfd;
void
reap_children (block, err)
int block, err;
{
WAIT_T status;
#ifdef WAIT_NOHANG
/* Initially, assume we have some. */
int reap_more = 1;
#ifdef WAIT_NOHANG
# define REAP_MORE reap_more
#else
# define REAP_MORE dead_children
#endif
rc_block = block;
rc_reap_all = 0;
rc_got_block = 0;
rc_start_rfd = job_rfd;
/* As long as:
We have at least one child outstanding OR a shell function in progress,
AND
We're blocking for a complete child OR there are more children to reap
we'll keep reaping children. */
while ((children != 0 || shell_function_pid != 0) &&
(block || REAP_MORE))
{
@ -456,10 +470,11 @@ reap_children (block, err)
if (pid < 0)
{
/* The wait*() failed miserably. Punt. */
/* EINTR? Try again. */
if (EINTR_SET)
goto local_wait;
/* The wait*() failed miserably. Punt. */
pfatal_with_name ("wait");
}
else if (pid > 0)
@ -472,26 +487,25 @@ reap_children (block, err)
else
{
/* No local children are dead. */
#ifdef WAIT_NOHANG
reap_more = 0;
#endif
if (block && any_remote)
{
/* Now try a blocking wait for a remote child. */
pid = remote_status (&exit_code, &exit_sig, &coredump, 1);
if (pid < 0)
goto remote_status_lose;
else if (pid == 0)
/* No remote children either. Finally give up. */
break;
else
/* We got a remote child. */
remote = 1;
}
else
break;
rc_reap_all = 1;
if (!block || !any_remote)
break;
/* Now try a blocking wait for a remote child. */
pid = remote_status (&exit_code, &exit_sig, &coredump, 1);
if (pid < 0)
goto remote_status_lose;
else if (pid == 0)
/* No remote children either. Finally give up. */
break;
/* We got a remote child. */
remote = 1;
}
#endif /* !__MSDOS__, !Amiga, !WINDOWS32. */
#ifdef __MSDOS__
/* Life is very different on MSDOS. */
pid = dos_pid - 1;
@ -703,8 +717,10 @@ reap_children (block, err)
/* Only block for one child. */
block = 0;
rc_block = block;
}
rc_end_rfd = job_rfd;
return;
}

16
main.c
View file

@ -945,7 +945,7 @@ int main (int argc, char ** argv)
if (print_version_flag)
die (0);
#if !defined(__MSDOS__) && !defined(VMS)
#ifndef VMS
/* Set the "MAKE_COMMAND" variable to the name we were invoked with.
(If it is a relative pathname with a slash, prepend our directory name
so the result will run the same program regardless of the current dir.
@ -963,9 +963,21 @@ int main (int argc, char ** argv)
strneq(argv[0], "//", 2))
argv[0] = xstrdup(w32ify(argv[0],1));
#else /* WINDOWS32 */
#ifdef __MSDOS__
if (strchr (argv[0], '\\'))
{
char *p;
argv[0] = xstrdup (argv[0]);
for (p = argv[0]; *p; p++)
if (*p == '\\')
*p = '/';
}
#else /* !__MSDOS__ */
if (current_directory[0] != '\0'
&& argv[0] != 0 && argv[0][0] != '/' && index (argv[0], '/') != 0)
argv[0] = concat (current_directory, "/", argv[0]);
#endif /* !__MSDOS__ */
#endif /* WINDOWS32 */
#endif
@ -1339,6 +1351,8 @@ int main (int argc, char ** argv)
submakes it's the token they were given by their parent. For the
top make, we just subtract one from the number the user wants. */
job_slots = 1; /* !!!!!DEBUG!!!!! */
while (--job_slots)
{
write (job_fds[1], &c, 1);

View file

@ -18,7 +18,7 @@ MTEMPLATES = Makefile.DOS SMakefile
# General rule for turning a .template into a regular file.
#
$(TEMPLATES) : % : %.template configure.in
$(TEMPLATES) : % : %.template Makefile
rm -f $@
sed -e 's@%VERSION%@$(VERSION)@g' \
-e 's@%PACKAGE%@$(PACKAGE)@g' \
@ -27,7 +27,7 @@ $(TEMPLATES) : % : %.template configure.in
# Construct Makefiles by adding on dependencies, etc.
#
$(MTEMPLATES) : % : %.template .dep_segment Makefile.am maintMakefile
$(MTEMPLATES) : % : %.template .dep_segment Makefile
rm -f $@
sed -e 's@%VERSION%@$(VERSION)@g' \
-e 's@%PROGRAMS%@$(bin_PROGRAMS)@g' \
@ -40,7 +40,7 @@ $(MTEMPLATES) : % : %.template .dep_segment Makefile.am maintMakefile
cat $(word 2,$^) >>$@
chmod a-w $@
NMakefile: NMakefile.template .dep_segment Makefile.am maintMakefile
NMakefile: NMakefile.template .dep_segment Makefile
rm -f $@
cp $< $@
echo >>$@; echo '# --------------- DEPENDENCIES' >>$@; echo '#' >>$@; \
@ -49,7 +49,7 @@ NMakefile: NMakefile.template .dep_segment Makefile.am maintMakefile
# Construct build.sh.in
#
build.sh.in: build.template Makefile.am maintMakefile
build.sh.in: build.template Makefile
rm -f $@
sed -e 's@%objs%@$(filter-out remote-%, $(make_OBJECTS)@g' \
-e 's@%globobjs%@$(patsubst %.c,%.o,$(globsrc)))@g' \

View file

@ -2750,9 +2750,9 @@ called @file{@var{name}.d} from a C source file called @file{@var{name}.c}:
@smallexample
@group
%.d: %.c
$(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< \
| sed '\''s/\($*\)\.o[ :]*/\1.o $@@ : /g'\'' > $@@; \
[ -s $@@ ] || rm -f $@@'
set -e; $(CC) -M $(CPPFLAGS) $< \
| sed 's/\($*\)\.o[ :]*/\1.o $@@ : /g' > $@@; \
[ -s $@@ ] || rm -f $@@
@end group
@end smallexample

View file

@ -780,9 +780,9 @@ try_variable_definition (flocp, line, origin)
case f_simple:
/* A simple variable definition "var := value". Expand the value.
We have to allocate memory since otherwise it'll clobber the
variable buffer, and we still need that. */
alloc_value = allocated_variable_expand (p);
value = alloc_value;
variable buffer, and we may still need that if we're looking at a
target-specific variable. */
value = alloc_value = allocated_variable_expand (p);
break;
case f_conditional:
/* A conditional variable definition "var ?= value".
@ -824,8 +824,10 @@ try_variable_definition (flocp, line, origin)
else
/* The previous definition of the variable was simple.
The new value comes from the old value, which was expanded
when it was set; and from the expanded new value. */
p = variable_expand (p);
when it was set; and from the expanded new value. Allocate
memory for the expansion as we may still need the rest of the
buffer if we're looking at a target-specific variable. */
p = alloc_value = allocated_variable_expand (p);
oldlen = strlen (v->value);
newlen = strlen (p);