summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/parse.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* kill += 1, -= 1 -> ++, --espie2007-09-171-2/+2
|
* rename dirSearchPath -> defaultPath, and openDirectories -> knownDirectoriesespie2007-09-161-5/+5
|
* kill .SHELL, make doesn't even support it in non-parallel mode.espie2007-09-161-9/+1
|
* cut up dir.c into dir.c/direxpand.c as there is very little interface betweenespie2007-09-161-1/+2
| | | | two modules that do different things.
* fix curly in targets... broke it and no-one saw the difference, so it'sespie2007-08-051-2/+2
| | | | probably not used that often.
* introduce a Var_Substi to substitute on intervals.espie2007-07-301-314/+274
| | | | | | | | | | | | | | | | | | | | | | Since we don't really know how to change Var_Subst and dependent functions, we cheat, and copy the string to a buffer instead. Clean-up the parser a bit: reorganize the include files lookup function: introduce a resolve_include_filename function that figures out the full name of the file, introduce a handle_include_file that does all the include file handling, and rename the functions into handle_xxx_include, so that we can remove most comments. Rename ParseIsCond into handle_bsd_command, cut most of its code into constituent functions. Semantic changes: - follow the rules that, if an optional construct does not parse correctly, then it's not a real extension, and give the normal parser a chance to figure it out. If the syntax checks out, semantic errors ARE real errors. - allow variables to not be defined in include file names, no reason not to. okay miod@
* everywhere except in Var_Parse, we always add/append variables to theespie2007-07-301-2/+2
| | | | | | | | VAR_GLOBAL context, so make it the common case: rename the basic functions to Var_Set_with_ctxt/Var_Append_with_ctxt, define Var_Set and Var_Append as macros that specify VAR_GLOBAL, and use these. okay miod@
* separate and name functions to add target nodes to the graph.espie2007-07-301-38/+47
| | | | okay miod@
* simplify computations in the var module: instead of advancing a char *espie2007-07-241-1/+1
| | | | | | | | | | and keeping track of a length, we just advance the char *, and ditch the length. We can still get the length at the end of the top-level functions to satisfy existing interfaces. Much simpler code, less error-prone. Okay millert@
* move the code that grabs a value in Var_Parse in its own function,espie2007-07-241-1/+1
| | | | | | | | | get_expanded_value. Extend the code a bit to be much more thorough in case of a recursive expansion: shows exactly the cycle of variable names involved. okay millert@
* change Var_ParseSkip API to increment the position instead of returning aespie2007-07-241-2/+2
| | | | | | | | length, simplifies code. (warns a bit, symptom of some further issues to fix). okay millert@
* big clean-up patch:espie2007-07-201-3/+2
| | | | | | | | | | | | - rename a few functions in var.c to names that make more sense. - introduce Var_Deletei because it makes more sense. - rewrite .for loops to use a local LoopVar construct to avoid looking up more stuff. - reformat var.c to near K&R - rewrite most comments in var.c shown to a few people. millert@ gave me his okay since it passes through ports correctly.
* A set of big related changes. okay millert@, tested further by kettenis@espie2007-07-081-2/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | and matthieu@ This all revolves around putting ALL global variables into one single big hash, and using flags. This removes some impossible to understand stuff, like old varfind, and allows for some nice stuff. - each time we reference a global variable, we create it, possibly as a dummy variable. - each time we go to the environment, we remember it, thus we no longer go back to it. Lists of dependant changes: - isolate changes to oldVars and checkEnvFirst. - remove VAR_CMD and VAR_GLOBAL contexts. The only distinction is in parsevar. Split Parse_DoVar into Parse_DoVar and Parse_CmdlineVar - rework var modules around obtain_global_var, observe flags in various functions like Var_Value and Var_Seti. - Var_Seti/Var_Appendi are almost the same code, use that internally. - add magic to handle the very special SHELL variable. - introduce Var_Definedi for the cases where we don't want the actual value, to simplify tests. - add keyword .poison, parse it and set global flags accordingly. - do poison_checks where needed. - document poison. - in for loops, set variable temporarily, so that Var_SubstVar will also substitute it in varmodifiers expressions.
* remove some bogus *p tests from charles longeautedu2007-03-201-8/+8
| | | | ok deraadt millert
* * add an extra argument to the dir lookup functions to say whether weespie2007-01-181-26/+43
| | | | | | | | | | | | | | | should look in the current directory. * refactor include files treatment to have a separate function to look for an include. * use both pieces to make sure system includes do not get looked up in the current directory unless everything else fails. This is != from the netbsd solution to the same problem, which stuffs `magic' entries into filepaths to say whether dot should be looked at first or last. feature requested by matthieu@. okay matthieu@
* ISO function declarations, trim a few comments, rename a few variables toespie2004-04-071-62/+38
| | | | | | more explicit/more consistent names. okay otto@
* Remove the advertising clause in the UCB license which Berkeleymillert2003-06-031-6/+2
| | | | rescinded 22 July 1999. Proofed by myself and Theo.
* This is the first step in sanitizing the conditional parser.espie2002-06-111-26/+26
| | | | | | | | | | | | | | | | | Change the conditional recognition algorithm: scan for a sequence of alphabetic characters, hash it, and compare it against a small table (using ohash functions). This makes Cond_Eval entry more logical, and allows for some shortcuts in recognizing .include, .for, .undef. This also means that conditionals must have an intervening blank between the keyword and the actual test, e.g., .ifA will no longer work. (but no-one actually uses this, and it's highly obfuscated) Okay miod@.
* Fixed version... don't see how this could work on i386, since it didn'tespie2001-11-111-4/+4
| | | | initialize create in main.c.
* undo changes that crash on (at least) the alphaderaadt2001-11-111-4/+4
|
* Redo LstInit as a macro: smaller and faster code in all cases, zeroing twoespie2001-11-111-4/+4
| | | | | | | pointers is simpler than calling a function. Recognize purely static lst headers, which don't really need any initialization. ok miod@
* Replace the most used static lists in make by persistent growable arrays.espie2001-06-121-70/+66
| | | | | 5% speed increase on a make build. ok miod@
* Take includes out of lst.h, re-add what's needed to separate files.espie2001-05-291-1/+2
| | | | Removes remaining lint stuff from lst.lib.
* Mostly clean-up:espie2001-05-231-414/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - cut up those huge include files into separate interfaces for all modules. Put the interface documentation there, and not with the implementation. - light-weight includes for needed concrete types (lst_t.h, timestamp_t.h). - cut out some more logically separate parts: cmd_exec, varname, parsevar, timestamp. - put all error handling functions together, so that we will be able to clean them up. - more systematic naming: functioni to handle interval, function to handle string. - put the init/end code apart to minimize coupling. - kill weird types like ReturnStatus and Boolean. Use standard bool (with a fallback for non-iso systems) - better interface documentation for lots of subsystems. As a result, make compilation goes somewhat faster (5%, even considering the largish BSD copyrights to read). The corresponding preprocessed source goes down from 1,5M to 1M. A few minor code changes as well: Parse_DoVar is no longer destructive. Parse_IsVar functionality is folded into Parse_DoVar (as it knows what an assignment is), a few more interval handling functions. Avoid calling XXX_End when they do nothing, just #define XXX_End to nothing. Parse_DoVar is slightly more general: it will handle compound assignments as long as they make sense, e.g., VAR +!= cmd will work. As a side effect, VAR++=value now triggers an error (two + in assignment). - this stuff doesn't occur in portable Makefiles. - writing VAR++ = value or VAR+ +=value disambiguates it. - this is a good thing, it uncovered a bug in bsd.port.mk. Tested by naddy@. Okayed millert@. I'll handle the fallback if there is any. This went through a full make build anyways, including isakmpd (without mickey's custom binutils, as he didn't see fit to share it with me).
* thinko in my rewrite. Repair var:sh = somethingespie2001-05-151-7/+7
| | | | Looks like nobody is using this anyways.
* Synch with my current work.espie2001-05-031-638/+681
| | | | | | | | | | | | | | | | | | | | | | | | | Numerous changes: - generate can build several tables - style cleanup - statistics code - use variable names throughout (struct Name) - recursive variables everywhere - faster parser (pass buffer along instead of allocating multiple copies) - correct parser. Handles comments everywhere, and ; correctly - more string intervals - simplified dir.c, less recursion. - extended for loops - sinclude() - finished removing extra junk from Lst_* - handles ${@D} and friends in a simpler way - cleaned up and modular VarModifiers handling. - recognizes some gnu Makefile usages and errors out about them. Additionally, some extra functionality is defined by FEATURES. The set of functionalities is currently hardcoded to OpenBSD defaults, but this may include support for some NetBSD extensions, like ODE modifiers. Backed by miod@ and millert@, who finally got sick of my endless patches...
* Clean-ups:espie2000-11-241-3/+3
| | | | | | | | | * Buf_Destroy can be a macro * X_ instead of _X for struct names, to avoid infringing on the system's namespace. * better wildcard detection heuristics * fix #ifdef CLEANUP code * a few comments
* Replace the old hash used to hold file names within a directory withespie2000-09-141-3/+4
| | | | | | | | | | | | | | open hashing. An interesting optimization is that the open hashing interface is more fine-grained, hence we can compute the correct hash value at the start of Dir_FindFile, and reuse it for each hash structure into which we look (the effect is measurable on large directories along with objdir/VPATH). Remove a few unnecessary Lst_Open/Lst_Close that serve no purpose except obfuscating the code. The interface to dir.h changes slightly, hence tedious includes changes...
* - new DirReadDir internal function, that just reads a directory fromespie2000-09-141-4/+4
| | | | | | | | | | the disk or from a cache. - use it in Dir_AddDir, and directly to set up dot. - change Dir_AddDir to use string intervals, as this simplifies dependend functions. - set up an open-hashing cache for opened directory names. - add_dirpath() function in main, to simplify code. - simplify cleaning-up directories, as Dir_ClearPath is overkill.
* Use the new hash scheme to store the target nodes.espie2000-09-141-4/+4
| | | | | | Scrap the list of all targets: it only slows make down. The only visible difference is that the list of all targets is not shown in order when debugging.
* Clean-up, systematic use of UNUSED, white space...espie2000-09-141-8/+7
|
* Some systematic clean-up.espie2000-09-141-10/+10
| | | | | | | | | | - UNUSED macro that expands to __attribute__((unused)) for gcc - move rcsid around so that they can be tagged UNUSED. - activate -Wunused. - use UNUSED instead of kludgy junk for function arguments. - add extern to all extern prototypes. - update comments in lst.h. - clean up var.c a little bit, constifying arguments, updating comments...
* This patch replaces str_concat with a slightly unobfuscated version.espie2000-06-231-3/+3
| | | | | In particular, Dir_MakeFlags is abusing str_concat, and works much better with buffers.
* This is complementary to the previous patch.espie2000-06-231-318/+2
| | | | | | | | There is no code change in this patch, we just move the remaining `lowparse' functions to the right file, and adjust the interface file accordingly. Reviewed by miod@
* This patch is worth a lot, speed-wise.espie2000-06-231-560/+106
| | | | | | | | | | | | | | | | | | | | | | | This does introduce a proper stack of IFiles to handle included files: instead of having the current file be a special case, it's also an IFile. The corresponding code is slightly unobfuscated, removing the error-prone ParseEOF function, freeing the filename systematically (thus, main.c needs to strdup stdin), and merging both include functions lookup into one. The speed gain comes from changing the IFile structure to merge with fgetln seamlessly. The low-level parse code is mostly moved to a new file, lowparse.c, to make things easier to read (see next patch as well). Accordingly, util.c gains a fgetln. Note the interaction between Parse_File, Dir_FindFile, and ReadMakefile in main.c. This patch closes a subtle memory hole (only the Makefile names, so rather small). Reviewed by miod@.
* This patch separates local contexts from global contexts for good.espie2000-06-231-4/+4
| | | | | | | | | | Apart from a few casts, VAR_GLOBAL and friends are separate data structures, so we use a small array for local variables. We also junk allVars, since TargFreeGN can release local nodes, and var.c has explicit lists for its variables already. Reviewed millert@ and miod@.
* In various places, VAR_CMD is used to actually mean `no real context',espie2000-06-231-9/+9
| | | | | | | | | | | | | | since lookup will start with VAR_CMD in any case. This fixes VarFind and Var_Parse to handle ctxt == NULL correctly, and replace those confusing VAR_CMD with proper NULL pointers. This patch also handles three small details: - .CURDIR is necessarily set in VAR_GLOBAL, - suffix handling for archives copies two hard-coded variables, for which it can use a quick path, - typos in TargFreeGN. Reviewed millert@, miod@.
* Once those special variable are taken care of, other Var functions can takeespie2000-06-231-3/+3
| | | | | | | | | | | | | | | the GNode's context directly. We rename that special Lst to `SymTable *' in prevision of things to come. Along the line, we lose the special GNodes affected to VAR_CMD, VAR_GLOBAL, VAR_ENV, which become simple Lsts... This is not a problem, except when getting to a context's name for debugging (handled very nicely by offsetof). Again, this is a preparatory patch, which does not gain anything except for cleaning up issues... Reviewed by millert@ and miod@, like the previous patch
* Trivial consequences of the previous list changes:espie2000-06-231-3/+3
| | | | | | | | | | | - audit code for Lst_Datum, it's never applied to an empty pointer, so check can be removed -> turn into a macro, - Lst_First, Lst_Last can become macro as well - specialized version of Lst_Succ (Lst_Adv) to use in loops where it cannot fail, - Lst_Open can no longer fail. Trim down corresponding code. Reviewed millert@, miod@
* This removes the few instances of Lst_New left.espie2000-06-171-47/+37
| | | | | | | | | | | | | | | - replaces Lst_Duplicate with Lst_Clone, which does not allocate storage - split Lst_Concat into Lst_Concat/Lst_ConcatDestroy Thus, all the LstValid checks are gone, since we always invoke list functions with valid pointers. Note that dynamic list allocation accounted for roughly 20% of all calls to malloc. The extraneous calls to malloc left are now mostly in parse.c, which makes some wasteful usage of temporary buffers. With those few patches, the code is sturdier, and easier to maintain. Reviewed by millert@
* A few assorted changes, to remove more dynamic lists.espie2000-06-171-14/+8
| | | | | | | | | | | | - in Dir_Expand, path is a misnomer. Use a temp variable instead... Reformat code for readability. - Change Parse_MainName/Targ_FindList so that they fill arguments instead of allocating new lists. - nuke Targ_FindList(TG_NOCREATE), as this is never used. - close a small memory hole (forgot to free sysMkPath if CLEANUP). Reviewed by millert@
* This patch introduces a distinction betweenespie2000-06-171-100/+90
| | | | | | | | | | | | | | Lst_Init (constructor) and Lst_New (allocation + construction) Lst_Destroy (destructor) and Lst_Delete (deallocation + destruction), and uses that to turn most dynamic allocation of lists (Lst pointers) into static structures (LIST). Most of this is mundane, except for allGNs in targ.c, where the code must be checked to verify that Targ_Init is called soon enough. Lst_New is a temporary addition. All lists will soon be static. Reviewed by millert@, like the previous patch.
* Clean-up patch: use `void *' instead of old-fashioned ClientData/Address.espie2000-06-101-29/+29
|
* Thus, Lst_ForEach no longer needs returning a status.espie2000-06-101-46/+25
| | | | | | | | | In fact, it can become a macro based on Lst_ForEachFrom. This also introduces Lst_Every, as a shortcut for the very common case where Lst_ForEach does not need any user data. Finally, make consistent use of a few function typedefs, instead of having explicit void (*)(Lst) arguments all over the place.
* Lst_Find and Lst_ForEach do the same thing, except that the comparisonespie2000-06-101-21/+19
| | | | | | | | | | | sense is reversed (Lst_Find returns when proc says 0, whereas Lst_ForEach goes on while proc says 0). This patch turns a number of Lst_ForEach into Lst_Find. Specifically, all Lst_ForEach that actually may return quickly as proc does not always returns zero. Of course, the corresponding proc need to be tweaked to swap 0 and 1...
* Record location in target node as well.espie2000-04-171-3/+8
| | | | | Indicate what went wrong for commands like @exit 1
* Don't free Makefile filenames when the file is finished reading, butespie2000-04-171-5/+24
| | | | keep them for error reporting.
* Remove idiotic, braindead casts T* -> void*espie2000-03-261-36/+36
| | | | | | | They serve no purpose, except hiding potential bugs. In particular, remove (ClientData) cast from macro, showing potentially troublesome use of Hashes to store time_t.
* Finish changing all Var_Parse arguments to size_t. Thanks to millert@espie2000-01-081-3/+3
| | | | for reminding me.
* Nothing ever checks ReturnStatus on Lst_Insert, Lst_Append, Lst_AtFront,espie1999-12-181-23/+23
| | | | | | Lst_AtEnd, Lst_Concat, Lst_Remove, Lst_Replace. Don't bother returning one.