aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrh <>2024-10-11 14:30:58 +0000
committerdrh <>2024-10-11 14:30:58 +0000
commitb23cce9a16a6b90fed2bd3e189fe4e9f2ff63b68 (patch)
tree18bf8f1a7f947cdbedd365af96c5de6911abb32f
parent0b453b3b3379f34527c957c6e1f7631a887c7340 (diff)
downloadsqlite-b23cce9a16a6b90fed2bd3e189fe4e9f2ff63b68.tar.gz
sqlite-b23cce9a16a6b90fed2bd3e189fe4e9f2ff63b68.zip
Fix the CSV output mode in the CLI such that the line ending is NL by default
but goes to CRLF if ".crnl on" is set. Make the .crnl command available on non-Windows builds. Update the .crnl command such that if it has no arguments it shows the current setting. FossilOrigin-Name: da750e39df7bf42330d8c8b266300da07247c9619895861b4cff4be7c94db7cf
-rw-r--r--manifest12
-rw-r--r--manifest.uuid2
-rw-r--r--src/shell.c.in40
3 files changed, 26 insertions, 28 deletions
diff --git a/manifest b/manifest
index f410abbe6..a632e7547 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Avoid\sundesirable\sNL\sto\sCRLF\stranslation\swhen\sdoing\sbinary\soutput\sto\sthe\nWindows\sconsole.
-D 2024-10-11T14:02:48.369
+C Fix\sthe\sCSV\soutput\smode\sin\sthe\sCLI\ssuch\sthat\sthe\sline\sending\sis\sNL\sby\sdefault\nbut\sgoes\sto\sCRLF\sif\s".crnl\son"\sis\sset.\s\sMake\sthe\s.crnl\scommand\savailable\son\nnon-Windows\sbuilds.\s\sUpdate\sthe\s.crnl\scommand\ssuch\sthat\sif\sit\shas\sno\sarguments\nit\sshows\sthe\scurrent\ssetting.
+D 2024-10-11T14:30:58.752
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -770,7 +770,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe
-F src/shell.c.in 0701ac81f16d1b23254f141118ea064c33c153d7099d3bf7db650ce45eead689
+F src/shell.c.in 46fa7b8be665d17c9593fbf40299ee799e6a932a9b59e7f2e5c686f574136cae
F src/sqlite.h.in 1def838497ad53c81486649ce79821925d1ac20a9843af317a344d507efe116e
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
@@ -2216,8 +2216,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P bcfae7183e92ce37717852bae5b1dd526903fa8429fb6f738c2147d4e5231642
-R ce21189a126f3d2c64453710bc34a276
+P d25bdce36abed95524ad058a277aba7bb17270e7ff1476474713dbc29742c762
+R 1814f31c76f5b99a165395372f50c6cf
U drh
-Z 1e590b34c76a965a6a2ae1e5a7b7871c
+Z d664c82762a3265052efdefacef5a18c
# Remove this line to create a well-formed Fossil manifest.
diff --git a/manifest.uuid b/manifest.uuid
index e116a9db3..77aea442e 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-d25bdce36abed95524ad058a277aba7bb17270e7ff1476474713dbc29742c762
+da750e39df7bf42330d8c8b266300da07247c9619895861b4cff4be7c94db7cf
diff --git a/src/shell.c.in b/src/shell.c.in
index 5a90fec7e..ec32acca7 100644
--- a/src/shell.c.in
+++ b/src/shell.c.in
@@ -1629,13 +1629,7 @@ static const char *modeDescr[] = {
#define SEP_Tab "\t"
#define SEP_Space " "
#define SEP_Comma ","
-#ifdef SQLITE_U8TEXT_ONLY
- /* With the SQLITE_U8TEXT_ONLY option, the output will always be in
- ** text mode. The \r will be inserted automatically. */
-# define SEP_CrLf "\n"
-#else
-# define SEP_CrLf "\r\n"
-#endif
+#define SEP_CrLf "\n" /* Use ".crnl on" to get \r\n line endings */
#define SEP_Unit "\x1F"
#define SEP_Record "\x1E"
@@ -2801,13 +2795,21 @@ static int shell_callback(
for(i=0; i<nArg; i++){
output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
}
- sqlite3_fputs(p->rowSeparator, p->out);
+ if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){
+ sqlite3_fputs("\r\n", p->out);
+ }else{
+ sqlite3_fputs(p->rowSeparator, p->out);
+ }
}
if( nArg>0 ){
for(i=0; i<nArg; i++){
output_csv(p, azArg[i], i<nArg-1);
}
- sqlite3_fputs(p->rowSeparator, p->out);
+ if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){
+ sqlite3_fputs("\r\n", p->out);
+ }else{
+ sqlite3_fputs(p->rowSeparator, p->out);
+ }
}
setCrnlMode(p);
break;
@@ -4952,9 +4954,7 @@ static const char *(azHelp[]) = {
".clone NEWDB Clone data into NEWDB from the existing database",
#endif
".connection [close] [#] Open or close an auxiliary database connection",
-#if defined(_WIN32)
- ".crnl on|off Translate \\n to \\r\\n. Default ON",
-#endif
+ ".crnl on|off Translate \\n to \\r\\n sometimes. Default OFF",
".databases List names and files of attached databases",
".dbconfig ?op? ?val? List or change sqlite3_db_config() options",
#if SQLITE_SHELL_HAVE_RECOVER
@@ -8573,17 +8573,13 @@ static int do_meta_command(char *zLine, ShellState *p){
}else
if( c=='c' && n==4 && cli_strncmp(azArg[0], "crnl", n)==0 ){
-#if !defined(_WIN32)
- sqlite3_fputs("The \".crnl\" command is disable in this build.\n", p->out);
-#else
if( nArg==2 ){
p->crnlMode = booleanValue(azArg[1]);
setCrnlMode(p);
}else{
- eputz("Usage: .crnl on|off\n");
- rc = 1;
+ sqlite3_fprintf(stderr, "crnl is currently %s\n",
+ p->crnlMode ? "ON" : "OFF");
}
-#endif
}else
if( c=='d' && n>1 && cli_strncmp(azArg[0], "databases", n)==0 ){
@@ -12620,9 +12616,11 @@ static void main_init(ShellState *data) {
/* By default, come up in O_BINARY mode. That way, the default output is
** the same for Windows and non-Windows systems. Use the ".crnl on"
** command to change into O_TEXT mode to do automatic NL-to-CRLF
- ** conversions on output for Windows. Windows console output is not
- ** subject to the crnlMode setting and is unaffected either way. This
- ** setting only affects output going into a file or pipe. */
+ ** conversions on output for Windows.
+ **
+ ** End-of-line marks on CVS output is CRLF when in .crnl is on and
+ ** NL when .crnl is off.
+ */
data->crnlMode = 0;
}