SQLite

Check-in [b7c5ce84]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Ensure that detection of control characters by comparison against 0x1f uses unsigned characters. Forum post 4c344ca61f.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b7c5ce84216cc7f5a3ba07404572edb94fd628b3a7421111cd5f5333f3e56ea8
User & Date: drh 2025-03-02 20:29:49
Context
2025-03-03
11:48
Minor configure script doc tweaks. This is also a note that the basic elements of the build run as-is on Haiku OS Beta 5 but the tcl bits do not (for lack of tclConfig.sh). (check-in: acf9babf user: stephan tags: trunk)
2025-03-02
20:29
Ensure that detection of control characters by comparison against 0x1f uses unsigned characters. Forum post 4c344ca61f. (check-in: b7c5ce84 user: drh tags: trunk)
2025-03-01
23:44
Use SQLITE_EXTRA_INIT_MUTEXED instead of SQLITE_EXTRA_INIT for the SQLITE_WASM_EXTRA_INIT feature, as suggested in forum post 14183b98fc0b1dea. This doesn't make a functional difference now - this is in the name of future-proofing against eventual threading support in wasm. (check-in: 46479c2e user: stephan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/printf.c.
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
          ** For %#Q, do the same but only if there is at least
          ** one control character. */
          u32 nBack = 0;
          u32 nCtrl = 0;
          for(k=0; k<i; k++){
            if( escarg[k]=='\\' ){
              nBack++;
            }else if( escarg[k]<=0x1f ){
              nCtrl++;
            }
          }
          if( nCtrl || xtype==etESCAPE_q ){
            n += nBack + 5*nCtrl;
            if( xtype==etESCAPE_Q ){
              n += 10;







|







796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
          ** For %#Q, do the same but only if there is at least
          ** one control character. */
          u32 nBack = 0;
          u32 nCtrl = 0;
          for(k=0; k<i; k++){
            if( escarg[k]=='\\' ){
              nBack++;
            }else if( ((u8*)escarg)[k]<=0x1f ){
              nCtrl++;
            }
          }
          if( nCtrl || xtype==etESCAPE_q ){
            n += nBack + 5*nCtrl;
            if( xtype==etESCAPE_Q ){
              n += 10;
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
        if( flag_alternateform ){
          for(i=0; i<k; i++){
            bufpt[j++] = ch = escarg[i];
            if( ch==q ){
              bufpt[j++] = ch;
            }else if( ch=='\\' ){
              bufpt[j++] = '\\';
            }else if( ch<=0x1f ){
              bufpt[j-1] = '\\';
              bufpt[j++] = 'u';
              bufpt[j++] = '0';
              bufpt[j++] = '0';
              bufpt[j++] = ch>=0x10 ? '1' : '0';
              bufpt[j++] = "0123456789abcdef"[ch&0xf];
            }







|







834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
        if( flag_alternateform ){
          for(i=0; i<k; i++){
            bufpt[j++] = ch = escarg[i];
            if( ch==q ){
              bufpt[j++] = ch;
            }else if( ch=='\\' ){
              bufpt[j++] = '\\';
            }else if( ((unsigned char)ch)<=0x1f ){
              bufpt[j-1] = '\\';
              bufpt[j++] = 'u';
              bufpt[j++] = '0';
              bufpt[j++] = '0';
              bufpt[j++] = ch>=0x10 ? '1' : '0';
              bufpt[j++] = "0123456789abcdef"[ch&0xf];
            }
Changes to test/func9.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 2023-08-29
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#*************************************************************************
#
# Test cases for SQL newer functions
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_execsql_test func9-100 {
  SELECT concat('abc',123,null,'xyz');
} {abc123xyz}











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 2023-08-29
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#*************************************************************************
#
# Test cases for some newer SQL functions
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_execsql_test func9-100 {
  SELECT concat('abc',123,null,'xyz');
} {abc123xyz}
32
33
34
35
36
37
38










39
40
do_catchsql_test func9-150 {
  SELECT concat_ws();
} {1 {wrong number of arguments to function concat_ws()}}
do_catchsql_test func9-160 {
  SELECT concat_ws(',');
} {1 {wrong number of arguments to function concat_ws()}}












finish_test







>
>
>
>
>
>
>
>
>
>


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
do_catchsql_test func9-150 {
  SELECT concat_ws();
} {1 {wrong number of arguments to function concat_ws()}}
do_catchsql_test func9-160 {
  SELECT concat_ws(',');
} {1 {wrong number of arguments to function concat_ws()}}

# https://sqlite.org/forum/forumpost/4c344ca61f (2025-03-02)
do_execsql_test func9-200 {
  SELECT unistr('G\u00e4ste');
} {Gäste}
do_execsql_test func9-210 {
  SELECT unistr_quote(unistr('G\u00e4ste'));
} {'Gäste'}
do_execsql_test func9-220 {
  SELECT format('%#Q',unistr('G\u00e4ste'));
} {'Gäste'}

finish_test