aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-09 02:34:21 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-09 02:34:21 -0700
commit1c21a53e4ed03371df5d9f16359545862bb4820e (patch)
tree7c44b46c5a35a8bcffd1d7698aaaddce6af4d148 /include
parent80ba65e830589b2b4e77112445ab03a3ce1de773 (diff)
downloadnasm-1c21a53e4ed03371df5d9f16359545862bb4820e.tar.gz
nasm-1c21a53e4ed03371df5d9f16359545862bb4820e.tar.xz
nasm-1c21a53e4ed03371df5d9f16359545862bb4820e.zip
preproc: fix parsing of single-line macro arguments, cleanups
The single-line macro argument parsing was completely broken as a comma would not be recognized as an argument separator. In the process of fixing this, make a fair bit of code cleanups. Note: reverse tokens for smacro->expansion doesn't actually make any sense anymore, might reconsider that. This checkin also removes the distinction between "magic" and plain smacros; the only difference is which specific expand method is being invoked. Finally, extend the allocating-string functions such that *all* the allocating string functions support querying the length of the string a posteori. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Diffstat (limited to 'include')
-rw-r--r--include/nasmlib.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/include/nasmlib.h b/include/nasmlib.h
index b8666e67..eb3a637d 100644
--- a/include/nasmlib.h
+++ b/include/nasmlib.h
@@ -87,10 +87,22 @@ char * safe_alloc nasm_vasprintf(const char *fmt, va_list ap);
void * safe_alloc printf_func(2, 3) nasm_axprintf(size_t extra, const char *fmt, ...);
void * safe_alloc nasm_vaxprintf(size_t extra, const char *fmt, va_list ap);
-extern size_t _nasm_aprintf_size;
-static inline size_t nasm_aprintf_size(void)
+/*
+ * nasm_last_string_len() returns the length of the last string allocated
+ * by [v]asprintf, nasm_strdup, nasm_strcat, or nasm_strcatn.
+ *
+ * nasm_last_string_size() returns the equivalent size including the
+ * final NUL.
+ */
+static inline size_t nasm_last_string_len(void)
+{
+ extern size_t _nasm_last_string_size;
+ return _nasm_last_string_size - 1;
+}
+static inline size_t nasm_last_string_size(void)
{
- return _nasm_aprintf_size;
+ extern size_t _nasm_last_string_size;
+ return _nasm_last_string_size;
}
/* Assert the argument is a pointer without evaluating it */