Commit Graph

697 Commits

Author SHA1 Message Date
Hartmut Brandt
d8549718a9 Move some comments around to where they belong and remove some unneccessary
gcc magic.

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.229)
2005-05-12 11:16:04 +00:00
Hartmut Brandt
f7a01b8dcc Convert Compat_RunCommand() to use ProcWait(). This also gives Cmd_Exec()
the potential to handle interrupts which it doesn't currently.

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.228)
2005-05-12 11:09:45 +00:00
Hartmut Brandt
32b5d9451b Make a function ProcWait() that waits for the given process.
Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.227)
2005-05-12 10:55:37 +00:00
Hartmut Brandt
4eb51779c8 Overhaul the fork(), exec() code. Put all the common handling that
takes place in the child process in a function ProcExec(). Make sure,
that the child does not call malloc() or other potential dangerous
functions (there are still calls to Punt() in the error case that
should go away). Allocate the argv string via malloc to overcome
the non-constness bug of the execvp prototype. Change the handling of
shell meta-characters and move the builtin list near the list of shell
builtins. Both of these lists should actuall be configurable by the .SHELL
target since they depend on the shell used.

Patch:		7.21[2-9], 7.22[0-46]
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-12 10:40:57 +00:00
Hartmut Brandt
4aa6beaf60 Move the definitions of the OP_* constants from make.h into GNode.h
where they actually belong to. Move the definitions of the strings
for special macros like "$*" from make.h to parse.h - they're used
only in the parser.

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.211)
2005-05-10 14:27:04 +00:00
Hartmut Brandt
824060d705 Path_Expand() expects its first argument to be writeable so put the
default system directory into a writeable character array before passing
it to Path_Expand().

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.210)
2005-05-10 14:23:31 +00:00
Hartmut Brandt
e8b4c1591a Move declarations of variables belonging to the variable module
from globals.h into var.h.

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.209)
2005-05-10 14:16:40 +00:00
Hartmut Brandt
413c6d2540 Style: remove spaces before tabs.
Patch:	7.207
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 14:13:20 +00:00
Hartmut Brandt
a139b7bac1 Move the remaining two prototypes from nonints.h to make.h and
remove nonints.h.

Patch:	7.204
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 14:10:44 +00:00
Hartmut Brandt
9a910e11d1 Make shellPath and shellName static - they're used in job.c only.
Move definition of parsing error levels from make.h into parse.h.

Patches:	7.202,7.203
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 14:06:19 +00:00
Hartmut Brandt
43ad410a92 Make the three versions of fork() more uniform.
Patch:		7.201 (idea taken, but done differently)
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 14:03:28 +00:00
Hartmut Brandt
d7bc2a41df Move the defines for TMPPAT and KQUEUE from the public job.h into job.c
since they are used only there.

Patch:		7.200
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 13:48:15 +00:00
Hartmut Brandt
626dc02016 Merge compat.c into job.c. There is a lot in common between these
files and we are going to factor this out.

Patch:		7.199 (slightly changed)
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 13:45:29 +00:00
Hartmut Brandt
c26295ddea Move Cmd_Exec() from main.c to job.c and fix its prototype. This
results in a warning that will go away soon.

Patch:		7.198
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 13:18:58 +00:00
Hartmut Brandt
671adc85da Var_SubstOnly() is only used to subsitute a variable from the global
context (and only in one place to substitute the .for variable). Therefor
there is no need to pass the context as a parameter.

Patch:	7.197
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 12:02:15 +00:00
Hartmut Brandt
45b3caadf9 Move the declaration of VAR_CMD and VAR_GLOBAL from globals.h to var.h
Patch:		7.196
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 11:58:52 +00:00
Hartmut Brandt
3b5ff5e82d Clean up comments. No code changes.
Patch:		7.195
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 11:55:46 +00:00
Hartmut Brandt
74369e814b Merge var_modify.c into var.c and move types and function declarations
that are now used only in var.c from var.h to var.c

Patches:	7.193,7.194
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 11:53:20 +00:00
Hartmut Brandt
70d7035e1f Move some debugging code from targ.c to var.c where it actually belongs.
Patch:		7.192
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 08:14:26 +00:00
Hartmut Brandt
103823e628 Make make a little bit more POSIXish with regard to option parsing:
take everything after -- as either a macro assignment or a target.
Note that make still reorders arguments before --: anything starting
with a dash is considered an option, anything which contains an equal
sign is considered a macro assignment and everything else a target.
This still is not POSIX with regard to the options, but it will probably
not change because it has been make's behaviour for ages.
Add a new function Var_Match() that correctly skips a macro call by just
doing the same as Var_Subst() but without producing output. This will help
making the parser more robust.

Patches:	7.190,7.191
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 08:06:13 +00:00
Hartmut Brandt
02c3270da1 Split Var_Subst() into two functions: Var_SubstOnly() which substitutes
only one variable and Var_Subst() which substitutes all. Split out the
test whether a variable should not be expanded into match_var().
Make access to the input string consistently using str[]. Remove two
unused functions: Var_GetTail() and Var_GetHead().

Patches:	7.184-7.189
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-09 14:06:04 +00:00
Hartmut Brandt
352a63dee8 Introduce a new pseudo-target .EXPORTVAR which allows to put a
make macro into the environment of programs executed by make. This
has approximately the same function as gmake's export directive.
The form of a pseudo target was deliberately choosen to minimize work
for POSIX compatibility (Makefiles are not allowed to use any targets
starting with a dot and consisting only of uppercase letters except those
specified in the standard when they want POSIX compatible behaviour, so
such a Makefile can never contain .EXPORTVAR.)
Change the handling of macros coming from the environment: instead
of asking the environment for each variable we could not find otherwise
put all the environment variables in a special variable environment just
at start up.

This has been tested on the ports cluster by kris.

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-06 18:30:06 +00:00
Hartmut Brandt
be7a5506e8 Rename the directive_hash.[ch] files to hash_tables.[ch] now
that there are more than one hash table in them. There is no
history to preserve here, so go without a repo-copy.

Asked for by:	Max Okumoto <okumoto@ucsd.edu>
2005-04-29 15:15:28 +00:00
Hartmut Brandt
3dece030a5 Implement a pseudo-target .WARN that allows toggeling the warning flags
for the current make. This does not override flags specified on the
command line and these settings are not passed to sub-makes.
2005-04-29 14:37:44 +00:00
Hartmut Brandt
48c49ace00 Introduce a flag to enable extended warnings (-x) and make them off
by default. This should fix the problem of getting lots of errors
when building with an up-to-date make and old *.mk files.
2005-04-28 15:37:25 +00:00
Hartmut Brandt
b1880272f1 Use a minimal perfect hash for the special sources/targets too. Add
the corresponding magic to create the hash function to the Makefile.
2005-04-28 12:05:43 +00:00
Hartmut Brandt
47cc56ab55 Fix the $$FreeBSD$$ that should be written verbatim to directive_hash.c
so that it doesn't get replaced with the Makefile's revision.
2005-04-28 08:04:46 +00:00
Hartmut Brandt
2274441da6 Move the hash function for directives into its own file and add
a Makefile target to re-created this file. Note, that there is no
explicite dependency to automatically re-create the file, because this
is needed only when the directive table changes and it requires the
(yet to come) devel/mph port.

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (first version)
2005-04-28 07:55:55 +00:00
Hartmut Brandt
beed8bb5f6 Split VarFind() into a series of functions tailored for the different sets
of flags originally passed to VarFind(). This eliminates the code by
removing a bunch of tests.

Patch:		7.173

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-04-13 11:40:44 +00:00
Hartmut Brandt
797bb929c6 Parse_Init() is gone so remove comments that mention it. 2005-04-11 07:40:54 +00:00
Hartmut Brandt
9e1e6570f3 Remove an unneccesary forward declaration for MainParseArgs().
getopt() may be called several times - make sure to set optreset
to reset it. Cleanup handling of non-option arguments.
Remove some misleading comments.

Patch:		7.171

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-04-11 07:32:49 +00:00
Hartmut Brandt
8f5850c6f4 Remove the call to Parse_Init() - there is no need to initialize
a static variable to NULL. Forgot this in the previous commit to
parse.[ch].
2005-04-11 07:26:21 +00:00
Hartmut Brandt
f520690c2c Rework the directive parsing code. Instead of using a lot of strcmp()s
on every line that starts with a dot use a minimal perfect hash
function and a single strcmp() on the first word after the dot
to find out whether it is really a directive call and, if yes, which
one. Then directly dispatch to a handler function for that directive
(or fall through to the dependency handling code). This makes the
directive parse a little bit more strict about the syntax: the directive
word must be followed by a character that is not alphanumerical and not
an underline (making .undefFOO illegal); .endif and .else can only be
followed by comments.
2005-04-11 07:20:10 +00:00
Hartmut Brandt
2a30c95875 Move the code for parsing .for and .if statements to the place where the
other directives are handled.
2005-04-08 09:03:40 +00:00
Hartmut Brandt
a45b448277 When Parse_Error is called after the top-level Makefile is closed we
have no CURFILE anymore so we cannot print a file name or line number.

When ParseSkipLine() returns NULL (it does this when it has detected an
EOF in an .if block) try to pop the input stack and process the next line
2005-04-07 14:39:38 +00:00
Hartmut Brandt
a9c22e4739 Handle popping of the input stack in ParseReadLine() instead of
Parse_File(). Remove a comment and a piece of code comming from
ancient times when the if-directive read like #if and not .if.
Correctly analyze the first character of a line.
2005-04-07 11:29:39 +00:00
Hartmut Brandt
192ee26c2f Mostly stylistic changes: remove the noPLen field from the Shell
structure - it is just the strlen() of noPrint. Inline JobCondPassSig()
in the only function JobPassSig() using it. Fix the argument types
of JobPrintCommand(). Better parsing for the .SHELL target keywords.
2005-04-07 11:26:15 +00:00
Hartmut Brandt
506e445a6c There is not much sense in having an else after Punt() and _exit() which
never return. Also use pid_t for variables holding PIDs.
2005-04-05 12:33:54 +00:00
Hartmut Brandt
683f92e306 Put parantheses into 'if (foo && bar & flag)'. While they are not strictly
needed, they are useful for the human reader.
2005-04-05 08:14:40 +00:00
Hartmut Brandt
d265c4e11a Remove lots if irritating parantheses and fix two comments.
Checked by:	md5
2005-04-05 08:09:48 +00:00
Hartmut Brandt
e7e49de4e5 Remove the definition for STATIC and just use static. 2005-04-05 07:44:11 +00:00
Hartmut Brandt
2a2532d215 Remove unneccessary local prototypes. 2005-04-05 07:43:02 +00:00
Hartmut Brandt
d9e678f13f The static tfile is used only in one single function so move it into that
function.
2005-04-05 07:40:40 +00:00
Hartmut Brandt
29c6a883cd The tfile field of struct Job isn't used anymore since revision 1.22 so
remove it now.
2005-04-05 07:32:12 +00:00
Hartmut Brandt
49ecabba2d Use a type-safe intrusive list to put jobs on the jobs or stoppedJobs list
instead of the generic Lst.
2005-04-01 16:24:25 +00:00
Hartmut Brandt
4d52cd1820 Remove a forward declaration that isn't needed anymore. 2005-04-01 16:23:48 +00:00
Hartmut Brandt
4bc60ea3fb Both struct Job and struct Shell are only used inside job.c so there is
no need to have them in a header file that is included by other modules.
Move them both into the c-file.
2005-04-01 13:35:35 +00:00
Hartmut Brandt
f54201efce Style: fix indentation. 2005-04-01 13:25:45 +00:00
Hartmut Brandt
a2e1fc0052 Style: fix indentation. 2005-04-01 13:06:05 +00:00
Hartmut Brandt
bfcf27787a Style: indentation. 2005-04-01 13:02:17 +00:00
Hartmut Brandt
ab9267be40 Style: Indentation. 2005-04-01 12:42:03 +00:00
Hartmut Brandt
c0489a0689 Style: fix indentation. 2005-04-01 12:31:15 +00:00
Hartmut Brandt
54348124ed Style: fix indentation. 2005-04-01 11:20:17 +00:00
Hartmut Brandt
5682c1009c Style: fix indentation. 2005-04-01 11:12:29 +00:00
Hartmut Brandt
901275d3b7 Style: fix indentation. 2005-04-01 10:53:43 +00:00
Hartmut Brandt
c06ac233d7 Document the new -A flag for ignoring archive errors. 2005-03-31 11:40:53 +00:00
Hartmut Brandt
5e0a7a4450 Almost complete rewrite of the archive code (except for the Makefile parsing
part). Archive handling was broken at least since the move from BSD ar/ranlib
to GNU binutils because of the different archive format. This rewrite fixes
this by making make to carry around the defines for all formats (it supports)
so it can support all of them independent of the actually used one. The
supported formats are: traditional BSD (this seems to come from V7 at least,
short names only and __.SYMDEF), BSD4.4 (long names with #1/ and __.SYMDEF)
and SysV (extra name table and //). The only format not supported are broken
traditional archives where the member names are truncated to 15 characters.

Errors in the archive are not ignored anymore, but cause make to stop with
an error message. The command line option -A causes these errors to become
non-fatal. This is almost compatible with previous usage except for the
error message printed in any case.

Use a type-safe intrusive list for the archive cache.

Reviewed by:	Max Okumoto <okumoto@ucsd.edu> (without new error handling)
2005-03-31 11:35:56 +00:00
Hartmut Brandt
ae6bff540a Move the MAX macro to a util.h so it becomes usable in other modules.
Suggested by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-31 11:12:45 +00:00
Hartmut Brandt
ba467ce430 Make the structure for handling the input stack local to the parse
module. The only module accessing it (the current line number) was the
condition module, so pass the current line number as a function argument.
Centralize the pushing of new input sources into one function
ParsePushInput() and rename the function handling the popping from ParseEOF()
to ParsePopInput(). Make the entire thing a little bit clearer, by holding
the current input source in the top element of the stack instead of
using extra variables for this. Use a type-safe intrusive list for the
input stack.
2005-03-30 15:18:58 +00:00
Hartmut Brandt
f43eb6f83b Fix a bug introduced in a previous commit: ParseModifier() consumes
characters so it is not safe to move around code from
before it to after it. This should fix problems with building the
documentation.

Patch:		7.170

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-30 15:14:22 +00:00
Hartmut Brandt
fe504834f3 Style: de-lispify by removing extra parantheses in conditional expressions. 2005-03-23 16:28:57 +00:00
Hartmut Brandt
1b0d28102e Style: make indentation 8 characters. 2005-03-23 16:14:41 +00:00
Hartmut Brandt
fb1dac11b4 Make paths an explicite datatype instead of using the generic Lst.
A Path is now a TAILQ of PathElements each of which just points to
a reference counted directory. Rename all functions dealing with Paths
from the Dir_ prefix to a Path_ prefix.
2005-03-23 12:56:15 +00:00
Hartmut Brandt
76a6d2363f Style: <space><tab> -> <tab> 2005-03-22 12:59:02 +00:00
Hartmut Brandt
cbb7c3931c Rename struct Path to struct Dir and move it into the C-file. It
is not used outside.
2005-03-22 12:54:46 +00:00
Hartmut Brandt
35167ece76 Remove debugging code that crept in in the last commit. 2005-03-22 12:52:00 +00:00
Hartmut Brandt
ad6ba6872a Remove Lst_Find() and Lst_FindFrom() now that they aren't needed anymore. 2005-03-22 12:40:24 +00:00
Hartmut Brandt
e4a90d00b4 Remove the last two instances of Lst_Find() calls. 2005-03-22 12:38:55 +00:00
Hartmut Brandt
144b68a7ef Use VarParse() inside var.c instead of Var_Parse().
Patch:		7.163

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:20:08 +00:00
Hartmut Brandt
6fd71d7a66 Unify callers to Var_Parse() with regard to variable names.
Patch:		7.162

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:18:15 +00:00
Hartmut Brandt
a4c193bbe2 Make some callers of VarFind using the same code structure.
Patch:		7.161

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:16:09 +00:00
Hartmut Brandt
29b59e2865 De-lispify some if()-expressions by removing extra parantheses.
Patch:		7.160
Requested by:	harti

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:12:16 +00:00
Hartmut Brandt
b6c44471ba Return a Buf object from VarGetPattern() instead of a char * and a size_t.
Store a Buf object in struct VarPattern instead of a char * and a length.

Patch:		7.158

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:09:43 +00:00
Hartmut Brandt
ce873d22d5 Use the struct VarPattern's lhs field instead of using an extra variable
to store the left expression of a C modificator.

Patch:		7.157

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:06:34 +00:00
Hartmut Brandt
6edf648505 Merge struct VarREPattern into struct VarPattern. This will help sorting
out common code.

Patch:		7.156

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:03:42 +00:00
Hartmut Brandt
b31a79d77e Sort prototypes.
Patch:		7.155

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:01:04 +00:00
Hartmut Brandt
d344c54aba Fix indentation.
Patch:		7.154 (partly)

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:00:02 +00:00
Hartmut Brandt
5af70720f4 Delete an extra empty line.
Patch:		7.153

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 07:57:18 +00:00
Hartmut Brandt
1ff3feb03d An automatic variable in a local scope is (conceptionally) destroyed with
the closing brace so it is unwise to keep a pointer to it. Make
the variable static to fix this.

Patch:		7.152

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 07:56:22 +00:00
Hartmut Brandt
4896df6314 Simplify buffer access by using Buf_Data() and Buf_Peel() where
appropriate.

Patch:		7.147-7.151

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 07:50:40 +00:00
Hartmut Brandt
9668c011e9 Two new functions: Buf_Data() returns a reference to the data in
the buffer and Buf_AppendBuf() appends a copy of one buffer to another
buffer.

Patch:		7.146,7.147

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 07:42:51 +00:00
Hartmut Brandt
cffe7fcdef Remove a temporary variable. Rename pattern to patt to be consistent.
Remove unreachable code for VAR_NOSUBST - it was never set.
Replace redundant code with calls to VarGetPattern().

Patch:		7.143-7.145

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 07:38:46 +00:00
Hartmut Brandt
1610cab61d Remove unneeded temporary variables in modifier_S() and modifier_C().
Change the parsing of the C modifier flags so that specifying both
'1' and 'g' gives an error.

Patch:		7.141,7.142

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 12:40:27 +00:00
Hartmut Brandt
090051a931 Remove comment about Var_Parse assuming that the first character
is always a '$'. This is not always correct, for example for
conditionals: .if defined(foobar).

Clean up some comments.

Move common code out of if-statements.

Patch:		7.140

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 12:32:41 +00:00
Hartmut Brandt
f244a9fb0a Split out SysV variable substitution into its own function.
Patch:		7.139

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 12:27:53 +00:00
Hartmut Brandt
a33399ac68 Rename freePtr to freeResult to make it more obvious about what
pointer we're talking.

Patch:		7.138

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 12:19:23 +00:00
Hartmut Brandt
6cb006aff1 Move some code from ParseModifier() into the calling function to
simplify things. Correct a number comments.

Patch:		7.137

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 12:17:44 +00:00
Hartmut Brandt
61cc000336 Cleanup the VAR_JUNK handling.
Patch:		7.136

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 12:15:06 +00:00
Hartmut Brandt
8f712e5034 Don't pass 'consumed' through all the parsing routines where it can be computed
by the caller. Don't pass 'endc' - it can be computed from 'startc'.
Remove unneccessary temporary variables. Remove constant if-expressions
and remove code before call Fatal() - there is no point to cleanup before
aborting.

Patch:		7.134,7.135

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 12:07:14 +00:00
Hartmut Brandt
b072d12283 Change one occurence of 'delim' to the correct type. Delete another
occurence which actually holds always the same constant value.
Shorten the name pattern to patt.

Patch:		7.133

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 11:54:46 +00:00
Hartmut Brandt
13591063f0 Replace calls to Lst_Find with either appropriate LST_FOREACH macros
plus predicate inlining or a special purpose function with takes
and returns the correct types.
2005-03-21 11:44:57 +00:00
Hartmut Brandt
0906b0904f Reduce number of parameters passed between the parsing routines
by putting them into struct VarParser or computing them (consumed).
Change the loop termination condition in VarParseLong from endc to \0.

Patch:		7.128-7.132

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 11:43:02 +00:00
Hartmut Brandt
73c5a04dfa Reduce the number of explicit parameters passed to VarParse()
by passing them through struct VarParser.

Patch:		7.127

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 07:40:33 +00:00
Hartmut Brandt
cedc4e46c2 Cleanup handling of colons in variable substitutions.
Patch:		7.126

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-18 16:52:46 +00:00
Hartmut Brandt
af0b17b173 Unfold parsing of single letter modifiers from multi-letter ones.
Patch:		7.125

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-18 15:51:04 +00:00
Hartmut Brandt
2ae8b5b5f6 Style: fix indentation and <space><tab>.
Patch:		7.124

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-18 15:44:23 +00:00
Hartmut Brandt
e524dd1162 Split out the 'S' modifier into its own function.
Patch:		7.122,7.123

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-18 15:37:31 +00:00
Hartmut Brandt
1753011e3f Convert Var_Parse to a wrapper function.
Reduce the number of arguments passed between these functions by
creating a special-purpose struct.

Patch:		7.120,7.121

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-18 15:34:07 +00:00
Hartmut Brandt
6ea1a0dc21 Replace Lst_Find calls with LST_FOREACH loops. This helps in
constification und simplifies the code because the one-liner
predicates can be inlined into the code.
2005-03-18 15:25:23 +00:00
Hartmut Brandt
2559e71404 Replace a bogus use of Lst_Find with explicite LST_FOREACH calls
and remove the unneeded second argument to ReadMakefile.
2005-03-18 15:23:49 +00:00
Hartmut Brandt
7ea59d002e Fix a bug in matching suffixes. Under certain circumstances the code
would access memory before the beginning of the string to match (the
suffix match starts at the end of both the string and the suffix and
proceedes to the begin until either the start of the suffix is hit
or the character does not match). This could lead to a memcpy copying
into random memory. Fix this by checking the length of the string to
match too and replacing the Lst_Find calls with LST_FOREACH loops
(last part by me).

Submitted by:	Matt Dillon <dillon@apollo.backplane.com> (in principle)
2005-03-18 15:16:09 +00:00
Hartmut Brandt
0ce37001aa Now that there are no users of Lst_ForEach and Lst_ForEachFrom are left
delete these two macros and all the associated stuff.
2005-03-16 16:11:11 +00:00
Hartmut Brandt
0bcbcabd26 Replace Lst_ForEach by LST_FOREACH. 2005-03-16 16:02:09 +00:00
Hartmut Brandt
a238417909 Replace another bunch of Lst_ForEachs by LST_FOREACHs and simplify code. 2005-03-16 12:22:15 +00:00
Hartmut Brandt
363fa56a62 Fix a comment. 2005-03-16 08:06:28 +00:00
Hartmut Brandt
0bcd542606 Get rid of another bunch of Lst_ForEach in favour of LST_FOREACH and
simplify code accordingly.
2005-03-16 08:04:45 +00:00
Hartmut Brandt
d2f389f5e4 Ups. Revert the last commits. These have been committed by accident. 2005-03-15 15:10:51 +00:00
Hartmut Brandt
d735bf8813 modifier_M: instead of going through the string twice to compute the
size of the buffer we need, just allocate the possible maximum.

Patch:		7.117

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-15 15:05:14 +00:00
Hartmut Brandt
77f4b22417 Style: Move a variable from a local scope up to the begin of the function.
Rename result variable so common code becomes more visible.
Rename freePtr to freeResult to make clear what pointer must be freed.

Patch:		7.116, 7.116a

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-15 14:52:10 +00:00
Hartmut Brandt
49fe6e22fd Get rid of a number of Lst_ForEach calls in favour of LST_FOREACH
and simplify the printing functions.
2005-03-15 14:28:39 +00:00
Hartmut Brandt
ca98b031fd VarParseLong: move the detection of the modifier separator ':' into
the loop. Add a comment why the 'consumed' variable is updated.
Rename lengthPtr to consumed.

Patch:		7.115

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-15 14:27:29 +00:00
Hartmut Brandt
dd37002304 Yet another version of passing the last line to ParseFinishLine().
It turns out that some ports use the obscure feature of spreading
a dependency block across multiple include files. While this seems
bad style, allow it for now and call said function only at end of
all input to process the really last line of everything.
2005-03-15 14:25:24 +00:00
Hartmut Brandt
f321cf01e1 Get rid of another Lst_ForEach in favour of LST_FOREACH. Get rid
of the now unused struct LstSrc and collapes two functions into one.
2005-03-14 17:04:58 +00:00
Hartmut Brandt
03ecd4b822 ParseModifier(): rename rw_str to value and reindent cleanup section.
ParseRestModifier() and ParseRestEnd(): move advancement of ptr to remove
a confusing calculation.
VarParseLong(): cleanup calculation of consumed.

Patch:		7.114

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-14 17:03:34 +00:00
Hartmut Brandt
e0da09426f Move the creation of a Src structure into its own function. 2005-03-14 12:04:20 +00:00
Hartmut Brandt
b33cc19c5f Split off two function from VarParseLong to handle modifiers and the
actual variable lookup. Consistently rename lengthPtr to consumed.
Update a number of comments to match the code.

Patch:		7.111-113

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-14 12:03:30 +00:00
Hartmut Brandt
8cb809ea3f Convert a couple of other uses of Lst_ForEach to LST_FOREACH and
simplify code.
2005-03-14 08:29:58 +00:00
Hartmut Brandt
c2d34cc331 Simplify the print routines by using LST_FOREACH instead of Lst_ForEach
and inlining the small printing utility functions.
Create a function that can be used to produce printable representations
of flag words.
2005-03-11 13:24:08 +00:00
Hartmut Brandt
7985e10d29 Remove leading underscores from the pathname defines. All identifiers
with leading underscore followed by an uppercase letter are in the
implementation namespace.
2005-03-11 13:02:38 +00:00
Hartmut Brandt
2c9d008998 Remove the leading underscore from structure tags. All identifiers
with a leading underscore are in the implementation namespace.
2005-03-11 12:57:25 +00:00
Hartmut Brandt
941266174e Style: Fix indentation. 2005-03-11 12:40:55 +00:00
Hartmut Brandt
b13ac84d46 Call ParseFinishLine() also for the last line in a file. This
patch differs from the previous one in that it calls the function
only when a real file hits EOF. The bodies of .for loops are also
handled as files, but for these we don't want to end a dependency block
on the 'EOF' as in:

foo:
	do-this
.for ...
	do-something
.endfor
	do-more
2005-03-11 11:29:39 +00:00
Hartmut Brandt
520fec816c Back out the last commit. It turns out that this breaks more than
it fixes. This should fix the buildworld breakage.
2005-03-11 07:53:32 +00:00
Hartmut Brandt
da559dbfd0 Constify Var_Dump and simplify it by inlining VarPrintVar. 2005-03-10 15:38:01 +00:00
Hartmut Brandt
248cf569be Call ParseFinishLine() for the last line of a file too. 2005-03-10 15:30:09 +00:00
Hartmut Brandt
6dfe1d848e Reorganize Suff_EndTransform to be called only for nodes for
which it is needed (transforms).
2005-03-10 14:54:47 +00:00
Hartmut Brandt
8c87f5a0c7 Style: fix function style before working on it (mainly intendation). 2005-03-10 10:16:03 +00:00
Hartmut Brandt
a2e5fa0890 Implement a new macro LST_NEXT which is like Lst_Succ but doesn't check
for its argument to be non-NULL.
2005-03-09 16:53:31 +00:00
Hartmut Brandt
0d037244ba Split SuffExpandChildren into three functions: one that skips
variables and expands archive specifications, one that expands
wild cards and a driver that loops over the children list and
expands each child if necessary replacing it with it's expansions.
2005-03-09 16:51:43 +00:00
Hartmut Brandt
4ca8a80cb5 Var_Subst() cannot return NULL so there is no reason to check
for it.
2005-03-09 07:53:03 +00:00
Hartmut Brandt
0fdac3eed6 Style: fix indentation of SuffExpandChildren before working on it. 2005-03-08 16:30:32 +00:00
Hartmut Brandt
e390545124 Use Buf_Peel to get rid of a local variable. 2005-03-08 14:37:47 +00:00
Hartmut Brandt
d5247abc18 Use the Buf_Peel function to get to the string contained into a
buffer without using an extra local variable.
2005-03-08 14:33:58 +00:00
Hartmut Brandt
1a67f7b6d6 Remove useless local prototypes. 2005-03-08 14:30:18 +00:00
Hartmut Brandt
0c270d9eb0 Style: fix indentation. 2005-03-08 14:29:23 +00:00
Hartmut Brandt
7ca80f1cbc Use the new Buf_Peel function to simplify things.
Remove an unused struct definition.
2005-03-08 13:15:51 +00:00
Hartmut Brandt
3509f4d713 Create a new function Buf_Peel that returns the string from inside
a Buffer and frees the Buffer.
2005-03-08 13:15:18 +00:00
Hartmut Brandt
1753d0e6a4 Add a debugging function that prints a message and appends the
current strerror.
2005-03-08 07:47:14 +00:00
Hartmut Brandt
a0aea18e18 Mark functions that don't return as dead. 2005-03-08 07:45:50 +00:00
Hartmut Brandt
34d49b885f Finish constification of Var_Parse() and Var_Subst().
Patch:		0.18, 0.8, 7.110

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-08 07:43:57 +00:00
Hartmut Brandt
b37a89c4d4 Constify the callers of brk_string in this file.
Patch:		7.108

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-07 16:23:53 +00:00
Hartmut Brandt
f4d3f46b2e Style: fix indendation of VarModify().
Patch:		7.107

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-07 16:14:50 +00:00
Hartmut Brandt
3cc51195c4 Constify the input argument to brk_string.
Patch:		7.106

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-07 16:10:39 +00:00
Hartmut Brandt
c4487a484d Factor out the 'S' modifier into its own function. Move a variable
that is now used for both the 'M'/'N' branch and the 'S' branch of
the switch statement into a common scope.

Patch:		7.102-105
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-07 16:08:39 +00:00
Hartmut Brandt
ec3074aef1 Move the 'M' and 'N' modifiers into their own function.
Patch:		7.101

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-07 12:43:59 +00:00
Hartmut Brandt
573d78add6 Style: remove unneeded parantheses in conditionals. 2005-03-03 11:34:04 +00:00
Hartmut Brandt
b6bda8ea9d Constify the code paths for the 'M' and 'N' modifiers.
Patch:		7.100

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-03 11:26:28 +00:00
Hartmut Brandt
179fc89109 Fix parsing of archives: in System V archive format the member names
is terminated with a slash. Although we are not System V, ar has
been configured to put that slash in. This format allows filenames
with trailing spaces.
2005-03-03 10:46:23 +00:00
Hartmut Brandt
5c78dee378 Fix parsing of archive specifications on the target side of
dependency lines.  It seems that nobody is actually is using
the archive-feature of make.
2005-03-03 10:09:39 +00:00
Hartmut Brandt
49f5e8346a Update the description comment of the function to reflect the
previous change.
2005-03-03 10:07:28 +00:00