From c799c15dbef70dd8ee63be2c4b77ebeacce1df00 Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 15 Aug 2026 10:10:17 +0000 Subject: [PATCH] Refactor "realfmt"→"fpfmt" and "intfmt"→"ifmt". FossilOrigin-Name: 17277813d101187d85755b7bad3f1c95380335021e13ee368be0add0c8c346b3 --- ext/qrf/README.md | 8 +++---- ext/qrf/qrf.c | 26 ++++++++++----------- ext/qrf/qrf.h | 4 ++-- manifest | 24 ++++++++++---------- manifest.uuid | 2 +- src/shell.c.in | 44 +++++++++++++++++------------------ src/tclsqlite.c | 20 ++++++++-------- test/modeA.sql | 58 +++++++++++++++++++++++------------------------ test/qrf01.test | 18 +++++++-------- 9 files changed, 102 insertions(+), 102 deletions(-) diff --git a/ext/qrf/README.md b/ext/qrf/README.md index 9ff0338b62..68919fe61d 100644 --- a/ext/qrf/README.md +++ b/ext/qrf/README.md @@ -132,8 +132,8 @@ struct sqlite3_qrf_spec { char **pzOutput; /* Storage location for output string */ /* The following are available in iVersion 2 and later */ unsigned char bRowCount; /* Show the number of rows at end of each query */ - char *zIntFmt; /* Format string for integers */ - char *zRealFmt; /* Format string for floating point */ + char *zIFmt; /* Format string for integers */ + char *zFpFmt; /* Format string for floating point */ /* Additional fields may be added in the future */ }; ~~~ @@ -608,9 +608,9 @@ If the value of bRowCount is QRF_Yes, then an extra line of text of the form "(N rows)" might be appended to the end of query output, depending on eStyle. -### 2.19 Number Formatting (zIntFmt and zRealFmt) +### 2.19 Number Formatting (zIFmt and zFpFmt) -If the zIntFmt and zRealFmt fields are a short printf-style format +If the zIFmt and zFpFmt fields are a short printf-style format string, than that formatting string is used to render integer and floating-point values, respectively. The width and precision fields of the format string (if present) must not exceed three decimal digits. diff --git a/ext/qrf/qrf.c b/ext/qrf/qrf.c index 2f4ed0c175..15cea66a91 100644 --- a/ext/qrf/qrf.c +++ b/ext/qrf/qrf.c @@ -118,11 +118,11 @@ static const char qrfCType[] = { #endif /* -** The argument is a proposed format string for the zIntFmt or zRealFmt +** The argument is a proposed format string for the zIFmt or zFpFmt ** parameters. Return value indicates: ** ** 0 The input is not a valid format string. If this string -** appears in either zIntFmt or zRealFmt, it will be ignored. +** appears in either zIFmt or zFpFmt, it will be ignored. ** ** 1 The input is a valid format string for integers. ** @@ -1142,14 +1142,14 @@ static void qrfRenderValue(Qrf *p, sqlite3_str *pOut, int iCol){ } switch( sqlite3_column_type(p->pStmt,iCol) ){ case SQLITE_INTEGER: { - sqlite3_str_appendf(pOut, p->spec.zIntFmt, + sqlite3_str_appendf(pOut, p->spec.zIFmt, sqlite3_column_int64(p->pStmt,iCol)); break; } case SQLITE_FLOAT: { - if( p->spec.zRealFmt ){ + if( p->spec.zFpFmt ){ double r = sqlite3_column_double(p->pStmt,iCol); - sqlite3_str_appendf(pOut,p->spec.zRealFmt,r); + sqlite3_str_appendf(pOut,p->spec.zFpFmt,r); }else{ const char *zTxt = (const char*)sqlite3_column_text(p->pStmt,iCol); sqlite3_str_appendall(pOut, zTxt); @@ -3016,19 +3016,19 @@ qrf_reinit: } if( p->spec.zColumnSep==0 ) p->spec.zColumnSep = ","; if( p->spec.zRowSep==0 ) p->spec.zRowSep = "\n"; - if( p->spec.zIntFmt==0 || sqlite3_qrf_ckformat(p->spec.zIntFmt)!=1 ){ - p->spec.zIntFmt = "%lld"; + if( p->spec.zIFmt==0 || sqlite3_qrf_ckformat(p->spec.zIFmt)!=1 ){ + p->spec.zIFmt = "%lld"; }else{ - size_t n = strlen(p->spec.zIntFmt); - memcpy(p->zFmt, p->spec.zIntFmt, n-1); + size_t n = strlen(p->spec.zIFmt); + memcpy(p->zFmt, p->spec.zIFmt, n-1); p->zFmt[n-1] = 'l'; p->zFmt[n] = 'l'; - p->zFmt[n+1] = p->spec.zIntFmt[n-1]; + p->zFmt[n+1] = p->spec.zIFmt[n-1]; p->zFmt[n+2] = 0; - p->spec.zIntFmt = p->zFmt; + p->spec.zIFmt = p->zFmt; } - if( p->spec.zRealFmt && sqlite3_qrf_ckformat(p->spec.zRealFmt)!=2 ){ - p->spec.zRealFmt = 0; + if( p->spec.zFpFmt && sqlite3_qrf_ckformat(p->spec.zFpFmt)!=2 ){ + p->spec.zFpFmt = 0; } } diff --git a/ext/qrf/qrf.h b/ext/qrf/qrf.h index 9b2364f829..cb3a52518f 100644 --- a/ext/qrf/qrf.h +++ b/ext/qrf/qrf.h @@ -59,8 +59,8 @@ struct sqlite3_qrf_spec { char **pzOutput; /* Storage location for output string */ /* The following are available in iVersion 2 and later */ unsigned char bRowCount; /* Show the number of rows at end of each query */ - char *zIntFmt; /* Format string for integers */ - char *zRealFmt; /* Format string for floating point */ + char *zIFmt; /* Format string for integers */ + char *zFpFmt; /* Format string for floating point */ /* Additional fields may be added in the future */ }; diff --git a/manifest b/manifest index 9e1d74b84b..1e4e2a2934 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sredundant\soffsetof\sdefinition\sfrom\sqrf.c. -D 2026-08-14T18:49:42.749 +C Refactor\s"realfmt"→"fpfmt"\sand\s"intfmt"→"ifmt". +D 2026-08-15T10:10:17.514 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -423,10 +423,10 @@ F ext/misc/wholenumber.c e41953e078894e66a0ff05dd6c76a61f904828c9a4620c7255fac26 F ext/misc/windirent.h 02211ce51f3034c675f2dbf4d228194d51b3ee05734678bad5106fff6292e60c F ext/misc/zipfile.c 84d8c265f6d1835327009458413b4cc017c5a9e19936583b562bd6808a659601 F ext/misc/zorder.c bddff2e1b9661a90c95c2a9a9c7ecd8908afab5763256294dd12d609d4664eee -F ext/qrf/README.md 40377f2b4acb15dd2d8a8894674c52f0b1498ad439a26bfb64800f0bc0e42e3a +F ext/qrf/README.md c5c47a8b82ee870557ec9c6734bf93c296ae4821d33cf60253b36f2fcee09601 F ext/qrf/dev-notes.md e68a6d91ce4c7eb296ef2daadc2bb79c95c317ad15b9fafe40850c67b29c2430 -F ext/qrf/qrf.c b30c9dfdc29a7d6bfb51029797f391416b195b45114896f9b4ab822bdfa37e6a -F ext/qrf/qrf.h 62208aefef5714b9e9294f993a653f3ec5fb85a5873e5fe3e88df34c90f1bcab +F ext/qrf/qrf.c 2acebfc0a8ab654b0dc0b4b225a5b3a8d435c54692d12287e505ff740ff6f768 +F ext/qrf/qrf.h 82016075681a58b8eaf260eda49205ad10c5a4940d5673a152340b6b19440f7f F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8 F ext/rbu/rbu1.test 25870dd7db7eb5597e2b4d6e29e7a7e095abf332660f67d89959552ce8f8f255 F ext/rbu/rbu10.test 7c22caa32c2ff26983ca8320779a31495a6555737684af7aba3daaf762ef3363 @@ -743,7 +743,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 7145e41ad75e04a811b326aa5faf83c2e071480fabd9fc825055a6b889e6cb86 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 7720e5e4ffcdf630691a2208e284a5b4eb507f51a06a380487b10ef5f6a9c8dc -F src/shell.c.in 450774a5fbe08ed73ae973cf8ab6bf04bc4480fcf4141094073aec69e80d099a +F src/shell.c.in a4e702b7e4acde729712b08cab8e9888ebbd468887d05b4e5799509b41150fe8 F src/sqlite.h.in 2101a2b494cbc282d0dc1c3f631c4fb83060c52876cc9d7615b091ad66d932b1 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479 F src/sqlite3ext.h 0efd4723bad9124ea1f581d9f1ea0254ac1c6f3e5fb29e4f3dcf36c72485a456 @@ -751,7 +751,7 @@ F src/sqliteInt.h e024c4d4d6ec812e087c46126a5aea9ca3b386240459da6013aab90a9d18cf F src/sqliteLimit.h 7617f2ee673dab382046beba4552283f442cf1a181bb169ac38eb908135dd8da F src/status.c 7565d63a79aa2f326339a24a0461a60096d0bd2bce711fefb50b5c89335f3592 F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c e827fa90c2f7571223a83f2a13b0105232730cb8496052bf09836870cab19396 +F src/tclsqlite.c 935275eaafba7a737d7c44cb1626ae0ce3c273576bb442b00fab3b7d4acc1e48 F src/tclsqlite.h 614b3780a62522bc9f8f2b9fb22689e8009958e7aa77e572d0f3149050af348a F src/test1.c bd9e5123ef2136c960a16c09a1abfbcb6c1498e5193deb2acee188260a31a473 F src/test2.c a61ed01d9264a1db74ab42fbc981fc66165f85d5e3947e92be61a73e79ec4f2d @@ -1465,7 +1465,7 @@ F test/mmap4.test 2e2b4e32555b58da15176e6fe750f17c9dcf7f93 F test/mmapcorrupt.test 470fb44fe92e99c1d23701d156f8c17865f5b027063c9119dcfdb842791f4465 F test/mmapfault.test d4c9eff9cd8c2dc14bc43e71e042f175b0a26fe3 F test/mmapwarm.test 2272005969cd17a910077bd5082f70bc1fefad9a875afec7fc9af483898ecaf3 -F test/modeA.sql 33f17eac6b2a6ff7ce07120a066b3b3a5cb95b1aeed36807ef562f602518af47 +F test/modeA.sql a6830e8742876f74d0eab9047d44cece0fdf0bf82a323735af0fc86dc14c27d8 F test/multiplex.test d74c034e52805f6de8cc5432cef8c9eb774bb64ec29b83a22effc8ca4dac1f08 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a F test/multiplex3.test fac575e0b1b852025575a6a8357701d80933e98b5d2fe6d35ddaa68f92f6a1f7 @@ -1537,7 +1537,7 @@ F test/printf2.test 3f55c1871a5a65507416076f6eb97e738d5210aeda7595a74ee895f2224c F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/pushdown.test 46a626ef1c0ca79b85296ff2e078b9da20a50e9b804b38f441590c3987580ddd -F test/qrf01.test 8006b3a480b1318bd88854a984cea6592f199416d39e63b99dc0fd6266b4cbc4 +F test/qrf01.test dfd8ef8bfb3765bb036595946bb1c3bcfc571197d2b7f2c7c8413117e7918dc3 F test/qrf02.test 39b4afdc000bedccdafc0aecf17638df67a67aaa2d2942865ae6abcc48ba0e92 F test/qrf03.test e7efe46d204671726b4707585126cd78d107368de4a7d0c7b8d5157cdd8624ed F test/qrf04.test 0894692c998d2401dcc33449c02051b503ecce0c94217be54fb007c82d2d1379 @@ -2218,8 +2218,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c -P 61b0157686da3e6700ddcb7273b91eba69ff3015f8185470fd4fa02e52205401 -R a5735a82c7fe2149f7f200065d699e6a +P 5d230cafc6abf48dd623385df106e61fa5bf15a9cff855eb27680aa0f7533c8b +R 85110d133ae92098d064fba934128824 U drh -Z 344b2d08006f8d18da2d1fa756e0e9a0 +Z aee5be21b747420ad1c12d11d1ea8925 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8a80888132..847f2373e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d230cafc6abf48dd623385df106e61fa5bf15a9cff855eb27680aa0f7533c8b +17277813d101187d85755b7bad3f1c95380335021e13ee368be0add0c8c346b3 diff --git a/src/shell.c.in b/src/shell.c.in index 4b327993d2..7404919ff8 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -371,8 +371,8 @@ typedef struct Mode { u8 bAutoScreenWidth; /* Using the TTY to determine screen width */ u8 mFlags; /* MFLG_ECHO, MFLG_CRLF, etc. */ u8 eMode; /* One of the MODE_ values */ - char zIntFmt[24]; /* Space to hold the --intfmt value */ - char zRealFmt[24]; /* Space to hold the --realfmt value */ + char zIFmt[24]; /* Space to hold the --ifmt value */ + char zFpFmt[24]; /* Space to hold the --fpfmt value */ sqlite3_qrf_spec spec; /* Spec to be passed into QRF */ } Mode; @@ -8676,7 +8676,9 @@ static int modeTitleDsply(ShellState *p, int bAll){ ** --escape ESC Enable/disable escaping of control characters ** found in the output. ESC can be "off", "ascii", ** or "symbol". -** --intfmt STRING String is a printf-style format string used to +** --fpfmt STRING String is a printf-style format string used to +** render floating-point values. +** --ifmt STRING String is a printf-style format string used to ** render integer values. ** --linelimit N Set the maximum number of output lines to show for ** any single SQL value to N. Longer values are @@ -8697,8 +8699,6 @@ static int modeTitleDsply(ShellState *p, int bAll){ ** "off", "on", "sql", "relaxed", "csv", "html", ** "tcl", or "json". "off" means show the text as-is. ** "on" is an alias for "sql". -** --realfmt STRING String is a printf-style format string used to -** render floating-point values. ** --reset Changes all mode settings back to their default. ** --rowcount BOOLEAN Show "(N rows)" at the end of query results. ** --rowsep STRING Use STRING as the row separator @@ -8936,38 +8936,38 @@ static int dotCmdMode(ShellState *p){ break; } chng = 1; - }else if( optionMatch(z,"intfmt") ){ + }else if( optionMatch(z,"ifmt") ){ if( i+1>=nArg ){ dotCmdError(p, i, "missing argument", 0); return 1; } i++; if( azArg[i][0]==0 || cli_strcmp(azArg[i],"default")==0 ){ - p->mode.spec.zIntFmt = 0; + p->mode.spec.zIFmt = 0; }else if( sqlite3_qrf_ckformat(azArg[i])!=1 ){ dotCmdError(p, i, "not a valid integer format", 0); return 1; }else{ - assert( strlen(azArg[i])mode.zIntFmt)-1 ); - memcpy(p->mode.zIntFmt, azArg[i], strlen(azArg[i])+1); - p->mode.spec.zIntFmt = p->mode.zIntFmt; + assert( strlen(azArg[i])mode.zIFmt)-1 ); + memcpy(p->mode.zIFmt, azArg[i], strlen(azArg[i])+1); + p->mode.spec.zIFmt = p->mode.zIFmt; } chng = 1; - }else if( optionMatch(z,"realfmt") ){ + }else if( optionMatch(z,"fpfmt") ){ if( i+1>=nArg ){ dotCmdError(p, i, "missing argument", 0); return 1; } i++; if( azArg[i][0]==0 || cli_strcmp(azArg[i],"default")==0 ){ - p->mode.spec.zRealFmt = 0; + p->mode.spec.zFpFmt = 0; }else if( sqlite3_qrf_ckformat(azArg[i])!=2 ){ dotCmdError(p, i, "not a valid floating-point format", 0); return 1; }else{ - assert( strlen(azArg[i])mode.zRealFmt)-1 ); - memcpy(p->mode.zRealFmt, azArg[i], strlen(azArg[i])+1); - p->mode.spec.zRealFmt = p->mode.zRealFmt; + assert( strlen(azArg[i])mode.zFpFmt)-1 ); + memcpy(p->mode.zFpFmt, azArg[i], strlen(azArg[i])+1); + p->mode.spec.zFpFmt = p->mode.zFpFmt; } chng = 1; }else if( optionMatch(z,"reset") ){ @@ -9204,9 +9204,13 @@ static int dotCmdMode(ShellState *p){ if( bAll || p->mode.spec.eEsc!=QRF_Auto ){ sqlite3_str_appendf(pDesc, " --escape %s",qrfEscNames[p->mode.spec.eEsc]); } - if( bAll || p->mode.spec.zIntFmt!=0 ){ - const char *z = p->mode.spec.zIntFmt; - sqlite3_str_appendf(pDesc, " --intfmt %s", z ? z : "default"); + if( bAll || p->mode.spec.zFpFmt!=0 ){ + const char *z = p->mode.spec.zFpFmt; + sqlite3_str_appendf(pDesc, " --fpfmt %s", z ? z : "\"\""); + } + if( bAll || p->mode.spec.zIFmt!=0 ){ + const char *z = p->mode.spec.zIFmt; + sqlite3_str_appendf(pDesc, " --ifmt %s", z ? z : "\"\""); } if( bAll || (p->mode.spec.nLineLimit>0 && pI->eCx>0) @@ -9245,10 +9249,6 @@ static int dotCmdMode(ShellState *p){ ){ sqlite3_str_appendf(pDesc," --quote %s",qrfQuoteNames[p->mode.spec.eText]); } - if( bAll || p->mode.spec.zRealFmt!=0 ){ - const char *z = p->mode.spec.zRealFmt; - sqlite3_str_appendf(pDesc, " --realfmt %s", z ? z : "default"); - } if( bAll || ((p->mode.spec.bRowCount==QRF_Yes) != ((pI->mFlg&4)!=0)) ){ diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 3a0110a4fd..1d67492279 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -2079,8 +2079,8 @@ static void DbHookCmd( ** -rowsep TEXT Row separator text ** -tablename TEXT Table name for style "insert" ** -null TEXT Text for NULL values -** -intfmt STRING Format for integer values -** -realfmt STRING Format for floating-point values +** -ifmt STRING Format for integer values +** -fpfmt STRING Format for floating-point values ** ** A mapping from TCL "format" command options to sqlite3_qrf_spec fields ** is below. Use this to reference the QRF documentation: @@ -2111,8 +2111,8 @@ static void DbHookCmd( ** -rowsep zRowSep ** -tablename zTableName ** -null zNull -** -intfmt zIntFmt -** -realfmt zRealFmt +** -ifmt zIFmt +** -fpfmt zFpFmt ** ** The TCL -title option maps to eTitle and bTitles as follows: ** @@ -2408,27 +2408,27 @@ static int dbQrf(SqliteDb *pDb, int objc, Tcl_Obj *const*objv){ }else if( strcmp(zArg,"-null")==0 ){ qrf.zNull = Tcl_GetString(objv[i+1]); i++; - }else if( strcmp(zArg,"-intfmt")==0 ){ + }else if( strcmp(zArg,"-ifmt")==0 ){ char *zFmt = Tcl_GetString(objv[i+1]); if( zFmt[0]==0 || strcmp(zFmt,"default")==0 ){ zFmt = 0; }else if( sqlite3_qrf_ckformat(zFmt)!=1 ){ - Tcl_AppendResult(pDb->interp, "bad format for -intfmt", (char*)0); + Tcl_AppendResult(pDb->interp, "bad format for -ifmt", (char*)0); rc = TCL_ERROR; goto format_failed; } - qrf.zIntFmt = zFmt; + qrf.zIFmt = zFmt; i++; - }else if( strcmp(zArg,"-realfmt")==0 ){ + }else if( strcmp(zArg,"-fpfmt")==0 ){ char *zFmt = Tcl_GetString(objv[i+1]); if( zFmt[0]==0 || strcmp(zFmt,"default")==0 ){ zFmt = 0; }else if( sqlite3_qrf_ckformat(zFmt)!=2 ){ - Tcl_AppendResult(pDb->interp, "bad format for -realfmt", (char*)0); + Tcl_AppendResult(pDb->interp, "bad format for -fpfmt", (char*)0); rc = TCL_ERROR; goto format_failed; } - qrf.zRealFmt = zFmt; + qrf.zFpFmt = zFmt; i++; }else if( strcmp(zArg,"-version")==0 ){ /* Undocumented. Testing use only */ diff --git a/test/modeA.sql b/test/modeA.sql index 7f265b91e2..9fc2929afa 100644 --- a/test/modeA.sql +++ b/test/modeA.sql @@ -103,7 +103,7 @@ END .testcase 140 .mode -v .check <