Fossil SCM

Sync with trunk.

florian 2024-12-12 16:58 UTC timeline-keyboard-navigation merge
Commit 611f20e81708ee77c0d6a7b6103cb0723aa51731e8a6ec154fd4e0d45e6f74cd
157 files changed +1 -1 +4 -1 +1 -1 +7 +5 -3 +95 -28 +722 -241 +3 -3 +1 -1 +3370 -1991 +2361 -1405 +80 -13 +22 -17 +4 -1 +7 -6 +1 -1 +23 -6 +8 -1 +12 -4 +49 -1 +4 -3 -17 +3 -1 +9 -3 +114 -14 +221 -71 +28 -9 +13 -14 +52 -10 +52 -10 +50 -48 +146 -7 +1 -1 +8 -8 +26 -1 +2 +1 -1 +99 -9 +13 -5 +63 -35 +25 -5 +3 -1 +1 -1 +15 -3 +54 -6 +2 -2 +6 +4 -6 +4 -1 +152 -17 +2 -1 +16 -4 +13 -10 +2 -1 +7 -3 +465 -6 +619 +804 -168 +6 -2 +1 +12 -2 +9 -3 +4 -5 +7 -7 +83 -64 +16 -4 +7 -5 +5 -40 +9 +2 -1 +2 -1 +1 -1 +55 -3 +4 -4 +229 +40 -1 +20 +20 -20 +6 +2 +1 +2 -1 +1 -1 +1 +2 +4 -4 +3 -3 +2 -2 +2 -2 +3 -3 +2 -2 +6 -6 +2 -2 +1 -1 +1 -1 +2 -2 +26 -4 +2 -2 +1 -1 +4 -4 +1 -1 +10 -8 +13 -5 +3 -3 +1 -1 +3 -3 +6 -6 +1 -1 +1 -1 +9 -10 +1 -1 +3 -3 +2 -2 +1 -1 +1 -1 +1 -1 +1 -1 +4 -4 +4 -4 +2 -2 +5 -5 +1 -1 +3 -3 +1 -1 +1 -1 +2 -2 +2 -2 +8 -8 +7 -7 +10 -9 +1 -1 +2 -1 +6 -2 +4 -4 +2 -2 +1 -1 +1 -1 +2 -2 +1 -1 +1 -1 +1 -1 +1 -1 +1 -1 +2 -3 +2 -2 +2 -2 +6 -5 +33 -13 +1 -1 +5 -5 +2 -2 +2 -2 +2 -2 +1 -1 +5 -5 +7 -4 +1 -1
~ BUILD.txt ~ Makefile.in ~ VERSION ~ auto.def ~ autosetup/autosetup ~ autosetup/autosetup-config.guess ~ autosetup/autosetup-config.sub ~ autosetup/autosetup-find-tclsh ~ autosetup/cc.tcl ~ extsrc/shell.c ~ extsrc/sqlite3.c ~ extsrc/sqlite3.h ~ fossil.1 ~ skins/darkmode/css.txt ~ skins/default/css.txt ~ src/add.c ~ src/allrepo.c ~ src/attach.c ~ src/bisect.c ~ src/blob.c ~ src/branch.c ~ src/browse.c ~ src/builtin.c ~ src/chat.c ~ src/checkin.c ~ src/comformat.c ~ src/configure.c ~ src/db.c ~ src/default.css ~ src/default.css ~ src/delta.c ~ src/diff.c ~ src/diff.tcl ~ src/diffcmd.c ~ src/dispatch.c ~ src/doc.c ~ src/event.c ~ src/file.c ~ src/finfo.c ~ src/forum.c ~ src/fossil.diff.js ~ src/fossil.dom.js ~ src/fossil.page.chat.js ~ src/fossil.page.pikchrshowasm.js ~ src/fossil.pikchr.js ~ src/glob.c ~ src/http.c ~ src/http_ssl.c ~ src/http_transport.c ~ src/info.c ~ src/interwiki.c ~ src/login.c ~ src/main.c ~ src/main.mk ~ src/manifest.c ~ src/merge.c ~ src/merge.tcl ~ src/merge3.c ~ src/patch.c ~ src/path.c ~ src/pikchrshow.c ~ src/rebuild.c ~ src/rss.c ~ src/schema.c ~ src/search.c ~ src/setup.c ~ src/setupuser.c ~ src/sitemap.c ~ src/th_tcl.c ~ src/timeline.c ~ src/timeline.c ~ src/tkt.c ~ src/update.c ~ src/wiki.c ~ src/winfile.c ~ src/xfer.c ~ test/comment.test ~ test/glob.test ~ test/settings.test ~ test/tester.tcl ~ test/utf8-comment.txt ~ tools/makemake.tcl ~ tools/man_page_command_list.tcl ~ win/Makefile.mingw ~ win/Makefile.msc ~ www/aboutcgi.wiki ~ www/adding_code.wiki ~ www/alerts.md ~ www/antibot.wiki ~ www/backoffice.md ~ www/blame.wiki ~ www/bugtheory.wiki ~ www/build.wiki ~ www/caps/index.md ~ www/caps/ref.html ~ www/cgi.wiki ~ www/changes.wiki ~ www/chat.md ~ www/checkin_names.wiki ~ www/concepts.wiki ~ www/contribute.wiki ~ www/custom_ticket.wiki ~ www/embeddeddoc.wiki ~ www/env-opts.md ~ www/event.wiki ~ www/fileedit-page.md ~ www/fileformat.wiki ~ www/forum.wiki ~ www/fossil-is-not-relational.md ~ www/fossil-v-git.wiki ~ www/fossil_prompt.wiki ~ www/gitusers.md ~ www/glossary.md ~ www/grep.md ~ www/hashpolicy.wiki ~ www/hints.wiki ~ www/history.md ~ www/hooks.md ~ www/index.wiki ~ www/inout.wiki ~ www/interwiki.md ~ www/json-api/api-artifact.md ~ www/json-api/api-auth.md ~ www/json-api/api-checkout.md ~ www/json-api/api-finfo.md ~ www/json-api/api-query.md ~ www/json-api/api-tag.md ~ www/json-api/conventions.md ~ www/json-api/hacking.md ~ www/makefile.wiki ~ www/mdtest/test1.md ~ www/newrepo.wiki ~ www/password.wiki ~ www/patchcmd.md ~ www/pikchr.md ~ www/qandc.wiki ~ www/quickstart.wiki ~ www/rebaseharm.md ~ www/selfcheck.wiki ~ www/selfhost.wiki ~ www/server/debian/service.md ~ www/server/openbsd/fastcgi.md ~ www/server/windows/service.md ~ www/settings.wiki ~ www/shunning.wiki ~ www/stats.wiki ~ www/style.wiki ~ www/sync.wiki ~ www/tech_overview.wiki ~ www/th1.md ~ www/theory1.wiki ~ www/tickets.wiki ~ www/unvers.wiki ~ www/userlinks.wiki ~ www/webui.wiki ~ www/whyallinone.md ~ www/wikitheory.wiki
+1 -1
--- BUILD.txt
+++ BUILD.txt
@@ -42,11 +42,11 @@
4242
mkdir build
4343
cd build
4444
../configure
4545
make
4646
47
-This will now keep all generates files separate from the maintained
47
+This will now keep all generated files separate from the maintained
4848
source code.
4949
5050
--------------------------------------------------------------------------
5151
5252
Here are some notes on what is happening behind the scenes:
5353
--- BUILD.txt
+++ BUILD.txt
@@ -42,11 +42,11 @@
42 mkdir build
43 cd build
44 ../configure
45 make
46
47 This will now keep all generates files separate from the maintained
48 source code.
49
50 --------------------------------------------------------------------------
51
52 Here are some notes on what is happening behind the scenes:
53
--- BUILD.txt
+++ BUILD.txt
@@ -42,11 +42,11 @@
42 mkdir build
43 cd build
44 ../configure
45 make
46
47 This will now keep all generated files separate from the maintained
48 source code.
49
50 --------------------------------------------------------------------------
51
52 Here are some notes on what is happening behind the scenes:
53
+4 -1
--- Makefile.in
+++ Makefile.in
@@ -51,11 +51,11 @@
5151
BCCFLAGS = @CPPFLAGS@ $(CFLAGS)
5252
TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ $(CFLAGS) -DHAVE_AUTOCONFIG_H
5353
#
5454
# Fuzzing may be enable by appending -fsanitize=fuzzer -DFOSSIL_FUZZ
5555
# to the TCCFLAGS variable.
56
-# For more thorouth (but also slower) investigation
56
+# For more thorough (but also slower) investigation
5757
# -fsanitize=fuzzer,undefined,address
5858
# might be more useful.
5959
6060
INSTALLDIR = $(DESTDIR)@prefix@/bin
6161
USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
@@ -92,10 +92,13 @@
9292
MAKE_COMPILATION_DB = @MAKE_COMPILATION_DB@
9393
9494
.PHONY: all tags
9595
9696
include $(SRCDIR)/main.mk
97
+SQLITE_OPTIONS += @SQLITE_OPTIONS_EXT@
98
+SHELL_OPTIONS += @SQLITE_OPTIONS_EXT@
99
+# ^^^ must come after main.mk is included
97100
98101
distclean: clean
99102
-rm -f autoconfig.h config.log Makefile
100103
-rm -f cscope.out tags
101104
102105
--- Makefile.in
+++ Makefile.in
@@ -51,11 +51,11 @@
51 BCCFLAGS = @CPPFLAGS@ $(CFLAGS)
52 TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ $(CFLAGS) -DHAVE_AUTOCONFIG_H
53 #
54 # Fuzzing may be enable by appending -fsanitize=fuzzer -DFOSSIL_FUZZ
55 # to the TCCFLAGS variable.
56 # For more thorouth (but also slower) investigation
57 # -fsanitize=fuzzer,undefined,address
58 # might be more useful.
59
60 INSTALLDIR = $(DESTDIR)@prefix@/bin
61 USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
@@ -92,10 +92,13 @@
92 MAKE_COMPILATION_DB = @MAKE_COMPILATION_DB@
93
94 .PHONY: all tags
95
96 include $(SRCDIR)/main.mk
 
 
 
97
98 distclean: clean
99 -rm -f autoconfig.h config.log Makefile
100 -rm -f cscope.out tags
101
102
--- Makefile.in
+++ Makefile.in
@@ -51,11 +51,11 @@
51 BCCFLAGS = @CPPFLAGS@ $(CFLAGS)
52 TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ $(CFLAGS) -DHAVE_AUTOCONFIG_H
53 #
54 # Fuzzing may be enable by appending -fsanitize=fuzzer -DFOSSIL_FUZZ
55 # to the TCCFLAGS variable.
56 # For more thorough (but also slower) investigation
57 # -fsanitize=fuzzer,undefined,address
58 # might be more useful.
59
60 INSTALLDIR = $(DESTDIR)@prefix@/bin
61 USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
@@ -92,10 +92,13 @@
92 MAKE_COMPILATION_DB = @MAKE_COMPILATION_DB@
93
94 .PHONY: all tags
95
96 include $(SRCDIR)/main.mk
97 SQLITE_OPTIONS += @SQLITE_OPTIONS_EXT@
98 SHELL_OPTIONS += @SQLITE_OPTIONS_EXT@
99 # ^^^ must come after main.mk is included
100
101 distclean: clean
102 -rm -f autoconfig.h config.log Makefile
103 -rm -f cscope.out tags
104
105
+1 -1
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1
-2.25
1
+2.26
22
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 2.25
2
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 2.26
2
+7
--- auto.def
+++ auto.def
@@ -104,18 +104,21 @@
104104
msg-result "WARNING: tclsh $v found; need >= 8.6 for 'make test'."
105105
define TCLSH false ;# force "make test" failure via /usr/bin/false
106106
}
107107
}
108108
109
+define CFLAGS [get-env CFLAGS "-g -O2"]
109110
define EXTRA_CFLAGS "-Wall"
110111
define EXTRA_LDFLAGS ""
111112
define USE_SYSTEM_SQLITE 0
112113
define USE_LINENOISE 0
113114
define USE_MMAN_H 0
114115
define USE_SEE 0
115116
define SQLITE3_ORIGIN 0
116117
# SQLITE3_ORIGIN 0 = src/sqlite3, 1=src/sqlite3-see.c, 2=client-provided
118
+define SQLITE_OPTIONS_EXT ""
119
+# SQLITE_OPTIONS_EXT => build-dependent CFLAGS for sqlite3.c and shell.c
117120
118121
# Maintain the C89/C90-style order of variable declarations before statements.
119122
# Check if the compiler supports the respective warning flag.
120123
if {[cctest -cflags -Wdeclaration-after-statement]} {
121124
define-append EXTRA_CFLAGS -Wdeclaration-after-statement
@@ -401,10 +404,14 @@
401404
msg-result "Linked to zlib via default library path"
402405
} else {
403406
define-append EXTRA_LDFLAGS "$lcheck"
404407
msg-result "Linked to zlib via $lcheck"
405408
}
409
+ if {![check-function-in-lib compressBound z]} {
410
+ puts "Notice: disabling zlib compression in the SQL shell"
411
+ define-append SQLITE_OPTIONS_EXT {-USQLITE_HAVE_ZLIB}
412
+ }
406413
break
407414
}
408415
}
409416
set ::zlib_lib -lz
410417
}
411418
--- auto.def
+++ auto.def
@@ -104,18 +104,21 @@
104 msg-result "WARNING: tclsh $v found; need >= 8.6 for 'make test'."
105 define TCLSH false ;# force "make test" failure via /usr/bin/false
106 }
107 }
108
 
109 define EXTRA_CFLAGS "-Wall"
110 define EXTRA_LDFLAGS ""
111 define USE_SYSTEM_SQLITE 0
112 define USE_LINENOISE 0
113 define USE_MMAN_H 0
114 define USE_SEE 0
115 define SQLITE3_ORIGIN 0
116 # SQLITE3_ORIGIN 0 = src/sqlite3, 1=src/sqlite3-see.c, 2=client-provided
 
 
117
118 # Maintain the C89/C90-style order of variable declarations before statements.
119 # Check if the compiler supports the respective warning flag.
120 if {[cctest -cflags -Wdeclaration-after-statement]} {
121 define-append EXTRA_CFLAGS -Wdeclaration-after-statement
@@ -401,10 +404,14 @@
401 msg-result "Linked to zlib via default library path"
402 } else {
403 define-append EXTRA_LDFLAGS "$lcheck"
404 msg-result "Linked to zlib via $lcheck"
405 }
 
 
 
 
406 break
407 }
408 }
409 set ::zlib_lib -lz
410 }
411
--- auto.def
+++ auto.def
@@ -104,18 +104,21 @@
104 msg-result "WARNING: tclsh $v found; need >= 8.6 for 'make test'."
105 define TCLSH false ;# force "make test" failure via /usr/bin/false
106 }
107 }
108
109 define CFLAGS [get-env CFLAGS "-g -O2"]
110 define EXTRA_CFLAGS "-Wall"
111 define EXTRA_LDFLAGS ""
112 define USE_SYSTEM_SQLITE 0
113 define USE_LINENOISE 0
114 define USE_MMAN_H 0
115 define USE_SEE 0
116 define SQLITE3_ORIGIN 0
117 # SQLITE3_ORIGIN 0 = src/sqlite3, 1=src/sqlite3-see.c, 2=client-provided
118 define SQLITE_OPTIONS_EXT ""
119 # SQLITE_OPTIONS_EXT => build-dependent CFLAGS for sqlite3.c and shell.c
120
121 # Maintain the C89/C90-style order of variable declarations before statements.
122 # Check if the compiler supports the respective warning flag.
123 if {[cctest -cflags -Wdeclaration-after-statement]} {
124 define-append EXTRA_CFLAGS -Wdeclaration-after-statement
@@ -401,10 +404,14 @@
404 msg-result "Linked to zlib via default library path"
405 } else {
406 define-append EXTRA_LDFLAGS "$lcheck"
407 msg-result "Linked to zlib via $lcheck"
408 }
409 if {![check-function-in-lib compressBound z]} {
410 puts "Notice: disabling zlib compression in the SQL shell"
411 define-append SQLITE_OPTIONS_EXT {-USQLITE_HAVE_ZLIB}
412 }
413 break
414 }
415 }
416 set ::zlib_lib -lz
417 }
418
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -564,11 +564,14 @@
564564
set max [max $max [string length $opt]]
565565
}
566566
set indent [string repeat " " [expr {$max+4}]]
567567
set cols [getenv COLUMNS 80]
568568
catch {
569
- lassign [exec stty size] rows cols
569
+ lassign [exec stty size] _ sttycols
570
+ if {[string is integer -strict $sttycols]} {
571
+ set cols $sttycols
572
+ }
570573
}
571574
incr cols -1
572575
# Now output
573576
foreach help $::autosetup(optionhelp) {
574577
lassign $help opt module desc
@@ -908,12 +911,11 @@
908911
# @find-executable-path name
909912
#
910913
# Searches the path for an executable with the given name.
911914
# Note that the name may include some parameters, e.g. 'cc -mbig-endian',
912915
# in which case the parameters are ignored.
913
-# The full path to the executable if found, or "" if not found.
914
-# Returns 1 if found, or 0 if not.
916
+# Returns the full path to the executable if found, or "" if not found.
915917
#
916918
proc find-executable-path {name} {
917919
# Ignore any parameters
918920
set name [lindex $name 0]
919921
# The empty string is never a valid executable
920922
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -564,11 +564,14 @@
564 set max [max $max [string length $opt]]
565 }
566 set indent [string repeat " " [expr {$max+4}]]
567 set cols [getenv COLUMNS 80]
568 catch {
569 lassign [exec stty size] rows cols
 
 
 
570 }
571 incr cols -1
572 # Now output
573 foreach help $::autosetup(optionhelp) {
574 lassign $help opt module desc
@@ -908,12 +911,11 @@
908 # @find-executable-path name
909 #
910 # Searches the path for an executable with the given name.
911 # Note that the name may include some parameters, e.g. 'cc -mbig-endian',
912 # in which case the parameters are ignored.
913 # The full path to the executable if found, or "" if not found.
914 # Returns 1 if found, or 0 if not.
915 #
916 proc find-executable-path {name} {
917 # Ignore any parameters
918 set name [lindex $name 0]
919 # The empty string is never a valid executable
920
--- autosetup/autosetup
+++ autosetup/autosetup
@@ -564,11 +564,14 @@
564 set max [max $max [string length $opt]]
565 }
566 set indent [string repeat " " [expr {$max+4}]]
567 set cols [getenv COLUMNS 80]
568 catch {
569 lassign [exec stty size] _ sttycols
570 if {[string is integer -strict $sttycols]} {
571 set cols $sttycols
572 }
573 }
574 incr cols -1
575 # Now output
576 foreach help $::autosetup(optionhelp) {
577 lassign $help opt module desc
@@ -908,12 +911,11 @@
911 # @find-executable-path name
912 #
913 # Searches the path for an executable with the given name.
914 # Note that the name may include some parameters, e.g. 'cc -mbig-endian',
915 # in which case the parameters are ignored.
916 # Returns the full path to the executable if found, or "" if not found.
 
917 #
918 proc find-executable-path {name} {
919 # Ignore any parameters
920 set name [lindex $name 0]
921 # The empty string is never a valid executable
922
--- autosetup/autosetup-config.guess
+++ autosetup/autosetup-config.guess
@@ -1,16 +1,16 @@
11
#! /bin/sh
22
# Attempt to guess a canonical system name.
3
-# Copyright 1992-2021 Free Software Foundation, Inc.
3
+# Copyright 1992-2024 Free Software Foundation, Inc.
44
55
# shellcheck disable=SC2006,SC2268 # see below for rationale
66
7
-timestamp='2021-06-03'
7
+timestamp='2024-07-27'
88
99
# This file is free software; you can redistribute it and/or modify it
1010
# under the terms of the GNU General Public License as published by
11
-# the Free Software Foundation; either version 3 of the License, or
11
+# the Free Software Foundation, either version 3 of the License, or
1212
# (at your option) any later version.
1313
#
1414
# This program is distributed in the hope that it will be useful, but
1515
# WITHOUT ANY WARRANTY; without even the implied warranty of
1616
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -45,11 +45,11 @@
4545
me=`echo "$0" | sed -e 's,.*/,,'`
4646
4747
usage="\
4848
Usage: $0 [OPTION]
4949
50
-Output the configuration name of the system \`$me' is run on.
50
+Output the configuration name of the system '$me' is run on.
5151
5252
Options:
5353
-h, --help print this help, then exit
5454
-t, --time-stamp print date of last modification, then exit
5555
-v, --version print version number, then exit
@@ -58,17 +58,17 @@
5858
5959
version="\
6060
GNU config.guess ($timestamp)
6161
6262
Originally written by Per Bothner.
63
-Copyright 1992-2021 Free Software Foundation, Inc.
63
+Copyright 1992-2024 Free Software Foundation, Inc.
6464
6565
This is free software; see the source for copying conditions. There is NO
6666
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
6767
6868
help="
69
-Try \`$me --help' for more information."
69
+Try '$me --help' for more information."
7070
7171
# Parse command line
7272
while test $# -gt 0 ; do
7373
case $1 in
7474
--time-stamp | --time* | -t )
@@ -100,12 +100,12 @@
100100
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
101101
# compiler to aid in system detection is discouraged as it requires
102102
# temporary files to be created and, as you can see below, it is a
103103
# headache to deal with in a portable fashion.
104104
105
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
106
-# use `HOST_CC' if defined, but it is deprecated.
105
+# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
106
+# use 'HOST_CC' if defined, but it is deprecated.
107107
108108
# Portable tmp directory creation inspired by the Autoconf team.
109109
110110
tmp=
111111
# shellcheck disable=SC2172
@@ -121,11 +121,11 @@
121121
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
122122
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
123123
dummy=$tmp/dummy
124124
case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
125125
,,) echo "int x;" > "$dummy.c"
126
- for driver in cc gcc c89 c99 ; do
126
+ for driver in cc gcc c17 c99 c89 ; do
127127
if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
128128
CC_FOR_BUILD=$driver
129129
break
130130
fi
131131
done
@@ -153,22 +153,28 @@
153153
Linux|GNU|GNU/*)
154154
LIBC=unknown
155155
156156
set_cc_for_build
157157
cat <<-EOF > "$dummy.c"
158
+ #if defined(__ANDROID__)
159
+ LIBC=android
160
+ #else
158161
#include <features.h>
159162
#if defined(__UCLIBC__)
160163
LIBC=uclibc
161164
#elif defined(__dietlibc__)
162165
LIBC=dietlibc
163166
#elif defined(__GLIBC__)
164167
LIBC=gnu
168
+ #elif defined(__LLVM_LIBC__)
169
+ LIBC=llvm
165170
#else
166171
#include <stdarg.h>
167172
/* First heuristic to detect musl libc. */
168173
#ifdef __DEFINED_va_list
169174
LIBC=musl
175
+ #endif
170176
#endif
171177
#endif
172178
EOF
173179
cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
174180
eval "$cc_set_libc"
@@ -435,11 +441,11 @@
435441
# If there is a compiler, see if it is configured for 64-bit objects.
436442
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
437443
# This test works for both compilers.
438444
if test "$CC_FOR_BUILD" != no_compiler_found; then
439445
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
440
- (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
446
+ (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
441447
grep IS_64BIT_ARCH >/dev/null
442448
then
443449
SUN_ARCH=x86_64
444450
fi
445451
fi
@@ -457,11 +463,11 @@
457463
case `/usr/bin/arch -k` in
458464
Series*|S4*)
459465
UNAME_RELEASE=`uname -v`
460466
;;
461467
esac
462
- # Japanese Language versions have a version number like `4.1.3-JL'.
468
+ # Japanese Language versions have a version number like '4.1.3-JL'.
463469
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
464470
GUESS=sparc-sun-sunos$SUN_REL
465471
;;
466472
sun3*:SunOS:*:*)
467473
GUESS=m68k-sun-sunos$UNAME_RELEASE
@@ -626,11 +632,12 @@
626632
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
627633
set_cc_for_build
628634
sed 's/^ //' << EOF > "$dummy.c"
629635
#include <sys/systemcfg.h>
630636
631
- main()
637
+ int
638
+ main ()
632639
{
633640
if (!__power_pc())
634641
exit(1);
635642
puts("powerpc-ibm-aix3.2.5");
636643
exit(0);
@@ -710,11 +717,12 @@
710717
711718
#define _HPUX_SOURCE
712719
#include <stdlib.h>
713720
#include <unistd.h>
714721
715
- int main ()
722
+ int
723
+ main ()
716724
{
717725
#if defined(_SC_KERNEL_BITS)
718726
long bits = sysconf(_SC_KERNEL_BITS);
719727
#endif
720728
long cpu = sysconf (_SC_CPU_VERSION);
@@ -902,11 +910,11 @@
902910
FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
903911
GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
904912
fi
905913
;;
906914
*:FreeBSD:*:*)
907
- UNAME_PROCESSOR=`/usr/bin/uname -p`
915
+ UNAME_PROCESSOR=`uname -p`
908916
case $UNAME_PROCESSOR in
909917
amd64)
910918
UNAME_PROCESSOR=x86_64 ;;
911919
i386)
912920
UNAME_PROCESSOR=i586 ;;
@@ -927,10 +935,13 @@
927935
GUESS=$UNAME_MACHINE-pc-msys
928936
;;
929937
i*:PW*:*)
930938
GUESS=$UNAME_MACHINE-pc-pw32
931939
;;
940
+ *:SerenityOS:*:*)
941
+ GUESS=$UNAME_MACHINE-pc-serenity
942
+ ;;
932943
*:Interix*:*)
933944
case $UNAME_MACHINE in
934945
x86)
935946
GUESS=i586-pc-interix$UNAME_RELEASE
936947
;;
@@ -961,15 +972,41 @@
961972
# other systems with GNU libc and userland
962973
GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
963974
GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
964975
GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
965976
;;
977
+ x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
978
+ GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
979
+ ;;
980
+ *:[Mm]anagarm:*:*)
981
+ GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
982
+ ;;
966983
*:Minix:*:*)
967984
GUESS=$UNAME_MACHINE-unknown-minix
968985
;;
969986
aarch64:Linux:*:*)
970
- GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
987
+ set_cc_for_build
988
+ CPU=$UNAME_MACHINE
989
+ LIBCABI=$LIBC
990
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
991
+ ABI=64
992
+ sed 's/^ //' << EOF > "$dummy.c"
993
+ #ifdef __ARM_EABI__
994
+ #ifdef __ARM_PCS_VFP
995
+ ABI=eabihf
996
+ #else
997
+ ABI=eabi
998
+ #endif
999
+ #endif
1000
+EOF
1001
+ cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1002
+ eval "$cc_set_abi"
1003
+ case $ABI in
1004
+ eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
1005
+ esac
1006
+ fi
1007
+ GUESS=$CPU-unknown-linux-$LIBCABI
9711008
;;
9721009
aarch64_be:Linux:*:*)
9731010
UNAME_MACHINE=aarch64_be
9741011
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
9751012
;;
@@ -1031,11 +1068,20 @@
10311068
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10321069
;;
10331070
k1om:Linux:*:*)
10341071
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10351072
;;
1036
- loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
1073
+ kvx:Linux:*:*)
1074
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1075
+ ;;
1076
+ kvx:cos:*:*)
1077
+ GUESS=$UNAME_MACHINE-unknown-cos
1078
+ ;;
1079
+ kvx:mbr:*:*)
1080
+ GUESS=$UNAME_MACHINE-unknown-mbr
1081
+ ;;
1082
+ loongarch32:Linux:*:* | loongarch64:Linux:*:*)
10371083
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10381084
;;
10391085
m32r*:Linux:*:*)
10401086
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10411087
;;
@@ -1146,20 +1192,31 @@
11461192
vax:Linux:*:*)
11471193
GUESS=$UNAME_MACHINE-dec-linux-$LIBC
11481194
;;
11491195
x86_64:Linux:*:*)
11501196
set_cc_for_build
1197
+ CPU=$UNAME_MACHINE
11511198
LIBCABI=$LIBC
11521199
if test "$CC_FOR_BUILD" != no_compiler_found; then
1153
- if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
1154
- (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1155
- grep IS_X32 >/dev/null
1156
- then
1157
- LIBCABI=${LIBC}x32
1158
- fi
1159
- fi
1160
- GUESS=$UNAME_MACHINE-pc-linux-$LIBCABI
1200
+ ABI=64
1201
+ sed 's/^ //' << EOF > "$dummy.c"
1202
+ #ifdef __i386__
1203
+ ABI=x86
1204
+ #else
1205
+ #ifdef __ILP32__
1206
+ ABI=x32
1207
+ #endif
1208
+ #endif
1209
+EOF
1210
+ cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1211
+ eval "$cc_set_abi"
1212
+ case $ABI in
1213
+ x86) CPU=i686 ;;
1214
+ x32) LIBCABI=${LIBC}x32 ;;
1215
+ esac
1216
+ fi
1217
+ GUESS=$CPU-pc-linux-$LIBCABI
11611218
;;
11621219
xtensa*:Linux:*:*)
11631220
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11641221
;;
11651222
i*86:DYNIX/ptx:4*:*)
@@ -1175,11 +1232,11 @@
11751232
# I just have to hope. -- rms.
11761233
# Use sysv4.2uw... so that sysv4* matches it.
11771234
GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
11781235
;;
11791236
i*86:OS/2:*:*)
1180
- # If we were able to find `uname', then EMX Unix compatibility
1237
+ # If we were able to find 'uname', then EMX Unix compatibility
11811238
# is probably installed.
11821239
GUESS=$UNAME_MACHINE-pc-os2-emx
11831240
;;
11841241
i*86:XTS-300:*:STOP)
11851242
GUESS=$UNAME_MACHINE-unknown-stop
@@ -1316,11 +1373,11 @@
13161373
GUESS=$UNAME_MACHINE-sni-sysv4
13171374
else
13181375
GUESS=ns32k-sni-sysv
13191376
fi
13201377
;;
1321
- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1378
+ PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
13221379
# says <[email protected]>
13231380
GUESS=i586-unisys-sysv4
13241381
;;
13251382
*:UNIX_System_V:4*:FTX*)
13261383
# From Gerald Hewes <[email protected]>.
@@ -1362,12 +1419,15 @@
13621419
GUESS=i586-pc-beos
13631420
;;
13641421
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
13651422
GUESS=i586-pc-haiku
13661423
;;
1367
- x86_64:Haiku:*:*)
1368
- GUESS=x86_64-unknown-haiku
1424
+ ppc:Haiku:*:*) # Haiku running on Apple PowerPC
1425
+ GUESS=powerpc-apple-haiku
1426
+ ;;
1427
+ *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat)
1428
+ GUESS=$UNAME_MACHINE-unknown-haiku
13691429
;;
13701430
SX-4:SUPER-UX:*:*)
13711431
GUESS=sx4-nec-superux$UNAME_RELEASE
13721432
;;
13731433
SX-5:SUPER-UX:*:*)
@@ -1520,10 +1580,13 @@
15201580
GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
15211581
;;
15221582
i*86:rdos:*:*)
15231583
GUESS=$UNAME_MACHINE-pc-rdos
15241584
;;
1585
+ i*86:Fiwix:*:*)
1586
+ GUESS=$UNAME_MACHINE-pc-fiwix
1587
+ ;;
15251588
*:AROS:*:*)
15261589
GUESS=$UNAME_MACHINE-unknown-aros
15271590
;;
15281591
x86_64:VMkernel:*:*)
15291592
GUESS=$UNAME_MACHINE-unknown-esx
@@ -1532,10 +1595,13 @@
15321595
GUESS=x86_64-unknown-onefs
15331596
;;
15341597
*:Unleashed:*:*)
15351598
GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
15361599
;;
1600
+ *:Ironclad:*:*)
1601
+ GUESS=$UNAME_MACHINE-unknown-ironclad
1602
+ ;;
15371603
esac
15381604
15391605
# Do we have a guess based on uname results?
15401606
if test "x$GUESS" != x; then
15411607
echo "$GUESS"
@@ -1555,10 +1621,11 @@
15551621
#if defined(_SIZE_T_) || defined(SIGLOST)
15561622
#include <sys/utsname.h>
15571623
#endif
15581624
#endif
15591625
#endif
1626
+int
15601627
main ()
15611628
{
15621629
#if defined (sony)
15631630
#if defined (MIPSEB)
15641631
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
15651632
--- autosetup/autosetup-config.guess
+++ autosetup/autosetup-config.guess
@@ -1,16 +1,16 @@
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright 1992-2021 Free Software Foundation, Inc.
4
5 # shellcheck disable=SC2006,SC2268 # see below for rationale
6
7 timestamp='2021-06-03'
8
9 # This file is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -45,11 +45,11 @@
45 me=`echo "$0" | sed -e 's,.*/,,'`
46
47 usage="\
48 Usage: $0 [OPTION]
49
50 Output the configuration name of the system \`$me' is run on.
51
52 Options:
53 -h, --help print this help, then exit
54 -t, --time-stamp print date of last modification, then exit
55 -v, --version print version number, then exit
@@ -58,17 +58,17 @@
58
59 version="\
60 GNU config.guess ($timestamp)
61
62 Originally written by Per Bothner.
63 Copyright 1992-2021 Free Software Foundation, Inc.
64
65 This is free software; see the source for copying conditions. There is NO
66 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
67
68 help="
69 Try \`$me --help' for more information."
70
71 # Parse command line
72 while test $# -gt 0 ; do
73 case $1 in
74 --time-stamp | --time* | -t )
@@ -100,12 +100,12 @@
100 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
101 # compiler to aid in system detection is discouraged as it requires
102 # temporary files to be created and, as you can see below, it is a
103 # headache to deal with in a portable fashion.
104
105 # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
106 # use `HOST_CC' if defined, but it is deprecated.
107
108 # Portable tmp directory creation inspired by the Autoconf team.
109
110 tmp=
111 # shellcheck disable=SC2172
@@ -121,11 +121,11 @@
121 { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
122 { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
123 dummy=$tmp/dummy
124 case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
125 ,,) echo "int x;" > "$dummy.c"
126 for driver in cc gcc c89 c99 ; do
127 if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
128 CC_FOR_BUILD=$driver
129 break
130 fi
131 done
@@ -153,22 +153,28 @@
153 Linux|GNU|GNU/*)
154 LIBC=unknown
155
156 set_cc_for_build
157 cat <<-EOF > "$dummy.c"
 
 
 
158 #include <features.h>
159 #if defined(__UCLIBC__)
160 LIBC=uclibc
161 #elif defined(__dietlibc__)
162 LIBC=dietlibc
163 #elif defined(__GLIBC__)
164 LIBC=gnu
 
 
165 #else
166 #include <stdarg.h>
167 /* First heuristic to detect musl libc. */
168 #ifdef __DEFINED_va_list
169 LIBC=musl
 
170 #endif
171 #endif
172 EOF
173 cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
174 eval "$cc_set_libc"
@@ -435,11 +441,11 @@
435 # If there is a compiler, see if it is configured for 64-bit objects.
436 # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
437 # This test works for both compilers.
438 if test "$CC_FOR_BUILD" != no_compiler_found; then
439 if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
440 (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
441 grep IS_64BIT_ARCH >/dev/null
442 then
443 SUN_ARCH=x86_64
444 fi
445 fi
@@ -457,11 +463,11 @@
457 case `/usr/bin/arch -k` in
458 Series*|S4*)
459 UNAME_RELEASE=`uname -v`
460 ;;
461 esac
462 # Japanese Language versions have a version number like `4.1.3-JL'.
463 SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
464 GUESS=sparc-sun-sunos$SUN_REL
465 ;;
466 sun3*:SunOS:*:*)
467 GUESS=m68k-sun-sunos$UNAME_RELEASE
@@ -626,11 +632,12 @@
626 if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
627 set_cc_for_build
628 sed 's/^ //' << EOF > "$dummy.c"
629 #include <sys/systemcfg.h>
630
631 main()
 
632 {
633 if (!__power_pc())
634 exit(1);
635 puts("powerpc-ibm-aix3.2.5");
636 exit(0);
@@ -710,11 +717,12 @@
710
711 #define _HPUX_SOURCE
712 #include <stdlib.h>
713 #include <unistd.h>
714
715 int main ()
 
716 {
717 #if defined(_SC_KERNEL_BITS)
718 long bits = sysconf(_SC_KERNEL_BITS);
719 #endif
720 long cpu = sysconf (_SC_CPU_VERSION);
@@ -902,11 +910,11 @@
902 FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
903 GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
904 fi
905 ;;
906 *:FreeBSD:*:*)
907 UNAME_PROCESSOR=`/usr/bin/uname -p`
908 case $UNAME_PROCESSOR in
909 amd64)
910 UNAME_PROCESSOR=x86_64 ;;
911 i386)
912 UNAME_PROCESSOR=i586 ;;
@@ -927,10 +935,13 @@
927 GUESS=$UNAME_MACHINE-pc-msys
928 ;;
929 i*:PW*:*)
930 GUESS=$UNAME_MACHINE-pc-pw32
931 ;;
 
 
 
932 *:Interix*:*)
933 case $UNAME_MACHINE in
934 x86)
935 GUESS=i586-pc-interix$UNAME_RELEASE
936 ;;
@@ -961,15 +972,41 @@
961 # other systems with GNU libc and userland
962 GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
963 GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
964 GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
965 ;;
 
 
 
 
 
 
966 *:Minix:*:*)
967 GUESS=$UNAME_MACHINE-unknown-minix
968 ;;
969 aarch64:Linux:*:*)
970 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
971 ;;
972 aarch64_be:Linux:*:*)
973 UNAME_MACHINE=aarch64_be
974 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
975 ;;
@@ -1031,11 +1068,20 @@
1031 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1032 ;;
1033 k1om:Linux:*:*)
1034 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1035 ;;
1036 loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
 
 
 
 
 
 
 
 
 
1037 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1038 ;;
1039 m32r*:Linux:*:*)
1040 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1041 ;;
@@ -1146,20 +1192,31 @@
1146 vax:Linux:*:*)
1147 GUESS=$UNAME_MACHINE-dec-linux-$LIBC
1148 ;;
1149 x86_64:Linux:*:*)
1150 set_cc_for_build
 
1151 LIBCABI=$LIBC
1152 if test "$CC_FOR_BUILD" != no_compiler_found; then
1153 if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
1154 (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1155 grep IS_X32 >/dev/null
1156 then
1157 LIBCABI=${LIBC}x32
1158 fi
1159 fi
1160 GUESS=$UNAME_MACHINE-pc-linux-$LIBCABI
 
 
 
 
 
 
 
 
 
 
1161 ;;
1162 xtensa*:Linux:*:*)
1163 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1164 ;;
1165 i*86:DYNIX/ptx:4*:*)
@@ -1175,11 +1232,11 @@
1175 # I just have to hope. -- rms.
1176 # Use sysv4.2uw... so that sysv4* matches it.
1177 GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
1178 ;;
1179 i*86:OS/2:*:*)
1180 # If we were able to find `uname', then EMX Unix compatibility
1181 # is probably installed.
1182 GUESS=$UNAME_MACHINE-pc-os2-emx
1183 ;;
1184 i*86:XTS-300:*:STOP)
1185 GUESS=$UNAME_MACHINE-unknown-stop
@@ -1316,11 +1373,11 @@
1316 GUESS=$UNAME_MACHINE-sni-sysv4
1317 else
1318 GUESS=ns32k-sni-sysv
1319 fi
1320 ;;
1321 PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1322 # says <[email protected]>
1323 GUESS=i586-unisys-sysv4
1324 ;;
1325 *:UNIX_System_V:4*:FTX*)
1326 # From Gerald Hewes <[email protected]>.
@@ -1362,12 +1419,15 @@
1362 GUESS=i586-pc-beos
1363 ;;
1364 BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
1365 GUESS=i586-pc-haiku
1366 ;;
1367 x86_64:Haiku:*:*)
1368 GUESS=x86_64-unknown-haiku
 
 
 
1369 ;;
1370 SX-4:SUPER-UX:*:*)
1371 GUESS=sx4-nec-superux$UNAME_RELEASE
1372 ;;
1373 SX-5:SUPER-UX:*:*)
@@ -1520,10 +1580,13 @@
1520 GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
1521 ;;
1522 i*86:rdos:*:*)
1523 GUESS=$UNAME_MACHINE-pc-rdos
1524 ;;
 
 
 
1525 *:AROS:*:*)
1526 GUESS=$UNAME_MACHINE-unknown-aros
1527 ;;
1528 x86_64:VMkernel:*:*)
1529 GUESS=$UNAME_MACHINE-unknown-esx
@@ -1532,10 +1595,13 @@
1532 GUESS=x86_64-unknown-onefs
1533 ;;
1534 *:Unleashed:*:*)
1535 GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
1536 ;;
 
 
 
1537 esac
1538
1539 # Do we have a guess based on uname results?
1540 if test "x$GUESS" != x; then
1541 echo "$GUESS"
@@ -1555,10 +1621,11 @@
1555 #if defined(_SIZE_T_) || defined(SIGLOST)
1556 #include <sys/utsname.h>
1557 #endif
1558 #endif
1559 #endif
 
1560 main ()
1561 {
1562 #if defined (sony)
1563 #if defined (MIPSEB)
1564 /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
1565
--- autosetup/autosetup-config.guess
+++ autosetup/autosetup-config.guess
@@ -1,16 +1,16 @@
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright 1992-2024 Free Software Foundation, Inc.
4
5 # shellcheck disable=SC2006,SC2268 # see below for rationale
6
7 timestamp='2024-07-27'
8
9 # This file is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -45,11 +45,11 @@
45 me=`echo "$0" | sed -e 's,.*/,,'`
46
47 usage="\
48 Usage: $0 [OPTION]
49
50 Output the configuration name of the system '$me' is run on.
51
52 Options:
53 -h, --help print this help, then exit
54 -t, --time-stamp print date of last modification, then exit
55 -v, --version print version number, then exit
@@ -58,17 +58,17 @@
58
59 version="\
60 GNU config.guess ($timestamp)
61
62 Originally written by Per Bothner.
63 Copyright 1992-2024 Free Software Foundation, Inc.
64
65 This is free software; see the source for copying conditions. There is NO
66 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
67
68 help="
69 Try '$me --help' for more information."
70
71 # Parse command line
72 while test $# -gt 0 ; do
73 case $1 in
74 --time-stamp | --time* | -t )
@@ -100,12 +100,12 @@
100 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
101 # compiler to aid in system detection is discouraged as it requires
102 # temporary files to be created and, as you can see below, it is a
103 # headache to deal with in a portable fashion.
104
105 # Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
106 # use 'HOST_CC' if defined, but it is deprecated.
107
108 # Portable tmp directory creation inspired by the Autoconf team.
109
110 tmp=
111 # shellcheck disable=SC2172
@@ -121,11 +121,11 @@
121 { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
122 { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
123 dummy=$tmp/dummy
124 case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
125 ,,) echo "int x;" > "$dummy.c"
126 for driver in cc gcc c17 c99 c89 ; do
127 if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
128 CC_FOR_BUILD=$driver
129 break
130 fi
131 done
@@ -153,22 +153,28 @@
153 Linux|GNU|GNU/*)
154 LIBC=unknown
155
156 set_cc_for_build
157 cat <<-EOF > "$dummy.c"
158 #if defined(__ANDROID__)
159 LIBC=android
160 #else
161 #include <features.h>
162 #if defined(__UCLIBC__)
163 LIBC=uclibc
164 #elif defined(__dietlibc__)
165 LIBC=dietlibc
166 #elif defined(__GLIBC__)
167 LIBC=gnu
168 #elif defined(__LLVM_LIBC__)
169 LIBC=llvm
170 #else
171 #include <stdarg.h>
172 /* First heuristic to detect musl libc. */
173 #ifdef __DEFINED_va_list
174 LIBC=musl
175 #endif
176 #endif
177 #endif
178 EOF
179 cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
180 eval "$cc_set_libc"
@@ -435,11 +441,11 @@
441 # If there is a compiler, see if it is configured for 64-bit objects.
442 # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
443 # This test works for both compilers.
444 if test "$CC_FOR_BUILD" != no_compiler_found; then
445 if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
446 (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
447 grep IS_64BIT_ARCH >/dev/null
448 then
449 SUN_ARCH=x86_64
450 fi
451 fi
@@ -457,11 +463,11 @@
463 case `/usr/bin/arch -k` in
464 Series*|S4*)
465 UNAME_RELEASE=`uname -v`
466 ;;
467 esac
468 # Japanese Language versions have a version number like '4.1.3-JL'.
469 SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
470 GUESS=sparc-sun-sunos$SUN_REL
471 ;;
472 sun3*:SunOS:*:*)
473 GUESS=m68k-sun-sunos$UNAME_RELEASE
@@ -626,11 +632,12 @@
632 if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
633 set_cc_for_build
634 sed 's/^ //' << EOF > "$dummy.c"
635 #include <sys/systemcfg.h>
636
637 int
638 main ()
639 {
640 if (!__power_pc())
641 exit(1);
642 puts("powerpc-ibm-aix3.2.5");
643 exit(0);
@@ -710,11 +717,12 @@
717
718 #define _HPUX_SOURCE
719 #include <stdlib.h>
720 #include <unistd.h>
721
722 int
723 main ()
724 {
725 #if defined(_SC_KERNEL_BITS)
726 long bits = sysconf(_SC_KERNEL_BITS);
727 #endif
728 long cpu = sysconf (_SC_CPU_VERSION);
@@ -902,11 +910,11 @@
910 FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
911 GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
912 fi
913 ;;
914 *:FreeBSD:*:*)
915 UNAME_PROCESSOR=`uname -p`
916 case $UNAME_PROCESSOR in
917 amd64)
918 UNAME_PROCESSOR=x86_64 ;;
919 i386)
920 UNAME_PROCESSOR=i586 ;;
@@ -927,10 +935,13 @@
935 GUESS=$UNAME_MACHINE-pc-msys
936 ;;
937 i*:PW*:*)
938 GUESS=$UNAME_MACHINE-pc-pw32
939 ;;
940 *:SerenityOS:*:*)
941 GUESS=$UNAME_MACHINE-pc-serenity
942 ;;
943 *:Interix*:*)
944 case $UNAME_MACHINE in
945 x86)
946 GUESS=i586-pc-interix$UNAME_RELEASE
947 ;;
@@ -961,15 +972,41 @@
972 # other systems with GNU libc and userland
973 GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
974 GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
975 GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
976 ;;
977 x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
978 GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
979 ;;
980 *:[Mm]anagarm:*:*)
981 GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
982 ;;
983 *:Minix:*:*)
984 GUESS=$UNAME_MACHINE-unknown-minix
985 ;;
986 aarch64:Linux:*:*)
987 set_cc_for_build
988 CPU=$UNAME_MACHINE
989 LIBCABI=$LIBC
990 if test "$CC_FOR_BUILD" != no_compiler_found; then
991 ABI=64
992 sed 's/^ //' << EOF > "$dummy.c"
993 #ifdef __ARM_EABI__
994 #ifdef __ARM_PCS_VFP
995 ABI=eabihf
996 #else
997 ABI=eabi
998 #endif
999 #endif
1000 EOF
1001 cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1002 eval "$cc_set_abi"
1003 case $ABI in
1004 eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
1005 esac
1006 fi
1007 GUESS=$CPU-unknown-linux-$LIBCABI
1008 ;;
1009 aarch64_be:Linux:*:*)
1010 UNAME_MACHINE=aarch64_be
1011 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1012 ;;
@@ -1031,11 +1068,20 @@
1068 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1069 ;;
1070 k1om:Linux:*:*)
1071 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1072 ;;
1073 kvx:Linux:*:*)
1074 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1075 ;;
1076 kvx:cos:*:*)
1077 GUESS=$UNAME_MACHINE-unknown-cos
1078 ;;
1079 kvx:mbr:*:*)
1080 GUESS=$UNAME_MACHINE-unknown-mbr
1081 ;;
1082 loongarch32:Linux:*:* | loongarch64:Linux:*:*)
1083 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1084 ;;
1085 m32r*:Linux:*:*)
1086 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1087 ;;
@@ -1146,20 +1192,31 @@
1192 vax:Linux:*:*)
1193 GUESS=$UNAME_MACHINE-dec-linux-$LIBC
1194 ;;
1195 x86_64:Linux:*:*)
1196 set_cc_for_build
1197 CPU=$UNAME_MACHINE
1198 LIBCABI=$LIBC
1199 if test "$CC_FOR_BUILD" != no_compiler_found; then
1200 ABI=64
1201 sed 's/^ //' << EOF > "$dummy.c"
1202 #ifdef __i386__
1203 ABI=x86
1204 #else
1205 #ifdef __ILP32__
1206 ABI=x32
1207 #endif
1208 #endif
1209 EOF
1210 cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1211 eval "$cc_set_abi"
1212 case $ABI in
1213 x86) CPU=i686 ;;
1214 x32) LIBCABI=${LIBC}x32 ;;
1215 esac
1216 fi
1217 GUESS=$CPU-pc-linux-$LIBCABI
1218 ;;
1219 xtensa*:Linux:*:*)
1220 GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1221 ;;
1222 i*86:DYNIX/ptx:4*:*)
@@ -1175,11 +1232,11 @@
1232 # I just have to hope. -- rms.
1233 # Use sysv4.2uw... so that sysv4* matches it.
1234 GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
1235 ;;
1236 i*86:OS/2:*:*)
1237 # If we were able to find 'uname', then EMX Unix compatibility
1238 # is probably installed.
1239 GUESS=$UNAME_MACHINE-pc-os2-emx
1240 ;;
1241 i*86:XTS-300:*:STOP)
1242 GUESS=$UNAME_MACHINE-unknown-stop
@@ -1316,11 +1373,11 @@
1373 GUESS=$UNAME_MACHINE-sni-sysv4
1374 else
1375 GUESS=ns32k-sni-sysv
1376 fi
1377 ;;
1378 PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
1379 # says <[email protected]>
1380 GUESS=i586-unisys-sysv4
1381 ;;
1382 *:UNIX_System_V:4*:FTX*)
1383 # From Gerald Hewes <[email protected]>.
@@ -1362,12 +1419,15 @@
1419 GUESS=i586-pc-beos
1420 ;;
1421 BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
1422 GUESS=i586-pc-haiku
1423 ;;
1424 ppc:Haiku:*:*) # Haiku running on Apple PowerPC
1425 GUESS=powerpc-apple-haiku
1426 ;;
1427 *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat)
1428 GUESS=$UNAME_MACHINE-unknown-haiku
1429 ;;
1430 SX-4:SUPER-UX:*:*)
1431 GUESS=sx4-nec-superux$UNAME_RELEASE
1432 ;;
1433 SX-5:SUPER-UX:*:*)
@@ -1520,10 +1580,13 @@
1580 GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
1581 ;;
1582 i*86:rdos:*:*)
1583 GUESS=$UNAME_MACHINE-pc-rdos
1584 ;;
1585 i*86:Fiwix:*:*)
1586 GUESS=$UNAME_MACHINE-pc-fiwix
1587 ;;
1588 *:AROS:*:*)
1589 GUESS=$UNAME_MACHINE-unknown-aros
1590 ;;
1591 x86_64:VMkernel:*:*)
1592 GUESS=$UNAME_MACHINE-unknown-esx
@@ -1532,10 +1595,13 @@
1595 GUESS=x86_64-unknown-onefs
1596 ;;
1597 *:Unleashed:*:*)
1598 GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
1599 ;;
1600 *:Ironclad:*:*)
1601 GUESS=$UNAME_MACHINE-unknown-ironclad
1602 ;;
1603 esac
1604
1605 # Do we have a guess based on uname results?
1606 if test "x$GUESS" != x; then
1607 echo "$GUESS"
@@ -1555,10 +1621,11 @@
1621 #if defined(_SIZE_T_) || defined(SIGLOST)
1622 #include <sys/utsname.h>
1623 #endif
1624 #endif
1625 #endif
1626 int
1627 main ()
1628 {
1629 #if defined (sony)
1630 #if defined (MIPSEB)
1631 /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
1632
--- autosetup/autosetup-config.sub
+++ autosetup/autosetup-config.sub
@@ -1,16 +1,16 @@
11
#! /bin/sh
22
# Configuration validation subroutine script.
3
-# Copyright 1992-2021 Free Software Foundation, Inc.
3
+# Copyright 1992-2024 Free Software Foundation, Inc.
44
5
-# shellcheck disable=SC2006,SC2268 # see below for rationale
5
+# shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale
66
7
-timestamp='2021-07-03'
7
+timestamp='2024-05-27'
88
99
# This file is free software; you can redistribute it and/or modify it
1010
# under the terms of the GNU General Public License as published by
11
-# the Free Software Foundation; either version 3 of the License, or
11
+# the Free Software Foundation, either version 3 of the License, or
1212
# (at your option) any later version.
1313
#
1414
# This program is distributed in the hope that it will be useful, but
1515
# WITHOUT ANY WARRANTY; without even the implied warranty of
1616
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -74,17 +74,17 @@
7474
Report bugs and patches to <[email protected]>."
7575
7676
version="\
7777
GNU config.sub ($timestamp)
7878
79
-Copyright 1992-2021 Free Software Foundation, Inc.
79
+Copyright 1992-2024 Free Software Foundation, Inc.
8080
8181
This is free software; see the source for copying conditions. There is NO
8282
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
8383
8484
help="
85
-Try \`$me --help' for more information."
85
+Try '$me --help' for more information."
8686
8787
# Parse command line
8888
while test $# -gt 0 ; do
8989
case $1 in
9090
--time-stamp | --time* | -t )
@@ -118,19 +118,20 @@
118118
*) echo "$me: too many arguments$help" >&2
119119
exit 1;;
120120
esac
121121
122122
# Split fields of configuration type
123
-# shellcheck disable=SC2162
123
+saved_IFS=$IFS
124124
IFS="-" read field1 field2 field3 field4 <<EOF
125125
$1
126126
EOF
127
+IFS=$saved_IFS
127128
128129
# Separate into logical components for further validation
129130
case $1 in
130131
*-*-*-*-*)
131
- echo Invalid configuration \`"$1"\': more than four components >&2
132
+ echo "Invalid configuration '$1': more than four components" >&2
132133
exit 1
133134
;;
134135
*-*-*-*)
135136
basic_machine=$field1-$field2
136137
basic_os=$field3-$field4
@@ -138,14 +139,25 @@
138139
*-*-*)
139140
# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
140141
# parts
141142
maybe_os=$field2-$field3
142143
case $maybe_os in
143
- nto-qnx* | linux-* | uclinux-uclibc* \
144
- | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
145
- | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
146
- | storm-chaos* | os2-emx* | rtmk-nova*)
144
+ cloudabi*-eabi* \
145
+ | kfreebsd*-gnu* \
146
+ | knetbsd*-gnu* \
147
+ | kopensolaris*-gnu* \
148
+ | linux-* \
149
+ | managarm-* \
150
+ | netbsd*-eabi* \
151
+ | netbsd*-gnu* \
152
+ | nto-qnx* \
153
+ | os2-emx* \
154
+ | rtmk-nova* \
155
+ | storm-chaos* \
156
+ | uclinux-gnu* \
157
+ | uclinux-uclibc* \
158
+ | windows-* )
147159
basic_machine=$field1
148160
basic_os=$maybe_os
149161
;;
150162
android-linux)
151163
basic_machine=$field1-unknown
@@ -156,37 +168,105 @@
156168
basic_os=$field3
157169
;;
158170
esac
159171
;;
160172
*-*)
161
- # A lone config we happen to match not fitting any pattern
162173
case $field1-$field2 in
174
+ # Shorthands that happen to contain a single dash
175
+ convex-c[12] | convex-c3[248])
176
+ basic_machine=$field2-convex
177
+ basic_os=
178
+ ;;
163179
decstation-3100)
164180
basic_machine=mips-dec
165181
basic_os=
166182
;;
167183
*-*)
168184
# Second component is usually, but not always the OS
169185
case $field2 in
170
- # Prevent following clause from handling this valid os
186
+ # Do not treat sunos as a manufacturer
171187
sun*os*)
172188
basic_machine=$field1
173189
basic_os=$field2
174190
;;
175191
# Manufacturers
176
- dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
177
- | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
178
- | unicom* | ibm* | next | hp | isi* | apollo | altos* \
179
- | convergent* | ncr* | news | 32* | 3600* | 3100* \
180
- | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
181
- | ultra | tti* | harris | dolphin | highlevel | gould \
182
- | cbm | ns | masscomp | apple | axis | knuth | cray \
183
- | microblaze* | sim | cisco \
184
- | oki | wec | wrs | winbond)
192
+ 3100* \
193
+ | 32* \
194
+ | 3300* \
195
+ | 3600* \
196
+ | 7300* \
197
+ | acorn \
198
+ | altos* \
199
+ | apollo \
200
+ | apple \
201
+ | atari \
202
+ | att* \
203
+ | axis \
204
+ | be \
205
+ | bull \
206
+ | cbm \
207
+ | ccur \
208
+ | cisco \
209
+ | commodore \
210
+ | convergent* \
211
+ | convex* \
212
+ | cray \
213
+ | crds \
214
+ | dec* \
215
+ | delta* \
216
+ | dg \
217
+ | digital \
218
+ | dolphin \
219
+ | encore* \
220
+ | gould \
221
+ | harris \
222
+ | highlevel \
223
+ | hitachi* \
224
+ | hp \
225
+ | ibm* \
226
+ | intergraph \
227
+ | isi* \
228
+ | knuth \
229
+ | masscomp \
230
+ | microblaze* \
231
+ | mips* \
232
+ | motorola* \
233
+ | ncr* \
234
+ | news \
235
+ | next \
236
+ | ns \
237
+ | oki \
238
+ | omron* \
239
+ | pc533* \
240
+ | rebel \
241
+ | rom68k \
242
+ | rombug \
243
+ | semi \
244
+ | sequent* \
245
+ | siemens \
246
+ | sgi* \
247
+ | siemens \
248
+ | sim \
249
+ | sni \
250
+ | sony* \
251
+ | stratus \
252
+ | sun \
253
+ | sun[234]* \
254
+ | tektronix \
255
+ | tti* \
256
+ | ultra \
257
+ | unicom* \
258
+ | wec \
259
+ | winbond \
260
+ | wrs)
185261
basic_machine=$field1-$field2
186262
basic_os=
187263
;;
264
+ zephyr*)
265
+ basic_machine=$field1-unknown
266
+ basic_os=$field2
267
+ ;;
188268
*)
189269
basic_machine=$field1
190270
basic_os=$field2
191271
;;
192272
esac
@@ -263,30 +343,10 @@
263343
;;
264344
cegcc)
265345
basic_machine=arm-unknown
266346
basic_os=cegcc
267347
;;
268
- convex-c1)
269
- basic_machine=c1-convex
270
- basic_os=bsd
271
- ;;
272
- convex-c2)
273
- basic_machine=c2-convex
274
- basic_os=bsd
275
- ;;
276
- convex-c32)
277
- basic_machine=c32-convex
278
- basic_os=bsd
279
- ;;
280
- convex-c34)
281
- basic_machine=c34-convex
282
- basic_os=bsd
283
- ;;
284
- convex-c38)
285
- basic_machine=c38-convex
286
- basic_os=bsd
287
- ;;
288348
cray)
289349
basic_machine=j90-cray
290350
basic_os=unicos
291351
;;
292352
crds | unos)
@@ -705,13 +765,21 @@
705765
decsystem20* | dec20*)
706766
cpu=pdp10
707767
vendor=dec
708768
basic_os=tops20
709769
;;
710
- delta | 3300 | motorola-3300 | motorola-delta \
711
- | 3300-motorola | delta-motorola)
770
+ delta | 3300 | delta-motorola | 3300-motorola | motorola-delta | motorola-3300)
712771
cpu=m68k
713772
vendor=motorola
714773
;;
715
- dpx2*)
774
+ # This used to be dpx2*, but that gets the RS6000-based
775
+ # DPX/20 and the x86-based DPX/2-100 wrong. See
776
+ # https://oldskool.silicium.org/stations/bull_dpx20.htm
777
+ # https://www.feb-patrimoine.com/english/bull_dpx2.htm
778
+ # https://www.feb-patrimoine.com/english/unix_and_bull.htm
779
+ dpx2 | dpx2[23]00 | dpx2[23]xx)
716780
cpu=m68k
717781
vendor=bull
782
+ ;;
783
+ dpx2100 | dpx21xx)
784
+ cpu=i386
785
+ vendor=bull
@@ -718,6 +786,9 @@
718
- basic_os=sysv3
786
+ ;;
787
+ dpx20)
788
+ cpu=rs6000
789
+ vendor=bull
719790
;;
720791
encore | umax | mmax)
721792
cpu=ns32k
722793
vendor=encore
723794
;;
@@ -828,22 +899,10 @@
828899
basic_os=newsos
829900
;;
830901
next | m*-next)
831902
cpu=m68k
832903
vendor=next
833
- case $basic_os in
834
- openstep*)
835
- ;;
836
- nextstep*)
837
- ;;
838
- ns2*)
839
- basic_os=nextstep2
840
- ;;
841
- *)
842
- basic_os=nextstep3
843
- ;;
844
- esac
845904
;;
846905
np1)
847906
cpu=np1
848907
vendor=gould
849908
;;
@@ -928,16 +987,17 @@
928987
cpu=sparc
929988
vendor=`echo "$basic_machine" | sed 's/-.*//'`
930989
;;
931990
932991
*-*)
933
- # shellcheck disable=SC2162
992
+ saved_IFS=$IFS
934993
IFS="-" read cpu vendor <<EOF
935994
$basic_machine
936995
EOF
996
+ IFS=$saved_IFS
937997
;;
938
- # We use `pc' rather than `unknown'
998
+ # We use 'pc' rather than 'unknown'
939999
# because (1) that's what they normally are, and
9401000
# (2) the word "unknown" tends to confuse beginning users.
9411001
i*86 | x86_64)
9421002
cpu=$basic_machine
9431003
vendor=pc
@@ -961,19 +1021,23 @@
9611021
9621022
unset -v basic_machine
9631023
9641024
# Decode basic machines in the full and proper CPU-Company form.
9651025
case $cpu-$vendor in
966
- # Here we handle the default manufacturer of certain CPU types in canonical form. It is in
967
- # some cases the only manufacturer, in others, it is the most popular.
1026
+ # Here we handle the default manufacturer of certain CPU types in canonical form.
1027
+ # It is in some cases the only manufacturer, in others, it is the most popular.
1028
+ c[12]-convex | c[12]-unknown | c3[248]-convex | c3[248]-unknown)
1029
+ vendor=convex
1030
+ basic_os=${basic_os:-bsd}
1031
+ ;;
9681032
craynv-unknown)
9691033
vendor=cray
9701034
basic_os=${basic_os:-unicosmp}
9711035
;;
9721036
c90-unknown | c90-cray)
9731037
vendor=cray
974
- basic_os=${Basic_os:-unicos}
1038
+ basic_os=${basic_os:-unicos}
9751039
;;
9761040
fx80-unknown)
9771041
vendor=alliant
9781042
;;
9791043
romp-unknown)
@@ -1010,23 +1074,46 @@
10101074
cpu=xps100
10111075
vendor=honeywell
10121076
;;
10131077
10141078
# Here we normalize CPU types with a missing or matching vendor
1015
- dpx20-unknown | dpx20-bull)
1016
- cpu=rs6000
1017
- vendor=bull
1079
+ armh-unknown | armh-alt)
1080
+ cpu=armv7l
1081
+ vendor=alt
1082
+ basic_os=${basic_os:-linux-gnueabihf}
1083
+ ;;
1084
+
1085
+ # Normalized CPU+vendor pairs that imply an OS, if not otherwise specified
1086
+ m68k-isi)
1087
+ basic_os=${basic_os:-sysv}
1088
+ ;;
1089
+ m68k-sony)
1090
+ basic_os=${basic_os:-newsos}
1091
+ ;;
1092
+ m68k-tektronix)
1093
+ basic_os=${basic_os:-bsd}
1094
+ ;;
1095
+ m88k-harris)
1096
+ basic_os=${basic_os:-sysv3}
1097
+ ;;
1098
+ i386-bull | m68k-bull)
1099
+ basic_os=${basic_os:-sysv3}
1100
+ ;;
1101
+ rs6000-bull)
10181102
basic_os=${basic_os:-bosx}
10191103
;;
1104
+ mips-sni)
1105
+ basic_os=${basic_os:-sysv4}
1106
+ ;;
10201107
10211108
# Here we normalize CPU types irrespective of the vendor
10221109
amd64-*)
10231110
cpu=x86_64
10241111
;;
10251112
blackfin-*)
10261113
cpu=bfin
1027
- basic_os=linux
1114
+ basic_os=${basic_os:-linux}
10281115
;;
10291116
c54x-*)
10301117
cpu=tic54x
10311118
;;
10321119
c55x-*)
@@ -1045,37 +1132,34 @@
10451132
ms1-*)
10461133
cpu=mt
10471134
;;
10481135
m68knommu-*)
10491136
cpu=m68k
1050
- basic_os=linux
1137
+ basic_os=${basic_os:-linux}
10511138
;;
10521139
m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
10531140
cpu=s12z
10541141
;;
10551142
openrisc-*)
10561143
cpu=or32
10571144
;;
10581145
parisc-*)
10591146
cpu=hppa
1060
- basic_os=linux
1147
+ basic_os=${basic_os:-linux}
10611148
;;
10621149
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
10631150
cpu=i586
10641151
;;
1065
- pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
1152
+ pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
10661153
cpu=i686
10671154
;;
10681155
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
10691156
cpu=i686
10701157
;;
10711158
pentium4-*)
10721159
cpu=i786
10731160
;;
1074
- pc98-*)
1075
- cpu=i386
1076
- ;;
10771161
ppc-* | ppcbe-*)
10781162
cpu=powerpc
10791163
;;
10801164
ppcle-* | powerpclittle-*)
10811165
cpu=powerpcle
@@ -1105,17 +1189,14 @@
11051189
cpu=mipstx39
11061190
;;
11071191
tx39el-*)
11081192
cpu=mipstx39el
11091193
;;
1110
- x64-*)
1111
- cpu=x86_64
1112
- ;;
11131194
xscale-* | xscalee[bl]-*)
11141195
cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
11151196
;;
1116
- arm64-*)
1197
+ arm64-* | aarch64le-*)
11171198
cpu=aarch64
11181199
;;
11191200
11201201
# Recognize the canonical CPU Types that limit and/or modify the
11211202
# company names they are paired with.
@@ -1163,118 +1244,235 @@
11631244
11641245
*)
11651246
# Recognize the canonical CPU types that are allowed with any
11661247
# company name.
11671248
case $cpu in
1168
- 1750a | 580 \
1249
+ 1750a \
1250
+ | 580 \
1251
+ | [cjt]90 \
11691252
| a29k \
1170
- | aarch64 | aarch64_be \
1253
+ | aarch64 \
1254
+ | aarch64_be \
1255
+ | aarch64c \
11711256
| abacus \
1172
- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1173
- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1174
- | alphapca5[67] | alpha64pca5[67] \
1257
+ | alpha \
1258
+ | alpha64 \
1259
+ | alpha64ev56 \
1260
+ | alpha64ev6[78] \
1261
+ | alpha64ev[4-8] \
1262
+ | alpha64pca5[67] \
1263
+ | alphaev56 \
1264
+ | alphaev6[78] \
1265
+ | alphaev[4-8] \
1266
+ | alphapca5[67] \
11751267
| am33_2.0 \
11761268
| amdgcn \
1177
- | arc | arceb | arc32 | arc64 \
1178
- | arm | arm[lb]e | arme[lb] | armv* \
1179
- | avr | avr32 \
1269
+ | arc \
1270
+ | arc32 \
1271
+ | arc64 \
1272
+ | arceb \
1273
+ | arm \
1274
+ | arm64e \
1275
+ | arm64ec \
1276
+ | arm[lb]e \
1277
+ | arme[lb] \
1278
+ | armv* \
11801279
| asmjs \
1280
+ | avr \
1281
+ | avr32 \
11811282
| ba \
1182
- | be32 | be64 \
1183
- | bfin | bpf | bs2000 \
1184
- | c[123]* | c30 | [cjt]90 | c4x \
1185
- | c8051 | clipper | craynv | csky | cydra \
1186
- | d10v | d30v | dlx | dsp16xx \
1187
- | e2k | elxsi | epiphany \
1188
- | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
1189
- | h8300 | h8500 \
1190
- | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
1283
+ | be32 \
1284
+ | be64 \
1285
+ | bfin \
1286
+ | bpf \
1287
+ | bs2000 \
1288
+ | c30 \
1289
+ | c4x \
1290
+ | c8051 \
1291
+ | c[123]* \
1292
+ | clipper \
1293
+ | craynv \
1294
+ | csky \
1295
+ | cydra \
1296
+ | d10v \
1297
+ | d30v \
1298
+ | dlx \
1299
+ | dsp16xx \
1300
+ | e2k \
1301
+ | elxsi \
1302
+ | epiphany \
1303
+ | f30[01] \
1304
+ | f700 \
1305
+ | fido \
1306
+ | fr30 \
1307
+ | frv \
1308
+ | ft32 \
1309
+ | fx80 \
1310
+ | h8300 \
1311
+ | h8500 \
11911312
| hexagon \
1192
- | i370 | i*86 | i860 | i960 | ia16 | ia64 \
1193
- | ip2k | iq2000 \
1313
+ | hppa \
1314
+ | hppa1.[01] \
1315
+ | hppa2.0 \
1316
+ | hppa2.0[nw] \
1317
+ | hppa64 \
1318
+ | i*86 \
1319
+ | i370 \
1320
+ | i860 \
1321
+ | i960 \
1322
+ | ia16 \
1323
+ | ia64 \
1324
+ | ip2k \
1325
+ | iq2000 \
1326
+ | javascript \
11941327
| k1om \
1195
- | le32 | le64 \
1328
+ | kvx \
1329
+ | le32 \
1330
+ | le64 \
11961331
| lm32 \
1197
- | loongarch32 | loongarch64 | loongarchx32 \
1198
- | m32c | m32r | m32rle \
1199
- | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1200
- | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1201
- | m88110 | m88k | maxq | mb | mcore | mep | metag \
1202
- | microblaze | microblazeel \
1203
- | mips | mipsbe | mipseb | mipsel | mipsle \
1204
- | mips16 \
1205
- | mips64 | mips64eb | mips64el \
1206
- | mips64octeon | mips64octeonel \
1207
- | mips64orion | mips64orionel \
1208
- | mips64r5900 | mips64r5900el \
1209
- | mips64vr | mips64vrel \
1210
- | mips64vr4100 | mips64vr4100el \
1211
- | mips64vr4300 | mips64vr4300el \
1212
- | mips64vr5000 | mips64vr5000el \
1213
- | mips64vr5900 | mips64vr5900el \
1214
- | mipsisa32 | mipsisa32el \
1215
- | mipsisa32r2 | mipsisa32r2el \
1216
- | mipsisa32r3 | mipsisa32r3el \
1217
- | mipsisa32r5 | mipsisa32r5el \
1218
- | mipsisa32r6 | mipsisa32r6el \
1219
- | mipsisa64 | mipsisa64el \
1220
- | mipsisa64r2 | mipsisa64r2el \
1221
- | mipsisa64r3 | mipsisa64r3el \
1222
- | mipsisa64r5 | mipsisa64r5el \
1223
- | mipsisa64r6 | mipsisa64r6el \
1224
- | mipsisa64sb1 | mipsisa64sb1el \
1225
- | mipsisa64sr71k | mipsisa64sr71kel \
1226
- | mipsr5900 | mipsr5900el \
1227
- | mipstx39 | mipstx39el \
1332
+ | loongarch32 \
1333
+ | loongarch64 \
1334
+ | m32c \
1335
+ | m32r \
1336
+ | m32rle \
1337
+ | m5200 \
1338
+ | m68000 \
1339
+ | m680[012346]0 \
1340
+ | m6811 \
1341
+ | m6812 \
1342
+ | m68360 \
1343
+ | m683?2 \
1344
+ | m68hc11 \
1345
+ | m68hc12 \
1346
+ | m68hcs12x \
1347
+ | m68k \
1348
+ | m88110 \
1349
+ | m88k \
1350
+ | maxq \
1351
+ | mb \
1352
+ | mcore \
1353
+ | mep \
1354
+ | metag \
1355
+ | microblaze \
1356
+ | microblazeel \
1357
+ | mips* \
12281358
| mmix \
1229
- | mn10200 | mn10300 \
1359
+ | mn10200 \
1360
+ | mn10300 \
12301361
| moxie \
1231
- | mt \
12321362
| msp430 \
1233
- | nds32 | nds32le | nds32be \
1363
+ | mt \
1364
+ | nanomips* \
1365
+ | nds32 \
1366
+ | nds32be \
1367
+ | nds32le \
12341368
| nfp \
1235
- | nios | nios2 | nios2eb | nios2el \
1236
- | none | np1 | ns16k | ns32k | nvptx \
1369
+ | nios \
1370
+ | nios2 \
1371
+ | nios2eb \
1372
+ | nios2el \
1373
+ | none \
1374
+ | np1 \
1375
+ | ns16k \
1376
+ | ns32k \
1377
+ | nvptx \
12371378
| open8 \
12381379
| or1k* \
12391380
| or32 \
12401381
| orion \
1382
+ | pdp10 \
1383
+ | pdp11 \
12411384
| picochip \
1242
- | pdp10 | pdp11 | pj | pjl | pn | power \
1243
- | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
1385
+ | pj \
1386
+ | pjl \
1387
+ | pn \
1388
+ | power \
1389
+ | powerpc \
1390
+ | powerpc64 \
1391
+ | powerpc64le \
1392
+ | powerpcle \
1393
+ | powerpcspe \
12441394
| pru \
12451395
| pyramid \
1246
- | riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1247
- | rl78 | romp | rs6000 | rx \
1248
- | s390 | s390x \
1396
+ | riscv \
1397
+ | riscv32 \
1398
+ | riscv32be \
1399
+ | riscv64 \
1400
+ | riscv64be \
1401
+ | rl78 \
1402
+ | romp \
1403
+ | rs6000 \
1404
+ | rx \
1405
+ | s390 \
1406
+ | s390x \
12491407
| score \
1250
- | sh | shl \
1251
- | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1252
- | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1253
- | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
1408
+ | sh \
1409
+ | sh64 \
1410
+ | sh64le \
1411
+ | sh[12345][lb]e \
1412
+ | sh[1234] \
1413
+ | sh[1234]e[lb] \
1414
+ | sh[23]e \
1415
+ | sh[23]ele \
1416
+ | sh[24]a \
1417
+ | sh[24]ae[lb] \
1418
+ | sh[lb]e \
1419
+ | she[lb] \
1420
+ | shl \
1421
+ | sparc \
1422
+ | sparc64 \
1423
+ | sparc64b \
1424
+ | sparc64v \
1425
+ | sparc86x \
1426
+ | sparclet \
12541427
| sparclite \
1255
- | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
1428
+ | sparcv8 \
1429
+ | sparcv9 \
1430
+ | sparcv9b \
1431
+ | sparcv9v \
12561432
| spu \
1433
+ | sv1 \
1434
+ | sx* \
12571435
| tahoe \
12581436
| thumbv7* \
1259
- | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
1437
+ | tic30 \
1438
+ | tic4x \
1439
+ | tic54x \
1440
+ | tic55x \
1441
+ | tic6x \
1442
+ | tic80 \
12601443
| tron \
12611444
| ubicom32 \
1262
- | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
1445
+ | v70 \
1446
+ | v810 \
1447
+ | v850 \
1448
+ | v850e \
1449
+ | v850e1 \
1450
+ | v850e2 \
1451
+ | v850e2v3 \
1452
+ | v850es \
12631453
| vax \
1454
+ | vc4 \
12641455
| visium \
12651456
| w65 \
1266
- | wasm32 | wasm64 \
1457
+ | wasm32 \
1458
+ | wasm64 \
12671459
| we32k \
1268
- | x86 | x86_64 | xc16x | xgate | xps100 \
1269
- | xstormy16 | xtensa* \
1460
+ | x86 \
1461
+ | x86_64 \
1462
+ | xc16x \
1463
+ | xgate \
1464
+ | xps100 \
1465
+ | xstormy16 \
1466
+ | xtensa* \
12701467
| ymp \
1271
- | z8k | z80)
1468
+ | z80 \
1469
+ | z8k)
12721470
;;
12731471
12741472
*)
1275
- echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
1473
+ echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
12761474
exit 1
12771475
;;
12781476
esac
12791477
;;
12801478
esac
@@ -1291,15 +1489,16 @@
12911489
;;
12921490
esac
12931491
12941492
# Decode manufacturer-specific aliases for certain operating systems.
12951493
1296
-if test x$basic_os != x
1494
+if test x"$basic_os" != x
12971495
then
12981496
1299
-# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just
1497
+# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
13001498
# set os.
1499
+obj=
13011500
case $basic_os in
13021501
gnu/linux*)
13031502
kernel=linux
13041503
os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
13051504
;;
@@ -1310,14 +1509,15 @@
13101509
nto-qnx*)
13111510
kernel=nto
13121511
os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
13131512
;;
13141513
*-*)
1315
- # shellcheck disable=SC2162
1514
+ saved_IFS=$IFS
13161515
IFS="-" read kernel os <<EOF
13171516
$basic_os
13181517
EOF
1518
+ IFS=$saved_IFS
13191519
;;
13201520
# Default OS when just kernel was specified
13211521
nto*)
13221522
kernel=nto
13231523
os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
@@ -1324,10 +1524,14 @@
13241524
;;
13251525
linux*)
13261526
kernel=linux
13271527
os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
13281528
;;
1529
+ managarm*)
1530
+ kernel=managarm
1531
+ os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
1532
+ ;;
13291533
*)
13301534
kernel=
13311535
os=$basic_os
13321536
;;
13331537
esac
@@ -1350,10 +1554,27 @@
13501554
solaris)
13511555
os=solaris2
13521556
;;
13531557
unixware*)
13541558
os=sysv4.2uw
1559
+ ;;
1560
+ # The marketing names for NeXT's operating systems were
1561
+ # NeXTSTEP, NeXTSTEP 2, OpenSTEP 3, OpenSTEP 4. 'openstep' is
1562
+ # mapped to 'openstep3', but 'openstep1' and 'openstep2' are
1563
+ # mapped to 'nextstep' and 'nextstep2', consistent with the
1564
+ # treatment of SunOS/Solaris.
1565
+ ns | ns1 | nextstep | nextstep1 | openstep1)
1566
+ os=nextstep
1567
+ ;;
1568
+ ns2 | nextstep2 | openstep2)
1569
+ os=nextstep2
1570
+ ;;
1571
+ ns3 | nextstep3 | openstep | openstep3)
1572
+ os=openstep3
1573
+ ;;
1574
+ ns4 | nextstep4 | openstep4)
1575
+ os=openstep4
13551576
;;
13561577
# es1800 is here to avoid being matched by es* (a different OS)
13571578
es1800*)
13581579
os=ose
13591580
;;
@@ -1421,10 +1642,11 @@
14211642
wince*)
14221643
os=wince
14231644
;;
14241645
utek*)
14251646
os=bsd
1647
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|tektronix|'`
14261648
;;
14271649
dynix*)
14281650
os=bsd
14291651
;;
14301652
acis*)
@@ -1437,25 +1659,29 @@
14371659
os=syllable
14381660
;;
14391661
386bsd)
14401662
os=bsd
14411663
;;
1442
- ctix* | uts*)
1664
+ ctix*)
1665
+ os=sysv
1666
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|convergent|'`
1667
+ ;;
1668
+ uts*)
14431669
os=sysv
14441670
;;
14451671
nova*)
1446
- os=rtmk-nova
1447
- ;;
1448
- ns2)
1449
- os=nextstep2
1672
+ kernel=rtmk
1673
+ os=nova
14501674
;;
14511675
# Preserve the version number of sinix5.
14521676
sinix5.*)
14531677
os=`echo "$os" | sed -e 's|sinix|sysv|'`
1678
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
14541679
;;
14551680
sinix*)
14561681
os=sysv4
1682
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
14571683
;;
14581684
tpf*)
14591685
os=tpf
14601686
;;
14611687
triton*)
@@ -1489,13 +1715,19 @@
14891715
case $cpu in
14901716
arm*)
14911717
os=eabi
14921718
;;
14931719
*)
1494
- os=elf
1720
+ os=
1721
+ obj=elf
14951722
;;
14961723
esac
1724
+ ;;
1725
+ aout* | coff* | elf* | pe*)
1726
+ # These are machine code file formats, not OSes
1727
+ obj=$os
1728
+ os=
14971729
;;
14981730
*)
14991731
# No normalization, but not necessarily accepted, that comes below.
15001732
;;
15011733
esac
@@ -1511,47 +1743,57 @@
15111743
# that MANUFACTURER isn't an operating system. Otherwise, code above
15121744
# will signal an error saying that MANUFACTURER isn't an operating
15131745
# system, and we'll never get to this point.
15141746
15151747
kernel=
1748
+obj=
15161749
case $cpu-$vendor in
15171750
score-*)
1518
- os=elf
1751
+ os=
1752
+ obj=elf
15191753
;;
15201754
spu-*)
1521
- os=elf
1755
+ os=
1756
+ obj=elf
15221757
;;
15231758
*-acorn)
15241759
os=riscix1.2
15251760
;;
15261761
arm*-rebel)
15271762
kernel=linux
15281763
os=gnu
15291764
;;
15301765
arm*-semi)
1531
- os=aout
1766
+ os=
1767
+ obj=aout
15321768
;;
15331769
c4x-* | tic4x-*)
1534
- os=coff
1770
+ os=
1771
+ obj=coff
15351772
;;
15361773
c8051-*)
1537
- os=elf
1774
+ os=
1775
+ obj=elf
15381776
;;
15391777
clipper-intergraph)
15401778
os=clix
15411779
;;
15421780
hexagon-*)
1543
- os=elf
1781
+ os=
1782
+ obj=elf
15441783
;;
15451784
tic54x-*)
1546
- os=coff
1785
+ os=
1786
+ obj=coff
15471787
;;
15481788
tic55x-*)
1549
- os=coff
1789
+ os=
1790
+ obj=coff
15501791
;;
15511792
tic6x-*)
1552
- os=coff
1793
+ os=
1794
+ obj=coff
15531795
;;
15541796
# This must come before the *-dec entry.
15551797
pdp10-*)
15561798
os=tops20
15571799
;;
@@ -1569,32 +1811,47 @@
15691811
;;
15701812
m68000-sun)
15711813
os=sunos3
15721814
;;
15731815
m68*-cisco)
1574
- os=aout
1816
+ os=
1817
+ obj=aout
15751818
;;
15761819
mep-*)
1577
- os=elf
1820
+ os=
1821
+ obj=elf
1822
+ ;;
1823
+ # The -sgi and -siemens entries must be before the mips- entry
1824
+ # or we get the wrong os.
1825
+ *-sgi)
1826
+ os=irix
1827
+ ;;
1828
+ *-siemens)
1829
+ os=sysv4
15781830
;;
15791831
mips*-cisco)
1580
- os=elf
1832
+ os=
1833
+ obj=elf
15811834
;;
1582
- mips*-*)
1583
- os=elf
1835
+ mips*-*|nanomips*-*)
1836
+ os=
1837
+ obj=elf
15841838
;;
15851839
or32-*)
1586
- os=coff
1840
+ os=
1841
+ obj=coff
15871842
;;
1588
- *-tti) # must be before sparc entry or we get the wrong os.
1843
+ # This must be before the sparc-* entry or we get the wrong os.
1844
+ *-tti)
15891845
os=sysv3
15901846
;;
15911847
sparc-* | *-sun)
15921848
os=sunos4.1.1
15931849
;;
15941850
pru-*)
1595
- os=elf
1851
+ os=
1852
+ obj=elf
15961853
;;
15971854
*-be)
15981855
os=beos
15991856
;;
16001857
*-ibm)
@@ -1614,11 +1871,11 @@
16141871
;;
16151872
*-hp)
16161873
os=hpux
16171874
;;
16181875
*-hitachi)
1619
- os=hiux
1876
+ os=hiuxwe2
16201877
;;
16211878
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
16221879
os=sysv
16231880
;;
16241881
*-cbm)
@@ -1658,27 +1915,23 @@
16581915
os=bsd
16591916
;;
16601917
*-encore)
16611918
os=bsd
16621919
;;
1663
- *-sgi)
1664
- os=irix
1665
- ;;
1666
- *-siemens)
1667
- os=sysv4
1668
- ;;
16691920
*-masscomp)
16701921
os=rtu
16711922
;;
16721923
f30[01]-fujitsu | f700-fujitsu)
16731924
os=uxpv
16741925
;;
16751926
*-rom68k)
1676
- os=coff
1927
+ os=
1928
+ obj=coff
16771929
;;
16781930
*-*bug)
1679
- os=coff
1931
+ os=
1932
+ obj=coff
16801933
;;
16811934
*-apple)
16821935
os=macos
16831936
;;
16841937
*-atari*)
@@ -1692,96 +1945,324 @@
16921945
;;
16931946
esac
16941947
16951948
fi
16961949
1697
-# Now, validate our (potentially fixed-up) OS.
1950
+# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
1951
+
16981952
case $os in
16991953
# Sometimes we do "kernel-libc", so those need to count as OSes.
1700
- musl* | newlib* | uclibc*)
1954
+ llvm* | musl* | newlib* | relibc* | uclibc*)
17011955
;;
17021956
# Likewise for "kernel-abi"
17031957
eabi* | gnueabi*)
17041958
;;
17051959
# VxWorks passes extra cpu info in the 4th filed.
17061960
simlinux | simwindows | spe)
1961
+ ;;
1962
+ # See `case $cpu-$os` validation below
1963
+ ghcjs)
17071964
;;
17081965
# Now accept the basic system types.
1709
- # The portable systems comes first.
17101966
# Each alternative MUST end in a * to match a version number.
1711
- gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1712
- | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1713
- | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1714
- | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \
1715
- | hiux* | abug | nacl* | netware* | windows* \
1716
- | os9* | macos* | osx* | ios* \
1717
- | mpw* | magic* | mmixware* | mon960* | lnews* \
1718
- | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1719
- | aos* | aros* | cloudabi* | sortix* | twizzler* \
1720
- | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1721
- | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1722
- | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1723
- | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1724
- | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
1725
- | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
1726
- | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
1727
- | udi* | lites* | ieee* | go32* | aux* | hcos* \
1728
- | chorusrdb* | cegcc* | glidix* | serenity* \
1729
- | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
1730
- | midipix* | mingw32* | mingw64* | mint* \
1731
- | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1732
- | interix* | uwin* | mks* | rhapsody* | darwin* \
1733
- | openstep* | oskit* | conix* | pw32* | nonstopux* \
1734
- | storm-chaos* | tops10* | tenex* | tops20* | its* \
1735
- | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1736
- | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1737
- | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1738
- | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1739
- | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1740
- | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1741
- | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*)
1967
+ abug \
1968
+ | aix* \
1969
+ | amdhsa* \
1970
+ | amigados* \
1971
+ | amigaos* \
1972
+ | android* \
1973
+ | aof* \
1974
+ | aos* \
1975
+ | aros* \
1976
+ | atheos* \
1977
+ | auroraux* \
1978
+ | aux* \
1979
+ | beos* \
1980
+ | bitrig* \
1981
+ | bme* \
1982
+ | bosx* \
1983
+ | bsd* \
1984
+ | cegcc* \
1985
+ | chorusos* \
1986
+ | chorusrdb* \
1987
+ | clix* \
1988
+ | cloudabi* \
1989
+ | cnk* \
1990
+ | conix* \
1991
+ | cos* \
1992
+ | cxux* \
1993
+ | cygwin* \
1994
+ | darwin* \
1995
+ | dgux* \
1996
+ | dicos* \
1997
+ | dnix* \
1998
+ | domain* \
1999
+ | dragonfly* \
2000
+ | drops* \
2001
+ | ebmon* \
2002
+ | ecoff* \
2003
+ | ekkobsd* \
2004
+ | emscripten* \
2005
+ | emx* \
2006
+ | es* \
2007
+ | fiwix* \
2008
+ | freebsd* \
2009
+ | fuchsia* \
2010
+ | genix* \
2011
+ | genode* \
2012
+ | glidix* \
2013
+ | gnu* \
2014
+ | go32* \
2015
+ | haiku* \
2016
+ | hcos* \
2017
+ | hiux* \
2018
+ | hms* \
2019
+ | hpux* \
2020
+ | ieee* \
2021
+ | interix* \
2022
+ | ios* \
2023
+ | iris* \
2024
+ | irix* \
2025
+ | ironclad* \
2026
+ | isc* \
2027
+ | its* \
2028
+ | l4re* \
2029
+ | libertybsd* \
2030
+ | lites* \
2031
+ | lnews* \
2032
+ | luna* \
2033
+ | lynxos* \
2034
+ | mach* \
2035
+ | macos* \
2036
+ | magic* \
2037
+ | mbr* \
2038
+ | midipix* \
2039
+ | midnightbsd* \
2040
+ | mingw32* \
2041
+ | mingw64* \
2042
+ | minix* \
2043
+ | mint* \
2044
+ | mirbsd* \
2045
+ | mks* \
2046
+ | mlibc* \
2047
+ | mmixware* \
2048
+ | mon960* \
2049
+ | morphos* \
2050
+ | moss* \
2051
+ | moxiebox* \
2052
+ | mpeix* \
2053
+ | mpw* \
2054
+ | msdos* \
2055
+ | msys* \
2056
+ | mvs* \
2057
+ | nacl* \
2058
+ | netbsd* \
2059
+ | netware* \
2060
+ | newsos* \
2061
+ | nextstep* \
2062
+ | nindy* \
2063
+ | nonstopux* \
2064
+ | nova* \
2065
+ | nsk* \
2066
+ | nucleus* \
2067
+ | nx6 \
2068
+ | nx7 \
2069
+ | oabi* \
2070
+ | ohos* \
2071
+ | onefs* \
2072
+ | openbsd* \
2073
+ | openedition* \
2074
+ | openstep* \
2075
+ | os108* \
2076
+ | os2* \
2077
+ | os400* \
2078
+ | os68k* \
2079
+ | os9* \
2080
+ | ose* \
2081
+ | osf* \
2082
+ | oskit* \
2083
+ | osx* \
2084
+ | palmos* \
2085
+ | phoenix* \
2086
+ | plan9* \
2087
+ | powermax* \
2088
+ | powerunix* \
2089
+ | proelf* \
2090
+ | psos* \
2091
+ | psp* \
2092
+ | ptx* \
2093
+ | pw32* \
2094
+ | qnx* \
2095
+ | rdos* \
2096
+ | redox* \
2097
+ | rhapsody* \
2098
+ | riscix* \
2099
+ | riscos* \
2100
+ | rtems* \
2101
+ | rtmk* \
2102
+ | rtu* \
2103
+ | scout* \
2104
+ | secbsd* \
2105
+ | sei* \
2106
+ | serenity* \
2107
+ | sim* \
2108
+ | skyos* \
2109
+ | solaris* \
2110
+ | solidbsd* \
2111
+ | sortix* \
2112
+ | storm-chaos* \
2113
+ | sunos \
2114
+ | sunos[34]* \
2115
+ | superux* \
2116
+ | syllable* \
2117
+ | sym* \
2118
+ | sysv* \
2119
+ | tenex* \
2120
+ | tirtos* \
2121
+ | toppers* \
2122
+ | tops10* \
2123
+ | tops20* \
2124
+ | tpf* \
2125
+ | tvos* \
2126
+ | twizzler* \
2127
+ | uclinux* \
2128
+ | udi* \
2129
+ | udk* \
2130
+ | ultrix* \
2131
+ | unicos* \
2132
+ | uniplus* \
2133
+ | unleashed* \
2134
+ | unos* \
2135
+ | uwin* \
2136
+ | uxpv* \
2137
+ | v88r* \
2138
+ |*vms* \
2139
+ | vos* \
2140
+ | vsta* \
2141
+ | vxsim* \
2142
+ | vxworks* \
2143
+ | wasi* \
2144
+ | watchos* \
2145
+ | wince* \
2146
+ | windiss* \
2147
+ | windows* \
2148
+ | winnt* \
2149
+ | xenix* \
2150
+ | xray* \
2151
+ | zephyr* \
2152
+ | zvmoe* )
17422153
;;
17432154
# This one is extra strict with allowed versions
17442155
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
17452156
# Don't forget version if it is 3.2v4 or newer.
17462157
;;
2158
+ # This refers to builds using the UEFI calling convention
2159
+ # (which depends on the architecture) and PE file format.
2160
+ # Note that this is both a different calling convention and
2161
+ # different file format than that of GNU-EFI
2162
+ # (x86_64-w64-mingw32).
2163
+ uefi)
2164
+ ;;
17472165
none)
17482166
;;
2167
+ kernel* | msvc* )
2168
+ # Restricted further below
2169
+ ;;
2170
+ '')
2171
+ if test x"$obj" = x
2172
+ then
2173
+ echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
2174
+ fi
2175
+ ;;
2176
+ *)
2177
+ echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
2178
+ exit 1
2179
+ ;;
2180
+esac
2181
+
2182
+case $obj in
2183
+ aout* | coff* | elf* | pe*)
2184
+ ;;
2185
+ '')
2186
+ # empty is fine
2187
+ ;;
17492188
*)
1750
- echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
2189
+ echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
2190
+ exit 1
2191
+ ;;
2192
+esac
2193
+
2194
+# Here we handle the constraint that a (synthetic) cpu and os are
2195
+# valid only in combination with each other and nowhere else.
2196
+case $cpu-$os in
2197
+ # The "javascript-unknown-ghcjs" triple is used by GHC; we
2198
+ # accept it here in order to tolerate that, but reject any
2199
+ # variations.
2200
+ javascript-ghcjs)
2201
+ ;;
2202
+ javascript-* | *-ghcjs)
2203
+ echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
17512204
exit 1
17522205
;;
17532206
esac
17542207
17552208
# As a final step for OS-related things, validate the OS-kernel combination
17562209
# (given a valid OS), if there is a kernel.
1757
-case $kernel-$os in
1758
- linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* )
2210
+case $kernel-$os-$obj in
2211
+ linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
2212
+ | linux-mlibc*- | linux-musl*- | linux-newlib*- \
2213
+ | linux-relibc*- | linux-uclibc*- | linux-ohos*- )
2214
+ ;;
2215
+ uclinux-uclibc*- | uclinux-gnu*- )
2216
+ ;;
2217
+ managarm-mlibc*- | managarm-kernel*- )
17592218
;;
1760
- uclinux-uclibc* )
2219
+ windows*-msvc*-)
17612220
;;
1762
- -dietlibc* | -newlib* | -musl* | -uclibc* )
2221
+ -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
2222
+ | -uclibc*- )
17632223
# These are just libc implementations, not actual OSes, and thus
17642224
# require a kernel.
1765
- echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
2225
+ echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
2226
+ exit 1
2227
+ ;;
2228
+ -kernel*- )
2229
+ echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
2230
+ exit 1
2231
+ ;;
2232
+ *-kernel*- )
2233
+ echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
2234
+ exit 1
2235
+ ;;
2236
+ *-msvc*- )
2237
+ echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
17662238
exit 1
17672239
;;
1768
- kfreebsd*-gnu* | kopensolaris*-gnu*)
1769
- ;;
1770
- vxworks-simlinux | vxworks-simwindows | vxworks-spe)
1771
- ;;
1772
- nto-qnx*)
1773
- ;;
1774
- os2-emx)
1775
- ;;
1776
- *-eabi* | *-gnueabi*)
1777
- ;;
1778
- -*)
2240
+ kfreebsd*-gnu*- | knetbsd*-gnu*- | netbsd*-gnu*- | kopensolaris*-gnu*-)
2241
+ ;;
2242
+ vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
2243
+ ;;
2244
+ nto-qnx*-)
2245
+ ;;
2246
+ os2-emx-)
2247
+ ;;
2248
+ rtmk-nova-)
2249
+ ;;
2250
+ *-eabi*- | *-gnueabi*-)
2251
+ ;;
2252
+ none--*)
2253
+ # None (no kernel, i.e. freestanding / bare metal),
2254
+ # can be paired with an machine code file format
2255
+ ;;
2256
+ -*-)
17792257
# Blank kernel with real OS is always fine.
17802258
;;
1781
- *-*)
1782
- echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
2259
+ --*)
2260
+ # Blank kernel and OS with real machine code file format is always fine.
2261
+ ;;
2262
+ *-*-*)
2263
+ echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
17832264
exit 1
17842265
;;
17852266
esac
17862267
17872268
# Here we handle the case where we know the os, and the CPU type, but not the
@@ -1790,11 +2271,11 @@
17902271
unknown)
17912272
case $cpu-$os in
17922273
*-riscix*)
17932274
vendor=acorn
17942275
;;
1795
- *-sunos*)
2276
+ *-sunos* | *-solaris*)
17962277
vendor=sun
17972278
;;
17982279
*-cnk* | *-aix*)
17992280
vendor=ibm
18002281
;;
@@ -1860,14 +2341,14 @@
18602341
;;
18612342
esac
18622343
;;
18632344
esac
18642345
1865
-echo "$cpu-$vendor-${kernel:+$kernel-}$os"
2346
+echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
18662347
exit
18672348
18682349
# Local variables:
18692350
# eval: (add-hook 'before-save-hook 'time-stamp)
18702351
# time-stamp-start: "timestamp='"
18712352
# time-stamp-format: "%:y-%02m-%02d"
18722353
# time-stamp-end: "'"
18732354
# End:
18742355
--- autosetup/autosetup-config.sub
+++ autosetup/autosetup-config.sub
@@ -1,16 +1,16 @@
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright 1992-2021 Free Software Foundation, Inc.
4
5 # shellcheck disable=SC2006,SC2268 # see below for rationale
6
7 timestamp='2021-07-03'
8
9 # This file is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -74,17 +74,17 @@
74 Report bugs and patches to <[email protected]>."
75
76 version="\
77 GNU config.sub ($timestamp)
78
79 Copyright 1992-2021 Free Software Foundation, Inc.
80
81 This is free software; see the source for copying conditions. There is NO
82 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83
84 help="
85 Try \`$me --help' for more information."
86
87 # Parse command line
88 while test $# -gt 0 ; do
89 case $1 in
90 --time-stamp | --time* | -t )
@@ -118,19 +118,20 @@
118 *) echo "$me: too many arguments$help" >&2
119 exit 1;;
120 esac
121
122 # Split fields of configuration type
123 # shellcheck disable=SC2162
124 IFS="-" read field1 field2 field3 field4 <<EOF
125 $1
126 EOF
 
127
128 # Separate into logical components for further validation
129 case $1 in
130 *-*-*-*-*)
131 echo Invalid configuration \`"$1"\': more than four components >&2
132 exit 1
133 ;;
134 *-*-*-*)
135 basic_machine=$field1-$field2
136 basic_os=$field3-$field4
@@ -138,14 +139,25 @@
138 *-*-*)
139 # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
140 # parts
141 maybe_os=$field2-$field3
142 case $maybe_os in
143 nto-qnx* | linux-* | uclinux-uclibc* \
144 | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
145 | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
146 | storm-chaos* | os2-emx* | rtmk-nova*)
 
 
 
 
 
 
 
 
 
 
 
147 basic_machine=$field1
148 basic_os=$maybe_os
149 ;;
150 android-linux)
151 basic_machine=$field1-unknown
@@ -156,37 +168,105 @@
156 basic_os=$field3
157 ;;
158 esac
159 ;;
160 *-*)
161 # A lone config we happen to match not fitting any pattern
162 case $field1-$field2 in
 
 
 
 
 
163 decstation-3100)
164 basic_machine=mips-dec
165 basic_os=
166 ;;
167 *-*)
168 # Second component is usually, but not always the OS
169 case $field2 in
170 # Prevent following clause from handling this valid os
171 sun*os*)
172 basic_machine=$field1
173 basic_os=$field2
174 ;;
175 # Manufacturers
176 dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
177 | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
178 | unicom* | ibm* | next | hp | isi* | apollo | altos* \
179 | convergent* | ncr* | news | 32* | 3600* | 3100* \
180 | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
181 | ultra | tti* | harris | dolphin | highlevel | gould \
182 | cbm | ns | masscomp | apple | axis | knuth | cray \
183 | microblaze* | sim | cisco \
184 | oki | wec | wrs | winbond)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185 basic_machine=$field1-$field2
186 basic_os=
187 ;;
 
 
 
 
188 *)
189 basic_machine=$field1
190 basic_os=$field2
191 ;;
192 esac
@@ -263,30 +343,10 @@
263 ;;
264 cegcc)
265 basic_machine=arm-unknown
266 basic_os=cegcc
267 ;;
268 convex-c1)
269 basic_machine=c1-convex
270 basic_os=bsd
271 ;;
272 convex-c2)
273 basic_machine=c2-convex
274 basic_os=bsd
275 ;;
276 convex-c32)
277 basic_machine=c32-convex
278 basic_os=bsd
279 ;;
280 convex-c34)
281 basic_machine=c34-convex
282 basic_os=bsd
283 ;;
284 convex-c38)
285 basic_machine=c38-convex
286 basic_os=bsd
287 ;;
288 cray)
289 basic_machine=j90-cray
290 basic_os=unicos
291 ;;
292 crds | unos)
@@ -705,13 +765,21 @@
705 decsystem20* | dec20*)
706 cpu=pdp10
707 vendor=dec
708 basic_os=tops20
709 ;;
710 delta | 3300 | motorola-3300 | motorola-delta \
711 | 3300-motorola | delta-motorola)
712 cpu=m68k
713 vendor=motorola
714 ;;
715 dpx2*)
 
 
 
 
 
716 cpu=m68k
717 vendor=bull
 
 
 
 
@@ -718,6 +786,9 @@
718 basic_os=sysv3
 
 
 
719 ;;
720 encore | umax | mmax)
721 cpu=ns32k
722 vendor=encore
723 ;;
@@ -828,22 +899,10 @@
828 basic_os=newsos
829 ;;
830 next | m*-next)
831 cpu=m68k
832 vendor=next
833 case $basic_os in
834 openstep*)
835 ;;
836 nextstep*)
837 ;;
838 ns2*)
839 basic_os=nextstep2
840 ;;
841 *)
842 basic_os=nextstep3
843 ;;
844 esac
845 ;;
846 np1)
847 cpu=np1
848 vendor=gould
849 ;;
@@ -928,16 +987,17 @@
928 cpu=sparc
929 vendor=`echo "$basic_machine" | sed 's/-.*//'`
930 ;;
931
932 *-*)
933 # shellcheck disable=SC2162
934 IFS="-" read cpu vendor <<EOF
935 $basic_machine
936 EOF
 
937 ;;
938 # We use `pc' rather than `unknown'
939 # because (1) that's what they normally are, and
940 # (2) the word "unknown" tends to confuse beginning users.
941 i*86 | x86_64)
942 cpu=$basic_machine
943 vendor=pc
@@ -961,19 +1021,23 @@
961
962 unset -v basic_machine
963
964 # Decode basic machines in the full and proper CPU-Company form.
965 case $cpu-$vendor in
966 # Here we handle the default manufacturer of certain CPU types in canonical form. It is in
967 # some cases the only manufacturer, in others, it is the most popular.
 
 
 
 
968 craynv-unknown)
969 vendor=cray
970 basic_os=${basic_os:-unicosmp}
971 ;;
972 c90-unknown | c90-cray)
973 vendor=cray
974 basic_os=${Basic_os:-unicos}
975 ;;
976 fx80-unknown)
977 vendor=alliant
978 ;;
979 romp-unknown)
@@ -1010,23 +1074,46 @@
1010 cpu=xps100
1011 vendor=honeywell
1012 ;;
1013
1014 # Here we normalize CPU types with a missing or matching vendor
1015 dpx20-unknown | dpx20-bull)
1016 cpu=rs6000
1017 vendor=bull
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1018 basic_os=${basic_os:-bosx}
1019 ;;
 
 
 
1020
1021 # Here we normalize CPU types irrespective of the vendor
1022 amd64-*)
1023 cpu=x86_64
1024 ;;
1025 blackfin-*)
1026 cpu=bfin
1027 basic_os=linux
1028 ;;
1029 c54x-*)
1030 cpu=tic54x
1031 ;;
1032 c55x-*)
@@ -1045,37 +1132,34 @@
1045 ms1-*)
1046 cpu=mt
1047 ;;
1048 m68knommu-*)
1049 cpu=m68k
1050 basic_os=linux
1051 ;;
1052 m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1053 cpu=s12z
1054 ;;
1055 openrisc-*)
1056 cpu=or32
1057 ;;
1058 parisc-*)
1059 cpu=hppa
1060 basic_os=linux
1061 ;;
1062 pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1063 cpu=i586
1064 ;;
1065 pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
1066 cpu=i686
1067 ;;
1068 pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1069 cpu=i686
1070 ;;
1071 pentium4-*)
1072 cpu=i786
1073 ;;
1074 pc98-*)
1075 cpu=i386
1076 ;;
1077 ppc-* | ppcbe-*)
1078 cpu=powerpc
1079 ;;
1080 ppcle-* | powerpclittle-*)
1081 cpu=powerpcle
@@ -1105,17 +1189,14 @@
1105 cpu=mipstx39
1106 ;;
1107 tx39el-*)
1108 cpu=mipstx39el
1109 ;;
1110 x64-*)
1111 cpu=x86_64
1112 ;;
1113 xscale-* | xscalee[bl]-*)
1114 cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1115 ;;
1116 arm64-*)
1117 cpu=aarch64
1118 ;;
1119
1120 # Recognize the canonical CPU Types that limit and/or modify the
1121 # company names they are paired with.
@@ -1163,118 +1244,235 @@
1163
1164 *)
1165 # Recognize the canonical CPU types that are allowed with any
1166 # company name.
1167 case $cpu in
1168 1750a | 580 \
 
 
1169 | a29k \
1170 | aarch64 | aarch64_be \
 
 
1171 | abacus \
1172 | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
1173 | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
1174 | alphapca5[67] | alpha64pca5[67] \
 
 
 
 
 
 
 
1175 | am33_2.0 \
1176 | amdgcn \
1177 | arc | arceb | arc32 | arc64 \
1178 | arm | arm[lb]e | arme[lb] | armv* \
1179 | avr | avr32 \
 
 
 
 
 
 
 
1180 | asmjs \
 
 
1181 | ba \
1182 | be32 | be64 \
1183 | bfin | bpf | bs2000 \
1184 | c[123]* | c30 | [cjt]90 | c4x \
1185 | c8051 | clipper | craynv | csky | cydra \
1186 | d10v | d30v | dlx | dsp16xx \
1187 | e2k | elxsi | epiphany \
1188 | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
1189 | h8300 | h8500 \
1190 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1191 | hexagon \
1192 | i370 | i*86 | i860 | i960 | ia16 | ia64 \
1193 | ip2k | iq2000 \
 
 
 
 
 
 
 
 
 
 
 
 
1194 | k1om \
1195 | le32 | le64 \
 
 
1196 | lm32 \
1197 | loongarch32 | loongarch64 | loongarchx32 \
1198 | m32c | m32r | m32rle \
1199 | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
1200 | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
1201 | m88110 | m88k | maxq | mb | mcore | mep | metag \
1202 | microblaze | microblazeel \
1203 | mips | mipsbe | mipseb | mipsel | mipsle \
1204 | mips16 \
1205 | mips64 | mips64eb | mips64el \
1206 | mips64octeon | mips64octeonel \
1207 | mips64orion | mips64orionel \
1208 | mips64r5900 | mips64r5900el \
1209 | mips64vr | mips64vrel \
1210 | mips64vr4100 | mips64vr4100el \
1211 | mips64vr4300 | mips64vr4300el \
1212 | mips64vr5000 | mips64vr5000el \
1213 | mips64vr5900 | mips64vr5900el \
1214 | mipsisa32 | mipsisa32el \
1215 | mipsisa32r2 | mipsisa32r2el \
1216 | mipsisa32r3 | mipsisa32r3el \
1217 | mipsisa32r5 | mipsisa32r5el \
1218 | mipsisa32r6 | mipsisa32r6el \
1219 | mipsisa64 | mipsisa64el \
1220 | mipsisa64r2 | mipsisa64r2el \
1221 | mipsisa64r3 | mipsisa64r3el \
1222 | mipsisa64r5 | mipsisa64r5el \
1223 | mipsisa64r6 | mipsisa64r6el \
1224 | mipsisa64sb1 | mipsisa64sb1el \
1225 | mipsisa64sr71k | mipsisa64sr71kel \
1226 | mipsr5900 | mipsr5900el \
1227 | mipstx39 | mipstx39el \
1228 | mmix \
1229 | mn10200 | mn10300 \
 
1230 | moxie \
1231 | mt \
1232 | msp430 \
1233 | nds32 | nds32le | nds32be \
 
 
 
 
1234 | nfp \
1235 | nios | nios2 | nios2eb | nios2el \
1236 | none | np1 | ns16k | ns32k | nvptx \
 
 
 
 
 
 
 
1237 | open8 \
1238 | or1k* \
1239 | or32 \
1240 | orion \
 
 
1241 | picochip \
1242 | pdp10 | pdp11 | pj | pjl | pn | power \
1243 | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
 
 
 
 
 
 
 
1244 | pru \
1245 | pyramid \
1246 | riscv | riscv32 | riscv32be | riscv64 | riscv64be \
1247 | rl78 | romp | rs6000 | rx \
1248 | s390 | s390x \
 
 
 
 
 
 
 
 
1249 | score \
1250 | sh | shl \
1251 | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
1252 | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
1253 | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1254 | sparclite \
1255 | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
 
 
 
1256 | spu \
 
 
1257 | tahoe \
1258 | thumbv7* \
1259 | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
 
 
 
 
 
1260 | tron \
1261 | ubicom32 \
1262 | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
 
 
 
 
 
 
 
1263 | vax \
 
1264 | visium \
1265 | w65 \
1266 | wasm32 | wasm64 \
 
1267 | we32k \
1268 | x86 | x86_64 | xc16x | xgate | xps100 \
1269 | xstormy16 | xtensa* \
 
 
 
 
 
1270 | ymp \
1271 | z8k | z80)
 
1272 ;;
1273
1274 *)
1275 echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
1276 exit 1
1277 ;;
1278 esac
1279 ;;
1280 esac
@@ -1291,15 +1489,16 @@
1291 ;;
1292 esac
1293
1294 # Decode manufacturer-specific aliases for certain operating systems.
1295
1296 if test x$basic_os != x
1297 then
1298
1299 # First recognize some ad-hoc caes, or perhaps split kernel-os, or else just
1300 # set os.
 
1301 case $basic_os in
1302 gnu/linux*)
1303 kernel=linux
1304 os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1305 ;;
@@ -1310,14 +1509,15 @@
1310 nto-qnx*)
1311 kernel=nto
1312 os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1313 ;;
1314 *-*)
1315 # shellcheck disable=SC2162
1316 IFS="-" read kernel os <<EOF
1317 $basic_os
1318 EOF
 
1319 ;;
1320 # Default OS when just kernel was specified
1321 nto*)
1322 kernel=nto
1323 os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
@@ -1324,10 +1524,14 @@
1324 ;;
1325 linux*)
1326 kernel=linux
1327 os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1328 ;;
 
 
 
 
1329 *)
1330 kernel=
1331 os=$basic_os
1332 ;;
1333 esac
@@ -1350,10 +1554,27 @@
1350 solaris)
1351 os=solaris2
1352 ;;
1353 unixware*)
1354 os=sysv4.2uw
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1355 ;;
1356 # es1800 is here to avoid being matched by es* (a different OS)
1357 es1800*)
1358 os=ose
1359 ;;
@@ -1421,10 +1642,11 @@
1421 wince*)
1422 os=wince
1423 ;;
1424 utek*)
1425 os=bsd
 
1426 ;;
1427 dynix*)
1428 os=bsd
1429 ;;
1430 acis*)
@@ -1437,25 +1659,29 @@
1437 os=syllable
1438 ;;
1439 386bsd)
1440 os=bsd
1441 ;;
1442 ctix* | uts*)
 
 
 
 
1443 os=sysv
1444 ;;
1445 nova*)
1446 os=rtmk-nova
1447 ;;
1448 ns2)
1449 os=nextstep2
1450 ;;
1451 # Preserve the version number of sinix5.
1452 sinix5.*)
1453 os=`echo "$os" | sed -e 's|sinix|sysv|'`
 
1454 ;;
1455 sinix*)
1456 os=sysv4
 
1457 ;;
1458 tpf*)
1459 os=tpf
1460 ;;
1461 triton*)
@@ -1489,13 +1715,19 @@
1489 case $cpu in
1490 arm*)
1491 os=eabi
1492 ;;
1493 *)
1494 os=elf
 
1495 ;;
1496 esac
 
 
 
 
 
1497 ;;
1498 *)
1499 # No normalization, but not necessarily accepted, that comes below.
1500 ;;
1501 esac
@@ -1511,47 +1743,57 @@
1511 # that MANUFACTURER isn't an operating system. Otherwise, code above
1512 # will signal an error saying that MANUFACTURER isn't an operating
1513 # system, and we'll never get to this point.
1514
1515 kernel=
 
1516 case $cpu-$vendor in
1517 score-*)
1518 os=elf
 
1519 ;;
1520 spu-*)
1521 os=elf
 
1522 ;;
1523 *-acorn)
1524 os=riscix1.2
1525 ;;
1526 arm*-rebel)
1527 kernel=linux
1528 os=gnu
1529 ;;
1530 arm*-semi)
1531 os=aout
 
1532 ;;
1533 c4x-* | tic4x-*)
1534 os=coff
 
1535 ;;
1536 c8051-*)
1537 os=elf
 
1538 ;;
1539 clipper-intergraph)
1540 os=clix
1541 ;;
1542 hexagon-*)
1543 os=elf
 
1544 ;;
1545 tic54x-*)
1546 os=coff
 
1547 ;;
1548 tic55x-*)
1549 os=coff
 
1550 ;;
1551 tic6x-*)
1552 os=coff
 
1553 ;;
1554 # This must come before the *-dec entry.
1555 pdp10-*)
1556 os=tops20
1557 ;;
@@ -1569,32 +1811,47 @@
1569 ;;
1570 m68000-sun)
1571 os=sunos3
1572 ;;
1573 m68*-cisco)
1574 os=aout
 
1575 ;;
1576 mep-*)
1577 os=elf
 
 
 
 
 
 
 
 
 
1578 ;;
1579 mips*-cisco)
1580 os=elf
 
1581 ;;
1582 mips*-*)
1583 os=elf
 
1584 ;;
1585 or32-*)
1586 os=coff
 
1587 ;;
1588 *-tti) # must be before sparc entry or we get the wrong os.
 
1589 os=sysv3
1590 ;;
1591 sparc-* | *-sun)
1592 os=sunos4.1.1
1593 ;;
1594 pru-*)
1595 os=elf
 
1596 ;;
1597 *-be)
1598 os=beos
1599 ;;
1600 *-ibm)
@@ -1614,11 +1871,11 @@
1614 ;;
1615 *-hp)
1616 os=hpux
1617 ;;
1618 *-hitachi)
1619 os=hiux
1620 ;;
1621 i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1622 os=sysv
1623 ;;
1624 *-cbm)
@@ -1658,27 +1915,23 @@
1658 os=bsd
1659 ;;
1660 *-encore)
1661 os=bsd
1662 ;;
1663 *-sgi)
1664 os=irix
1665 ;;
1666 *-siemens)
1667 os=sysv4
1668 ;;
1669 *-masscomp)
1670 os=rtu
1671 ;;
1672 f30[01]-fujitsu | f700-fujitsu)
1673 os=uxpv
1674 ;;
1675 *-rom68k)
1676 os=coff
 
1677 ;;
1678 *-*bug)
1679 os=coff
 
1680 ;;
1681 *-apple)
1682 os=macos
1683 ;;
1684 *-atari*)
@@ -1692,96 +1945,324 @@
1692 ;;
1693 esac
1694
1695 fi
1696
1697 # Now, validate our (potentially fixed-up) OS.
 
1698 case $os in
1699 # Sometimes we do "kernel-libc", so those need to count as OSes.
1700 musl* | newlib* | uclibc*)
1701 ;;
1702 # Likewise for "kernel-abi"
1703 eabi* | gnueabi*)
1704 ;;
1705 # VxWorks passes extra cpu info in the 4th filed.
1706 simlinux | simwindows | spe)
 
 
 
1707 ;;
1708 # Now accept the basic system types.
1709 # The portable systems comes first.
1710 # Each alternative MUST end in a * to match a version number.
1711 gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
1712 | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
1713 | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
1714 | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \
1715 | hiux* | abug | nacl* | netware* | windows* \
1716 | os9* | macos* | osx* | ios* \
1717 | mpw* | magic* | mmixware* | mon960* | lnews* \
1718 | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
1719 | aos* | aros* | cloudabi* | sortix* | twizzler* \
1720 | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
1721 | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
1722 | mirbsd* | netbsd* | dicos* | openedition* | ose* \
1723 | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
1724 | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
1725 | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
1726 | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
1727 | udi* | lites* | ieee* | go32* | aux* | hcos* \
1728 | chorusrdb* | cegcc* | glidix* | serenity* \
1729 | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
1730 | midipix* | mingw32* | mingw64* | mint* \
1731 | uxpv* | beos* | mpeix* | udk* | moxiebox* \
1732 | interix* | uwin* | mks* | rhapsody* | darwin* \
1733 | openstep* | oskit* | conix* | pw32* | nonstopux* \
1734 | storm-chaos* | tops10* | tenex* | tops20* | its* \
1735 | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
1736 | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
1737 | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
1738 | skyos* | haiku* | rdos* | toppers* | drops* | es* \
1739 | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
1740 | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
1741 | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1742 ;;
1743 # This one is extra strict with allowed versions
1744 sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
1745 # Don't forget version if it is 3.2v4 or newer.
1746 ;;
 
 
 
 
 
 
 
1747 none)
1748 ;;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1749 *)
1750 echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1751 exit 1
1752 ;;
1753 esac
1754
1755 # As a final step for OS-related things, validate the OS-kernel combination
1756 # (given a valid OS), if there is a kernel.
1757 case $kernel-$os in
1758 linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* )
 
 
 
 
 
 
1759 ;;
1760 uclinux-uclibc* )
1761 ;;
1762 -dietlibc* | -newlib* | -musl* | -uclibc* )
 
1763 # These are just libc implementations, not actual OSes, and thus
1764 # require a kernel.
1765 echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
 
 
 
 
 
 
 
 
 
 
 
 
1766 exit 1
1767 ;;
1768 kfreebsd*-gnu* | kopensolaris*-gnu*)
1769 ;;
1770 vxworks-simlinux | vxworks-simwindows | vxworks-spe)
1771 ;;
1772 nto-qnx*)
1773 ;;
1774 os2-emx)
1775 ;;
1776 *-eabi* | *-gnueabi*)
1777 ;;
1778 -*)
 
 
 
 
 
 
1779 # Blank kernel with real OS is always fine.
1780 ;;
1781 *-*)
1782 echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
 
 
 
1783 exit 1
1784 ;;
1785 esac
1786
1787 # Here we handle the case where we know the os, and the CPU type, but not the
@@ -1790,11 +2271,11 @@
1790 unknown)
1791 case $cpu-$os in
1792 *-riscix*)
1793 vendor=acorn
1794 ;;
1795 *-sunos*)
1796 vendor=sun
1797 ;;
1798 *-cnk* | *-aix*)
1799 vendor=ibm
1800 ;;
@@ -1860,14 +2341,14 @@
1860 ;;
1861 esac
1862 ;;
1863 esac
1864
1865 echo "$cpu-$vendor-${kernel:+$kernel-}$os"
1866 exit
1867
1868 # Local variables:
1869 # eval: (add-hook 'before-save-hook 'time-stamp)
1870 # time-stamp-start: "timestamp='"
1871 # time-stamp-format: "%:y-%02m-%02d"
1872 # time-stamp-end: "'"
1873 # End:
1874
--- autosetup/autosetup-config.sub
+++ autosetup/autosetup-config.sub
@@ -1,16 +1,16 @@
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright 1992-2024 Free Software Foundation, Inc.
4
5 # shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale
6
7 timestamp='2024-05-27'
8
9 # This file is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -74,17 +74,17 @@
74 Report bugs and patches to <[email protected]>."
75
76 version="\
77 GNU config.sub ($timestamp)
78
79 Copyright 1992-2024 Free Software Foundation, Inc.
80
81 This is free software; see the source for copying conditions. There is NO
82 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83
84 help="
85 Try '$me --help' for more information."
86
87 # Parse command line
88 while test $# -gt 0 ; do
89 case $1 in
90 --time-stamp | --time* | -t )
@@ -118,19 +118,20 @@
118 *) echo "$me: too many arguments$help" >&2
119 exit 1;;
120 esac
121
122 # Split fields of configuration type
123 saved_IFS=$IFS
124 IFS="-" read field1 field2 field3 field4 <<EOF
125 $1
126 EOF
127 IFS=$saved_IFS
128
129 # Separate into logical components for further validation
130 case $1 in
131 *-*-*-*-*)
132 echo "Invalid configuration '$1': more than four components" >&2
133 exit 1
134 ;;
135 *-*-*-*)
136 basic_machine=$field1-$field2
137 basic_os=$field3-$field4
@@ -138,14 +139,25 @@
139 *-*-*)
140 # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
141 # parts
142 maybe_os=$field2-$field3
143 case $maybe_os in
144 cloudabi*-eabi* \
145 | kfreebsd*-gnu* \
146 | knetbsd*-gnu* \
147 | kopensolaris*-gnu* \
148 | linux-* \
149 | managarm-* \
150 | netbsd*-eabi* \
151 | netbsd*-gnu* \
152 | nto-qnx* \
153 | os2-emx* \
154 | rtmk-nova* \
155 | storm-chaos* \
156 | uclinux-gnu* \
157 | uclinux-uclibc* \
158 | windows-* )
159 basic_machine=$field1
160 basic_os=$maybe_os
161 ;;
162 android-linux)
163 basic_machine=$field1-unknown
@@ -156,37 +168,105 @@
168 basic_os=$field3
169 ;;
170 esac
171 ;;
172 *-*)
 
173 case $field1-$field2 in
174 # Shorthands that happen to contain a single dash
175 convex-c[12] | convex-c3[248])
176 basic_machine=$field2-convex
177 basic_os=
178 ;;
179 decstation-3100)
180 basic_machine=mips-dec
181 basic_os=
182 ;;
183 *-*)
184 # Second component is usually, but not always the OS
185 case $field2 in
186 # Do not treat sunos as a manufacturer
187 sun*os*)
188 basic_machine=$field1
189 basic_os=$field2
190 ;;
191 # Manufacturers
192 3100* \
193 | 32* \
194 | 3300* \
195 | 3600* \
196 | 7300* \
197 | acorn \
198 | altos* \
199 | apollo \
200 | apple \
201 | atari \
202 | att* \
203 | axis \
204 | be \
205 | bull \
206 | cbm \
207 | ccur \
208 | cisco \
209 | commodore \
210 | convergent* \
211 | convex* \
212 | cray \
213 | crds \
214 | dec* \
215 | delta* \
216 | dg \
217 | digital \
218 | dolphin \
219 | encore* \
220 | gould \
221 | harris \
222 | highlevel \
223 | hitachi* \
224 | hp \
225 | ibm* \
226 | intergraph \
227 | isi* \
228 | knuth \
229 | masscomp \
230 | microblaze* \
231 | mips* \
232 | motorola* \
233 | ncr* \
234 | news \
235 | next \
236 | ns \
237 | oki \
238 | omron* \
239 | pc533* \
240 | rebel \
241 | rom68k \
242 | rombug \
243 | semi \
244 | sequent* \
245 | siemens \
246 | sgi* \
247 | siemens \
248 | sim \
249 | sni \
250 | sony* \
251 | stratus \
252 | sun \
253 | sun[234]* \
254 | tektronix \
255 | tti* \
256 | ultra \
257 | unicom* \
258 | wec \
259 | winbond \
260 | wrs)
261 basic_machine=$field1-$field2
262 basic_os=
263 ;;
264 zephyr*)
265 basic_machine=$field1-unknown
266 basic_os=$field2
267 ;;
268 *)
269 basic_machine=$field1
270 basic_os=$field2
271 ;;
272 esac
@@ -263,30 +343,10 @@
343 ;;
344 cegcc)
345 basic_machine=arm-unknown
346 basic_os=cegcc
347 ;;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348 cray)
349 basic_machine=j90-cray
350 basic_os=unicos
351 ;;
352 crds | unos)
@@ -705,13 +765,21 @@
765 decsystem20* | dec20*)
766 cpu=pdp10
767 vendor=dec
768 basic_os=tops20
769 ;;
770 delta | 3300 | delta-motorola | 3300-motorola | motorola-delta | motorola-3300)
 
771 cpu=m68k
772 vendor=motorola
773 ;;
774 # This used to be dpx2*, but that gets the RS6000-based
775 # DPX/20 and the x86-based DPX/2-100 wrong. See
776 # https://oldskool.silicium.org/stations/bull_dpx20.htm
777 # https://www.feb-patrimoine.com/english/bull_dpx2.htm
778 # https://www.feb-patrimoine.com/english/unix_and_bull.htm
779 dpx2 | dpx2[23]00 | dpx2[23]xx)
780 cpu=m68k
781 vendor=bull
782 ;;
783 dpx2100 | dpx21xx)
784 cpu=i386
785 vendor=bull
@@ -718,6 +786,9 @@
786 ;;
787 dpx20)
788 cpu=rs6000
789 vendor=bull
790 ;;
791 encore | umax | mmax)
792 cpu=ns32k
793 vendor=encore
794 ;;
@@ -828,22 +899,10 @@
899 basic_os=newsos
900 ;;
901 next | m*-next)
902 cpu=m68k
903 vendor=next
 
 
 
 
 
 
 
 
 
 
 
 
904 ;;
905 np1)
906 cpu=np1
907 vendor=gould
908 ;;
@@ -928,16 +987,17 @@
987 cpu=sparc
988 vendor=`echo "$basic_machine" | sed 's/-.*//'`
989 ;;
990
991 *-*)
992 saved_IFS=$IFS
993 IFS="-" read cpu vendor <<EOF
994 $basic_machine
995 EOF
996 IFS=$saved_IFS
997 ;;
998 # We use 'pc' rather than 'unknown'
999 # because (1) that's what they normally are, and
1000 # (2) the word "unknown" tends to confuse beginning users.
1001 i*86 | x86_64)
1002 cpu=$basic_machine
1003 vendor=pc
@@ -961,19 +1021,23 @@
1021
1022 unset -v basic_machine
1023
1024 # Decode basic machines in the full and proper CPU-Company form.
1025 case $cpu-$vendor in
1026 # Here we handle the default manufacturer of certain CPU types in canonical form.
1027 # It is in some cases the only manufacturer, in others, it is the most popular.
1028 c[12]-convex | c[12]-unknown | c3[248]-convex | c3[248]-unknown)
1029 vendor=convex
1030 basic_os=${basic_os:-bsd}
1031 ;;
1032 craynv-unknown)
1033 vendor=cray
1034 basic_os=${basic_os:-unicosmp}
1035 ;;
1036 c90-unknown | c90-cray)
1037 vendor=cray
1038 basic_os=${basic_os:-unicos}
1039 ;;
1040 fx80-unknown)
1041 vendor=alliant
1042 ;;
1043 romp-unknown)
@@ -1010,23 +1074,46 @@
1074 cpu=xps100
1075 vendor=honeywell
1076 ;;
1077
1078 # Here we normalize CPU types with a missing or matching vendor
1079 armh-unknown | armh-alt)
1080 cpu=armv7l
1081 vendor=alt
1082 basic_os=${basic_os:-linux-gnueabihf}
1083 ;;
1084
1085 # Normalized CPU+vendor pairs that imply an OS, if not otherwise specified
1086 m68k-isi)
1087 basic_os=${basic_os:-sysv}
1088 ;;
1089 m68k-sony)
1090 basic_os=${basic_os:-newsos}
1091 ;;
1092 m68k-tektronix)
1093 basic_os=${basic_os:-bsd}
1094 ;;
1095 m88k-harris)
1096 basic_os=${basic_os:-sysv3}
1097 ;;
1098 i386-bull | m68k-bull)
1099 basic_os=${basic_os:-sysv3}
1100 ;;
1101 rs6000-bull)
1102 basic_os=${basic_os:-bosx}
1103 ;;
1104 mips-sni)
1105 basic_os=${basic_os:-sysv4}
1106 ;;
1107
1108 # Here we normalize CPU types irrespective of the vendor
1109 amd64-*)
1110 cpu=x86_64
1111 ;;
1112 blackfin-*)
1113 cpu=bfin
1114 basic_os=${basic_os:-linux}
1115 ;;
1116 c54x-*)
1117 cpu=tic54x
1118 ;;
1119 c55x-*)
@@ -1045,37 +1132,34 @@
1132 ms1-*)
1133 cpu=mt
1134 ;;
1135 m68knommu-*)
1136 cpu=m68k
1137 basic_os=${basic_os:-linux}
1138 ;;
1139 m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1140 cpu=s12z
1141 ;;
1142 openrisc-*)
1143 cpu=or32
1144 ;;
1145 parisc-*)
1146 cpu=hppa
1147 basic_os=${basic_os:-linux}
1148 ;;
1149 pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1150 cpu=i586
1151 ;;
1152 pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
1153 cpu=i686
1154 ;;
1155 pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1156 cpu=i686
1157 ;;
1158 pentium4-*)
1159 cpu=i786
1160 ;;
 
 
 
1161 ppc-* | ppcbe-*)
1162 cpu=powerpc
1163 ;;
1164 ppcle-* | powerpclittle-*)
1165 cpu=powerpcle
@@ -1105,17 +1189,14 @@
1189 cpu=mipstx39
1190 ;;
1191 tx39el-*)
1192 cpu=mipstx39el
1193 ;;
 
 
 
1194 xscale-* | xscalee[bl]-*)
1195 cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1196 ;;
1197 arm64-* | aarch64le-*)
1198 cpu=aarch64
1199 ;;
1200
1201 # Recognize the canonical CPU Types that limit and/or modify the
1202 # company names they are paired with.
@@ -1163,118 +1244,235 @@
1244
1245 *)
1246 # Recognize the canonical CPU types that are allowed with any
1247 # company name.
1248 case $cpu in
1249 1750a \
1250 | 580 \
1251 | [cjt]90 \
1252 | a29k \
1253 | aarch64 \
1254 | aarch64_be \
1255 | aarch64c \
1256 | abacus \
1257 | alpha \
1258 | alpha64 \
1259 | alpha64ev56 \
1260 | alpha64ev6[78] \
1261 | alpha64ev[4-8] \
1262 | alpha64pca5[67] \
1263 | alphaev56 \
1264 | alphaev6[78] \
1265 | alphaev[4-8] \
1266 | alphapca5[67] \
1267 | am33_2.0 \
1268 | amdgcn \
1269 | arc \
1270 | arc32 \
1271 | arc64 \
1272 | arceb \
1273 | arm \
1274 | arm64e \
1275 | arm64ec \
1276 | arm[lb]e \
1277 | arme[lb] \
1278 | armv* \
1279 | asmjs \
1280 | avr \
1281 | avr32 \
1282 | ba \
1283 | be32 \
1284 | be64 \
1285 | bfin \
1286 | bpf \
1287 | bs2000 \
1288 | c30 \
1289 | c4x \
1290 | c8051 \
1291 | c[123]* \
1292 | clipper \
1293 | craynv \
1294 | csky \
1295 | cydra \
1296 | d10v \
1297 | d30v \
1298 | dlx \
1299 | dsp16xx \
1300 | e2k \
1301 | elxsi \
1302 | epiphany \
1303 | f30[01] \
1304 | f700 \
1305 | fido \
1306 | fr30 \
1307 | frv \
1308 | ft32 \
1309 | fx80 \
1310 | h8300 \
1311 | h8500 \
1312 | hexagon \
1313 | hppa \
1314 | hppa1.[01] \
1315 | hppa2.0 \
1316 | hppa2.0[nw] \
1317 | hppa64 \
1318 | i*86 \
1319 | i370 \
1320 | i860 \
1321 | i960 \
1322 | ia16 \
1323 | ia64 \
1324 | ip2k \
1325 | iq2000 \
1326 | javascript \
1327 | k1om \
1328 | kvx \
1329 | le32 \
1330 | le64 \
1331 | lm32 \
1332 | loongarch32 \
1333 | loongarch64 \
1334 | m32c \
1335 | m32r \
1336 | m32rle \
1337 | m5200 \
1338 | m68000 \
1339 | m680[012346]0 \
1340 | m6811 \
1341 | m6812 \
1342 | m68360 \
1343 | m683?2 \
1344 | m68hc11 \
1345 | m68hc12 \
1346 | m68hcs12x \
1347 | m68k \
1348 | m88110 \
1349 | m88k \
1350 | maxq \
1351 | mb \
1352 | mcore \
1353 | mep \
1354 | metag \
1355 | microblaze \
1356 | microblazeel \
1357 | mips* \
 
 
 
 
 
1358 | mmix \
1359 | mn10200 \
1360 | mn10300 \
1361 | moxie \
 
1362 | msp430 \
1363 | mt \
1364 | nanomips* \
1365 | nds32 \
1366 | nds32be \
1367 | nds32le \
1368 | nfp \
1369 | nios \
1370 | nios2 \
1371 | nios2eb \
1372 | nios2el \
1373 | none \
1374 | np1 \
1375 | ns16k \
1376 | ns32k \
1377 | nvptx \
1378 | open8 \
1379 | or1k* \
1380 | or32 \
1381 | orion \
1382 | pdp10 \
1383 | pdp11 \
1384 | picochip \
1385 | pj \
1386 | pjl \
1387 | pn \
1388 | power \
1389 | powerpc \
1390 | powerpc64 \
1391 | powerpc64le \
1392 | powerpcle \
1393 | powerpcspe \
1394 | pru \
1395 | pyramid \
1396 | riscv \
1397 | riscv32 \
1398 | riscv32be \
1399 | riscv64 \
1400 | riscv64be \
1401 | rl78 \
1402 | romp \
1403 | rs6000 \
1404 | rx \
1405 | s390 \
1406 | s390x \
1407 | score \
1408 | sh \
1409 | sh64 \
1410 | sh64le \
1411 | sh[12345][lb]e \
1412 | sh[1234] \
1413 | sh[1234]e[lb] \
1414 | sh[23]e \
1415 | sh[23]ele \
1416 | sh[24]a \
1417 | sh[24]ae[lb] \
1418 | sh[lb]e \
1419 | she[lb] \
1420 | shl \
1421 | sparc \
1422 | sparc64 \
1423 | sparc64b \
1424 | sparc64v \
1425 | sparc86x \
1426 | sparclet \
1427 | sparclite \
1428 | sparcv8 \
1429 | sparcv9 \
1430 | sparcv9b \
1431 | sparcv9v \
1432 | spu \
1433 | sv1 \
1434 | sx* \
1435 | tahoe \
1436 | thumbv7* \
1437 | tic30 \
1438 | tic4x \
1439 | tic54x \
1440 | tic55x \
1441 | tic6x \
1442 | tic80 \
1443 | tron \
1444 | ubicom32 \
1445 | v70 \
1446 | v810 \
1447 | v850 \
1448 | v850e \
1449 | v850e1 \
1450 | v850e2 \
1451 | v850e2v3 \
1452 | v850es \
1453 | vax \
1454 | vc4 \
1455 | visium \
1456 | w65 \
1457 | wasm32 \
1458 | wasm64 \
1459 | we32k \
1460 | x86 \
1461 | x86_64 \
1462 | xc16x \
1463 | xgate \
1464 | xps100 \
1465 | xstormy16 \
1466 | xtensa* \
1467 | ymp \
1468 | z80 \
1469 | z8k)
1470 ;;
1471
1472 *)
1473 echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
1474 exit 1
1475 ;;
1476 esac
1477 ;;
1478 esac
@@ -1291,15 +1489,16 @@
1489 ;;
1490 esac
1491
1492 # Decode manufacturer-specific aliases for certain operating systems.
1493
1494 if test x"$basic_os" != x
1495 then
1496
1497 # First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
1498 # set os.
1499 obj=
1500 case $basic_os in
1501 gnu/linux*)
1502 kernel=linux
1503 os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1504 ;;
@@ -1310,14 +1509,15 @@
1509 nto-qnx*)
1510 kernel=nto
1511 os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1512 ;;
1513 *-*)
1514 saved_IFS=$IFS
1515 IFS="-" read kernel os <<EOF
1516 $basic_os
1517 EOF
1518 IFS=$saved_IFS
1519 ;;
1520 # Default OS when just kernel was specified
1521 nto*)
1522 kernel=nto
1523 os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
@@ -1324,10 +1524,14 @@
1524 ;;
1525 linux*)
1526 kernel=linux
1527 os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1528 ;;
1529 managarm*)
1530 kernel=managarm
1531 os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
1532 ;;
1533 *)
1534 kernel=
1535 os=$basic_os
1536 ;;
1537 esac
@@ -1350,10 +1554,27 @@
1554 solaris)
1555 os=solaris2
1556 ;;
1557 unixware*)
1558 os=sysv4.2uw
1559 ;;
1560 # The marketing names for NeXT's operating systems were
1561 # NeXTSTEP, NeXTSTEP 2, OpenSTEP 3, OpenSTEP 4. 'openstep' is
1562 # mapped to 'openstep3', but 'openstep1' and 'openstep2' are
1563 # mapped to 'nextstep' and 'nextstep2', consistent with the
1564 # treatment of SunOS/Solaris.
1565 ns | ns1 | nextstep | nextstep1 | openstep1)
1566 os=nextstep
1567 ;;
1568 ns2 | nextstep2 | openstep2)
1569 os=nextstep2
1570 ;;
1571 ns3 | nextstep3 | openstep | openstep3)
1572 os=openstep3
1573 ;;
1574 ns4 | nextstep4 | openstep4)
1575 os=openstep4
1576 ;;
1577 # es1800 is here to avoid being matched by es* (a different OS)
1578 es1800*)
1579 os=ose
1580 ;;
@@ -1421,10 +1642,11 @@
1642 wince*)
1643 os=wince
1644 ;;
1645 utek*)
1646 os=bsd
1647 vendor=`echo "$vendor" | sed -e 's|^unknown$|tektronix|'`
1648 ;;
1649 dynix*)
1650 os=bsd
1651 ;;
1652 acis*)
@@ -1437,25 +1659,29 @@
1659 os=syllable
1660 ;;
1661 386bsd)
1662 os=bsd
1663 ;;
1664 ctix*)
1665 os=sysv
1666 vendor=`echo "$vendor" | sed -e 's|^unknown$|convergent|'`
1667 ;;
1668 uts*)
1669 os=sysv
1670 ;;
1671 nova*)
1672 kernel=rtmk
1673 os=nova
 
 
1674 ;;
1675 # Preserve the version number of sinix5.
1676 sinix5.*)
1677 os=`echo "$os" | sed -e 's|sinix|sysv|'`
1678 vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
1679 ;;
1680 sinix*)
1681 os=sysv4
1682 vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
1683 ;;
1684 tpf*)
1685 os=tpf
1686 ;;
1687 triton*)
@@ -1489,13 +1715,19 @@
1715 case $cpu in
1716 arm*)
1717 os=eabi
1718 ;;
1719 *)
1720 os=
1721 obj=elf
1722 ;;
1723 esac
1724 ;;
1725 aout* | coff* | elf* | pe*)
1726 # These are machine code file formats, not OSes
1727 obj=$os
1728 os=
1729 ;;
1730 *)
1731 # No normalization, but not necessarily accepted, that comes below.
1732 ;;
1733 esac
@@ -1511,47 +1743,57 @@
1743 # that MANUFACTURER isn't an operating system. Otherwise, code above
1744 # will signal an error saying that MANUFACTURER isn't an operating
1745 # system, and we'll never get to this point.
1746
1747 kernel=
1748 obj=
1749 case $cpu-$vendor in
1750 score-*)
1751 os=
1752 obj=elf
1753 ;;
1754 spu-*)
1755 os=
1756 obj=elf
1757 ;;
1758 *-acorn)
1759 os=riscix1.2
1760 ;;
1761 arm*-rebel)
1762 kernel=linux
1763 os=gnu
1764 ;;
1765 arm*-semi)
1766 os=
1767 obj=aout
1768 ;;
1769 c4x-* | tic4x-*)
1770 os=
1771 obj=coff
1772 ;;
1773 c8051-*)
1774 os=
1775 obj=elf
1776 ;;
1777 clipper-intergraph)
1778 os=clix
1779 ;;
1780 hexagon-*)
1781 os=
1782 obj=elf
1783 ;;
1784 tic54x-*)
1785 os=
1786 obj=coff
1787 ;;
1788 tic55x-*)
1789 os=
1790 obj=coff
1791 ;;
1792 tic6x-*)
1793 os=
1794 obj=coff
1795 ;;
1796 # This must come before the *-dec entry.
1797 pdp10-*)
1798 os=tops20
1799 ;;
@@ -1569,32 +1811,47 @@
1811 ;;
1812 m68000-sun)
1813 os=sunos3
1814 ;;
1815 m68*-cisco)
1816 os=
1817 obj=aout
1818 ;;
1819 mep-*)
1820 os=
1821 obj=elf
1822 ;;
1823 # The -sgi and -siemens entries must be before the mips- entry
1824 # or we get the wrong os.
1825 *-sgi)
1826 os=irix
1827 ;;
1828 *-siemens)
1829 os=sysv4
1830 ;;
1831 mips*-cisco)
1832 os=
1833 obj=elf
1834 ;;
1835 mips*-*|nanomips*-*)
1836 os=
1837 obj=elf
1838 ;;
1839 or32-*)
1840 os=
1841 obj=coff
1842 ;;
1843 # This must be before the sparc-* entry or we get the wrong os.
1844 *-tti)
1845 os=sysv3
1846 ;;
1847 sparc-* | *-sun)
1848 os=sunos4.1.1
1849 ;;
1850 pru-*)
1851 os=
1852 obj=elf
1853 ;;
1854 *-be)
1855 os=beos
1856 ;;
1857 *-ibm)
@@ -1614,11 +1871,11 @@
1871 ;;
1872 *-hp)
1873 os=hpux
1874 ;;
1875 *-hitachi)
1876 os=hiuxwe2
1877 ;;
1878 i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1879 os=sysv
1880 ;;
1881 *-cbm)
@@ -1658,27 +1915,23 @@
1915 os=bsd
1916 ;;
1917 *-encore)
1918 os=bsd
1919 ;;
 
 
 
 
 
 
1920 *-masscomp)
1921 os=rtu
1922 ;;
1923 f30[01]-fujitsu | f700-fujitsu)
1924 os=uxpv
1925 ;;
1926 *-rom68k)
1927 os=
1928 obj=coff
1929 ;;
1930 *-*bug)
1931 os=
1932 obj=coff
1933 ;;
1934 *-apple)
1935 os=macos
1936 ;;
1937 *-atari*)
@@ -1692,96 +1945,324 @@
1945 ;;
1946 esac
1947
1948 fi
1949
1950 # Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
1951
1952 case $os in
1953 # Sometimes we do "kernel-libc", so those need to count as OSes.
1954 llvm* | musl* | newlib* | relibc* | uclibc*)
1955 ;;
1956 # Likewise for "kernel-abi"
1957 eabi* | gnueabi*)
1958 ;;
1959 # VxWorks passes extra cpu info in the 4th filed.
1960 simlinux | simwindows | spe)
1961 ;;
1962 # See `case $cpu-$os` validation below
1963 ghcjs)
1964 ;;
1965 # Now accept the basic system types.
 
1966 # Each alternative MUST end in a * to match a version number.
1967 abug \
1968 | aix* \
1969 | amdhsa* \
1970 | amigados* \
1971 | amigaos* \
1972 | android* \
1973 | aof* \
1974 | aos* \
1975 | aros* \
1976 | atheos* \
1977 | auroraux* \
1978 | aux* \
1979 | beos* \
1980 | bitrig* \
1981 | bme* \
1982 | bosx* \
1983 | bsd* \
1984 | cegcc* \
1985 | chorusos* \
1986 | chorusrdb* \
1987 | clix* \
1988 | cloudabi* \
1989 | cnk* \
1990 | conix* \
1991 | cos* \
1992 | cxux* \
1993 | cygwin* \
1994 | darwin* \
1995 | dgux* \
1996 | dicos* \
1997 | dnix* \
1998 | domain* \
1999 | dragonfly* \
2000 | drops* \
2001 | ebmon* \
2002 | ecoff* \
2003 | ekkobsd* \
2004 | emscripten* \
2005 | emx* \
2006 | es* \
2007 | fiwix* \
2008 | freebsd* \
2009 | fuchsia* \
2010 | genix* \
2011 | genode* \
2012 | glidix* \
2013 | gnu* \
2014 | go32* \
2015 | haiku* \
2016 | hcos* \
2017 | hiux* \
2018 | hms* \
2019 | hpux* \
2020 | ieee* \
2021 | interix* \
2022 | ios* \
2023 | iris* \
2024 | irix* \
2025 | ironclad* \
2026 | isc* \
2027 | its* \
2028 | l4re* \
2029 | libertybsd* \
2030 | lites* \
2031 | lnews* \
2032 | luna* \
2033 | lynxos* \
2034 | mach* \
2035 | macos* \
2036 | magic* \
2037 | mbr* \
2038 | midipix* \
2039 | midnightbsd* \
2040 | mingw32* \
2041 | mingw64* \
2042 | minix* \
2043 | mint* \
2044 | mirbsd* \
2045 | mks* \
2046 | mlibc* \
2047 | mmixware* \
2048 | mon960* \
2049 | morphos* \
2050 | moss* \
2051 | moxiebox* \
2052 | mpeix* \
2053 | mpw* \
2054 | msdos* \
2055 | msys* \
2056 | mvs* \
2057 | nacl* \
2058 | netbsd* \
2059 | netware* \
2060 | newsos* \
2061 | nextstep* \
2062 | nindy* \
2063 | nonstopux* \
2064 | nova* \
2065 | nsk* \
2066 | nucleus* \
2067 | nx6 \
2068 | nx7 \
2069 | oabi* \
2070 | ohos* \
2071 | onefs* \
2072 | openbsd* \
2073 | openedition* \
2074 | openstep* \
2075 | os108* \
2076 | os2* \
2077 | os400* \
2078 | os68k* \
2079 | os9* \
2080 | ose* \
2081 | osf* \
2082 | oskit* \
2083 | osx* \
2084 | palmos* \
2085 | phoenix* \
2086 | plan9* \
2087 | powermax* \
2088 | powerunix* \
2089 | proelf* \
2090 | psos* \
2091 | psp* \
2092 | ptx* \
2093 | pw32* \
2094 | qnx* \
2095 | rdos* \
2096 | redox* \
2097 | rhapsody* \
2098 | riscix* \
2099 | riscos* \
2100 | rtems* \
2101 | rtmk* \
2102 | rtu* \
2103 | scout* \
2104 | secbsd* \
2105 | sei* \
2106 | serenity* \
2107 | sim* \
2108 | skyos* \
2109 | solaris* \
2110 | solidbsd* \
2111 | sortix* \
2112 | storm-chaos* \
2113 | sunos \
2114 | sunos[34]* \
2115 | superux* \
2116 | syllable* \
2117 | sym* \
2118 | sysv* \
2119 | tenex* \
2120 | tirtos* \
2121 | toppers* \
2122 | tops10* \
2123 | tops20* \
2124 | tpf* \
2125 | tvos* \
2126 | twizzler* \
2127 | uclinux* \
2128 | udi* \
2129 | udk* \
2130 | ultrix* \
2131 | unicos* \
2132 | uniplus* \
2133 | unleashed* \
2134 | unos* \
2135 | uwin* \
2136 | uxpv* \
2137 | v88r* \
2138 |*vms* \
2139 | vos* \
2140 | vsta* \
2141 | vxsim* \
2142 | vxworks* \
2143 | wasi* \
2144 | watchos* \
2145 | wince* \
2146 | windiss* \
2147 | windows* \
2148 | winnt* \
2149 | xenix* \
2150 | xray* \
2151 | zephyr* \
2152 | zvmoe* )
2153 ;;
2154 # This one is extra strict with allowed versions
2155 sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
2156 # Don't forget version if it is 3.2v4 or newer.
2157 ;;
2158 # This refers to builds using the UEFI calling convention
2159 # (which depends on the architecture) and PE file format.
2160 # Note that this is both a different calling convention and
2161 # different file format than that of GNU-EFI
2162 # (x86_64-w64-mingw32).
2163 uefi)
2164 ;;
2165 none)
2166 ;;
2167 kernel* | msvc* )
2168 # Restricted further below
2169 ;;
2170 '')
2171 if test x"$obj" = x
2172 then
2173 echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
2174 fi
2175 ;;
2176 *)
2177 echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
2178 exit 1
2179 ;;
2180 esac
2181
2182 case $obj in
2183 aout* | coff* | elf* | pe*)
2184 ;;
2185 '')
2186 # empty is fine
2187 ;;
2188 *)
2189 echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
2190 exit 1
2191 ;;
2192 esac
2193
2194 # Here we handle the constraint that a (synthetic) cpu and os are
2195 # valid only in combination with each other and nowhere else.
2196 case $cpu-$os in
2197 # The "javascript-unknown-ghcjs" triple is used by GHC; we
2198 # accept it here in order to tolerate that, but reject any
2199 # variations.
2200 javascript-ghcjs)
2201 ;;
2202 javascript-* | *-ghcjs)
2203 echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
2204 exit 1
2205 ;;
2206 esac
2207
2208 # As a final step for OS-related things, validate the OS-kernel combination
2209 # (given a valid OS), if there is a kernel.
2210 case $kernel-$os-$obj in
2211 linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
2212 | linux-mlibc*- | linux-musl*- | linux-newlib*- \
2213 | linux-relibc*- | linux-uclibc*- | linux-ohos*- )
2214 ;;
2215 uclinux-uclibc*- | uclinux-gnu*- )
2216 ;;
2217 managarm-mlibc*- | managarm-kernel*- )
2218 ;;
2219 windows*-msvc*-)
2220 ;;
2221 -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
2222 | -uclibc*- )
2223 # These are just libc implementations, not actual OSes, and thus
2224 # require a kernel.
2225 echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
2226 exit 1
2227 ;;
2228 -kernel*- )
2229 echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
2230 exit 1
2231 ;;
2232 *-kernel*- )
2233 echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
2234 exit 1
2235 ;;
2236 *-msvc*- )
2237 echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
2238 exit 1
2239 ;;
2240 kfreebsd*-gnu*- | knetbsd*-gnu*- | netbsd*-gnu*- | kopensolaris*-gnu*-)
2241 ;;
2242 vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
2243 ;;
2244 nto-qnx*-)
2245 ;;
2246 os2-emx-)
2247 ;;
2248 rtmk-nova-)
2249 ;;
2250 *-eabi*- | *-gnueabi*-)
2251 ;;
2252 none--*)
2253 # None (no kernel, i.e. freestanding / bare metal),
2254 # can be paired with an machine code file format
2255 ;;
2256 -*-)
2257 # Blank kernel with real OS is always fine.
2258 ;;
2259 --*)
2260 # Blank kernel and OS with real machine code file format is always fine.
2261 ;;
2262 *-*-*)
2263 echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
2264 exit 1
2265 ;;
2266 esac
2267
2268 # Here we handle the case where we know the os, and the CPU type, but not the
@@ -1790,11 +2271,11 @@
2271 unknown)
2272 case $cpu-$os in
2273 *-riscix*)
2274 vendor=acorn
2275 ;;
2276 *-sunos* | *-solaris*)
2277 vendor=sun
2278 ;;
2279 *-cnk* | *-aix*)
2280 vendor=ibm
2281 ;;
@@ -1860,14 +2341,14 @@
2341 ;;
2342 esac
2343 ;;
2344 esac
2345
2346 echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
2347 exit
2348
2349 # Local variables:
2350 # eval: (add-hook 'before-save-hook 'time-stamp)
2351 # time-stamp-start: "timestamp='"
2352 # time-stamp-format: "%:y-%02m-%02d"
2353 # time-stamp-end: "'"
2354 # End:
2355
--- autosetup/autosetup-find-tclsh
+++ autosetup/autosetup-find-tclsh
@@ -3,14 +3,14 @@
33
# If not found, builds a bootstrap jimsh in current dir from source
44
# Prefer $autosetup_tclsh if is set in the environment (unless ./jimsh0 works)
55
# If an argument is given, use that as the test instead of autosetup-test-tclsh
66
d="`dirname "$0"`"
77
for tclsh in ./jimsh0 $autosetup_tclsh jimsh tclsh tclsh8.5 tclsh8.6 tclsh8.7; do
8
- { $tclsh "$d/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
8
+ { $tclsh "$d/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
99
done
1010
echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
1111
for cc in ${CC_FOR_BUILD:-cc} gcc; do
12
- { $cc -o jimsh0 "$d/jimsh0.c"; } 2>&1 >/dev/null || continue
13
- ./jimsh0 "$d/${1-autosetup-test-tclsh}" && exit 0
12
+ { $cc -o jimsh0 "$d/jimsh0.c"; } >/dev/null 2>&1 || continue
13
+ ./jimsh0 "$d/${1-autosetup-test-tclsh}" && exit 0
1414
done
1515
echo 1>&2 "No working C compiler found. Tried ${CC_FOR_BUILD:-cc} and gcc."
1616
echo false
1717
--- autosetup/autosetup-find-tclsh
+++ autosetup/autosetup-find-tclsh
@@ -3,14 +3,14 @@
3 # If not found, builds a bootstrap jimsh in current dir from source
4 # Prefer $autosetup_tclsh if is set in the environment (unless ./jimsh0 works)
5 # If an argument is given, use that as the test instead of autosetup-test-tclsh
6 d="`dirname "$0"`"
7 for tclsh in ./jimsh0 $autosetup_tclsh jimsh tclsh tclsh8.5 tclsh8.6 tclsh8.7; do
8 { $tclsh "$d/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
9 done
10 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
11 for cc in ${CC_FOR_BUILD:-cc} gcc; do
12 { $cc -o jimsh0 "$d/jimsh0.c"; } 2>&1 >/dev/null || continue
13 ./jimsh0 "$d/${1-autosetup-test-tclsh}" && exit 0
14 done
15 echo 1>&2 "No working C compiler found. Tried ${CC_FOR_BUILD:-cc} and gcc."
16 echo false
17
--- autosetup/autosetup-find-tclsh
+++ autosetup/autosetup-find-tclsh
@@ -3,14 +3,14 @@
3 # If not found, builds a bootstrap jimsh in current dir from source
4 # Prefer $autosetup_tclsh if is set in the environment (unless ./jimsh0 works)
5 # If an argument is given, use that as the test instead of autosetup-test-tclsh
6 d="`dirname "$0"`"
7 for tclsh in ./jimsh0 $autosetup_tclsh jimsh tclsh tclsh8.5 tclsh8.6 tclsh8.7; do
8 { $tclsh "$d/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
9 done
10 echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
11 for cc in ${CC_FOR_BUILD:-cc} gcc; do
12 { $cc -o jimsh0 "$d/jimsh0.c"; } >/dev/null 2>&1 || continue
13 ./jimsh0 "$d/${1-autosetup-test-tclsh}" && exit 0
14 done
15 echo 1>&2 "No working C compiler found. Tried ${CC_FOR_BUILD:-cc} and gcc."
16 echo false
17
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -3,11 +3,11 @@
33
44
# @synopsis:
55
#
66
# The 'cc' module supports checking various 'features' of the C or C++
77
# compiler/linker environment. Common commands are 'cc-check-includes',
8
-# 'cc-check-types', 'cc-check-functions', 'cc-with', 'make-config-header' and 'make-template'.
8
+# 'cc-check-types', 'cc-check-functions', 'cc-with' and 'make-config-header'
99
#
1010
# The following environment variables are used if set:
1111
#
1212
## CC - C compiler
1313
## CXX - C++ compiler
1414
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -3,11 +3,11 @@
3
4 # @synopsis:
5 #
6 # The 'cc' module supports checking various 'features' of the C or C++
7 # compiler/linker environment. Common commands are 'cc-check-includes',
8 # 'cc-check-types', 'cc-check-functions', 'cc-with', 'make-config-header' and 'make-template'.
9 #
10 # The following environment variables are used if set:
11 #
12 ## CC - C compiler
13 ## CXX - C++ compiler
14
--- autosetup/cc.tcl
+++ autosetup/cc.tcl
@@ -3,11 +3,11 @@
3
4 # @synopsis:
5 #
6 # The 'cc' module supports checking various 'features' of the C or C++
7 # compiler/linker environment. Common commands are 'cc-check-includes',
8 # 'cc-check-types', 'cc-check-functions', 'cc-with' and 'make-config-header'
9 #
10 # The following environment variables are used if set:
11 #
12 ## CC - C compiler
13 ## CXX - C++ compiler
14
+3370 -1991
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -120,13 +120,10 @@
120120
#include <math.h>
121121
#include "sqlite3.h"
122122
typedef sqlite3_int64 i64;
123123
typedef sqlite3_uint64 u64;
124124
typedef unsigned char u8;
125
-#if SQLITE_USER_AUTHENTICATION
126
-# include "sqlite3userauth.h"
127
-#endif
128125
#include <ctype.h>
129126
#include <stdarg.h>
130127
131128
#if !defined(_WIN32) && !defined(WIN32)
132129
# include <signal.h>
@@ -208,12 +205,10 @@
208205
# define unlink _unlink
209206
# endif
210207
# ifndef strdup
211208
# define strdup _strdup
212209
# endif
213
-# undef popen
214
-# define popen _popen
215210
# undef pclose
216211
# define pclose _pclose
217212
# endif
218213
#else
219214
/* Make sure isatty() has a prototype. */
@@ -253,10 +248,370 @@
253248
/* string conversion routines only needed on Win32 */
254249
extern char *sqlite3_win32_unicode_to_utf8(LPCWSTR);
255250
extern LPWSTR sqlite3_win32_utf8_to_unicode(const char *zText);
256251
#endif
257252
253
+/************************* Begin ../ext/misc/sqlite3_stdio.h ******************/
254
+/*
255
+** 2024-09-24
256
+**
257
+** The author disclaims copyright to this source code. In place of
258
+** a legal notice, here is a blessing:
259
+**
260
+** May you do good and not evil.
261
+** May you find forgiveness for yourself and forgive others.
262
+** May you share freely, never taking more than you give.
263
+**
264
+*************************************************************************
265
+**
266
+** This header file contains definitions of interfaces that provide
267
+** cross-platform I/O for UTF-8 content.
268
+**
269
+** On most platforms, the interfaces definitions in this file are
270
+** just #defines. For example sqlite3_fopen() is a macro that resolves
271
+** to the standard fopen() in the C-library.
272
+**
273
+** But Windows does not have a standard C-library, at least not one that
274
+** can handle UTF-8. So for windows build, the interfaces resolve to new
275
+** C-language routines contained in the separate sqlite3_stdio.c source file.
276
+**
277
+** So on all non-Windows platforms, simply #include this header file and
278
+** use the interfaces defined herein. Then to run your application on Windows,
279
+** also link in the accompanying sqlite3_stdio.c source file when compiling
280
+** to get compatible interfaces.
281
+*/
282
+#ifndef _SQLITE3_STDIO_H_
283
+#define _SQLITE3_STDIO_H_ 1
284
+#ifdef _WIN32
285
+/**** Definitions For Windows ****/
286
+#include <stdio.h>
287
+#include <windows.h>
288
+
289
+FILE *sqlite3_fopen(const char *zFilename, const char *zMode);
290
+FILE *sqlite3_popen(const char *zCommand, const char *type);
291
+char *sqlite3_fgets(char *s, int size, FILE *stream);
292
+int sqlite3_fputs(const char *s, FILE *stream);
293
+int sqlite3_fprintf(FILE *stream, const char *format, ...);
294
+void sqlite3_fsetmode(FILE *stream, int mode);
295
+
296
+
297
+#else
298
+/**** Definitions For All Other Platforms ****/
299
+#include <stdio.h>
300
+#define sqlite3_fopen fopen
301
+#define sqlite3_popen popen
302
+#define sqlite3_fgets fgets
303
+#define sqlite3_fputs fputs
304
+#define sqlite3_fprintf fprintf
305
+#define sqlite3_fsetmode(F,X) /*no-op*/
306
+
307
+#endif
308
+#endif /* _SQLITE3_STDIO_H_ */
309
+
310
+/************************* End ../ext/misc/sqlite3_stdio.h ********************/
311
+/************************* Begin ../ext/misc/sqlite3_stdio.c ******************/
312
+/*
313
+** 2024-09-24
314
+**
315
+** The author disclaims copyright to this source code. In place of
316
+** a legal notice, here is a blessing:
317
+**
318
+** May you do good and not evil.
319
+** May you find forgiveness for yourself and forgive others.
320
+** May you share freely, never taking more than you give.
321
+**
322
+*************************************************************************
323
+**
324
+** Implementation of standard I/O interfaces for UTF-8 that are missing
325
+** on Windows.
326
+*/
327
+#ifdef _WIN32 /* This file is a no-op on all platforms except Windows */
328
+#ifndef _SQLITE3_STDIO_H_
329
+/* #include "sqlite3_stdio.h" */
330
+#endif
331
+#undef WIN32_LEAN_AND_MEAN
332
+#define WIN32_LEAN_AND_MEAN
333
+#include <windows.h>
334
+#include <stdlib.h>
335
+#include <string.h>
336
+#include <stdio.h>
337
+#include <assert.h>
338
+/* #include "sqlite3.h" */
339
+#include <ctype.h>
340
+#include <stdarg.h>
341
+#include <io.h>
342
+#include <fcntl.h>
343
+
344
+/*
345
+** If the SQLITE_U8TEXT_ONLY option is defined, then use O_U8TEXT
346
+** when appropriate on all output. (Sometimes use O_BINARY when
347
+** rendering ASCII text in cases where NL-to-CRLF expansion would
348
+** not be correct.)
349
+**
350
+** If the SQLITE_U8TEXT_STDIO option is defined, then use O_U8TEXT
351
+** when appropriate when writing to stdout or stderr. Use O_BINARY
352
+** or O_TEXT (depending on things like the .mode and the .crlf setting
353
+** in the CLI, or other context clues in other applications) for all
354
+** other output channels.
355
+**
356
+** The default behavior, if neither of the above is defined is to
357
+** use O_U8TEXT when writing to the Windows console (or anything
358
+** else for which _isatty() returns true) and to use O_BINARY or O_TEXT
359
+** for all other output channels.
360
+*/
361
+#if defined(SQLITE_U8TEXT_ONLY)
362
+# define UseWtextForOutput(fd) 1
363
+# define UseWtextForInput(fd) 1
364
+# define IsConsole(fd) _isatty(_fileno(fd))
365
+#elif defined(SQLITE_U8TEXT_STDIO)
366
+# define UseWtextForOutput(fd) ((fd)==stdout || (fd)==stderr)
367
+# define UseWtextForInput(fd) ((fd)==stdin)
368
+# define IsConsole(fd) _isatty(_fileno(fd))
369
+#else
370
+# define UseWtextForOutput(fd) _isatty(_fileno(fd))
371
+# define UseWtextForInput(fd) _isatty(_fileno(fd))
372
+# define IsConsole(fd) 1
373
+#endif
374
+
375
+/*
376
+** Global variables determine if simulated O_BINARY mode is to be
377
+** used for stdout or other, respectively. Simulated O_BINARY mode
378
+** means the mode is usually O_BINARY, but switches to O_U8TEXT for
379
+** unicode characters U+0080 or greater (any character that has a
380
+** multi-byte representation in UTF-8). This is the only way we
381
+** have found to render Unicode characters on a Windows console while
382
+** at the same time avoiding undesirable \n to \r\n translation.
383
+*/
384
+static int simBinaryStdout = 0;
385
+static int simBinaryOther = 0;
386
+
387
+
388
+/*
389
+** Determine if simulated binary mode should be used for output to fd
390
+*/
391
+static int UseBinaryWText(FILE *fd){
392
+ if( fd==stdout || fd==stderr ){
393
+ return simBinaryStdout;
394
+ }else{
395
+ return simBinaryOther;
396
+ }
397
+}
398
+
399
+
400
+/*
401
+** Work-alike for the fopen() routine from the standard C library.
402
+*/
403
+FILE *sqlite3_fopen(const char *zFilename, const char *zMode){
404
+ FILE *fp = 0;
405
+ wchar_t *b1, *b2;
406
+ int sz1, sz2;
407
+
408
+ sz1 = (int)strlen(zFilename);
409
+ sz2 = (int)strlen(zMode);
410
+ b1 = sqlite3_malloc( (sz1+1)*sizeof(b1[0]) );
411
+ b2 = sqlite3_malloc( (sz2+1)*sizeof(b1[0]) );
412
+ if( b1 && b2 ){
413
+ sz1 = MultiByteToWideChar(CP_UTF8, 0, zFilename, sz1, b1, sz1);
414
+ b1[sz1] = 0;
415
+ sz2 = MultiByteToWideChar(CP_UTF8, 0, zMode, sz2, b2, sz2);
416
+ b2[sz2] = 0;
417
+ fp = _wfopen(b1, b2);
418
+ }
419
+ sqlite3_free(b1);
420
+ sqlite3_free(b2);
421
+ simBinaryOther = 0;
422
+ return fp;
423
+}
424
+
425
+
426
+/*
427
+** Work-alike for the popen() routine from the standard C library.
428
+*/
429
+FILE *sqlite3_popen(const char *zCommand, const char *zMode){
430
+ FILE *fp = 0;
431
+ wchar_t *b1, *b2;
432
+ int sz1, sz2;
433
+
434
+ sz1 = (int)strlen(zCommand);
435
+ sz2 = (int)strlen(zMode);
436
+ b1 = sqlite3_malloc( (sz1+1)*sizeof(b1[0]) );
437
+ b2 = sqlite3_malloc( (sz2+1)*sizeof(b1[0]) );
438
+ if( b1 && b2 ){
439
+ sz1 = MultiByteToWideChar(CP_UTF8, 0, zCommand, sz1, b1, sz1);
440
+ b1[sz1] = 0;
441
+ sz2 = MultiByteToWideChar(CP_UTF8, 0, zMode, sz2, b2, sz2);
442
+ b2[sz2] = 0;
443
+ fp = _wpopen(b1, b2);
444
+ }
445
+ sqlite3_free(b1);
446
+ sqlite3_free(b2);
447
+ return fp;
448
+}
449
+
450
+/*
451
+** Work-alike for fgets() from the standard C library.
452
+*/
453
+char *sqlite3_fgets(char *buf, int sz, FILE *in){
454
+ if( UseWtextForInput(in) ){
455
+ /* When reading from the command-prompt in Windows, it is necessary
456
+ ** to use _O_WTEXT input mode to read UTF-16 characters, then translate
457
+ ** that into UTF-8. Otherwise, non-ASCII characters all get translated
458
+ ** into '?'.
459
+ */
460
+ wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) );
461
+ if( b1==0 ) return 0;
462
+#ifndef SQLITE_USE_STDIO_FOR_CONSOLE
463
+ DWORD nRead = 0;
464
+ if( IsConsole(in)
465
+ && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz, &nRead, 0)
466
+ ){
467
+ b1[nRead] = 0;
468
+ }else
469
+#endif
470
+ {
471
+ _setmode(_fileno(in), IsConsole(in) ? _O_WTEXT : _O_U8TEXT);
472
+ if( fgetws(b1, sz/4, in)==0 ){
473
+ sqlite3_free(b1);
474
+ return 0;
475
+ }
476
+ }
477
+ WideCharToMultiByte(CP_UTF8, 0, b1, -1, buf, sz, 0, 0);
478
+ sqlite3_free(b1);
479
+ return buf;
480
+ }else{
481
+ /* Reading from a file or other input source, just read bytes without
482
+ ** any translation. */
483
+ return fgets(buf, sz, in);
484
+ }
485
+}
486
+
487
+/*
488
+** Send ASCII text as O_BINARY. But for Unicode characters U+0080 and
489
+** greater, switch to O_U8TEXT.
490
+*/
491
+static void piecemealOutput(wchar_t *b1, int sz, FILE *out){
492
+ int i;
493
+ wchar_t c;
494
+ while( sz>0 ){
495
+ for(i=0; i<sz && b1[i]>=0x80; i++){}
496
+ if( i>0 ){
497
+ c = b1[i];
498
+ b1[i] = 0;
499
+ fflush(out);
500
+ _setmode(_fileno(out), _O_U8TEXT);
501
+ fputws(b1, out);
502
+ fflush(out);
503
+ b1 += i;
504
+ b1[0] = c;
505
+ sz -= i;
506
+ }else{
507
+ fflush(out);
508
+ _setmode(_fileno(out), _O_TEXT);
509
+ _setmode(_fileno(out), _O_BINARY);
510
+ fwrite(&b1[0], 1, 1, out);
511
+ for(i=1; i<sz && b1[i]<0x80; i++){
512
+ fwrite(&b1[i], 1, 1, out);
513
+ }
514
+ fflush(out);
515
+ _setmode(_fileno(out), _O_U8TEXT);
516
+ b1 += i;
517
+ sz -= i;
518
+ }
519
+ }
520
+}
521
+
522
+/*
523
+** Work-alike for fputs() from the standard C library.
524
+*/
525
+int sqlite3_fputs(const char *z, FILE *out){
526
+ if( !UseWtextForOutput(out) ){
527
+ /* Writing to a file or other destination, just write bytes without
528
+ ** any translation. */
529
+ return fputs(z, out);
530
+ }else{
531
+ /* One must use UTF16 in order to get unicode support when writing
532
+ ** to the console on Windows.
533
+ */
534
+ int sz = (int)strlen(z);
535
+ wchar_t *b1 = sqlite3_malloc( (sz+1)*sizeof(wchar_t) );
536
+ if( b1==0 ) return 0;
537
+ sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz);
538
+ b1[sz] = 0;
539
+
540
+#ifndef SQLITE_STDIO_FOR_CONSOLE
541
+ DWORD nWr = 0;
542
+ if( IsConsole(out)
543
+ && WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),b1,sz,&nWr,0)
544
+ ){
545
+ /* If writing to the console, then the WriteConsoleW() is all we
546
+ ** need to do. */
547
+ }else
548
+#endif
549
+ {
550
+ /* For non-console I/O, or if SQLITE_USE_STDIO_FOR_CONSOLE is defined
551
+ ** then write using the standard library. */
552
+ _setmode(_fileno(out), _O_U8TEXT);
553
+ if( UseBinaryWText(out) ){
554
+ piecemealOutput(b1, sz, out);
555
+ }else{
556
+ fputws(b1, out);
557
+ }
558
+ }
559
+ sqlite3_free(b1);
560
+ return 0;
561
+ }
562
+}
563
+
564
+
565
+/*
566
+** Work-alike for fprintf() from the standard C library.
567
+*/
568
+int sqlite3_fprintf(FILE *out, const char *zFormat, ...){
569
+ int rc;
570
+ if( UseWtextForOutput(out) ){
571
+ /* When writing to the command-prompt in Windows, it is necessary
572
+ ** to use _O_WTEXT input mode and write UTF-16 characters.
573
+ */
574
+ char *z;
575
+ va_list ap;
576
+
577
+ va_start(ap, zFormat);
578
+ z = sqlite3_vmprintf(zFormat, ap);
579
+ va_end(ap);
580
+ sqlite3_fputs(z, out);
581
+ rc = (int)strlen(z);
582
+ sqlite3_free(z);
583
+ }else{
584
+ /* Writing to a file or other destination, just write bytes without
585
+ ** any translation. */
586
+ va_list ap;
587
+ va_start(ap, zFormat);
588
+ rc = vfprintf(out, zFormat, ap);
589
+ va_end(ap);
590
+ }
591
+ return rc;
592
+}
593
+
594
+/*
595
+** Set the mode for an output stream. mode argument is typically _O_BINARY or
596
+** _O_TEXT.
597
+*/
598
+void sqlite3_fsetmode(FILE *fp, int mode){
599
+ if( !UseWtextForOutput(fp) ){
600
+ fflush(fp);
601
+ _setmode(_fileno(fp), mode);
602
+ }else if( fp==stdout || fp==stderr ){
603
+ simBinaryStdout = (mode==_O_BINARY);
604
+ }else{
605
+ simBinaryOther = (mode==_O_BINARY);
606
+ }
607
+}
608
+
609
+#endif /* defined(_WIN32) */
610
+
611
+/************************* End ../ext/misc/sqlite3_stdio.c ********************/
612
+
258613
/* Use console I/O package as a direct INCLUDE. */
259614
#define SQLITE_INTERNAL_LINKAGE static
260615
261616
#ifdef SQLITE_SHELL_FIDDLE
262617
/* Deselect most features from the console I/O package for Fiddle. */
@@ -264,1118 +619,13 @@
264619
# define SQLITE_CIO_NO_CLASSIFY
265620
# define SQLITE_CIO_NO_TRANSLATE
266621
# define SQLITE_CIO_NO_SETMODE
267622
# define SQLITE_CIO_NO_FLUSH
268623
#endif
269
-/************************* Begin ../ext/consio/console_io.h ******************/
270
-/*
271
-** 2023 November 1
272
-**
273
-** The author disclaims copyright to this source code. In place of
274
-** a legal notice, here is a blessing:
275
-**
276
-** May you do good and not evil.
277
-** May you find forgiveness for yourself and forgive others.
278
-** May you share freely, never taking more than you give.
279
-**
280
-********************************************************************************
281
-** This file exposes various interfaces used for console and other I/O
282
-** by the SQLite project command-line tools. These interfaces are used
283
-** at either source conglomeration time, compilation time, or run time.
284
-** This source provides for either inclusion into conglomerated,
285
-** "single-source" forms or separate compilation then linking.
286
-**
287
-** Platform dependencies are "hidden" here by various stratagems so
288
-** that, provided certain conditions are met, the programs using this
289
-** source or object code compiled from it need no explicit conditional
290
-** compilation in their source for their console and stream I/O.
291
-**
292
-** The symbols and functionality exposed here are not a public API.
293
-** This code may change in tandem with other project code as needed.
294
-**
295
-** When this .h file and its companion .c are directly incorporated into
296
-** a source conglomeration (such as shell.c), the preprocessor symbol
297
-** CIO_WIN_WC_XLATE is defined as 0 or 1, reflecting whether console I/O
298
-** translation for Windows is effected for the build.
299
-*/
300
-#define HAVE_CONSOLE_IO_H 1
301
-#ifndef SQLITE_INTERNAL_LINKAGE
302
-# define SQLITE_INTERNAL_LINKAGE extern /* external to translation unit */
303
-# include <stdio.h>
304
-#else
305
-# define SHELL_NO_SYSINC /* Better yet, modify mkshellc.tcl for this. */
306
-#endif
307
-
308
-#ifndef SQLITE3_H
309
-/* # include "sqlite3.h" */
310
-#endif
311
-
312
-#ifndef SQLITE_CIO_NO_CLASSIFY
313
-
314
-/* Define enum for use with following function. */
315
-typedef enum StreamsAreConsole {
316
- SAC_NoConsole = 0,
317
- SAC_InConsole = 1, SAC_OutConsole = 2, SAC_ErrConsole = 4,
318
- SAC_AnyConsole = 0x7
319
-} StreamsAreConsole;
320
-
321
-/*
322
-** Classify the three standard I/O streams according to whether
323
-** they are connected to a console attached to the process.
324
-**
325
-** Returns the bit-wise OR of SAC_{In,Out,Err}Console values,
326
-** or SAC_NoConsole if none of the streams reaches a console.
327
-**
328
-** This function should be called before any I/O is done with
329
-** the given streams. As a side-effect, the given inputs are
330
-** recorded so that later I/O operations on them may be done
331
-** differently than the C library FILE* I/O would be done,
332
-** iff the stream is used for the I/O functions that follow,
333
-** and to support the ones that use an implicit stream.
334
-**
335
-** On some platforms, stream or console mode alteration (aka
336
-** "Setup") may be made which is undone by consoleRestore().
337
-*/
338
-SQLITE_INTERNAL_LINKAGE StreamsAreConsole
339
-consoleClassifySetup( FILE *pfIn, FILE *pfOut, FILE *pfErr );
340
-/* A usual call for convenience: */
341
-#define SQLITE_STD_CONSOLE_INIT() consoleClassifySetup(stdin,stdout,stderr)
342
-
343
-/*
344
-** After an initial call to consoleClassifySetup(...), renew
345
-** the same setup it effected. (A call not after is an error.)
346
-** This will restore state altered by consoleRestore();
347
-**
348
-** Applications which run an inferior (child) process which
349
-** inherits the same I/O streams may call this function after
350
-** such a process exits to guard against console mode changes.
351
-*/
352
-SQLITE_INTERNAL_LINKAGE void consoleRenewSetup(void);
353
-
354
-/*
355
-** Undo any side-effects left by consoleClassifySetup(...).
356
-**
357
-** This should be called after consoleClassifySetup() and
358
-** before the process terminates normally. It is suitable
359
-** for use with the atexit() C library procedure. After
360
-** this call, no console I/O should be done until one of
361
-** console{Classify or Renew}Setup(...) is called again.
362
-**
363
-** Applications which run an inferior (child) process that
364
-** inherits the same I/O streams might call this procedure
365
-** before so that said process will have a console setup
366
-** however users have configured it or come to expect.
367
-*/
368
-SQLITE_INTERNAL_LINKAGE void SQLITE_CDECL consoleRestore( void );
369
-
370
-#else /* defined(SQLITE_CIO_NO_CLASSIFY) */
371
-# define consoleClassifySetup(i,o,e)
372
-# define consoleRenewSetup()
373
-# define consoleRestore()
374
-#endif /* defined(SQLITE_CIO_NO_CLASSIFY) */
375
-
376
-#ifndef SQLITE_CIO_NO_REDIRECT
377
-/*
378
-** Set stream to be used for the functions below which write
379
-** to "the designated X stream", where X is Output or Error.
380
-** Returns the previous value.
381
-**
382
-** Alternatively, pass the special value, invalidFileStream,
383
-** to get the designated stream value without setting it.
384
-**
385
-** Before the designated streams are set, they default to
386
-** those passed to consoleClassifySetup(...), and before
387
-** that is called they default to stdout and stderr.
388
-**
389
-** It is error to close a stream so designated, then, without
390
-** designating another, use the corresponding {o,e}Emit(...).
391
-*/
392
-SQLITE_INTERNAL_LINKAGE FILE *invalidFileStream;
393
-SQLITE_INTERNAL_LINKAGE FILE *setOutputStream(FILE *pf);
394
-# ifdef CONSIO_SET_ERROR_STREAM
395
-SQLITE_INTERNAL_LINKAGE FILE *setErrorStream(FILE *pf);
396
-# endif
397
-#else
398
-# define setOutputStream(pf)
399
-# define setErrorStream(pf)
400
-#endif /* !defined(SQLITE_CIO_NO_REDIRECT) */
401
-
402
-#ifndef SQLITE_CIO_NO_TRANSLATE
403
-/*
404
-** Emit output like fprintf(). If the output is going to the
405
-** console and translation from UTF-8 is necessary, perform
406
-** the needed translation. Otherwise, write formatted output
407
-** to the provided stream almost as-is, possibly with newline
408
-** translation as specified by set{Binary,Text}Mode().
409
-*/
410
-SQLITE_INTERNAL_LINKAGE int fPrintfUtf8(FILE *pfO, const char *zFormat, ...);
411
-/* Like fPrintfUtf8 except stream is always the designated output. */
412
-SQLITE_INTERNAL_LINKAGE int oPrintfUtf8(const char *zFormat, ...);
413
-/* Like fPrintfUtf8 except stream is always the designated error. */
414
-SQLITE_INTERNAL_LINKAGE int ePrintfUtf8(const char *zFormat, ...);
415
-
416
-/*
417
-** Emit output like fputs(). If the output is going to the
418
-** console and translation from UTF-8 is necessary, perform
419
-** the needed translation. Otherwise, write given text to the
420
-** provided stream almost as-is, possibly with newline
421
-** translation as specified by set{Binary,Text}Mode().
422
-*/
423
-SQLITE_INTERNAL_LINKAGE int fPutsUtf8(const char *z, FILE *pfO);
424
-/* Like fPutsUtf8 except stream is always the designated output. */
425
-SQLITE_INTERNAL_LINKAGE int oPutsUtf8(const char *z);
426
-/* Like fPutsUtf8 except stream is always the designated error. */
427
-SQLITE_INTERNAL_LINKAGE int ePutsUtf8(const char *z);
428
-
429
-/*
430
-** Emit output like fPutsUtf8(), except that the length of the
431
-** accepted char or character sequence is limited by nAccept.
432
-**
433
-** Returns the number of accepted char values.
434
-*/
435
-#ifdef CONSIO_SPUTB
436
-SQLITE_INTERNAL_LINKAGE int
437
-fPutbUtf8(FILE *pfOut, const char *cBuf, int nAccept);
438
-/* Like fPutbUtf8 except stream is always the designated output. */
439
-#endif
440
-SQLITE_INTERNAL_LINKAGE int
441
-oPutbUtf8(const char *cBuf, int nAccept);
442
-/* Like fPutbUtf8 except stream is always the designated error. */
443
-#ifdef CONSIO_EPUTB
444
-SQLITE_INTERNAL_LINKAGE int
445
-ePutbUtf8(const char *cBuf, int nAccept);
446
-#endif
447
-
448
-/*
449
-** Flush the given output stream. Return non-zero for success, else 0.
450
-*/
451
-#if !defined(SQLITE_CIO_NO_FLUSH) && !defined(SQLITE_CIO_NO_SETMODE)
452
-SQLITE_INTERNAL_LINKAGE int
453
-fFlushBuffer(FILE *pfOut);
454
-#endif
455
-
456
-/*
457
-** Collect input like fgets(...) with special provisions for input
458
-** from the console on such platforms as require same. Newline
459
-** translation may be done as set by set{Binary,Text}Mode().
460
-** As a convenience, pfIn==NULL is treated as stdin.
461
-*/
462
-SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn);
463
-/* Like fGetsUtf8 except stream is always the designated input. */
464
-/* SQLITE_INTERNAL_LINKAGE char* iGetsUtf8(char *cBuf, int ncMax); */
465
-
466
-#endif /* !defined(SQLITE_CIO_NO_TRANSLATE) */
467
-
468
-#ifndef SQLITE_CIO_NO_SETMODE
469
-/*
470
-** Set given stream for binary mode, where newline translation is
471
-** not done, or for text mode where, for some platforms, newlines
472
-** are translated to the platform's conventional char sequence.
473
-** If bFlush true, flush the stream.
474
-**
475
-** An additional side-effect is that if the stream is one passed
476
-** to consoleClassifySetup() as an output, it is flushed first.
477
-**
478
-** Note that binary/text mode has no effect on console I/O
479
-** translation. On all platforms, newline to the console starts
480
-** a new line and CR,LF chars from the console become a newline.
481
-*/
482
-SQLITE_INTERNAL_LINKAGE void setBinaryMode(FILE *, short bFlush);
483
-SQLITE_INTERNAL_LINKAGE void setTextMode(FILE *, short bFlush);
484
-#endif
485
-
486
-#ifdef SQLITE_CIO_PROMPTED_IN
487
-typedef struct Prompts {
488
- int numPrompts;
489
- const char **azPrompts;
490
-} Prompts;
491
-
492
-/*
493
-** Macros for use of a line editor.
494
-**
495
-** The following macros define operations involving use of a
496
-** line-editing library or simple console interaction.
497
-** A "T" argument is a text (char *) buffer or filename.
498
-** A "N" argument is an integer.
499
-**
500
-** SHELL_ADD_HISTORY(T) // Record text as line(s) of history.
501
-** SHELL_READ_HISTORY(T) // Read history from file named by T.
502
-** SHELL_WRITE_HISTORY(T) // Write history to file named by T.
503
-** SHELL_STIFLE_HISTORY(N) // Limit history to N entries.
504
-**
505
-** A console program which does interactive console input is
506
-** expected to call:
507
-** SHELL_READ_HISTORY(T) before collecting such input;
508
-** SHELL_ADD_HISTORY(T) as record-worthy input is taken;
509
-** SHELL_STIFLE_HISTORY(N) after console input ceases; then
510
-** SHELL_WRITE_HISTORY(T) before the program exits.
511
-*/
512
-
513
-/*
514
-** Retrieve a single line of input text from an input stream.
515
-**
516
-** If pfIn is the input stream passed to consoleClassifySetup(),
517
-** and azPrompt is not NULL, then a prompt is issued before the
518
-** line is collected, as selected by the isContinuation flag.
519
-** Array azPrompt[{0,1}] holds the {main,continuation} prompt.
520
-**
521
-** If zBufPrior is not NULL then it is a buffer from a prior
522
-** call to this routine that can be reused, or will be freed.
523
-**
524
-** The result is stored in space obtained from malloc() and
525
-** must either be freed by the caller or else passed back to
526
-** this function as zBufPrior for reuse.
527
-**
528
-** This function may call upon services of a line-editing
529
-** library to interactively collect line edited input.
530
-*/
531
-SQLITE_INTERNAL_LINKAGE char *
532
-shellGetLine(FILE *pfIn, char *zBufPrior, int nLen,
533
- short isContinuation, Prompts azPrompt);
534
-#endif /* defined(SQLITE_CIO_PROMPTED_IN) */
535
-/*
536
-** TBD: Define an interface for application(s) to generate
537
-** completion candidates for use by the line-editor.
538
-**
539
-** This may be premature; the CLI is the only application
540
-** that does this. Yet, getting line-editing melded into
541
-** console I/O is desirable because a line-editing library
542
-** may have to establish console operating mode, possibly
543
-** in a way that interferes with the above functionality.
544
-*/
545
-
546
-#if !(defined(SQLITE_CIO_NO_UTF8SCAN)&&defined(SQLITE_CIO_NO_TRANSLATE))
547
-/* Skip over as much z[] input char sequence as is valid UTF-8,
548
-** limited per nAccept char's or whole characters and containing
549
-** no char cn such that ((1<<cn) & ccm)!=0. On return, the
550
-** sequence z:return (inclusive:exclusive) is validated UTF-8.
551
-** Limit: nAccept>=0 => char count, nAccept<0 => character
552
- */
553
-SQLITE_INTERNAL_LINKAGE const char*
554
-zSkipValidUtf8(const char *z, int nAccept, long ccm);
555
-
556
-#endif
557
-
558
-/************************* End ../ext/consio/console_io.h ********************/
559
-/************************* Begin ../ext/consio/console_io.c ******************/
560
-/*
561
-** 2023 November 4
562
-**
563
-** The author disclaims copyright to this source code. In place of
564
-** a legal notice, here is a blessing:
565
-**
566
-** May you do good and not evil.
567
-** May you find forgiveness for yourself and forgive others.
568
-** May you share freely, never taking more than you give.
569
-**
570
-********************************************************************************
571
-** This file implements various interfaces used for console and stream I/O
572
-** by the SQLite project command-line tools, as explained in console_io.h .
573
-** Functions prefixed by "SQLITE_INTERNAL_LINKAGE" behave as described there.
574
-*/
575
-
576
-#ifndef SQLITE_CDECL
577
-# define SQLITE_CDECL
578
-#endif
579
-
580
-#ifndef SHELL_NO_SYSINC
581
-# include <stdarg.h>
582
-# include <string.h>
583
-# include <stdlib.h>
584
-# include <limits.h>
585
-# include <assert.h>
586
-/* # include "sqlite3.h" */
587
-#endif
588
-#ifndef HAVE_CONSOLE_IO_H
589
-# include "console_io.h"
590
-#endif
591
-#if defined(_MSC_VER)
592
-# pragma warning(disable : 4204)
593
-#endif
594
-
595
-#ifndef SQLITE_CIO_NO_TRANSLATE
596
-# if (defined(_WIN32) || defined(WIN32)) && !SQLITE_OS_WINRT
597
-# ifndef SHELL_NO_SYSINC
598
-# include <io.h>
599
-# include <fcntl.h>
600
-# undef WIN32_LEAN_AND_MEAN
601
-# define WIN32_LEAN_AND_MEAN
602
-# include <windows.h>
603
-# endif
604
-# define CIO_WIN_WC_XLATE 1 /* Use WCHAR Windows APIs for console I/O */
605
-# else
606
-# ifndef SHELL_NO_SYSINC
607
-# include <unistd.h>
608
-# endif
609
-# define CIO_WIN_WC_XLATE 0 /* Use plain C library stream I/O at console */
610
-# endif
611
-#else
612
-# define CIO_WIN_WC_XLATE 0 /* Not exposing translation routines at all */
613
-#endif
614
-
615
-#if CIO_WIN_WC_XLATE
616
-static HANDLE handleOfFile(FILE *pf){
617
- int fileDesc = _fileno(pf);
618
- union { intptr_t osfh; HANDLE fh; } fid = {
619
- (fileDesc>=0)? _get_osfhandle(fileDesc) : (intptr_t)INVALID_HANDLE_VALUE
620
- };
621
- return fid.fh;
622
-}
623
-#endif
624
-
625
-#ifndef SQLITE_CIO_NO_TRANSLATE
626
-typedef struct PerStreamTags {
627
-# if CIO_WIN_WC_XLATE
628
- HANDLE hx;
629
- DWORD consMode;
630
- char acIncomplete[4];
631
-# else
632
- short reachesConsole;
633
-# endif
634
- FILE *pf;
635
-} PerStreamTags;
636
-
637
-/* Define NULL-like value for things which can validly be 0. */
638
-# define SHELL_INVALID_FILE_PTR ((FILE *)~0)
639
-# if CIO_WIN_WC_XLATE
640
-# define SHELL_INVALID_CONS_MODE 0xFFFF0000
641
-# endif
642
-
643
-# if CIO_WIN_WC_XLATE
644
-# define PST_INITIALIZER { INVALID_HANDLE_VALUE, SHELL_INVALID_CONS_MODE, \
645
- {0,0,0,0}, SHELL_INVALID_FILE_PTR }
646
-# else
647
-# define PST_INITIALIZER { 0, SHELL_INVALID_FILE_PTR }
648
-# endif
649
-
650
-/* Quickly say whether a known output is going to the console. */
651
-# if CIO_WIN_WC_XLATE
652
-static short pstReachesConsole(PerStreamTags *ppst){
653
- return (ppst->hx != INVALID_HANDLE_VALUE);
654
-}
655
-# else
656
-# define pstReachesConsole(ppst) 0
657
-# endif
658
-
659
-# if CIO_WIN_WC_XLATE
660
-static void restoreConsoleArb(PerStreamTags *ppst){
661
- if( pstReachesConsole(ppst) ) SetConsoleMode(ppst->hx, ppst->consMode);
662
-}
663
-# else
664
-# define restoreConsoleArb(ppst)
665
-# endif
666
-
667
-/* Say whether FILE* appears to be a console, collect associated info. */
668
-static short streamOfConsole(FILE *pf, /* out */ PerStreamTags *ppst){
669
-# if CIO_WIN_WC_XLATE
670
- short rv = 0;
671
- DWORD dwCM = SHELL_INVALID_CONS_MODE;
672
- HANDLE fh = handleOfFile(pf);
673
- ppst->pf = pf;
674
- if( INVALID_HANDLE_VALUE != fh ){
675
- rv = (GetFileType(fh) == FILE_TYPE_CHAR && GetConsoleMode(fh,&dwCM));
676
- }
677
- ppst->hx = (rv)? fh : INVALID_HANDLE_VALUE;
678
- ppst->consMode = dwCM;
679
- return rv;
680
-# else
681
- ppst->pf = pf;
682
- ppst->reachesConsole = ( (short)isatty(fileno(pf)) );
683
- return ppst->reachesConsole;
684
-# endif
685
-}
686
-
687
-# ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
688
-# define ENABLE_VIRTUAL_TERMINAL_PROCESSING (0x4)
689
-# endif
690
-
691
-# if CIO_WIN_WC_XLATE
692
-/* Define console modes for use with the Windows Console API. */
693
-# define SHELL_CONI_MODE \
694
- (ENABLE_ECHO_INPUT | ENABLE_INSERT_MODE | ENABLE_LINE_INPUT | 0x80 \
695
- | ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS | ENABLE_PROCESSED_INPUT)
696
-# define SHELL_CONO_MODE (ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT \
697
- | ENABLE_VIRTUAL_TERMINAL_PROCESSING)
698
-# endif
699
-
700
-typedef struct ConsoleInfo {
701
- PerStreamTags pstSetup[3];
702
- PerStreamTags pstDesignated[3];
703
- StreamsAreConsole sacSetup;
704
-} ConsoleInfo;
705
-
706
-static short isValidStreamInfo(PerStreamTags *ppst){
707
- return (ppst->pf != SHELL_INVALID_FILE_PTR);
708
-}
709
-
710
-static ConsoleInfo consoleInfo = {
711
- { /* pstSetup */ PST_INITIALIZER, PST_INITIALIZER, PST_INITIALIZER },
712
- { /* pstDesignated[] */ PST_INITIALIZER, PST_INITIALIZER, PST_INITIALIZER },
713
- SAC_NoConsole /* sacSetup */
714
-};
715
-
716
-SQLITE_INTERNAL_LINKAGE FILE* invalidFileStream = (FILE *)~0;
717
-
718
-# if CIO_WIN_WC_XLATE
719
-static void maybeSetupAsConsole(PerStreamTags *ppst, short odir){
720
- if( pstReachesConsole(ppst) ){
721
- DWORD cm = odir? SHELL_CONO_MODE : SHELL_CONI_MODE;
722
- SetConsoleMode(ppst->hx, cm);
723
- }
724
-}
725
-# else
726
-# define maybeSetupAsConsole(ppst,odir)
727
-# endif
728
-
729
-SQLITE_INTERNAL_LINKAGE void consoleRenewSetup(void){
730
-# if CIO_WIN_WC_XLATE
731
- int ix = 0;
732
- while( ix < 6 ){
733
- PerStreamTags *ppst = (ix<3)?
734
- &consoleInfo.pstSetup[ix] : &consoleInfo.pstDesignated[ix-3];
735
- maybeSetupAsConsole(ppst, (ix % 3)>0);
736
- ++ix;
737
- }
738
-# endif
739
-}
740
-
741
-SQLITE_INTERNAL_LINKAGE StreamsAreConsole
742
-consoleClassifySetup( FILE *pfIn, FILE *pfOut, FILE *pfErr ){
743
- StreamsAreConsole rv = SAC_NoConsole;
744
- FILE* apf[3] = { pfIn, pfOut, pfErr };
745
- int ix;
746
- for( ix = 2; ix >= 0; --ix ){
747
- PerStreamTags *ppst = &consoleInfo.pstSetup[ix];
748
- if( streamOfConsole(apf[ix], ppst) ){
749
- rv |= (SAC_InConsole<<ix);
750
- }
751
- consoleInfo.pstDesignated[ix] = *ppst;
752
- if( ix > 0 ) fflush(apf[ix]);
753
- }
754
- consoleInfo.sacSetup = rv;
755
- consoleRenewSetup();
756
- return rv;
757
-}
758
-
759
-SQLITE_INTERNAL_LINKAGE void SQLITE_CDECL consoleRestore( void ){
760
-# if CIO_WIN_WC_XLATE
761
- static ConsoleInfo *pci = &consoleInfo;
762
- if( pci->sacSetup ){
763
- int ix;
764
- for( ix=0; ix<3; ++ix ){
765
- if( pci->sacSetup & (SAC_InConsole<<ix) ){
766
- PerStreamTags *ppst = &pci->pstSetup[ix];
767
- SetConsoleMode(ppst->hx, ppst->consMode);
768
- }
769
- }
770
- }
771
-# endif
772
-}
773
-#endif /* !defined(SQLITE_CIO_NO_TRANSLATE) */
774
-
775
-#ifdef SQLITE_CIO_INPUT_REDIR
776
-/* Say whether given FILE* is among those known, via either
777
-** consoleClassifySetup() or set{Output,Error}Stream, as
778
-** readable, and return an associated PerStreamTags pointer
779
-** if so. Otherwise, return 0.
780
-*/
781
-static PerStreamTags * isKnownReadable(FILE *pf){
782
- static PerStreamTags *apst[] = {
783
- &consoleInfo.pstDesignated[0], &consoleInfo.pstSetup[0], 0
784
- };
785
- int ix = 0;
786
- do {
787
- if( apst[ix]->pf == pf ) break;
788
- } while( apst[++ix] != 0 );
789
- return apst[ix];
790
-}
791
-#endif
792
-
793
-#ifndef SQLITE_CIO_NO_TRANSLATE
794
-/* Say whether given FILE* is among those known, via either
795
-** consoleClassifySetup() or set{Output,Error}Stream, as
796
-** writable, and return an associated PerStreamTags pointer
797
-** if so. Otherwise, return 0.
798
-*/
799
-static PerStreamTags * isKnownWritable(FILE *pf){
800
- static PerStreamTags *apst[] = {
801
- &consoleInfo.pstDesignated[1], &consoleInfo.pstDesignated[2],
802
- &consoleInfo.pstSetup[1], &consoleInfo.pstSetup[2], 0
803
- };
804
- int ix = 0;
805
- do {
806
- if( apst[ix]->pf == pf ) break;
807
- } while( apst[++ix] != 0 );
808
- return apst[ix];
809
-}
810
-
811
-static FILE *designateEmitStream(FILE *pf, unsigned chix){
812
- FILE *rv = consoleInfo.pstDesignated[chix].pf;
813
- if( pf == invalidFileStream ) return rv;
814
- else{
815
- /* Setting a possibly new output stream. */
816
- PerStreamTags *ppst = isKnownWritable(pf);
817
- if( ppst != 0 ){
818
- PerStreamTags pst = *ppst;
819
- consoleInfo.pstDesignated[chix] = pst;
820
- }else streamOfConsole(pf, &consoleInfo.pstDesignated[chix]);
821
- }
822
- return rv;
823
-}
824
-
825
-SQLITE_INTERNAL_LINKAGE FILE *setOutputStream(FILE *pf){
826
- return designateEmitStream(pf, 1);
827
-}
828
-# ifdef CONSIO_SET_ERROR_STREAM
829
-SQLITE_INTERNAL_LINKAGE FILE *setErrorStream(FILE *pf){
830
- return designateEmitStream(pf, 2);
831
-}
832
-# endif
833
-#endif /* !defined(SQLITE_CIO_NO_TRANSLATE) */
834
-
835
-#ifndef SQLITE_CIO_NO_SETMODE
836
-# if CIO_WIN_WC_XLATE
837
-static void setModeFlushQ(FILE *pf, short bFlush, int mode){
838
- if( bFlush ) fflush(pf);
839
- _setmode(_fileno(pf), mode);
840
-}
841
-# else
842
-# define setModeFlushQ(f, b, m) if(b) fflush(f)
843
-# endif
844
-
845
-SQLITE_INTERNAL_LINKAGE void setBinaryMode(FILE *pf, short bFlush){
846
- setModeFlushQ(pf, bFlush, _O_BINARY);
847
-}
848
-SQLITE_INTERNAL_LINKAGE void setTextMode(FILE *pf, short bFlush){
849
- setModeFlushQ(pf, bFlush, _O_TEXT);
850
-}
851
-# undef setModeFlushQ
852
-
853
-#else /* defined(SQLITE_CIO_NO_SETMODE) */
854
-# define setBinaryMode(f, bFlush) do{ if((bFlush)) fflush(f); }while(0)
855
-# define setTextMode(f, bFlush) do{ if((bFlush)) fflush(f); }while(0)
856
-#endif /* defined(SQLITE_CIO_NO_SETMODE) */
857
-
858
-#ifndef SQLITE_CIO_NO_TRANSLATE
859
-# if CIO_WIN_WC_XLATE
860
-/* Write buffer cBuf as output to stream known to reach console,
861
-** limited to ncTake char's. Return ncTake on success, else 0. */
862
-static int conZstrEmit(PerStreamTags *ppst, const char *z, int ncTake){
863
- int rv = 0;
864
- if( z!=NULL ){
865
- int nwc = MultiByteToWideChar(CP_UTF8,0, z,ncTake, 0,0);
866
- if( nwc > 0 ){
867
- WCHAR *zw = sqlite3_malloc64(nwc*sizeof(WCHAR));
868
- if( zw!=NULL ){
869
- nwc = MultiByteToWideChar(CP_UTF8,0, z,ncTake, zw,nwc);
870
- if( nwc > 0 ){
871
- /* Translation from UTF-8 to UTF-16, then WCHARs out. */
872
- if( WriteConsoleW(ppst->hx, zw,nwc, 0, NULL) ){
873
- rv = ncTake;
874
- }
875
- }
876
- sqlite3_free(zw);
877
- }
878
- }
879
- }
880
- return rv;
881
-}
882
-
883
-/* For {f,o,e}PrintfUtf8() when stream is known to reach console. */
884
-static int conioVmPrintf(PerStreamTags *ppst, const char *zFormat, va_list ap){
885
- char *z = sqlite3_vmprintf(zFormat, ap);
886
- if( z ){
887
- int rv = conZstrEmit(ppst, z, (int)strlen(z));
888
- sqlite3_free(z);
889
- return rv;
890
- }else return 0;
891
-}
892
-# endif /* CIO_WIN_WC_XLATE */
893
-
894
-# ifdef CONSIO_GET_EMIT_STREAM
895
-static PerStreamTags * getDesignatedEmitStream(FILE *pf, unsigned chix,
896
- PerStreamTags *ppst){
897
- PerStreamTags *rv = isKnownWritable(pf);
898
- short isValid = (rv!=0)? isValidStreamInfo(rv) : 0;
899
- if( rv != 0 && isValid ) return rv;
900
- streamOfConsole(pf, ppst);
901
- return ppst;
902
-}
903
-# endif
904
-
905
-/* Get stream info, either for designated output or error stream when
906
-** chix equals 1 or 2, or for an arbitrary stream when chix == 0.
907
-** In either case, ppst references a caller-owned PerStreamTags
908
-** struct which may be filled in if none of the known writable
909
-** streams is being held by consoleInfo. The ppf parameter is a
910
-** byref output when chix!=0 and a byref input when chix==0.
911
- */
912
-static PerStreamTags *
913
-getEmitStreamInfo(unsigned chix, PerStreamTags *ppst,
914
- /* in/out */ FILE **ppf){
915
- PerStreamTags *ppstTry;
916
- FILE *pfEmit;
917
- if( chix > 0 ){
918
- ppstTry = &consoleInfo.pstDesignated[chix];
919
- if( !isValidStreamInfo(ppstTry) ){
920
- ppstTry = &consoleInfo.pstSetup[chix];
921
- pfEmit = ppst->pf;
922
- }else pfEmit = ppstTry->pf;
923
- if( !isValidStreamInfo(ppstTry) ){
924
- pfEmit = (chix > 1)? stderr : stdout;
925
- ppstTry = ppst;
926
- streamOfConsole(pfEmit, ppstTry);
927
- }
928
- *ppf = pfEmit;
929
- }else{
930
- ppstTry = isKnownWritable(*ppf);
931
- if( ppstTry != 0 ) return ppstTry;
932
- streamOfConsole(*ppf, ppst);
933
- return ppst;
934
- }
935
- return ppstTry;
936
-}
937
-
938
-SQLITE_INTERNAL_LINKAGE int oPrintfUtf8(const char *zFormat, ...){
939
- va_list ap;
940
- int rv;
941
- FILE *pfOut;
942
- PerStreamTags pst = PST_INITIALIZER; /* for unknown streams */
943
-# if CIO_WIN_WC_XLATE
944
- PerStreamTags *ppst = getEmitStreamInfo(1, &pst, &pfOut);
945
-# else
946
- getEmitStreamInfo(1, &pst, &pfOut);
947
-# endif
948
- assert(zFormat!=0);
949
- va_start(ap, zFormat);
950
-# if CIO_WIN_WC_XLATE
951
- if( pstReachesConsole(ppst) ){
952
- rv = conioVmPrintf(ppst, zFormat, ap);
953
- }else{
954
-# endif
955
- rv = vfprintf(pfOut, zFormat, ap);
956
-# if CIO_WIN_WC_XLATE
957
- }
958
-# endif
959
- va_end(ap);
960
- return rv;
961
-}
962
-
963
-SQLITE_INTERNAL_LINKAGE int ePrintfUtf8(const char *zFormat, ...){
964
- va_list ap;
965
- int rv;
966
- FILE *pfErr;
967
- PerStreamTags pst = PST_INITIALIZER; /* for unknown streams */
968
-# if CIO_WIN_WC_XLATE
969
- PerStreamTags *ppst = getEmitStreamInfo(2, &pst, &pfErr);
970
-# else
971
- getEmitStreamInfo(2, &pst, &pfErr);
972
-# endif
973
- assert(zFormat!=0);
974
- va_start(ap, zFormat);
975
-# if CIO_WIN_WC_XLATE
976
- if( pstReachesConsole(ppst) ){
977
- rv = conioVmPrintf(ppst, zFormat, ap);
978
- }else{
979
-# endif
980
- rv = vfprintf(pfErr, zFormat, ap);
981
-# if CIO_WIN_WC_XLATE
982
- }
983
-# endif
984
- va_end(ap);
985
- return rv;
986
-}
987
-
988
-SQLITE_INTERNAL_LINKAGE int fPrintfUtf8(FILE *pfO, const char *zFormat, ...){
989
- va_list ap;
990
- int rv;
991
- PerStreamTags pst = PST_INITIALIZER; /* for unknown streams */
992
-# if CIO_WIN_WC_XLATE
993
- PerStreamTags *ppst = getEmitStreamInfo(0, &pst, &pfO);
994
-# else
995
- getEmitStreamInfo(0, &pst, &pfO);
996
-# endif
997
- assert(zFormat!=0);
998
- va_start(ap, zFormat);
999
-# if CIO_WIN_WC_XLATE
1000
- if( pstReachesConsole(ppst) ){
1001
- maybeSetupAsConsole(ppst, 1);
1002
- rv = conioVmPrintf(ppst, zFormat, ap);
1003
- if( 0 == isKnownWritable(ppst->pf) ) restoreConsoleArb(ppst);
1004
- }else{
1005
-# endif
1006
- rv = vfprintf(pfO, zFormat, ap);
1007
-# if CIO_WIN_WC_XLATE
1008
- }
1009
-# endif
1010
- va_end(ap);
1011
- return rv;
1012
-}
1013
-
1014
-SQLITE_INTERNAL_LINKAGE int fPutsUtf8(const char *z, FILE *pfO){
1015
- PerStreamTags pst = PST_INITIALIZER; /* for unknown streams */
1016
-# if CIO_WIN_WC_XLATE
1017
- PerStreamTags *ppst = getEmitStreamInfo(0, &pst, &pfO);
1018
-# else
1019
- getEmitStreamInfo(0, &pst, &pfO);
1020
-# endif
1021
- assert(z!=0);
1022
-# if CIO_WIN_WC_XLATE
1023
- if( pstReachesConsole(ppst) ){
1024
- int rv;
1025
- maybeSetupAsConsole(ppst, 1);
1026
- rv = conZstrEmit(ppst, z, (int)strlen(z));
1027
- if( 0 == isKnownWritable(ppst->pf) ) restoreConsoleArb(ppst);
1028
- return rv;
1029
- }else {
1030
-# endif
1031
- return (fputs(z, pfO)<0)? 0 : (int)strlen(z);
1032
-# if CIO_WIN_WC_XLATE
1033
- }
1034
-# endif
1035
-}
1036
-
1037
-SQLITE_INTERNAL_LINKAGE int ePutsUtf8(const char *z){
1038
- FILE *pfErr;
1039
- PerStreamTags pst = PST_INITIALIZER; /* for unknown streams */
1040
-# if CIO_WIN_WC_XLATE
1041
- PerStreamTags *ppst = getEmitStreamInfo(2, &pst, &pfErr);
1042
-# else
1043
- getEmitStreamInfo(2, &pst, &pfErr);
1044
-# endif
1045
- assert(z!=0);
1046
-# if CIO_WIN_WC_XLATE
1047
- if( pstReachesConsole(ppst) ) return conZstrEmit(ppst, z, (int)strlen(z));
1048
- else {
1049
-# endif
1050
- return (fputs(z, pfErr)<0)? 0 : (int)strlen(z);
1051
-# if CIO_WIN_WC_XLATE
1052
- }
1053
-# endif
1054
-}
1055
-
1056
-SQLITE_INTERNAL_LINKAGE int oPutsUtf8(const char *z){
1057
- FILE *pfOut;
1058
- PerStreamTags pst = PST_INITIALIZER; /* for unknown streams */
1059
-# if CIO_WIN_WC_XLATE
1060
- PerStreamTags *ppst = getEmitStreamInfo(1, &pst, &pfOut);
1061
-# else
1062
- getEmitStreamInfo(1, &pst, &pfOut);
1063
-# endif
1064
- assert(z!=0);
1065
-# if CIO_WIN_WC_XLATE
1066
- if( pstReachesConsole(ppst) ) return conZstrEmit(ppst, z, (int)strlen(z));
1067
- else {
1068
-# endif
1069
- return (fputs(z, pfOut)<0)? 0 : (int)strlen(z);
1070
-# if CIO_WIN_WC_XLATE
1071
- }
1072
-# endif
1073
-}
1074
-
1075
-#endif /* !defined(SQLITE_CIO_NO_TRANSLATE) */
1076
-
1077
-#if !(defined(SQLITE_CIO_NO_UTF8SCAN) && defined(SQLITE_CIO_NO_TRANSLATE))
1078
-/* Skip over as much z[] input char sequence as is valid UTF-8,
1079
-** limited per nAccept char's or whole characters and containing
1080
-** no char cn such that ((1<<cn) & ccm)!=0. On return, the
1081
-** sequence z:return (inclusive:exclusive) is validated UTF-8.
1082
-** Limit: nAccept>=0 => char count, nAccept<0 => character
1083
- */
1084
-SQLITE_INTERNAL_LINKAGE const char*
1085
-zSkipValidUtf8(const char *z, int nAccept, long ccm){
1086
- int ng = (nAccept<0)? -nAccept : 0;
1087
- const char *pcLimit = (nAccept>=0)? z+nAccept : 0;
1088
- assert(z!=0);
1089
- while( (pcLimit)? (z<pcLimit) : (ng-- != 0) ){
1090
- char c = *z;
1091
- if( (c & 0x80) == 0 ){
1092
- if( ccm != 0L && c < 0x20 && ((1L<<c) & ccm) != 0 ) return z;
1093
- ++z; /* ASCII */
1094
- }else if( (c & 0xC0) != 0xC0 ) return z; /* not a lead byte */
1095
- else{
1096
- const char *zt = z+1; /* Got lead byte, look at trail bytes.*/
1097
- do{
1098
- if( pcLimit && zt >= pcLimit ) return z;
1099
- else{
1100
- char ct = *zt++;
1101
- if( ct==0 || (zt-z)>4 || (ct & 0xC0)!=0x80 ){
1102
- /* Trailing bytes are too few, too many, or invalid. */
1103
- return z;
1104
- }
1105
- }
1106
- } while( ((c <<= 1) & 0x40) == 0x40 ); /* Eat lead byte's count. */
1107
- z = zt;
1108
- }
1109
- }
1110
- return z;
1111
-}
1112
-#endif /*!(defined(SQLITE_CIO_NO_UTF8SCAN)&&defined(SQLITE_CIO_NO_TRANSLATE))*/
1113
-
1114
-#ifndef SQLITE_CIO_NO_TRANSLATE
1115
-# ifdef CONSIO_SPUTB
1116
-SQLITE_INTERNAL_LINKAGE int
1117
-fPutbUtf8(FILE *pfO, const char *cBuf, int nAccept){
1118
- assert(pfO!=0);
1119
-# if CIO_WIN_WC_XLATE
1120
- PerStreamTags pst = PST_INITIALIZER; /* for unknown streams */
1121
- PerStreamTags *ppst = getEmitStreamInfo(0, &pst, &pfO);
1122
- if( pstReachesConsole(ppst) ){
1123
- int rv;
1124
- maybeSetupAsConsole(ppst, 1);
1125
- rv = conZstrEmit(ppst, cBuf, nAccept);
1126
- if( 0 == isKnownWritable(ppst->pf) ) restoreConsoleArb(ppst);
1127
- return rv;
1128
- }else {
1129
-# endif
1130
- return (int)fwrite(cBuf, 1, nAccept, pfO);
1131
-# if CIO_WIN_WC_XLATE
1132
- }
1133
-# endif
1134
-}
1135
-# endif
1136
-
1137
-SQLITE_INTERNAL_LINKAGE int
1138
-oPutbUtf8(const char *cBuf, int nAccept){
1139
- FILE *pfOut;
1140
- PerStreamTags pst = PST_INITIALIZER; /* for unknown streams */
1141
-# if CIO_WIN_WC_XLATE
1142
- PerStreamTags *ppst = getEmitStreamInfo(1, &pst, &pfOut);
1143
-# else
1144
- getEmitStreamInfo(1, &pst, &pfOut);
1145
-# endif
1146
-# if CIO_WIN_WC_XLATE
1147
- if( pstReachesConsole(ppst) ){
1148
- return conZstrEmit(ppst, cBuf, nAccept);
1149
- }else {
1150
-# endif
1151
- return (int)fwrite(cBuf, 1, nAccept, pfOut);
1152
-# if CIO_WIN_WC_XLATE
1153
- }
1154
-# endif
1155
-}
1156
-
1157
-/*
1158
-** Flush the given output stream. Return non-zero for success, else 0.
1159
-*/
1160
-#if !defined(SQLITE_CIO_NO_FLUSH) && !defined(SQLITE_CIO_NO_SETMODE)
1161
-SQLITE_INTERNAL_LINKAGE int
1162
-fFlushBuffer(FILE *pfOut){
1163
-# if CIO_WIN_WC_XLATE && !defined(SHELL_OMIT_FIO_DUPE)
1164
- return FlushFileBuffers(handleOfFile(pfOut))? 1 : 0;
1165
-# else
1166
- return fflush(pfOut);
1167
-# endif
1168
-}
1169
-#endif
1170
-
1171
-#if CIO_WIN_WC_XLATE \
1172
- && !defined(SHELL_OMIT_FIO_DUPE) \
1173
- && defined(SQLITE_USE_ONLY_WIN32)
1174
-static struct FileAltIds {
1175
- int fd;
1176
- HANDLE fh;
1177
-} altIdsOfFile(FILE *pf){
1178
- struct FileAltIds rv = { _fileno(pf) };
1179
- union { intptr_t osfh; HANDLE fh; } fid = {
1180
- (rv.fd>=0)? _get_osfhandle(rv.fd) : (intptr_t)INVALID_HANDLE_VALUE
1181
- };
1182
- rv.fh = fid.fh;
1183
- return rv;
1184
-}
1185
-
1186
-SQLITE_INTERNAL_LINKAGE size_t
1187
-cfWrite(const void *buf, size_t osz, size_t ocnt, FILE *pf){
1188
- size_t rv = 0;
1189
- struct FileAltIds fai = altIdsOfFile(pf);
1190
- int fmode = _setmode(fai.fd, _O_BINARY);
1191
- _setmode(fai.fd, fmode);
1192
- while( rv < ocnt ){
1193
- size_t nbo = osz;
1194
- while( nbo > 0 ){
1195
- DWORD dwno = (nbo>(1L<<24))? 1L<<24 : (DWORD)nbo;
1196
- BOOL wrc = TRUE;
1197
- BOOL genCR = (fmode & _O_TEXT)!=0;
1198
- if( genCR ){
1199
- const char *pnl = (const char*)memchr(buf, '\n', nbo);
1200
- if( pnl ) nbo = pnl - (const char*)buf;
1201
- else genCR = 0;
1202
- }
1203
- if( dwno>0 ) wrc = WriteFile(fai.fh, buf, dwno, 0,0);
1204
- if( genCR && wrc ){
1205
- wrc = WriteFile(fai.fh, "\r\n", 2, 0,0);
1206
- ++dwno; /* Skip over the LF */
1207
- }
1208
- if( !wrc ) return rv;
1209
- buf = (const char*)buf + dwno;
1210
- nbo += dwno;
1211
- }
1212
- ++rv;
1213
- }
1214
- return rv;
1215
-}
1216
-
1217
-SQLITE_INTERNAL_LINKAGE char *
1218
-cfGets(char *cBuf, int n, FILE *pf){
1219
- int nci = 0;
1220
- struct FileAltIds fai = altIdsOfFile(pf);
1221
- int fmode = _setmode(fai.fd, _O_BINARY);
1222
- BOOL eatCR = (fmode & _O_TEXT)!=0;
1223
- _setmode(fai.fd, fmode);
1224
- while( nci < n-1 ){
1225
- DWORD nr;
1226
- if( !ReadFile(fai.fh, cBuf+nci, 1, &nr, 0) || nr==0 ) break;
1227
- if( nr>0 && (!eatCR || cBuf[nci]!='\r') ) nci += nr;
1228
- }
1229
- if( nci < n ) cBuf[nci] = 0;
1230
- return (nci>0)? cBuf : 0;
1231
-}
1232
-# else
1233
-# define cfWrite(b,os,no,f) fwrite(b,os,no,f)
1234
-# define cfGets(b,n,f) fgets(b,n,f)
1235
-# endif
1236
-
1237
-# ifdef CONSIO_EPUTB
1238
-SQLITE_INTERNAL_LINKAGE int
1239
-ePutbUtf8(const char *cBuf, int nAccept){
1240
- FILE *pfErr;
1241
- PerStreamTags pst = PST_INITIALIZER; /* for unknown streams */
1242
- PerStreamTags *ppst = getEmitStreamInfo(2, &pst, &pfErr);
1243
-# if CIO_WIN_WC_XLATE
1244
- if( pstReachesConsole(ppst) ){
1245
- return conZstrEmit(ppst, cBuf, nAccept);
1246
- }else {
1247
-# endif
1248
- return (int)cfWrite(cBuf, 1, nAccept, pfErr);
1249
-# if CIO_WIN_WC_XLATE
1250
- }
1251
-# endif
1252
-}
1253
-# endif /* defined(CONSIO_EPUTB) */
1254
-
1255
-SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn){
1256
- if( pfIn==0 ) pfIn = stdin;
1257
-# if CIO_WIN_WC_XLATE
1258
- if( pfIn == consoleInfo.pstSetup[0].pf
1259
- && (consoleInfo.sacSetup & SAC_InConsole)!=0 ){
1260
-# if CIO_WIN_WC_XLATE==1
1261
-# define SHELL_GULP 150 /* Count of WCHARS to be gulped at a time */
1262
- WCHAR wcBuf[SHELL_GULP+1];
1263
- int lend = 0, noc = 0;
1264
- if( ncMax > 0 ) cBuf[0] = 0;
1265
- while( noc < ncMax-8-1 && !lend ){
1266
- /* There is room for at least 2 more characters and a 0-terminator. */
1267
- int na = (ncMax > SHELL_GULP*4+1 + noc)? SHELL_GULP : (ncMax-1 - noc)/4;
1268
-# undef SHELL_GULP
1269
- DWORD nbr = 0;
1270
- BOOL bRC = ReadConsoleW(consoleInfo.pstSetup[0].hx, wcBuf, na, &nbr, 0);
1271
- if( bRC && nbr>0 && (wcBuf[nbr-1]&0xF800)==0xD800 ){
1272
- /* Last WHAR read is first of a UTF-16 surrogate pair. Grab its mate. */
1273
- DWORD nbrx;
1274
- bRC &= ReadConsoleW(consoleInfo.pstSetup[0].hx, wcBuf+nbr, 1, &nbrx, 0);
1275
- if( bRC ) nbr += nbrx;
1276
- }
1277
- if( !bRC || (noc==0 && nbr==0) ) return 0;
1278
- if( nbr > 0 ){
1279
- int nmb = WideCharToMultiByte(CP_UTF8, 0, wcBuf,nbr,0,0,0,0);
1280
- if( nmb != 0 && noc+nmb <= ncMax ){
1281
- int iseg = noc;
1282
- nmb = WideCharToMultiByte(CP_UTF8, 0, wcBuf,nbr,cBuf+noc,nmb,0,0);
1283
- noc += nmb;
1284
- /* Fixup line-ends as coded by Windows for CR (or "Enter".)
1285
- ** This is done without regard for any setMode{Text,Binary}()
1286
- ** call that might have been done on the interactive input.
1287
- */
1288
- if( noc > 0 ){
1289
- if( cBuf[noc-1]=='\n' ){
1290
- lend = 1;
1291
- if( noc > 1 && cBuf[noc-2]=='\r' ) cBuf[--noc-1] = '\n';
1292
- }
1293
- }
1294
- /* Check for ^Z (anywhere in line) too, to act as EOF. */
1295
- while( iseg < noc ){
1296
- if( cBuf[iseg]=='\x1a' ){
1297
- noc = iseg; /* Chop ^Z and anything following. */
1298
- lend = 1; /* Counts as end of line too. */
1299
- break;
1300
- }
1301
- ++iseg;
1302
- }
1303
- }else break; /* Drop apparent garbage in. (Could assert.) */
1304
- }else break;
1305
- }
1306
- /* If got nothing, (after ^Z chop), must be at end-of-file. */
1307
- if( noc > 0 ){
1308
- cBuf[noc] = 0;
1309
- return cBuf;
1310
- }else return 0;
1311
-# endif
1312
- }else{
1313
-# endif
1314
- return cfGets(cBuf, ncMax, pfIn);
1315
-# if CIO_WIN_WC_XLATE
1316
- }
1317
-# endif
1318
-}
1319
-#endif /* !defined(SQLITE_CIO_NO_TRANSLATE) */
1320
-
1321
-#if defined(_MSC_VER)
1322
-# pragma warning(default : 4204)
1323
-#endif
1324
-
1325
-#undef SHELL_INVALID_FILE_PTR
1326
-
1327
-/************************* End ../ext/consio/console_io.c ********************/
1328
-
1329
-#ifndef SQLITE_SHELL_FIDDLE
1330
-
1331
-/* From here onward, fgets() is redirected to the console_io library. */
1332
-# define fgets(b,n,f) fGetsUtf8(b,n,f)
1333
-/*
1334
- * Define macros for emitting output text in various ways:
1335
- * sputz(s, z) => emit 0-terminated string z to given stream s
1336
- * sputf(s, f, ...) => emit varargs per format f to given stream s
1337
- * oputz(z) => emit 0-terminated string z to default stream
1338
- * oputf(f, ...) => emit varargs per format f to default stream
1339
- * eputz(z) => emit 0-terminated string z to error stream
1340
- * eputf(f, ...) => emit varargs per format f to error stream
1341
- * oputb(b, n) => emit char buffer b[0..n-1] to default stream
1342
- *
1343
- * Note that the default stream is whatever has been last set via:
1344
- * setOutputStream(FILE *pf)
1345
- * This is normally the stream that CLI normal output goes to.
1346
- * For the stand-alone CLI, it is stdout with no .output redirect.
1347
- *
1348
- * The ?putz(z) forms are required for the Fiddle builds for string literal
1349
- * output, in aid of enforcing format string to argument correspondence.
1350
- */
1351
-# define sputz(s,z) fPutsUtf8(z,s)
1352
-# define sputf fPrintfUtf8
1353
-# define oputz(z) oPutsUtf8(z)
1354
-# define oputf oPrintfUtf8
1355
-# define eputz(z) ePutsUtf8(z)
1356
-# define eputf ePrintfUtf8
1357
-# define oputb(buf,na) oPutbUtf8(buf,na)
1358
-# define fflush(s) fFlushBuffer(s);
1359
-
1360
-#else
1361
-/* For Fiddle, all console handling and emit redirection is omitted. */
1362
-/* These next 3 macros are for emitting formatted output. When complaints
1363
- * from the WASM build are issued for non-formatted output, when a mere
1364
- * string literal is to be emitted, the ?putz(z) forms should be used.
1365
- * (This permits compile-time checking of format string / argument mismatch.)
1366
- */
1367
-# define oputf(fmt, ...) printf(fmt,__VA_ARGS__)
1368
-# define eputf(fmt, ...) fprintf(stderr,fmt,__VA_ARGS__)
1369
-# define sputf(fp,fmt, ...) fprintf(fp,fmt,__VA_ARGS__)
1370
-/* These next 3 macros are for emitting simple string literals. */
1371
-# define oputz(z) fputs(z,stdout)
1372
-# define eputz(z) fputs(z,stderr)
1373
-# define sputz(fp,z) fputs(z,fp)
1374
-# define oputb(buf,na) fwrite(buf,1,na,stdout)
1375
-# undef fflush
1376
-#endif
624
+
625
+#define eputz(z) sqlite3_fputs(z,stderr)
626
+#define sputz(fp,z) sqlite3_fputs(z,fp)
1377627
1378628
/* True if the timer is enabled */
1379629
static int enableTimer = 0;
1380630
1381631
/* A version of strcmp() that works with NULL values */
@@ -1416,10 +666,11 @@
1416666
struct timeval ru_utime; /* user CPU time used */
1417667
struct timeval ru_stime; /* system CPU time used */
1418668
};
1419669
#define getrusage(A,B) memset(B,0,sizeof(*B))
1420670
#endif
671
+
1421672
1422673
/* Saved resource information for the beginning of an operation */
1423674
static struct rusage sBegin; /* CPU time at start */
1424675
static sqlite3_int64 iBegin; /* Wall-clock time at start */
1425676
@@ -1440,24 +691,24 @@
1440691
}
1441692
1442693
/*
1443694
** Print the timing results.
1444695
*/
1445
-static void endTimer(void){
696
+static void endTimer(FILE *out){
1446697
if( enableTimer ){
1447698
sqlite3_int64 iEnd = timeOfDay();
1448699
struct rusage sEnd;
1449700
getrusage(RUSAGE_SELF, &sEnd);
1450
- sputf(stdout, "Run Time: real %.3f user %f sys %f\n",
701
+ sqlite3_fprintf(out, "Run Time: real %.3f user %f sys %f\n",
1451702
(iEnd - iBegin)*0.001,
1452703
timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),
1453704
timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));
1454705
}
1455706
}
1456707
1457708
#define BEGIN_TIMER beginTimer()
1458
-#define END_TIMER endTimer()
709
+#define END_TIMER(X) endTimer(X)
1459710
#define HAS_TIMER 1
1460711
1461712
#elif (defined(_WIN32) || defined(WIN32))
1462713
1463714
/* Saved resource information for the beginning of an operation */
@@ -1519,29 +770,29 @@
1519770
}
1520771
1521772
/*
1522773
** Print the timing results.
1523774
*/
1524
-static void endTimer(void){
775
+static void endTimer(FILE *out){
1525776
if( enableTimer && getProcessTimesAddr){
1526777
FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd;
1527778
sqlite3_int64 ftWallEnd = timeOfDay();
1528779
getProcessTimesAddr(hProcess,&ftCreation,&ftExit,&ftKernelEnd,&ftUserEnd);
1529
- sputf(stdout, "Run Time: real %.3f user %f sys %f\n",
780
+ sqlite3_fprintf(out, "Run Time: real %.3f user %f sys %f\n",
1530781
(ftWallEnd - ftWallBegin)*0.001,
1531782
timeDiff(&ftUserBegin, &ftUserEnd),
1532783
timeDiff(&ftKernelBegin, &ftKernelEnd));
1533784
}
1534785
}
1535786
1536787
#define BEGIN_TIMER beginTimer()
1537
-#define END_TIMER endTimer()
788
+#define END_TIMER(X) endTimer(X)
1538789
#define HAS_TIMER hasTimer()
1539790
1540791
#else
1541792
#define BEGIN_TIMER
1542
-#define END_TIMER
793
+#define END_TIMER(X) /*no-op*/
1543794
#define HAS_TIMER 0
1544795
#endif
1545796
1546797
/*
1547798
** Used to prevent warnings about unused parameters
@@ -1738,41 +989,216 @@
1738989
char *z;
1739990
if( iotrace==0 ) return;
1740991
va_start(ap, zFormat);
1741992
z = sqlite3_vmprintf(zFormat, ap);
1742993
va_end(ap);
1743
- sputf(iotrace, "%s", z);
994
+ sqlite3_fprintf(iotrace, "%s", z);
1744995
sqlite3_free(z);
1745996
}
1746997
#endif
1747998
999
+/* Lookup table to estimate the number of columns consumed by a Unicode
1000
+** character.
1001
+*/
1002
+static const struct {
1003
+ unsigned char w; /* Width of the character in columns */
1004
+ int iFirst; /* First character in a span having this width */
1005
+} aUWidth[] = {
1006
+ /* {1, 0x00000}, */
1007
+ {0, 0x00300}, {1, 0x00370}, {0, 0x00483}, {1, 0x00487}, {0, 0x00488},
1008
+ {1, 0x0048a}, {0, 0x00591}, {1, 0x005be}, {0, 0x005bf}, {1, 0x005c0},
1009
+ {0, 0x005c1}, {1, 0x005c3}, {0, 0x005c4}, {1, 0x005c6}, {0, 0x005c7},
1010
+ {1, 0x005c8}, {0, 0x00600}, {1, 0x00604}, {0, 0x00610}, {1, 0x00616},
1011
+ {0, 0x0064b}, {1, 0x0065f}, {0, 0x00670}, {1, 0x00671}, {0, 0x006d6},
1012
+ {1, 0x006e5}, {0, 0x006e7}, {1, 0x006e9}, {0, 0x006ea}, {1, 0x006ee},
1013
+ {0, 0x0070f}, {1, 0x00710}, {0, 0x00711}, {1, 0x00712}, {0, 0x00730},
1014
+ {1, 0x0074b}, {0, 0x007a6}, {1, 0x007b1}, {0, 0x007eb}, {1, 0x007f4},
1015
+ {0, 0x00901}, {1, 0x00903}, {0, 0x0093c}, {1, 0x0093d}, {0, 0x00941},
1016
+ {1, 0x00949}, {0, 0x0094d}, {1, 0x0094e}, {0, 0x00951}, {1, 0x00955},
1017
+ {0, 0x00962}, {1, 0x00964}, {0, 0x00981}, {1, 0x00982}, {0, 0x009bc},
1018
+ {1, 0x009bd}, {0, 0x009c1}, {1, 0x009c5}, {0, 0x009cd}, {1, 0x009ce},
1019
+ {0, 0x009e2}, {1, 0x009e4}, {0, 0x00a01}, {1, 0x00a03}, {0, 0x00a3c},
1020
+ {1, 0x00a3d}, {0, 0x00a41}, {1, 0x00a43}, {0, 0x00a47}, {1, 0x00a49},
1021
+ {0, 0x00a4b}, {1, 0x00a4e}, {0, 0x00a70}, {1, 0x00a72}, {0, 0x00a81},
1022
+ {1, 0x00a83}, {0, 0x00abc}, {1, 0x00abd}, {0, 0x00ac1}, {1, 0x00ac6},
1023
+ {0, 0x00ac7}, {1, 0x00ac9}, {0, 0x00acd}, {1, 0x00ace}, {0, 0x00ae2},
1024
+ {1, 0x00ae4}, {0, 0x00b01}, {1, 0x00b02}, {0, 0x00b3c}, {1, 0x00b3d},
1025
+ {0, 0x00b3f}, {1, 0x00b40}, {0, 0x00b41}, {1, 0x00b44}, {0, 0x00b4d},
1026
+ {1, 0x00b4e}, {0, 0x00b56}, {1, 0x00b57}, {0, 0x00b82}, {1, 0x00b83},
1027
+ {0, 0x00bc0}, {1, 0x00bc1}, {0, 0x00bcd}, {1, 0x00bce}, {0, 0x00c3e},
1028
+ {1, 0x00c41}, {0, 0x00c46}, {1, 0x00c49}, {0, 0x00c4a}, {1, 0x00c4e},
1029
+ {0, 0x00c55}, {1, 0x00c57}, {0, 0x00cbc}, {1, 0x00cbd}, {0, 0x00cbf},
1030
+ {1, 0x00cc0}, {0, 0x00cc6}, {1, 0x00cc7}, {0, 0x00ccc}, {1, 0x00cce},
1031
+ {0, 0x00ce2}, {1, 0x00ce4}, {0, 0x00d41}, {1, 0x00d44}, {0, 0x00d4d},
1032
+ {1, 0x00d4e}, {0, 0x00dca}, {1, 0x00dcb}, {0, 0x00dd2}, {1, 0x00dd5},
1033
+ {0, 0x00dd6}, {1, 0x00dd7}, {0, 0x00e31}, {1, 0x00e32}, {0, 0x00e34},
1034
+ {1, 0x00e3b}, {0, 0x00e47}, {1, 0x00e4f}, {0, 0x00eb1}, {1, 0x00eb2},
1035
+ {0, 0x00eb4}, {1, 0x00eba}, {0, 0x00ebb}, {1, 0x00ebd}, {0, 0x00ec8},
1036
+ {1, 0x00ece}, {0, 0x00f18}, {1, 0x00f1a}, {0, 0x00f35}, {1, 0x00f36},
1037
+ {0, 0x00f37}, {1, 0x00f38}, {0, 0x00f39}, {1, 0x00f3a}, {0, 0x00f71},
1038
+ {1, 0x00f7f}, {0, 0x00f80}, {1, 0x00f85}, {0, 0x00f86}, {1, 0x00f88},
1039
+ {0, 0x00f90}, {1, 0x00f98}, {0, 0x00f99}, {1, 0x00fbd}, {0, 0x00fc6},
1040
+ {1, 0x00fc7}, {0, 0x0102d}, {1, 0x01031}, {0, 0x01032}, {1, 0x01033},
1041
+ {0, 0x01036}, {1, 0x01038}, {0, 0x01039}, {1, 0x0103a}, {0, 0x01058},
1042
+ {1, 0x0105a}, {2, 0x01100}, {0, 0x01160}, {1, 0x01200}, {0, 0x0135f},
1043
+ {1, 0x01360}, {0, 0x01712}, {1, 0x01715}, {0, 0x01732}, {1, 0x01735},
1044
+ {0, 0x01752}, {1, 0x01754}, {0, 0x01772}, {1, 0x01774}, {0, 0x017b4},
1045
+ {1, 0x017b6}, {0, 0x017b7}, {1, 0x017be}, {0, 0x017c6}, {1, 0x017c7},
1046
+ {0, 0x017c9}, {1, 0x017d4}, {0, 0x017dd}, {1, 0x017de}, {0, 0x0180b},
1047
+ {1, 0x0180e}, {0, 0x018a9}, {1, 0x018aa}, {0, 0x01920}, {1, 0x01923},
1048
+ {0, 0x01927}, {1, 0x01929}, {0, 0x01932}, {1, 0x01933}, {0, 0x01939},
1049
+ {1, 0x0193c}, {0, 0x01a17}, {1, 0x01a19}, {0, 0x01b00}, {1, 0x01b04},
1050
+ {0, 0x01b34}, {1, 0x01b35}, {0, 0x01b36}, {1, 0x01b3b}, {0, 0x01b3c},
1051
+ {1, 0x01b3d}, {0, 0x01b42}, {1, 0x01b43}, {0, 0x01b6b}, {1, 0x01b74},
1052
+ {0, 0x01dc0}, {1, 0x01dcb}, {0, 0x01dfe}, {1, 0x01e00}, {0, 0x0200b},
1053
+ {1, 0x02010}, {0, 0x0202a}, {1, 0x0202f}, {0, 0x02060}, {1, 0x02064},
1054
+ {0, 0x0206a}, {1, 0x02070}, {0, 0x020d0}, {1, 0x020f0}, {2, 0x02329},
1055
+ {1, 0x0232b}, {2, 0x02e80}, {0, 0x0302a}, {2, 0x03030}, {1, 0x0303f},
1056
+ {2, 0x03040}, {0, 0x03099}, {2, 0x0309b}, {1, 0x0a4d0}, {0, 0x0a806},
1057
+ {1, 0x0a807}, {0, 0x0a80b}, {1, 0x0a80c}, {0, 0x0a825}, {1, 0x0a827},
1058
+ {2, 0x0ac00}, {1, 0x0d7a4}, {2, 0x0f900}, {1, 0x0fb00}, {0, 0x0fb1e},
1059
+ {1, 0x0fb1f}, {0, 0x0fe00}, {2, 0x0fe10}, {1, 0x0fe1a}, {0, 0x0fe20},
1060
+ {1, 0x0fe24}, {2, 0x0fe30}, {1, 0x0fe70}, {0, 0x0feff}, {2, 0x0ff00},
1061
+ {1, 0x0ff61}, {2, 0x0ffe0}, {1, 0x0ffe7}, {0, 0x0fff9}, {1, 0x0fffc},
1062
+ {0, 0x10a01}, {1, 0x10a04}, {0, 0x10a05}, {1, 0x10a07}, {0, 0x10a0c},
1063
+ {1, 0x10a10}, {0, 0x10a38}, {1, 0x10a3b}, {0, 0x10a3f}, {1, 0x10a40},
1064
+ {0, 0x1d167}, {1, 0x1d16a}, {0, 0x1d173}, {1, 0x1d183}, {0, 0x1d185},
1065
+ {1, 0x1d18c}, {0, 0x1d1aa}, {1, 0x1d1ae}, {0, 0x1d242}, {1, 0x1d245},
1066
+ {2, 0x20000}, {1, 0x2fffe}, {2, 0x30000}, {1, 0x3fffe}, {0, 0xe0001},
1067
+ {1, 0xe0002}, {0, 0xe0020}, {1, 0xe0080}, {0, 0xe0100}, {1, 0xe01f0}
1068
+};
1069
+
17481070
/*
1749
-** Output string zUtf to Out stream as w characters. If w is negative,
1071
+** Return an estimate of the width, in columns, for the single Unicode
1072
+** character c. For normal characters, the answer is always 1. But the
1073
+** estimate might be 0 or 2 for zero-width and double-width characters.
1074
+**
1075
+** Different display devices display unicode using different widths. So
1076
+** it is impossible to know that true display width with 100% accuracy.
1077
+** Inaccuracies in the width estimates might cause columns to be misaligned.
1078
+** Unfortunately, there is nothing we can do about that.
1079
+*/
1080
+int cli_wcwidth(int c){
1081
+ int iFirst, iLast;
1082
+
1083
+ /* Fast path for common characters */
1084
+ if( c<=0x300 ) return 1;
1085
+
1086
+ /* The general case */
1087
+ iFirst = 0;
1088
+ iLast = sizeof(aUWidth)/sizeof(aUWidth[0]) - 1;
1089
+ while( iFirst<iLast-1 ){
1090
+ int iMid = (iFirst+iLast)/2;
1091
+ int cMid = aUWidth[iMid].iFirst;
1092
+ if( cMid < c ){
1093
+ iFirst = iMid;
1094
+ }else if( cMid > c ){
1095
+ iLast = iMid - 1;
1096
+ }else{
1097
+ return aUWidth[iMid].w;
1098
+ }
1099
+ }
1100
+ if( aUWidth[iLast].iFirst > c ) return aUWidth[iFirst].w;
1101
+ return aUWidth[iLast].w;
1102
+}
1103
+
1104
+/*
1105
+** Compute the value and length of a multi-byte UTF-8 character that
1106
+** begins at z[0]. Return the length. Write the Unicode value into *pU.
1107
+**
1108
+** This routine only works for *multi-byte* UTF-8 characters.
1109
+*/
1110
+static int decodeUtf8(const unsigned char *z, int *pU){
1111
+ if( (z[0] & 0xe0)==0xc0 && (z[1] & 0xc0)==0x80 ){
1112
+ *pU = ((z[0] & 0x1f)<<6) | (z[1] & 0x3f);
1113
+ return 2;
1114
+ }
1115
+ if( (z[0] & 0xf0)==0xe0 && (z[1] & 0xc0)==0x80 && (z[2] & 0xc0)==0x80 ){
1116
+ *pU = ((z[0] & 0x0f)<<12) | ((z[1] & 0x3f)<<6) | (z[2] & 0x3f);
1117
+ return 3;
1118
+ }
1119
+ if( (z[0] & 0xf8)==0xf0 && (z[1] & 0xc0)==0x80 && (z[2] & 0xc0)==0x80
1120
+ && (z[3] & 0xc0)==0x80
1121
+ ){
1122
+ *pU = ((z[0] & 0x0f)<<18) | ((z[1] & 0x3f)<<12) | ((z[2] & 0x3f))<<6
1123
+ | (z[4] & 0x3f);
1124
+ return 4;
1125
+ }
1126
+ *pU = 0;
1127
+ return 1;
1128
+}
1129
+
1130
+
1131
+#if 0 /* NOT USED */
1132
+/*
1133
+** Return the width, in display columns, of a UTF-8 string.
1134
+**
1135
+** Each normal character counts as 1. Zero-width characters count
1136
+** as zero, and double-width characters count as 2.
1137
+*/
1138
+int cli_wcswidth(const char *z){
1139
+ const unsigned char *a = (const unsigned char*)z;
1140
+ int n = 0;
1141
+ int i = 0;
1142
+ unsigned char c;
1143
+ while( (c = a[i])!=0 ){
1144
+ if( c>=0xc0 ){
1145
+ int u;
1146
+ int len = decodeUtf8(&a[i], &u);
1147
+ i += len;
1148
+ n += cli_wcwidth(u);
1149
+ }else if( c>=' ' ){
1150
+ n++;
1151
+ i++;
1152
+ }else{
1153
+ i++;
1154
+ }
1155
+ }
1156
+ return n;
1157
+}
1158
+#endif
1159
+
1160
+/*
1161
+** Output string zUtf to stdout as w characters. If w is negative,
17501162
** then right-justify the text. W is the width in UTF-8 characters, not
17511163
** in bytes. This is different from the %*.*s specification in printf
17521164
** since with %*.*s the width is measured in bytes, not characters.
1165
+**
1166
+** Take into account zero-width and double-width Unicode characters.
1167
+** In other words, a zero-width character does not count toward the
1168
+** the w limit. A double-width character counts as two.
17531169
*/
1754
-static void utf8_width_print(int w, const char *zUtf){
1755
- int i;
1756
- int n;
1170
+static void utf8_width_print(FILE *out, int w, const char *zUtf){
1171
+ const unsigned char *a = (const unsigned char*)zUtf;
1172
+ unsigned char c;
1173
+ int i = 0;
1174
+ int n = 0;
17571175
int aw = w<0 ? -w : w;
17581176
if( zUtf==0 ) zUtf = "";
1759
- for(i=n=0; zUtf[i]; i++){
1760
- if( (zUtf[i]&0xc0)!=0x80 ){
1177
+ while( (c = a[i])!=0 ){
1178
+ if( (c&0xc0)==0xc0 ){
1179
+ int u;
1180
+ int len = decodeUtf8(a+i, &u);
1181
+ int x = cli_wcwidth(u);
1182
+ if( x+n>aw ){
1183
+ break;
1184
+ }
1185
+ i += len;
1186
+ n += x;
1187
+ }else if( n>=aw ){
1188
+ break;
1189
+ }else{
17611190
n++;
1762
- if( n==aw ){
1763
- do{ i++; }while( (zUtf[i]&0xc0)==0x80 );
1764
- break;
1765
- }
1191
+ i++;
17661192
}
17671193
}
17681194
if( n>=aw ){
1769
- oputf("%.*s", i, zUtf);
1195
+ sqlite3_fprintf(out, "%.*s", i, zUtf);
17701196
}else if( w<0 ){
1771
- oputf("%*s%s", aw-n, "", zUtf);
1197
+ sqlite3_fprintf(out, "%*s%s", aw-n, "", zUtf);
17721198
}else{
1773
- oputf("%s%*s", zUtf, aw-n, "");
1199
+ sqlite3_fprintf(out, "%s%*s", zUtf, aw-n, "");
17741200
}
17751201
}
17761202
17771203
17781204
/*
@@ -1834,11 +1260,11 @@
18341260
struct __stat64 x = {0};
18351261
# define STAT_CHR_SRC(mode) ((mode & (_S_IFCHR|_S_IFIFO|_S_IFREG))!=0)
18361262
/* On Windows, open first, then check the stream nature. This order
18371263
** is necessary because _stat() and sibs, when checking a named pipe,
18381264
** effectively break the pipe as its supplier sees it. */
1839
- FILE *rv = fopen(zFile, "rb");
1265
+ FILE *rv = sqlite3_fopen(zFile, "rb");
18401266
if( rv==0 ) return 0;
18411267
if( _fstat64(_fileno(rv), &x) != 0
18421268
|| !STAT_CHR_SRC(x.st_mode)){
18431269
fclose(rv);
18441270
rv = 0;
@@ -1848,11 +1274,11 @@
18481274
struct stat x = {0};
18491275
int rc = stat(zFile, &x);
18501276
# define STAT_CHR_SRC(mode) (S_ISREG(mode)||S_ISFIFO(mode)||S_ISCHR(mode))
18511277
if( rc!=0 ) return 0;
18521278
if( STAT_CHR_SRC(x.st_mode) ){
1853
- return fopen(zFile, "rb");
1279
+ return sqlite3_fopen(zFile, "rb");
18541280
}else{
18551281
return 0;
18561282
}
18571283
#endif
18581284
#undef STAT_CHR_SRC
@@ -1875,11 +1301,11 @@
18751301
if( n+100>nLine ){
18761302
nLine = nLine*2 + 100;
18771303
zLine = realloc(zLine, nLine);
18781304
shell_check_oom(zLine);
18791305
}
1880
- if( fgets(&zLine[n], nLine - n, in)==0 ){
1306
+ if( sqlite3_fgets(&zLine[n], nLine - n, in)==0 ){
18811307
if( n==0 ){
18821308
free(zLine);
18831309
return 0;
18841310
}
18851311
zLine[n] = 0;
@@ -2941,11 +2367,11 @@
29412367
**
29422368
******************************************************************************
29432369
**
29442370
** This SQLite extension implements functions that compute SHA3 hashes
29452371
** in the way described by the (U.S.) NIST FIPS 202 SHA-3 Standard.
2946
-** Two SQL functions are implemented:
2372
+** Three SQL functions are implemented:
29472373
**
29482374
** sha3(X,SIZE)
29492375
** sha3_agg(Y,SIZE)
29502376
** sha3_query(Z,SIZE)
29512377
**
@@ -3783,10 +3209,422 @@
37833209
}
37843210
return rc;
37853211
}
37863212
37873213
/************************* End ../ext/misc/shathree.c ********************/
3214
+/************************* Begin ../ext/misc/sha1.c ******************/
3215
+/*
3216
+** 2017-01-27
3217
+**
3218
+** The author disclaims copyright to this source code. In place of
3219
+** a legal notice, here is a blessing:
3220
+**
3221
+** May you do good and not evil.
3222
+** May you find forgiveness for yourself and forgive others.
3223
+** May you share freely, never taking more than you give.
3224
+**
3225
+******************************************************************************
3226
+**
3227
+** This SQLite extension implements functions that compute SHA1 hashes.
3228
+** Two SQL functions are implemented:
3229
+**
3230
+** sha1(X)
3231
+** sha1_query(Y)
3232
+**
3233
+** The sha1(X) function computes the SHA1 hash of the input X, or NULL if
3234
+** X is NULL.
3235
+**
3236
+** The sha1_query(Y) function evalutes all queries in the SQL statements of Y
3237
+** and returns a hash of their results.
3238
+*/
3239
+/* #include "sqlite3ext.h" */
3240
+SQLITE_EXTENSION_INIT1
3241
+#include <assert.h>
3242
+#include <string.h>
3243
+#include <stdarg.h>
3244
+
3245
+/******************************************************************************
3246
+** The Hash Engine
3247
+*/
3248
+/* Context for the SHA1 hash */
3249
+typedef struct SHA1Context SHA1Context;
3250
+struct SHA1Context {
3251
+ unsigned int state[5];
3252
+ unsigned int count[2];
3253
+ unsigned char buffer[64];
3254
+};
3255
+
3256
+#define SHA_ROT(x,l,r) ((x) << (l) | (x) >> (r))
3257
+#define rol(x,k) SHA_ROT(x,k,32-(k))
3258
+#define ror(x,k) SHA_ROT(x,32-(k),k)
3259
+
3260
+#define blk0le(i) (block[i] = (ror(block[i],8)&0xFF00FF00) \
3261
+ |(rol(block[i],8)&0x00FF00FF))
3262
+#define blk0be(i) block[i]
3263
+#define blk(i) (block[i&15] = rol(block[(i+13)&15]^block[(i+8)&15] \
3264
+ ^block[(i+2)&15]^block[i&15],1))
3265
+
3266
+/*
3267
+ * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
3268
+ *
3269
+ * Rl0() for little-endian and Rb0() for big-endian. Endianness is
3270
+ * determined at run-time.
3271
+ */
3272
+#define Rl0(v,w,x,y,z,i) \
3273
+ z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=ror(w,2);
3274
+#define Rb0(v,w,x,y,z,i) \
3275
+ z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=ror(w,2);
3276
+#define R1(v,w,x,y,z,i) \
3277
+ z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=ror(w,2);
3278
+#define R2(v,w,x,y,z,i) \
3279
+ z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=ror(w,2);
3280
+#define R3(v,w,x,y,z,i) \
3281
+ z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=ror(w,2);
3282
+#define R4(v,w,x,y,z,i) \
3283
+ z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=ror(w,2);
3284
+
3285
+/*
3286
+ * Hash a single 512-bit block. This is the core of the algorithm.
3287
+ */
3288
+static void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){
3289
+ unsigned int qq[5]; /* a, b, c, d, e; */
3290
+ static int one = 1;
3291
+ unsigned int block[16];
3292
+ memcpy(block, buffer, 64);
3293
+ memcpy(qq,state,5*sizeof(unsigned int));
3294
+
3295
+#define a qq[0]
3296
+#define b qq[1]
3297
+#define c qq[2]
3298
+#define d qq[3]
3299
+#define e qq[4]
3300
+
3301
+ /* Copy p->state[] to working vars */
3302
+ /*
3303
+ a = state[0];
3304
+ b = state[1];
3305
+ c = state[2];
3306
+ d = state[3];
3307
+ e = state[4];
3308
+ */
3309
+
3310
+ /* 4 rounds of 20 operations each. Loop unrolled. */
3311
+ if( 1 == *(unsigned char*)&one ){
3312
+ Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3);
3313
+ Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7);
3314
+ Rl0(c,d,e,a,b, 8); Rl0(b,c,d,e,a, 9); Rl0(a,b,c,d,e,10); Rl0(e,a,b,c,d,11);
3315
+ Rl0(d,e,a,b,c,12); Rl0(c,d,e,a,b,13); Rl0(b,c,d,e,a,14); Rl0(a,b,c,d,e,15);
3316
+ }else{
3317
+ Rb0(a,b,c,d,e, 0); Rb0(e,a,b,c,d, 1); Rb0(d,e,a,b,c, 2); Rb0(c,d,e,a,b, 3);
3318
+ Rb0(b,c,d,e,a, 4); Rb0(a,b,c,d,e, 5); Rb0(e,a,b,c,d, 6); Rb0(d,e,a,b,c, 7);
3319
+ Rb0(c,d,e,a,b, 8); Rb0(b,c,d,e,a, 9); Rb0(a,b,c,d,e,10); Rb0(e,a,b,c,d,11);
3320
+ Rb0(d,e,a,b,c,12); Rb0(c,d,e,a,b,13); Rb0(b,c,d,e,a,14); Rb0(a,b,c,d,e,15);
3321
+ }
3322
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
3323
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
3324
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
3325
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
3326
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
3327
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
3328
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
3329
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
3330
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
3331
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
3332
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
3333
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
3334
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
3335
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
3336
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
3337
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
3338
+
3339
+ /* Add the working vars back into context.state[] */
3340
+ state[0] += a;
3341
+ state[1] += b;
3342
+ state[2] += c;
3343
+ state[3] += d;
3344
+ state[4] += e;
3345
+
3346
+#undef a
3347
+#undef b
3348
+#undef c
3349
+#undef d
3350
+#undef e
3351
+}
3352
+
3353
+
3354
+/* Initialize a SHA1 context */
3355
+static void hash_init(SHA1Context *p){
3356
+ /* SHA1 initialization constants */
3357
+ p->state[0] = 0x67452301;
3358
+ p->state[1] = 0xEFCDAB89;
3359
+ p->state[2] = 0x98BADCFE;
3360
+ p->state[3] = 0x10325476;
3361
+ p->state[4] = 0xC3D2E1F0;
3362
+ p->count[0] = p->count[1] = 0;
3363
+}
3364
+
3365
+/* Add new content to the SHA1 hash */
3366
+static void hash_step(
3367
+ SHA1Context *p, /* Add content to this context */
3368
+ const unsigned char *data, /* Data to be added */
3369
+ unsigned int len /* Number of bytes in data */
3370
+){
3371
+ unsigned int i, j;
3372
+
3373
+ j = p->count[0];
3374
+ if( (p->count[0] += len << 3) < j ){
3375
+ p->count[1] += (len>>29)+1;
3376
+ }
3377
+ j = (j >> 3) & 63;
3378
+ if( (j + len) > 63 ){
3379
+ (void)memcpy(&p->buffer[j], data, (i = 64-j));
3380
+ SHA1Transform(p->state, p->buffer);
3381
+ for(; i + 63 < len; i += 64){
3382
+ SHA1Transform(p->state, &data[i]);
3383
+ }
3384
+ j = 0;
3385
+ }else{
3386
+ i = 0;
3387
+ }
3388
+ (void)memcpy(&p->buffer[j], &data[i], len - i);
3389
+}
3390
+
3391
+/* Compute a string using sqlite3_vsnprintf() and hash it */
3392
+static void hash_step_vformat(
3393
+ SHA1Context *p, /* Add content to this context */
3394
+ const char *zFormat,
3395
+ ...
3396
+){
3397
+ va_list ap;
3398
+ int n;
3399
+ char zBuf[50];
3400
+ va_start(ap, zFormat);
3401
+ sqlite3_vsnprintf(sizeof(zBuf),zBuf,zFormat,ap);
3402
+ va_end(ap);
3403
+ n = (int)strlen(zBuf);
3404
+ hash_step(p, (unsigned char*)zBuf, n);
3405
+}
3406
+
3407
+
3408
+/* Add padding and compute the message digest. Render the
3409
+** message digest as lower-case hexadecimal and put it into
3410
+** zOut[]. zOut[] must be at least 41 bytes long. */
3411
+static void hash_finish(
3412
+ SHA1Context *p, /* The SHA1 context to finish and render */
3413
+ char *zOut, /* Store hex or binary hash here */
3414
+ int bAsBinary /* 1 for binary hash, 0 for hex hash */
3415
+){
3416
+ unsigned int i;
3417
+ unsigned char finalcount[8];
3418
+ unsigned char digest[20];
3419
+ static const char zEncode[] = "0123456789abcdef";
3420
+
3421
+ for (i = 0; i < 8; i++){
3422
+ finalcount[i] = (unsigned char)((p->count[(i >= 4 ? 0 : 1)]
3423
+ >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
3424
+ }
3425
+ hash_step(p, (const unsigned char *)"\200", 1);
3426
+ while ((p->count[0] & 504) != 448){
3427
+ hash_step(p, (const unsigned char *)"\0", 1);
3428
+ }
3429
+ hash_step(p, finalcount, 8); /* Should cause a SHA1Transform() */
3430
+ for (i = 0; i < 20; i++){
3431
+ digest[i] = (unsigned char)((p->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
3432
+ }
3433
+ if( bAsBinary ){
3434
+ memcpy(zOut, digest, 20);
3435
+ }else{
3436
+ for(i=0; i<20; i++){
3437
+ zOut[i*2] = zEncode[(digest[i]>>4)&0xf];
3438
+ zOut[i*2+1] = zEncode[digest[i] & 0xf];
3439
+ }
3440
+ zOut[i*2]= 0;
3441
+ }
3442
+}
3443
+/* End of the hashing logic
3444
+*****************************************************************************/
3445
+
3446
+/*
3447
+** Implementation of the sha1(X) function.
3448
+**
3449
+** Return a lower-case hexadecimal rendering of the SHA1 hash of the
3450
+** argument X. If X is a BLOB, it is hashed as is. For all other
3451
+** types of input, X is converted into a UTF-8 string and the string
3452
+** is hash without the trailing 0x00 terminator. The hash of a NULL
3453
+** value is NULL.
3454
+*/
3455
+static void sha1Func(
3456
+ sqlite3_context *context,
3457
+ int argc,
3458
+ sqlite3_value **argv
3459
+){
3460
+ SHA1Context cx;
3461
+ int eType = sqlite3_value_type(argv[0]);
3462
+ int nByte = sqlite3_value_bytes(argv[0]);
3463
+ char zOut[44];
3464
+
3465
+ assert( argc==1 );
3466
+ if( eType==SQLITE_NULL ) return;
3467
+ hash_init(&cx);
3468
+ if( eType==SQLITE_BLOB ){
3469
+ hash_step(&cx, sqlite3_value_blob(argv[0]), nByte);
3470
+ }else{
3471
+ hash_step(&cx, sqlite3_value_text(argv[0]), nByte);
3472
+ }
3473
+ if( sqlite3_user_data(context)!=0 ){
3474
+ hash_finish(&cx, zOut, 1);
3475
+ sqlite3_result_blob(context, zOut, 20, SQLITE_TRANSIENT);
3476
+ }else{
3477
+ hash_finish(&cx, zOut, 0);
3478
+ sqlite3_result_blob(context, zOut, 40, SQLITE_TRANSIENT);
3479
+ }
3480
+}
3481
+
3482
+/*
3483
+** Implementation of the sha1_query(SQL) function.
3484
+**
3485
+** This function compiles and runs the SQL statement(s) given in the
3486
+** argument. The results are hashed using SHA1 and that hash is returned.
3487
+**
3488
+** The original SQL text is included as part of the hash.
3489
+**
3490
+** The hash is not just a concatenation of the outputs. Each query
3491
+** is delimited and each row and value within the query is delimited,
3492
+** with all values being marked with their datatypes.
3493
+*/
3494
+static void sha1QueryFunc(
3495
+ sqlite3_context *context,
3496
+ int argc,
3497
+ sqlite3_value **argv
3498
+){
3499
+ sqlite3 *db = sqlite3_context_db_handle(context);
3500
+ const char *zSql = (const char*)sqlite3_value_text(argv[0]);
3501
+ sqlite3_stmt *pStmt = 0;
3502
+ int nCol; /* Number of columns in the result set */
3503
+ int i; /* Loop counter */
3504
+ int rc;
3505
+ int n;
3506
+ const char *z;
3507
+ SHA1Context cx;
3508
+ char zOut[44];
3509
+
3510
+ assert( argc==1 );
3511
+ if( zSql==0 ) return;
3512
+ hash_init(&cx);
3513
+ while( zSql[0] ){
3514
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zSql);
3515
+ if( rc ){
3516
+ char *zMsg = sqlite3_mprintf("error SQL statement [%s]: %s",
3517
+ zSql, sqlite3_errmsg(db));
3518
+ sqlite3_finalize(pStmt);
3519
+ sqlite3_result_error(context, zMsg, -1);
3520
+ sqlite3_free(zMsg);
3521
+ return;
3522
+ }
3523
+ if( !sqlite3_stmt_readonly(pStmt) ){
3524
+ char *zMsg = sqlite3_mprintf("non-query: [%s]", sqlite3_sql(pStmt));
3525
+ sqlite3_finalize(pStmt);
3526
+ sqlite3_result_error(context, zMsg, -1);
3527
+ sqlite3_free(zMsg);
3528
+ return;
3529
+ }
3530
+ nCol = sqlite3_column_count(pStmt);
3531
+ z = sqlite3_sql(pStmt);
3532
+ n = (int)strlen(z);
3533
+ hash_step_vformat(&cx,"S%d:",n);
3534
+ hash_step(&cx,(unsigned char*)z,n);
3535
+
3536
+ /* Compute a hash over the result of the query */
3537
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){
3538
+ hash_step(&cx,(const unsigned char*)"R",1);
3539
+ for(i=0; i<nCol; i++){
3540
+ switch( sqlite3_column_type(pStmt,i) ){
3541
+ case SQLITE_NULL: {
3542
+ hash_step(&cx, (const unsigned char*)"N",1);
3543
+ break;
3544
+ }
3545
+ case SQLITE_INTEGER: {
3546
+ sqlite3_uint64 u;
3547
+ int j;
3548
+ unsigned char x[9];
3549
+ sqlite3_int64 v = sqlite3_column_int64(pStmt,i);
3550
+ memcpy(&u, &v, 8);
3551
+ for(j=8; j>=1; j--){
3552
+ x[j] = u & 0xff;
3553
+ u >>= 8;
3554
+ }
3555
+ x[0] = 'I';
3556
+ hash_step(&cx, x, 9);
3557
+ break;
3558
+ }
3559
+ case SQLITE_FLOAT: {
3560
+ sqlite3_uint64 u;
3561
+ int j;
3562
+ unsigned char x[9];
3563
+ double r = sqlite3_column_double(pStmt,i);
3564
+ memcpy(&u, &r, 8);
3565
+ for(j=8; j>=1; j--){
3566
+ x[j] = u & 0xff;
3567
+ u >>= 8;
3568
+ }
3569
+ x[0] = 'F';
3570
+ hash_step(&cx,x,9);
3571
+ break;
3572
+ }
3573
+ case SQLITE_TEXT: {
3574
+ int n2 = sqlite3_column_bytes(pStmt, i);
3575
+ const unsigned char *z2 = sqlite3_column_text(pStmt, i);
3576
+ hash_step_vformat(&cx,"T%d:",n2);
3577
+ hash_step(&cx, z2, n2);
3578
+ break;
3579
+ }
3580
+ case SQLITE_BLOB: {
3581
+ int n2 = sqlite3_column_bytes(pStmt, i);
3582
+ const unsigned char *z2 = sqlite3_column_blob(pStmt, i);
3583
+ hash_step_vformat(&cx,"B%d:",n2);
3584
+ hash_step(&cx, z2, n2);
3585
+ break;
3586
+ }
3587
+ }
3588
+ }
3589
+ }
3590
+ sqlite3_finalize(pStmt);
3591
+ }
3592
+ hash_finish(&cx, zOut, 0);
3593
+ sqlite3_result_text(context, zOut, 40, SQLITE_TRANSIENT);
3594
+}
3595
+
3596
+
3597
+#ifdef _WIN32
3598
+
3599
+#endif
3600
+int sqlite3_sha_init(
3601
+ sqlite3 *db,
3602
+ char **pzErrMsg,
3603
+ const sqlite3_api_routines *pApi
3604
+){
3605
+ int rc = SQLITE_OK;
3606
+ static int one = 1;
3607
+ SQLITE_EXTENSION_INIT2(pApi);
3608
+ (void)pzErrMsg; /* Unused parameter */
3609
+ rc = sqlite3_create_function(db, "sha1", 1,
3610
+ SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC,
3611
+ 0, sha1Func, 0, 0);
3612
+ if( rc==SQLITE_OK ){
3613
+ rc = sqlite3_create_function(db, "sha1b", 1,
3614
+ SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC,
3615
+ (void*)&one, sha1Func, 0, 0);
3616
+ }
3617
+ if( rc==SQLITE_OK ){
3618
+ rc = sqlite3_create_function(db, "sha1_query", 1,
3619
+ SQLITE_UTF8|SQLITE_DIRECTONLY, 0,
3620
+ sha1QueryFunc, 0, 0);
3621
+ }
3622
+ return rc;
3623
+}
3624
+
3625
+/************************* End ../ext/misc/sha1.c ********************/
37883626
/************************* Begin ../ext/misc/uint.c ******************/
37893627
/*
37903628
** 2020-04-14
37913629
**
37923630
** The author disclaims copyright to this source code. In place of
@@ -5075,11 +4913,11 @@
50754913
}else if( !p->bSorted || y>=p->a[p->nUsed-1] ){
50764914
p->a[p->nUsed++] = y;
50774915
}else if( p->bKeepSorted ){
50784916
int i;
50794917
i = percentBinarySearch(p, y, 0);
5080
- if( i<p->nUsed ){
4918
+ if( i<(int)p->nUsed ){
50814919
memmove(&p->a[i+1], &p->a[i], (p->nUsed-i)*sizeof(p->a[0]));
50824920
}
50834921
p->a[i] = y;
50844922
p->nUsed++;
50854923
}else{
@@ -5191,11 +5029,11 @@
51915029
51925030
/* Find and remove the row */
51935031
i = percentBinarySearch(p, y, 1);
51945032
if( i>=0 ){
51955033
p->nUsed--;
5196
- if( i<p->nUsed ){
5034
+ if( i<(int)p->nUsed ){
51975035
memmove(&p->a[i], &p->a[i+1], (p->nUsed - i)*sizeof(p->a[0]));
51985036
}
51995037
}
52005038
}
52015039
@@ -5251,15 +5089,15 @@
52515089
sqlite3 *db,
52525090
char **pzErrMsg,
52535091
const sqlite3_api_routines *pApi
52545092
){
52555093
int rc = SQLITE_OK;
5256
- int i;
5257
-#if defined(SQLITE3_H) || defined(SQLITE_STATIC_PERCENTILE)
5258
- (void)pApi; /* Unused parameter */
5259
-#else
5094
+ unsigned int i;
5095
+#ifdef SQLITE3EXT_H
52605096
SQLITE_EXTENSION_INIT2(pApi);
5097
+#else
5098
+ (void)pApi; /* Unused parameter */
52615099
#endif
52625100
(void)pzErrMsg; /* Unused parameter */
52635101
for(i=0; i<sizeof(aPercentFunc)/sizeof(aPercentFunc[0]); i++){
52645102
rc = sqlite3_create_window_function(db,
52655103
aPercentFunc[i].zName,
@@ -7012,50 +6850,58 @@
70126850
aIdx[4] = i;
70136851
idxNum |= 0x40;
70146852
}
70156853
continue;
70166854
}
7017
- if( pConstraint->iColumn==SERIES_COLUMN_VALUE ){
7018
- switch( op ){
7019
- case SQLITE_INDEX_CONSTRAINT_EQ:
7020
- case SQLITE_INDEX_CONSTRAINT_IS: {
7021
- idxNum |= 0x0080;
7022
- idxNum &= ~0x3300;
7023
- aIdx[5] = i;
7024
- aIdx[6] = -1;
7025
- bStartSeen = 1;
7026
- break;
7027
- }
7028
- case SQLITE_INDEX_CONSTRAINT_GE: {
7029
- if( idxNum & 0x0080 ) break;
7030
- idxNum |= 0x0100;
7031
- idxNum &= ~0x0200;
7032
- aIdx[5] = i;
7033
- bStartSeen = 1;
7034
- break;
7035
- }
7036
- case SQLITE_INDEX_CONSTRAINT_GT: {
7037
- if( idxNum & 0x0080 ) break;
7038
- idxNum |= 0x0200;
7039
- idxNum &= ~0x0100;
7040
- aIdx[5] = i;
7041
- bStartSeen = 1;
7042
- break;
7043
- }
7044
- case SQLITE_INDEX_CONSTRAINT_LE: {
7045
- if( idxNum & 0x0080 ) break;
7046
- idxNum |= 0x1000;
7047
- idxNum &= ~0x2000;
7048
- aIdx[6] = i;
7049
- break;
7050
- }
7051
- case SQLITE_INDEX_CONSTRAINT_LT: {
7052
- if( idxNum & 0x0080 ) break;
7053
- idxNum |= 0x2000;
7054
- idxNum &= ~0x1000;
7055
- aIdx[6] = i;
7056
- break;
6855
+ if( pConstraint->iColumn<SERIES_COLUMN_START ){
6856
+ if( pConstraint->iColumn==SERIES_COLUMN_VALUE && pConstraint->usable ){
6857
+ switch( op ){
6858
+ case SQLITE_INDEX_CONSTRAINT_EQ:
6859
+ case SQLITE_INDEX_CONSTRAINT_IS: {
6860
+ idxNum |= 0x0080;
6861
+ idxNum &= ~0x3300;
6862
+ aIdx[5] = i;
6863
+ aIdx[6] = -1;
6864
+#ifndef ZERO_ARGUMENT_GENERATE_SERIES
6865
+ bStartSeen = 1;
6866
+#endif
6867
+ break;
6868
+ }
6869
+ case SQLITE_INDEX_CONSTRAINT_GE: {
6870
+ if( idxNum & 0x0080 ) break;
6871
+ idxNum |= 0x0100;
6872
+ idxNum &= ~0x0200;
6873
+ aIdx[5] = i;
6874
+#ifndef ZERO_ARGUMENT_GENERATE_SERIES
6875
+ bStartSeen = 1;
6876
+#endif
6877
+ break;
6878
+ }
6879
+ case SQLITE_INDEX_CONSTRAINT_GT: {
6880
+ if( idxNum & 0x0080 ) break;
6881
+ idxNum |= 0x0200;
6882
+ idxNum &= ~0x0100;
6883
+ aIdx[5] = i;
6884
+#ifndef ZERO_ARGUMENT_GENERATE_SERIES
6885
+ bStartSeen = 1;
6886
+#endif
6887
+ break;
6888
+ }
6889
+ case SQLITE_INDEX_CONSTRAINT_LE: {
6890
+ if( idxNum & 0x0080 ) break;
6891
+ idxNum |= 0x1000;
6892
+ idxNum &= ~0x2000;
6893
+ aIdx[6] = i;
6894
+ break;
6895
+ }
6896
+ case SQLITE_INDEX_CONSTRAINT_LT: {
6897
+ if( idxNum & 0x0080 ) break;
6898
+ idxNum |= 0x2000;
6899
+ idxNum &= ~0x1000;
6900
+ aIdx[6] = i;
6901
+ break;
6902
+ }
70576903
}
70586904
}
70596905
continue;
70606906
}
70616907
iCol = pConstraint->iColumn - SERIES_COLUMN_START;
@@ -8115,11 +7961,11 @@
81157961
** If the optional MTIME argument is present, then it is interpreted
81167962
** as an integer - the number of seconds since the unix epoch. The
81177963
** modification-time of the target file is set to this value before
81187964
** returning.
81197965
**
8120
-** If three or more arguments are passed to this function and an
7966
+** If five or more arguments are passed to this function and an
81217967
** error is encountered, an exception is raised.
81227968
**
81237969
** READFILE(FILE):
81247970
**
81257971
** Read and return the contents of file FILE (type blob) from disk.
@@ -8185,10 +8031,17 @@
81858031
# define lstat(path,buf) stat(path,buf)
81868032
#endif
81878033
#include <time.h>
81888034
#include <errno.h>
81898035
8036
+/* When used as part of the CLI, the sqlite3_stdio.h module will have
8037
+** been included before this one. In that case use the sqlite3_stdio.h
8038
+** #defines. If not, create our own for fopen().
8039
+*/
8040
+#ifndef _SQLITE3_STDIO_H_
8041
+# define sqlite3_fopen fopen
8042
+#endif
81908043
81918044
/*
81928045
** Structure of the fsdir() table-valued function
81938046
*/
81948047
/* 0 1 2 3 4 5 */
@@ -8217,11 +8070,11 @@
82178070
sqlite3_int64 nIn;
82188071
void *pBuf;
82198072
sqlite3 *db;
82208073
int mxBlob;
82218074
8222
- in = fopen(zName, "rb");
8075
+ in = sqlite3_fopen(zName, "rb");
82238076
if( in==0 ){
82248077
/* File does not exist or is unreadable. Leave the result set to NULL. */
82258078
return;
82268079
}
82278080
fseek(in, 0, SEEK_END);
@@ -8472,11 +8325,11 @@
84728325
}
84738326
}else{
84748327
sqlite3_int64 nWrite = 0;
84758328
const char *z;
84768329
int rc = 0;
8477
- FILE *out = fopen(zFile, "wb");
8330
+ FILE *out = sqlite3_fopen(zFile, "wb");
84788331
if( out==0 ) return 1;
84798332
z = (const char*)sqlite3_value_blob(pData);
84808333
if( z ){
84818334
sqlite3_int64 n = fwrite(z, 1, sqlite3_value_bytes(pData), out);
84828335
nWrite = sqlite3_value_bytes(pData);
@@ -10333,10 +10186,18 @@
1033310186
#ifndef SQLITE_NO_STDINT
1033410187
# include <stdint.h>
1033510188
#endif
1033610189
1033710190
#include <zlib.h>
10191
+
10192
+/* When used as part of the CLI, the sqlite3_stdio.h module will have
10193
+** been included before this one. In that case use the sqlite3_stdio.h
10194
+** #defines. If not, create our own for fopen().
10195
+*/
10196
+#ifndef _SQLITE3_STDIO_H_
10197
+# define sqlite3_fopen fopen
10198
+#endif
1033810199
1033910200
#ifndef SQLITE_OMIT_VIRTUALTABLE
1034010201
1034110202
#ifndef SQLITE_AMALGAMATION
1034210203
@@ -11590,11 +11451,11 @@
1159011451
}else{
1159111452
zFile = (const char*)sqlite3_value_text(argv[0]);
1159211453
}
1159311454
1159411455
if( 0==pTab->pWriteFd && 0==bInMemory ){
11595
- pCsr->pFile = zFile ? fopen(zFile, "rb") : 0;
11456
+ pCsr->pFile = zFile ? sqlite3_fopen(zFile, "rb") : 0;
1159611457
if( pCsr->pFile==0 ){
1159711458
zipfileCursorErr(pCsr, "cannot open file: %s", zFile);
1159811459
rc = SQLITE_ERROR;
1159911460
}else{
1160011461
rc = zipfileReadEOCD(pTab, 0, 0, pCsr->pFile, &pCsr->eocd);
@@ -11780,11 +11641,11 @@
1178011641
1178111642
/* Open a write fd on the file. Also load the entire central directory
1178211643
** structure into memory. During the transaction any new file data is
1178311644
** appended to the archive file, but the central directory is accumulated
1178411645
** in main-memory until the transaction is committed. */
11785
- pTab->pWriteFd = fopen(pTab->zFile, "ab+");
11646
+ pTab->pWriteFd = sqlite3_fopen(pTab->zFile, "ab+");
1178611647
if( pTab->pWriteFd==0 ){
1178711648
pTab->base.zErrMsg = sqlite3_mprintf(
1178811649
"zipfile: failed to open file %s for writing", pTab->zFile
1178911650
);
1179011651
rc = SQLITE_ERROR;
@@ -14233,10 +14094,70 @@
1423314094
}
1423414095
1423514096
return rc;
1423614097
}
1423714098
14099
+/*
14100
+** This function tests if the schema of the main database of database handle
14101
+** db contains an object named zTab. Assuming no error occurs, output parameter
14102
+** (*pbContains) is set to true if zTab exists, or false if it does not.
14103
+**
14104
+** Or, if an error occurs, an SQLite error code is returned. The final value
14105
+** of (*pbContains) is undefined in this case.
14106
+*/
14107
+static int expertDbContainsObject(
14108
+ sqlite3 *db,
14109
+ const char *zTab,
14110
+ int *pbContains /* OUT: True if object exists */
14111
+){
14112
+ const char *zSql = "SELECT 1 FROM sqlite_schema WHERE name = ?";
14113
+ sqlite3_stmt *pSql = 0;
14114
+ int rc = SQLITE_OK;
14115
+ int ret = 0;
14116
+
14117
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pSql, 0);
14118
+ if( rc==SQLITE_OK ){
14119
+ sqlite3_bind_text(pSql, 1, zTab, -1, SQLITE_STATIC);
14120
+ if( SQLITE_ROW==sqlite3_step(pSql) ){
14121
+ ret = 1;
14122
+ }
14123
+ rc = sqlite3_finalize(pSql);
14124
+ }
14125
+
14126
+ *pbContains = ret;
14127
+ return rc;
14128
+}
14129
+
14130
+/*
14131
+** Execute SQL command zSql using database handle db. If no error occurs,
14132
+** set (*pzErr) to NULL and return SQLITE_OK.
14133
+**
14134
+** If an error does occur, return an SQLite error code and set (*pzErr) to
14135
+** point to a buffer containing an English language error message. Except,
14136
+** if the error message begins with "no such module:", then ignore the
14137
+** error and return as if the SQL statement had succeeded.
14138
+**
14139
+** This is used to copy as much of the database schema as possible while
14140
+** ignoring any errors related to missing virtual table modules.
14141
+*/
14142
+static int expertSchemaSql(sqlite3 *db, const char *zSql, char **pzErr){
14143
+ int rc = SQLITE_OK;
14144
+ char *zErr = 0;
14145
+
14146
+ rc = sqlite3_exec(db, zSql, 0, 0, &zErr);
14147
+ if( rc!=SQLITE_OK && zErr ){
14148
+ int nErr = STRLEN(zErr);
14149
+ if( nErr>=15 && memcmp(zErr, "no such module:", 15)==0 ){
14150
+ sqlite3_free(zErr);
14151
+ rc = SQLITE_OK;
14152
+ zErr = 0;
14153
+ }
14154
+ }
14155
+
14156
+ *pzErr = zErr;
14157
+ return rc;
14158
+}
1423814159
1423914160
static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){
1424014161
int rc = idxRegisterVtab(p);
1424114162
sqlite3_stmt *pSchema = 0;
1424214163
@@ -14244,30 +14165,39 @@
1424414165
**
1424514166
** 1) Add an entry to the p->pTable list, and
1424614167
** 2) Create the equivalent virtual table in dbv.
1424714168
*/
1424814169
rc = idxPrepareStmt(p->db, &pSchema, pzErrmsg,
14249
- "SELECT type, name, sql, 1 FROM sqlite_schema "
14250
- "WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%%' "
14170
+ "SELECT type, name, sql, 1, "
14171
+ " substr(sql,1,14)=='create virtual' COLLATE nocase "
14172
+ "FROM sqlite_schema "
14173
+ "WHERE type IN ('table','view') AND "
14174
+ " substr(name,1,7)!='sqlite_' COLLATE nocase "
1425114175
" UNION ALL "
14252
- "SELECT type, name, sql, 2 FROM sqlite_schema "
14176
+ "SELECT type, name, sql, 2, 0 FROM sqlite_schema "
1425314177
"WHERE type = 'trigger'"
1425414178
" AND tbl_name IN(SELECT name FROM sqlite_schema WHERE type = 'view') "
14255
- "ORDER BY 4, 1"
14179
+ "ORDER BY 4, 5 DESC, 1"
1425614180
);
1425714181
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSchema) ){
1425814182
const char *zType = (const char*)sqlite3_column_text(pSchema, 0);
1425914183
const char *zName = (const char*)sqlite3_column_text(pSchema, 1);
1426014184
const char *zSql = (const char*)sqlite3_column_text(pSchema, 2);
14185
+ int bVirtual = sqlite3_column_int(pSchema, 4);
14186
+ int bExists = 0;
1426114187
1426214188
if( zType==0 || zName==0 ) continue;
14263
- if( zType[0]=='v' || zType[1]=='r' ){
14264
- if( zSql ) rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg);
14189
+ rc = expertDbContainsObject(p->dbv, zName, &bExists);
14190
+ if( rc || bExists ) continue;
14191
+
14192
+ if( zType[0]=='v' || zType[1]=='r' || bVirtual ){
14193
+ /* A view. Or a trigger on a view. */
14194
+ if( zSql ) rc = expertSchemaSql(p->dbv, zSql, pzErrmsg);
1426514195
}else{
1426614196
IdxTable *pTab;
1426714197
rc = idxGetTableInfo(p->db, zName, &pTab, pzErrmsg);
14268
- if( rc==SQLITE_OK ){
14198
+ if( rc==SQLITE_OK && ALWAYS(pTab!=0) ){
1426914199
int i;
1427014200
char *zInner = 0;
1427114201
char *zOuter = 0;
1427214202
pTab->pNext = p->pTable;
1427314203
p->pTable = pTab;
@@ -14464,10 +14394,16 @@
1446414394
sqlite3_bind_text(pIndexXInfo, 1, zIdx, -1, SQLITE_STATIC);
1446514395
while( SQLITE_OK==rc && SQLITE_ROW==sqlite3_step(pIndexXInfo) ){
1446614396
const char *zComma = zCols==0 ? "" : ", ";
1446714397
const char *zName = (const char*)sqlite3_column_text(pIndexXInfo, 0);
1446814398
const char *zColl = (const char*)sqlite3_column_text(pIndexXInfo, 1);
14399
+ if( zName==0 ){
14400
+ /* This index contains an expression. Ignore it. */
14401
+ sqlite3_free(zCols);
14402
+ sqlite3_free(zOrder);
14403
+ return sqlite3_reset(pIndexXInfo);
14404
+ }
1446914405
zCols = idxAppendText(&rc, zCols,
1447014406
"%sx.%Q IS sqlite_expert_rem(%d, x.%Q) COLLATE %s",
1447114407
zComma, zName, nCol, zName, zColl
1447214408
);
1447314409
zOrder = idxAppendText(&rc, zOrder, "%s%d", zComma, ++nCol);
@@ -14792,16 +14728,22 @@
1479214728
1479314729
/* Copy the entire schema of database [db] into [dbm]. */
1479414730
if( rc==SQLITE_OK ){
1479514731
sqlite3_stmt *pSql = 0;
1479614732
rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg,
14797
- "SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
14798
- " AND sql NOT LIKE 'CREATE VIRTUAL %%' ORDER BY rowid"
14733
+ "SELECT sql, name, substr(sql,1,14)=='create virtual' COLLATE nocase"
14734
+ " FROM sqlite_schema WHERE substr(name,1,7)!='sqlite_' COLLATE nocase"
14735
+ " ORDER BY 3 DESC, rowid"
1479914736
);
1480014737
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
1480114738
const char *zSql = (const char*)sqlite3_column_text(pSql, 0);
14802
- if( zSql ) rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg);
14739
+ const char *zName = (const char*)sqlite3_column_text(pSql, 1);
14740
+ int bExists = 0;
14741
+ rc = expertDbContainsObject(pNew->dbm, zName, &bExists);
14742
+ if( rc==SQLITE_OK && zSql && bExists==0 ){
14743
+ rc = expertSchemaSql(pNew->dbm, zSql, pzErrmsg);
14744
+ }
1480314745
}
1480414746
idxFinalize(&rc, pSql);
1480514747
}
1480614748
1480714749
/* Create the vtab schema */
@@ -16211,10 +16153,1197 @@
1621116153
}
1621216154
return rc;
1621316155
}
1621416156
1621516157
/************************* End ../ext/misc/stmtrand.c ********************/
16158
+/************************* Begin ../ext/misc/vfstrace.c ******************/
16159
+/*
16160
+** 2011 March 16
16161
+**
16162
+** The author disclaims copyright to this source code. In place of
16163
+** a legal notice, here is a blessing:
16164
+**
16165
+** May you do good and not evil.
16166
+** May you find forgiveness for yourself and forgive others.
16167
+** May you share freely, never taking more than you give.
16168
+**
16169
+******************************************************************************
16170
+**
16171
+** This file contains code implements a VFS shim that writes diagnostic
16172
+** output for each VFS call, similar to "strace".
16173
+**
16174
+** USAGE:
16175
+**
16176
+** This source file exports a single symbol which is the name of a
16177
+** function:
16178
+**
16179
+** int vfstrace_register(
16180
+** const char *zTraceName, // Name of the newly constructed VFS
16181
+** const char *zOldVfsName, // Name of the underlying VFS
16182
+** int (*xOut)(const char*,void*), // Output routine. ex: fputs
16183
+** void *pOutArg, // 2nd argument to xOut. ex: stderr
16184
+** int makeDefault // Make the new VFS the default
16185
+** );
16186
+**
16187
+** Applications that want to trace their VFS usage must provide a callback
16188
+** function with this prototype:
16189
+**
16190
+** int traceOutput(const char *zMessage, void *pAppData);
16191
+**
16192
+** This function will "output" the trace messages, where "output" can
16193
+** mean different things to different applications. The traceOutput function
16194
+** for the command-line shell (see shell.c) is "fputs" from the standard
16195
+** library, which means that all trace output is written on the stream
16196
+** specified by the second argument. In the case of the command-line shell
16197
+** the second argument is stderr. Other applications might choose to output
16198
+** trace information to a file, over a socket, or write it into a buffer.
16199
+**
16200
+** The vfstrace_register() function creates a new "shim" VFS named by
16201
+** the zTraceName parameter. A "shim" VFS is an SQLite backend that does
16202
+** not really perform the duties of a true backend, but simply filters or
16203
+** interprets VFS calls before passing them off to another VFS which does
16204
+** the actual work. In this case the other VFS - the one that does the
16205
+** real work - is identified by the second parameter, zOldVfsName. If
16206
+** the 2nd parameter is NULL then the default VFS is used. The common
16207
+** case is for the 2nd parameter to be NULL.
16208
+**
16209
+** The third and fourth parameters are the pointer to the output function
16210
+** and the second argument to the output function. For the SQLite
16211
+** command-line shell, when the -vfstrace option is used, these parameters
16212
+** are fputs and stderr, respectively.
16213
+**
16214
+** The fifth argument is true (non-zero) to cause the newly created VFS
16215
+** to become the default VFS. The common case is for the fifth parameter
16216
+** to be true.
16217
+**
16218
+** The call to vfstrace_register() simply creates the shim VFS that does
16219
+** tracing. The application must also arrange to use the new VFS for
16220
+** all database connections that are created and for which tracing is
16221
+** desired. This can be done by specifying the trace VFS using URI filename
16222
+** notation, or by specifying the trace VFS as the 4th parameter to
16223
+** sqlite3_open_v2() or by making the trace VFS be the default (by setting
16224
+** the 5th parameter of vfstrace_register() to 1).
16225
+**
16226
+**
16227
+** ENABLING VFSTRACE IN A COMMAND-LINE SHELL
16228
+**
16229
+** The SQLite command line shell implemented by the shell.c source file
16230
+** can be used with this module. To compile in -vfstrace support, first
16231
+** gather this file (test_vfstrace.c), the shell source file (shell.c),
16232
+** and the SQLite amalgamation source files (sqlite3.c, sqlite3.h) into
16233
+** the working directory. Then compile using a command like the following:
16234
+**
16235
+** gcc -o sqlite3 -Os -I. -DSQLITE_ENABLE_VFSTRACE \
16236
+** -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE \
16237
+** -DHAVE_READLINE -DHAVE_USLEEP=1 \
16238
+** shell.c test_vfstrace.c sqlite3.c -ldl -lreadline -lncurses
16239
+**
16240
+** The gcc command above works on Linux and provides (in addition to the
16241
+** -vfstrace option) support for FTS3 and FTS4, RTREE, and command-line
16242
+** editing using the readline library. The command-line shell does not
16243
+** use threads so we added -DSQLITE_THREADSAFE=0 just to make the code
16244
+** run a little faster. For compiling on a Mac, you'll probably need
16245
+** to omit the -DHAVE_READLINE, the -lreadline, and the -lncurses options.
16246
+** The compilation could be simplified to just this:
16247
+**
16248
+** gcc -DSQLITE_ENABLE_VFSTRACE \
16249
+** shell.c test_vfstrace.c sqlite3.c -ldl -lpthread
16250
+**
16251
+** In this second example, all unnecessary options have been removed
16252
+** Note that since the code is now threadsafe, we had to add the -lpthread
16253
+** option to pull in the pthreads library.
16254
+**
16255
+** To cross-compile for windows using MinGW, a command like this might
16256
+** work:
16257
+**
16258
+** /opt/mingw/bin/i386-mingw32msvc-gcc -o sqlite3.exe -Os -I \
16259
+** -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_VFSTRACE \
16260
+** shell.c test_vfstrace.c sqlite3.c
16261
+**
16262
+** Similar compiler commands will work on different systems. The key
16263
+** invariants are (1) you must have -DSQLITE_ENABLE_VFSTRACE so that
16264
+** the shell.c source file will know to include the -vfstrace command-line
16265
+** option and (2) you must compile and link the three source files
16266
+** shell,c, test_vfstrace.c, and sqlite3.c.
16267
+**
16268
+** RUNTIME CONTROL OF VFSTRACE OUTPUT
16269
+**
16270
+** The application can use the "vfstrace" pragma to control which VFS
16271
+** APIs are traced. To disable all output:
16272
+**
16273
+** PRAGMA vfstrace('-all');
16274
+**
16275
+** To enable all output (which is the default setting):
16276
+**
16277
+** PRAGMA vfstrace('+all');
16278
+**
16279
+** Individual APIs can be enabled or disabled by name, with or without
16280
+** the initial "x" character. For example, to set up for tracing lock
16281
+** primatives only:
16282
+**
16283
+** PRAGMA vfstrace('-all, +Lock,Unlock,ShmLock');
16284
+**
16285
+** The argument to the vfstrace pragma ignores capitalization and any
16286
+** characters other than alphabetics, '+', and '-'.
16287
+*/
16288
+#include <stdlib.h>
16289
+#include <string.h>
16290
+/* #include "sqlite3.h" */
16291
+
16292
+/*
16293
+** An instance of this structure is attached to the each trace VFS to
16294
+** provide auxiliary information.
16295
+*/
16296
+typedef struct vfstrace_info vfstrace_info;
16297
+struct vfstrace_info {
16298
+ sqlite3_vfs *pRootVfs; /* The underlying real VFS */
16299
+ int (*xOut)(const char*, void*); /* Send output here */
16300
+ unsigned int mTrace; /* Mask of interfaces to trace */
16301
+ u8 bOn; /* Tracing on/off */
16302
+ void *pOutArg; /* First argument to xOut */
16303
+ const char *zVfsName; /* Name of this trace-VFS */
16304
+ sqlite3_vfs *pTraceVfs; /* Pointer back to the trace VFS */
16305
+};
16306
+
16307
+/*
16308
+** The sqlite3_file object for the trace VFS
16309
+*/
16310
+typedef struct vfstrace_file vfstrace_file;
16311
+struct vfstrace_file {
16312
+ sqlite3_file base; /* Base class. Must be first */
16313
+ vfstrace_info *pInfo; /* The trace-VFS to which this file belongs */
16314
+ const char *zFName; /* Base name of the file */
16315
+ sqlite3_file *pReal; /* The real underlying file */
16316
+};
16317
+
16318
+/*
16319
+** Bit values for vfstrace_info.mTrace.
16320
+*/
16321
+#define VTR_CLOSE 0x00000001
16322
+#define VTR_READ 0x00000002
16323
+#define VTR_WRITE 0x00000004
16324
+#define VTR_TRUNC 0x00000008
16325
+#define VTR_SYNC 0x00000010
16326
+#define VTR_FSIZE 0x00000020
16327
+#define VTR_LOCK 0x00000040
16328
+#define VTR_UNLOCK 0x00000080
16329
+#define VTR_CRL 0x00000100
16330
+#define VTR_FCTRL 0x00000200
16331
+#define VTR_SECSZ 0x00000400
16332
+#define VTR_DEVCHAR 0x00000800
16333
+#define VTR_SHMLOCK 0x00001000
16334
+#define VTR_SHMMAP 0x00002000
16335
+#define VTR_SHMBAR 0x00004000
16336
+#define VTR_SHMUNMAP 0x00008000
16337
+#define VTR_OPEN 0x00010000
16338
+#define VTR_DELETE 0x00020000
16339
+#define VTR_ACCESS 0x00040000
16340
+#define VTR_FULLPATH 0x00080000
16341
+#define VTR_DLOPEN 0x00100000
16342
+#define VTR_DLERR 0x00200000
16343
+#define VTR_DLSYM 0x00400000
16344
+#define VTR_DLCLOSE 0x00800000
16345
+#define VTR_RAND 0x01000000
16346
+#define VTR_SLEEP 0x02000000
16347
+#define VTR_CURTIME 0x04000000
16348
+#define VTR_LASTERR 0x08000000
16349
+
16350
+/*
16351
+** Method declarations for vfstrace_file.
16352
+*/
16353
+static int vfstraceClose(sqlite3_file*);
16354
+static int vfstraceRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
16355
+static int vfstraceWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64);
16356
+static int vfstraceTruncate(sqlite3_file*, sqlite3_int64 size);
16357
+static int vfstraceSync(sqlite3_file*, int flags);
16358
+static int vfstraceFileSize(sqlite3_file*, sqlite3_int64 *pSize);
16359
+static int vfstraceLock(sqlite3_file*, int);
16360
+static int vfstraceUnlock(sqlite3_file*, int);
16361
+static int vfstraceCheckReservedLock(sqlite3_file*, int *);
16362
+static int vfstraceFileControl(sqlite3_file*, int op, void *pArg);
16363
+static int vfstraceSectorSize(sqlite3_file*);
16364
+static int vfstraceDeviceCharacteristics(sqlite3_file*);
16365
+static int vfstraceShmLock(sqlite3_file*,int,int,int);
16366
+static int vfstraceShmMap(sqlite3_file*,int,int,int, void volatile **);
16367
+static void vfstraceShmBarrier(sqlite3_file*);
16368
+static int vfstraceShmUnmap(sqlite3_file*,int);
16369
+
16370
+/*
16371
+** Method declarations for vfstrace_vfs.
16372
+*/
16373
+static int vfstraceOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);
16374
+static int vfstraceDelete(sqlite3_vfs*, const char *zName, int syncDir);
16375
+static int vfstraceAccess(sqlite3_vfs*, const char *zName, int flags, int *);
16376
+static int vfstraceFullPathname(sqlite3_vfs*, const char *zName, int, char *);
16377
+static void *vfstraceDlOpen(sqlite3_vfs*, const char *zFilename);
16378
+static void vfstraceDlError(sqlite3_vfs*, int nByte, char *zErrMsg);
16379
+static void (*vfstraceDlSym(sqlite3_vfs*,void*, const char *zSymbol))(void);
16380
+static void vfstraceDlClose(sqlite3_vfs*, void*);
16381
+static int vfstraceRandomness(sqlite3_vfs*, int nByte, char *zOut);
16382
+static int vfstraceSleep(sqlite3_vfs*, int microseconds);
16383
+static int vfstraceCurrentTime(sqlite3_vfs*, double*);
16384
+static int vfstraceGetLastError(sqlite3_vfs*, int, char*);
16385
+static int vfstraceCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);
16386
+static int vfstraceSetSystemCall(sqlite3_vfs*,const char*, sqlite3_syscall_ptr);
16387
+static sqlite3_syscall_ptr vfstraceGetSystemCall(sqlite3_vfs*, const char *);
16388
+static const char *vfstraceNextSystemCall(sqlite3_vfs*, const char *zName);
16389
+
16390
+/*
16391
+** Return a pointer to the tail of the pathname. Examples:
16392
+**
16393
+** /home/drh/xyzzy.txt -> xyzzy.txt
16394
+** xyzzy.txt -> xyzzy.txt
16395
+*/
16396
+static const char *fileTail(const char *z){
16397
+ size_t i;
16398
+ if( z==0 ) return 0;
16399
+ i = strlen(z)-1;
16400
+ while( i>0 && z[i-1]!='/' ){ i--; }
16401
+ return &z[i];
16402
+}
16403
+
16404
+/*
16405
+** Send trace output defined by zFormat and subsequent arguments.
16406
+*/
16407
+static void vfstrace_printf(
16408
+ vfstrace_info *pInfo,
16409
+ const char *zFormat,
16410
+ ...
16411
+){
16412
+ va_list ap;
16413
+ char *zMsg;
16414
+ if( pInfo->bOn ){
16415
+ va_start(ap, zFormat);
16416
+ zMsg = sqlite3_vmprintf(zFormat, ap);
16417
+ va_end(ap);
16418
+ pInfo->xOut(zMsg, pInfo->pOutArg);
16419
+ sqlite3_free(zMsg);
16420
+ }
16421
+}
16422
+
16423
+/*
16424
+** Try to convert an error code into a symbolic name for that error code.
16425
+*/
16426
+static const char *vfstrace_errcode_name(int rc ){
16427
+ const char *zVal = 0;
16428
+ switch( rc ){
16429
+ case SQLITE_OK: zVal = "SQLITE_OK"; break;
16430
+ case SQLITE_INTERNAL: zVal = "SQLITE_INTERNAL"; break;
16431
+ case SQLITE_ERROR: zVal = "SQLITE_ERROR"; break;
16432
+ case SQLITE_PERM: zVal = "SQLITE_PERM"; break;
16433
+ case SQLITE_ABORT: zVal = "SQLITE_ABORT"; break;
16434
+ case SQLITE_BUSY: zVal = "SQLITE_BUSY"; break;
16435
+ case SQLITE_LOCKED: zVal = "SQLITE_LOCKED"; break;
16436
+ case SQLITE_NOMEM: zVal = "SQLITE_NOMEM"; break;
16437
+ case SQLITE_READONLY: zVal = "SQLITE_READONLY"; break;
16438
+ case SQLITE_INTERRUPT: zVal = "SQLITE_INTERRUPT"; break;
16439
+ case SQLITE_IOERR: zVal = "SQLITE_IOERR"; break;
16440
+ case SQLITE_CORRUPT: zVal = "SQLITE_CORRUPT"; break;
16441
+ case SQLITE_NOTFOUND: zVal = "SQLITE_NOTFOUND"; break;
16442
+ case SQLITE_FULL: zVal = "SQLITE_FULL"; break;
16443
+ case SQLITE_CANTOPEN: zVal = "SQLITE_CANTOPEN"; break;
16444
+ case SQLITE_PROTOCOL: zVal = "SQLITE_PROTOCOL"; break;
16445
+ case SQLITE_EMPTY: zVal = "SQLITE_EMPTY"; break;
16446
+ case SQLITE_SCHEMA: zVal = "SQLITE_SCHEMA"; break;
16447
+ case SQLITE_TOOBIG: zVal = "SQLITE_TOOBIG"; break;
16448
+ case SQLITE_CONSTRAINT: zVal = "SQLITE_CONSTRAINT"; break;
16449
+ case SQLITE_MISMATCH: zVal = "SQLITE_MISMATCH"; break;
16450
+ case SQLITE_MISUSE: zVal = "SQLITE_MISUSE"; break;
16451
+ case SQLITE_NOLFS: zVal = "SQLITE_NOLFS"; break;
16452
+ case SQLITE_IOERR_READ: zVal = "SQLITE_IOERR_READ"; break;
16453
+ case SQLITE_IOERR_SHORT_READ: zVal = "SQLITE_IOERR_SHORT_READ"; break;
16454
+ case SQLITE_IOERR_WRITE: zVal = "SQLITE_IOERR_WRITE"; break;
16455
+ case SQLITE_IOERR_FSYNC: zVal = "SQLITE_IOERR_FSYNC"; break;
16456
+ case SQLITE_IOERR_DIR_FSYNC: zVal = "SQLITE_IOERR_DIR_FSYNC"; break;
16457
+ case SQLITE_IOERR_TRUNCATE: zVal = "SQLITE_IOERR_TRUNCATE"; break;
16458
+ case SQLITE_IOERR_FSTAT: zVal = "SQLITE_IOERR_FSTAT"; break;
16459
+ case SQLITE_IOERR_UNLOCK: zVal = "SQLITE_IOERR_UNLOCK"; break;
16460
+ case SQLITE_IOERR_RDLOCK: zVal = "SQLITE_IOERR_RDLOCK"; break;
16461
+ case SQLITE_IOERR_DELETE: zVal = "SQLITE_IOERR_DELETE"; break;
16462
+ case SQLITE_IOERR_BLOCKED: zVal = "SQLITE_IOERR_BLOCKED"; break;
16463
+ case SQLITE_IOERR_NOMEM: zVal = "SQLITE_IOERR_NOMEM"; break;
16464
+ case SQLITE_IOERR_ACCESS: zVal = "SQLITE_IOERR_ACCESS"; break;
16465
+ case SQLITE_IOERR_CHECKRESERVEDLOCK:
16466
+ zVal = "SQLITE_IOERR_CHECKRESERVEDLOCK"; break;
16467
+ case SQLITE_IOERR_LOCK: zVal = "SQLITE_IOERR_LOCK"; break;
16468
+ case SQLITE_IOERR_CLOSE: zVal = "SQLITE_IOERR_CLOSE"; break;
16469
+ case SQLITE_IOERR_DIR_CLOSE: zVal = "SQLITE_IOERR_DIR_CLOSE"; break;
16470
+ case SQLITE_IOERR_SHMOPEN: zVal = "SQLITE_IOERR_SHMOPEN"; break;
16471
+ case SQLITE_IOERR_SHMSIZE: zVal = "SQLITE_IOERR_SHMSIZE"; break;
16472
+ case SQLITE_IOERR_SHMLOCK: zVal = "SQLITE_IOERR_SHMLOCK"; break;
16473
+ case SQLITE_IOERR_SHMMAP: zVal = "SQLITE_IOERR_SHMMAP"; break;
16474
+ case SQLITE_IOERR_SEEK: zVal = "SQLITE_IOERR_SEEK"; break;
16475
+ case SQLITE_IOERR_GETTEMPPATH: zVal = "SQLITE_IOERR_GETTEMPPATH"; break;
16476
+ case SQLITE_IOERR_CONVPATH: zVal = "SQLITE_IOERR_CONVPATH"; break;
16477
+ case SQLITE_READONLY_DBMOVED: zVal = "SQLITE_READONLY_DBMOVED"; break;
16478
+ case SQLITE_LOCKED_SHAREDCACHE: zVal = "SQLITE_LOCKED_SHAREDCACHE"; break;
16479
+ case SQLITE_BUSY_RECOVERY: zVal = "SQLITE_BUSY_RECOVERY"; break;
16480
+ case SQLITE_CANTOPEN_NOTEMPDIR: zVal = "SQLITE_CANTOPEN_NOTEMPDIR"; break;
16481
+ }
16482
+ return zVal;
16483
+}
16484
+
16485
+/*
16486
+** Convert value rc into a string and print it using zFormat. zFormat
16487
+** should have exactly one %s
16488
+*/
16489
+static void vfstrace_print_errcode(
16490
+ vfstrace_info *pInfo,
16491
+ const char *zFormat,
16492
+ int rc
16493
+){
16494
+ const char *zVal;
16495
+ char zBuf[50];
16496
+ zVal = vfstrace_errcode_name(rc);
16497
+ if( zVal==0 ){
16498
+ zVal = vfstrace_errcode_name(rc&0xff);
16499
+ if( zVal ){
16500
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%s | 0x%x", zVal, rc&0xffff00);
16501
+ }else{
16502
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%d (0x%x)", rc, rc);
16503
+ }
16504
+ zVal = zBuf;
16505
+ }
16506
+ vfstrace_printf(pInfo, zFormat, zVal);
16507
+}
16508
+
16509
+/*
16510
+** Append to a buffer.
16511
+*/
16512
+static void strappend(char *z, int *pI, const char *zAppend){
16513
+ int i = *pI;
16514
+ while( zAppend[0] ){ z[i++] = *(zAppend++); }
16515
+ z[i] = 0;
16516
+ *pI = i;
16517
+}
16518
+
16519
+/*
16520
+** Turn tracing output on or off according to mMask.
16521
+*/
16522
+static void vfstraceOnOff(vfstrace_info *pInfo, unsigned int mMask){
16523
+ pInfo->bOn = (pInfo->mTrace & mMask)!=0;
16524
+}
16525
+
16526
+/*
16527
+** Close an vfstrace-file.
16528
+*/
16529
+static int vfstraceClose(sqlite3_file *pFile){
16530
+ vfstrace_file *p = (vfstrace_file *)pFile;
16531
+ vfstrace_info *pInfo = p->pInfo;
16532
+ int rc;
16533
+ vfstraceOnOff(pInfo, VTR_CLOSE);
16534
+ vfstrace_printf(pInfo, "%s.xClose(%s)", pInfo->zVfsName, p->zFName);
16535
+ rc = p->pReal->pMethods->xClose(p->pReal);
16536
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
16537
+ if( rc==SQLITE_OK ){
16538
+ sqlite3_free((void*)p->base.pMethods);
16539
+ p->base.pMethods = 0;
16540
+ }
16541
+ return rc;
16542
+}
16543
+
16544
+/*
16545
+** Read data from an vfstrace-file.
16546
+*/
16547
+static int vfstraceRead(
16548
+ sqlite3_file *pFile,
16549
+ void *zBuf,
16550
+ int iAmt,
16551
+ sqlite_int64 iOfst
16552
+){
16553
+ vfstrace_file *p = (vfstrace_file *)pFile;
16554
+ vfstrace_info *pInfo = p->pInfo;
16555
+ int rc;
16556
+ vfstraceOnOff(pInfo, VTR_READ);
16557
+ vfstrace_printf(pInfo, "%s.xRead(%s,n=%d,ofst=%lld)",
16558
+ pInfo->zVfsName, p->zFName, iAmt, iOfst);
16559
+ rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);
16560
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
16561
+ return rc;
16562
+}
16563
+
16564
+/*
16565
+** Write data to an vfstrace-file.
16566
+*/
16567
+static int vfstraceWrite(
16568
+ sqlite3_file *pFile,
16569
+ const void *zBuf,
16570
+ int iAmt,
16571
+ sqlite_int64 iOfst
16572
+){
16573
+ vfstrace_file *p = (vfstrace_file *)pFile;
16574
+ vfstrace_info *pInfo = p->pInfo;
16575
+ int rc;
16576
+ vfstraceOnOff(pInfo, VTR_WRITE);
16577
+ vfstrace_printf(pInfo, "%s.xWrite(%s,n=%d,ofst=%lld)",
16578
+ pInfo->zVfsName, p->zFName, iAmt, iOfst);
16579
+ rc = p->pReal->pMethods->xWrite(p->pReal, zBuf, iAmt, iOfst);
16580
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
16581
+ return rc;
16582
+}
16583
+
16584
+/*
16585
+** Truncate an vfstrace-file.
16586
+*/
16587
+static int vfstraceTruncate(sqlite3_file *pFile, sqlite_int64 size){
16588
+ vfstrace_file *p = (vfstrace_file *)pFile;
16589
+ vfstrace_info *pInfo = p->pInfo;
16590
+ int rc;
16591
+ vfstraceOnOff(pInfo, VTR_TRUNC);
16592
+ vfstrace_printf(pInfo, "%s.xTruncate(%s,%lld)", pInfo->zVfsName, p->zFName,
16593
+ size);
16594
+ rc = p->pReal->pMethods->xTruncate(p->pReal, size);
16595
+ vfstrace_printf(pInfo, " -> %d\n", rc);
16596
+ return rc;
16597
+}
16598
+
16599
+/*
16600
+** Sync an vfstrace-file.
16601
+*/
16602
+static int vfstraceSync(sqlite3_file *pFile, int flags){
16603
+ vfstrace_file *p = (vfstrace_file *)pFile;
16604
+ vfstrace_info *pInfo = p->pInfo;
16605
+ int rc;
16606
+ int i;
16607
+ char zBuf[100];
16608
+ memcpy(zBuf, "|0", 3);
16609
+ i = 0;
16610
+ if( flags & SQLITE_SYNC_FULL ) strappend(zBuf, &i, "|FULL");
16611
+ else if( flags & SQLITE_SYNC_NORMAL ) strappend(zBuf, &i, "|NORMAL");
16612
+ if( flags & SQLITE_SYNC_DATAONLY ) strappend(zBuf, &i, "|DATAONLY");
16613
+ if( flags & ~(SQLITE_SYNC_FULL|SQLITE_SYNC_DATAONLY) ){
16614
+ sqlite3_snprintf(sizeof(zBuf)-i, &zBuf[i], "|0x%x", flags);
16615
+ }
16616
+ vfstraceOnOff(pInfo, VTR_SYNC);
16617
+ vfstrace_printf(pInfo, "%s.xSync(%s,%s)", pInfo->zVfsName, p->zFName,
16618
+ &zBuf[1]);
16619
+ rc = p->pReal->pMethods->xSync(p->pReal, flags);
16620
+ vfstrace_printf(pInfo, " -> %d\n", rc);
16621
+ return rc;
16622
+}
16623
+
16624
+/*
16625
+** Return the current file-size of an vfstrace-file.
16626
+*/
16627
+static int vfstraceFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){
16628
+ vfstrace_file *p = (vfstrace_file *)pFile;
16629
+ vfstrace_info *pInfo = p->pInfo;
16630
+ int rc;
16631
+ vfstraceOnOff(pInfo, VTR_FSIZE);
16632
+ vfstrace_printf(pInfo, "%s.xFileSize(%s)", pInfo->zVfsName, p->zFName);
16633
+ rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);
16634
+ vfstrace_print_errcode(pInfo, " -> %s,", rc);
16635
+ vfstrace_printf(pInfo, " size=%lld\n", *pSize);
16636
+ return rc;
16637
+}
16638
+
16639
+/*
16640
+** Return the name of a lock.
16641
+*/
16642
+static const char *lockName(int eLock){
16643
+ const char *azLockNames[] = {
16644
+ "NONE", "SHARED", "RESERVED", "PENDING", "EXCLUSIVE"
16645
+ };
16646
+ if( eLock<0 || eLock>=(int)(sizeof(azLockNames)/sizeof(azLockNames[0])) ){
16647
+ return "???";
16648
+ }else{
16649
+ return azLockNames[eLock];
16650
+ }
16651
+}
16652
+
16653
+/*
16654
+** Lock an vfstrace-file.
16655
+*/
16656
+static int vfstraceLock(sqlite3_file *pFile, int eLock){
16657
+ vfstrace_file *p = (vfstrace_file *)pFile;
16658
+ vfstrace_info *pInfo = p->pInfo;
16659
+ int rc;
16660
+ vfstraceOnOff(pInfo, VTR_LOCK);
16661
+ vfstrace_printf(pInfo, "%s.xLock(%s,%s)", pInfo->zVfsName, p->zFName,
16662
+ lockName(eLock));
16663
+ rc = p->pReal->pMethods->xLock(p->pReal, eLock);
16664
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
16665
+ return rc;
16666
+}
16667
+
16668
+/*
16669
+** Unlock an vfstrace-file.
16670
+*/
16671
+static int vfstraceUnlock(sqlite3_file *pFile, int eLock){
16672
+ vfstrace_file *p = (vfstrace_file *)pFile;
16673
+ vfstrace_info *pInfo = p->pInfo;
16674
+ int rc;
16675
+ vfstraceOnOff(pInfo, VTR_UNLOCK);
16676
+ vfstrace_printf(pInfo, "%s.xUnlock(%s,%s)", pInfo->zVfsName, p->zFName,
16677
+ lockName(eLock));
16678
+ rc = p->pReal->pMethods->xUnlock(p->pReal, eLock);
16679
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
16680
+ return rc;
16681
+}
16682
+
16683
+/*
16684
+** Check if another file-handle holds a RESERVED lock on an vfstrace-file.
16685
+*/
16686
+static int vfstraceCheckReservedLock(sqlite3_file *pFile, int *pResOut){
16687
+ vfstrace_file *p = (vfstrace_file *)pFile;
16688
+ vfstrace_info *pInfo = p->pInfo;
16689
+ int rc;
16690
+ vfstraceOnOff(pInfo, VTR_CRL);
16691
+ vfstrace_printf(pInfo, "%s.xCheckReservedLock(%s,%d)",
16692
+ pInfo->zVfsName, p->zFName);
16693
+ rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);
16694
+ vfstrace_print_errcode(pInfo, " -> %s", rc);
16695
+ vfstrace_printf(pInfo, ", out=%d\n", *pResOut);
16696
+ return rc;
16697
+}
16698
+
16699
+/*
16700
+** File control method. For custom operations on an vfstrace-file.
16701
+*/
16702
+static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){
16703
+ vfstrace_file *p = (vfstrace_file *)pFile;
16704
+ vfstrace_info *pInfo = p->pInfo;
16705
+ int rc;
16706
+ char zBuf[100];
16707
+ char zBuf2[100];
16708
+ char *zOp;
16709
+ char *zRVal = 0;
16710
+ vfstraceOnOff(pInfo, VTR_FCTRL);
16711
+ switch( op ){
16712
+ case SQLITE_FCNTL_LOCKSTATE: zOp = "LOCKSTATE"; break;
16713
+ case SQLITE_GET_LOCKPROXYFILE: zOp = "GET_LOCKPROXYFILE"; break;
16714
+ case SQLITE_SET_LOCKPROXYFILE: zOp = "SET_LOCKPROXYFILE"; break;
16715
+ case SQLITE_LAST_ERRNO: zOp = "LAST_ERRNO"; break;
16716
+ case SQLITE_FCNTL_SIZE_HINT: {
16717
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "SIZE_HINT,%lld",
16718
+ *(sqlite3_int64*)pArg);
16719
+ zOp = zBuf;
16720
+ break;
16721
+ }
16722
+ case SQLITE_FCNTL_CHUNK_SIZE: {
16723
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "CHUNK_SIZE,%d", *(int*)pArg);
16724
+ zOp = zBuf;
16725
+ break;
16726
+ }
16727
+ case SQLITE_FCNTL_FILE_POINTER: zOp = "FILE_POINTER"; break;
16728
+ case SQLITE_FCNTL_WIN32_AV_RETRY: zOp = "WIN32_AV_RETRY"; break;
16729
+ case SQLITE_FCNTL_PERSIST_WAL: {
16730
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "PERSIST_WAL,%d", *(int*)pArg);
16731
+ zOp = zBuf;
16732
+ break;
16733
+ }
16734
+ case SQLITE_FCNTL_OVERWRITE: zOp = "OVERWRITE"; break;
16735
+ case SQLITE_FCNTL_VFSNAME: zOp = "VFSNAME"; break;
16736
+ case SQLITE_FCNTL_POWERSAFE_OVERWRITE: zOp = "POWERSAFE_OVERWRITE"; break;
16737
+ case SQLITE_FCNTL_PRAGMA: {
16738
+ const char *const* a = (const char*const*)pArg;
16739
+ if( a[1] && strcmp(a[1],"vfstrace")==0 && a[2] ){
16740
+ const u8 *zArg = (const u8*)a[2];
16741
+ if( zArg[0]>='0' && zArg[0]<=9 ){
16742
+ pInfo->mTrace = (sqlite3_uint64)strtoll(a[2], 0, 0);
16743
+ }else{
16744
+ static const struct {
16745
+ const char *z;
16746
+ unsigned int m;
16747
+ } aKw[] = {
16748
+ { "all", 0xffffffff },
16749
+ { "close", VTR_CLOSE },
16750
+ { "read", VTR_READ },
16751
+ { "write", VTR_WRITE },
16752
+ { "truncate", VTR_TRUNC },
16753
+ { "sync", VTR_SYNC },
16754
+ { "filesize", VTR_FSIZE },
16755
+ { "lock", VTR_LOCK },
16756
+ { "unlock", VTR_UNLOCK },
16757
+ { "checkreservedlock", VTR_CRL },
16758
+ { "filecontrol", VTR_FCTRL },
16759
+ { "sectorsize", VTR_SECSZ },
16760
+ { "devicecharacteristics", VTR_DEVCHAR },
16761
+ { "shmlock", VTR_SHMLOCK },
16762
+ { "shmmap", VTR_SHMMAP },
16763
+ { "shmummap", VTR_SHMUNMAP },
16764
+ { "shmbarrier", VTR_SHMBAR },
16765
+ { "open", VTR_OPEN },
16766
+ { "delete", VTR_DELETE },
16767
+ { "access", VTR_ACCESS },
16768
+ { "fullpathname", VTR_FULLPATH },
16769
+ { "dlopen", VTR_DLOPEN },
16770
+ { "dlerror", VTR_DLERR },
16771
+ { "dlsym", VTR_DLSYM },
16772
+ { "dlclose", VTR_DLCLOSE },
16773
+ { "randomness", VTR_RAND },
16774
+ { "sleep", VTR_SLEEP },
16775
+ { "currenttime", VTR_CURTIME },
16776
+ { "currenttimeint64", VTR_CURTIME },
16777
+ { "getlasterror", VTR_LASTERR },
16778
+ };
16779
+ int onOff = 1;
16780
+ while( zArg[0] ){
16781
+ int jj, n;
16782
+ while( zArg[0]!=0 && zArg[0]!='-' && zArg[0]!='+'
16783
+ && !isalpha(zArg[0]) ) zArg++;
16784
+ if( zArg[0]==0 ) break;
16785
+ if( zArg[0]=='-' ){
16786
+ onOff = 0;
16787
+ zArg++;
16788
+ }else if( zArg[0]=='+' ){
16789
+ onOff = 1;
16790
+ zArg++;
16791
+ }
16792
+ while( !isalpha(zArg[0]) ){
16793
+ if( zArg[0]==0 ) break;
16794
+ zArg++;
16795
+ }
16796
+ if( zArg[0]=='x' && isalpha(zArg[1]) ) zArg++;
16797
+ for(n=0; isalpha(zArg[n]); n++){}
16798
+ for(jj=0; jj<(int)(sizeof(aKw)/sizeof(aKw[0])); jj++){
16799
+ if( sqlite3_strnicmp(aKw[jj].z,(const char*)zArg,n)==0 ){
16800
+ if( onOff ){
16801
+ pInfo->mTrace |= aKw[jj].m;
16802
+ }else{
16803
+ pInfo->mTrace &= ~aKw[jj].m;
16804
+ }
16805
+ break;
16806
+ }
16807
+ }
16808
+ zArg += n;
16809
+ }
16810
+ }
16811
+ }
16812
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "PRAGMA,[%s,%s]",a[1],a[2]);
16813
+ zOp = zBuf;
16814
+ break;
16815
+ }
16816
+ case SQLITE_FCNTL_BUSYHANDLER: zOp = "BUSYHANDLER"; break;
16817
+ case SQLITE_FCNTL_TEMPFILENAME: zOp = "TEMPFILENAME"; break;
16818
+ case SQLITE_FCNTL_MMAP_SIZE: {
16819
+ sqlite3_int64 iMMap = *(sqlite3_int64*)pArg;
16820
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "MMAP_SIZE,%lld",iMMap);
16821
+ zOp = zBuf;
16822
+ break;
16823
+ }
16824
+ case SQLITE_FCNTL_TRACE: zOp = "TRACE"; break;
16825
+ case SQLITE_FCNTL_HAS_MOVED: zOp = "HAS_MOVED"; break;
16826
+ case SQLITE_FCNTL_SYNC: zOp = "SYNC"; break;
16827
+ case SQLITE_FCNTL_COMMIT_PHASETWO: zOp = "COMMIT_PHASETWO"; break;
16828
+ case SQLITE_FCNTL_WIN32_SET_HANDLE: zOp = "WIN32_SET_HANDLE"; break;
16829
+ case SQLITE_FCNTL_WAL_BLOCK: zOp = "WAL_BLOCK"; break;
16830
+ case SQLITE_FCNTL_ZIPVFS: zOp = "ZIPVFS"; break;
16831
+ case SQLITE_FCNTL_RBU: zOp = "RBU"; break;
16832
+ case SQLITE_FCNTL_VFS_POINTER: zOp = "VFS_POINTER"; break;
16833
+ case SQLITE_FCNTL_JOURNAL_POINTER: zOp = "JOURNAL_POINTER"; break;
16834
+ case SQLITE_FCNTL_WIN32_GET_HANDLE: zOp = "WIN32_GET_HANDLE"; break;
16835
+ case SQLITE_FCNTL_PDB: zOp = "PDB"; break;
16836
+ case SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: zOp = "BEGIN_ATOMIC_WRITE"; break;
16837
+ case SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: zOp = "COMMIT_ATOMIC_WRITE"; break;
16838
+ case SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: {
16839
+ zOp = "ROLLBACK_ATOMIC_WRITE";
16840
+ break;
16841
+ }
16842
+ case SQLITE_FCNTL_LOCK_TIMEOUT: {
16843
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "LOCK_TIMEOUT,%d", *(int*)pArg);
16844
+ zOp = zBuf;
16845
+ break;
16846
+ }
16847
+ case SQLITE_FCNTL_DATA_VERSION: zOp = "DATA_VERSION"; break;
16848
+ case SQLITE_FCNTL_SIZE_LIMIT: zOp = "SIZE_LIMIT"; break;
16849
+ case SQLITE_FCNTL_CKPT_DONE: zOp = "CKPT_DONE"; break;
16850
+ case SQLITE_FCNTL_RESERVE_BYTES: zOp = "RESERVED_BYTES"; break;
16851
+ case SQLITE_FCNTL_CKPT_START: zOp = "CKPT_START"; break;
16852
+ case SQLITE_FCNTL_EXTERNAL_READER: zOp = "EXTERNAL_READER"; break;
16853
+ case SQLITE_FCNTL_CKSM_FILE: zOp = "CKSM_FILE"; break;
16854
+ case SQLITE_FCNTL_RESET_CACHE: zOp = "RESET_CACHE"; break;
16855
+ case 0xca093fa0: zOp = "DB_UNCHANGED"; break;
16856
+ default: {
16857
+ sqlite3_snprintf(sizeof zBuf, zBuf, "%d", op);
16858
+ zOp = zBuf;
16859
+ break;
16860
+ }
16861
+ }
16862
+ vfstrace_printf(pInfo, "%s.xFileControl(%s,%s)",
16863
+ pInfo->zVfsName, p->zFName, zOp);
16864
+ rc = p->pReal->pMethods->xFileControl(p->pReal, op, pArg);
16865
+ if( rc==SQLITE_OK ){
16866
+ switch( op ){
16867
+ case SQLITE_FCNTL_VFSNAME: {
16868
+ *(char**)pArg = sqlite3_mprintf("vfstrace.%s/%z",
16869
+ pInfo->zVfsName, *(char**)pArg);
16870
+ zRVal = *(char**)pArg;
16871
+ break;
16872
+ }
16873
+ case SQLITE_FCNTL_MMAP_SIZE: {
16874
+ sqlite3_snprintf(sizeof(zBuf2), zBuf2, "%lld", *(sqlite3_int64*)pArg);
16875
+ zRVal = zBuf2;
16876
+ break;
16877
+ }
16878
+ case SQLITE_FCNTL_HAS_MOVED:
16879
+ case SQLITE_FCNTL_PERSIST_WAL: {
16880
+ sqlite3_snprintf(sizeof(zBuf2), zBuf2, "%d", *(int*)pArg);
16881
+ zRVal = zBuf2;
16882
+ break;
16883
+ }
16884
+ case SQLITE_FCNTL_PRAGMA:
16885
+ case SQLITE_FCNTL_TEMPFILENAME: {
16886
+ zRVal = *(char**)pArg;
16887
+ break;
16888
+ }
16889
+ }
16890
+ }
16891
+ if( zRVal ){
16892
+ vfstrace_print_errcode(pInfo, " -> %s", rc);
16893
+ vfstrace_printf(pInfo, ", %s\n", zRVal);
16894
+ }else{
16895
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
16896
+ }
16897
+ return rc;
16898
+}
16899
+
16900
+/*
16901
+** Return the sector-size in bytes for an vfstrace-file.
16902
+*/
16903
+static int vfstraceSectorSize(sqlite3_file *pFile){
16904
+ vfstrace_file *p = (vfstrace_file *)pFile;
16905
+ vfstrace_info *pInfo = p->pInfo;
16906
+ int rc;
16907
+ vfstraceOnOff(pInfo, VTR_SECSZ);
16908
+ vfstrace_printf(pInfo, "%s.xSectorSize(%s)", pInfo->zVfsName, p->zFName);
16909
+ rc = p->pReal->pMethods->xSectorSize(p->pReal);
16910
+ vfstrace_printf(pInfo, " -> %d\n", rc);
16911
+ return rc;
16912
+}
16913
+
16914
+/*
16915
+** Return the device characteristic flags supported by an vfstrace-file.
16916
+*/
16917
+static int vfstraceDeviceCharacteristics(sqlite3_file *pFile){
16918
+ vfstrace_file *p = (vfstrace_file *)pFile;
16919
+ vfstrace_info *pInfo = p->pInfo;
16920
+ int rc;
16921
+ vfstraceOnOff(pInfo, VTR_DEVCHAR);
16922
+ vfstrace_printf(pInfo, "%s.xDeviceCharacteristics(%s)",
16923
+ pInfo->zVfsName, p->zFName);
16924
+ rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal);
16925
+ vfstrace_printf(pInfo, " -> 0x%08x\n", rc);
16926
+ return rc;
16927
+}
16928
+
16929
+/*
16930
+** Shared-memory operations.
16931
+*/
16932
+static int vfstraceShmLock(sqlite3_file *pFile, int ofst, int n, int flags){
16933
+ static const char *azLockName[] = {
16934
+ "WRITE",
16935
+ "CKPT",
16936
+ "RECOVER",
16937
+ "READ0",
16938
+ "READ1",
16939
+ "READ2",
16940
+ "READ3",
16941
+ "READ4",
16942
+ };
16943
+ vfstrace_file *p = (vfstrace_file *)pFile;
16944
+ vfstrace_info *pInfo = p->pInfo;
16945
+ int rc;
16946
+ char zLck[100];
16947
+ int i = 0;
16948
+ vfstraceOnOff(pInfo, VTR_SHMLOCK);
16949
+ memcpy(zLck, "|0", 3);
16950
+ if( flags & SQLITE_SHM_UNLOCK ) strappend(zLck, &i, "|UNLOCK");
16951
+ if( flags & SQLITE_SHM_LOCK ) strappend(zLck, &i, "|LOCK");
16952
+ if( flags & SQLITE_SHM_SHARED ) strappend(zLck, &i, "|SHARED");
16953
+ if( flags & SQLITE_SHM_EXCLUSIVE ) strappend(zLck, &i, "|EXCLUSIVE");
16954
+ if( flags & ~(0xf) ){
16955
+ sqlite3_snprintf(sizeof(zLck)-i, &zLck[i], "|0x%x", flags);
16956
+ }
16957
+ if( ofst>=0 && ofst<(int)(sizeof(azLockName)/sizeof(azLockName[0])) ){
16958
+ vfstrace_printf(pInfo, "%s.xShmLock(%s,ofst=%d(%s),n=%d,%s)",
16959
+ pInfo->zVfsName, p->zFName, ofst, azLockName[ofst],
16960
+ n, &zLck[1]);
16961
+ }else{
16962
+ vfstrace_printf(pInfo, "%s.xShmLock(%s,ofst=5d,n=%d,%s)",
16963
+ pInfo->zVfsName, p->zFName, ofst,
16964
+ n, &zLck[1]);
16965
+ }
16966
+ rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags);
16967
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
16968
+ return rc;
16969
+}
16970
+static int vfstraceShmMap(
16971
+ sqlite3_file *pFile,
16972
+ int iRegion,
16973
+ int szRegion,
16974
+ int isWrite,
16975
+ void volatile **pp
16976
+){
16977
+ vfstrace_file *p = (vfstrace_file *)pFile;
16978
+ vfstrace_info *pInfo = p->pInfo;
16979
+ int rc;
16980
+ vfstraceOnOff(pInfo, VTR_SHMMAP);
16981
+ vfstrace_printf(pInfo, "%s.xShmMap(%s,iRegion=%d,szRegion=%d,isWrite=%d,*)",
16982
+ pInfo->zVfsName, p->zFName, iRegion, szRegion, isWrite);
16983
+ rc = p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, isWrite, pp);
16984
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
16985
+ return rc;
16986
+}
16987
+static void vfstraceShmBarrier(sqlite3_file *pFile){
16988
+ vfstrace_file *p = (vfstrace_file *)pFile;
16989
+ vfstrace_info *pInfo = p->pInfo;
16990
+ vfstraceOnOff(pInfo, VTR_SHMBAR);
16991
+ vfstrace_printf(pInfo, "%s.xShmBarrier(%s)\n", pInfo->zVfsName, p->zFName);
16992
+ p->pReal->pMethods->xShmBarrier(p->pReal);
16993
+}
16994
+static int vfstraceShmUnmap(sqlite3_file *pFile, int delFlag){
16995
+ vfstrace_file *p = (vfstrace_file *)pFile;
16996
+ vfstrace_info *pInfo = p->pInfo;
16997
+ int rc;
16998
+ vfstraceOnOff(pInfo, VTR_SHMUNMAP);
16999
+ vfstrace_printf(pInfo, "%s.xShmUnmap(%s,delFlag=%d)",
17000
+ pInfo->zVfsName, p->zFName, delFlag);
17001
+ rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
17002
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
17003
+ return rc;
17004
+}
17005
+
17006
+
17007
+
17008
+/*
17009
+** Open an vfstrace file handle.
17010
+*/
17011
+static int vfstraceOpen(
17012
+ sqlite3_vfs *pVfs,
17013
+ const char *zName,
17014
+ sqlite3_file *pFile,
17015
+ int flags,
17016
+ int *pOutFlags
17017
+){
17018
+ int rc;
17019
+ vfstrace_file *p = (vfstrace_file *)pFile;
17020
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17021
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17022
+ p->pInfo = pInfo;
17023
+ p->zFName = zName ? fileTail(zName) : "<temp>";
17024
+ p->pReal = (sqlite3_file *)&p[1];
17025
+ rc = pRoot->xOpen(pRoot, zName, p->pReal, flags, pOutFlags);
17026
+ vfstraceOnOff(pInfo, VTR_OPEN);
17027
+ vfstrace_printf(pInfo, "%s.xOpen(%s,flags=0x%x)",
17028
+ pInfo->zVfsName, p->zFName, flags);
17029
+ if( p->pReal->pMethods ){
17030
+ sqlite3_io_methods *pNew = sqlite3_malloc( sizeof(*pNew) );
17031
+ const sqlite3_io_methods *pSub = p->pReal->pMethods;
17032
+ memset(pNew, 0, sizeof(*pNew));
17033
+ pNew->iVersion = pSub->iVersion;
17034
+ pNew->xClose = vfstraceClose;
17035
+ pNew->xRead = vfstraceRead;
17036
+ pNew->xWrite = vfstraceWrite;
17037
+ pNew->xTruncate = vfstraceTruncate;
17038
+ pNew->xSync = vfstraceSync;
17039
+ pNew->xFileSize = vfstraceFileSize;
17040
+ pNew->xLock = vfstraceLock;
17041
+ pNew->xUnlock = vfstraceUnlock;
17042
+ pNew->xCheckReservedLock = vfstraceCheckReservedLock;
17043
+ pNew->xFileControl = vfstraceFileControl;
17044
+ pNew->xSectorSize = vfstraceSectorSize;
17045
+ pNew->xDeviceCharacteristics = vfstraceDeviceCharacteristics;
17046
+ if( pNew->iVersion>=2 ){
17047
+ pNew->xShmMap = pSub->xShmMap ? vfstraceShmMap : 0;
17048
+ pNew->xShmLock = pSub->xShmLock ? vfstraceShmLock : 0;
17049
+ pNew->xShmBarrier = pSub->xShmBarrier ? vfstraceShmBarrier : 0;
17050
+ pNew->xShmUnmap = pSub->xShmUnmap ? vfstraceShmUnmap : 0;
17051
+ }
17052
+ pFile->pMethods = pNew;
17053
+ }
17054
+ vfstrace_print_errcode(pInfo, " -> %s", rc);
17055
+ if( pOutFlags ){
17056
+ vfstrace_printf(pInfo, ", outFlags=0x%x\n", *pOutFlags);
17057
+ }else{
17058
+ vfstrace_printf(pInfo, "\n");
17059
+ }
17060
+ return rc;
17061
+}
17062
+
17063
+/*
17064
+** Delete the file located at zPath. If the dirSync argument is true,
17065
+** ensure the file-system modifications are synced to disk before
17066
+** returning.
17067
+*/
17068
+static int vfstraceDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
17069
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17070
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17071
+ int rc;
17072
+ vfstraceOnOff(pInfo, VTR_DELETE);
17073
+ vfstrace_printf(pInfo, "%s.xDelete(\"%s\",%d)",
17074
+ pInfo->zVfsName, zPath, dirSync);
17075
+ rc = pRoot->xDelete(pRoot, zPath, dirSync);
17076
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
17077
+ return rc;
17078
+}
17079
+
17080
+/*
17081
+** Test for access permissions. Return true if the requested permission
17082
+** is available, or false otherwise.
17083
+*/
17084
+static int vfstraceAccess(
17085
+ sqlite3_vfs *pVfs,
17086
+ const char *zPath,
17087
+ int flags,
17088
+ int *pResOut
17089
+){
17090
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17091
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17092
+ int rc;
17093
+ vfstraceOnOff(pInfo, VTR_ACCESS);
17094
+ vfstrace_printf(pInfo, "%s.xAccess(\"%s\",%d)",
17095
+ pInfo->zVfsName, zPath, flags);
17096
+ rc = pRoot->xAccess(pRoot, zPath, flags, pResOut);
17097
+ vfstrace_print_errcode(pInfo, " -> %s", rc);
17098
+ vfstrace_printf(pInfo, ", out=%d\n", *pResOut);
17099
+ return rc;
17100
+}
17101
+
17102
+/*
17103
+** Populate buffer zOut with the full canonical pathname corresponding
17104
+** to the pathname in zPath. zOut is guaranteed to point to a buffer
17105
+** of at least (DEVSYM_MAX_PATHNAME+1) bytes.
17106
+*/
17107
+static int vfstraceFullPathname(
17108
+ sqlite3_vfs *pVfs,
17109
+ const char *zPath,
17110
+ int nOut,
17111
+ char *zOut
17112
+){
17113
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17114
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17115
+ int rc;
17116
+ vfstraceOnOff(pInfo, VTR_FULLPATH);
17117
+ vfstrace_printf(pInfo, "%s.xFullPathname(\"%s\")",
17118
+ pInfo->zVfsName, zPath);
17119
+ rc = pRoot->xFullPathname(pRoot, zPath, nOut, zOut);
17120
+ vfstrace_print_errcode(pInfo, " -> %s", rc);
17121
+ vfstrace_printf(pInfo, ", out=\"%.*s\"\n", nOut, zOut);
17122
+ return rc;
17123
+}
17124
+
17125
+/*
17126
+** Open the dynamic library located at zPath and return a handle.
17127
+*/
17128
+static void *vfstraceDlOpen(sqlite3_vfs *pVfs, const char *zPath){
17129
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17130
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17131
+ vfstraceOnOff(pInfo, VTR_DLOPEN);
17132
+ vfstrace_printf(pInfo, "%s.xDlOpen(\"%s\")\n", pInfo->zVfsName, zPath);
17133
+ return pRoot->xDlOpen(pRoot, zPath);
17134
+}
17135
+
17136
+/*
17137
+** Populate the buffer zErrMsg (size nByte bytes) with a human readable
17138
+** utf-8 string describing the most recent error encountered associated
17139
+** with dynamic libraries.
17140
+*/
17141
+static void vfstraceDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){
17142
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17143
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17144
+ vfstraceOnOff(pInfo, VTR_DLERR);
17145
+ vfstrace_printf(pInfo, "%s.xDlError(%d)", pInfo->zVfsName, nByte);
17146
+ pRoot->xDlError(pRoot, nByte, zErrMsg);
17147
+ vfstrace_printf(pInfo, " -> \"%s\"", zErrMsg);
17148
+}
17149
+
17150
+/*
17151
+** Return a pointer to the symbol zSymbol in the dynamic library pHandle.
17152
+*/
17153
+static void (*vfstraceDlSym(sqlite3_vfs *pVfs,void *p,const char *zSym))(void){
17154
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17155
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17156
+ vfstrace_printf(pInfo, "%s.xDlSym(\"%s\")\n", pInfo->zVfsName, zSym);
17157
+ return pRoot->xDlSym(pRoot, p, zSym);
17158
+}
17159
+
17160
+/*
17161
+** Close the dynamic library handle pHandle.
17162
+*/
17163
+static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){
17164
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17165
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17166
+ vfstraceOnOff(pInfo, VTR_DLCLOSE);
17167
+ vfstrace_printf(pInfo, "%s.xDlOpen()\n", pInfo->zVfsName);
17168
+ pRoot->xDlClose(pRoot, pHandle);
17169
+}
17170
+
17171
+/*
17172
+** Populate the buffer pointed to by zBufOut with nByte bytes of
17173
+** random data.
17174
+*/
17175
+static int vfstraceRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
17176
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17177
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17178
+ vfstraceOnOff(pInfo, VTR_RAND);
17179
+ vfstrace_printf(pInfo, "%s.xRandomness(%d)\n", pInfo->zVfsName, nByte);
17180
+ return pRoot->xRandomness(pRoot, nByte, zBufOut);
17181
+}
17182
+
17183
+/*
17184
+** Sleep for nMicro microseconds. Return the number of microseconds
17185
+** actually slept.
17186
+*/
17187
+static int vfstraceSleep(sqlite3_vfs *pVfs, int nMicro){
17188
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17189
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17190
+ vfstraceOnOff(pInfo, VTR_SLEEP);
17191
+ vfstrace_printf(pInfo, "%s.xSleep(%d)\n", pInfo->zVfsName, nMicro);
17192
+ return pRoot->xSleep(pRoot, nMicro);
17193
+}
17194
+
17195
+/*
17196
+** Return the current time as a Julian Day number in *pTimeOut.
17197
+*/
17198
+static int vfstraceCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){
17199
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17200
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17201
+ int rc;
17202
+ vfstraceOnOff(pInfo, VTR_CURTIME);
17203
+ vfstrace_printf(pInfo, "%s.xCurrentTime()", pInfo->zVfsName);
17204
+ rc = pRoot->xCurrentTime(pRoot, pTimeOut);
17205
+ vfstrace_printf(pInfo, " -> %.17g\n", *pTimeOut);
17206
+ return rc;
17207
+}
17208
+static int vfstraceCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){
17209
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17210
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17211
+ int rc;
17212
+ vfstraceOnOff(pInfo, VTR_CURTIME);
17213
+ vfstrace_printf(pInfo, "%s.xCurrentTimeInt64()", pInfo->zVfsName);
17214
+ rc = pRoot->xCurrentTimeInt64(pRoot, pTimeOut);
17215
+ vfstrace_printf(pInfo, " -> %lld\n", *pTimeOut);
17216
+ return rc;
17217
+}
17218
+
17219
+/*
17220
+** Return the most recent error code and message
17221
+*/
17222
+static int vfstraceGetLastError(sqlite3_vfs *pVfs, int nErr, char *zErr){
17223
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17224
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17225
+ int rc;
17226
+ vfstraceOnOff(pInfo, VTR_LASTERR);
17227
+ vfstrace_printf(pInfo, "%s.xGetLastError(%d,zBuf)", pInfo->zVfsName, nErr);
17228
+ if( nErr ) zErr[0] = 0;
17229
+ rc = pRoot->xGetLastError(pRoot, nErr, zErr);
17230
+ vfstrace_printf(pInfo, " -> zBuf[] = \"%s\", rc = %d\n", nErr?zErr:"", rc);
17231
+ return rc;
17232
+}
17233
+
17234
+/*
17235
+** Override system calls.
17236
+*/
17237
+static int vfstraceSetSystemCall(
17238
+ sqlite3_vfs *pVfs,
17239
+ const char *zName,
17240
+ sqlite3_syscall_ptr pFunc
17241
+){
17242
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17243
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17244
+ return pRoot->xSetSystemCall(pRoot, zName, pFunc);
17245
+}
17246
+static sqlite3_syscall_ptr vfstraceGetSystemCall(
17247
+ sqlite3_vfs *pVfs,
17248
+ const char *zName
17249
+){
17250
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17251
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17252
+ return pRoot->xGetSystemCall(pRoot, zName);
17253
+}
17254
+static const char *vfstraceNextSystemCall(sqlite3_vfs *pVfs, const char *zName){
17255
+ vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17256
+ sqlite3_vfs *pRoot = pInfo->pRootVfs;
17257
+ return pRoot->xNextSystemCall(pRoot, zName);
17258
+}
17259
+
17260
+
17261
+/*
17262
+** Clients invoke this routine to construct a new trace-vfs shim.
17263
+**
17264
+** Return SQLITE_OK on success.
17265
+**
17266
+** SQLITE_NOMEM is returned in the case of a memory allocation error.
17267
+** SQLITE_NOTFOUND is returned if zOldVfsName does not exist.
17268
+*/
17269
+int vfstrace_register(
17270
+ const char *zTraceName, /* Name of the newly constructed VFS */
17271
+ const char *zOldVfsName, /* Name of the underlying VFS */
17272
+ int (*xOut)(const char*,void*), /* Output routine. ex: fputs */
17273
+ void *pOutArg, /* 2nd argument to xOut. ex: stderr */
17274
+ int makeDefault /* True to make the new VFS the default */
17275
+){
17276
+ sqlite3_vfs *pNew;
17277
+ sqlite3_vfs *pRoot;
17278
+ vfstrace_info *pInfo;
17279
+ size_t nName;
17280
+ size_t nByte;
17281
+
17282
+ pRoot = sqlite3_vfs_find(zOldVfsName);
17283
+ if( pRoot==0 ) return SQLITE_NOTFOUND;
17284
+ nName = strlen(zTraceName);
17285
+ nByte = sizeof(*pNew) + sizeof(*pInfo) + nName + 1;
17286
+ pNew = sqlite3_malloc64( nByte );
17287
+ if( pNew==0 ) return SQLITE_NOMEM;
17288
+ memset(pNew, 0, nByte);
17289
+ pInfo = (vfstrace_info*)&pNew[1];
17290
+ pNew->iVersion = pRoot->iVersion;
17291
+ pNew->szOsFile = pRoot->szOsFile + sizeof(vfstrace_file);
17292
+ pNew->mxPathname = pRoot->mxPathname;
17293
+ pNew->zName = (char*)&pInfo[1];
17294
+ memcpy((char*)&pInfo[1], zTraceName, nName+1);
17295
+ pNew->pAppData = pInfo;
17296
+ pNew->xOpen = vfstraceOpen;
17297
+ pNew->xDelete = vfstraceDelete;
17298
+ pNew->xAccess = vfstraceAccess;
17299
+ pNew->xFullPathname = vfstraceFullPathname;
17300
+ pNew->xDlOpen = pRoot->xDlOpen==0 ? 0 : vfstraceDlOpen;
17301
+ pNew->xDlError = pRoot->xDlError==0 ? 0 : vfstraceDlError;
17302
+ pNew->xDlSym = pRoot->xDlSym==0 ? 0 : vfstraceDlSym;
17303
+ pNew->xDlClose = pRoot->xDlClose==0 ? 0 : vfstraceDlClose;
17304
+ pNew->xRandomness = vfstraceRandomness;
17305
+ pNew->xSleep = vfstraceSleep;
17306
+ pNew->xCurrentTime = vfstraceCurrentTime;
17307
+ pNew->xGetLastError = pRoot->xGetLastError==0 ? 0 : vfstraceGetLastError;
17308
+ if( pNew->iVersion>=2 ){
17309
+ pNew->xCurrentTimeInt64 = pRoot->xCurrentTimeInt64==0 ? 0 :
17310
+ vfstraceCurrentTimeInt64;
17311
+ if( pNew->iVersion>=3 ){
17312
+ pNew->xSetSystemCall = pRoot->xSetSystemCall==0 ? 0 :
17313
+ vfstraceSetSystemCall;
17314
+ pNew->xGetSystemCall = pRoot->xGetSystemCall==0 ? 0 :
17315
+ vfstraceGetSystemCall;
17316
+ pNew->xNextSystemCall = pRoot->xNextSystemCall==0 ? 0 :
17317
+ vfstraceNextSystemCall;
17318
+ }
17319
+ }
17320
+ pInfo->pRootVfs = pRoot;
17321
+ pInfo->xOut = xOut;
17322
+ pInfo->pOutArg = pOutArg;
17323
+ pInfo->zVfsName = pNew->zName;
17324
+ pInfo->pTraceVfs = pNew;
17325
+ pInfo->mTrace = 0xffffffff;
17326
+ pInfo->bOn = 1;
17327
+ vfstrace_printf(pInfo, "%s.enabled_for(\"%s\")\n",
17328
+ pInfo->zVfsName, pRoot->zName);
17329
+ return sqlite3_vfs_register(pNew, makeDefault);
17330
+}
17331
+
17332
+/*
17333
+** Look for the named VFS. If it is a TRACEVFS, then unregister it
17334
+** and delete it.
17335
+*/
17336
+void vfstrace_unregister(const char *zTraceName){
17337
+ sqlite3_vfs *pVfs = sqlite3_vfs_find(zTraceName);
17338
+ if( pVfs==0 ) return;
17339
+ if( pVfs->xOpen!=vfstraceOpen ) return;
17340
+ sqlite3_vfs_unregister(pVfs);
17341
+ sqlite3_free(pVfs);
17342
+}
17343
+
17344
+/************************* End ../ext/misc/vfstrace.c ********************/
1621617345
1621717346
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
1621817347
#define SQLITE_SHELL_HAVE_RECOVER 1
1621917348
#else
1622017349
#define SQLITE_SHELL_HAVE_RECOVER 0
@@ -18241,11 +19370,11 @@
1824119370
}while( strstr(z,zBuf)!=0 );
1824219371
return zBuf;
1824319372
}
1824419373
1824519374
/*
18246
-** Implementation of scalar SQL function "escape_crnl". The argument passed to
19375
+** Implementation of scalar SQL function "escape_crlf". The argument passed to
1824719376
** this function is the output of built-in function quote(). If the first
1824819377
** character of the input is "'", indicating that the value passed to quote()
1824919378
** was a text value, then this function searches the input for "\n" and "\r"
1825019379
** characters and adds a wrapper similar to the following:
1825119380
**
@@ -18252,11 +19381,11 @@
1825219381
** replace(replace(<input>, '\n'