Commit Graph

312 Commits

Author SHA1 Message Date
Jin Kyu Song
c9486b965b Build: Suppress warning messages
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-20 11:29:42 -08:00
Cyrill Gorcunov
e75331cc09 BR3392270: preproc: Handle all token chains in mmacro params range
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-11-09 12:08:41 +04:00
Jin Kyu Song
a800aed7b7 AVX-512: Handle curly braces in multi-line macro parameters
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-08-22 19:37:25 +04:00
Cyrill Gorcunov
ce6527459f BR3392253: Fix potential buffer overflow in number conversion
Reported-by: franck.uberto@esrf.fr
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-05-06 23:43:43 +04:00
Philipp Kloke
b432f57741 Fixed wrong/redundant comparison according to documentation in comment above.
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-04-01 02:13:41 +04:00
Cyrill Gorcunov
8b5c9fba4e BR3392240: preproc: Don't fail on pasting of space expanded rvalue tokens
Reported-by: KO Myung-Hun <komh@chollian.net>
Tested-by: KO Myung-Hun <komh@chollian.net>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2013-02-04 10:18:21 +04:00
Cyrill Gorcunov
490f85e73d br3392236: Don't treat \Space after \BackSlash as a sign for line continuation
In commit f1fe4fdeab I occasionally
made a \Space after \BackSlash being a sign of line continuation.

Fix it.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-12-27 20:04:28 +04:00
Cyrill Gorcunov
f1fe4fdeab BR3392226 preproc: Rework line readin procedure
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-10-27 20:56:59 +04:00
Cyrill Gorcunov
1cf9b31d55 BR 3392207: preproc: Rewrite paste_tokens routine
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-08-07 11:27:17 +04:00
Cyrill Gorcunov
0b78bff510 preproc: Split get rid of global preproc methods
This will allow to hook on updated preprocessor
without breaking existing one.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-05-07 01:57:55 +04:00
Cyrill Gorcunov
6094166044 preproc: Drop never used pp_runtime
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-05-06 20:49:24 +04:00
Cyrill Gorcunov
194563915d preproc: Use bsii helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2012-05-02 00:19:38 +04:00
Cyrill Gorcunov
1a42fb28a1 preproc: Finally drop context-through search
[backport 290eac7569]

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-11 11:40:26 +04:00
Cyrill Gorcunov
65ff09a9d8 BR3392200: preproc - Fix dangling paste term
Backport 99a055add9

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 cb00cd1ba7.

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