summaryrefslogtreecommitdiff
path: root/asm/quote.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-02-26 14:00:54 -0800
committerH. Peter Anvin <hpa@zytor.com>2019-02-26 14:00:54 -0800
commit8b262474424c0f6912b22bbf7452f26bfa4d1235 (patch)
treea40a21f2e346f65f71a24189fc8434dbd330a35b /asm/quote.c
parenta8604c83fa8ece9859fb76b328b8753f549b8863 (diff)
downloadnasm-8b262474424c0f6912b22bbf7452f26bfa4d1235.tar.gz
preproc: add %i... variants, evaluated macro parameters, cleanupsevalmacro
All directives which create single-line macros now have %i... variants to define case-insensitive versions. Case insensitive rather sucks, but at least this way it is consistent. Single-line macro parameters can now be evaluated as a number, as done by %assign. To do so, declare a parameter starting with =, for example: %define foo(x,=y) mov [x],macro_array_y ... would evaluate y as a number but leave x as a string. NOTE: it would arguably be better to have this as a per-instance basis, but it is easily handled by having a secondary macro called with the same argument twice. Finally, add a more consistent method for defining "magic" macros, which need to be evaluated at runtime. For now, it is only used by the special macros __FILE__, __LINE__, __BITS__, __PTR__, and __PASS__. __PTR__ is a new macro which evaluates to word, dword or qword matching the value of __BITS__. The magic macro framework, however, provides a natural hook for a future plug-in infrastructure to hook into a scripting language. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'asm/quote.c')
-rw-r--r--asm/quote.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/asm/quote.c b/asm/quote.c
index 75a93726..813141b3 100644
--- a/asm/quote.c
+++ b/asm/quote.c
@@ -217,6 +217,14 @@ static char *emit_utf8(char *q, int32_t v)
}
/*
+ * Quote a C string
+ */
+char *nasm_quote_cstr(const char *str)
+{
+ return nasm_quote(str, strlen(str));
+}
+
+/*
* Do an *in-place* dequoting of the specified string, returning the
* resulting length (which may be containing embedded nulls.)
*