Commit Graph

138 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
da559dbfd0 Constify Var_Dump and simplify it by inlining VarPrintVar. 2005-03-10 15:38:01 +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
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
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
d0330ee675 Transform VarParseLong() so that the lifetime and the constness of
variables gets clearer. Transform if() conditions to make the flow
clearer.

Patch:		7.93-99

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-03 07:25:04 +00:00
Hartmut Brandt
bf7c33df9c Move the check for the error case (variable ends without a closing
paranthesis or brace) into the loop and don't leak the buffer in this
case. Remove the check for Var_Parse returning NULL - it can't.

Patch:		7.92

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-02 15:52:04 +00:00
Hartmut Brandt
b7beb62744 Fix indentation on a block of code.
Patch:		7.91

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-02 14:43:40 +00:00
Hartmut Brandt
09394f0073 Push the length computation down into VarParseShort().
Return always malloc()-ed strings from VarParseShort() to get
rid of warnings when returning string constants from a non-const char *
function.

Patch:		7.90

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-02 14:30:36 +00:00
Hartmut Brandt
41664cddcd Make sure the length variable is initialized to 0 before passing
it to Var_Parse().

Patch:		7.85

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-01 17:52:18 +00:00
Hartmut Brandt
f1c603af79 Split out ParseModifiers from VarParseLong.
Patch:		7.84
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-01 12:26:32 +00:00
Hartmut Brandt
73058038d5 VarParseLong: Create new else block for haveModifier. Move the call
to VarExpand down into the branches of the if as well as cleanup code.
Eliminate code that is now obviously dead.

Patch:		7.83

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-01 12:22:07 +00:00
Hartmut Brandt
aeadeefcdf Reverse a condition so that the else clause can be changed
to a fallthrough.

Patch:		7.82

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-01 07:58:18 +00:00
Hartmut Brandt
4866acd4de VarParseLong: Move the initialisation of dynamic up which saves
an else clause. Move the assignment to the lengthPtr down to
just before the return statements.

Patch:		7.81

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-28 17:23:17 +00:00
Hartmut Brandt
9944ed62ba Don't modify the input string in VarParseLong(). It is not
necessary to NUL-terminated it, because we know the lengths
from the pointers.

Patch:		7.80

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-28 15:01:37 +00:00
Hartmut Brandt
4ce3340f48 Major clean up and split the Var_Parse monster function into three
functions: one for the single letter variables, one for the others
and one that does the recursive expansion.

Patches:	7.68-7.79

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-26 08:54:40 +00:00
Hartmut Brandt
179078e76d Change the return value of Var_Subst to return a Buffer instead
of a char *.

Patch:		7.49

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-25 13:16:56 +00:00
Hartmut Brandt
d057118357 Var_Parse: Separate different error states by introducing an else block
after a return. Move assignments to {freePtr, dynamic, start} closer to the
return statements to clarify which variables are actually used for
communication between the losely coupled blocks of the code. Clear up
an if-expression to make common structures of the conditions clearer.
Use strchr instead of switch statements to check for a character beeing
a member of a set.

Patches:	7-62.2, 7-62.3, 7-64, 7-65.1, 7-65.2
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-24 16:05:45 +00:00
Hartmut Brandt
a65e9283c5 Push assignments to just before the returns from the function to
get it clearer what variables are actually needed.

Patches:	7.62.2, 7.62.3
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-24 10:35:39 +00:00
Hartmut Brandt
0cb1c98b7a Fix wording of a comment.
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-24 10:30:23 +00:00
Hartmut Brandt
6abaece6ae Forgot to set *freePtr to FALSE in another place.
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-21 08:10:21 +00:00