summaryrefslogtreecommitdiff
path: root/rpmio/macro.c
AgeCommit message (Collapse)AuthorFilesLines
2012-12-18display the actual unknown option instead of '?'Thierry Vignaud1-1/+1
'?' is returned by getopt when option is unknown, making hard to pinpoint the actual bogus option... Signed-off-by: Panu Matilainen <pmatilai@redhat.com> (cherry picked from commit 8192e580a0a962b8eb7f9d8fc07bd3f99ccf0ffe)
2012-11-01Enable built-in %dirname macroPanu Matilainen1-3/+1
- This might've clashed with %dir in spec %files at some point as indicated by the comments, but that should no longer be the case.
2012-05-22Add support for 7zip compressed tarballsChristophe Fergeau1-0/+3
Teach %prep and %uncompress how to handle 7zip tarballs, with the mingw toolchain landing in fedora, this may be useful when crossbuilding Windows sources compressed using 7zip (CxImage is one such project).
2012-05-10Keep the macro buffer terminated on appendPanu Matilainen1-1/+2
- This isn't strictly needed as we're terminating the buffers "just in case" all over the place but handling this centrally might allow some day eliminating the other fluff...
2012-05-10Fix off-by-ones in mbAppend() and mbAppendStr()Panu Matilainen1-2/+2
- Oops, remember to reserve space for the trailing \0 when appending. mb->nb holds the number of actual characters left in the buffer, not the terminator. Fixes a regression introduced in rpm 4.9.x dynamic macro realloction work (RhBug:431009 reprise)
2011-05-31Clean up + clarify popMacro() a bitPanu Matilainen1-10/+15
- Actually protect against NULL mep (shouldn't happen but...) - Remove bogus comment + add actually relevant comments - Make the *mep reassignment more obvious by taking it out of the if where its easily missed - Replace dead NULL-assignments with a trash-n-burn memset() - Fixup indentation to match general rpm style
2011-05-31Use popMacro() when freeing the entire macro tablePanu Matilainen1-11/+4
- We already have a function to free macro entries, use it to remove code duplication
2011-05-28Eliminate bunch of obvious dead NULL-assignments around librpmioPanu Matilainen1-1/+1
2011-05-24Add support for nested Lua macro expansion (RhBug:490740)Panu Matilainen1-4/+4
- Lift the printbuffer accounting out of rpmlua into a struct of its own (Funny thing, this looks a whole lot like the macro expansion buffer and Good Ole StringBuf Brothers ... Boys ... Mam. Unify them one of these days maybe) - Replace the simplistic on/off printbuffer with a stack of buffers, fixup the lone caller to use the new internal push/pop API.
2011-05-18Eliminate bogus ferror() checksPanu Matilainen1-3/+1
- fopen() returns NULL on errors, never an opened stream with error flag set. These are leftovers from past where rpmio fd was used instead of FILE and probably the checks were bogus even back then too.
2011-05-18Always copy macro source when expanding itMichael Schroeder1-6/+6
- A macro can undefine itself, and unless we grab a copy of it we'll end up accessing already freed memory. Fixes a regression from commit ebc4ceaaeb8bb59019f4635471b28eb5f3eaaaa6 which assumed a copy is not always needed. Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2011-04-29Add lrzip support.Ville Skyttä1-0/+3
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2011-04-29Add lzip support.Ville Skyttä1-0/+3
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2011-03-17Plug memory leaks on macro definition error casesPanu Matilainen1-3/+3
2010-09-27Handle non-terminated substrings centrally in expandMacro()Panu Matilainen1-41/+22
- expandMacro() is big and ugly already, but handling the non-terminated substrings there once and for all avoids having to ping-pong recurse through couple of helpers to get there.
2010-09-27Dynamic expansion buffer reallocation for lua macros tooPanu Matilainen1-6/+12
2010-09-27Whoops, fix typo/thinko from commit dc258bac41e32e754b15a413d844160f34b6a12ePanu Matilainen1-1/+1
2010-09-27Eliminate the internal in-place-expansion buffer limitationPanu Matilainen1-30/+32
- Return the dynamically allocated expansion buffer to callers from expandU(), except using a slightly less cryptic expandThis() name for it now. Also deal with non-terminated strings centrally in expandThis() instead of doing alloc + copy to terminate in every caller.
2010-09-27Simplify / sanitize expandU() a bitPanu Matilainen1-12/+7
- Instead of saving and restoring the bits we'll mess with, just make a temporary expansion state struct with non-buffer state copied from "parent".
2010-09-27Dynamically reallocate macro expansion buffer (ticket #45)Panu Matilainen1-14/+15
- Eliminate the underlying limitation of macro expansion limit by growing the buffer as needed when adding characters to it. This doesn't fix the entire issue yet however: expandU() and expandMacros() are still limited to caller-specified buffer size, and output from lua-macros isn't dynamically resized. One step at a time...
2010-09-27Let expandMacro() allocate its own bufferPanu Matilainen1-16/+17
- More pre-requisites for dynamic buffer resizing, callers have no clue how much expandMacro() is going to need.
2010-09-27Track current expansion point via distance to buffer startPanu Matilainen1-21/+23
- Supposedly no functional changes, just paving way for dynamic buffer resizing which is impossible when accessing pointers directly.
2010-09-27Push the macro buffer size limit down by one levelPanu Matilainen1-24/+24
- Turn expandMacros() into a wrapper around internal doExpandMacros() which returns the expanded string in a newly allocated buffer, use the internal version for rpmExpand() too.
2010-09-27Eliminate unused spec field from macro expansion state structPanu Matilainen1-3/+0
2010-09-27Avoid calloc() in macro findEntry()Panu Matilainen1-5/+4
- It's just the macro name we're grabbing here, that ought to fit on stack comfortably enough.
2010-09-27Avoid unnecessary round-trip through expandT() where possiblePanu Matilainen1-3/+3
- In the cases where expandT() was called with strlen(source) we can now just bypass it and call expandMacro() directly, avoiding an unnecessary string copy.
2010-09-27Use function arguments to pass, duh, arguments into functions. Duh.Panu Matilainen1-20/+9
- No functional changes, just eliminating mindless save-and-restore ping-pong through macro expansion state struct.
2010-07-13Redirect macro stack backtrace printing to debug log.Jindrich Novy1-4/+4
2010-07-13Fix cryptic macro evaluation error message (RhBug:613010)Jindrich Novy1-2/+1
2010-01-07Revert "Always free locally defined macros when they go out of scope"Panu Matilainen1-2/+3
- the "fix" breaks seemingly legitimate use in fedora font package macros, possibly some funky interaction with %{lua: } macros or something - this reverts commit f895acd285366cf58cc3c97b5f188fecbfd782a8.
2010-01-04Always free locally defined macros when they go out of scopePanu Matilainen1-3/+2
- Prior to this, local defines in constructs like %{!?foo: %define foo bar} would remain defined until a parametrized macro gets called, causing obscure and confusing errors in specs such as RhBug:551971 and countless others. Use of %global is now always required for such constructs.
2010-01-04Remove -98 vintage ifdef'ed dead codePanu Matilainen1-13/+0
2009-12-23Move getopt() portability fiddles out of system.hPanu Matilainen1-0/+6
- only macro.c needs, no point polluting includes everywhere
2009-10-06Decompress lzma files with xz.Ville Skyttä1-2/+0
2009-09-07Eliminate unused variablePanu Matilainen1-2/+2
2009-08-31Replace equal/not equal uses of str[n]cmp() with rstreq[n] in io codePanu Matilainen1-1/+1
2009-03-27Handle XZ in %uncompress macroPanu Matilainen1-0/+3
- should've been in commit 8078d0ba24662308b10d9eb0f0da978584b7e757
2009-03-27Add built-in %getconfdir macro for getting rpmConfigDir() valuePanu Matilainen1-0/+4
- define %_rpmconfigdir via %getconfdir in the main macro config, this avoids it getting lost on macro reloads as happens when building several packages at once
2009-01-16Add getenv macro, use instead of $(echo $HOME) for defaulsPanu Matilainen1-0/+3
- inspired by http://lists.rpm.org/pipermail/rpm-maint/2009-January/002332.html
2008-11-22Add function to retrieve rpm config base directoryPanu Matilainen1-1/+0
- one-shot to determine configuration base directory path from RPM_CONFIGDIR environement or build-time default - rpmfileutil is a bit strange place, this would really belong to librpm but Lua initialization needs the path so...
2008-10-19Permit tab as whitespace between macro arguments (rhbz#467567)Panu Matilainen1-1/+1
- another dumb regression from macro handling cleanups
2008-09-11Macro argument handling regression regression (rhbz#461180)Panu Matilainen1-6/+3
- commit f366011c42e4cf13d3acdd1af45127f0a1baec3a is too simplistic and broke other stuff in turn...
2008-07-16Make rpmExpand() smarter wrt memory allocationsPanu Matilainen1-1/+12
- precalculate unexpanded size and allocate enough for that plus MACROBUFSIZ for expansion - typical allocation is way smaller than what gets allocated "just in case", calculate expanded size and realloc to actual size to avoid wasting memory
2008-07-16Eliminate another unnecessary temp variablePanu Matilainen1-4/+2
- do all the copying inside a loop
2008-07-16Eliminate unnecessary variablePanu Matilainen1-3/+2
- leftover from static buffer times..
2008-07-16Macro argument handling regression (rhbz#455333)Panu Matilainen1-2/+4
- expandMacro() wants the next \0 character to be returned, which might or might not be the same as lastc passed to grabArgs() - use memcpy() instead of memmove() for the copy, the areas can't overlap
2008-06-10Use correct type for strlen()Panu Matilainen1-1/+1
2008-04-29Plug memleak in macro doFoo()Panu Matilainen1-0/+1
2008-04-19Further simplify rpmInitMacros()Panu Matilainen1-27/+14
- Use argvSplit() for splitting the macro path to components instead of manual pointer-parsery. - If URL's are to be supported or accepted at all (previous code attempted to skip them), ':' is a very poor delimiter character.
2008-04-19Use argvFree() to free, well, an argv, instead of manual freeingPanu Matilainen1-6/+3