From: stephan Date: Thu, 13 Nov 2025 14:47:41 +0000 (+0000) Subject: Add the #include -raw flag to ext/wasm/c-pp-lite.c to support a pending feature. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a9025a5f1a4c7e3a2dbb9244901df57308e30cce;p=thirdparty%2Fsqlite.git Add the #include -raw flag to ext/wasm/c-pp-lite.c to support a pending feature. FossilOrigin-Name: 42c30c314969c0f2573bbe36615683ac19a7ba4e30004c7080873459096caaf5 --- diff --git a/ext/wasm/c-pp-lite.c b/ext/wasm/c-pp-lite.c index 536fb3e583..7b70b3895f 100644 --- a/ext/wasm/c-pp-lite.c +++ b/ext/wasm/c-pp-lite.c @@ -270,9 +270,10 @@ static void db_prepare(sqlite3_stmt **pStmt, const char * zSql, ...); /* ** Opens the given file and processes its contents as c-pp, sending ** all output to the global c-pp output channel. Fails fatally on -** error. +** error. If bRaw is true then the file's contents are passed through +** verbatim, rather than being preprocessed. */ -static void cmpp_process_file(const char * zName); +static void cmpp_process_file(const char * zName, int bRaw); /* ** Operator policy for cmpp_kvp_parse(). @@ -2212,12 +2213,23 @@ static void cmpp_kwd_endif(CmppKeyword const * pKw, CmppTokenizer *t){ static void cmpp_kwd_include(CmppKeyword const * pKw, CmppTokenizer *t){ char const * zFile; char * zResolved; + int bRaw = 0 /* -raw flag */; if(CT_skip(t)) return; - else if(t->args.argc!=2){ - cmpp_kwd__err(pKw, t, "Expecting exactly 1 filename argument"); + else if(t->args.argc<2 || t->args.argc>3){ + cmpp_kwd__err(pKw, t, "Expected args: ?-raw? filename"); + } + if(t->args.argc==2){ + zFile = (const char *)t->args.argv[1]; + }else{ + if( 0==strcmp("-raw", (char*)t->args.argv[1]) ){ + bRaw = 1; + }else{ + cmpp_kwd__err(pKw, t, "Unhandled argument: %s", + t->args.argv[1]); + } + zFile = (const char *)t->args.argv[2]; } - zFile = (const char *)t->args.argv[1]; - if(db_including_has(zFile)){ + if(!bRaw && db_including_has(zFile)){ /* Note that different spellings of the same filename ** will elude this check, but that seems okay, as different ** spellings means that we're not re-running the exact same @@ -2228,16 +2240,15 @@ static void cmpp_kwd_include(CmppKeyword const * pKw, CmppTokenizer *t){ } zResolved = db_include_search(zFile); if(zResolved){ - db_including_add(zFile, t->zName, t->token.lineNo); - cmpp_process_file(zResolved); - db_include_rm(zFile); + if( bRaw ) db_including_add(zFile, t->zName, t->token.lineNo); + cmpp_process_file(zResolved, bRaw); + if( bRaw ) db_include_rm(zFile); db_free(zResolved); }else{ cmpp_t__err(t, "file not found: %s", zFile); } } - static void cmpp_dump_defines( FILE * fp, int bIndent ){ sqlite3_stmt * const q = g_stmt(GStmt_defSelAll); while( SQLITE_ROW==sqlite3_step(q) ){ @@ -2391,7 +2402,7 @@ CmppKeyword aKeywords[] = { {S(Endif), 0, TT_Endif, cmpp_kwd_endif}, {S(Error), 0, TT_Error, cmpp_kwd_error}, {S(If), 1, TT_If, cmpp_kwd_if}, - {S(Include), 0, TT_Include, cmpp_kwd_include}, + {S(Include), 1, TT_Include, cmpp_kwd_include}, {S(Pragma), 1, TT_Pragma, cmpp_kwd_pragma}, {S(Savepoint), 1, TT_Savepoint, cmpp_kwd_savepoint}, {S(Stderr), 0, TT_Stderr, cmpp_kwd_stderr}, @@ -2443,14 +2454,25 @@ void cmpp_process_string(const char * zName, g.tok = oldTok; } -void cmpp_process_file(const char * zName){ +void cmpp_process_file(const char * zName, int bRaw){ FileWrapper fw = FileWrapper_empty; FileWrapper_open(&fw, zName, "r"); g_FileWrapper_link(&fw); FileWrapper_slurp(&fw); g_debug(1,("Read %u byte(s) from [%s]\n", fw.nContent, fw.zName)); if( fw.zContent ){ - cmpp_process_string(zName, fw.zContent, fw.nContent); + if( bRaw ){ + FileWrapper fw = FileWrapper_empty; + FileWrapper_open(&fw, zName, "rb"); + g_FileWrapper_link(&fw); + FileWrapper_slurp(&fw); + if( 1!=fwrite(fw.zContent, fw.nContent, 1, g.out.pFile) ){ + fatal("fwrite() failed with errno %d\n", errno); + } + g_FileWrapper_close(&fw); + }else{ + cmpp_process_string(zName, fw.zContent, fw.nContent); + } } g_FileWrapper_close(&fw); } @@ -2689,7 +2711,7 @@ int main(int argc, char const * const * argv){ DOIT { ++nFile; g_out_open; - cmpp_process_file(zVal); + cmpp_process_file(zVal, 0); } } ISFLAG("e"){ @@ -2772,7 +2794,7 @@ int main(int argc, char const * const * argv){ ++inclCount; } FileWrapper_open(&g.out, g.out.zName, "w"); - cmpp_process_file("-"); + cmpp_process_file("-", 0); } } } diff --git a/manifest b/manifest index efb625b66c..4eb5356f5d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sthe\sEXISTS-to-JOIN\soptimization\s([e33da6d5dc964db8])\sso\nthat\sit\sworks\swith\snested\sWHERE\sand\sEXISTS\sstatements.\n[forum:/forumpost/0704c3c41e49631b|Forum\spost\s0704c3c41e4] -D 2025-11-13T11:36:48.835 +C Add\sthe\s#include\s-raw\sflag\sto\sext/wasm/c-pp-lite.c\sto\ssupport\sa\spending\sfeature. +D 2025-11-13T14:47:41.941 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -604,7 +604,7 @@ F ext/wasm/api/sqlite3-vtab-helper.c-pp.js 9097074724172e31e56ce20ccd7482259cf72 F ext/wasm/api/sqlite3-wasm.c 2d1cbe498f7b0fb64b11451eda481f458df74d6258baea635513e637fcbb8b1a F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bda1c75bd674a92a0e27cc2f3d46dbbf21e422413f8046814515a0bd7409328a F ext/wasm/api/sqlite3-worker1.c-pp.js 802d69ead8c38dc1be52c83afbfc77e757da8a91a2e159e7ed3ecda8b8dba2e7 -F ext/wasm/c-pp-lite.c 67e86d9ea47cf3e70a4067acd92788f4f8e6271fae02a68490b069303d7597be +F ext/wasm/c-pp-lite.c 943be1a36774d58385dca32de36fc18d4f432fe79f7aa35e6c85dd6a6b825bd0 F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f @@ -2167,8 +2167,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P cb0f0e22241aae65938b4bc7a1b809088466a17cee80344f66ee889a76c422c1 -R e1df7415359298fd0a1cd1de534392b6 -U drh -Z 3f50cf19050f41cd47ef418e45137a07 +P d1e901eddc25175174d0706238ae0c33bfa5569e0c2ba4f1164b7a9600203442 +R 69751ab1669928a56efde739054714dc +U stephan +Z 96038a39e433e91de1388406d7509460 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4c354a0c06..e470a63f10 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d1e901eddc25175174d0706238ae0c33bfa5569e0c2ba4f1164b7a9600203442 +42c30c314969c0f2573bbe36615683ac19a7ba4e30004c7080873459096caaf5