From 6eaeea0a3bf0069be6b1a7706e8e4dc183588b58 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 16 Oct 2025 01:44:03 +0000 Subject: [PATCH] Fix an off-by-one in c-pp-lite.c which could cause @token@-processed output to get one duplicated byte. FossilOrigin-Name: aa2f4c51604f4d4286c8a1ec7eaa6251892471e32087af695712513ee620ea46 --- ext/wasm/c-pp-lite.c | 17 ++++++++++++++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/ext/wasm/c-pp-lite.c b/ext/wasm/c-pp-lite.c index acb64df654..ee3e71bbc0 100644 --- a/ext/wasm/c-pp-lite.c +++ b/ext/wasm/c-pp-lite.c @@ -386,6 +386,9 @@ static void g_stderrv(char const *zFmt, va_list); if(lvl<=g.flags.doDebug) g_stderr("%s @ %s():%d: ",g.zArgv0,__func__,__LINE__); \ if(lvl<=g.flags.doDebug) g_stderr pfexpr +#define g_warn(zFmt,...) g_stderr("%s:%d %s() " zFmt "\n", __FILE__, __LINE__, __func__, __VA_ARGS__) +#define g_warn0(zMsg) g_stderr("%s:%d %s() %s\n", __FILE__, __LINE__, __func__, zMsg) + void cmpp_free(void *p){ sqlite3_free(p); } @@ -1468,6 +1471,9 @@ static inline void cmpp__skip_space_c( unsigned char const **p, *p = z; } +#define ustr_c(X) ((unsigned char const *)X) +//#define ustr_nc(X) ((unsigned char *)X) + /** Scan [t->zPos,t->zEnd) for a derective delimiter. Emits any non-delimiter output found along the way. @@ -1477,7 +1483,7 @@ static inline void cmpp__skip_space_c( unsigned char const **p, If a delimiter is found, it updates t->token and returns 0. On no match returns 0. */ -//static +static int CmppTokenizer__delim_search(CmppTokenizer * const t){ if(!t->zPos) t->zPos = t->zBegin; if( t->zPos>=t->zEnd ){ @@ -1621,16 +1627,21 @@ static void cmpp_t_out_expand(CmppTokenizer * const t, unsigned char const chEol = (unsigned char)'\n'; int state = 0 /* 0==looking for opening @ ** 1==looking for closing @ */; + if( 0 ){ + g_warn("zLeft=%d %c", (int)*zLeft, *zLeft); + } #define tflush \ + if(z>zEnd) z=zEnd; \ if(zLeft