299 Commits

Author SHA1 Message Date
Cyrill Gorcunov
65ff09a9d8 BR3392200: preproc - Fix dangling paste term
Backport 99a055add917fe954038885d9013f8968f76790c

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-03-04 13:05:55 +04:00
H. Peter Anvin
36206cd378 preproc: Revert to the NASM 2.09 preprocessor
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-03 16:23:19 -08:00
Cyrill Gorcunov
500ddabcd3 preproc: Drop never used Cond structure
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-03-01 02:17:51 +04:00
Cyrill Gorcunov
99a055add9 BR3392200: preproc - Fix dangling paste term
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>
2012-02-27 11:12:06 +04:00
Cyrill Gorcunov
8a88750cd8 preproc: Proper bracing with list_for_each
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-11-20 10:42:13 +04:00
Cyrill Gorcunov
5c607760fe preproc: Drop NULL assignments for static variables
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-09 19:04:14 +04:00
Cyrill Gorcunov
9900c6b081 preproc: A few style fixups
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-09 18:58:46 +04:00
Cyrill Gorcunov
6acada6f39 preproc: %ifenv should require environment variable name to exist
Otherwise naked %ifenv/%endif passes without a notice.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-10-02 09:18:34 +04:00
Cyrill Gorcunov
4c6f82f78f BR3414012: Make %if[n]def to handle tail spaces
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-10-02 01:08:02 +04:00
Cyrill Gorcunov
6b4a64167c preproc: Drop emitting() rudimanet
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-08-01 00:20:13 +04:00
Cyrill Gorcunov
f30cf73533 preproc: Align members in structures
For easier reading

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-17 20:20:14 +04:00
Cyrill Gorcunov
d57a031616 preproc: Reorder ExpInv to drop padding
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-17 20:11:08 +04:00
Cyrill Gorcunov
10083ae953 preproc: Reorder SMacro members to eliminate padding
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-07-17 20:06:20 +04:00
Cyrill Gorcunov
4e40962918 preproc: Drop useless assignments
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-06 23:12:55 +04:00
Cyrill Gorcunov
86b2ad05f8 preproc: Move Preproc type to preproc_ops structure
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-07-02 00:15:24 +04:00
Cyrill Gorcunov
0ad6a7b293 preproc: Refactor smacro paramters expansion
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-30 01:36:45 +04:00
Cyrill Gorcunov
194ba892ca preproc: Add smacro paramter helpers
I belive this should simply code a bit.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-30 01:16:35 +04:00
Cyrill Gorcunov
5b6c96b9fd preproc: Alignment in loop
Just for easier reading

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-30 00:22:53 +04:00
Cyrill Gorcunov
290eac7569 preproc: Finally drop context-through search
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-28 02:01:47 +04:00
Cyrill Gorcunov
b6c6ca96e7 preproc: nasm_free is safe against NULL argument
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-28 01:33:02 +04:00
Cyrill Gorcunov
c6a742cb6b Revert "BR3288901: Relax concat rules in preprocessor code"
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-27 01:23:09 +04:00
Cyrill Gorcunov
fdd0ac5f43 preproc: Add trace point into paste_tokens
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-27 01:22:27 +04:00
Cyrill Gorcunov
2e04600e3d preproc: Some more tracing calls
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-26 23:33:56 +04:00
Cyrill Gorcunov
9d1141aea9 preproc: Missed double charp in nasm_trace
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-26 23:07:35 +04:00
Cyrill Gorcunov
fc0c1281db preproc: Add tokenization tracing
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-25 19:51:44 +04:00
Cyrill Gorcunov
82667ff5d3 preproc.c: Get rid of a few tabs and update year
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25 19:34:19 +04:00
Cyrill Gorcunov
3eba69a63a preproc.c: Use list_reverse helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25 18:16:54 +04:00
Cyrill Gorcunov
fb27fc21e7 preproc: Drop unused 'mtok' variable
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-06-25 12:08:30 +04:00
Cyrill Gorcunov
cb00cd1ba7 BR3288901: Relax concat rules in preprocessor code
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-06-25 12:03:36 +04:00
Cyrill Gorcunov
a09fe1ebfb Merge branch 'nasm-2.09.xx'
Conflicts:
	doc/changes.src
	version

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-03-12 22:35:42 +03:00
Cyrill Gorcunov
d34a1085b5 preproc.c: Don't forget to dup filename before free
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-07 11:23:08 +03:00
Cyrill Gorcunov
8dcfd883c7 preproc.c: Fix use-after-free bug
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-03-05 23:54:49 +03:00
Cyrill Gorcunov
6b27129f80 preproc: Use nasm_zalloc helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-02-28 08:45:52 +03:00
Keith Kanios
6faad4efe0 preproc.c: fix tokenize() warnings for ignored expansion definitions 2010-12-18 14:08:02 -06:00
Keith Kanios
21d885b164 preproc.c: simplify %un[i]macro warning message 2010-12-18 12:22:21 -06:00
Keith Kanios
c98a5b4c89 preproc.c: warn/ignore when attempting to %un[i]macro an active macro 2010-12-18 12:17:31 -06:00
Keith Kanios
6a7c3e9f30 preproc.c: replace tabs with spaces on recent commits 2010-12-18 11:49:53 -06:00
Keith Kanios
9412465dc1 preproc.c: free expansion definitions as needed 2010-12-18 11:47:28 -06:00
Keith Kanios
104803de9f preproc.c: free tokens when ignoring expansion definition lines 2010-12-18 11:05:46 -06:00
Keith Kanios
ba935f2bc5 preproc.c: placate tokenize() warnings during expansion definition 2010-12-18 10:54:39 -06:00
Keith Kanios
3136d48212 preproc.c: fix handling of %? and %?? 2010-11-13 09:34:34 -06:00
Cyrill Gorcunov
eb7bf9811f Revert 29cb0bb1b39f4e3c9e013993457e85fce14f5142
Redundant call on nonsmart compilers doesn't
worth it in compare with two assignment operations.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 23:08:14 +03:00
Cyrill Gorcunov
49e8f698fc preproc: Add dump_token helper
While being debugging some nifty problem I found
that it might be useful to produce a full dump of
tokens, in particular text of tokens.

For this reason dump_token is here just to not loose
it. It doesn't affect normal build procedure since it
requires a special -DNASM_TRACE to be passed to the
compiler. Which of course we don't in a regular
compilations.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:35 +03:00
Cyrill Gorcunov
574fbf1972 preproc: Use nasm_zalloc more
To eliminate possible access into heap data

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:30 +03:00
Cyrill Gorcunov
a22e7a983c preproc: Use memset for stack allocated structure
To be on safe side

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:24 +03:00
Cyrill Gorcunov
6f38fe6cd5 preproc: inc_fopen -- set sl->next early
It's safer to init it early and be sure we not
miss anything after.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:18 +03:00
Cyrill Gorcunov
c515774a92 preproc: Use nasm_zalloc for new_ExpDef, new_ExpInv
Srink the code and make it a bit faster.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:13 +03:00
Cyrill Gorcunov
29cb0bb1b3 preproc: Use nasm_zalloc in new_Line
It's shorter

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:44:07 +03:00
Cyrill Gorcunov
a5aea577dd preproc.c: Get rid of tab/space mess
No change on binary level

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-11 22:43:56 +03:00
Cyrill Gorcunov
55cc4d0423 preproc: do_directive: Allocate 'Include' from zeroified-memory
If not all members of structure being allocated from
heap get initialized we better to use nasm_zalloc instead
of nasm_malloc.

For example inc gets allocated in do_directive being parially
initialized and we erroniously get mmac_depth set to some
crappy value leading to SIGSEV in result.

[ http://forum.nasm.us/index.php?topic=921.msg3257#msg3257 ]

nb: I've cleaned verror from tab/space mess while were at it

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-11-10 23:17:34 +03:00