summaryrefslogtreecommitdiff
path: root/preproc.c
AgeCommit message (Collapse)AuthorFilesLines
2013-11-27preproc: Handle curly braces in multi-line macro parametersJin Kyu Song1-13/+29
Multi-line macro uses curly braces for enclosing a parameter containing comma(s). Passing curly braces as a part of a parameter which is already enclosed with braces confuses the macro expander. The number of braces in a group parameter is counted and any brace in the outmost enclosing braces is treated as a part of parameter. e.g.) mmacro {1,2,3}, {4,{5,6}} mmacro gets 2 parameters of '1,2,3' and '4,{5,6}' Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-27Revert "AVX-512: Handle curly braces in multi-line macro parameters"Jin Kyu Song1-5/+0
This reverts commit a800aed7b75d56114f2e1e4928cbc48ecf96a4a0. As recommended by the community, braces inside a group parameter of multi-line macro should be parsed without a need of a leading escape character such as "\{ab,c\}". Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-20Build: Suppress warning messagesJin Kyu Song1-1/+1
Giving a correct printf format specifier supresses the warning message. And a local pointer variable is initialized with NULL. Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
2013-11-09BR3392270: preproc: Handle all token chains in mmacro params rangeCyrill Gorcunov1-7/+18
A typical example is | | %macro m0 0-* | %rep %0 | m0 arg is %1 | %rotate 1 | %endrep | %endmacro | | %macro m1 0-* | m0 %{1:-1} | %endmacro | | m1 a=b, c=d If passed with nasm -E the output must be like m0 arg is a=b m0 arg is c=d http://bugzilla.nasm.us/show_bug.cgi?id=3392270 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-08-22AVX-512: Handle curly braces in multi-line macro parametersJin Kyu Song1-0/+5
Multi-line macro uses curly braces for enclosing a parameter containing comma(s). Passing curly braces as a part of a parameter which is already enclosed with braces confuses the macro expander. Escape character '\' is prefixed in this case. e.g.) mmacro {1,2,3}, {4,\{5,6\}} mmacro gets 2 parameters of '1,2,3' and '4,{5,6}' Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-05-06BR3392253: Fix potential buffer overflow in number conversionCyrill Gorcunov1-1/+1
Reported-by: franck.uberto@esrf.fr Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-04-01Fixed wrong/redundant comparison according to documentation in comment above.Philipp Kloke1-1/+1
Bug found by: CppCheck 1.59 (static source analysis tool) Signed-off-by: Philipp Kloke <philipp.kloke@web.de> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-04BR3392240: preproc: Don't fail on pasting of space expanded rvalue tokensCyrill Gorcunov1-4/+25
Reported-by: KO Myung-Hun <komh@chollian.net> Tested-by: KO Myung-Hun <komh@chollian.net> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-12-27br3392236: Don't treat \Space after \BackSlash as a sign for line continuationCyrill Gorcunov1-1/+1
In commit f1fe4fdeabeaf2e5e4d02ef43beeb09a6fbfed1b I occasionally made a \Space after \BackSlash being a sign of line continuation. Fix it. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-10-27BR3392226 preproc: Rework line readin procedureCyrill Gorcunov1-57/+56
It's been reported that we handle MacOS eol wrong. This patch fixes the problem. http://bugzilla.nasm.us/show_bug.cgi?id=3392226 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-08-07BR 3392207: preproc: Rewrite paste_tokens routineCyrill Gorcunov1-97/+136
This should make it easier to read and moreover now we're able to preprocess pasting as %define N 1e%++%+ 5 dd N, 1e+5 Note that N should be expanded as series of pasting to 1e+5 term, but before this patch we were ending up in 1e+%+ 5 which is wrong. In other words the fixed version output is dd 1e+5, 1e+5 while broken one was dd 1e+%+ 5, 1e+5 This patch also fixes nil dereferences in case if there is no left or right token around pasting term. http://bugzilla.nasm.us/show_bug.cgi?id=3392207 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-05-07preproc: Split get rid of global preproc methodsCyrill Gorcunov1-6/+11
This will allow to hook on updated preprocessor without breaking existing one. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-05-06preproc: Drop never used pp_runtimeCyrill Gorcunov1-20/+0
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-05-02preproc: Use bsii helperCyrill Gorcunov1-18/+1
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-03-11preproc: Finally drop context-through searchCyrill Gorcunov1-62/+15
[backport 290eac75699fb768fdea4588772cf08b5db2788c] 2.09 series was the last one we support context-thru search (and we were issuing a warning about that) so drop all-context from get_ctx() routine. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-03-04BR3392200: preproc - Fix dangling paste termCyrill Gorcunov1-2/+7
Backport 99a055add917fe954038885d9013f8968f76790c Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-03-03preproc: Revert to the NASM 2.09 preprocessorH. Peter Anvin1-1257/+962
The NASM 2.09 preprocessor allows some illogical constructs, but which unfortunately has been found in real code in the field. We need a compatibility solution or a pragma before we can avoid that. However, we need the other features in NASM 2.10 to come out, so revert the preprocessor changes for now. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-03-01preproc: Drop never used Cond structureCyrill Gorcunov1-2/+0
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-02-27BR3392200: preproc - Fix dangling paste termCyrill Gorcunov1-2/+10
In case if there a production {tok},{%+},{whitespace}* the preprocessor does not delete ending paste+spaces tokens. Fix it. http://bugzilla.nasm.us/show_bug.cgi?id=3392200 Reported-by: KO Myung-Hun <komh@chollian.net> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-20preproc: Proper bracing with list_for_eachCyrill Gorcunov1-3/+6
It is a potential place for a bug if list_for_each helper is used with multiple lines of code without a proper bracing. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-09preproc: Drop NULL assignments for static variablesCyrill Gorcunov1-8/+8
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-09preproc: A few style fixupsCyrill Gorcunov1-23/+36
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-02preproc: %ifenv should require environment variable name to existCyrill Gorcunov1-3/+4
Otherwise naked %ifenv/%endif passes without a notice. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-02BR3414012: Make %if[n]def to handle tail spacesCyrill Gorcunov1-3/+4
In case if there a trailing spaces after expansion %if[n]def might produce a false alarms on macro id being expected. Note it also makes the constructions like bare %ifdef %endif invalid, while before they were passed well without a notice. Reported-by: KO Myung-Hun Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-08-01preproc: Drop emitting() rudimanetCyrill Gorcunov1-1/+0
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-17preproc: Align members in structuresCyrill Gorcunov1-45/+47
For easier reading Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-17preproc: Reorder ExpInv to drop paddingCyrill Gorcunov1-18/+19
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-17preproc: Reorder SMacro members to eliminate paddingCyrill Gorcunov1-6/+6
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-06preproc: Drop useless assignmentsCyrill Gorcunov1-4/+0
new_ExpDef does zalloc'ate memory so no need to assign zeros again. Same time it should fix MSC complains on NULL assignment on boolean variable. Reported-by: Jasper Neuman <jasper.neumann@web.de> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-02preproc: Move Preproc type to preproc_ops structureCyrill Gorcunov1-1/+1
There is no need to hide this structure into a type. The former preproc_ops is a way more descriptive. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-30preproc: Refactor smacro paramters expansionCyrill Gorcunov1-6/+9
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-30preproc: Add smacro paramter helpersCyrill Gorcunov1-6/+32
I belive this should simply code a bit. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-30preproc: Alignment in loopCyrill Gorcunov1-3/+3
Just for easier reading Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-28preproc: Finally drop context-through searchCyrill Gorcunov1-36/+16
2.09 series was the last one we support context-thru search (and we were issuing a warning about that) so drop all-context from get_ctx() routine. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-28preproc: nasm_free is safe against NULL argumentCyrill Gorcunov1-10/+5
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-27Revert "BR3288901: Relax concat rules in preprocessor code"Cyrill Gorcunov1-23/+27
This reverts commit cb00cd1ba7f07f60f0a94c43cfc4fa7b01e2ff95. As Victor pointed out some tests do not pass with this commit so revert it until things get fixed. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-27preproc: Add trace point into paste_tokensCyrill Gorcunov1-0/+2
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-26preproc: Some more tracing callsCyrill Gorcunov1-0/+17
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-26preproc: Missed double charp in nasm_traceCyrill Gorcunov1-1/+1
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25preproc: Add tokenization tracingCyrill Gorcunov1-4/+47
It's a bit more than that, also TRACE=1 make flag added to run this facility on and off at compiling time. Debug feature only, doesn't affect regular users. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25preproc.c: Get rid of a few tabs and update yearCyrill Gorcunov1-3/+3
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25preproc.c: Use list_reverse helperCyrill Gorcunov1-9/+3
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25preproc: Drop unused 'mtok' variableCyrill Gorcunov1-2/+1
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25BR3288901: Relax concat rules in preprocessor codeCyrill Gorcunov1-27/+23
We simply allow the following terminals to be concat'ed if they are written without space or any other separator inbetween. a := id | preproc-id | number | float | other b := id | preproc-id | number | float | other if match(a,b): s := concat(a,b) re-tokenize(s) Basically it means it's up to code author to write preproc code a way the sane production appears. Some notes. 1) We don't concat strings. 2) The 'weirdpaste' test fails now because with relaxed rules it works as needed and was borken before. The lacmus snippet is %define N 1e%++%+ 5 dd N, 1e+5 Previously the output was dd 1e+%+ 5, 1e+5 which is wrong since we have explicit concat here with %+ operator. The new code production is correct and looks like dd 1e+5, 1e+5 as expected. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-03-12Merge branch 'nasm-2.09.xx'Cyrill Gorcunov1-1/+1
Conflicts: doc/changes.src version Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-03-07preproc.c: Don't forget to dup filename before freeCyrill Gorcunov1-1/+1
src_set_fname simply gets copy of pointer (ideally we need refcounting here) so don't pass the name which will be freed soon but rather pass a copy. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-03-05preproc.c: Fix use-after-free bugCyrill Gorcunov1-1/+1
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-02-28preproc: Use nasm_zalloc helperCyrill Gorcunov1-35/+14
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-12-18preproc.c: fix tokenize() warnings for ignored expansion definitionsKeith Kanios1-3/+8
2010-12-18preproc.c: simplify %un[i]macro warning messageKeith Kanios1-1/+1