In NASM a string constant can be surrounded by
a pair of single quotes, or by a pair of double
quotes. In fact, it is even possible to define
a string constant without the trailing single
or double quote.
Currently %(EL)IF(N)IDN(I) considers two string
tokens to be non-identical, if their ->text is
non-identical.
Instead it should ignore the leading quotes, as
well as the trailing quotes (if present), when
it compares those fields.
A simple example:
%ifidn 'string',"string" ; should be TRUE
%endif
The attached change fixes that problem.
preproc.c change for %(EL)IF(N)IDN(I)
Logged In: YES
user_id=806493
Making right compare of strings is more simple - just to
replace quotes of the the second string with quotes of the first
string.
But, I think, no quotes should be stored in internal
preprocessor string representation. As well, as preprocessor
string should have ability to contain arbitrary symbols (even a
null character) and C-like escape syntax should be provided.
Logged In: YES
user_id=804543
> Making right compare of strings is more simple - just
> to replace quotes of the the second string with quotes
> of the first string.
Nope. If one of the stwo strings is properly terminated
with a single or double quote, but the other one is not,
then they'd mismatch due to the difference in length...
> But, I think, no quotes should be stored in internal
> preprocessor string representation. As well, as
> preprocessor string should have ability to contain
> arbitrary symbols (even a null character) and C-like
> escape syntax should be provided.
I'll think about the \0 case. It worries me somewhat.
Logged In: YES
user_id=806493
Uploaded into CVS:
* Unterminated string auto termination.
* %(el)if(n)idn insensitivity to string quotes difference
(#809300).
Logged In: YES
user_id=804543
Auto termination is only acceptable if it is un-done at
the end of preprocessing, e.g. in detoken().
See the comments I just added to SF #809218.
Logged In: YES
user_id=806493
Unterminated string is a bug. We have no need in this bug
propagation:
%define str "Hello, World!
db str, 10, 13, 0
; db "Hello, World!, 10, 13
Logged In: YES
user_id=804543
No, it is not a bug.
In fact, as of writing this, it is the only way of
being able to quote a piece of text inside a macro.
%macro SingleQuote 2+
%push local
%xdefine %$single '
%xdefine %1 %$single%2%$single
%pop
%endmacro
SingleQuote TEMP,%$TEMP
db TEMP ; embeds the value of the
; PATH environment variable
The fact that your modified preprocessor offers a
bunch of new functionality that allows the user to
handle this sort of thing in a different way does
not change the fact that unterminated strings do
have their uses in the existing preprocessor. Just
because you can't think of a use, it's not a bug.