Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | 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. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
da750e39df7bf42330d8c8b266300da0 |
User & Date: | drh 2024-10-11 14:30:58.752 |
Context
2024-10-11
| ||
17:02 | An improved method for statically linking sqlite3_analyzer.exe using Tcl9. Enable wildcard expansion of arguments to testfiture on Windows. (check-in: 9b87ea219b user: drh tags: trunk) | |
14:30 | 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. (check-in: da750e39df user: drh tags: trunk) | |
14:02 | Avoid undesirable NL to CRLF translation when doing binary output to the Windows console. (check-in: d25bdce36a user: drh tags: trunk) | |
Changes
Changes to src/shell.c.in.
︙ | ︙ | |||
1625 1626 1627 1628 1629 1630 1631 | ** import/export modes. */ #define SEP_Column "|" #define SEP_Row "\n" #define SEP_Tab "\t" #define SEP_Space " " #define SEP_Comma "," | < < < | < < < | 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 | ** import/export modes. */ #define SEP_Column "|" #define SEP_Row "\n" #define SEP_Tab "\t" #define SEP_Space " " #define SEP_Comma "," #define SEP_CrLf "\n" /* Use ".crnl on" to get \r\n line endings */ #define SEP_Unit "\x1F" #define SEP_Record "\x1E" /* ** Limit input nesting via .read or any other input redirect. ** It's not too expensive, so a generous allowance can be made. */ |
︙ | ︙ | |||
2797 2798 2799 2800 2801 2802 2803 | } case MODE_Csv: { sqlite3_fsetmode(p->out, _O_BINARY); if( p->cnt++==0 && p->showHeader ){ for(i=0; i<nArg; i++){ output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1); } | > > > | > > > > | > | 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 | } case MODE_Csv: { sqlite3_fsetmode(p->out, _O_BINARY); if( p->cnt++==0 && p->showHeader ){ for(i=0; i<nArg; i++){ output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1); } 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); } 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; } case MODE_Insert: { if( azArg==0 ) break; sqlite3_fprintf(p->out, "INSERT INTO %s",p->zDestTable); |
︙ | ︙ | |||
4948 4949 4950 4951 4952 4953 4954 | #endif ".changes on|off Show number of rows changed by SQL", #ifndef SQLITE_SHELL_FIDDLE ".check GLOB Fail if output since .testcase does not match", ".clone NEWDB Clone data into NEWDB from the existing database", #endif ".connection [close] [#] Open or close an auxiliary database connection", | < | < | 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 | #endif ".changes on|off Show number of rows changed by SQL", #ifndef SQLITE_SHELL_FIDDLE ".check GLOB Fail if output since .testcase does not match", ".clone NEWDB Clone data into NEWDB from the existing database", #endif ".connection [close] [#] Open or close an auxiliary database connection", ".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 ".dbinfo ?DB? Show status information about the database", #endif ".dump ?OBJECTS? Render database content as SQL", " Options:", |
︙ | ︙ | |||
8569 8570 8571 8572 8573 8574 8575 | }else{ eputz("Usage: .connection [close] [CONNECTION-NUMBER]\n"); rc = 1; } }else if( c=='c' && n==4 && cli_strncmp(azArg[0], "crnl", n)==0 ){ | < < < | | < | 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 | }else{ eputz("Usage: .connection [close] [CONNECTION-NUMBER]\n"); rc = 1; } }else if( c=='c' && n==4 && cli_strncmp(azArg[0], "crnl", n)==0 ){ if( nArg==2 ){ p->crnlMode = booleanValue(azArg[1]); setCrnlMode(p); }else{ sqlite3_fprintf(stderr, "crnl is currently %s\n", p->crnlMode ? "ON" : "OFF"); } }else if( c=='d' && n>1 && cli_strncmp(azArg[0], "databases", n)==0 ){ char **azName = 0; int nName = 0; sqlite3_stmt *pStmt; int i; |
︙ | ︙ | |||
12616 12617 12618 12619 12620 12621 12622 | sqlite3_config(SQLITE_CONFIG_MULTITHREAD); sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); /* 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 | | | | > > | 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 | sqlite3_config(SQLITE_CONFIG_MULTITHREAD); sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); /* 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. ** ** End-of-line marks on CVS output is CRLF when in .crnl is on and ** NL when .crnl is off. */ data->crnlMode = 0; } /* ** Output text to the console in a font that attracts extra attention. */ #if defined(_WIN32) || defined(WIN32) |
︙ | ︙ |