Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add support for markdown page titles |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | commonmark-markdown |
| Files: | files | file ages | folders |
| SHA3-256: |
4a298e69ecb74b05ca73f6cea093186b |
| User & Date: | mjanssen 2017-10-04 10:59:14.719 |
Context
|
2017-10-04
| ||
| 11:37 | Simplify title determining code check-in: b36643651c user: mjanssen tags: commonmark-markdown | |
| 10:59 | Add support for markdown page titles check-in: 4a298e69ec user: mjanssen tags: commonmark-markdown | |
| 05:35 | Improvement to TH_RETURN handling needed for TH1 hooks. Update and correct TH1 hook tests. Add draft documentation for TH1 hooks. check-in: 36f0e47b32 user: mistachkin tags: trunk | |
|
2017-03-11
| ||
| 13:59 | Add test commonmark test suite check-in: 9893619067 user: mjanssen tags: commonmark-markdown | |
Changes
Name change from .fossil-settings/crnl-glob to .fossil-settings/crlf-glob.
Changes to VERSION.
|
| | | 1 | 2.4 |
Changes to auto.def.
| ︙ | ︙ | |||
9 10 11 12 13 14 15 |
with-zlib:path|auto|tree
=> {Look for zlib in the given path, automatically, or in the source tree}
with-exec-rel-paths=0
=> {Enable relative paths for external diff/gdiff}
with-legacy-mv-rm=0 => {Enable legacy behavior for mv/rm (skip checkout files)}
with-th1-docs=0 => {Enable TH1 for embedded documentation pages}
with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
| | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
with-zlib:path|auto|tree
=> {Look for zlib in the given path, automatically, or in the source tree}
with-exec-rel-paths=0
=> {Enable relative paths for external diff/gdiff}
with-legacy-mv-rm=0 => {Enable legacy behavior for mv/rm (skip checkout files)}
with-th1-docs=0 => {Enable TH1 for embedded documentation pages}
with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
with-tcl=path => {Enable Tcl integration, with Tcl in the specified path}
with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
with-tcl-private-stubs=0
=> {Enable Tcl integration via private stubs mechanism}
with-see=0 => {Enable the SQLite Encryption Extension (SEE)}
internal-sqlite=1 => {Don't use the internal SQLite, use the system one}
static=0 => {Link a static executable}
fusefs=1 => {Disable the Fuse Filesystem}
|
| ︙ | ︙ | |||
86 87 88 89 90 91 92 |
# search for the system SQLite once with -ldl, and once without. If
# the library can only be found with $extralibs set to -ldl, then
# the code below will append -ldl to LIBS.
#
foreach extralibs {{} {-ldl}} {
# Locate the system SQLite by searching for sqlite3_open(). Then check
| | | | | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# search for the system SQLite once with -ldl, and once without. If
# the library can only be found with $extralibs set to -ldl, then
# the code below will append -ldl to LIBS.
#
foreach extralibs {{} {-ldl}} {
# Locate the system SQLite by searching for sqlite3_open(). Then check
# if sqlite3_prepare_v3() can be found as well. If we can find open() but
# not prepare_v3(), then the system SQLite is too old to link against
# fossil.
#
if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
if {![check-function-in-lib sqlite3_prepare_v3 sqlite3 $extralibs]} {
user-error "system sqlite3 too old (require >= 3.20.0)"
}
# Success. Update symbols and return.
#
define USE_SYSTEM_SQLITE 1
define-append LIBS -lsqlite3
define-append LIBS $extralibs
|
| ︙ | ︙ | |||
130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
if {[string match *-solaris* [get-define host]]} {
define-append EXTRA_CFLAGS {-D_XOPEN_SOURCE=500 -D__EXTENSIONS__}
}
if {[opt-bool fossil-debug]} {
define-append EXTRA_CFLAGS -DFOSSIL_DEBUG
msg-result "Debugging support enabled"
}
if {[opt-bool with-see]} {
define-append EXTRA_CFLAGS -DUSE_SEE
define USE_SEE 1
msg-result "Enabling encryption support"
| > | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
if {[string match *-solaris* [get-define host]]} {
define-append EXTRA_CFLAGS {-D_XOPEN_SOURCE=500 -D__EXTENSIONS__}
}
if {[opt-bool fossil-debug]} {
define-append EXTRA_CFLAGS -DFOSSIL_DEBUG
define CFLAGS {-g -O0}
msg-result "Debugging support enabled"
}
if {[opt-bool with-see]} {
define-append EXTRA_CFLAGS -DUSE_SEE
define USE_SEE 1
msg-result "Enabling encryption support"
|
| ︙ | ︙ | |||
186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# XXX: This will not work on all systems.
define-append EXTRA_LDFLAGS -static
msg-result "Trying to link statically"
} else {
define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
define FOSSIL_DYNAMIC_BUILD
}
# Helper for OpenSSL checking
proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
msg-checking "Checking for $msg..."
set rc 0
if {[is_mingw]} {
lappend libs -lgdi32 -lwsock32 -lcrypt32
| > > > | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# XXX: This will not work on all systems.
define-append EXTRA_LDFLAGS -static
msg-result "Trying to link statically"
} else {
define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
define FOSSIL_DYNAMIC_BUILD
}
# Check for libraries that need to be sorted out early
cc-check-function-in-lib iconv iconv
# Helper for OpenSSL checking
proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
msg-checking "Checking for $msg..."
set rc 0
if {[is_mingw]} {
lappend libs -lgdi32 -lwsock32 -lcrypt32
|
| ︙ | ︙ | |||
455 456 457 458 459 460 461 |
cc-check-function-in-lib gethostbyname nsl
if {![cc-check-function-in-lib socket {socket network}]} {
# Last resort, may be Windows
if {[is_mingw]} {
define-append LIBS -lwsock32
}
}
| < | 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
cc-check-function-in-lib gethostbyname nsl
if {![cc-check-function-in-lib socket {socket network}]} {
# Last resort, may be Windows
if {[is_mingw]} {
define-append LIBS -lwsock32
}
}
cc-check-functions utime
cc-check-functions usleep
cc-check-functions strchrnul
# Check for getloadavg(), and if it doesn't exist, define FOSSIL_OMIT_LOAD_AVERAGE
if {![cc-check-functions getloadavg]} {
define FOSSIL_OMIT_LOAD_AVERAGE 1
|
| ︙ | ︙ |
Changes to autosetup/autosetup.
| ︙ | ︙ | |||
57 58 59 60 61 62 63 |
# (b)
if {[getenv WRAPPER ""] eq ""} {
# Invoked directly
set autosetup(srcdir) [pwd]
} else {
# Invoked via the configure wrapper
| | > > > > > > > | < | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# (b)
if {[getenv WRAPPER ""] eq ""} {
# Invoked directly
set autosetup(srcdir) [pwd]
} else {
# Invoked via the configure wrapper
set autosetup(srcdir) [file-normalize [file dirname $autosetup(exe)]]
}
set autosetup(autodef) [relative-path $autosetup(srcdir)/auto.def]
# (c)
set autosetup(builddir) [pwd]
set autosetup(argv) $argv
set autosetup(cmdline) {}
# options is a list of known options
set autosetup(options) {}
# optset is a dictionary of option values set by the user based on getopt
set autosetup(optset) {}
# optdefault is a dictionary of default values for options
set autosetup(optdefault) {}
set autosetup(optionhelp) {}
set autosetup(showhelp) 0
# Parse options
use getopt
# At the is point we don't know what is a valid option
# We simply parse anything that looks like an option
set autosetup(getopt) [getopt argv]
#"=Core Options:"
options-add {
help:=local => "display help and options. Optionally specify a module name, such as --help=system"
version => "display the version of autosetup"
ref:=text manual:=text
reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
debug => "display debugging output as autosetup runs"
install:=. => "install autosetup to the current or given directory (in the 'autosetup/' subdirectory)"
force init:=help => "create initial auto.def, etc. Use --init=help for known types"
# Undocumented options
option-checking=1
nopager
quiet
timing
conf:
}
if {[opt-bool version]} {
puts $autosetup(version)
exit 0
}
# autosetup --conf=alternate-auto.def
if {[opt-val conf] ne ""} {
|
| ︙ | ︙ | |||
196 197 198 199 200 201 202 | configlog "define $n $define($n)" } } exit 0 } | | | | > > > > > > > > > > | > > > > > > > > > > > | > > > > > > > > > | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
configlog "define $n $define($n)"
}
}
exit 0
}
# @opt-bool ?-nodefault? option ...
#
# Check each of the named, boolean options and if any have been explicitly enabled
# or disabled by the user, return 1 or 0 accordingly.
#
# If the option was specified more than once, the last value wins.
# e.g. With --enable-foo --disable-foo, [opt-bool foo] will return 0
#
# If no value was specified by the user, returns the default value for the
# first option. If -nodefault is given, this behaviour changes and
# -1 is returned instead.
#
proc opt-bool {args} {
set nodefault 0
if {[lindex $args 0] eq "-nodefault"} {
set nodefault 1
set args [lrange $args 1 end]
}
option-check-names {*}$args
foreach opt $args {
if {[dict exists $::autosetup(optset) $opt]} {
return [dict get $::autosetup(optset) $opt]
}
}
if {$nodefault} {
return -1
}
# Default value is the default for the first option
return [dict get $::autosetup(optdefault) [lindex $args 0]]
}
# @opt-val option-list ?default=""?
#
# Returns a list containing all the values given for the non-boolean options in 'option-list'.
# There will be one entry in the list for each option given by the user, including if the
# same option was used multiple times.
# If only a single value is required, use something like:
#
## lindex [opt-val $names] end
#
# If no options were set, $default is returned (exactly, not as a list).
#
proc opt-val {names {default ""}} {
option-check-names {*}$names
foreach opt $names {
if {[dict exists $::autosetup(optset) $opt]} {
lappend result {*}[dict get $::autosetup(optset) $opt]
}
}
if {[info exists result]} {
return $result
}
return $default
}
proc option-check-names {args} {
foreach o $args {
if {$o ni $::autosetup(options)} {
autosetup-error "Request for undeclared option --$o"
}
}
}
# Parse the option definition in $opts and update
# ::autosetup(setoptions) and ::autosetup(optionhelp) appropriately
#
proc options-add {opts {header ""}} {
global autosetup
# First weed out comment lines
set realopts {}
foreach line [split $opts \n] {
if {![string match "#*" [string trimleft $line]]} {
append realopts $line \n
}
|
| ︙ | ︙ | |||
273 274 275 276 277 278 279 |
if {[string match "-*" $opt]} {
# This is a documentation-only option, like "-C <dir>"
set opthelp $opt
} elseif {$colon eq ""} {
# Boolean option
lappend autosetup(options) $name
| < < < > > > > > > > > > > > > > > > > > > > > > > > > | > | > > > | > > > | > | > > > | > > | | > | | > | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
if {[string match "-*" $opt]} {
# This is a documentation-only option, like "-C <dir>"
set opthelp $opt
} elseif {$colon eq ""} {
# Boolean option
lappend autosetup(options) $name
if {$value eq "1"} {
set opthelp "--disable-$name"
} else {
set opthelp "--$name"
}
# Set the default
if {$value eq ""} {
set value 0
}
dict set autosetup(optdefault) $name $value
if {[dict exists $autosetup(getopt) $name]} {
# The option was specified by the user. Look at the last value.
lassign [lindex [dict get $autosetup(getopt) $name] end] type setvalue
if {$type eq "str"} {
# Can we convert the value to a boolean?
if {$setvalue in {1 enabled yes}} {
set setvalue 1
} elseif {$setvalue in {0 disabled no}} {
set setvalue 0
} else {
user-error "Boolean option $name given as --$name=$setvalue"
}
}
dict set autosetup(optset) $name $setvalue
#puts "Found boolean option --$name=$setvalue"
}
} else {
# String option.
lappend autosetup(options) $name
if {$equal eq "="} {
# String option with optional value
set opthelp "--$name?=$value?"
} else {
# String option with required value
set opthelp "--$name=$value"
}
dict set autosetup(optdefault) $name $value
# Get the values specified by the user
if {[dict exists $autosetup(getopt) $name]} {
set listvalue {}
foreach pair [dict get $autosetup(getopt) $name] {
lassign $pair type setvalue
if {$type eq "bool" && $setvalue} {
if {$equal ne "="} {
user-error "Option --$name requires a value"
}
# If given as a boolean, use the default value
set setvalue $value
}
lappend listvalue $setvalue
}
#puts "Found string option --$name=$listvalue"
dict set autosetup(optset) $name $listvalue
}
}
# Now create the help for this option if appropriate
if {[lindex $opts $i+1] eq "=>"} {
set desc [lindex $opts $i+2]
#string match \n* $desc
if {$header ne ""} {
|
| ︙ | ︙ | |||
428 429 430 431 432 433 434 |
if {$::autosetup(showhelp)} {
options-show
exit 0
}
# Check for invalid options
if {[opt-bool option-checking]} {
| | | 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
if {$::autosetup(showhelp)} {
options-show
exit 0
}
# Check for invalid options
if {[opt-bool option-checking]} {
foreach o [dict keys $::autosetup(getopt)] {
if {$o ni $::autosetup(options)} {
user-error "Unknown option --$o"
}
}
}
}
|
| ︙ | ︙ | |||
1094 1095 1096 1097 1098 1099 1100 |
set modsource(getopt) {
# Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Simple getopt module
# Parse everything out of the argv list which looks like an option
| < > > > > > > > > | | | | | > | < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < | 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 |
set modsource(getopt) {
# Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# Simple getopt module
# Parse everything out of the argv list which looks like an option
# Everything which doesn't look like an option, or is after --, is left unchanged
# Understands --enable-xxx as a synonym for --xxx to enable the boolean option xxx.
# Understands --disable-xxx to disable the boolean option xxx.
#
# The returned value is a dictionary keyed by option name
# Each value is a list of {type value} ... where type is "bool" or "str".
# The value for a boolean option is 0 or 1. The value of a string option is the value given.
proc getopt {argvname} {
upvar $argvname argv
set nargv {}
set opts {}
for {set i 0} {$i < [llength $argv]} {incr i} {
set arg [lindex $argv $i]
#dputs arg=$arg
if {$arg eq "--"} {
# End of options
incr i
lappend nargv {*}[lrange $argv $i end]
break
}
if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
# --name=value
dict lappend opts $name [list str $value]
} elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
if {$prefix in {enable- with- ""}} {
set value 1
} else {
set value 0
}
dict lappend opts $name [list bool $value]
} else {
lappend nargv $arg
}
}
#puts "getopt: argv=[join $argv] => [join $nargv]"
#array set getopt $opts
#parray getopt
set argv $nargv
return $opts
}
}
# ----- module help -----
set modsource(help) {
# Copyright (c) 2010 WorkWare Systems http://workware.net.au/
|
| ︙ | ︙ |
Changes to autosetup/cc-lib.tcl.
| ︙ | ︙ | |||
8 9 10 11 12 13 14 |
use cc
module-options {}
# @cc-check-lfs
#
# The equivalent of the AC_SYS_LARGEFILE macro
| | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
use cc
module-options {}
# @cc-check-lfs
#
# The equivalent of the AC_SYS_LARGEFILE macro
#
# defines 'HAVE_LFS' if LFS is available,
# and defines '_FILE_OFFSET_BITS=64' if necessary
#
# Returns 1 if 'LFS' is available or 0 otherwise
#
proc cc-check-lfs {} {
cc-check-includes sys/types.h
|
| ︙ | ︙ | |||
34 35 36 37 38 39 40 | define-feature lfs $lfs return $lfs } # @cc-check-endian # # The equivalent of the AC_C_BIGENDIAN macro | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
define-feature lfs $lfs
return $lfs
}
# @cc-check-endian
#
# The equivalent of the AC_C_BIGENDIAN macro
#
# defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
# or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
#
# Returns 1 if determined, or 0 if not.
#
proc cc-check-endian {} {
cc-check-includes sys/types.h sys/param.h
|
| ︙ | ︙ | |||
155 156 157 158 159 160 161 |
msg-result "not found"
}
cctest_alignof _Alignof
cctest_alignof __alignof__
cctest_alignof __alignof
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
msg-result "not found"
}
cctest_alignof _Alignof
cctest_alignof __alignof__
cctest_alignof __alignof
}
# @cc-check-alloca
#
# The equivalent of the AC_FUNC_ALLOCA macro
#
# Checks for the existence of alloca
# defines HAVE_ALLOCA and returns 1 if it exists
proc cc-check-alloca {} {
cc-check-some-feature alloca {
cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
}
}
# @cc-signal-return-type
#
# The equivalent of the AC_TYPE_SIGNAL macro
#
# defines RETSIGTYPE to int or void
proc cc-signal-return-type {} {
msg-checking "Checking return type of signal handlers..."
cc-with {-includes {sys/types.h signal.h}} {
if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
set type int
} else {
set type void
}
define RETSIGTYPE $type
msg-result $type
}
}
|
Changes to autosetup/cc-shared.tcl.
| ︙ | ︙ | |||
60 61 62 63 64 65 66 |
define SH_SOPREFIX ""
define LD_LIBRARY_PATH PATH
}
sparc* {
if {[msg-quiet cc-check-decls __SUNPRO_C]} {
msg-result "Found sun stdio compiler"
# sun stdio compiler
| | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
define SH_SOPREFIX ""
define LD_LIBRARY_PATH PATH
}
sparc* {
if {[msg-quiet cc-check-decls __SUNPRO_C]} {
msg-result "Found sun stdio compiler"
# sun stdio compiler
# XXX: These haven't been fully tested.
define SHOBJ_CFLAGS -KPIC
define SHOBJ_LDFLAGS "-G"
define SH_CFLAGS -KPIC
define SH_LINKFLAGS -Wl,-export-dynamic
define SH_SOPREFIX -Wl,-h,
} else {
# sparc has a very small GOT table limit, so use -fPIC
define SH_CFLAGS -fPIC
define SHOBJ_CFLAGS -fPIC
}
}
*-*-solaris* {
if {[msg-quiet cc-check-decls __SUNPRO_C]} {
msg-result "Found sun stdio compiler"
# sun stdio compiler
# XXX: These haven't been fully tested.
define SHOBJ_CFLAGS -KPIC
define SHOBJ_LDFLAGS "-G"
define SH_CFLAGS -KPIC
define SH_LINKFLAGS -Wl,-export-dynamic
define SH_SOPREFIX -Wl,-h,
}
}
|
| ︙ | ︙ | |||
101 102 103 104 105 106 107 108 109 110 111 112 |
define SHOBJ_LDFLAGS -shared
define SH_CFLAGS ""
define SH_LDFLAGS -shared
define SH_LINKFLAGS ""
define SH_SOPREFIX ""
define LD_LIBRARY_PATH LIBRARY_PATH
}
}
if {![is-defined SHOBJ_LDFLAGS_R]} {
define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
}
| > > > > > | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
define SHOBJ_LDFLAGS -shared
define SH_CFLAGS ""
define SH_LDFLAGS -shared
define SH_LINKFLAGS ""
define SH_SOPREFIX ""
define LD_LIBRARY_PATH LIBRARY_PATH
}
microblaze* {
# Microblaze generally needs -fPIC rather than -fpic
define SHOBJ_CFLAGS -fPIC
define SH_CFLAGS -fPIC
}
}
if {![is-defined SHOBJ_LDFLAGS_R]} {
define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
}
|
Changes to autosetup/cc.tcl.
| ︙ | ︙ | |||
45 46 47 48 49 50 51 |
proc cctest_type {type} {
cctest -code "$type _x;"
}
# Checks for the existence of the given type/structure member.
# e.g. "struct stat.st_mtime"
proc cctest_member {struct_member} {
| > | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
proc cctest_type {type} {
cctest -code "$type _x;"
}
# Checks for the existence of the given type/structure member.
# e.g. "struct stat.st_mtime"
proc cctest_member {struct_member} {
# split at the first dot
regexp {^([^.]+)[.](.*)$} $struct_member -> struct member
cctest -code "static $struct _s; return sizeof(_s.$member);"
}
# Checks for the existence of the given define by compiling
#
proc cctest_define {name} {
cctest -code "#ifndef $name\n#error not defined\n#endif"
|
| ︙ | ︙ | |||
206 207 208 209 210 211 212 | # Checks that the given function can be found in one of the libs. # # First checks for no library required, then checks each of the libraries # in turn. # # If the function is found, the feature is defined and lib_$function is defined # to -l$lib where the function was found, or "" if no library required. | | | | > | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# Checks that the given function can be found in one of the libs.
#
# First checks for no library required, then checks each of the libraries
# in turn.
#
# If the function is found, the feature is defined and lib_$function is defined
# to -l$lib where the function was found, or "" if no library required.
# In addition, -l$lib is prepended to the LIBS define.
#
# If additional libraries may be needed for linking, they should be specified
# as $extralibs as "-lotherlib1 -lotherlib2".
# These libraries are not automatically added to LIBS.
#
# Returns 1 if found or 0 if not.
#
proc cc-check-function-in-lib {function libs {otherlibs {}}} {
msg-checking "Checking libs for $function..."
set found 0
cc-with [list -libs $otherlibs] {
if {[cctest_function $function]} {
msg-result "none needed"
define lib_$function ""
incr found
} else {
foreach lib $libs {
cc-with [list -libs -l$lib] {
if {[cctest_function $function]} {
msg-result -l$lib
define lib_$function -l$lib
# prepend to LIBS
define LIBS "-l$lib [get-define LIBS]"
incr found
break
}
}
}
}
}
|
| ︙ | ︙ | |||
411 412 413 414 415 416 417 | return -code [dict get $info -code] $result } return $result } } # @cctest ?settings? | | | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
return -code [dict get $info -code] $result
}
return $result
}
}
# @cctest ?settings?
#
# Low level C compiler checker. Compiles and or links a small C program
# according to the arguments and returns 1 if OK, or 0 if not.
#
# Supported settings are:
#
## -cflags cflags A list of flags to pass to the compiler
## -includes list A list of includes, e.g. {stdlib.h stdio.h}
|
| ︙ | ︙ | |||
494 495 496 497 498 499 500 |
lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
}
default {
autosetup-error "cctest called with unknown language: $opts(-lang)"
}
}
| | > > < > > > | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
}
default {
autosetup-error "cctest called with unknown language: $opts(-lang)"
}
}
if {$opts(-link)} {
lappend cmdline {*}[get-define LDFLAGS]
} else {
set tmp conftest__.o
lappend cmdline -c
}
lappend cmdline {*}$opts(-cflags) {*}[get-define cc-default-debug ""]
lappend cmdline $src -o $tmp {*}$opts(-libs)
if {$opts(-link)} {
lappend cmdline {*}[get-define LIBS]
}
# At this point we have the complete command line and the
# complete source to be compiled. Get the result from cache if
# we can
if {[info exists ::cc_cache($cmdline,$lines)]} {
msg-checking "(cached) "
set ok $::cc_cache($cmdline,$lines)
|
| ︙ | ︙ |
Changes to autosetup/jimsh0.c.
1 2 3 4 5 6 7 8 9 | /* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */ #define JIM_TCL_COMPAT #define JIM_ANSIC #define JIM_REGEXP #define HAVE_NO_AUTOCONF #define _JIMAUTOCONF_H #define TCL_LIBRARY "." #define jim_ext_bootstrap #define jim_ext_aio | > > | 1 2 3 4 5 6 7 8 9 10 11 | /* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */ #define _GNU_SOURCE #define JIM_TCL_COMPAT #define JIM_REFERENCES #define JIM_ANSIC #define JIM_REGEXP #define HAVE_NO_AUTOCONF #define _JIMAUTOCONF_H #define TCL_LIBRARY "." #define jim_ext_bootstrap #define jim_ext_aio |
| ︙ | ︙ | |||
31 32 33 34 35 36 37 | #define HAVE_SYS_TIME_H #define HAVE_DIRENT_H #define HAVE_UNISTD_H #else #define TCL_PLATFORM_OS "unknown" #define TCL_PLATFORM_PLATFORM "unix" #define TCL_PLATFORM_PATH_SEPARATOR ":" | < < < < < < | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
#define HAVE_SYS_TIME_H
#define HAVE_DIRENT_H
#define HAVE_UNISTD_H
#else
#define TCL_PLATFORM_OS "unknown"
#define TCL_PLATFORM_PLATFORM "unix"
#define TCL_PLATFORM_PATH_SEPARATOR ":"
#define HAVE_VFORK
#define HAVE_WAITPID
#define HAVE_ISATTY
#define HAVE_MKSTEMP
#define HAVE_LINK
#define HAVE_SYS_TIME_H
#define HAVE_DIRENT_H
#define HAVE_UNISTD_H
#endif
#define JIM_VERSION 76
#ifndef JIM_WIN32COMPAT_H
#define JIM_WIN32COMPAT_H
#ifdef __cplusplus
extern "C" {
|
| ︙ | ︙ | |||
107 108 109 110 111 112 113 |
#define HAVE_OPENDIR
struct dirent {
char *d_name;
};
typedef struct DIR {
| | | | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
#define HAVE_OPENDIR
struct dirent {
char *d_name;
};
typedef struct DIR {
long handle;
struct _finddata_t info;
struct dirent result;
char *name;
} DIR;
DIR *opendir(const char *name);
int closedir(DIR *dir);
struct dirent *readdir(DIR *dir);
#elif defined(__MINGW32__)
#include <stdlib.h>
#define strtod __strtod
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef UTF8_UTIL_H
|
| ︙ | ︙ | |||
177 178 179 180 181 182 183 |
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <limits.h>
| | | | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#ifndef HAVE_NO_AUTOCONF
#endif
|
| ︙ | ︙ | |||
226 227 228 229 230 231 232 | #define JIM_BREAK 3 #define JIM_CONTINUE 4 #define JIM_SIGNAL 5 #define JIM_EXIT 6 #define JIM_EVAL 7 | | | | | | | | | | | | | | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | #define JIM_BREAK 3 #define JIM_CONTINUE 4 #define JIM_SIGNAL 5 #define JIM_EXIT 6 #define JIM_EVAL 7 #define JIM_MAX_CALLFRAME_DEPTH 1000 #define JIM_MAX_EVAL_DEPTH 2000 #define JIM_PRIV_FLAG_SHIFT 20 #define JIM_NONE 0 #define JIM_ERRMSG 1 #define JIM_ENUM_ABBREV 2 #define JIM_UNSHARED 4 #define JIM_MUSTEXIST 8 #define JIM_SUBST_NOVAR 1 #define JIM_SUBST_NOCMD 2 #define JIM_SUBST_NOESC 4 #define JIM_SUBST_FLAG 128 #define JIM_CASESENS 0 #define JIM_NOCASE 1 #define JIM_PATH_LEN 1024 #define JIM_NOTUSED(V) ((void) V) |
| ︙ | ︙ | |||
341 342 343 344 345 346 347 |
#define Jim_GetHashEntryVal(he) ((he)->u.val)
#define Jim_GetHashTableCollisions(ht) ((ht)->collisions)
#define Jim_GetHashTableSize(ht) ((ht)->size)
#define Jim_GetHashTableUsed(ht) ((ht)->used)
typedef struct Jim_Obj {
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
#define Jim_GetHashEntryVal(he) ((he)->u.val)
#define Jim_GetHashTableCollisions(ht) ((ht)->collisions)
#define Jim_GetHashTableSize(ht) ((ht)->size)
#define Jim_GetHashTableUsed(ht) ((ht)->used)
typedef struct Jim_Obj {
char *bytes;
const struct Jim_ObjType *typePtr;
int refCount;
int length;
union {
jim_wide wideValue;
int intValue;
double doubleValue;
void *ptr;
struct {
void *ptr1;
void *ptr2;
} twoPtrValue;
struct {
struct Jim_Var *varPtr;
unsigned long callFrameId;
int global;
} varValue;
struct {
struct Jim_Obj *nsObj;
struct Jim_Cmd *cmdPtr;
unsigned long procEpoch;
} cmdValue;
struct {
struct Jim_Obj **ele;
int len;
int maxLen;
} listValue;
struct {
int maxLength;
int charLength;
} strValue;
struct {
unsigned long id;
struct Jim_Reference *refPtr;
} refValue;
struct {
struct Jim_Obj *fileNameObj;
int lineNumber;
} sourceValue;
struct {
struct Jim_Obj *varNameObjPtr;
struct Jim_Obj *indexObjPtr;
} dictSubstValue;
struct {
void *compre;
unsigned flags;
} regexpValue;
struct {
int line;
int argc;
} scriptLineValue;
} internalRep;
struct Jim_Obj *prevObjPtr;
struct Jim_Obj *nextObjPtr;
} Jim_Obj;
#define Jim_IncrRefCount(objPtr) \
++(objPtr)->refCount
#define Jim_DecrRefCount(interp, objPtr) \
if (--(objPtr)->refCount <= 0) Jim_FreeObj(interp, objPtr)
|
| ︙ | ︙ | |||
444 445 446 447 448 449 450 |
typedef void (Jim_FreeInternalRepProc)(struct Jim_Interp *interp,
struct Jim_Obj *objPtr);
typedef void (Jim_DupInternalRepProc)(struct Jim_Interp *interp,
struct Jim_Obj *srcPtr, Jim_Obj *dupPtr);
typedef void (Jim_UpdateStringProc)(struct Jim_Obj *objPtr);
typedef struct Jim_ObjType {
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
typedef void (Jim_FreeInternalRepProc)(struct Jim_Interp *interp,
struct Jim_Obj *objPtr);
typedef void (Jim_DupInternalRepProc)(struct Jim_Interp *interp,
struct Jim_Obj *srcPtr, Jim_Obj *dupPtr);
typedef void (Jim_UpdateStringProc)(struct Jim_Obj *objPtr);
typedef struct Jim_ObjType {
const char *name;
Jim_FreeInternalRepProc *freeIntRepProc;
Jim_DupInternalRepProc *dupIntRepProc;
Jim_UpdateStringProc *updateStringProc;
int flags;
} Jim_ObjType;
#define JIM_TYPE_NONE 0
#define JIM_TYPE_REFERENCES 1
typedef struct Jim_CallFrame {
unsigned long id;
int level;
struct Jim_HashTable vars;
struct Jim_HashTable *staticVars;
struct Jim_CallFrame *parent;
Jim_Obj *const *argv;
int argc;
Jim_Obj *procArgsObjPtr;
Jim_Obj *procBodyObjPtr;
struct Jim_CallFrame *next;
Jim_Obj *nsObj;
Jim_Obj *fileNameObj;
int line;
Jim_Stack *localCommands;
struct Jim_Obj *tailcallObj;
struct Jim_Cmd *tailcallCmd;
} Jim_CallFrame;
typedef struct Jim_Var {
Jim_Obj *objPtr;
struct Jim_CallFrame *linkFramePtr;
} Jim_Var;
typedef int Jim_CmdProc(struct Jim_Interp *interp, int argc,
Jim_Obj *const *argv);
typedef void Jim_DelCmdProc(struct Jim_Interp *interp, void *privData);
typedef struct Jim_Cmd {
int inUse;
int isproc;
struct Jim_Cmd *prevCmd;
union {
struct {
Jim_CmdProc *cmdProc;
Jim_DelCmdProc *delProc;
void *privData;
} native;
struct {
Jim_Obj *argListObjPtr;
Jim_Obj *bodyObjPtr;
Jim_HashTable *staticVars;
int argListLen;
int reqArity;
int optArity;
int argsPos;
int upcall;
struct Jim_ProcArg {
Jim_Obj *nameObjPtr;
Jim_Obj *defaultObjPtr;
} *arglist;
Jim_Obj *nsObj;
} proc;
} u;
} Jim_Cmd;
typedef struct Jim_PrngState {
unsigned char sbox[256];
unsigned int i, j;
} Jim_PrngState;
typedef struct Jim_Interp {
Jim_Obj *result;
int errorLine;
Jim_Obj *errorFileNameObj;
int addStackTrace;
int maxCallFrameDepth;
int maxEvalDepth;
int evalDepth;
int returnCode;
int returnLevel;
int exitCode;
long id;
int signal_level;
jim_wide sigmask;
int (*signal_set_result)(struct Jim_Interp *interp, jim_wide sigmask);
Jim_CallFrame *framePtr;
Jim_CallFrame *topFramePtr;
struct Jim_HashTable commands;
unsigned long procEpoch; /* Incremented every time the result
of procedures names lookup caching
may no longer be valid. */
unsigned long callFrameEpoch; /* Incremented every time a new
callframe is created. This id is used for the
'ID' field contained in the Jim_CallFrame
structure. */
int local;
Jim_Obj *liveList;
Jim_Obj *freeList;
Jim_Obj *currentScriptObj;
Jim_Obj *nullScriptObj;
Jim_Obj *emptyObj;
Jim_Obj *trueObj;
Jim_Obj *falseObj;
unsigned long referenceNextId;
struct Jim_HashTable references;
unsigned long lastCollectId; /* reference max Id of the last GC
execution. It's set to -1 while the collection
is running as sentinel to avoid to recursive
calls via the [collect] command inside
finalizers. */
time_t lastCollectTime;
Jim_Obj *stackTrace;
Jim_Obj *errorProc;
Jim_Obj *unknown;
int unknown_called;
int errorFlag;
void *cmdPrivData; /* Used to pass the private data pointer to
a command. It is set to what the user specified
via Jim_CreateCommand(). */
struct Jim_CallFrame *freeFramesList;
struct Jim_HashTable assocData;
Jim_PrngState *prngState;
struct Jim_HashTable packages;
Jim_Stack *loadHandles;
} Jim_Interp;
#define Jim_InterpIncrProcEpoch(i) (i)->procEpoch++
#define Jim_SetResultString(i,s,l) Jim_SetResult(i, Jim_NewStringObj(i,s,l))
#define Jim_SetResultInt(i,intval) Jim_SetResult(i, Jim_NewIntObj(i,intval))
#define Jim_SetResultBool(i,b) Jim_SetResultInt(i, b)
|
| ︙ | ︙ | |||
833 834 835 836 837 838 839 |
JIM_EXPORT int Jim_EvalExpression (Jim_Interp *interp,
Jim_Obj *exprObjPtr, Jim_Obj **exprResultPtrPtr);
JIM_EXPORT int Jim_GetBoolFromExpr (Jim_Interp *interp,
Jim_Obj *exprObjPtr, int *boolPtr);
| < < < < | 829 830 831 832 833 834 835 836 837 838 839 840 841 842 |
JIM_EXPORT int Jim_EvalExpression (Jim_Interp *interp,
Jim_Obj *exprObjPtr, Jim_Obj **exprResultPtrPtr);
JIM_EXPORT int Jim_GetBoolFromExpr (Jim_Interp *interp,
Jim_Obj *exprObjPtr, int *boolPtr);
JIM_EXPORT int Jim_GetWide (Jim_Interp *interp, Jim_Obj *objPtr,
jim_wide *widePtr);
JIM_EXPORT int Jim_GetLong (Jim_Interp *interp, Jim_Obj *objPtr,
long *longPtr);
#define Jim_NewWideObj Jim_NewIntObj
JIM_EXPORT Jim_Obj * Jim_NewIntObj (Jim_Interp *interp,
|
| ︙ | ︙ | |||
910 911 912 913 914 915 916 | JIM_EXPORT int Jim_IsDict(Jim_Obj *objPtr); JIM_EXPORT int Jim_IsList(Jim_Obj *objPtr); #ifdef __cplusplus } #endif | | | | | | | | | | | 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 |
JIM_EXPORT int Jim_IsDict(Jim_Obj *objPtr);
JIM_EXPORT int Jim_IsList(Jim_Obj *objPtr);
#ifdef __cplusplus
}
#endif
#endif
#ifndef JIM_SUBCMD_H
#define JIM_SUBCMD_H
#ifdef __cplusplus
extern "C" {
#endif
#define JIM_MODFLAG_HIDDEN 0x0001
#define JIM_MODFLAG_FULLARGV 0x0002
typedef int jim_subcmd_function(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
typedef struct {
const char *cmd;
const char *args;
jim_subcmd_function *function;
short minargs;
short maxargs;
unsigned short flags;
} jim_subcmd_type;
const jim_subcmd_type *
Jim_ParseSubCmd(Jim_Interp *interp, const jim_subcmd_type *command_table, int argc, Jim_Obj *const *argv);
int Jim_SubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
|
| ︙ | ︙ | |||
966 967 968 969 970 971 972 |
typedef struct {
int rm_so;
int rm_eo;
} regmatch_t;
typedef struct regexp {
| | | | | | | | | | | | | | | | | | | | | | | | | | | 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 |
typedef struct {
int rm_so;
int rm_eo;
} regmatch_t;
typedef struct regexp {
int re_nsub;
int cflags;
int err;
int regstart;
int reganch;
int regmust;
int regmlen;
int *program;
const char *regparse;
int p;
int proglen;
int eflags;
const char *start;
const char *reginput;
const char *regbol;
regmatch_t *pmatch;
int nmatch;
} regexp;
typedef regexp regex_t;
#define REG_EXTENDED 0
#define REG_NEWLINE 1
#define REG_ICASE 2
#define REG_NOTBOL 16
enum {
REG_NOERROR,
REG_NOMATCH,
REG_BADPAT,
REG_ERR_NULL_ARGUMENT,
REG_ERR_UNKNOWN,
REG_ERR_TOO_BIG,
REG_ERR_NOMEM,
REG_ERR_TOO_MANY_PAREN,
REG_ERR_UNMATCHED_PAREN,
REG_ERR_UNMATCHED_BRACES,
|
| ︙ | ︙ | |||
1786 1787 1788 1789 1790 1791 1792 | " }\n" " file delete $path\n" "}\n" ); } | < | 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 | " }\n" " file delete $path\n" "}\n" ); } #include <stdio.h> #include <string.h> #include <errno.h> #include <fcntl.h> #ifdef HAVE_UNISTD_H #include <unistd.h> #include <sys/stat.h> |
| ︙ | ︙ | |||
1815 1816 1817 1818 1819 1820 1821 | #if defined(JIM_SSL) #include <openssl/ssl.h> #include <openssl/err.h> #endif | | | | 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 |
#if defined(JIM_SSL)
#include <openssl/ssl.h>
#include <openssl/err.h>
#endif
#define AIO_CMD_LEN 32
#define AIO_BUF_LEN 256
#ifndef HAVE_FTELLO
#define ftello ftell
#endif
#ifndef HAVE_FSEEKO
#define fseeko fseek
#endif
|
| ︙ | ︙ | |||
1855 1856 1857 1858 1859 1860 1861 |
} JimAioFopsType;
typedef struct AioFile
{
FILE *fp;
Jim_Obj *filename;
int type;
| | | 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 |
} JimAioFopsType;
typedef struct AioFile
{
FILE *fp;
Jim_Obj *filename;
int type;
int openFlags;
int fd;
Jim_Obj *rEvent;
Jim_Obj *wEvent;
Jim_Obj *eEvent;
int addr_family;
void *ssl;
const JimAioFopsType *fops;
|
| ︙ | ︙ | |||
1886 1887 1888 1889 1890 1891 1892 |
static int stdio_error(const AioFile *af)
{
if (!ferror(af->fp)) {
return JIM_OK;
}
clearerr(af->fp);
| | | 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 |
static int stdio_error(const AioFile *af)
{
if (!ferror(af->fp)) {
return JIM_OK;
}
clearerr(af->fp);
if (feof(af->fp) || errno == EAGAIN || errno == EINTR) {
return JIM_OK;
}
#ifdef ECONNRESET
if (errno == ECONNRESET) {
return JIM_OK;
}
|
| ︙ | ︙ | |||
1952 1953 1954 1955 1956 1957 1958 |
AioFile *af = privData;
JIM_NOTUSED(interp);
Jim_DecrRefCount(interp, af->filename);
#ifdef jim_ext_eventloop
| | | | 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 |
AioFile *af = privData;
JIM_NOTUSED(interp);
Jim_DecrRefCount(interp, af->filename);
#ifdef jim_ext_eventloop
Jim_DeleteFileHandler(interp, af->fp, JIM_EVENT_READABLE | JIM_EVENT_WRITABLE | JIM_EVENT_EXCEPTION);
#endif
#if defined(JIM_SSL)
if (af->ssl != NULL) {
SSL_free(af->ssl);
}
#endif
|
| ︙ | ︙ | |||
1975 1976 1977 1978 1979 1980 1981 |
static int aio_cmd_read(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
char buf[AIO_BUF_LEN];
Jim_Obj *objPtr;
int nonewline = 0;
| | | 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 |
static int aio_cmd_read(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
char buf[AIO_BUF_LEN];
Jim_Obj *objPtr;
int nonewline = 0;
jim_wide neededLen = -1;
if (argc && Jim_CompareStringImmediate(interp, argv[0], "-nonewline")) {
nonewline = 1;
argv++;
argc--;
}
if (argc == 1) {
|
| ︙ | ︙ | |||
2014 2015 2016 2017 2018 2019 2020 |
if (neededLen != -1) {
neededLen -= retval;
}
}
if (retval != readlen)
break;
}
| | | 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 |
if (neededLen != -1) {
neededLen -= retval;
}
}
if (retval != readlen)
break;
}
if (JimCheckStreamError(interp, af)) {
Jim_FreeNewObj(interp, objPtr);
return JIM_ERR;
}
if (nonewline) {
int len;
const char *s = Jim_GetString(objPtr, &len);
|
| ︙ | ︙ | |||
2036 2037 2038 2039 2040 2041 2042 |
return JIM_OK;
}
AioFile *Jim_AioFile(Jim_Interp *interp, Jim_Obj *command)
{
Jim_Cmd *cmdPtr = Jim_GetCommand(interp, command, JIM_ERRMSG);
| | | 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 |
return JIM_OK;
}
AioFile *Jim_AioFile(Jim_Interp *interp, Jim_Obj *command)
{
Jim_Cmd *cmdPtr = Jim_GetCommand(interp, command, JIM_ERRMSG);
if (cmdPtr && !cmdPtr->isproc && cmdPtr->u.native.cmdProc == JimAioSubCmdProc) {
return (AioFile *) cmdPtr->u.native.privData;
}
Jim_SetResultFormatted(interp, "Not a filehandle: \"%#s\"", command);
return NULL;
}
|
| ︙ | ︙ | |||
2117 2118 2119 2120 2121 2122 2123 |
if (buf[AIO_BUF_LEN - 1] == '\0' && buf[AIO_BUF_LEN - 2] != '\n') {
Jim_AppendString(interp, objPtr, buf, AIO_BUF_LEN - 1);
}
else {
len = strlen(buf);
if (len && (buf[len - 1] == '\n')) {
| | | | | 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 |
if (buf[AIO_BUF_LEN - 1] == '\0' && buf[AIO_BUF_LEN - 2] != '\n') {
Jim_AppendString(interp, objPtr, buf, AIO_BUF_LEN - 1);
}
else {
len = strlen(buf);
if (len && (buf[len - 1] == '\n')) {
len--;
}
Jim_AppendString(interp, objPtr, buf, len);
break;
}
}
if (JimCheckStreamError(interp, af)) {
Jim_FreeNewObj(interp, objPtr);
return JIM_ERR;
}
if (argc) {
if (Jim_SetVariable(interp, argv[0], objPtr) != JIM_OK) {
Jim_FreeNewObj(interp, objPtr);
return JIM_ERR;
}
len = Jim_Length(objPtr);
if (len == 0 && feof(af->fp)) {
len = -1;
}
Jim_SetResultInt(interp, len);
}
else {
Jim_SetResult(interp, objPtr);
}
|
| ︙ | ︙ | |||
2371 2372 2373 2374 2375 2376 2377 |
return Jim_EvalObjBackground(interp, *objPtrPtr);
}
static int aio_eventinfo(Jim_Interp *interp, AioFile * af, unsigned mask, Jim_Obj **scriptHandlerObj,
int argc, Jim_Obj * const *argv)
{
if (argc == 0) {
| | | | | | | | | 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 |
return Jim_EvalObjBackground(interp, *objPtrPtr);
}
static int aio_eventinfo(Jim_Interp *interp, AioFile * af, unsigned mask, Jim_Obj **scriptHandlerObj,
int argc, Jim_Obj * const *argv)
{
if (argc == 0) {
if (*scriptHandlerObj) {
Jim_SetResult(interp, *scriptHandlerObj);
}
return JIM_OK;
}
if (*scriptHandlerObj) {
Jim_DeleteFileHandler(interp, af->fp, mask);
}
if (Jim_Length(argv[0]) == 0) {
return JIM_OK;
}
Jim_IncrRefCount(argv[0]);
*scriptHandlerObj = argv[0];
Jim_CreateFileHandler(interp, af->fp, mask,
JimAioFileEventHandler, scriptHandlerObj, JimAioFileEventFinalizer);
return JIM_OK;
}
static int aio_cmd_readable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
|
| ︙ | ︙ | |||
2422 2423 2424 2425 2426 2427 2428 |
AioFile *af = Jim_CmdPrivData(interp);
return aio_eventinfo(interp, af, JIM_EVENT_EXCEPTION, &af->eEvent, argc, argv);
}
#endif
| < | | | | | | | | | | | | | | | | | | 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 |
AioFile *af = Jim_CmdPrivData(interp);
return aio_eventinfo(interp, af, JIM_EVENT_EXCEPTION, &af->eEvent, argc, argv);
}
#endif
static const jim_subcmd_type aio_command_table[] = {
{ "read",
"?-nonewline? ?len?",
aio_cmd_read,
0,
2,
},
{ "copyto",
"handle ?size?",
aio_cmd_copy,
1,
2,
},
{ "gets",
"?var?",
aio_cmd_gets,
0,
1,
},
{ "puts",
"?-nonewline? str",
aio_cmd_puts,
1,
2,
},
{ "isatty",
NULL,
aio_cmd_isatty,
0,
0,
},
{ "flush",
NULL,
aio_cmd_flush,
0,
0,
},
{ "eof",
NULL,
aio_cmd_eof,
0,
0,
},
{ "close",
"?r(ead)|w(rite)?",
aio_cmd_close,
0,
1,
JIM_MODFLAG_FULLARGV,
},
{ "seek",
"offset ?start|current|end",
aio_cmd_seek,
1,
2,
},
{ "tell",
NULL,
aio_cmd_tell,
0,
0,
},
{ "filename",
NULL,
aio_cmd_filename,
0,
0,
},
#ifdef O_NDELAY
{ "ndelay",
"?0|1?",
aio_cmd_ndelay,
0,
1,
},
#endif
#ifdef HAVE_FSYNC
{ "sync",
NULL,
aio_cmd_sync,
0,
0,
},
#endif
{ "buffering",
"none|line|full",
aio_cmd_buffering,
1,
1,
},
#ifdef jim_ext_eventloop
{ "readable",
"?readable-script?",
aio_cmd_readable,
0,
1,
},
{ "writable",
"?writable-script?",
aio_cmd_writable,
0,
1,
},
{ "onexception",
"?exception-script?",
aio_cmd_onexception,
0,
1,
},
#endif
{ NULL }
};
static int JimAioSubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
|
| ︙ | ︙ | |||
2574 2575 2576 2577 2578 2579 2580 |
mode = (argc == 3) ? Jim_String(argv[2]) : "r";
#ifdef jim_ext_tclcompat
{
const char *filename = Jim_String(argv[1]);
| | | 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 |
mode = (argc == 3) ? Jim_String(argv[2]) : "r";
#ifdef jim_ext_tclcompat
{
const char *filename = Jim_String(argv[1]);
if (*filename == '|') {
Jim_Obj *evalObj[3];
evalObj[0] = Jim_NewStringObj(interp, "::popen", -1);
evalObj[1] = Jim_NewStringObj(interp, filename + 1, -1);
evalObj[2] = Jim_NewStringObj(interp, mode, -1);
|
| ︙ | ︙ | |||
2631 2632 2633 2634 2635 2636 2637 |
}
#endif
Jim_DecrRefCount(interp, filename);
return NULL;
}
}
| | | 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 |
}
#endif
Jim_DecrRefCount(interp, filename);
return NULL;
}
}
af = Jim_Alloc(sizeof(*af));
memset(af, 0, sizeof(*af));
af->fp = fh;
af->fd = fileno(fh);
af->filename = filename;
#ifdef FD_CLOEXEC
if ((openFlags & AIO_KEEPOPEN) == 0) {
|
| ︙ | ︙ | |||
2669 2670 2671 2672 2673 2674 2675 |
if (JimMakeChannel(interp, NULL, p[1], filename, hdlfmt, family, mode[1])) {
Jim_ListAppendElement(interp, objPtr, Jim_GetResult(interp));
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
}
| | | 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 |
if (JimMakeChannel(interp, NULL, p[1], filename, hdlfmt, family, mode[1])) {
Jim_ListAppendElement(interp, objPtr, Jim_GetResult(interp));
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
}
close(p[0]);
close(p[1]);
JimAioSetError(interp, NULL);
return JIM_ERR;
}
#endif
|
| ︙ | ︙ | |||
2703 2704 2705 2706 2707 2708 2709 |
else {
filenameObj = Jim_NewStringObj(interp, template, -1);
}
#if defined(S_IRWXG) && defined(S_IRWXO)
mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
#else
| | | | 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 |
else {
filenameObj = Jim_NewStringObj(interp, template, -1);
}
#if defined(S_IRWXG) && defined(S_IRWXO)
mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
#else
mask = umask(S_IXUSR);
#endif
fd = mkstemp(filenameObj->bytes);
umask(mask);
if (fd < 0) {
JimAioSetError(interp, filenameObj);
Jim_FreeNewObj(interp, filenameObj);
return -1;
}
|
| ︙ | ︙ | |||
2739 2740 2741 2742 2743 2744 2745 |
#endif
Jim_CreateCommand(interp, "open", JimAioOpenCommand, NULL, NULL);
#ifndef JIM_ANSIC
Jim_CreateCommand(interp, "socket", JimAioSockCommand, NULL, NULL);
#endif
| | | 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 |
#endif
Jim_CreateCommand(interp, "open", JimAioOpenCommand, NULL, NULL);
#ifndef JIM_ANSIC
Jim_CreateCommand(interp, "socket", JimAioSockCommand, NULL, NULL);
#endif
JimMakeChannel(interp, stdin, -1, NULL, "stdin", 0, "r");
JimMakeChannel(interp, stdout, -1, NULL, "stdout", 0, "w");
JimMakeChannel(interp, stderr, -1, NULL, "stderr", 0, "w");
return JIM_OK;
}
|
| ︙ | ︙ | |||
2839 2840 2841 2842 2843 2844 2845 |
static regex_t *SetRegexpFromAny(Jim_Interp *interp, Jim_Obj *objPtr, unsigned flags)
{
regex_t *compre;
const char *pattern;
int ret;
| | | | | | 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 |
static regex_t *SetRegexpFromAny(Jim_Interp *interp, Jim_Obj *objPtr, unsigned flags)
{
regex_t *compre;
const char *pattern;
int ret;
if (objPtr->typePtr == ®expObjType &&
objPtr->internalRep.regexpValue.compre && objPtr->internalRep.regexpValue.flags == flags) {
return objPtr->internalRep.regexpValue.compre;
}
pattern = Jim_String(objPtr);
compre = Jim_Alloc(sizeof(regex_t));
if ((ret = regcomp(compre, pattern, REG_EXTENDED | flags)) != 0) {
char buf[100];
regerror(ret, compre, buf, sizeof(buf));
|
| ︙ | ︙ | |||
3009 3010 3011 3012 3013 3014 3015 |
if (match == REG_NOMATCH) {
goto done;
}
num_matches++;
if (opt_all && !opt_inline) {
| | | 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 |
if (match == REG_NOMATCH) {
goto done;
}
num_matches++;
if (opt_all && !opt_inline) {
goto try_next_match;
}
j = 0;
for (i += 2; opt_inline ? j < num_vars : i < argc; i++, j++) {
Jim_Obj *resultObj;
|
| ︙ | ︙ | |||
3049 3050 3051 3052 3053 3054 3055 |
}
}
if (opt_inline) {
Jim_ListAppendElement(interp, resultListObj, resultObj);
}
else {
| | | 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 |
}
}
if (opt_inline) {
Jim_ListAppendElement(interp, resultListObj, resultObj);
}
else {
result = Jim_SetVariable(interp, argv[i], resultObj);
if (result != JIM_OK) {
Jim_FreeObj(interp, resultObj);
break;
}
}
|
| ︙ | ︙ | |||
3176 3177 3178 3179 3180 3181 3182 |
}
pattern = Jim_String(argv[i]);
source_str = Jim_GetString(argv[i + 1], &source_len);
replace_str = Jim_GetString(argv[i + 2], &replace_len);
varname = argv[i + 3];
| | | | 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 |
}
pattern = Jim_String(argv[i]);
source_str = Jim_GetString(argv[i + 1], &source_len);
replace_str = Jim_GetString(argv[i + 2], &replace_len);
varname = argv[i + 3];
resultObj = Jim_NewStringObj(interp, "", 0);
if (offset) {
if (offset < 0) {
offset += source_len + 1;
}
if (offset > source_len) {
offset = source_len;
}
else if (offset < 0) {
offset = 0;
}
}
Jim_AppendString(interp, resultObj, source_str, offset);
n = source_len - offset;
p = source_str + offset;
do {
int match = regexec(regex, p, MAX_SUB_MATCHES, pmatch, regexec_flags);
|
| ︙ | ︙ | |||
3250 3251 3252 3253 3254 3255 3256 |
pmatch[idx].rm_eo - pmatch[idx].rm_so);
}
}
p += pmatch[0].rm_eo;
n -= pmatch[0].rm_eo;
| | | | | | | 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 |
pmatch[idx].rm_eo - pmatch[idx].rm_so);
}
}
p += pmatch[0].rm_eo;
n -= pmatch[0].rm_eo;
if (!opt_all || n == 0) {
break;
}
if ((regcomp_flags & REG_NEWLINE) == 0 && pattern[0] == '^') {
break;
}
if (pattern[0] == '\0' && n) {
Jim_AppendString(interp, resultObj, p, 1);
p++;
n--;
}
regexec_flags |= REG_NOTBOL;
} while (n);
Jim_AppendString(interp, resultObj, p, -1);
if (argc - i == 4) {
result = Jim_SetVariable(interp, varname, resultObj);
if (result == JIM_OK) {
Jim_SetResultInt(interp, num_matches);
}
else {
|
| ︙ | ︙ | |||
3379 3380 3381 3382 3383 3384 3385 |
{
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, key, -1));
Jim_ListAppendElement(interp, listObj, Jim_NewIntObj(interp, value));
}
static int StoreStatData(Jim_Interp *interp, Jim_Obj *varName, const struct stat *sb)
{
| | | | | | | | 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 |
{
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, key, -1));
Jim_ListAppendElement(interp, listObj, Jim_NewIntObj(interp, value));
}
static int StoreStatData(Jim_Interp *interp, Jim_Obj *varName, const struct stat *sb)
{
Jim_Obj *listObj = Jim_NewListObj(interp, NULL, 0);
AppendStatElement(interp, listObj, "dev", sb->st_dev);
AppendStatElement(interp, listObj, "ino", sb->st_ino);
AppendStatElement(interp, listObj, "mode", sb->st_mode);
AppendStatElement(interp, listObj, "nlink", sb->st_nlink);
AppendStatElement(interp, listObj, "uid", sb->st_uid);
AppendStatElement(interp, listObj, "gid", sb->st_gid);
AppendStatElement(interp, listObj, "size", sb->st_size);
AppendStatElement(interp, listObj, "atime", sb->st_atime);
AppendStatElement(interp, listObj, "mtime", sb->st_mtime);
AppendStatElement(interp, listObj, "ctime", sb->st_ctime);
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, "type", -1));
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, JimGetFileType((int)sb->st_mode), -1));
if (varName) {
Jim_Obj *objPtr = Jim_GetVariable(interp, varName, JIM_NONE);
if (objPtr) {
if (Jim_DictSize(interp, objPtr) < 0) {
Jim_SetResultFormatted(interp, "can't set \"%#s(dev)\": variable isn't array", varName);
Jim_FreeNewObj(interp, listObj);
return JIM_ERR;
}
if (Jim_IsShared(objPtr))
objPtr = Jim_DuplicateObj(interp, objPtr);
Jim_ListAppendList(interp, objPtr, listObj);
Jim_DictSize(interp, objPtr);
Jim_InvalidateStringRep(objPtr);
Jim_FreeNewObj(interp, listObj);
listObj = objPtr;
}
Jim_SetVariable(interp, varName, listObj);
}
Jim_SetResult(interp, listObj);
return JIM_OK;
}
static int file_cmd_dirname(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
const char *path = Jim_String(argv[0]);
const char *p = strrchr(path, '/');
if (!p && path[0] == '.' && path[1] == '.' && path[2] == '\0') {
Jim_SetResultString(interp, "..", -1);
} else if (!p) {
Jim_SetResultString(interp, ".", -1);
}
else if (p == path) {
Jim_SetResultString(interp, "/", -1);
}
else if (ISWINDOWS && p[-1] == ':') {
Jim_SetResultString(interp, path, p - path + 1);
}
else {
Jim_SetResultString(interp, path, p - path);
}
return JIM_OK;
}
|
| ︙ | ︙ | |||
3520 3521 3522 3523 3524 3525 3526 |
{
int i;
char *newname = Jim_Alloc(MAXPATHLEN + 1);
char *last = newname;
*newname = 0;
| | | | | | | | | | 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 |
{
int i;
char *newname = Jim_Alloc(MAXPATHLEN + 1);
char *last = newname;
*newname = 0;
for (i = 0; i < argc; i++) {
int len;
const char *part = Jim_GetString(argv[i], &len);
if (*part == '/') {
last = newname;
}
else if (ISWINDOWS && strchr(part, ':')) {
last = newname;
}
else if (part[0] == '.') {
if (part[1] == '/') {
part += 2;
len -= 2;
}
else if (part[1] == 0 && last != newname) {
continue;
}
}
if (last != newname && last[-1] != '/') {
*last++ = '/';
}
if (len) {
if (last + len - newname >= MAXPATHLEN) {
Jim_Free(newname);
Jim_SetResultString(interp, "Path too long", -1);
return JIM_ERR;
}
memcpy(last, part, len);
last += len;
}
if (last > newname + 1 && last[-1] == '/') {
if (!ISWINDOWS || !(last > newname + 2 && last[-2] == ':')) {
*--last = 0;
}
}
}
*last = 0;
Jim_SetResult(interp, Jim_NewStringObjNoAlloc(interp, newname, last - newname));
return JIM_OK;
}
static int file_access(Jim_Interp *interp, Jim_Obj *filename, int mode)
|
| ︙ | ︙ | |||
3599 3600 3601 3602 3603 3604 3605 |
}
static int file_cmd_executable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
#ifdef X_OK
return file_access(interp, argv[0], X_OK);
#else
| | | 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 |
}
static int file_cmd_executable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
#ifdef X_OK
return file_access(interp, argv[0], X_OK);
#else
Jim_SetResultBool(interp, 1);
return JIM_OK;
#endif
}
static int file_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
|
| ︙ | ︙ | |||
3624 3625 3626 3627 3628 3629 3630 |
}
while (argc--) {
const char *path = Jim_String(argv[0]);
if (unlink(path) == -1 && errno != ENOENT) {
if (rmdir(path) == -1) {
| | | 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 |
}
while (argc--) {
const char *path = Jim_String(argv[0]);
if (unlink(path) == -1 && errno != ENOENT) {
if (rmdir(path) == -1) {
if (!force || Jim_EvalPrefix(interp, "file delete force", 1, argv) != JIM_OK) {
Jim_SetResultFormatted(interp, "couldn't delete file \"%s\": %s", path,
strerror(errno));
return JIM_ERR;
}
}
}
|
| ︙ | ︙ | |||
3647 3648 3649 3650 3651 3652 3653 |
#define MKDIR_DEFAULT(PATHNAME) mkdir(PATHNAME, 0755)
#endif
static int mkdir_all(char *path)
{
int ok = 1;
| | | | | | | | 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 |
#define MKDIR_DEFAULT(PATHNAME) mkdir(PATHNAME, 0755)
#endif
static int mkdir_all(char *path)
{
int ok = 1;
goto first;
while (ok--) {
{
char *slash = strrchr(path, '/');
if (slash && slash != path) {
*slash = 0;
if (mkdir_all(path) != 0) {
return -1;
}
*slash = '/';
}
}
first:
if (MKDIR_DEFAULT(path) == 0) {
return 0;
}
if (errno == ENOENT) {
continue;
}
if (errno == EEXIST) {
struct stat sb;
if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
return 0;
}
errno = EEXIST;
}
break;
}
return -1;
}
static int file_cmd_mkdir(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
|
| ︙ | ︙ | |||
3970 3971 3972 3973 3974 3975 3976 |
static const jim_subcmd_type file_command_table[] = {
{ "atime",
"name",
file_cmd_atime,
1,
1,
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 |
static const jim_subcmd_type file_command_table[] = {
{ "atime",
"name",
file_cmd_atime,
1,
1,
},
{ "mtime",
"name ?time?",
file_cmd_mtime,
1,
2,
},
{ "copy",
"?-force? source dest",
file_cmd_copy,
2,
3,
},
{ "dirname",
"name",
file_cmd_dirname,
1,
1,
},
{ "rootname",
"name",
file_cmd_rootname,
1,
1,
},
{ "extension",
"name",
file_cmd_extension,
1,
1,
},
{ "tail",
"name",
file_cmd_tail,
1,
1,
},
{ "normalize",
"name",
file_cmd_normalize,
1,
1,
},
{ "join",
"name ?name ...?",
file_cmd_join,
1,
-1,
},
{ "readable",
"name",
file_cmd_readable,
1,
1,
},
{ "writable",
"name",
file_cmd_writable,
1,
1,
},
{ "executable",
"name",
file_cmd_executable,
1,
1,
},
{ "exists",
"name",
file_cmd_exists,
1,
1,
},
{ "delete",
"?-force|--? name ...",
file_cmd_delete,
1,
-1,
},
{ "mkdir",
"dir ...",
file_cmd_mkdir,
1,
-1,
},
{ "tempfile",
"?template?",
file_cmd_tempfile,
0,
1,
},
{ "rename",
"?-force? source dest",
file_cmd_rename,
2,
3,
},
#if defined(HAVE_LINK) && defined(HAVE_SYMLINK)
{ "link",
"?-symbolic|-hard? newname target",
file_cmd_link,
2,
3,
},
#endif
#if defined(HAVE_READLINK)
{ "readlink",
"name",
file_cmd_readlink,
1,
1,
},
#endif
{ "size",
"name",
file_cmd_size,
1,
1,
},
{ "stat",
"name ?var?",
file_cmd_stat,
1,
2,
},
{ "lstat",
"name ?var?",
file_cmd_lstat,
1,
2,
},
{ "type",
"name",
file_cmd_type,
1,
1,
},
#ifdef HAVE_GETEUID
{ "owned",
"name",
file_cmd_owned,
1,
1,
},
#endif
{ "isdirectory",
"name",
file_cmd_isdirectory,
1,
1,
},
{ "isfile",
"name",
file_cmd_isfile,
1,
1,
},
{
NULL
}
};
static int Jim_CdCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
| ︙ | ︙ | |||
4187 4188 4189 4190 4191 4192 4193 |
if (getcwd(cwd, MAXPATHLEN) == NULL) {
Jim_SetResultString(interp, "Failed to get pwd", -1);
Jim_Free(cwd);
return JIM_ERR;
}
else if (ISWINDOWS) {
| | | 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 |
if (getcwd(cwd, MAXPATHLEN) == NULL) {
Jim_SetResultString(interp, "Failed to get pwd", -1);
Jim_Free(cwd);
return JIM_ERR;
}
else if (ISWINDOWS) {
char *p = cwd;
while ((p = strchr(p, '\\')) != NULL) {
*p++ = '/';
}
}
Jim_SetResultString(interp, cwd, -1);
|
| ︙ | ︙ | |||
4211 4212 4213 4214 4215 4216 4217 |
Jim_CreateCommand(interp, "file", Jim_SubCmdProc, (void *)file_command_table, NULL);
Jim_CreateCommand(interp, "pwd", Jim_PwdCmd, NULL, NULL);
Jim_CreateCommand(interp, "cd", Jim_CdCmd, NULL, NULL);
return JIM_OK;
}
| < | | | 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 |
Jim_CreateCommand(interp, "file", Jim_SubCmdProc, (void *)file_command_table, NULL);
Jim_CreateCommand(interp, "pwd", Jim_PwdCmd, NULL, NULL);
Jim_CreateCommand(interp, "cd", Jim_CdCmd, NULL, NULL);
return JIM_OK;
}
#include <string.h>
#include <ctype.h>
#if (!defined(HAVE_VFORK) || !defined(HAVE_WAITPID)) && !defined(__MINGW32__)
static int Jim_ExecCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *cmdlineObj = Jim_NewEmptyStringObj(interp);
int i, j;
int rc;
for (i = 1; i < argc; i++) {
int len;
const char *arg = Jim_GetString(argv[i], &len);
if (i > 1) {
Jim_AppendString(interp, cmdlineObj, " ", 1);
}
if (strpbrk(arg, "\\\" ") == NULL) {
Jim_AppendString(interp, cmdlineObj, arg, len);
continue;
}
Jim_AppendString(interp, cmdlineObj, "\"", 1);
for (j = 0; j < len; j++) {
if (arg[j] == '\\' || arg[j] == '"') {
|
| ︙ | ︙ | |||
4277 4278 4279 4280 4281 4282 4283 | #else #include <errno.h> #include <signal.h> #if defined(__MINGW32__) | | | 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 |
#else
#include <errno.h>
#include <signal.h>
#if defined(__MINGW32__)
#ifndef STRICT
#define STRICT
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <fcntl.h>
|
| ︙ | ︙ | |||
4403 4404 4405 4406 4407 4408 4409 |
Jim_Obj *objPtr = Jim_GetGlobalVariableStr(interp, "env", JIM_NONE);
if (!objPtr) {
return Jim_GetEnviron();
}
| | | | 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 |
Jim_Obj *objPtr = Jim_GetGlobalVariableStr(interp, "env", JIM_NONE);
if (!objPtr) {
return Jim_GetEnviron();
}
num = Jim_ListLength(interp, objPtr);
if (num % 2) {
num--;
}
size = Jim_Length(objPtr) + 2;
envptr = Jim_Alloc(sizeof(*envptr) * (num / 2 + 1) + size);
envdata = (char *)&envptr[num / 2 + 1];
|
| ︙ | ︙ | |||
4502 4503 4504 4505 4506 4507 4508 |
return JIM_ERR;
}
struct WaitInfo
{
| | | | | | | | 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 |
return JIM_ERR;
}
struct WaitInfo
{
pidtype pid;
int status;
int flags;
};
struct WaitInfoTable {
struct WaitInfo *info;
int size;
int used;
};
#define WI_DETACHED 2
#define WAIT_TABLE_GROW_BY 4
|
| ︙ | ︙ | |||
4537 4538 4539 4540 4541 4542 4543 |
table->size = table->used = 0;
return table;
}
static int Jim_ExecCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
| | | | | 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 |
table->size = table->used = 0;
return table;
}
static int Jim_ExecCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
fdtype outputId;
fdtype errorId;
pidtype *pidPtr;
int numPids, result;
int child_siginfo = 1;
Jim_Obj *childErrObj;
Jim_Obj *errStrObj;
if (argc > 1 && Jim_CompareStringImmediate(interp, argv[argc - 1], "&")) {
Jim_Obj *listObj;
int i;
argc--;
numPids = JimCreatePipeline(interp, argc - 1, argv + 1, &pidPtr, NULL, NULL, NULL);
if (numPids < 0) {
return JIM_ERR;
}
listObj = Jim_NewListObj(interp, NULL, 0);
for (i = 0; i < numPids; i++) {
Jim_ListAppendElement(interp, listObj, Jim_NewIntObj(interp, (long)pidPtr[i]));
}
Jim_SetResult(interp, listObj);
JimDetachPids(interp, numPids, pidPtr);
Jim_Free(pidPtr);
|
| ︙ | ︙ | |||
4576 4577 4578 4579 4580 4581 4582 |
return JIM_ERR;
}
result = JIM_OK;
errStrObj = Jim_NewStringObj(interp, "", 0);
| | | | | | | | 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 |
return JIM_ERR;
}
result = JIM_OK;
errStrObj = Jim_NewStringObj(interp, "", 0);
if (outputId != JIM_BAD_FD) {
if (JimAppendStreamToString(interp, outputId, errStrObj) < 0) {
result = JIM_ERR;
Jim_SetResultErrno(interp, "error reading from output pipe");
}
}
childErrObj = Jim_NewStringObj(interp, "", 0);
Jim_IncrRefCount(childErrObj);
if (JimCleanupChildren(interp, numPids, pidPtr, childErrObj) != JIM_OK) {
result = JIM_ERR;
}
if (errorId != JIM_BAD_FD) {
int ret;
JimRewindFd(errorId);
ret = JimAppendStreamToString(interp, errorId, errStrObj);
if (ret < 0) {
Jim_SetResultErrno(interp, "error reading from error pipe");
result = JIM_ERR;
}
else if (ret > 0) {
child_siginfo = 0;
}
}
if (child_siginfo) {
Jim_AppendObj(interp, errStrObj, childErrObj);
}
Jim_DecrRefCount(interp, childErrObj);
Jim_RemoveTrailingNewline(errStrObj);
Jim_SetResult(interp, errStrObj);
return result;
}
static void JimReapDetachedPids(struct WaitInfoTable *table)
{
|
| ︙ | ︙ | |||
4638 4639 4640 4641 4642 4643 4644 |
waitPtr = table->info;
dest = 0;
for (count = table->used; count > 0; waitPtr++, count--) {
if (waitPtr->flags & WI_DETACHED) {
int status;
pidtype pid = JimWaitPid(waitPtr->pid, &status, WNOHANG);
if (pid == waitPtr->pid) {
| | | | | | | | 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 |
waitPtr = table->info;
dest = 0;
for (count = table->used; count > 0; waitPtr++, count--) {
if (waitPtr->flags & WI_DETACHED) {
int status;
pidtype pid = JimWaitPid(waitPtr->pid, &status, WNOHANG);
if (pid == waitPtr->pid) {
table->used--;
continue;
}
}
if (waitPtr != &table->info[dest]) {
table->info[dest] = *waitPtr;
}
dest++;
}
}
static pidtype JimWaitForProcess(struct WaitInfoTable *table, pidtype pid, int *statusPtr)
{
int i;
for (i = 0; i < table->used; i++) {
if (pid == table->info[i].pid) {
JimWaitPid(pid, statusPtr, 0);
if (i != table->used - 1) {
table->info[i] = table->info[table->used - 1];
}
table->used--;
return pid;
}
}
return JIM_BAD_PID;
}
static void JimDetachPids(Jim_Interp *interp, int numPids, const pidtype *pidPtr)
{
int j;
struct WaitInfoTable *table = Jim_CmdPrivData(interp);
for (j = 0; j < numPids; j++) {
int i;
for (i = 0; i < table->used; i++) {
if (pidPtr[j] == table->info[i].pid) {
table->info[i].flags |= WI_DETACHED;
break;
}
}
|
| ︙ | ︙ | |||
4716 4717 4718 4719 4720 4721 4722 |
int numPids = 0; /* Actual number of processes that exist
* at *pidPtr right now. */
int cmdCount; /* Count of number of distinct commands
* found in argc/argv. */
const char *input = NULL; /* Describes input for pipeline, depending
* on "inputFile". NULL means take input
* from stdin/pipe. */
| | | | | | | 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 |
int numPids = 0; /* Actual number of processes that exist
* at *pidPtr right now. */
int cmdCount; /* Count of number of distinct commands
* found in argc/argv. */
const char *input = NULL; /* Describes input for pipeline, depending
* on "inputFile". NULL means take input
* from stdin/pipe. */
int input_len = 0;
#define FILE_NAME 0
#define FILE_APPEND 1
#define FILE_HANDLE 2
#define FILE_TEXT 3
int inputFile = FILE_NAME; /* 1 means input is name of input file.
* 2 means input is filehandle name.
* 0 means input holds actual
* text to be input to command. */
int outputFile = FILE_NAME; /* 0 means output is the name of output file.
|
| ︙ | ︙ | |||
4746 4747 4748 4749 4750 4751 4752 |
* or NULL if output goes to stdout/pipe. */
const char *error = NULL; /* Holds name of stderr file to pipe to,
* or NULL if stderr goes to stderr/pipe. */
fdtype inputId = JIM_BAD_FD;
fdtype outputId = JIM_BAD_FD;
fdtype errorId = JIM_BAD_FD;
fdtype lastOutputId = JIM_BAD_FD;
| | | | 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 |
* or NULL if output goes to stdout/pipe. */
const char *error = NULL; /* Holds name of stderr file to pipe to,
* or NULL if stderr goes to stderr/pipe. */
fdtype inputId = JIM_BAD_FD;
fdtype outputId = JIM_BAD_FD;
fdtype errorId = JIM_BAD_FD;
fdtype lastOutputId = JIM_BAD_FD;
fdtype pipeIds[2];
int firstArg, lastArg; /* Indexes of first and last arguments in
* current command. */
int lastBar;
int i;
pidtype pid;
char **save_environ;
struct WaitInfoTable *table = Jim_CmdPrivData(interp);
char **arg_array = Jim_Alloc(sizeof(*arg_array) * (argc + 1));
int arg_count = 0;
JimReapDetachedPids(table);
if (inPipePtr != NULL) {
*inPipePtr = JIM_BAD_FD;
|
| ︙ | ︙ | |||
4805 4806 4807 4808 4809 4810 4811 |
output = arg + 1;
if (*output == '>') {
outputFile = FILE_APPEND;
output++;
}
if (*output == '&') {
| | | 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 |
output = arg + 1;
if (*output == '>') {
outputFile = FILE_APPEND;
output++;
}
if (*output == '&') {
output++;
dup_error = 1;
}
if (*output == '@') {
outputFile = FILE_HANDLE;
output++;
}
|
| ︙ | ︙ | |||
4846 4847 4848 4849 4850 4851 4852 |
if (i == lastBar + 1 || i == argc - 1) {
Jim_SetResultString(interp, "illegal use of | or |& in command", -1);
goto badargs;
}
lastBar = i;
cmdCount++;
}
| | | | | 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 |
if (i == lastBar + 1 || i == argc - 1) {
Jim_SetResultString(interp, "illegal use of | or |& in command", -1);
goto badargs;
}
lastBar = i;
cmdCount++;
}
arg_array[arg_count++] = (char *)arg;
continue;
}
if (i >= argc) {
Jim_SetResultFormatted(interp, "can't specify \"%s\" as last word in command", arg);
goto badargs;
}
}
if (arg_count == 0) {
Jim_SetResultString(interp, "didn't specify command to execute", -1);
badargs:
Jim_Free(arg_array);
return -1;
}
save_environ = JimSaveEnv(JimBuildEnv(interp));
if (input != NULL) {
if (inputFile == FILE_TEXT) {
inputId = JimCreateTemp(interp, input, input_len);
if (inputId == JIM_BAD_FD) {
goto error;
}
}
else if (inputFile == FILE_HANDLE) {
FILE *fh = JimGetAioFilehandle(interp, input);
if (fh == NULL) {
goto error;
}
inputId = JimDupFd(JimFileno(fh));
}
|
| ︙ | ︙ | |||
4927 4928 4929 4930 4931 4932 4933 |
Jim_SetResultErrno(interp, "couldn't create output pipe");
goto error;
}
lastOutputId = pipeIds[1];
*outPipePtr = pipeIds[0];
pipeIds[0] = pipeIds[1] = JIM_BAD_FD;
}
| | | | | 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 |
Jim_SetResultErrno(interp, "couldn't create output pipe");
goto error;
}
lastOutputId = pipeIds[1];
*outPipePtr = pipeIds[0];
pipeIds[0] = pipeIds[1] = JIM_BAD_FD;
}
if (error != NULL) {
if (errorFile == FILE_HANDLE) {
if (strcmp(error, "1") == 0) {
if (lastOutputId != JIM_BAD_FD) {
errorId = JimDupFd(lastOutputId);
}
else {
error = "stdout";
}
}
if (errorId == JIM_BAD_FD) {
FILE *fh = JimGetAioFilehandle(interp, error);
if (fh == NULL) {
goto error;
|
| ︙ | ︙ | |||
4982 4983 4984 4985 4986 4987 4988 |
if (arg_array[lastArg][0] == '|') {
if (arg_array[lastArg][1] == '&') {
pipe_dup_err = 1;
}
break;
}
}
| | | | | | | | | | 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 |
if (arg_array[lastArg][0] == '|') {
if (arg_array[lastArg][1] == '&') {
pipe_dup_err = 1;
}
break;
}
}
arg_array[lastArg] = NULL;
if (lastArg == arg_count) {
outputId = lastOutputId;
}
else {
if (JimPipe(pipeIds) != 0) {
Jim_SetResultErrno(interp, "couldn't create pipe");
goto error;
}
outputId = pipeIds[1];
}
if (pipe_dup_err) {
errorId = outputId;
}
#ifdef __MINGW32__
pid = JimStartWinProcess(interp, &arg_array[firstArg], save_environ ? save_environ[0] : NULL, inputId, outputId, errorId);
if (pid == JIM_BAD_PID) {
Jim_SetResultFormatted(interp, "couldn't exec \"%s\"", arg_array[firstArg]);
goto error;
}
#else
pid = vfork();
if (pid < 0) {
Jim_SetResultErrno(interp, "couldn't fork child process");
goto error;
}
if (pid == 0) {
if (inputId != -1) dup2(inputId, 0);
if (outputId != -1) dup2(outputId, 1);
if (errorId != -1) dup2(errorId, 2);
for (i = 3; (i <= outputId) || (i <= inputId) || (i <= errorId); i++) {
close(i);
}
(void)signal(SIGPIPE, SIG_DFL);
execvpe(arg_array[firstArg], &arg_array[firstArg], Jim_GetEnviron());
fprintf(stderr, "couldn't exec \"%s\"\n", arg_array[firstArg]);
_exit(127);
}
#endif
if (table->used == table->size) {
table->size += WAIT_TABLE_GROW_BY;
table->info = Jim_Realloc(table->info, table->size * sizeof(*table->info));
}
table->info[table->used].pid = pid;
table->info[table->used].flags = 0;
table->used++;
pidPtr[numPids] = pid;
errorId = origErrorId;
if (inputId != JIM_BAD_FD) {
JimCloseFd(inputId);
}
if (outputId != JIM_BAD_FD) {
|
| ︙ | ︙ | |||
5120 5121 5122 5123 5124 5125 5126 |
static int JimCleanupChildren(Jim_Interp *interp, int numPids, pidtype *pidPtr, Jim_Obj *errStrObj)
{
struct WaitInfoTable *table = Jim_CmdPrivData(interp);
int result = JIM_OK;
int i;
| | | 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 |
static int JimCleanupChildren(Jim_Interp *interp, int numPids, pidtype *pidPtr, Jim_Obj *errStrObj)
{
struct WaitInfoTable *table = Jim_CmdPrivData(interp);
int result = JIM_OK;
int i;
for (i = 0; i < numPids; i++) {
int waitStatus = 0;
if (JimWaitForProcess(table, pidPtr[i], &waitStatus) != JIM_BAD_PID) {
if (JimCheckWaitStatus(interp, pidPtr[i], waitStatus, errStrObj) != JIM_OK) {
result = JIM_ERR;
}
}
|
| ︙ | ︙ | |||
5293 5294 5295 5296 5297 5298 5299 |
{
return (fdtype)_get_osfhandle(_fileno(fh));
}
static fdtype JimOpenForRead(const char *filename)
{
return CreateFile(filename, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
| | | | < < < < | | 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 |
{
return (fdtype)_get_osfhandle(_fileno(fh));
}
static fdtype JimOpenForRead(const char *filename)
{
return CreateFile(filename, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
JimStdSecAttrs(), OPEN_EXISTING, 0, NULL);
}
static fdtype JimOpenForWrite(const char *filename, int append)
{
return CreateFile(filename, append ? FILE_APPEND_DATA : GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
JimStdSecAttrs(), append ? OPEN_ALWAYS : CREATE_ALWAYS, 0, (HANDLE) NULL);
}
static FILE *JimFdOpenForWrite(fdtype fd)
{
return _fdopen(_open_osfhandle((int)fd, _O_TEXT), "w");
}
static pidtype JimWaitPid(pidtype pid, int *status, int nohang)
{
DWORD ret = WaitForSingleObject(pid, nohang ? 0 : INFINITE);
if (ret == WAIT_TIMEOUT || ret == WAIT_FAILED) {
return JIM_BAD_PID;
}
GetExitCodeProcess(pid, &ret);
*status = ret;
CloseHandle(pid);
return pid;
}
|
| ︙ | ︙ | |||
5342 5343 5344 5345 5346 5347 5348 |
NULL);
if (handle == INVALID_HANDLE_VALUE) {
goto error;
}
if (contents != NULL) {
| | | 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 |
NULL);
if (handle == INVALID_HANDLE_VALUE) {
goto error;
}
if (contents != NULL) {
FILE *fh = JimFdOpenForWrite(JimDupFd(handle));
if (fh == NULL) {
goto error;
}
if (fwrite(contents, len, 1, fh) != 1) {
fclose(fh);
|
| ︙ | ︙ | |||
5614 5615 5616 5617 5618 5619 5620 |
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
static int clock_cmd_format(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
| | | 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 |
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
static int clock_cmd_format(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
char buf[100];
time_t t;
long seconds;
const char *format = "%a %b %d %H:%M:%S %Z %Y";
if (argc == 2 || (argc == 3 && !Jim_CompareStringImmediate(interp, argv[1], "-format"))) {
|
| ︙ | ︙ | |||
5655 5656 5657 5658 5659 5660 5661 |
struct tm tm;
time_t now = time(0);
if (!Jim_CompareStringImmediate(interp, argv[1], "-format")) {
return -1;
}
| | | | 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 |
struct tm tm;
time_t now = time(0);
if (!Jim_CompareStringImmediate(interp, argv[1], "-format")) {
return -1;
}
localtime_r(&now, &tm);
pt = strptime(Jim_String(argv[0]), Jim_String(argv[2]), &tm);
if (pt == 0 || *pt != 0) {
Jim_SetResultString(interp, "Failed to parse time according to format", -1);
return JIM_ERR;
}
Jim_SetResultInt(interp, mktime(&tm));
return JIM_OK;
}
#endif
static int clock_cmd_seconds(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
| ︙ | ︙ | |||
5706 5707 5708 5709 5710 5711 5712 |
static const jim_subcmd_type clock_command_table[] = {
{ "seconds",
NULL,
clock_cmd_seconds,
0,
0,
| | | | | | | | 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 |
static const jim_subcmd_type clock_command_table[] = {
{ "seconds",
NULL,
clock_cmd_seconds,
0,
0,
},
{ "clicks",
NULL,
clock_cmd_micros,
0,
0,
},
{ "microseconds",
NULL,
clock_cmd_micros,
0,
0,
},
{ "milliseconds",
NULL,
clock_cmd_millis,
0,
0,
},
{ "format",
"seconds ?-format format?",
clock_cmd_format,
1,
3,
},
#ifdef HAVE_STRPTIME
{ "scan",
"str -format format",
clock_cmd_scan,
3,
3,
},
#endif
{ NULL }
};
int Jim_clockInit(Jim_Interp *interp)
{
|
| ︙ | ︙ | |||
5766 5767 5768 5769 5770 5771 5772 |
#include <string.h>
#include <stdio.h>
#include <errno.h>
static int array_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
| | | | | | 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 |
#include <string.h>
#include <stdio.h>
#include <errno.h>
static int array_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_SetResultInt(interp, Jim_GetVariable(interp, argv[0], 0) != 0);
return JIM_OK;
}
static int array_cmd_get(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
Jim_Obj *patternObj;
if (!objPtr) {
return JIM_OK;
}
patternObj = (argc == 1) ? NULL : argv[1];
if (patternObj == NULL || Jim_CompareStringImmediate(interp, patternObj, "*")) {
if (Jim_IsList(objPtr) && Jim_ListLength(interp, objPtr) % 2 == 0) {
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
}
return Jim_DictValues(interp, objPtr, patternObj);
}
static int array_cmd_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
|
| ︙ | ︙ | |||
5815 5816 5817 5818 5819 5820 5821 |
int i;
int len;
Jim_Obj *resultObj;
Jim_Obj *objPtr;
Jim_Obj **dictValuesObj;
if (argc == 1 || Jim_CompareStringImmediate(interp, argv[1], "*")) {
| | | | | | 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 |
int i;
int len;
Jim_Obj *resultObj;
Jim_Obj *objPtr;
Jim_Obj **dictValuesObj;
if (argc == 1 || Jim_CompareStringImmediate(interp, argv[1], "*")) {
Jim_UnsetVariable(interp, argv[0], JIM_NONE);
return JIM_OK;
}
objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
if (objPtr == NULL) {
return JIM_OK;
}
if (Jim_DictPairs(interp, objPtr, &dictValuesObj, &len) != JIM_OK) {
return JIM_ERR;
}
resultObj = Jim_NewDictObj(interp, NULL, 0);
for (i = 0; i < len; i += 2) {
if (!Jim_StringMatchObj(interp, argv[1], dictValuesObj[i], 0)) {
Jim_DictAddElement(interp, resultObj, dictValuesObj[i], dictValuesObj[i + 1]);
}
}
Jim_Free(dictValuesObj);
Jim_SetVariable(interp, argv[0], resultObj);
return JIM_OK;
}
static int array_cmd_size(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *objPtr;
int len = 0;
objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
if (objPtr) {
len = Jim_DictSize(interp, objPtr);
if (len < 0) {
return JIM_ERR;
}
}
|
| ︙ | ︙ | |||
5889 5890 5891 5892 5893 5894 5895 |
if (len % 2) {
Jim_SetResultString(interp, "list must have an even number of elements", -1);
return JIM_ERR;
}
dictObj = Jim_GetVariable(interp, argv[0], JIM_UNSHARED);
if (!dictObj) {
| | | 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 |
if (len % 2) {
Jim_SetResultString(interp, "list must have an even number of elements", -1);
return JIM_ERR;
}
dictObj = Jim_GetVariable(interp, argv[0], JIM_UNSHARED);
if (!dictObj) {
return Jim_SetVariable(interp, argv[0], listObj);
}
else if (Jim_DictSize(interp, dictObj) < 0) {
return JIM_ERR;
}
if (Jim_IsShared(dictObj)) {
|
| ︙ | ︙ | |||
5918 5919 5920 5921 5922 5923 5924 |
static const jim_subcmd_type array_command_table[] = {
{ "exists",
"arrayName",
array_cmd_exists,
1,
1,
| | | | | | | | | 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 |
static const jim_subcmd_type array_command_table[] = {
{ "exists",
"arrayName",
array_cmd_exists,
1,
1,
},
{ "get",
"arrayName ?pattern?",
array_cmd_get,
1,
2,
},
{ "names",
"arrayName ?pattern?",
array_cmd_names,
1,
2,
},
{ "set",
"arrayName list",
array_cmd_set,
2,
2,
},
{ "size",
"arrayName",
array_cmd_size,
1,
1,
},
{ "stat",
"arrayName",
array_cmd_stat,
1,
1,
},
{ "unset",
"arrayName ?pattern?",
array_cmd_unset,
1,
2,
},
{ NULL
}
};
int Jim_arrayInit(Jim_Interp *interp)
{
|
| ︙ | ︙ | |||
6000 6001 6002 6003 6004 6005 6006 | Jim_execInit(interp); Jim_clockInit(interp); Jim_arrayInit(interp); Jim_stdlibInit(interp); Jim_tclcompatInit(interp); return JIM_OK; } | | < | 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 | Jim_execInit(interp); Jim_clockInit(interp); Jim_arrayInit(interp); Jim_stdlibInit(interp); Jim_tclcompatInit(interp); return JIM_OK; } #define JIM_OPTIMIZATION #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <ctype.h> |
| ︙ | ︙ | |||
6070 6071 6072 6073 6074 6075 6076 | #ifdef JIM_DEBUG_PANIC static void JimPanicDump(int fail_condition, const char *fmt, ...); #define JimPanic(X) JimPanicDump X #else #define JimPanic(X) #endif | < < < < < < | 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 |
#ifdef JIM_DEBUG_PANIC
static void JimPanicDump(int fail_condition, const char *fmt, ...);
#define JimPanic(X) JimPanicDump X
#else
#define JimPanic(X)
#endif
static char JimEmptyStringRep[] = "";
static void JimFreeCallFrame(Jim_Interp *interp, Jim_CallFrame *cf, int action);
static int ListSetIndex(Jim_Interp *interp, Jim_Obj *listPtr, int listindex, Jim_Obj *newObjPtr,
int flags);
static int JimDeleteLocalProcs(Jim_Interp *interp, Jim_Stack *localCommands);
|
| ︙ | ︙ | |||
6132 6133 6134 6135 6136 6137 6138 |
if (flags & JIM_CHARSET_SCAN) {
if (*pattern == '^') {
not++;
pattern++;
}
| | | | | | | 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 |
if (flags & JIM_CHARSET_SCAN) {
if (*pattern == '^') {
not++;
pattern++;
}
if (*pattern == ']') {
goto first;
}
}
while (*pattern && *pattern != ']') {
if (pattern[0] == '\\') {
first:
pattern += utf8_tounicode_case(pattern, &pchar, nocase);
}
else {
int start;
int end;
pattern += utf8_tounicode_case(pattern, &start, nocase);
if (pattern[0] == '-' && pattern[1]) {
pattern += utf8_tounicode(pattern, &pchar);
pattern += utf8_tounicode_case(pattern, &end, nocase);
if ((c >= start && c <= end) || (c >= end && c <= start)) {
match = 1;
}
continue;
}
pchar = start;
}
|
| ︙ | ︙ | |||
6189 6190 6191 6192 6193 6194 6195 |
switch (pattern[0]) {
case '*':
while (pattern[1] == '*') {
pattern++;
}
pattern++;
if (!pattern[0]) {
| | | | | | | | 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 |
switch (pattern[0]) {
case '*':
while (pattern[1] == '*') {
pattern++;
}
pattern++;
if (!pattern[0]) {
return 1;
}
while (*string) {
if (JimGlobMatch(pattern, string, nocase))
return 1;
string += utf8_tounicode(string, &c);
}
return 0;
case '?':
string += utf8_tounicode(string, &c);
break;
case '[': {
string += utf8_tounicode(string, &c);
pattern = JimCharsetMatch(pattern + 1, c, nocase ? JIM_NOCASE : 0);
if (!pattern) {
return 0;
}
if (!*pattern) {
continue;
}
break;
}
case '\\':
if (pattern[1]) {
pattern++;
}
default:
string += utf8_tounicode_case(string, &c, nocase);
utf8_tounicode_case(pattern, &pchar, nocase);
if (pchar != c) {
return 0;
}
break;
|
| ︙ | ︙ | |||
6269 6270 6271 6272 6273 6274 6275 |
return JimSign(c1 - c2);
}
maxchars--;
}
if (!maxchars) {
return 0;
}
| | | 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 |
return JimSign(c1 - c2);
}
maxchars--;
}
if (!maxchars) {
return 0;
}
if (*s1) {
return 1;
}
if (*s2) {
return -1;
}
return 0;
|
| ︙ | ︙ | |||
6310 6311 6312 6313 6314 6315 6316 |
static int JimStringLast(const char *s1, int l1, const char *s2, int l2)
{
const char *p;
if (!l1 || !l2 || l1 > l2)
return -1;
| | | 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 |
static int JimStringLast(const char *s1, int l1, const char *s2, int l2)
{
const char *p;
if (!l1 || !l2 || l1 > l2)
return -1;
for (p = s2 + l2 - 1; p != s2 - 1; p--) {
if (*p == *s1 && memcmp(s1, p, l1) == 0) {
return p - s2;
}
}
return -1;
}
|
| ︙ | ︙ | |||
6369 6370 6371 6372 6373 6374 6375 |
if (str[i] == '+') {
i++;
}
*sign = 1;
}
if (str[i] != '0') {
| | | | | | | | | 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 |
if (str[i] == '+') {
i++;
}
*sign = 1;
}
if (str[i] != '0') {
return 0;
}
switch (str[i + 1]) {
case 'x': case 'X': *base = 16; break;
case 'o': case 'O': *base = 8; break;
case 'b': case 'B': *base = 2; break;
default: return 0;
}
i += 2;
if (str[i] != '-' && str[i] != '+' && !isspace(UCHAR(str[i]))) {
return i;
}
*base = 10;
return 0;
}
static long jim_strtol(const char *str, char **endptr)
{
int sign;
int base;
int i = JimNumberBase(str, &base, &sign);
if (base != 10) {
long value = strtol(str + i, endptr, base);
if (endptr == NULL || *endptr != str + i) {
return value * sign;
}
}
return strtol(str, endptr, 10);
}
static jim_wide jim_strtoull(const char *str, char **endptr)
{
#ifdef HAVE_LONG_LONG
int sign;
int base;
int i = JimNumberBase(str, &base, &sign);
if (base != 10) {
jim_wide value = strtoull(str + i, endptr, base);
if (endptr == NULL || *endptr != str + i) {
return value * sign;
}
}
return strtoull(str, endptr, 10);
#else
return (unsigned long)jim_strtol(str, endptr);
#endif
}
int Jim_StringToWide(const char *str, jim_wide * widePtr, int base)
|
| ︙ | ︙ | |||
6448 6449 6450 6451 6452 6453 6454 |
return JimCheckConversion(str, endptr);
}
int Jim_StringToDouble(const char *str, double *doublePtr)
{
char *endptr;
| | | | < < < < < < | < | < < < < | < < < | 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 |
return JimCheckConversion(str, endptr);
}
int Jim_StringToDouble(const char *str, double *doublePtr)
{
char *endptr;
errno = 0;
*doublePtr = strtod(str, &endptr);
return JimCheckConversion(str, endptr);
}
static jim_wide JimPowWide(jim_wide b, jim_wide e)
{
jim_wide i, res = 1;
if ((b == 0 && e != 0) || (e < 0))
return 0;
for (i = 0; i < e; i++) {
res *= b;
}
return res;
}
#ifdef JIM_DEBUG_PANIC
static void JimPanicDump(int condition, const char *fmt, ...)
{
|
| ︙ | ︙ | |||
6543 6544 6545 6546 6547 6548 6549 |
}
char *Jim_StrDupLen(const char *s, int l)
{
char *copy = Jim_Alloc(l + 1);
memcpy(copy, s, l + 1);
| | | 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 |
}
char *Jim_StrDupLen(const char *s, int l)
{
char *copy = Jim_Alloc(l + 1);
memcpy(copy, s, l + 1);
copy[l] = 0;
return copy;
}
static jim_wide JimClock(void)
{
|
| ︙ | ︙ | |||
6632 6633 6634 6635 6636 6637 6638 |
minimal = JIM_HT_INITIAL_SIZE;
Jim_ExpandHashTable(ht, minimal);
}
void Jim_ExpandHashTable(Jim_HashTable *ht, unsigned int size)
{
| | | | | | | | | | 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 |
minimal = JIM_HT_INITIAL_SIZE;
Jim_ExpandHashTable(ht, minimal);
}
void Jim_ExpandHashTable(Jim_HashTable *ht, unsigned int size)
{
Jim_HashTable n;
unsigned int realsize = JimHashTableNextPower(size), i;
if (size <= ht->used)
return;
Jim_InitHashTable(&n, ht->type, ht->privdata);
n.size = realsize;
n.sizemask = realsize - 1;
n.table = Jim_Alloc(realsize * sizeof(Jim_HashEntry *));
n.uniq = ht->uniq;
memset(n.table, 0, realsize * sizeof(Jim_HashEntry *));
n.used = ht->used;
for (i = 0; ht->used > 0; i++) {
Jim_HashEntry *he, *nextHe;
if (ht->table[i] == NULL)
continue;
he = ht->table[i];
while (he) {
unsigned int h;
nextHe = he->next;
h = Jim_HashKey(ht, he->key) & n.sizemask;
he->next = n.table[h];
n.table[h] = he;
ht->used--;
he = nextHe;
}
}
assert(ht->used == 0);
Jim_Free(ht->table);
*ht = n;
}
int Jim_AddHashEntry(Jim_HashTable *ht, const void *key, void *val)
{
Jim_HashEntry *entry;
entry = JimInsertHashEntry(ht, key, 0);
if (entry == NULL)
return JIM_ERR;
Jim_SetHashKey(ht, entry, key);
Jim_SetHashVal(ht, entry, val);
return JIM_OK;
}
int Jim_ReplaceHashEntry(Jim_HashTable *ht, const void *key, void *val)
|
| ︙ | ︙ | |||
6712 6713 6714 6715 6716 6717 6718 |
else {
Jim_FreeEntryVal(ht, entry);
Jim_SetHashVal(ht, entry, val);
}
existed = 1;
}
else {
| | | 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 |
else {
Jim_FreeEntryVal(ht, entry);
Jim_SetHashVal(ht, entry, val);
}
existed = 1;
}
else {
Jim_SetHashKey(ht, entry, key);
Jim_SetHashVal(ht, entry, val);
existed = 0;
}
return existed;
}
|
| ︙ | ︙ | |||
6735 6736 6737 6738 6739 6740 6741 |
return JIM_ERR;
h = Jim_HashKey(ht, key) & ht->sizemask;
he = ht->table[h];
prevHe = NULL;
while (he) {
if (Jim_CompareHashKeys(ht, key, he->key)) {
| | | | | | | | 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 |
return JIM_ERR;
h = Jim_HashKey(ht, key) & ht->sizemask;
he = ht->table[h];
prevHe = NULL;
while (he) {
if (Jim_CompareHashKeys(ht, key, he->key)) {
if (prevHe)
prevHe->next = he->next;
else
ht->table[h] = he->next;
Jim_FreeEntryKey(ht, he);
Jim_FreeEntryVal(ht, he);
Jim_Free(he);
ht->used--;
return JIM_OK;
}
prevHe = he;
he = he->next;
}
return JIM_ERR;
}
int Jim_FreeHashTable(Jim_HashTable *ht)
{
unsigned int i;
for (i = 0; ht->used > 0; i++) {
Jim_HashEntry *he, *nextHe;
if ((he = ht->table[i]) == NULL)
continue;
while (he) {
nextHe = he->next;
Jim_FreeEntryKey(ht, he);
Jim_FreeEntryVal(ht, he);
Jim_Free(he);
ht->used--;
he = nextHe;
}
}
Jim_Free(ht->table);
JimResetHashTable(ht);
return JIM_OK;
}
Jim_HashEntry *Jim_FindHashEntry(Jim_HashTable *ht, const void *key)
{
Jim_HashEntry *he;
unsigned int h;
|
| ︙ | ︙ | |||
6853 6854 6855 6856 6857 6858 6859 |
}
static Jim_HashEntry *JimInsertHashEntry(Jim_HashTable *ht, const void *key, int replace)
{
unsigned int h;
Jim_HashEntry *he;
| | | | | | 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 |
}
static Jim_HashEntry *JimInsertHashEntry(Jim_HashTable *ht, const void *key, int replace)
{
unsigned int h;
Jim_HashEntry *he;
JimExpandHashTableIfNeeded(ht);
h = Jim_HashKey(ht, key) & ht->sizemask;
he = ht->table[h];
while (he) {
if (Jim_CompareHashKeys(ht, key, he->key))
return replace ? he : NULL;
he = he->next;
}
he = Jim_Alloc(sizeof(*he));
he->next = ht->table[h];
ht->table[h] = he;
ht->used++;
he->key = NULL;
return he;
|
| ︙ | ︙ | |||
6899 6900 6901 6902 6903 6904 6905 |
static void JimStringCopyHTKeyDestructor(void *privdata, void *key)
{
Jim_Free(key);
}
static const Jim_HashTableType JimPackageHashTableType = {
| | | | | | | | | | | | | | 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 |
static void JimStringCopyHTKeyDestructor(void *privdata, void *key)
{
Jim_Free(key);
}
static const Jim_HashTableType JimPackageHashTableType = {
JimStringCopyHTHashFunction,
JimStringCopyHTDup,
NULL,
JimStringCopyHTKeyCompare,
JimStringCopyHTKeyDestructor,
NULL
};
typedef struct AssocDataValue
{
Jim_InterpDeleteProc *delProc;
void *data;
} AssocDataValue;
static void JimAssocDataHashTableValueDestructor(void *privdata, void *data)
{
AssocDataValue *assocPtr = (AssocDataValue *) data;
if (assocPtr->delProc != NULL)
assocPtr->delProc((Jim_Interp *)privdata, assocPtr->data);
Jim_Free(data);
}
static const Jim_HashTableType JimAssocDataHashTableType = {
JimStringCopyHTHashFunction,
JimStringCopyHTDup,
NULL,
JimStringCopyHTKeyCompare,
JimStringCopyHTKeyDestructor,
JimAssocDataHashTableValueDestructor
};
void Jim_InitStack(Jim_Stack *stack)
{
stack->len = 0;
stack->maxlen = 0;
stack->vector = NULL;
|
| ︙ | ︙ | |||
6985 6986 6987 6988 6989 6990 6991 |
for (i = 0; i < stack->len; i++)
freeFunc(stack->vector[i]);
}
| | | | | | | | | | | | < | < < < < | | | | | | | | | | | | | 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 |
for (i = 0; i < stack->len; i++)
freeFunc(stack->vector[i]);
}
#define JIM_TT_NONE 0
#define JIM_TT_STR 1
#define JIM_TT_ESC 2
#define JIM_TT_VAR 3
#define JIM_TT_DICTSUGAR 4
#define JIM_TT_CMD 5
#define JIM_TT_SEP 6
#define JIM_TT_EOL 7
#define JIM_TT_EOF 8
#define JIM_TT_LINE 9
#define JIM_TT_WORD 10
#define JIM_TT_SUBEXPR_START 11
#define JIM_TT_SUBEXPR_END 12
#define JIM_TT_SUBEXPR_COMMA 13
#define JIM_TT_EXPR_INT 14
#define JIM_TT_EXPR_DOUBLE 15
#define JIM_TT_EXPRSUGAR 16
#define JIM_TT_EXPR_OP 20
#define TOKEN_IS_SEP(type) (type >= JIM_TT_SEP && type <= JIM_TT_EOF)
struct JimParseMissing {
int ch;
int line;
};
struct JimParserCtx
{
const char *p;
int len;
int linenr;
const char *tstart;
const char *tend;
int tline;
int tt;
int eof;
int inquote;
int comment;
struct JimParseMissing missing;
};
static int JimParseScript(struct JimParserCtx *pc);
static int JimParseSep(struct JimParserCtx *pc);
static int JimParseEol(struct JimParserCtx *pc);
static int JimParseCmd(struct JimParserCtx *pc);
static int JimParseQuote(struct JimParserCtx *pc);
|
| ︙ | ︙ | |||
7069 7070 7071 7072 7073 7074 7075 |
pc->comment = 1;
pc->missing.ch = ' ';
pc->missing.line = linenr;
}
static int JimParseScript(struct JimParserCtx *pc)
{
| | | 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 |
pc->comment = 1;
pc->missing.ch = ' ';
pc->missing.line = linenr;
}
static int JimParseScript(struct JimParserCtx *pc)
{
while (1) {
if (!pc->len) {
pc->tstart = pc->p;
pc->tend = pc->p - 1;
pc->tline = pc->linenr;
pc->tt = JIM_TT_EOL;
pc->eof = 1;
return JIM_OK;
|
| ︙ | ︙ | |||
7105 7106 7107 7108 7109 7110 7111 |
return JimParseStr(pc);
case '[':
pc->comment = 0;
return JimParseCmd(pc);
case '$':
pc->comment = 0;
if (JimParseVar(pc) == JIM_ERR) {
| | | 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 |
return JimParseStr(pc);
case '[':
pc->comment = 0;
return JimParseCmd(pc);
case '$':
pc->comment = 0;
if (JimParseVar(pc) == JIM_ERR) {
pc->tstart = pc->tend = pc->p++;
pc->len--;
pc->tt = JIM_TT_ESC;
}
return JIM_OK;
case '#':
if (pc->comment) {
|
| ︙ | ︙ | |||
7166 7167 7168 7169 7170 7171 7172 |
}
static void JimParseSubBrace(struct JimParserCtx *pc)
{
int level = 1;
| | | 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 |
}
static void JimParseSubBrace(struct JimParserCtx *pc)
{
int level = 1;
pc->p++;
pc->len--;
while (pc->len) {
switch (*pc->p) {
case '\\':
if (pc->len > 1) {
if (*++pc->p == '\n') {
|
| ︙ | ︙ | |||
7210 7211 7212 7213 7214 7215 7216 |
}
static int JimParseSubQuote(struct JimParserCtx *pc)
{
int tt = JIM_TT_STR;
int line = pc->tline;
| | | 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 |
}
static int JimParseSubQuote(struct JimParserCtx *pc)
{
int tt = JIM_TT_STR;
int line = pc->tline;
pc->p++;
pc->len--;
while (pc->len) {
switch (*pc->p) {
case '\\':
if (pc->len > 1) {
if (*++pc->p == '\n') {
|
| ︙ | ︙ | |||
7259 7260 7261 7262 7263 7264 7265 |
static void JimParseSubCmd(struct JimParserCtx *pc)
{
int level = 1;
int startofword = 1;
int line = pc->tline;
| | | 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 |
static void JimParseSubCmd(struct JimParserCtx *pc)
{
int level = 1;
int startofword = 1;
int line = pc->tline;
pc->p++;
pc->len--;
while (pc->len) {
switch (*pc->p) {
case '\\':
if (pc->len > 1) {
if (*++pc->p == '\n') {
|
| ︙ | ︙ | |||
7339 7340 7341 7342 7343 7344 7345 |
pc->tline = pc->linenr;
pc->tt = JimParseSubQuote(pc);
return JIM_OK;
}
static int JimParseVar(struct JimParserCtx *pc)
{
| | | | 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 |
pc->tline = pc->linenr;
pc->tt = JimParseSubQuote(pc);
return JIM_OK;
}
static int JimParseVar(struct JimParserCtx *pc)
{
pc->p++;
pc->len--;
#ifdef EXPRSUGAR_BRACKET
if (*pc->p == '[') {
JimParseCmd(pc);
pc->tt = JIM_TT_EXPRSUGAR;
return JIM_OK;
}
#endif
pc->tstart = pc->p;
|
| ︙ | ︙ | |||
7375 7376 7377 7378 7379 7380 7381 |
if (pc->len) {
pc->p++;
pc->len--;
}
}
else {
while (1) {
| | | | 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 |
if (pc->len) {
pc->p++;
pc->len--;
}
}
else {
while (1) {
if (pc->p[0] == ':' && pc->p[1] == ':') {
while (*pc->p == ':') {
pc->p++;
pc->len--;
}
continue;
}
if (isalnum(UCHAR(*pc->p)) || *pc->p == '_' || UCHAR(*pc->p) >= 0x80) {
pc->p++;
pc->len--;
continue;
}
break;
}
if (*pc->p == '(') {
int count = 1;
const char *paren = NULL;
pc->tt = JIM_TT_DICTSUGAR;
while (count && pc->len) {
|
| ︙ | ︙ | |||
7417 7418 7419 7420 7421 7422 7423 |
}
}
if (count == 0) {
pc->p++;
pc->len--;
}
else if (paren) {
| | | 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 |
}
}
if (count == 0) {
pc->p++;
pc->len--;
}
else if (paren) {
paren++;
pc->len += (pc->p - paren);
pc->p = paren;
}
#ifndef EXPRSUGAR_BRACKET
if (*pc->tstart == '(') {
pc->tt = JIM_TT_EXPRSUGAR;
|
| ︙ | ︙ | |||
7442 7443 7444 7445 7446 7447 7448 |
return JIM_OK;
}
static int JimParseStr(struct JimParserCtx *pc)
{
if (pc->tt == JIM_TT_SEP || pc->tt == JIM_TT_EOL ||
pc->tt == JIM_TT_NONE || pc->tt == JIM_TT_STR) {
| | | | 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 |
return JIM_OK;
}
static int JimParseStr(struct JimParserCtx *pc)
{
if (pc->tt == JIM_TT_SEP || pc->tt == JIM_TT_EOL ||
pc->tt == JIM_TT_NONE || pc->tt == JIM_TT_STR) {
if (*pc->p == '{') {
return JimParseBrace(pc);
}
if (*pc->p == '"') {
pc->inquote = 1;
pc->p++;
pc->len--;
pc->missing.line = pc->tline;
}
}
pc->tstart = pc->p;
pc->tline = pc->linenr;
while (1) {
if (pc->len == 0) {
|
| ︙ | ︙ | |||
7480 7481 7482 7483 7484 7485 7486 |
if (*(pc->p + 1) == '\n') {
pc->linenr++;
}
pc->p++;
pc->len--;
}
else if (pc->len == 1) {
| | | | | | | 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 |
if (*(pc->p + 1) == '\n') {
pc->linenr++;
}
pc->p++;
pc->len--;
}
else if (pc->len == 1) {
pc->missing.ch = '\\';
}
break;
case '(':
if (pc->len > 1 && pc->p[1] != '$') {
break;
}
case ')':
if (*pc->p == '(' || pc->tt == JIM_TT_VAR) {
if (pc->p == pc->tstart) {
pc->p++;
pc->len--;
}
pc->tend = pc->p - 1;
pc->tt = JIM_TT_ESC;
return JIM_OK;
}
|
| ︙ | ︙ | |||
7538 7539 7540 7541 7542 7543 7544 |
return JIM_OK;
}
break;
}
pc->p++;
pc->len--;
}
| | | 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 |
return JIM_OK;
}
break;
}
pc->p++;
pc->len--;
}
return JIM_OK;
}
static int JimParseComment(struct JimParserCtx *pc)
{
while (*pc->p) {
if (*pc->p == '\\') {
pc->p++;
|
| ︙ | ︙ | |||
7649 7650 7651 7652 7653 7654 7655 |
for (k = 0; k < maxchars; k++) {
int c = xdigitval(s[i + k + 1]);
if (c == -1) {
break;
}
val = (val << 4) | c;
}
| | | | | | | | | 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 |
for (k = 0; k < maxchars; k++) {
int c = xdigitval(s[i + k + 1]);
if (c == -1) {
break;
}
val = (val << 4) | c;
}
if (s[i] == '{') {
if (k == 0 || val > 0x1fffff || s[i + k + 1] != '}') {
i--;
k = 0;
}
else {
k++;
}
}
if (k) {
if (s[i] == 'x') {
*p++ = val;
}
else {
p += utf8_fromunicode(p, val);
}
i += k;
break;
}
*p++ = s[i];
}
break;
case 'v':
*p++ = 0xb;
i++;
break;
case '\0':
*p++ = '\\';
i++;
break;
case '\n':
*p++ = ' ';
do {
i++;
} while (s[i + 1] == ' ' || s[i + 1] == '\t');
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{
int val = 0;
int c = odigitval(s[i + 1]);
val = c;
c = odigitval(s[i + 2]);
if (c == -1) {
|
| ︙ | ︙ | |||
7756 7757 7758 7759 7760 7761 7762 |
token = Jim_Alloc(1);
token[0] = '\0';
}
else {
len = (end - start) + 1;
token = Jim_Alloc(len + 1);
if (pc->tt != JIM_TT_ESC) {
| | | | 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 |
token = Jim_Alloc(1);
token[0] = '\0';
}
else {
len = (end - start) + 1;
token = Jim_Alloc(len + 1);
if (pc->tt != JIM_TT_ESC) {
memcpy(token, start, len);
token[len] = '\0';
}
else {
len = JimEscape(token, start, len);
}
}
return Jim_NewStringObjNoAlloc(interp, token, len);
}
|
| ︙ | ︙ | |||
7829 7830 7831 7832 7833 7834 7835 |
pc->tt = JIM_TT_STR;
while (pc->len) {
switch (*pc->p) {
case '\\':
pc->tt = JIM_TT_ESC;
if (--pc->len == 0) {
| | | 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 |
pc->tt = JIM_TT_STR;
while (pc->len) {
switch (*pc->p) {
case '\\':
pc->tt = JIM_TT_ESC;
if (--pc->len == 0) {
pc->tend = pc->p;
return JIM_OK;
}
pc->p++;
break;
case '\n':
pc->linenr++;
|
| ︙ | ︙ | |||
7865 7866 7867 7868 7869 7870 7871 |
while (pc->len) {
if (isspace(UCHAR(*pc->p))) {
pc->tend = pc->p - 1;
return JIM_OK;
}
if (*pc->p == '\\') {
if (--pc->len == 0) {
| | | | | | | | | | | | 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 |
while (pc->len) {
if (isspace(UCHAR(*pc->p))) {
pc->tend = pc->p - 1;
return JIM_OK;
}
if (*pc->p == '\\') {
if (--pc->len == 0) {
pc->tend = pc->p;
return JIM_OK;
}
pc->tt = JIM_TT_ESC;
pc->p++;
}
pc->p++;
pc->len--;
}
pc->tend = pc->p - 1;
return JIM_OK;
}
Jim_Obj *Jim_NewObj(Jim_Interp *interp)
{
Jim_Obj *objPtr;
if (interp->freeList != NULL) {
objPtr = interp->freeList;
interp->freeList = objPtr->nextObjPtr;
}
else {
objPtr = Jim_Alloc(sizeof(*objPtr));
}
objPtr->refCount = 0;
objPtr->prevObjPtr = NULL;
objPtr->nextObjPtr = interp->liveList;
if (interp->liveList)
interp->liveList->prevObjPtr = objPtr;
interp->liveList = objPtr;
return objPtr;
}
void Jim_FreeObj(Jim_Interp *interp, Jim_Obj *objPtr)
{
JimPanic((objPtr->refCount != 0, "!!!Object %p freed with bad refcount %d, type=%s", objPtr,
objPtr->refCount, objPtr->typePtr ? objPtr->typePtr->name : "<none>"));
Jim_FreeIntRep(interp, objPtr);
if (objPtr->bytes != NULL) {
if (objPtr->bytes != JimEmptyStringRep)
Jim_Free(objPtr->bytes);
}
if (objPtr->prevObjPtr)
objPtr->prevObjPtr->nextObjPtr = objPtr->nextObjPtr;
if (objPtr->nextObjPtr)
objPtr->nextObjPtr->prevObjPtr = objPtr->prevObjPtr;
if (interp->liveList == objPtr)
interp->liveList = objPtr->nextObjPtr;
#ifdef JIM_DISABLE_OBJECT_POOL
Jim_Free(objPtr);
#else
objPtr->prevObjPtr = NULL;
objPtr->nextObjPtr = interp->freeList;
if (interp->freeList)
interp->freeList->prevObjPtr = objPtr;
interp->freeList = objPtr;
objPtr->refCount = -1;
#endif
|
| ︙ | ︙ | |||
7958 7959 7960 7961 7962 7963 7964 |
Jim_Obj *Jim_DuplicateObj(Jim_Interp *interp, Jim_Obj *objPtr)
{
Jim_Obj *dupPtr;
dupPtr = Jim_NewObj(interp);
if (objPtr->bytes == NULL) {
| | | | | | | | | | 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 |
Jim_Obj *Jim_DuplicateObj(Jim_Interp *interp, Jim_Obj *objPtr)
{
Jim_Obj *dupPtr;
dupPtr = Jim_NewObj(interp);
if (objPtr->bytes == NULL) {
dupPtr->bytes = NULL;
}
else if (objPtr->length == 0) {
dupPtr->bytes = JimEmptyStringRep;
dupPtr->length = 0;
dupPtr->typePtr = NULL;
return dupPtr;
}
else {
dupPtr->bytes = Jim_Alloc(objPtr->length + 1);
dupPtr->length = objPtr->length;
memcpy(dupPtr->bytes, objPtr->bytes, objPtr->length + 1);
}
dupPtr->typePtr = objPtr->typePtr;
if (objPtr->typePtr != NULL) {
if (objPtr->typePtr->dupIntRepProc == NULL) {
dupPtr->internalRep = objPtr->internalRep;
}
else {
objPtr->typePtr->dupIntRepProc(interp, objPtr, dupPtr);
}
}
return dupPtr;
}
const char *Jim_GetString(Jim_Obj *objPtr, int *lenPtr)
{
if (objPtr->bytes == NULL) {
JimPanic((objPtr->typePtr->updateStringProc == NULL, "UpdateStringProc called against '%s' type.", objPtr->typePtr->name));
objPtr->typePtr->updateStringProc(objPtr);
}
if (lenPtr)
*lenPtr = objPtr->length;
return objPtr->bytes;
}
int Jim_Length(Jim_Obj *objPtr)
{
if (objPtr->bytes == NULL) {
JimPanic((objPtr->typePtr->updateStringProc == NULL, "UpdateStringProc called against '%s' type.", objPtr->typePtr->name));
objPtr->typePtr->updateStringProc(objPtr);
}
return objPtr->length;
}
const char *Jim_String(Jim_Obj *objPtr)
{
if (objPtr->bytes == NULL) {
JimPanic((objPtr->typePtr == NULL, "UpdateStringProc called against typeless value."));
JimPanic((objPtr->typePtr->updateStringProc == NULL, "UpdateStringProc called against '%s' type.", objPtr->typePtr->name));
objPtr->typePtr->updateStringProc(objPtr);
}
return objPtr->bytes;
}
|
| ︙ | ︙ | |||
8076 8077 8078 8079 8080 8081 8082 |
dupPtr->internalRep.strValue.maxLength = srcPtr->length;
dupPtr->internalRep.strValue.charLength = srcPtr->internalRep.strValue.charLength;
}
static int SetStringFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
if (objPtr->typePtr != &stringObjType) {
| | | | | | | 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 |
dupPtr->internalRep.strValue.maxLength = srcPtr->length;
dupPtr->internalRep.strValue.charLength = srcPtr->internalRep.strValue.charLength;
}
static int SetStringFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
if (objPtr->typePtr != &stringObjType) {
if (objPtr->bytes == NULL) {
JimPanic((objPtr->typePtr->updateStringProc == NULL, "UpdateStringProc called against '%s' type.", objPtr->typePtr->name));
objPtr->typePtr->updateStringProc(objPtr);
}
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &stringObjType;
objPtr->internalRep.strValue.maxLength = objPtr->length;
objPtr->internalRep.strValue.charLength = -1;
}
return JIM_OK;
}
int Jim_Utf8Length(Jim_Interp *interp, Jim_Obj *objPtr)
{
|
| ︙ | ︙ | |||
8112 8113 8114 8115 8116 8117 8118 |
}
Jim_Obj *Jim_NewStringObj(Jim_Interp *interp, const char *s, int len)
{
Jim_Obj *objPtr = Jim_NewObj(interp);
| | | | | | | 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 |
}
Jim_Obj *Jim_NewStringObj(Jim_Interp *interp, const char *s, int len)
{
Jim_Obj *objPtr = Jim_NewObj(interp);
if (len == -1)
len = strlen(s);
if (len == 0) {
objPtr->bytes = JimEmptyStringRep;
}
else {
objPtr->bytes = Jim_Alloc(len + 1);
memcpy(objPtr->bytes, s, len);
objPtr->bytes[len] = '\0';
}
objPtr->length = len;
objPtr->typePtr = NULL;
return objPtr;
}
Jim_Obj *Jim_NewStringObjUtf8(Jim_Interp *interp, const char *s, int charlen)
{
#ifdef JIM_UTF8
int bytelen = utf8_index(s, charlen);
Jim_Obj *objPtr = Jim_NewStringObj(interp, s, bytelen);
objPtr->typePtr = &stringObjType;
objPtr->internalRep.strValue.maxLength = bytelen;
objPtr->internalRep.strValue.charLength = charlen;
return objPtr;
#else
return Jim_NewStringObj(interp, s, charlen);
|
| ︙ | ︙ | |||
8171 8172 8173 8174 8175 8176 8177 |
if (len == -1)
len = strlen(str);
needlen = objPtr->length + len;
if (objPtr->internalRep.strValue.maxLength < needlen ||
objPtr->internalRep.strValue.maxLength == 0) {
needlen *= 2;
| | | | 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 |
if (len == -1)
len = strlen(str);
needlen = objPtr->length + len;
if (objPtr->internalRep.strValue.maxLength < needlen ||
objPtr->internalRep.strValue.maxLength == 0) {
needlen *= 2;
if (needlen < 7) {
needlen = 7;
}
if (objPtr->bytes == JimEmptyStringRep) {
objPtr->bytes = Jim_Alloc(needlen + 1);
}
else {
objPtr->bytes = Jim_Realloc(objPtr->bytes, needlen + 1);
}
objPtr->internalRep.strValue.maxLength = needlen;
}
memcpy(objPtr->bytes + objPtr->length, str, len);
objPtr->bytes[objPtr->length + len] = '\0';
if (objPtr->internalRep.strValue.charLength >= 0) {
objPtr->internalRep.strValue.charLength += utf8_strlen(objPtr->bytes + objPtr->length, len);
}
objPtr->length += len;
}
void Jim_AppendString(Jim_Interp *interp, Jim_Obj *objPtr, const char *str, int len)
{
|
| ︙ | ︙ | |||
8249 8250 8251 8252 8253 8254 8255 |
int Jim_StringCompareObj(Jim_Interp *interp, Jim_Obj *firstObjPtr, Jim_Obj *secondObjPtr, int nocase)
{
int l1, l2;
const char *s1 = Jim_GetString(firstObjPtr, &l1);
const char *s2 = Jim_GetString(secondObjPtr, &l2);
if (nocase) {
| | | 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 |
int Jim_StringCompareObj(Jim_Interp *interp, Jim_Obj *firstObjPtr, Jim_Obj *secondObjPtr, int nocase)
{
int l1, l2;
const char *s1 = Jim_GetString(firstObjPtr, &l1);
const char *s2 = Jim_GetString(secondObjPtr, &l2);
if (nocase) {
return JimStringCompareLen(s1, s2, -1, nocase);
}
return JimStringCompare(s1, l1, s2, l2);
}
int Jim_StringCompareLenObj(Jim_Interp *interp, Jim_Obj *firstObjPtr, Jim_Obj *secondObjPtr, int nocase)
{
|
| ︙ | ︙ | |||
8351 8352 8353 8354 8355 8356 8357 |
return NULL;
}
if (first == 0 && rangeLen == len) {
return strObjPtr;
}
if (len == bytelen) {
| | | 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 |
return NULL;
}
if (first == 0 && rangeLen == len) {
return strObjPtr;
}
if (len == bytelen) {
return Jim_NewStringObj(interp, str + first, rangeLen);
}
return Jim_NewStringObjUtf8(interp, str + utf8_index(str, first), rangeLen);
#else
return Jim_StringByteRangeObj(interp, strObjPtr, firstObjPtr, lastObjPtr);
#endif
}
|
| ︙ | ︙ | |||
8380 8381 8382 8383 8384 8385 8386 |
if (last < first) {
return strObjPtr;
}
str = Jim_String(strObjPtr);
| | | | | 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 |
if (last < first) {
return strObjPtr;
}
str = Jim_String(strObjPtr);
objPtr = Jim_NewStringObjUtf8(interp, str, first);
if (newStrObj) {
Jim_AppendObj(interp, objPtr, newStrObj);
}
Jim_AppendString(interp, objPtr, str + utf8_index(str, last + 1), len - last - 1);
return objPtr;
}
static void JimStrCopyUpperLower(char *dest, const char *str, int uc)
{
|
| ︙ | ︙ | |||
8491 8492 8493 8494 8495 8496 8497 |
static const char *JimFindTrimLeft(const char *str, int len, const char *trimchars, int trimlen)
{
while (len) {
int c;
int n = utf8_tounicode(str, &c);
if (utf8_memchr(trimchars, trimlen, c) == NULL) {
| | | 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 |
static const char *JimFindTrimLeft(const char *str, int len, const char *trimchars, int trimlen)
{
while (len) {
int c;
int n = utf8_tounicode(str, &c);
if (utf8_memchr(trimchars, trimlen, c) == NULL) {
break;
}
str += n;
len -= n;
}
return str;
}
|
| ︙ | ︙ | |||
8562 8563 8564 8565 8566 8567 8568 |
SetStringFromAny(interp, strObjPtr);
len = Jim_Length(strObjPtr);
nontrim = JimFindTrimRight(strObjPtr->bytes, len, trimchars, trimcharslen);
if (nontrim == NULL) {
| | | | | | | | | 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 |
SetStringFromAny(interp, strObjPtr);
len = Jim_Length(strObjPtr);
nontrim = JimFindTrimRight(strObjPtr->bytes, len, trimchars, trimcharslen);
if (nontrim == NULL) {
return Jim_NewEmptyStringObj(interp);
}
if (nontrim == strObjPtr->bytes + len) {
return strObjPtr;
}
if (Jim_IsShared(strObjPtr)) {
strObjPtr = Jim_NewStringObj(interp, strObjPtr->bytes, (nontrim - strObjPtr->bytes));
}
else {
strObjPtr->bytes[nontrim - strObjPtr->bytes] = 0;
strObjPtr->length = (nontrim - strObjPtr->bytes);
}
return strObjPtr;
}
static Jim_Obj *JimStringTrim(Jim_Interp *interp, Jim_Obj *strObjPtr, Jim_Obj *trimcharsObjPtr)
{
Jim_Obj *objPtr = JimStringTrimLeft(interp, strObjPtr, trimcharsObjPtr);
strObjPtr = JimStringTrimRight(interp, objPtr, trimcharsObjPtr);
if (objPtr != strObjPtr && objPtr->refCount == 0) {
Jim_FreeNewObj(interp, objPtr);
}
return strObjPtr;
}
|
| ︙ | ︙ | |||
8614 8615 8616 8617 8618 8619 8620 |
#endif
static int JimStringIs(Jim_Interp *interp, Jim_Obj *strObjPtr, Jim_Obj *strClass, int strict)
{
static const char * const strclassnames[] = {
"integer", "alpha", "alnum", "ascii", "digit",
"double", "lower", "upper", "space", "xdigit",
| | | | 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 |
#endif
static int JimStringIs(Jim_Interp *interp, Jim_Obj *strObjPtr, Jim_Obj *strClass, int strict)
{
static const char * const strclassnames[] = {
"integer", "alpha", "alnum", "ascii", "digit",
"double", "lower", "upper", "space", "xdigit",
"control", "print", "graph", "punct",
NULL
};
enum {
STR_IS_INTEGER, STR_IS_ALPHA, STR_IS_ALNUM, STR_IS_ASCII, STR_IS_DIGIT,
STR_IS_DOUBLE, STR_IS_LOWER, STR_IS_UPPER, STR_IS_SPACE, STR_IS_XDIGIT,
STR_IS_CONTROL, STR_IS_PRINT, STR_IS_GRAPH, STR_IS_PUNCT
};
int strclass;
int len;
int i;
const char *str;
int (*isclassfunc)(int c) = NULL;
|
| ︙ | ︙ | |||
8653 8654 8655 8656 8657 8658 8659 |
case STR_IS_DOUBLE:
{
double d;
Jim_SetResultBool(interp, Jim_GetDouble(interp, strObjPtr, &d) == JIM_OK && errno != ERANGE);
return JIM_OK;
}
| < < < < < < < | 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 |
case STR_IS_DOUBLE:
{
double d;
Jim_SetResultBool(interp, Jim_GetDouble(interp, strObjPtr, &d) == JIM_OK && errno != ERANGE);
return JIM_OK;
}
case STR_IS_ALPHA: isclassfunc = isalpha; break;
case STR_IS_ALNUM: isclassfunc = isalnum; break;
case STR_IS_ASCII: isclassfunc = jim_isascii; break;
case STR_IS_DIGIT: isclassfunc = isdigit; break;
case STR_IS_LOWER: isclassfunc = islower; break;
case STR_IS_UPPER: isclassfunc = isupper; break;
case STR_IS_SPACE: isclassfunc = isspace; break;
|
| ︙ | ︙ | |||
8711 8712 8713 8714 8715 8716 8717 |
if (strcmp(str, objStr) != 0)
return 0;
if (objPtr->typePtr != &comparedStringObjType) {
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &comparedStringObjType;
}
| | | 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 |
if (strcmp(str, objStr) != 0)
return 0;
if (objPtr->typePtr != &comparedStringObjType) {
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &comparedStringObjType;
}
objPtr->internalRep.ptr = (char *)str;
return 1;
}
}
static int qsortCompareStringPointers(const void *a, const void *b)
{
char *const *sa = (char *const *)a;
|
| ︙ | ︙ | |||
8804 8805 8806 8807 8808 8809 8810 |
{
Jim_Obj *objPtr;
int type;
} ScriptToken;
typedef struct ScriptObj
{
| | | | | | | | | 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 |
{
Jim_Obj *objPtr;
int type;
} ScriptToken;
typedef struct ScriptObj
{
ScriptToken *token;
Jim_Obj *fileNameObj;
int len;
int substFlags;
int inUse; /* Used to share a ScriptObj. Currently
only used by Jim_EvalObj() as protection against
shimmering of the currently evaluated object. */
int firstline;
int linenr;
int missing;
} ScriptObj;
static void JimSetScriptFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr);
static int JimParseCheckMissing(Jim_Interp *interp, int ch);
static ScriptObj *JimGetScript(Jim_Interp *interp, Jim_Obj *objPtr);
void FreeScriptInternalRep(Jim_Interp *interp, Jim_Obj *objPtr)
|
| ︙ | ︙ | |||
8845 8846 8847 8848 8849 8850 8851 |
JIM_NOTUSED(srcPtr);
dupPtr->typePtr = NULL;
}
typedef struct
{
| | | | | | | | | | | 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 |
JIM_NOTUSED(srcPtr);
dupPtr->typePtr = NULL;
}
typedef struct
{
const char *token;
int len;
int type;
int line;
} ParseToken;
typedef struct
{
ParseToken *list;
int size;
int count;
ParseToken static_list[20];
} ParseTokenList;
static void ScriptTokenListInit(ParseTokenList *tokenlist)
{
tokenlist->list = tokenlist->static_list;
tokenlist->size = sizeof(tokenlist->static_list) / sizeof(ParseToken);
tokenlist->count = 0;
|
| ︙ | ︙ | |||
8880 8881 8882 8883 8884 8885 8886 |
static void ScriptAddToken(ParseTokenList *tokenlist, const char *token, int len, int type,
int line)
{
ParseToken *t;
if (tokenlist->count == tokenlist->size) {
| | | | | | | | | | | | | | | | | | | | 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 |
static void ScriptAddToken(ParseTokenList *tokenlist, const char *token, int len, int type,
int line)
{
ParseToken *t;
if (tokenlist->count == tokenlist->size) {
tokenlist->size *= 2;
if (tokenlist->list != tokenlist->static_list) {
tokenlist->list =
Jim_Realloc(tokenlist->list, tokenlist->size * sizeof(*tokenlist->list));
}
else {
tokenlist->list = Jim_Alloc(tokenlist->size * sizeof(*tokenlist->list));
memcpy(tokenlist->list, tokenlist->static_list,
tokenlist->count * sizeof(*tokenlist->list));
}
}
t = &tokenlist->list[tokenlist->count++];
t->token = token;
t->len = len;
t->type = type;
t->line = line;
}
static int JimCountWordTokens(ParseToken *t)
{
int expand = 1;
int count = 0;
if (t->type == JIM_TT_STR && !TOKEN_IS_SEP(t[1].type)) {
if ((t->len == 1 && *t->token == '*') || (t->len == 6 && strncmp(t->token, "expand", 6) == 0)) {
expand = -1;
t++;
}
}
while (!TOKEN_IS_SEP(t->type)) {
t++;
count++;
}
return count * expand;
}
static Jim_Obj *JimMakeScriptObj(Jim_Interp *interp, const ParseToken *t)
{
Jim_Obj *objPtr;
if (t->type == JIM_TT_ESC && memchr(t->token, '\\', t->len) != NULL) {
int len = t->len;
char *str = Jim_Alloc(len + 1);
len = JimEscape(str, t->token, len);
objPtr = Jim_NewStringObjNoAlloc(interp, str, len);
}
else {
objPtr = Jim_NewStringObj(interp, t->token, t->len);
}
return objPtr;
}
static void ScriptObjAddTokens(Jim_Interp *interp, struct ScriptObj *script,
ParseTokenList *tokenlist)
{
int i;
struct ScriptToken *token;
int lineargs = 0;
ScriptToken *linefirst;
int count;
int linenr;
#ifdef DEBUG_SHOW_SCRIPT_TOKENS
printf("==== Tokens ====\n");
for (i = 0; i < tokenlist->count; i++) {
printf("[%2d]@%d %s '%.*s'\n", i, tokenlist->list[i].line, jim_tt_name(tokenlist->list[i].type),
tokenlist->list[i].len, tokenlist->list[i].token);
}
#endif
count = tokenlist->count;
for (i = 0; i < tokenlist->count; i++) {
if (tokenlist->list[i].type == JIM_TT_EOL) {
count++;
}
}
linenr = script->firstline = tokenlist->list[0].line;
token = script->token = Jim_Alloc(sizeof(ScriptToken) * count);
linefirst = token++;
for (i = 0; i < tokenlist->count; ) {
int wordtokens;
while (tokenlist->list[i].type == JIM_TT_SEP) {
i++;
}
wordtokens = JimCountWordTokens(tokenlist->list + i);
if (wordtokens == 0) {
if (lineargs) {
linefirst->type = JIM_TT_LINE;
linefirst->objPtr = JimNewScriptLineObj(interp, lineargs, linenr);
Jim_IncrRefCount(linefirst->objPtr);
lineargs = 0;
linefirst = token++;
}
i++;
continue;
}
else if (wordtokens != 1) {
token->type = JIM_TT_WORD;
token->objPtr = Jim_NewIntObj(interp, wordtokens);
Jim_IncrRefCount(token->objPtr);
token++;
if (wordtokens < 0) {
i++;
wordtokens = -wordtokens - 1;
lineargs--;
}
}
if (lineargs == 0) {
linenr = tokenlist->list[i].line;
}
lineargs++;
while (wordtokens--) {
const ParseToken *t = &tokenlist->list[i++];
token->type = t->type;
token->objPtr = JimMakeScriptObj(interp, t);
Jim_IncrRefCount(token->objPtr);
|
| ︙ | ︙ | |||
9095 9096 9097 9098 9099 9100 9101 |
struct ScriptToken *token;
token = script->token = Jim_Alloc(sizeof(ScriptToken) * tokenlist->count);
for (i = 0; i < tokenlist->count; i++) {
const ParseToken *t = &tokenlist->list[i];
| | | | | | | | | | 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 |
struct ScriptToken *token;
token = script->token = Jim_Alloc(sizeof(ScriptToken) * tokenlist->count);
for (i = 0; i < tokenlist->count; i++) {
const ParseToken *t = &tokenlist->list[i];
token->type = t->type;
token->objPtr = JimMakeScriptObj(interp, t);
Jim_IncrRefCount(token->objPtr);
token++;
}
script->len = i;
}
static void JimSetScriptFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr)
{
int scriptTextLen;
const char *scriptText = Jim_GetString(objPtr, &scriptTextLen);
struct JimParserCtx parser;
struct ScriptObj *script;
ParseTokenList tokenlist;
int line = 1;
if (objPtr->typePtr == &sourceObjType) {
line = objPtr->internalRep.sourceValue.lineNumber;
}
ScriptTokenListInit(&tokenlist);
JimParserInit(&parser, scriptText, scriptTextLen, line);
while (!parser.eof) {
JimParseScript(&parser);
ScriptAddToken(&tokenlist, parser.tstart, parser.tend - parser.tstart + 1, parser.tt,
parser.tline);
}
ScriptAddToken(&tokenlist, scriptText + scriptTextLen, 0, JIM_TT_EOF, 0);
script = Jim_Alloc(sizeof(*script));
memset(script, 0, sizeof(*script));
script->inUse = 1;
if (objPtr->typePtr == &sourceObjType) {
script->fileNameObj = objPtr->internalRep.sourceValue.fileNameObj;
}
else {
script->fileNameObj = interp->emptyObj;
}
Jim_IncrRefCount(script->fileNameObj);
script->missing = parser.missing.ch;
script->linenr = parser.missing.line;
ScriptObjAddTokens(interp, script, &tokenlist);
ScriptTokenListFree(&tokenlist);
Jim_FreeIntRep(interp, objPtr);
Jim_SetIntRepPtr(objPtr, script);
objPtr->typePtr = &scriptObjType;
}
static void JimAddErrorToStack(Jim_Interp *interp, ScriptObj *script);
static ScriptObj *JimGetScript(Jim_Interp *interp, Jim_Obj *objPtr)
{
if (objPtr == interp->emptyObj) {
objPtr = interp->nullScriptObj;
}
if (objPtr->typePtr != &scriptObjType || ((struct ScriptObj *)Jim_GetIntRepPtr(objPtr))->substFlags) {
JimSetScriptFromAny(interp, objPtr);
}
|
| ︙ | ︙ | |||
9201 9202 9203 9204 9205 9206 9207 |
Jim_DecrRefCount(interp, cmdPtr->u.proc.nsObj);
if (cmdPtr->u.proc.staticVars) {
Jim_FreeHashTable(cmdPtr->u.proc.staticVars);
Jim_Free(cmdPtr->u.proc.staticVars);
}
}
else {
| | | | | | | | | | | | | | | | | | 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 |
Jim_DecrRefCount(interp, cmdPtr->u.proc.nsObj);
if (cmdPtr->u.proc.staticVars) {
Jim_FreeHashTable(cmdPtr->u.proc.staticVars);
Jim_Free(cmdPtr->u.proc.staticVars);
}
}
else {
if (cmdPtr->u.native.delProc) {
cmdPtr->u.native.delProc(interp, cmdPtr->u.native.privData);
}
}
if (cmdPtr->prevCmd) {
JimDecrCmdRefCount(interp, cmdPtr->prevCmd);
}
Jim_Free(cmdPtr);
}
}
static void JimVariablesHTValDestructor(void *interp, void *val)
{
Jim_DecrRefCount(interp, ((Jim_Var *)val)->objPtr);
Jim_Free(val);
}
static const Jim_HashTableType JimVariablesHashTableType = {
JimStringCopyHTHashFunction,
JimStringCopyHTDup,
NULL,
JimStringCopyHTKeyCompare,
JimStringCopyHTKeyDestructor,
JimVariablesHTValDestructor
};
static void JimCommandsHT_ValDestructor(void *interp, void *val)
{
JimDecrCmdRefCount(interp, val);
}
static const Jim_HashTableType JimCommandsHashTableType = {
JimStringCopyHTHashFunction,
JimStringCopyHTDup,
NULL,
JimStringCopyHTKeyCompare,
JimStringCopyHTKeyDestructor,
JimCommandsHT_ValDestructor
};
#ifdef jim_ext_namespace
static Jim_Obj *JimQualifyNameObj(Jim_Interp *interp, Jim_Obj *nsObj)
{
const char *name = Jim_String(nsObj);
if (name[0] == ':' && name[1] == ':') {
while (*++name == ':') {
}
nsObj = Jim_NewStringObj(interp, name, -1);
}
else if (Jim_Length(interp->framePtr->nsObj)) {
nsObj = Jim_DuplicateObj(interp, interp->framePtr->nsObj);
Jim_AppendStrings(interp, nsObj, "::", name, NULL);
}
return nsObj;
}
Jim_Obj *Jim_MakeGlobalNamespaceName(Jim_Interp *interp, Jim_Obj *nameObjPtr)
|
| ︙ | ︙ | |||
9285 9286 9287 9288 9289 9290 9291 |
}
static const char *JimQualifyName(Jim_Interp *interp, const char *name, Jim_Obj **objPtrPtr)
{
Jim_Obj *objPtr = interp->emptyObj;
if (name[0] == ':' && name[1] == ':') {
| | | | | | | | 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 |
}
static const char *JimQualifyName(Jim_Interp *interp, const char *name, Jim_Obj **objPtrPtr)
{
Jim_Obj *objPtr = interp->emptyObj;
if (name[0] == ':' && name[1] == ':') {
while (*++name == ':') {
}
}
else if (Jim_Length(interp->framePtr->nsObj)) {
objPtr = Jim_DuplicateObj(interp, interp->framePtr->nsObj);
Jim_AppendStrings(interp, objPtr, "::", name, NULL);
name = Jim_String(objPtr);
}
Jim_IncrRefCount(objPtr);
*objPtrPtr = objPtr;
return name;
}
#define JimFreeQualifiedName(INTERP, OBJ) Jim_DecrRefCount((INTERP), (OBJ))
#else
#define JimQualifyName(INTERP, NAME, DUMMY) (((NAME)[0] == ':' && (NAME)[1] == ':') ? (NAME) + 2 : (NAME))
#define JimFreeQualifiedName(INTERP, DUMMY) (void)(DUMMY)
Jim_Obj *Jim_MakeGlobalNamespaceName(Jim_Interp *interp, Jim_Obj *nameObjPtr)
{
return nameObjPtr;
}
#endif
static int JimCreateCommand(Jim_Interp *interp, const char *name, Jim_Cmd *cmd)
{
Jim_HashEntry *he = Jim_FindHashEntry(&interp->commands, name);
if (he) {
Jim_InterpIncrProcEpoch(interp);
}
if (he && interp->local) {
cmd->prevCmd = Jim_GetHashEntryVal(he);
Jim_SetHashVal(&interp->commands, he, cmd);
}
else {
if (he) {
Jim_DeleteHashEntry(&interp->commands, name);
}
Jim_AddHashEntry(&interp->commands, name, cmd);
}
return JIM_OK;
}
int Jim_CreateCommand(Jim_Interp *interp, const char *cmdNameStr,
Jim_CmdProc *cmdProc, void *privData, Jim_DelCmdProc *delProc)
{
Jim_Cmd *cmdPtr = Jim_Alloc(sizeof(*cmdPtr));
memset(cmdPtr, 0, sizeof(*cmdPtr));
cmdPtr->inUse = 1;
cmdPtr->u.native.delProc = delProc;
cmdPtr->u.native.cmdProc = cmdProc;
cmdPtr->u.native.privData = privData;
JimCreateCommand(interp, cmdNameStr, cmdPtr);
|
| ︙ | ︙ | |||
9372 9373 9374 9375 9376 9377 9378 |
Jim_InitHashTable(cmdPtr->u.proc.staticVars, &JimVariablesHashTableType, interp);
for (i = 0; i < len; i++) {
Jim_Obj *objPtr, *initObjPtr, *nameObjPtr;
Jim_Var *varPtr;
int subLen;
objPtr = Jim_ListGetIndex(interp, staticsListObjPtr, i);
| | | 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 |
Jim_InitHashTable(cmdPtr->u.proc.staticVars, &JimVariablesHashTableType, interp);
for (i = 0; i < len; i++) {
Jim_Obj *objPtr, *initObjPtr, *nameObjPtr;
Jim_Var *varPtr;
int subLen;
objPtr = Jim_ListGetIndex(interp, staticsListObjPtr, i);
subLen = Jim_ListLength(interp, objPtr);
if (subLen == 1 || subLen == 2) {
nameObjPtr = Jim_ListGetIndex(interp, objPtr, 0);
if (subLen == 1) {
initObjPtr = Jim_GetVariable(interp, nameObjPtr, JIM_NONE);
if (initObjPtr == NULL) {
Jim_SetResultFormatted(interp,
|
| ︙ | ︙ | |||
9418 9419 9420 9421 9422 9423 9424 |
return JIM_OK;
}
static void JimUpdateProcNamespace(Jim_Interp *interp, Jim_Cmd *cmdPtr, const char *cmdname)
{
#ifdef jim_ext_namespace
if (cmdPtr->isproc) {
| | | | | | | | | | | 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 |
return JIM_OK;
}
static void JimUpdateProcNamespace(Jim_Interp *interp, Jim_Cmd *cmdPtr, const char *cmdname)
{
#ifdef jim_ext_namespace
if (cmdPtr->isproc) {
const char *pt = strrchr(cmdname, ':');
if (pt && pt != cmdname && pt[-1] == ':') {
Jim_DecrRefCount(interp, cmdPtr->u.proc.nsObj);
cmdPtr->u.proc.nsObj = Jim_NewStringObj(interp, cmdname, pt - cmdname - 1);
Jim_IncrRefCount(cmdPtr->u.proc.nsObj);
if (Jim_FindHashEntry(&interp->commands, pt + 1)) {
Jim_InterpIncrProcEpoch(interp);
}
}
}
#endif
}
static Jim_Cmd *JimCreateProcedureCmd(Jim_Interp *interp, Jim_Obj *argListObjPtr,
Jim_Obj *staticsListObjPtr, Jim_Obj *bodyObjPtr, Jim_Obj *nsObj)
{
Jim_Cmd *cmdPtr;
int argListLen;
int i;
argListLen = Jim_ListLength(interp, argListObjPtr);
cmdPtr = Jim_Alloc(sizeof(*cmdPtr) + sizeof(struct Jim_ProcArg) * argListLen);
memset(cmdPtr, 0, sizeof(*cmdPtr));
cmdPtr->inUse = 1;
cmdPtr->isproc = 1;
cmdPtr->u.proc.argListObjPtr = argListObjPtr;
cmdPtr->u.proc.argListLen = argListLen;
cmdPtr->u.proc.bodyObjPtr = bodyObjPtr;
cmdPtr->u.proc.argsPos = -1;
cmdPtr->u.proc.arglist = (struct Jim_ProcArg *)(cmdPtr + 1);
cmdPtr->u.proc.nsObj = nsObj ? nsObj : interp->emptyObj;
Jim_IncrRefCount(argListObjPtr);
Jim_IncrRefCount(bodyObjPtr);
Jim_IncrRefCount(cmdPtr->u.proc.nsObj);
if (staticsListObjPtr && JimCreateProcedureStatics(interp, cmdPtr, staticsListObjPtr) != JIM_OK) {
goto err;
}
for (i = 0; i < argListLen; i++) {
Jim_Obj *argPtr;
Jim_Obj *nameObjPtr;
Jim_Obj *defaultObjPtr;
int len;
argPtr = Jim_ListGetIndex(interp, argListObjPtr, i);
len = Jim_ListLength(interp, argPtr);
if (len == 0) {
Jim_SetResultString(interp, "argument with no name", -1);
err:
JimDecrCmdRefCount(interp, cmdPtr);
return NULL;
}
if (len > 2) {
Jim_SetResultFormatted(interp, "too many fields in argument specifier \"%#s\"", argPtr);
goto err;
}
if (len == 2) {
nameObjPtr = Jim_ListGetIndex(interp, argPtr, 0);
defaultObjPtr = Jim_ListGetIndex(interp, argPtr, 1);
}
else {
nameObjPtr = argPtr;
defaultObjPtr = NULL;
}
if (Jim_CompareStringImmediate(interp, nameObjPtr, "args")) {
if (cmdPtr->u.proc.argsPos >= 0) {
|
| ︙ | ︙ | |||
9556 9557 9558 9559 9560 9561 9562 |
if (newName[0] == 0) {
return Jim_DeleteCommand(interp, oldName);
}
fqold = JimQualifyName(interp, oldName, &qualifiedOldNameObj);
fqnew = JimQualifyName(interp, newName, &qualifiedNewNameObj);
| | | | | | 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 |
if (newName[0] == 0) {
return Jim_DeleteCommand(interp, oldName);
}
fqold = JimQualifyName(interp, oldName, &qualifiedOldNameObj);
fqnew = JimQualifyName(interp, newName, &qualifiedNewNameObj);
he = Jim_FindHashEntry(&interp->commands, fqold);
if (he == NULL) {
Jim_SetResultFormatted(interp, "can't rename \"%s\": command doesn't exist", oldName);
}
else if (Jim_FindHashEntry(&interp->commands, fqnew)) {
Jim_SetResultFormatted(interp, "can't rename to \"%s\": command already exists", newName);
}
else {
cmdPtr = Jim_GetHashEntryVal(he);
JimIncrCmdRefCount(cmdPtr);
JimUpdateProcNamespace(interp, cmdPtr, fqnew);
Jim_AddHashEntry(&interp->commands, fqnew, cmdPtr);
Jim_DeleteHashEntry(&interp->commands, fqold);
Jim_InterpIncrProcEpoch(interp);
ret = JIM_OK;
}
JimFreeQualifiedName(interp, qualifiedOldNameObj);
JimFreeQualifiedName(interp, qualifiedNewNameObj);
|
| ︙ | ︙ | |||
9617 9618 9619 9620 9621 9622 9623 |
if (objPtr->typePtr != &commandObjType ||
objPtr->internalRep.cmdValue.procEpoch != interp->procEpoch
#ifdef jim_ext_namespace
|| !Jim_StringEqObj(objPtr->internalRep.cmdValue.nsObj, interp->framePtr->nsObj)
#endif
) {
| | | | | | | | | | | | | | | | | | | 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 |
if (objPtr->typePtr != &commandObjType ||
objPtr->internalRep.cmdValue.procEpoch != interp->procEpoch
#ifdef jim_ext_namespace
|| !Jim_StringEqObj(objPtr->internalRep.cmdValue.nsObj, interp->framePtr->nsObj)
#endif
) {
const char *name = Jim_String(objPtr);
Jim_HashEntry *he;
if (name[0] == ':' && name[1] == ':') {
while (*++name == ':') {
}
}
#ifdef jim_ext_namespace
else if (Jim_Length(interp->framePtr->nsObj)) {
Jim_Obj *nameObj = Jim_DuplicateObj(interp, interp->framePtr->nsObj);
Jim_AppendStrings(interp, nameObj, "::", name, NULL);
he = Jim_FindHashEntry(&interp->commands, Jim_String(nameObj));
Jim_FreeNewObj(interp, nameObj);
if (he) {
goto found;
}
}
#endif
he = Jim_FindHashEntry(&interp->commands, name);
if (he == NULL) {
if (flags & JIM_ERRMSG) {
Jim_SetResultFormatted(interp, "invalid command name \"%#s\"", objPtr);
}
return NULL;
}
#ifdef jim_ext_namespace
found:
#endif
cmd = Jim_GetHashEntryVal(he);
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &commandObjType;
objPtr->internalRep.cmdValue.procEpoch = interp->procEpoch;
objPtr->internalRep.cmdValue.cmdPtr = cmd;
objPtr->internalRep.cmdValue.nsObj = interp->framePtr->nsObj;
Jim_IncrRefCount(interp->framePtr->nsObj);
}
else {
cmd = objPtr->internalRep.cmdValue.cmdPtr;
}
while (cmd->u.proc.upcall) {
cmd = cmd->prevCmd;
}
return cmd;
}
#define JIM_DICT_SUGAR 100
static int SetVariableFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr);
static const Jim_ObjType variableObjType = {
"variable",
NULL,
NULL,
NULL,
JIM_TYPE_REFERENCES,
};
static int JimValidName(Jim_Interp *interp, const char *type, Jim_Obj *nameObjPtr)
{
if (nameObjPtr->typePtr != &variableObjType) {
int len;
const char *str = Jim_GetString(nameObjPtr, &len);
if (memchr(str, '\0', len)) {
Jim_SetResultFormatted(interp, "%s name contains embedded null", type);
return JIM_ERR;
}
}
return JIM_OK;
}
static int SetVariableFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr)
{
const char *varName;
Jim_CallFrame *framePtr;
Jim_HashEntry *he;
int global;
int len;
if (objPtr->typePtr == &variableObjType) {
framePtr = objPtr->internalRep.varValue.global ? interp->topFramePtr : interp->framePtr;
if (objPtr->internalRep.varValue.callFrameId == framePtr->id) {
return JIM_OK;
}
}
else if (objPtr->typePtr == &dictSubstObjType) {
return JIM_DICT_SUGAR;
}
else if (JimValidName(interp, "variable", objPtr) != JIM_OK) {
return JIM_ERR;
}
varName = Jim_GetString(objPtr, &len);
if (len && varName[len - 1] == ')' && strchr(varName, '(') != NULL) {
return JIM_DICT_SUGAR;
}
if (varName[0] == ':' && varName[1] == ':') {
while (*++varName == ':') {
}
global = 1;
framePtr = interp->topFramePtr;
}
else {
global = 0;
framePtr = interp->framePtr;
}
he = Jim_FindHashEntry(&framePtr->vars, varName);
if (he == NULL) {
if (!global && framePtr->staticVars) {
he = Jim_FindHashEntry(framePtr->staticVars, varName);
}
if (he == NULL) {
return JIM_ERR;
}
}
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &variableObjType;
objPtr->internalRep.varValue.callFrameId = framePtr->id;
objPtr->internalRep.varValue.varPtr = Jim_GetHashEntryVal(he);
objPtr->internalRep.varValue.global = global;
return JIM_OK;
}
static int JimDictSugarSet(Jim_Interp *interp, Jim_Obj *ObjPtr, Jim_Obj *valObjPtr);
static Jim_Obj *JimDictSugarGet(Jim_Interp *interp, Jim_Obj *ObjPtr, int flags);
static Jim_Var *JimCreateVariable(Jim_Interp *interp, Jim_Obj *nameObjPtr, Jim_Obj *valObjPtr)
{
const char *name;
Jim_CallFrame *framePtr;
int global;
Jim_Var *var = Jim_Alloc(sizeof(*var));
var->objPtr = valObjPtr;
Jim_IncrRefCount(valObjPtr);
var->linkFramePtr = NULL;
name = Jim_String(nameObjPtr);
if (name[0] == ':' && name[1] == ':') {
while (*++name == ':') {
}
framePtr = interp->topFramePtr;
global = 1;
}
else {
framePtr = interp->framePtr;
global = 0;
}
Jim_AddHashEntry(&framePtr->vars, name, var);
Jim_FreeIntRep(interp, nameObjPtr);
nameObjPtr->typePtr = &variableObjType;
nameObjPtr->internalRep.varValue.callFrameId = framePtr->id;
nameObjPtr->internalRep.varValue.varPtr = var;
nameObjPtr->internalRep.varValue.global = global;
return var;
|
| ︙ | ︙ | |||
9828 9829 9830 9831 9832 9833 9834 |
case JIM_OK:
var = nameObjPtr->internalRep.varValue.varPtr;
if (var->linkFramePtr == NULL) {
Jim_IncrRefCount(valObjPtr);
Jim_DecrRefCount(interp, var->objPtr);
var->objPtr = valObjPtr;
}
| | | 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 |
case JIM_OK:
var = nameObjPtr->internalRep.varValue.varPtr;
if (var->linkFramePtr == NULL) {
Jim_IncrRefCount(valObjPtr);
Jim_DecrRefCount(interp, var->objPtr);
var->objPtr = valObjPtr;
}
else {
Jim_CallFrame *savedCallFrame;
savedCallFrame = interp->framePtr;
interp->framePtr = var->linkFramePtr;
err = Jim_SetVariable(interp, var->objPtr, valObjPtr);
interp->framePtr = savedCallFrame;
if (err != JIM_OK)
|
| ︙ | ︙ | |||
9889 9890 9891 9892 9893 9894 9895 |
Jim_Obj *targetNameObjPtr, Jim_CallFrame *targetCallFrame)
{
const char *varName;
const char *targetName;
Jim_CallFrame *framePtr;
Jim_Var *varPtr;
| | | | | | | | 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 |
Jim_Obj *targetNameObjPtr, Jim_CallFrame *targetCallFrame)
{
const char *varName;
const char *targetName;
Jim_CallFrame *framePtr;
Jim_Var *varPtr;
switch (SetVariableFromAny(interp, nameObjPtr)) {
case JIM_DICT_SUGAR:
Jim_SetResultFormatted(interp, "bad variable name \"%#s\": upvar won't create a scalar variable that looks like an array element", nameObjPtr);
return JIM_ERR;
case JIM_OK:
varPtr = nameObjPtr->internalRep.varValue.varPtr;
if (varPtr->linkFramePtr == NULL) {
Jim_SetResultFormatted(interp, "variable \"%#s\" already exists", nameObjPtr);
return JIM_ERR;
}
varPtr->linkFramePtr = NULL;
break;
}
varName = Jim_String(nameObjPtr);
if (varName[0] == ':' && varName[1] == ':') {
while (*++varName == ':') {
}
framePtr = interp->topFramePtr;
}
else {
framePtr = interp->framePtr;
}
targetName = Jim_String(targetNameObjPtr);
|
| ︙ | ︙ | |||
9940 9941 9942 9943 9944 9945 9946 |
Jim_SetResultFormatted(interp,
"bad variable name \"%#s\": upvar won't create namespace variable that refers to procedure variable",
nameObjPtr);
Jim_DecrRefCount(interp, targetNameObjPtr);
return JIM_ERR;
}
| | | | | | | | | 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 |
Jim_SetResultFormatted(interp,
"bad variable name \"%#s\": upvar won't create namespace variable that refers to procedure variable",
nameObjPtr);
Jim_DecrRefCount(interp, targetNameObjPtr);
return JIM_ERR;
}
if (framePtr == targetCallFrame) {
Jim_Obj *objPtr = targetNameObjPtr;
while (1) {
if (strcmp(Jim_String(objPtr), varName) == 0) {
Jim_SetResultString(interp, "can't upvar from variable to itself", -1);
Jim_DecrRefCount(interp, targetNameObjPtr);
return JIM_ERR;
}
if (SetVariableFromAny(interp, objPtr) != JIM_OK)
break;
varPtr = objPtr->internalRep.varValue.varPtr;
if (varPtr->linkFramePtr != targetCallFrame)
break;
objPtr = varPtr->objPtr;
}
}
Jim_SetVariable(interp, nameObjPtr, targetNameObjPtr);
nameObjPtr->internalRep.varValue.varPtr->linkFramePtr = targetCallFrame;
Jim_DecrRefCount(interp, targetNameObjPtr);
return JIM_OK;
}
Jim_Obj *Jim_GetVariable(Jim_Interp *interp, Jim_Obj *nameObjPtr, int flags)
{
switch (SetVariableFromAny(interp, nameObjPtr)) {
case JIM_OK:{
Jim_Var *varPtr = nameObjPtr->internalRep.varValue.varPtr;
if (varPtr->linkFramePtr == NULL) {
return varPtr->objPtr;
}
else {
Jim_Obj *objPtr;
Jim_CallFrame *savedCallFrame = interp->framePtr;
interp->framePtr = varPtr->linkFramePtr;
objPtr = Jim_GetVariable(interp, varPtr->objPtr, flags);
interp->framePtr = savedCallFrame;
if (objPtr) {
return objPtr;
}
}
}
break;
case JIM_DICT_SUGAR:
return JimDictSugarGet(interp, nameObjPtr, flags);
}
if (flags & JIM_ERRMSG) {
Jim_SetResultFormatted(interp, "can't read \"%#s\": no such variable", nameObjPtr);
}
return NULL;
}
|
| ︙ | ︙ | |||
10049 10050 10051 10052 10053 10054 10055 |
{
Jim_Var *varPtr;
int retval;
Jim_CallFrame *framePtr;
retval = SetVariableFromAny(interp, nameObjPtr);
if (retval == JIM_DICT_SUGAR) {
| | | | | 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 |
{
Jim_Var *varPtr;
int retval;
Jim_CallFrame *framePtr;
retval = SetVariableFromAny(interp, nameObjPtr);
if (retval == JIM_DICT_SUGAR) {
return JimDictSugarSet(interp, nameObjPtr, NULL);
}
else if (retval == JIM_OK) {
varPtr = nameObjPtr->internalRep.varValue.varPtr;
if (varPtr->linkFramePtr) {
framePtr = interp->framePtr;
interp->framePtr = varPtr->linkFramePtr;
retval = Jim_UnsetVariable(interp, varPtr->objPtr, JIM_NONE);
interp->framePtr = framePtr;
}
else {
const char *name = Jim_String(nameObjPtr);
if (nameObjPtr->internalRep.varValue.global) {
name += 2;
framePtr = interp->topFramePtr;
}
else {
framePtr = interp->framePtr;
}
retval = Jim_DeleteHashEntry(&framePtr->vars, name);
if (retval == JIM_OK) {
framePtr->id = interp->callFrameEpoch++;
}
}
}
if (retval != JIM_OK && (flags & JIM_ERRMSG)) {
Jim_SetResultFormatted(interp, "can't unset \"%#s\": no such variable", nameObjPtr);
}
|
| ︙ | ︙ | |||
10107 10108 10109 10110 10111 10112 10113 |
p++;
keyLen = (str + len) - p;
if (str[len - 1] == ')') {
keyLen--;
}
| | | | | | 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 |
p++;
keyLen = (str + len) - p;
if (str[len - 1] == ')') {
keyLen--;
}
keyObjPtr = Jim_NewStringObj(interp, p, keyLen);
Jim_IncrRefCount(varObjPtr);
Jim_IncrRefCount(keyObjPtr);
*varPtrPtr = varObjPtr;
*keyPtrPtr = keyObjPtr;
}
static int JimDictSugarSet(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *valObjPtr)
{
int err;
SetDictSubstFromAny(interp, objPtr);
err = Jim_SetDictKeysVector(interp, objPtr->internalRep.dictSubstValue.varNameObjPtr,
&objPtr->internalRep.dictSubstValue.indexObjPtr, 1, valObjPtr, JIM_MUSTEXIST);
if (err == JIM_OK) {
Jim_SetEmptyResult(interp);
}
else {
if (!valObjPtr) {
if (Jim_GetVariable(interp, objPtr->internalRep.dictSubstValue.varNameObjPtr, JIM_NONE)) {
Jim_SetResultFormatted(interp, "can't unset \"%#s\": no such element in array",
objPtr);
return err;
}
}
Jim_SetResultFormatted(interp, "can't %s \"%#s\": variable isn't array",
(valObjPtr ? "set" : "unset"), objPtr);
}
return err;
}
static Jim_Obj *JimDictExpandArrayVariable(Jim_Interp *interp, Jim_Obj *varObjPtr,
|
| ︙ | ︙ | |||
10164 10165 10166 10167 10168 10169 10170 |
ret = Jim_DictKey(interp, dictObjPtr, keyObjPtr, &resObjPtr, JIM_NONE);
if (ret != JIM_OK) {
Jim_SetResultFormatted(interp,
"can't read \"%#s(%#s)\": %s array", varObjPtr, keyObjPtr,
ret < 0 ? "variable isn't" : "no such element in");
}
else if ((flags & JIM_UNSHARED) && Jim_IsShared(dictObjPtr)) {
| | | 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 |
ret = Jim_DictKey(interp, dictObjPtr, keyObjPtr, &resObjPtr, JIM_NONE);
if (ret != JIM_OK) {
Jim_SetResultFormatted(interp,
"can't read \"%#s(%#s)\": %s array", varObjPtr, keyObjPtr,
ret < 0 ? "variable isn't" : "no such element in");
}
else if ((flags & JIM_UNSHARED) && Jim_IsShared(dictObjPtr)) {
Jim_SetVariable(interp, varObjPtr, Jim_DuplicateObj(interp, dictObjPtr));
}
return resObjPtr;
}
|
| ︙ | ︙ | |||
10206 10207 10208 10209 10210 10211 10212 |
static void SetDictSubstFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
if (objPtr->typePtr != &dictSubstObjType) {
Jim_Obj *varObjPtr, *keyObjPtr;
if (objPtr->typePtr == &interpolatedObjType) {
| | | 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 |
static void SetDictSubstFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
if (objPtr->typePtr != &dictSubstObjType) {
Jim_Obj *varObjPtr, *keyObjPtr;
if (objPtr->typePtr == &interpolatedObjType) {
varObjPtr = objPtr->internalRep.dictSubstValue.varNameObjPtr;
keyObjPtr = objPtr->internalRep.dictSubstValue.indexObjPtr;
Jim_IncrRefCount(varObjPtr);
Jim_IncrRefCount(keyObjPtr);
}
|
| ︙ | ︙ | |||
10251 10252 10253 10254 10255 10256 10257 |
}
static Jim_Obj *JimExpandExprSugar(Jim_Interp *interp, Jim_Obj *objPtr)
{
Jim_Obj *resultObjPtr;
if (Jim_EvalExpression(interp, objPtr, &resultObjPtr) == JIM_OK) {
| | | 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 |
}
static Jim_Obj *JimExpandExprSugar(Jim_Interp *interp, Jim_Obj *objPtr)
{
Jim_Obj *resultObjPtr;
if (Jim_EvalExpression(interp, objPtr, &resultObjPtr) == JIM_OK) {
resultObjPtr->refCount--;
return resultObjPtr;
}
return NULL;
}
|
| ︙ | ︙ | |||
10295 10296 10297 10298 10299 10300 10301 |
Jim_IncrRefCount(nsObj);
return cf;
}
static int JimDeleteLocalProcs(Jim_Interp *interp, Jim_Stack *localCommands)
{
| | | | < | > | | | 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 |
Jim_IncrRefCount(nsObj);
return cf;
}
static int JimDeleteLocalProcs(Jim_Interp *interp, Jim_Stack *localCommands)
{
if (localCommands) {
Jim_Obj *cmdNameObj;
while ((cmdNameObj = Jim_StackPop(localCommands)) != NULL) {
Jim_HashEntry *he;
Jim_Obj *fqObjName;
Jim_HashTable *ht = &interp->commands;
const char *fqname = JimQualifyName(interp, Jim_String(cmdNameObj), &fqObjName);
he = Jim_FindHashEntry(ht, fqname);
if (he) {
Jim_Cmd *cmd = Jim_GetHashEntryVal(he);
if (cmd->prevCmd) {
Jim_Cmd *prevCmd = cmd->prevCmd;
cmd->prevCmd = NULL;
JimDecrCmdRefCount(interp, cmd);
Jim_SetHashVal(ht, he, prevCmd);
}
else {
Jim_DeleteHashEntry(ht, fqname);
Jim_InterpIncrProcEpoch(interp);
}
}
Jim_DecrRefCount(interp, cmdNameObj);
JimFreeQualifiedName(interp, fqObjName);
}
Jim_FreeStack(localCommands);
Jim_Free(localCommands);
}
return JIM_OK;
}
#define JIM_FCF_FULL 0
#define JIM_FCF_REUSE 1
static void JimFreeCallFrame(Jim_Interp *interp, Jim_CallFrame *cf, int action)
{
JimDeleteLocalProcs(interp, cf->localCommands);
if (cf->procArgsObjPtr)
Jim_DecrRefCount(interp, cf->procArgsObjPtr);
if (cf->procBodyObjPtr)
|
| ︙ | ︙ | |||
10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 |
cf->vars.used = 0;
}
cf->next = interp->freeFramesList;
interp->freeFramesList = cf;
}
int Jim_IsBigEndian(void)
{
union {
unsigned short s;
unsigned char c[2];
} uval = {0x0102};
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 |
cf->vars.used = 0;
}
cf->next = interp->freeFramesList;
interp->freeFramesList = cf;
}
#ifdef JIM_REFERENCES
static void JimReferencesHTValDestructor(void *interp, void *val)
{
Jim_Reference *refPtr = (void *)val;
Jim_DecrRefCount(interp, refPtr->objPtr);
if (refPtr->finalizerCmdNamePtr != NULL) {
Jim_DecrRefCount(interp, refPtr->finalizerCmdNamePtr);
}
Jim_Free(val);
}
static unsigned int JimReferencesHTHashFunction(const void *key)
{
const unsigned long *widePtr = key;
unsigned int intValue = (unsigned int)*widePtr;
return Jim_IntHashFunction(intValue);
}
static void *JimReferencesHTKeyDup(void *privdata, const void *key)
{
void *copy = Jim_Alloc(sizeof(unsigned long));
JIM_NOTUSED(privdata);
memcpy(copy, key, sizeof(unsigned long));
return copy;
}
static int JimReferencesHTKeyCompare(void *privdata, const void *key1, const void *key2)
{
JIM_NOTUSED(privdata);
return memcmp(key1, key2, sizeof(unsigned long)) == 0;
}
static void JimReferencesHTKeyDestructor(void *privdata, void *key)
{
JIM_NOTUSED(privdata);
Jim_Free(key);
}
static const Jim_HashTableType JimReferencesHashTableType = {
JimReferencesHTHashFunction,
JimReferencesHTKeyDup,
NULL,
JimReferencesHTKeyCompare,
JimReferencesHTKeyDestructor,
JimReferencesHTValDestructor
};
#define JIM_REFERENCE_SPACE (35+JIM_REFERENCE_TAGLEN)
static int JimFormatReference(char *buf, Jim_Reference *refPtr, unsigned long id)
{
const char *fmt = "<reference.<%s>.%020lu>";
sprintf(buf, fmt, refPtr->tag, id);
return JIM_REFERENCE_SPACE;
}
static void UpdateStringOfReference(struct Jim_Obj *objPtr);
static const Jim_ObjType referenceObjType = {
"reference",
NULL,
NULL,
UpdateStringOfReference,
JIM_TYPE_REFERENCES,
};
static void UpdateStringOfReference(struct Jim_Obj *objPtr)
{
char buf[JIM_REFERENCE_SPACE + 1];
JimFormatReference(buf, objPtr->internalRep.refValue.refPtr, objPtr->internalRep.refValue.id);
JimSetStringBytes(objPtr, buf);
}
static int isrefchar(int c)
{
return (c == '_' || isalnum(c));
}
static int SetReferenceFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
unsigned long value;
int i, len;
const char *str, *start, *end;
char refId[21];
Jim_Reference *refPtr;
Jim_HashEntry *he;
char *endptr;
str = Jim_GetString(objPtr, &len);
if (len < JIM_REFERENCE_SPACE)
goto badformat;
start = str;
end = str + len - 1;
while (*start == ' ')
start++;
while (*end == ' ' && end > start)
end--;
if (end - start + 1 != JIM_REFERENCE_SPACE)
goto badformat;
if (memcmp(start, "<reference.<", 12) != 0)
goto badformat;
if (start[12 + JIM_REFERENCE_TAGLEN] != '>' || end[0] != '>')
goto badformat;
for (i = 0; i < JIM_REFERENCE_TAGLEN; i++) {
if (!isrefchar(start[12 + i]))
goto badformat;
}
memcpy(refId, start + 14 + JIM_REFERENCE_TAGLEN, 20);
refId[20] = '\0';
value = strtoul(refId, &endptr, 10);
if (JimCheckConversion(refId, endptr) != JIM_OK)
goto badformat;
he = Jim_FindHashEntry(&interp->references, &value);
if (he == NULL) {
Jim_SetResultFormatted(interp, "invalid reference id \"%#s\"", objPtr);
return JIM_ERR;
}
refPtr = Jim_GetHashEntryVal(he);
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &referenceObjType;
objPtr->internalRep.refValue.id = value;
objPtr->internalRep.refValue.refPtr = refPtr;
return JIM_OK;
badformat:
Jim_SetResultFormatted(interp, "expected reference but got \"%#s\"", objPtr);
return JIM_ERR;
}
Jim_Obj *Jim_NewReference(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *tagPtr, Jim_Obj *cmdNamePtr)
{
struct Jim_Reference *refPtr;
unsigned long id;
Jim_Obj *refObjPtr;
const char *tag;
int tagLen, i;
Jim_CollectIfNeeded(interp);
refPtr = Jim_Alloc(sizeof(*refPtr));
refPtr->objPtr = objPtr;
Jim_IncrRefCount(objPtr);
refPtr->finalizerCmdNamePtr = cmdNamePtr;
if (cmdNamePtr)
Jim_IncrRefCount(cmdNamePtr);
id = interp->referenceNextId++;
Jim_AddHashEntry(&interp->references, &id, refPtr);
refObjPtr = Jim_NewObj(interp);
refObjPtr->typePtr = &referenceObjType;
refObjPtr->bytes = NULL;
refObjPtr->internalRep.refValue.id = id;
refObjPtr->internalRep.refValue.refPtr = refPtr;
interp->referenceNextId++;
tag = Jim_GetString(tagPtr, &tagLen);
if (tagLen > JIM_REFERENCE_TAGLEN)
tagLen = JIM_REFERENCE_TAGLEN;
for (i = 0; i < JIM_REFERENCE_TAGLEN; i++) {
if (i < tagLen && isrefchar(tag[i]))
refPtr->tag[i] = tag[i];
else
refPtr->tag[i] = '_';
}
refPtr->tag[JIM_REFERENCE_TAGLEN] = '\0';
return refObjPtr;
}
Jim_Reference *Jim_GetReference(Jim_Interp *interp, Jim_Obj *objPtr)
{
if (objPtr->typePtr != &referenceObjType && SetReferenceFromAny(interp, objPtr) == JIM_ERR)
return NULL;
return objPtr->internalRep.refValue.refPtr;
}
int Jim_SetFinalizer(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *cmdNamePtr)
{
Jim_Reference *refPtr;
if ((refPtr = Jim_GetReference(interp, objPtr)) == NULL)
return JIM_ERR;
Jim_IncrRefCount(cmdNamePtr);
if (refPtr->finalizerCmdNamePtr)
Jim_DecrRefCount(interp, refPtr->finalizerCmdNamePtr);
refPtr->finalizerCmdNamePtr = cmdNamePtr;
return JIM_OK;
}
int Jim_GetFinalizer(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj **cmdNamePtrPtr)
{
Jim_Reference *refPtr;
if ((refPtr = Jim_GetReference(interp, objPtr)) == NULL)
return JIM_ERR;
*cmdNamePtrPtr = refPtr->finalizerCmdNamePtr;
return JIM_OK;
}
static const Jim_HashTableType JimRefMarkHashTableType = {
JimReferencesHTHashFunction,
JimReferencesHTKeyDup,
NULL,
JimReferencesHTKeyCompare,
JimReferencesHTKeyDestructor,
NULL
};
int Jim_Collect(Jim_Interp *interp)
{
int collected = 0;
return collected;
}
#define JIM_COLLECT_ID_PERIOD 5000
#define JIM_COLLECT_TIME_PERIOD 300
void Jim_CollectIfNeeded(Jim_Interp *interp)
{
unsigned long elapsedId;
int elapsedTime;
elapsedId = interp->referenceNextId - interp->lastCollectId;
elapsedTime = time(NULL) - interp->lastCollectTime;
if (elapsedId > JIM_COLLECT_ID_PERIOD || elapsedTime > JIM_COLLECT_TIME_PERIOD) {
Jim_Collect(interp);
}
}
#endif
int Jim_IsBigEndian(void)
{
union {
unsigned short s;
unsigned char c[2];
} uval = {0x0102};
|
| ︙ | ︙ | |||
10423 10424 10425 10426 10427 10428 10429 |
Jim_IncrRefCount(i->unknown);
Jim_IncrRefCount(i->currentScriptObj);
Jim_IncrRefCount(i->nullScriptObj);
Jim_IncrRefCount(i->errorProc);
Jim_IncrRefCount(i->trueObj);
Jim_IncrRefCount(i->falseObj);
| | | 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 |
Jim_IncrRefCount(i->unknown);
Jim_IncrRefCount(i->currentScriptObj);
Jim_IncrRefCount(i->nullScriptObj);
Jim_IncrRefCount(i->errorProc);
Jim_IncrRefCount(i->trueObj);
Jim_IncrRefCount(i->falseObj);
Jim_SetVariableStrWithStr(i, JIM_LIBPATH, TCL_LIBRARY);
Jim_SetVariableStrWithStr(i, JIM_INTERACTIVE, "0");
Jim_SetVariableStrWithStr(i, "tcl_platform(engine)", "Jim");
Jim_SetVariableStrWithStr(i, "tcl_platform(os)", TCL_PLATFORM_OS);
Jim_SetVariableStrWithStr(i, "tcl_platform(platform)", TCL_PLATFORM_PLATFORM);
Jim_SetVariableStrWithStr(i, "tcl_platform(pathSeparator)", TCL_PLATFORM_PATH_SEPARATOR);
|
| ︙ | ︙ | |||
10445 10446 10447 10448 10449 10450 10451 |
void Jim_FreeInterp(Jim_Interp *i)
{
Jim_CallFrame *cf, *cfx;
Jim_Obj *objPtr, *nextObjPtr;
| | | 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 |
void Jim_FreeInterp(Jim_Interp *i)
{
Jim_CallFrame *cf, *cfx;
Jim_Obj *objPtr, *nextObjPtr;
for (cf = i->framePtr; cf; cf = cfx) {
cfx = cf->parent;
JimFreeCallFrame(i, cf, JIM_FCF_FULL);
}
Jim_DecrRefCount(i, i->emptyObj);
Jim_DecrRefCount(i, i->trueObj);
|
| ︙ | ︙ | |||
10498 10499 10500 10501 10502 10503 10504 |
objPtr = objPtr->nextObjPtr;
}
printf("-------------------------------------\n\n");
JimPanic((1, "Live list non empty freeing the interpreter! Leak?"));
}
#endif
| | | | | 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 |
objPtr = objPtr->nextObjPtr;
}
printf("-------------------------------------\n\n");
JimPanic((1, "Live list non empty freeing the interpreter! Leak?"));
}
#endif
objPtr = i->freeList;
while (objPtr) {
nextObjPtr = objPtr->nextObjPtr;
Jim_Free(objPtr);
objPtr = nextObjPtr;
}
for (cf = i->freeFramesList; cf; cf = cfx) {
cfx = cf->next;
if (cf->vars.table)
Jim_FreeHashTable(&cf->vars);
Jim_Free(cf);
}
Jim_Free(i);
}
Jim_CallFrame *Jim_GetCallFrameByLevel(Jim_Interp *interp, Jim_Obj *levelObjPtr)
{
long level;
const char *str;
|
| ︙ | ︙ | |||
10539 10540 10541 10542 10543 10544 10545 |
}
}
else {
if (Jim_GetLong(interp, levelObjPtr, &level) != JIM_OK || level < 0) {
level = -1;
}
else {
| | | | | | | 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 |
}
}
else {
if (Jim_GetLong(interp, levelObjPtr, &level) != JIM_OK || level < 0) {
level = -1;
}
else {
level = interp->framePtr->level - level;
}
}
}
else {
str = "1";
level = interp->framePtr->level - 1;
}
if (level == 0) {
return interp->topFramePtr;
}
if (level > 0) {
for (framePtr = interp->framePtr; framePtr; framePtr = framePtr->parent) {
if (framePtr->level == level) {
return framePtr;
}
}
}
Jim_SetResultFormatted(interp, "bad level \"%s\"", str);
return NULL;
}
static Jim_CallFrame *JimGetCallFrameByInteger(Jim_Interp *interp, Jim_Obj *levelObjPtr)
{
long level;
Jim_CallFrame *framePtr;
if (Jim_GetLong(interp, levelObjPtr, &level) == JIM_OK) {
if (level <= 0) {
level = interp->framePtr->level + level;
}
if (level == 0) {
return interp->topFramePtr;
}
for (framePtr = interp->framePtr; framePtr; framePtr = framePtr->parent) {
if (framePtr->level == level) {
return framePtr;
}
}
}
|
| ︙ | ︙ | |||
10603 10604 10605 10606 10607 10608 10609 |
Jim_IncrRefCount(interp->stackTrace);
}
static void JimSetStackTrace(Jim_Interp *interp, Jim_Obj *stackTraceObj)
{
int len;
| | | | | | | | 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 |
Jim_IncrRefCount(interp->stackTrace);
}
static void JimSetStackTrace(Jim_Interp *interp, Jim_Obj *stackTraceObj)
{
int len;
Jim_IncrRefCount(stackTraceObj);
Jim_DecrRefCount(interp, interp->stackTrace);
interp->stackTrace = stackTraceObj;
interp->errorFlag = 1;
len = Jim_ListLength(interp, interp->stackTrace);
if (len >= 3) {
if (Jim_Length(Jim_ListGetIndex(interp, interp->stackTrace, len - 2)) == 0) {
interp->addStackTrace = 1;
}
}
}
static void JimAppendStackTrace(Jim_Interp *interp, const char *procname,
Jim_Obj *fileNameObj, int linenr)
{
if (strcmp(procname, "unknown") == 0) {
procname = "";
}
if (!*procname && !Jim_Length(fileNameObj)) {
return;
}
if (Jim_IsShared(interp->stackTrace)) {
Jim_DecrRefCount(interp, interp->stackTrace);
interp->stackTrace = Jim_DuplicateObj(interp, interp->stackTrace);
Jim_IncrRefCount(interp->stackTrace);
}
if (!*procname && Jim_Length(fileNameObj)) {
int len = Jim_ListLength(interp, interp->stackTrace);
if (len >= 3) {
Jim_Obj *objPtr = Jim_ListGetIndex(interp, interp->stackTrace, len - 3);
if (Jim_Length(objPtr)) {
objPtr = Jim_ListGetIndex(interp, interp->stackTrace, len - 2);
if (Jim_Length(objPtr) == 0) {
ListSetIndex(interp, interp->stackTrace, len - 2, fileNameObj, 0);
ListSetIndex(interp, interp->stackTrace, len - 1, Jim_NewIntObj(interp, linenr), 0);
return;
}
}
}
}
|
| ︙ | ︙ | |||
10751 10752 10753 10754 10755 10756 10757 |
static int SetIntFromAny(Jim_Interp *interp, Jim_Obj *objPtr, int flags)
{
jim_wide wideValue;
const char *str;
if (objPtr->typePtr == &coercedDoubleObjType) {
| | | | | | 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 |
static int SetIntFromAny(Jim_Interp *interp, Jim_Obj *objPtr, int flags)
{
jim_wide wideValue;
const char *str;
if (objPtr->typePtr == &coercedDoubleObjType) {
objPtr->typePtr = &intObjType;
return JIM_OK;
}
str = Jim_String(objPtr);
if (Jim_StringToWide(str, &wideValue, 0) != JIM_OK) {
if (flags & JIM_ERRMSG) {
Jim_SetResultFormatted(interp, "expected integer but got \"%#s\"", objPtr);
}
return JIM_ERR;
}
if ((wideValue == JIM_WIDE_MIN || wideValue == JIM_WIDE_MAX) && errno == ERANGE) {
Jim_SetResultString(interp, "Integer value too big to be represented", -1);
return JIM_ERR;
}
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &intObjType;
objPtr->internalRep.wideValue = wideValue;
return JIM_OK;
}
#ifdef JIM_OPTIMIZATION
|
| ︙ | ︙ | |||
10868 10869 10870 10871 10872 10873 10874 |
return;
}
{
char buf[JIM_DOUBLE_SPACE + 1];
int i;
int len = sprintf(buf, "%.12g", value);
| | | | 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 |
return;
}
{
char buf[JIM_DOUBLE_SPACE + 1];
int i;
int len = sprintf(buf, "%.12g", value);
for (i = 0; i < len; i++) {
if (buf[i] == '.' || buf[i] == 'e') {
#if defined(JIM_SPRINTF_DOUBLE_NEEDS_FIX)
char *e = strchr(buf, 'e');
if (e && (e[1] == '-' || e[1] == '+') && e[2] == '0') {
e += 2;
memmove(e, e + 1, len - (e - buf));
}
#endif
break;
}
}
|
| ︙ | ︙ | |||
10900 10901 10902 10903 10904 10905 10906 |
double doubleValue;
jim_wide wideValue;
const char *str;
str = Jim_String(objPtr);
#ifdef HAVE_LONG_LONG
| | | | | | | 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 |
double doubleValue;
jim_wide wideValue;
const char *str;
str = Jim_String(objPtr);
#ifdef HAVE_LONG_LONG
#define MIN_INT_IN_DOUBLE -(1LL << 53)
#define MAX_INT_IN_DOUBLE -(MIN_INT_IN_DOUBLE + 1)
if (objPtr->typePtr == &intObjType
&& JimWideValue(objPtr) >= MIN_INT_IN_DOUBLE
&& JimWideValue(objPtr) <= MAX_INT_IN_DOUBLE) {
objPtr->typePtr = &coercedDoubleObjType;
return JIM_OK;
}
else
#endif
if (Jim_StringToWide(str, &wideValue, 10) == JIM_OK) {
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &coercedDoubleObjType;
objPtr->internalRep.wideValue = wideValue;
return JIM_OK;
}
else {
if (Jim_StringToDouble(str, &doubleValue) != JIM_OK) {
Jim_SetResultFormatted(interp, "expected floating-point number but got \"%#s\"", objPtr);
return JIM_ERR;
}
Jim_FreeIntRep(interp, objPtr);
}
objPtr->typePtr = &doubleObjType;
objPtr->internalRep.doubleValue = doubleValue;
return JIM_OK;
}
|
| ︙ | ︙ | |||
10964 10965 10966 10967 10968 10969 10970 |
objPtr = Jim_NewObj(interp);
objPtr->typePtr = &doubleObjType;
objPtr->bytes = NULL;
objPtr->internalRep.doubleValue = doubleValue;
return objPtr;
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 |
objPtr = Jim_NewObj(interp);
objPtr->typePtr = &doubleObjType;
objPtr->bytes = NULL;
objPtr->internalRep.doubleValue = doubleValue;
return objPtr;
}
static void ListInsertElements(Jim_Obj *listPtr, int idx, int elemc, Jim_Obj *const *elemVec);
static void ListAppendElement(Jim_Obj *listPtr, Jim_Obj *objPtr);
static void FreeListInternalRep(Jim_Interp *interp, Jim_Obj *objPtr);
static void DupListInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr);
static void UpdateStringOfList(struct Jim_Obj *objPtr);
static int SetListFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr);
|
| ︙ | ︙ | |||
11054 11055 11056 11057 11058 11059 11060 |
#define JIM_ELESTR_SIMPLE 0
#define JIM_ELESTR_BRACE 1
#define JIM_ELESTR_QUOTE 2
static unsigned char ListElementQuotingType(const char *s, int len)
{
int i, level, blevel, trySimple = 1;
| | | 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 |
#define JIM_ELESTR_SIMPLE 0
#define JIM_ELESTR_BRACE 1
#define JIM_ELESTR_QUOTE 2
static unsigned char ListElementQuotingType(const char *s, int len)
{
int i, level, blevel, trySimple = 1;
if (len == 0)
return JIM_ELESTR_BRACE;
if (s[0] == '"' || s[0] == '{') {
trySimple = 0;
goto testbrace;
}
for (i = 0; i < len; i++) {
|
| ︙ | ︙ | |||
11076 11077 11078 11079 11080 11081 11082 |
case '\\':
case '\r':
case '\n':
case '\t':
case '\f':
case '\v':
trySimple = 0;
| | | | 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 |
case '\\':
case '\r':
case '\n':
case '\t':
case '\f':
case '\v':
trySimple = 0;
case '{':
case '}':
goto testbrace;
}
}
return JIM_ELESTR_SIMPLE;
testbrace:
if (s[len - 1] == '\\')
return JIM_ELESTR_QUOTE;
level = 0;
blevel = 0;
for (i = 0; i < len; i++) {
switch (s[i]) {
case '{':
|
| ︙ | ︙ | |||
11205 11206 11207 11208 11209 11210 11211 |
{
#define STATIC_QUOTING_LEN 32
int i, bufLen, realLength;
const char *strRep;
char *p;
unsigned char *quotingType, staticQuoting[STATIC_QUOTING_LEN];
| | | | | | | 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 |
{
#define STATIC_QUOTING_LEN 32
int i, bufLen, realLength;
const char *strRep;
char *p;
unsigned char *quotingType, staticQuoting[STATIC_QUOTING_LEN];
if (objc > STATIC_QUOTING_LEN) {
quotingType = Jim_Alloc(objc);
}
else {
quotingType = staticQuoting;
}
bufLen = 0;
for (i = 0; i < objc; i++) {
int len;
strRep = Jim_GetString(objv[i], &len);
quotingType[i] = ListElementQuotingType(strRep, len);
switch (quotingType[i]) {
case JIM_ELESTR_SIMPLE:
if (i != 0 || strRep[0] != '#') {
bufLen += len;
break;
}
quotingType[i] = JIM_ELESTR_BRACE;
case JIM_ELESTR_BRACE:
bufLen += len + 2;
break;
case JIM_ELESTR_QUOTE:
bufLen += len * 2;
break;
}
bufLen++;
}
bufLen++;
p = objPtr->bytes = Jim_Alloc(bufLen + 1);
realLength = 0;
for (i = 0; i < objc; i++) {
int len, qlen;
strRep = Jim_GetString(objv[i], &len);
|
| ︙ | ︙ | |||
11269 11270 11271 11272 11273 11274 11275 |
realLength++;
}
qlen = BackslashQuoteString(strRep, len, p);
p += qlen;
realLength += qlen;
break;
}
| | | | 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 |
realLength++;
}
qlen = BackslashQuoteString(strRep, len, p);
p += qlen;
realLength += qlen;
break;
}
if (i + 1 != objc) {
*p++ = ' ';
realLength++;
}
}
*p = '\0';
objPtr->length = realLength;
if (quotingType != staticQuoting) {
Jim_Free(quotingType);
}
}
|
| ︙ | ︙ | |||
11310 11311 11312 11313 11314 11315 11316 |
int i;
listObjPtrPtr = JimDictPairs(objPtr, &len);
for (i = 0; i < len; i++) {
Jim_IncrRefCount(listObjPtrPtr[i]);
}
| | | | | | 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 |
int i;
listObjPtrPtr = JimDictPairs(objPtr, &len);
for (i = 0; i < len; i++) {
Jim_IncrRefCount(listObjPtrPtr[i]);
}
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &listObjType;
objPtr->internalRep.listValue.len = len;
objPtr->internalRep.listValue.maxLen = len;
objPtr->internalRep.listValue.ele = listObjPtrPtr;
return JIM_OK;
}
if (objPtr->typePtr == &sourceObjType) {
fileNameObj = objPtr->internalRep.sourceValue.fileNameObj;
linenr = objPtr->internalRep.sourceValue.lineNumber;
}
else {
fileNameObj = interp->emptyObj;
linenr = 1;
}
Jim_IncrRefCount(fileNameObj);
str = Jim_GetString(objPtr, &strLen);
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &listObjType;
objPtr->internalRep.listValue.len = 0;
objPtr->internalRep.listValue.maxLen = 0;
objPtr->internalRep.listValue.ele = NULL;
if (strLen) {
JimParserInit(&parser, str, strLen, linenr);
while (!parser.eof) {
Jim_Obj *elementPtr;
JimParseList(&parser);
if (parser.tt != JIM_TT_STR && parser.tt != JIM_TT_ESC)
|
| ︙ | ︙ | |||
11474 11475 11476 11477 11478 11479 11480 |
static int ListSortCommand(Jim_Obj **lhsObj, Jim_Obj **rhsObj)
{
Jim_Obj *compare_script;
int rc;
jim_wide ret = 0;
| | | 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 |
static int ListSortCommand(Jim_Obj **lhsObj, Jim_Obj **rhsObj)
{
Jim_Obj *compare_script;
int rc;
jim_wide ret = 0;
compare_script = Jim_DuplicateObj(sort_info->interp, sort_info->command);
Jim_ListAppendElement(sort_info->interp, compare_script, *lhsObj);
Jim_ListAppendElement(sort_info->interp, compare_script, *rhsObj);
rc = Jim_EvalObj(sort_info->interp, compare_script);
if (rc != JIM_OK || Jim_GetWide(sort_info->interp, Jim_GetResult(sort_info->interp), &ret) != JIM_OK) {
|
| ︙ | ︙ | |||
11496 11497 11498 11499 11500 11501 11502 |
{
int src;
int dst = 0;
Jim_Obj **ele = listObjPtr->internalRep.listValue.ele;
for (src = 1; src < listObjPtr->internalRep.listValue.len; src++) {
if (comp(&ele[dst], &ele[src]) == 0) {
| | | | | | | 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 |
{
int src;
int dst = 0;
Jim_Obj **ele = listObjPtr->internalRep.listValue.ele;
for (src = 1; src < listObjPtr->internalRep.listValue.len; src++) {
if (comp(&ele[dst], &ele[src]) == 0) {
Jim_DecrRefCount(sort_info->interp, ele[dst]);
}
else {
dst++;
}
ele[dst] = ele[src];
}
ele[++dst] = ele[src];
listObjPtr->internalRep.listValue.len = dst;
}
static int ListSortElements(Jim_Interp *interp, Jim_Obj *listObjPtr, struct lsort_info *info)
{
struct lsort_info *prev_info;
typedef int (qsort_comparator) (const void *, const void *);
int (*fn) (Jim_Obj **, Jim_Obj **);
Jim_Obj **vector;
int len;
int rc;
JimPanic((Jim_IsShared(listObjPtr), "ListSortElements called with shared object"));
SetListFromAny(interp, listObjPtr);
prev_info = sort_info;
sort_info = info;
vector = listObjPtr->internalRep.listValue.ele;
len = listObjPtr->internalRep.listValue.len;
switch (info->type) {
case JIM_LSORT_ASCII:
|
| ︙ | ︙ | |||
11549 11550 11551 11552 11553 11554 11555 |
case JIM_LSORT_REAL:
fn = ListSortReal;
break;
case JIM_LSORT_COMMAND:
fn = ListSortCommand;
break;
default:
| | | | | 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 |
case JIM_LSORT_REAL:
fn = ListSortReal;
break;
case JIM_LSORT_COMMAND:
fn = ListSortCommand;
break;
default:
fn = NULL;
JimPanic((1, "ListSort called with invalid sort type"));
return -1;
}
if (info->indexed) {
info->subfn = fn;
fn = ListSortIndexHelper;
}
if ((rc = setjmp(info->jmpbuf)) == 0) {
qsort(vector, len, sizeof(Jim_Obj *), (qsort_comparator *) fn);
|
| ︙ | ︙ | |||
11583 11584 11585 11586 11587 11588 11589 |
int currentLen = listPtr->internalRep.listValue.len;
int requiredLen = currentLen + elemc;
int i;
Jim_Obj **point;
if (requiredLen > listPtr->internalRep.listValue.maxLen) {
if (requiredLen < 2) {
| | | 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 |
int currentLen = listPtr->internalRep.listValue.len;
int requiredLen = currentLen + elemc;
int i;
Jim_Obj **point;
if (requiredLen > listPtr->internalRep.listValue.maxLen) {
if (requiredLen < 2) {
requiredLen = 4;
}
else {
requiredLen *= 2;
}
listPtr->internalRep.listValue.ele = Jim_Realloc(listPtr->internalRep.listValue.ele,
|
| ︙ | ︙ | |||
11769 11770 11771 11772 11773 11774 11775 |
Jim_Obj *objPtr = Jim_NewListObj(interp, NULL, 0);
for (i = 0; i < objc; i++)
ListAppendList(objPtr, objv[i]);
return objPtr;
}
else {
| | | | | | | | 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 |
Jim_Obj *objPtr = Jim_NewListObj(interp, NULL, 0);
for (i = 0; i < objc; i++)
ListAppendList(objPtr, objv[i]);
return objPtr;
}
else {
int len = 0, objLen;
char *bytes, *p;
for (i = 0; i < objc; i++) {
len += Jim_Length(objv[i]);
}
if (objc)
len += objc - 1;
p = bytes = Jim_Alloc(len + 1);
for (i = 0; i < objc; i++) {
const char *s = Jim_GetString(objv[i], &objLen);
while (objLen && isspace(UCHAR(*s))) {
s++;
objLen--;
len--;
}
while (objLen && isspace(UCHAR(s[objLen - 1]))) {
if (objLen > 1 && s[objLen - 2] == '\\') {
break;
}
objLen--;
len--;
}
memcpy(p, s, objLen);
|
| ︙ | ︙ | |||
11823 11824 11825 11826 11827 11828 11829 |
{
int first, last;
int len, rangeLen;
if (Jim_GetIndex(interp, firstObjPtr, &first) != JIM_OK ||
Jim_GetIndex(interp, lastObjPtr, &last) != JIM_OK)
return NULL;
| | | 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 |
{
int first, last;
int len, rangeLen;
if (Jim_GetIndex(interp, firstObjPtr, &first) != JIM_OK ||
Jim_GetIndex(interp, lastObjPtr, &last) != JIM_OK)
return NULL;
len = Jim_ListLength(interp, listObjPtr);
first = JimRelToAbsIndex(len, first);
last = JimRelToAbsIndex(len, last);
JimRelToAbsRange(len, &first, &last, &rangeLen);
if (first == 0 && last == len) {
return listObjPtr;
}
return Jim_NewListObj(interp, listObjPtr->internalRep.listValue.ele + first, rangeLen);
|
| ︙ | ︙ | |||
11863 11864 11865 11866 11867 11868 11869 |
static void JimObjectHTKeyValDestructor(void *interp, void *val)
{
Jim_DecrRefCount(interp, (Jim_Obj *)val);
}
static const Jim_HashTableType JimDictHashTableType = {
| | | | | | | | 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 |
static void JimObjectHTKeyValDestructor(void *interp, void *val)
{
Jim_DecrRefCount(interp, (Jim_Obj *)val);
}
static const Jim_HashTableType JimDictHashTableType = {
JimObjectHTHashFunction,
JimObjectHTKeyValDup,
JimObjectHTKeyValDup,
JimObjectHTKeyCompare,
JimObjectHTKeyValDestructor,
JimObjectHTKeyValDestructor
};
static const Jim_ObjType dictObjType = {
"dict",
FreeDictInternalRep,
DupDictInternalRep,
UpdateStringOfDict,
|
| ︙ | ︙ | |||
11893 11894 11895 11896 11897 11898 11899 |
void DupDictInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr)
{
Jim_HashTable *ht, *dupHt;
Jim_HashTableIterator htiter;
Jim_HashEntry *he;
| | | | | | | | | 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 |
void DupDictInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr)
{
Jim_HashTable *ht, *dupHt;
Jim_HashTableIterator htiter;
Jim_HashEntry *he;
ht = srcPtr->internalRep.ptr;
dupHt = Jim_Alloc(sizeof(*dupHt));
Jim_InitHashTable(dupHt, &JimDictHashTableType, interp);
if (ht->size != 0)
Jim_ExpandHashTable(dupHt, ht->size);
JimInitHashTableIterator(ht, &htiter);
while ((he = Jim_NextHashEntry(&htiter)) != NULL) {
Jim_AddHashEntry(dupHt, he->key, he->u.val);
}
dupPtr->internalRep.ptr = dupHt;
dupPtr->typePtr = &dictObjType;
}
static Jim_Obj **JimDictPairs(Jim_Obj *dictPtr, int *len)
{
Jim_HashTable *ht;
Jim_HashTableIterator htiter;
Jim_HashEntry *he;
Jim_Obj **objv;
int i;
ht = dictPtr->internalRep.ptr;
objv = Jim_Alloc((ht->used * 2) * sizeof(Jim_Obj *));
JimInitHashTableIterator(ht, &htiter);
i = 0;
while ((he = Jim_NextHashEntry(&htiter)) != NULL) {
objv[i++] = Jim_GetHashEntryKey(he);
objv[i++] = Jim_GetHashEntryVal(he);
}
*len = i;
return objv;
}
static void UpdateStringOfDict(struct Jim_Obj *objPtr)
{
int len;
Jim_Obj **objv = JimDictPairs(objPtr, &len);
JimMakeListStringRep(objPtr, objv, len);
Jim_Free(objv);
}
static int SetDictFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr)
{
int listlen;
if (objPtr->typePtr == &dictObjType) {
return JIM_OK;
}
if (Jim_IsList(objPtr) && Jim_IsShared(objPtr)) {
Jim_String(objPtr);
}
listlen = Jim_ListLength(interp, objPtr);
if (listlen % 2) {
Jim_SetResultString(interp, "missing value to go with key", -1);
return JIM_ERR;
}
else {
Jim_HashTable *ht;
int i;
ht = Jim_Alloc(sizeof(*ht));
Jim_InitHashTable(ht, &JimDictHashTableType, interp);
for (i = 0; i < listlen; i += 2) {
|
| ︙ | ︙ | |||
11991 11992 11993 11994 11995 11996 11997 |
static int DictAddElement(Jim_Interp *interp, Jim_Obj *objPtr,
Jim_Obj *keyObjPtr, Jim_Obj *valueObjPtr)
{
Jim_HashTable *ht = objPtr->internalRep.ptr;
| | | 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 |
static int DictAddElement(Jim_Interp *interp, Jim_Obj *objPtr,
Jim_Obj *keyObjPtr, Jim_Obj *valueObjPtr)
{
Jim_HashTable *ht = objPtr->internalRep.ptr;
if (valueObjPtr == NULL) {
return Jim_DeleteHashEntry(ht, keyObjPtr);
}
Jim_ReplaceHashEntry(ht, keyObjPtr, valueObjPtr);
return JIM_OK;
}
int Jim_DictAddElement(Jim_Interp *interp, Jim_Obj *objPtr,
|
| ︙ | ︙ | |||
12091 12092 12093 12094 12095 12096 12097 |
{
Jim_Obj *varObjPtr, *objPtr, *dictObjPtr;
int shared, i;
varObjPtr = objPtr = Jim_GetVariable(interp, varNamePtr, flags);
if (objPtr == NULL) {
if (newObjPtr == NULL && (flags & JIM_MUSTEXIST)) {
| | | | | | | 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 |
{
Jim_Obj *varObjPtr, *objPtr, *dictObjPtr;
int shared, i;
varObjPtr = objPtr = Jim_GetVariable(interp, varNamePtr, flags);
if (objPtr == NULL) {
if (newObjPtr == NULL && (flags & JIM_MUSTEXIST)) {
return JIM_ERR;
}
varObjPtr = objPtr = Jim_NewDictObj(interp, NULL, 0);
if (Jim_SetVariable(interp, varNamePtr, objPtr) != JIM_OK) {
Jim_FreeNewObj(interp, varObjPtr);
return JIM_ERR;
}
}
if ((shared = Jim_IsShared(objPtr)))
varObjPtr = objPtr = Jim_DuplicateObj(interp, objPtr);
for (i = 0; i < keyc; i++) {
dictObjPtr = objPtr;
if (SetDictFromAny(interp, dictObjPtr) != JIM_OK) {
goto err;
}
if (i == keyc - 1) {
if (Jim_DictAddElement(interp, objPtr, keyv[keyc - 1], newObjPtr) != JIM_OK) {
if (newObjPtr || (flags & JIM_MUSTEXIST)) {
goto err;
}
}
break;
}
Jim_InvalidateStringRep(dictObjPtr);
if (Jim_DictKey(interp, dictObjPtr, keyv[i], &objPtr,
newObjPtr ? JIM_NONE : JIM_ERRMSG) == JIM_OK) {
if (Jim_IsShared(objPtr)) {
objPtr = Jim_DuplicateObj(interp, objPtr);
DictAddElement(interp, dictObjPtr, keyv[i], objPtr);
}
}
else {
if (newObjPtr == NULL) {
goto err;
}
objPtr = Jim_NewDictObj(interp, NULL, 0);
DictAddElement(interp, dictObjPtr, keyv[i], objPtr);
}
}
Jim_InvalidateStringRep(objPtr);
Jim_InvalidateStringRep(varObjPtr);
if (Jim_SetVariable(interp, varNamePtr, varObjPtr) != JIM_OK) {
goto err;
}
Jim_SetResult(interp, varObjPtr);
return JIM_OK;
|
| ︙ | ︙ | |||
12174 12175 12176 12177 12178 12179 12180 |
}
else {
char buf[JIM_INTEGER_SPACE + 1];
if (objPtr->internalRep.intValue >= 0) {
sprintf(buf, "%d", objPtr->internalRep.intValue);
}
else {
| | | | | | | | | | 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 |
}
else {
char buf[JIM_INTEGER_SPACE + 1];
if (objPtr->internalRep.intValue >= 0) {
sprintf(buf, "%d", objPtr->internalRep.intValue);
}
else {
sprintf(buf, "end%d", objPtr->internalRep.intValue + 1);
}
JimSetStringBytes(objPtr, buf);
}
}
static int SetIndexFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
int idx, end = 0;
const char *str;
char *endptr;
str = Jim_String(objPtr);
if (strncmp(str, "end", 3) == 0) {
end = 1;
str += 3;
idx = 0;
}
else {
idx = jim_strtol(str, &endptr);
if (endptr == str) {
goto badindex;
}
str = endptr;
}
if (*str == '+' || *str == '-') {
int sign = (*str == '+' ? 1 : -1);
idx += sign * jim_strtol(++str, &endptr);
if (str == endptr || *endptr) {
goto badindex;
}
str = endptr;
}
while (isspace(UCHAR(*str))) {
str++;
}
if (*str) {
goto badindex;
}
if (end) {
if (idx > 0) {
idx = INT_MAX;
}
else {
idx--;
}
}
else if (idx < 0) {
idx = -INT_MAX;
}
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &indexObjType;
objPtr->internalRep.intValue = idx;
return JIM_OK;
badindex:
Jim_SetResultFormatted(interp,
"bad index \"%#s\": must be integer?[+-]integer? or end?[+-]integer?", objPtr);
return JIM_ERR;
}
int Jim_GetIndex(Jim_Interp *interp, Jim_Obj *objPtr, int *indexPtr)
{
if (objPtr->typePtr == &intObjType) {
jim_wide val = JimWideValue(objPtr);
if (val < 0)
*indexPtr = -INT_MAX;
else if (val > INT_MAX)
*indexPtr = INT_MAX;
|
| ︙ | ︙ | |||
12306 12307 12308 12309 12310 12311 12312 |
}
static int SetReturnCodeFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
int returnCode;
jim_wide wideValue;
| | | < | | | | | | | | | | | | | | | | | | | | < < < | 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 |
}
static int SetReturnCodeFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
int returnCode;
jim_wide wideValue;
if (JimGetWideNoErr(interp, objPtr, &wideValue) != JIM_ERR)
returnCode = (int)wideValue;
else if (Jim_GetEnum(interp, objPtr, jimReturnCodes, &returnCode, NULL, JIM_NONE) != JIM_OK) {
Jim_SetResultFormatted(interp, "expected return code but got \"%#s\"", objPtr);
return JIM_ERR;
}
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &returnCodeObjType;
objPtr->internalRep.intValue = returnCode;
return JIM_OK;
}
int Jim_GetReturnCode(Jim_Interp *interp, Jim_Obj *objPtr, int *intPtr)
{
if (objPtr->typePtr != &returnCodeObjType && SetReturnCodeFromAny(interp, objPtr) == JIM_ERR)
return JIM_ERR;
*intPtr = objPtr->internalRep.intValue;
return JIM_OK;
}
static int JimParseExprOperator(struct JimParserCtx *pc);
static int JimParseExprNumber(struct JimParserCtx *pc);
static int JimParseExprIrrational(struct JimParserCtx *pc);
enum
{
JIM_EXPROP_MUL = JIM_TT_EXPR_OP,
JIM_EXPROP_DIV,
JIM_EXPROP_MOD,
JIM_EXPROP_SUB,
JIM_EXPROP_ADD,
JIM_EXPROP_LSHIFT,
JIM_EXPROP_RSHIFT,
JIM_EXPROP_ROTL,
JIM_EXPROP_ROTR,
JIM_EXPROP_LT,
JIM_EXPROP_GT,
JIM_EXPROP_LTE,
JIM_EXPROP_GTE,
JIM_EXPROP_NUMEQ,
JIM_EXPROP_NUMNE,
JIM_EXPROP_BITAND,
JIM_EXPROP_BITXOR,
JIM_EXPROP_BITOR,
JIM_EXPROP_LOGICAND,
JIM_EXPROP_LOGICAND_LEFT,
JIM_EXPROP_LOGICAND_RIGHT,
JIM_EXPROP_LOGICOR,
JIM_EXPROP_LOGICOR_LEFT,
JIM_EXPROP_LOGICOR_RIGHT,
JIM_EXPROP_TERNARY,
JIM_EXPROP_TERNARY_LEFT,
JIM_EXPROP_TERNARY_RIGHT,
JIM_EXPROP_COLON,
JIM_EXPROP_COLON_LEFT,
JIM_EXPROP_COLON_RIGHT,
JIM_EXPROP_POW,
JIM_EXPROP_STREQ,
JIM_EXPROP_STRNE,
JIM_EXPROP_STRIN,
JIM_EXPROP_STRNI,
JIM_EXPROP_NOT,
JIM_EXPROP_BITNOT,
JIM_EXPROP_UNARYMINUS,
JIM_EXPROP_UNARYPLUS,
JIM_EXPROP_FUNC_FIRST,
JIM_EXPROP_FUNC_INT = JIM_EXPROP_FUNC_FIRST,
JIM_EXPROP_FUNC_WIDE,
JIM_EXPROP_FUNC_ABS,
JIM_EXPROP_FUNC_DOUBLE,
JIM_EXPROP_FUNC_ROUND,
JIM_EXPROP_FUNC_RAND,
JIM_EXPROP_FUNC_SRAND,
JIM_EXPROP_FUNC_SIN,
JIM_EXPROP_FUNC_COS,
JIM_EXPROP_FUNC_TAN,
JIM_EXPROP_FUNC_ASIN,
JIM_EXPROP_FUNC_ACOS,
JIM_EXPROP_FUNC_ATAN,
JIM_EXPROP_FUNC_SINH,
JIM_EXPROP_FUNC_COSH,
JIM_EXPROP_FUNC_TANH,
JIM_EXPROP_FUNC_CEIL,
JIM_EXPROP_FUNC_FLOOR,
JIM_EXPROP_FUNC_EXP,
JIM_EXPROP_FUNC_LOG,
JIM_EXPROP_FUNC_LOG10,
JIM_EXPROP_FUNC_SQRT,
JIM_EXPROP_FUNC_POW,
};
struct JimExprState
{
Jim_Obj **stack;
int stacklen;
int opcode;
|
| ︙ | ︙ | |||
12504 12505 12506 12507 12508 12509 12510 |
break;
case JIM_EXPROP_FUNC_DOUBLE:
case JIM_EXPROP_UNARYPLUS:
dC = dA;
intresult = 0;
break;
case JIM_EXPROP_FUNC_ABS:
| < < < < | 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 |
break;
case JIM_EXPROP_FUNC_DOUBLE:
case JIM_EXPROP_UNARYPLUS:
dC = dA;
intresult = 0;
break;
case JIM_EXPROP_FUNC_ABS:
dC = dA >= 0 ? dA : -dA;
intresult = 0;
break;
case JIM_EXPROP_UNARYMINUS:
dC = -dA;
intresult = 0;
break;
case JIM_EXPROP_NOT:
|
| ︙ | ︙ | |||
12700 12701 12702 12703 12704 12705 12706 |
if (negative) {
wC = -wC;
}
}
break;
case JIM_EXPROP_ROTL:
case JIM_EXPROP_ROTR:{
| | | | 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 |
if (negative) {
wC = -wC;
}
}
break;
case JIM_EXPROP_ROTL:
case JIM_EXPROP_ROTR:{
unsigned long uA = (unsigned long)wA;
unsigned long uB = (unsigned long)wB;
const unsigned int S = sizeof(unsigned long) * 8;
uB %= S;
if (e->opcode == JIM_EXPROP_ROTR) {
uB = S - uB;
}
wC = (unsigned long)(uA << uB) | (uA >> (S - uB));
break;
|
| ︙ | ︙ | |||
12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 |
return rc;
}
static int JimExprOpBin(Jim_Interp *interp, struct JimExprState *e)
{
int rc = JIM_OK;
double dA, dB, dC = 0;
jim_wide wA, wB, wC = 0;
Jim_Obj *B = ExprPop(e);
Jim_Obj *A = ExprPop(e);
if ((A->typePtr != &doubleObjType || A->bytes) &&
(B->typePtr != &doubleObjType || B->bytes) &&
JimGetWideNoErr(interp, A, &wA) == JIM_OK && JimGetWideNoErr(interp, B, &wB) == JIM_OK) {
| > | < < < < < | | | | < < > | | | | | < < < < < < < < < < < | < < | | | > > > > > > > < | < | < < < | < < > | | | | | > | > | > | > | > | > > > | | | | | | | > | > > | > > > > > > > | > < < < < < < | 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 |
return rc;
}
static int JimExprOpBin(Jim_Interp *interp, struct JimExprState *e)
{
int intresult = 1;
int rc = JIM_OK;
double dA, dB, dC = 0;
jim_wide wA, wB, wC = 0;
Jim_Obj *B = ExprPop(e);
Jim_Obj *A = ExprPop(e);
if ((A->typePtr != &doubleObjType || A->bytes) &&
(B->typePtr != &doubleObjType || B->bytes) &&
JimGetWideNoErr(interp, A, &wA) == JIM_OK && JimGetWideNoErr(interp, B, &wB) == JIM_OK) {
switch (e->opcode) {
case JIM_EXPROP_POW:
case JIM_EXPROP_FUNC_POW:
wC = JimPowWide(wA, wB);
break;
case JIM_EXPROP_ADD:
wC = wA + wB;
break;
case JIM_EXPROP_SUB:
wC = wA - wB;
break;
case JIM_EXPROP_MUL:
wC = wA * wB;
break;
case JIM_EXPROP_DIV:
if (wB == 0) {
Jim_SetResultString(interp, "Division by zero", -1);
rc = JIM_ERR;
}
else {
if (wB < 0) {
wB = -wB;
wA = -wA;
}
wC = wA / wB;
if (wA % wB < 0) {
wC--;
}
}
break;
case JIM_EXPROP_LT:
wC = wA < wB;
break;
case JIM_EXPROP_GT:
wC = wA > wB;
break;
case JIM_EXPROP_LTE:
wC = wA <= wB;
break;
case JIM_EXPROP_GTE:
wC = wA >= wB;
break;
case JIM_EXPROP_NUMEQ:
wC = wA == wB;
break;
case JIM_EXPROP_NUMNE:
wC = wA != wB;
break;
default:
abort();
}
}
else if (Jim_GetDouble(interp, A, &dA) == JIM_OK && Jim_GetDouble(interp, B, &dB) == JIM_OK) {
intresult = 0;
switch (e->opcode) {
case JIM_EXPROP_POW:
case JIM_EXPROP_FUNC_POW:
#ifdef JIM_MATH_FUNCTIONS
dC = pow(dA, dB);
#else
Jim_SetResultString(interp, "unsupported", -1);
rc = JIM_ERR;
#endif
break;
case JIM_EXPROP_ADD:
dC = dA + dB;
break;
case JIM_EXPROP_SUB:
dC = dA - dB;
break;
case JIM_EXPROP_MUL:
dC = dA * dB;
break;
case JIM_EXPROP_DIV:
if (dB == 0) {
#ifdef INFINITY
dC = dA < 0 ? -INFINITY : INFINITY;
#else
dC = (dA < 0 ? -1.0 : 1.0) * strtod("Inf", NULL);
#endif
}
else {
dC = dA / dB;
}
break;
case JIM_EXPROP_LT:
wC = dA < dB;
intresult = 1;
break;
case JIM_EXPROP_GT:
wC = dA > dB;
intresult = 1;
break;
case JIM_EXPROP_LTE:
wC = dA <= dB;
intresult = 1;
break;
case JIM_EXPROP_GTE:
wC = dA >= dB;
intresult = 1;
break;
case JIM_EXPROP_NUMEQ:
wC = dA == dB;
intresult = 1;
break;
case JIM_EXPROP_NUMNE:
wC = dA != dB;
intresult = 1;
break;
default:
abort();
}
}
else {
int i = Jim_StringCompareObj(interp, A, B, 0);
switch (e->opcode) {
case JIM_EXPROP_LT:
wC = i < 0;
break;
case JIM_EXPROP_GT:
wC = i > 0;
break;
case JIM_EXPROP_LTE:
wC = i <= 0;
break;
case JIM_EXPROP_GTE:
wC = i >= 0;
break;
case JIM_EXPROP_NUMEQ:
wC = i == 0;
break;
case JIM_EXPROP_NUMNE:
wC = i != 0;
break;
default:
rc = JIM_ERR;
break;
}
}
if (rc == JIM_OK) {
if (intresult) {
ExprPush(e, Jim_NewIntObj(interp, wC));
}
else {
ExprPush(e, Jim_NewDoubleObj(interp, dC));
}
}
Jim_DecrRefCount(interp, A);
Jim_DecrRefCount(interp, B);
return rc;
}
static int JimSearchList(Jim_Interp *interp, Jim_Obj *listObjPtr, Jim_Obj *valObj)
{
int listlen;
int i;
|
| ︙ | ︙ | |||
12958 12959 12960 12961 12962 12963 12964 |
return JIM_OK;
}
static int ExprBool(Jim_Interp *interp, Jim_Obj *obj)
{
long l;
double d;
| < < < < | | | | | | | 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 |
return JIM_OK;
}
static int ExprBool(Jim_Interp *interp, Jim_Obj *obj)
{
long l;
double d;
if (Jim_GetLong(interp, obj, &l) == JIM_OK) {
return l != 0;
}
if (Jim_GetDouble(interp, obj, &d) == JIM_OK) {
return d != 0;
}
return -1;
}
static int JimExprOpAndLeft(Jim_Interp *interp, struct JimExprState *e)
{
Jim_Obj *skip = ExprPop(e);
Jim_Obj *A = ExprPop(e);
int rc = JIM_OK;
switch (ExprBool(interp, A)) {
case 0:
e->skip = JimWideValue(skip);
ExprPush(e, Jim_NewIntObj(interp, 0));
break;
case 1:
break;
case -1:
rc = JIM_ERR;
}
Jim_DecrRefCount(interp, A);
Jim_DecrRefCount(interp, skip);
return rc;
}
static int JimExprOpOrLeft(Jim_Interp *interp, struct JimExprState *e)
{
Jim_Obj *skip = ExprPop(e);
Jim_Obj *A = ExprPop(e);
int rc = JIM_OK;
switch (ExprBool(interp, A)) {
case 0:
break;
case 1:
e->skip = JimWideValue(skip);
ExprPush(e, Jim_NewIntObj(interp, 1));
break;
case -1:
rc = JIM_ERR;
break;
}
Jim_DecrRefCount(interp, A);
Jim_DecrRefCount(interp, skip);
return rc;
|
| ︙ | ︙ | |||
13042 13043 13044 13045 13046 13047 13048 |
break;
case 1:
ExprPush(e, Jim_NewIntObj(interp, 1));
break;
case -1:
| | | | | | | | | | | < | | | 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 |
break;
case 1:
ExprPush(e, Jim_NewIntObj(interp, 1));
break;
case -1:
rc = JIM_ERR;
break;
}
Jim_DecrRefCount(interp, A);
return rc;
}
static int JimExprOpTernaryLeft(Jim_Interp *interp, struct JimExprState *e)
{
Jim_Obj *skip = ExprPop(e);
Jim_Obj *A = ExprPop(e);
int rc = JIM_OK;
ExprPush(e, A);
switch (ExprBool(interp, A)) {
case 0:
e->skip = JimWideValue(skip);
ExprPush(e, Jim_NewIntObj(interp, 0));
break;
case 1:
break;
case -1:
rc = JIM_ERR;
break;
}
Jim_DecrRefCount(interp, A);
Jim_DecrRefCount(interp, skip);
return rc;
}
static int JimExprOpColonLeft(Jim_Interp *interp, struct JimExprState *e)
{
Jim_Obj *skip = ExprPop(e);
Jim_Obj *B = ExprPop(e);
Jim_Obj *A = ExprPop(e);
if (ExprBool(interp, A)) {
e->skip = JimWideValue(skip);
ExprPush(e, B);
}
Jim_DecrRefCount(interp, skip);
Jim_DecrRefCount(interp, A);
Jim_DecrRefCount(interp, B);
return JIM_OK;
}
static int JimExprOpNull(Jim_Interp *interp, struct JimExprState *e)
{
return JIM_OK;
}
enum
{
LAZY_NONE,
LAZY_OP,
LAZY_LEFT,
LAZY_RIGHT
};
#define OPRINIT(N, P, A, F) {N, F, P, A, LAZY_NONE, sizeof(N) - 1}
#define OPRINIT_LAZY(N, P, A, F, L) {N, F, P, A, L, sizeof(N) - 1}
static const struct Jim_ExprOperator Jim_ExprOperators[] = {
OPRINIT("*", 110, 2, JimExprOpBin),
OPRINIT("/", 110, 2, JimExprOpBin),
OPRINIT("%", 110, 2, JimExprOpIntBin),
OPRINIT("-", 100, 2, JimExprOpBin),
|
| ︙ | ︙ | |||
13146 13147 13148 13149 13150 13151 13152 |
OPRINIT("==", 70, 2, JimExprOpBin),
OPRINIT("!=", 70, 2, JimExprOpBin),
OPRINIT("&", 50, 2, JimExprOpIntBin),
OPRINIT("^", 49, 2, JimExprOpIntBin),
OPRINIT("|", 48, 2, JimExprOpIntBin),
| | | | | | | | | | | | | < | | 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 |
OPRINIT("==", 70, 2, JimExprOpBin),
OPRINIT("!=", 70, 2, JimExprOpBin),
OPRINIT("&", 50, 2, JimExprOpIntBin),
OPRINIT("^", 49, 2, JimExprOpIntBin),
OPRINIT("|", 48, 2, JimExprOpIntBin),
OPRINIT_LAZY("&&", 10, 2, NULL, LAZY_OP),
OPRINIT_LAZY(NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT),
OPRINIT_LAZY(NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT),
OPRINIT_LAZY("||", 9, 2, NULL, LAZY_OP),
OPRINIT_LAZY(NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT),
OPRINIT_LAZY(NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT),
OPRINIT_LAZY("?", 5, 2, JimExprOpNull, LAZY_OP),
OPRINIT_LAZY(NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT),
OPRINIT_LAZY(NULL, 5, 2, JimExprOpNull, LAZY_RIGHT),
OPRINIT_LAZY(":", 5, 2, JimExprOpNull, LAZY_OP),
OPRINIT_LAZY(NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT),
OPRINIT_LAZY(NULL, 5, 2, JimExprOpNull, LAZY_RIGHT),
OPRINIT("**", 250, 2, JimExprOpBin),
OPRINIT("eq", 60, 2, JimExprOpStrBin),
OPRINIT("ne", 60, 2, JimExprOpStrBin),
OPRINIT("in", 55, 2, JimExprOpStrBin),
OPRINIT("ni", 55, 2, JimExprOpStrBin),
|
| ︙ | ︙ | |||
13193 13194 13195 13196 13197 13198 13199 |
#ifdef JIM_MATH_FUNCTIONS
OPRINIT("sin", 200, 1, JimExprOpDoubleUnary),
OPRINIT("cos", 200, 1, JimExprOpDoubleUnary),
OPRINIT("tan", 200, 1, JimExprOpDoubleUnary),
OPRINIT("asin", 200, 1, JimExprOpDoubleUnary),
OPRINIT("acos", 200, 1, JimExprOpDoubleUnary),
OPRINIT("atan", 200, 1, JimExprOpDoubleUnary),
| < < < | | | 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 |
#ifdef JIM_MATH_FUNCTIONS
OPRINIT("sin", 200, 1, JimExprOpDoubleUnary),
OPRINIT("cos", 200, 1, JimExprOpDoubleUnary),
OPRINIT("tan", 200, 1, JimExprOpDoubleUnary),
OPRINIT("asin", 200, 1, JimExprOpDoubleUnary),
OPRINIT("acos", 200, 1, JimExprOpDoubleUnary),
OPRINIT("atan", 200, 1, JimExprOpDoubleUnary),
OPRINIT("sinh", 200, 1, JimExprOpDoubleUnary),
OPRINIT("cosh", 200, 1, JimExprOpDoubleUnary),
OPRINIT("tanh", 200, 1, JimExprOpDoubleUnary),
OPRINIT("ceil", 200, 1, JimExprOpDoubleUnary),
OPRINIT("floor", 200, 1, JimExprOpDoubleUnary),
OPRINIT("exp", 200, 1, JimExprOpDoubleUnary),
OPRINIT("log", 200, 1, JimExprOpDoubleUnary),
OPRINIT("log10", 200, 1, JimExprOpDoubleUnary),
OPRINIT("sqrt", 200, 1, JimExprOpDoubleUnary),
OPRINIT("pow", 200, 2, JimExprOpBin),
#endif
};
#undef OPRINIT
#undef OPRINIT_LAZY
#define JIM_EXPR_OPERATORS_NUM \
(sizeof(Jim_ExprOperators)/sizeof(struct Jim_ExprOperator))
static int JimParseExpression(struct JimParserCtx *pc)
{
while (isspace(UCHAR(*pc->p)) || (*(pc->p) == '\\' && *(pc->p + 1) == '\n')) {
if (*pc->p == '\n') {
pc->linenr++;
}
pc->p++;
pc->len--;
}
pc->tline = pc->linenr;
pc->tstart = pc->p;
if (pc->len == 0) {
pc->tend = pc->p;
pc->tt = JIM_TT_EOL;
pc->eof = 1;
|
| ︙ | ︙ | |||
13255 13256 13257 13258 13259 13260 13261 |
break;
case '[':
return JimParseCmd(pc);
case '$':
if (JimParseVar(pc) == JIM_ERR)
return JimParseExprOperator(pc);
else {
| | | 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 |
break;
case '[':
return JimParseCmd(pc);
case '$':
if (JimParseVar(pc) == JIM_ERR)
return JimParseExprOperator(pc);
else {
if (pc->tt == JIM_TT_EXPRSUGAR) {
return JIM_ERR;
}
return JIM_OK;
}
break;
case '0':
|
| ︙ | ︙ | |||
13284 13285 13286 13287 13288 13289 13290 |
return JimParseBrace(pc);
case 'N':
case 'I':
case 'n':
case 'i':
if (JimParseExprIrrational(pc) == JIM_ERR)
| < < < < < < < < | | | | | 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 |
return JimParseBrace(pc);
case 'N':
case 'I':
case 'n':
case 'i':
if (JimParseExprIrrational(pc) == JIM_ERR)
return JimParseExprOperator(pc);
break;
default:
return JimParseExprOperator(pc);
break;
}
return JIM_OK;
}
static int JimParseExprNumber(struct JimParserCtx *pc)
{
char *end;
pc->tt = JIM_TT_EXPR_INT;
jim_strtoull(pc->p, (char **)&pc->p);
if (strchr("eENnIi.", *pc->p) || pc->p == pc->tstart) {
if (strtod(pc->tstart, &end)) { }
if (end == pc->tstart)
return JIM_ERR;
if (end > pc->p) {
pc->tt = JIM_TT_EXPR_DOUBLE;
pc->p = end;
}
}
pc->tend = pc->p - 1;
pc->len -= (pc->p - pc->tstart);
return JIM_OK;
|
| ︙ | ︙ | |||
13344 13345 13346 13347 13348 13349 13350 |
pc->tt = JIM_TT_EXPR_DOUBLE;
return JIM_OK;
}
}
return JIM_ERR;
}
| < < < < < < < < < < < < < < < < < < < < < | | | 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 |
pc->tt = JIM_TT_EXPR_DOUBLE;
return JIM_OK;
}
}
return JIM_ERR;
}
static int JimParseExprOperator(struct JimParserCtx *pc)
{
int i;
int bestIdx = -1, bestLen = 0;
for (i = 0; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) {
const char * const opname = Jim_ExprOperators[i].name;
const int oplen = Jim_ExprOperators[i].namelen;
if (opname == NULL || opname[0] != pc->p[0]) {
continue;
}
if (oplen > bestLen && strncmp(opname, pc->p, oplen) == 0) {
bestIdx = i + JIM_TT_EXPR_OP;
bestLen = oplen;
}
}
if (bestIdx == -1) {
return JIM_ERR;
}
if (bestIdx >= JIM_EXPROP_FUNC_FIRST) {
const char *p = pc->p + bestLen;
int len = pc->len - bestLen;
while (len && isspace(UCHAR(*p))) {
len--;
p++;
|
| ︙ | ︙ | |||
13422 13423 13424 13425 13426 13427 13428 |
return &Jim_ExprOperators[opcode - JIM_TT_EXPR_OP];
}
const char *jim_tt_name(int type)
{
static const char * const tt_names[JIM_TT_EXPR_OP] =
{ "NIL", "STR", "ESC", "VAR", "ARY", "CMD", "SEP", "EOL", "EOF", "LIN", "WRD", "(((", ")))", ",,,", "INT",
| | < < < < < < | 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 |
return &Jim_ExprOperators[opcode - JIM_TT_EXPR_OP];
}
const char *jim_tt_name(int type)
{
static const char * const tt_names[JIM_TT_EXPR_OP] =
{ "NIL", "STR", "ESC", "VAR", "ARY", "CMD", "SEP", "EOL", "EOF", "LIN", "WRD", "(((", ")))", ",,,", "INT",
"DBL", "$()" };
if (type < JIM_TT_EXPR_OP) {
return tt_names[type];
}
else {
const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(type);
static char buf[20];
if (op->name) {
return op->name;
}
|
| ︙ | ︙ | |||
13459 13460 13461 13462 13463 13464 13465 |
NULL,
JIM_TYPE_REFERENCES,
};
typedef struct ExprByteCode
{
| | | | | 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 |
NULL,
JIM_TYPE_REFERENCES,
};
typedef struct ExprByteCode
{
ScriptToken *token;
int len;
int inUse;
} ExprByteCode;
static void ExprFreeByteCode(Jim_Interp *interp, ExprByteCode * expr)
{
int i;
for (i = 0; i < expr->len; i++) {
|
| ︙ | ︙ | |||
13493 13494 13495 13496 13497 13498 13499 |
}
static void DupExprInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr)
{
JIM_NOTUSED(interp);
JIM_NOTUSED(srcPtr);
| | > | < < < < | | | < < < < < < < < < < < < < < < < < < < < < | | | | | | 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 |
}
static void DupExprInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr)
{
JIM_NOTUSED(interp);
JIM_NOTUSED(srcPtr);
dupPtr->typePtr = NULL;
}
static int ExprCheckCorrectness(ExprByteCode * expr)
{
int i;
int stacklen = 0;
int ternary = 0;
for (i = 0; i < expr->len; i++) {
ScriptToken *t = &expr->token[i];
const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(t->type);
stacklen -= op->arity;
if (stacklen < 0) {
break;
}
if (t->type == JIM_EXPROP_TERNARY || t->type == JIM_EXPROP_TERNARY_LEFT) {
ternary++;
}
else if (t->type == JIM_EXPROP_COLON || t->type == JIM_EXPROP_COLON_LEFT) {
ternary--;
}
stacklen++;
}
if (stacklen != 1 || ternary != 0) {
return JIM_ERR;
}
return JIM_OK;
}
static int ExprAddLazyOperator(Jim_Interp *interp, ExprByteCode * expr, ParseToken *t)
{
int i;
int leftindex, arity, offset;
leftindex = expr->len - 1;
arity = 1;
while (arity) {
ScriptToken *tt = &expr->token[leftindex];
if (tt->type >= JIM_TT_EXPR_OP) {
arity += JimExprOperatorInfoByOpcode(tt->type)->arity;
}
arity--;
if (--leftindex < 0) {
return JIM_ERR;
}
}
leftindex++;
memmove(&expr->token[leftindex + 2], &expr->token[leftindex],
sizeof(*expr->token) * (expr->len - leftindex));
expr->len += 2;
offset = (expr->len - leftindex) - 1;
expr->token[leftindex + 1].type = t->type + 1;
expr->token[leftindex + 1].objPtr = interp->emptyObj;
expr->token[leftindex].type = JIM_TT_EXPR_INT;
expr->token[leftindex].objPtr = Jim_NewIntObj(interp, offset);
expr->token[expr->len].objPtr = interp->emptyObj;
expr->token[expr->len].type = t->type + 2;
expr->len++;
for (i = leftindex - 1; i > 0; i--) {
const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(expr->token[i].type);
if (op->lazy == LAZY_LEFT) {
if (JimWideValue(expr->token[i - 1].objPtr) + i - 1 >= leftindex) {
JimWideValue(expr->token[i - 1].objPtr) += 2;
}
}
|
| ︙ | ︙ | |||
13642 13643 13644 13645 13646 13647 13648 |
}
else if (expr->token[right_index].type == JIM_EXPROP_COLON_LEFT && ternary_count == 1) {
return right_index;
}
right_index--;
}
| | | 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 |
}
else if (expr->token[right_index].type == JIM_EXPROP_COLON_LEFT && ternary_count == 1) {
return right_index;
}
right_index--;
}
return -1;
}
static int ExprTernaryGetMoveIndices(ExprByteCode *expr, int right_index, int *prev_right_index, int *prev_left_index)
{
int i = right_index - 1;
int ternary_count = 1;
|
| ︙ | ︙ | |||
13684 13685 13686 13687 13688 13689 13690 |
int j;
ScriptToken tmp;
if (expr->token[i].type != JIM_EXPROP_COLON_RIGHT) {
continue;
}
| | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | < | < < | | | | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 |
int j;
ScriptToken tmp;
if (expr->token[i].type != JIM_EXPROP_COLON_RIGHT) {
continue;
}
if (ExprTernaryGetMoveIndices(expr, i, &prev_right_index, &prev_left_index) == 0) {
continue;
}
tmp = expr->token[prev_right_index];
for (j = prev_right_index; j < i; j++) {
expr->token[j] = expr->token[j + 1];
}
expr->token[i] = tmp;
JimWideValue(expr->token[prev_left_index-1].objPtr) += (i - prev_right_index);
i++;
}
}
static ExprByteCode *ExprCreateByteCode(Jim_Interp *interp, const ParseTokenList *tokenlist, Jim_Obj *fileNameObj)
{
Jim_Stack stack;
ExprByteCode *expr;
int ok = 1;
int i;
int prevtt = JIM_TT_NONE;
int have_ternary = 0;
int count = tokenlist->count - 1;
expr = Jim_Alloc(sizeof(*expr));
expr->inUse = 1;
expr->len = 0;
Jim_InitStack(&stack);
for (i = 0; i < tokenlist->count; i++) {
ParseToken *t = &tokenlist->list[i];
const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(t->type);
if (op->lazy == LAZY_OP) {
count += 2;
if (t->type == JIM_EXPROP_TERNARY) {
have_ternary = 1;
}
}
}
expr->token = Jim_Alloc(sizeof(ScriptToken) * count);
for (i = 0; i < tokenlist->count && ok; i++) {
ParseToken *t = &tokenlist->list[i];
struct ScriptToken *token = &expr->token[expr->len];
if (t->type == JIM_TT_EOL) {
break;
}
switch (t->type) {
case JIM_TT_STR:
case JIM_TT_ESC:
case JIM_TT_VAR:
case JIM_TT_DICTSUGAR:
case JIM_TT_EXPRSUGAR:
case JIM_TT_CMD:
token->type = t->type;
strexpr:
token->objPtr = Jim_NewStringObj(interp, t->token, t->len);
if (t->type == JIM_TT_CMD) {
JimSetSourceInfo(interp, token->objPtr, fileNameObj, t->line);
}
expr->len++;
break;
case JIM_TT_EXPR_INT:
case JIM_TT_EXPR_DOUBLE:
{
char *endptr;
if (t->type == JIM_TT_EXPR_INT) {
token->objPtr = Jim_NewIntObj(interp, jim_strtoull(t->token, &endptr));
}
else {
token->objPtr = Jim_NewDoubleObj(interp, strtod(t->token, &endptr));
}
if (endptr != t->token + t->len) {
Jim_FreeNewObj(interp, token->objPtr);
token->type = JIM_TT_STR;
goto strexpr;
}
token->type = t->type;
expr->len++;
}
break;
case JIM_TT_SUBEXPR_START:
Jim_StackPush(&stack, t);
prevtt = JIM_TT_NONE;
continue;
case JIM_TT_SUBEXPR_COMMA:
continue;
case JIM_TT_SUBEXPR_END:
ok = 0;
while (Jim_StackLen(&stack)) {
ParseToken *tt = Jim_StackPop(&stack);
if (tt->type == JIM_TT_SUBEXPR_START) {
ok = 1;
break;
}
if (ExprAddOperator(interp, expr, tt) != JIM_OK) {
goto err;
}
}
if (!ok) {
Jim_SetResultString(interp, "Unexpected close parenthesis", -1);
goto err;
}
break;
default:{
const struct Jim_ExprOperator *op;
ParseToken *tt;
if (prevtt == JIM_TT_NONE || prevtt >= JIM_TT_EXPR_OP) {
if (t->type == JIM_EXPROP_SUB) {
t->type = JIM_EXPROP_UNARYMINUS;
}
else if (t->type == JIM_EXPROP_ADD) {
t->type = JIM_EXPROP_UNARYPLUS;
}
}
op = JimExprOperatorInfoByOpcode(t->type);
while ((tt = Jim_StackPeek(&stack)) != NULL) {
const struct Jim_ExprOperator *tt_op =
JimExprOperatorInfoByOpcode(tt->type);
if (op->arity != 1 && tt_op->precedence >= op->precedence) {
if (ExprAddOperator(interp, expr, tt) != JIM_OK) {
ok = 0;
goto err;
}
Jim_StackPop(&stack);
}
else {
break;
}
}
Jim_StackPush(&stack, t);
break;
}
}
prevtt = t->type;
}
while (Jim_StackLen(&stack)) {
ParseToken *tt = Jim_StackPop(&stack);
if (tt->type == JIM_TT_SUBEXPR_START) {
ok = 0;
Jim_SetResultString(interp, "Missing close parenthesis", -1);
goto err;
}
if (ExprAddOperator(interp, expr, tt) != JIM_OK) {
ok = 0;
goto err;
}
}
if (have_ternary) {
ExprTernaryReorderExpression(interp, expr);
}
err:
Jim_FreeStack(&stack);
for (i = 0; i < expr->len; i++) {
Jim_IncrRefCount(expr->token[i].objPtr);
}
if (!ok) {
|
| ︙ | ︙ | |||
13902 13903 13904 13905 13906 13907 13908 |
struct JimParserCtx parser;
struct ExprByteCode *expr;
ParseTokenList tokenlist;
int line;
Jim_Obj *fileNameObj;
int rc = JIM_ERR;
| | | > | 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 |
struct JimParserCtx parser;
struct ExprByteCode *expr;
ParseTokenList tokenlist;
int line;
Jim_Obj *fileNameObj;
int rc = JIM_ERR;
if (objPtr->typePtr == &sourceObjType) {
fileNameObj = objPtr->internalRep.sourceValue.fileNameObj;
line = objPtr->internalRep.sourceValue.lineNumber;
}
else {
fileNameObj = interp->emptyObj;
line = 1;
}
Jim_IncrRefCount(fileNameObj);
exprText = Jim_GetString(objPtr, &exprTextLen);
ScriptTokenListInit(&tokenlist);
JimParserInit(&parser, exprText, exprTextLen, line);
while (!parser.eof) {
if (JimParseExpression(&parser) != JIM_OK) {
ScriptTokenListFree(&tokenlist);
invalidexpr:
Jim_SetResultFormatted(interp, "syntax error in expression: \"%#s\"", objPtr);
expr = NULL;
goto err;
}
ScriptAddToken(&tokenlist, parser.tstart, parser.tend - parser.tstart + 1, parser.tt,
parser.tline);
|
| ︙ | ︙ | |||
13948 13949 13950 13951 13952 13953 13954 |
if (JimParseCheckMissing(interp, parser.missing.ch) == JIM_ERR) {
ScriptTokenListFree(&tokenlist);
Jim_DecrRefCount(interp, fileNameObj);
return JIM_ERR;
}
| | | | | | < < | | | 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 |
if (JimParseCheckMissing(interp, parser.missing.ch) == JIM_ERR) {
ScriptTokenListFree(&tokenlist);
Jim_DecrRefCount(interp, fileNameObj);
return JIM_ERR;
}
expr = ExprCreateByteCode(interp, &tokenlist, fileNameObj);
ScriptTokenListFree(&tokenlist);
if (!expr) {
goto err;
}
#ifdef DEBUG_SHOW_EXPR
{
int i;
printf("==== Expr ====\n");
for (i = 0; i < expr->len; i++) {
ScriptToken *t = &expr->token[i];
printf("[%2d] %s '%s'\n", i, jim_tt_name(t->type), Jim_String(t->objPtr));
}
}
#endif
if (ExprCheckCorrectness(expr) != JIM_OK) {
ExprFreeByteCode(interp, expr);
goto invalidexpr;
}
rc = JIM_OK;
err:
Jim_DecrRefCount(interp, fileNameObj);
Jim_FreeIntRep(interp, objPtr);
Jim_SetIntRepPtr(objPtr, expr);
objPtr->typePtr = &exprObjType;
return rc;
}
|
| ︙ | ︙ | |||
14026 14027 14028 14029 14030 14031 14032 |
Jim_Obj *staticStack[JIM_EE_STATICSTACK_LEN];
int i;
int retcode = JIM_OK;
struct JimExprState e;
expr = JimGetExpression(interp, exprObjPtr);
if (!expr) {
| | | 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 |
Jim_Obj *staticStack[JIM_EE_STATICSTACK_LEN];
int i;
int retcode = JIM_OK;
struct JimExprState e;
expr = JimGetExpression(interp, exprObjPtr);
if (!expr) {
return JIM_ERR;
}
#ifdef JIM_OPTIMIZATION
{
Jim_Obj *objPtr;
|
| ︙ | ︙ | |||
14099 14100 14101 14102 14103 14104 14105 |
}
}
noopt:
#endif
expr->inUse++;
| | | < | 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 |
}
}
noopt:
#endif
expr->inUse++;
if (expr->len > JIM_EE_STATICSTACK_LEN)
e.stack = Jim_Alloc(sizeof(Jim_Obj *) * expr->len);
else
e.stack = staticStack;
e.stacklen = 0;
for (i = 0; i < expr->len && retcode == JIM_OK; i++) {
Jim_Obj *objPtr;
switch (expr->token[i].type) {
case JIM_TT_EXPR_INT:
case JIM_TT_EXPR_DOUBLE:
case JIM_TT_STR:
ExprPush(&e, expr->token[i].objPtr);
break;
case JIM_TT_VAR:
objPtr = Jim_GetVariable(interp, expr->token[i].objPtr, JIM_ERRMSG);
if (objPtr) {
|
| ︙ | ︙ | |||
14155 14156 14157 14158 14159 14160 14161 |
retcode = Jim_EvalObj(interp, expr->token[i].objPtr);
if (retcode == JIM_OK) {
ExprPush(&e, Jim_GetResult(interp));
}
break;
default:{
| | | | 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 |
retcode = Jim_EvalObj(interp, expr->token[i].objPtr);
if (retcode == JIM_OK) {
ExprPush(&e, Jim_GetResult(interp));
}
break;
default:{
e.skip = 0;
e.opcode = expr->token[i].type;
retcode = JimExprOperatorInfoByOpcode(e.opcode)->funcop(interp, &e);
i += e.skip;
continue;
}
}
}
expr->inUse--;
|
| ︙ | ︙ | |||
14188 14189 14190 14191 14192 14193 14194 |
}
int Jim_GetBoolFromExpr(Jim_Interp *interp, Jim_Obj *exprObjPtr, int *boolPtr)
{
int retcode;
jim_wide wideValue;
double doubleValue;
| < < | | < < < < < | | | | | | | | | | | | | | | 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 |
}
int Jim_GetBoolFromExpr(Jim_Interp *interp, Jim_Obj *exprObjPtr, int *boolPtr)
{
int retcode;
jim_wide wideValue;
double doubleValue;
Jim_Obj *exprResultPtr;
retcode = Jim_EvalExpression(interp, exprObjPtr, &exprResultPtr);
if (retcode != JIM_OK)
return retcode;
if (JimGetWideNoErr(interp, exprResultPtr, &wideValue) != JIM_OK) {
if (Jim_GetDouble(interp, exprResultPtr, &doubleValue) != JIM_OK) {
Jim_DecrRefCount(interp, exprResultPtr);
return JIM_ERR;
}
else {
Jim_DecrRefCount(interp, exprResultPtr);
*boolPtr = doubleValue != 0;
return JIM_OK;
}
}
*boolPtr = wideValue != 0;
Jim_DecrRefCount(interp, exprResultPtr);
return JIM_OK;
}
typedef struct ScanFmtPartDescr
{
char *arg;
char *prefix;
size_t width;
int pos;
char type;
char modifier;
} ScanFmtPartDescr;
typedef struct ScanFmtStringObj
{
jim_wide size;
char *stringRep;
size_t count;
size_t convCount;
size_t maxPos;
const char *error;
char *scratch;
ScanFmtPartDescr descr[1];
} ScanFmtStringObj;
static void FreeScanFmtInternalRep(Jim_Interp *interp, Jim_Obj *objPtr);
static void DupScanFmtInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr);
static void UpdateStringOfScanFmt(Jim_Obj *objPtr);
|
| ︙ | ︙ | |||
14292 14293 14294 14295 14296 14297 14298 |
int maxCount, i, approxSize, lastPos = -1;
const char *fmt = objPtr->bytes;
int maxFmtLen = objPtr->length;
const char *fmtEnd = fmt + maxFmtLen;
int curr;
Jim_FreeIntRep(interp, objPtr);
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 |
int maxCount, i, approxSize, lastPos = -1;
const char *fmt = objPtr->bytes;
int maxFmtLen = objPtr->length;
const char *fmtEnd = fmt + maxFmtLen;
int curr;
Jim_FreeIntRep(interp, objPtr);
for (i = 0, maxCount = 0; i < maxFmtLen; ++i)
if (fmt[i] == '%')
++maxCount;
approxSize = sizeof(ScanFmtStringObj)
+(maxCount + 1) * sizeof(ScanFmtPartDescr)
+maxFmtLen * sizeof(char) + 3 + 1
+ maxFmtLen * sizeof(char) + 1
+ maxFmtLen * sizeof(char)
+(maxCount + 1) * sizeof(char)
+1;
fmtObj = (ScanFmtStringObj *) Jim_Alloc(approxSize);
memset(fmtObj, 0, approxSize);
fmtObj->size = approxSize;
fmtObj->maxPos = 0;
fmtObj->scratch = (char *)&fmtObj->descr[maxCount + 1];
fmtObj->stringRep = fmtObj->scratch + maxFmtLen + 3 + 1;
memcpy(fmtObj->stringRep, fmt, maxFmtLen);
buffer = fmtObj->stringRep + maxFmtLen + 1;
objPtr->internalRep.ptr = fmtObj;
objPtr->typePtr = &scanFmtStringObjType;
for (i = 0, curr = 0; fmt < fmtEnd; ++fmt) {
int width = 0, skip;
ScanFmtPartDescr *descr = &fmtObj->descr[curr];
fmtObj->count++;
descr->width = 0;
if (*fmt != '%' || fmt[1] == '%') {
descr->type = 0;
descr->prefix = &buffer[i];
for (; fmt < fmtEnd; ++fmt) {
if (*fmt == '%') {
if (fmt[1] != '%')
break;
++fmt;
}
buffer[i++] = *fmt;
}
buffer[i++] = 0;
}
++fmt;
if (fmt >= fmtEnd)
goto done;
descr->pos = 0;
if (*fmt == '*') {
descr->pos = -1;
++fmt;
}
else
fmtObj->convCount++;
if (sscanf(fmt, "%d%n", &width, &skip) == 1) {
fmt += skip;
if (descr->pos != -1 && *fmt == '$') {
int prev;
++fmt;
descr->pos = width;
width = 0;
if ((lastPos == 0 && descr->pos > 0)
|| (lastPos > 0 && descr->pos == 0)) {
fmtObj->error = "cannot mix \"%\" and \"%n$\" conversion specifiers";
return JIM_ERR;
}
for (prev = 0; prev < curr; ++prev) {
if (fmtObj->descr[prev].pos == -1)
continue;
if (fmtObj->descr[prev].pos == descr->pos) {
fmtObj->error =
"variable is assigned by multiple \"%n$\" conversion specifiers";
return JIM_ERR;
}
}
if (sscanf(fmt, "%d%n", &width, &skip) == 1) {
descr->width = width;
fmt += skip;
}
if (descr->pos > 0 && (size_t) descr->pos > fmtObj->maxPos)
fmtObj->maxPos = descr->pos;
}
else {
descr->width = width;
}
}
if (lastPos == -1)
lastPos = descr->pos;
if (*fmt == '[') {
int swapped = 1, beg = i, end, j;
descr->type = '[';
descr->arg = &buffer[i];
++fmt;
if (*fmt == '^')
buffer[i++] = *fmt++;
if (*fmt == ']')
buffer[i++] = *fmt++;
while (*fmt && *fmt != ']')
buffer[i++] = *fmt++;
if (*fmt != ']') {
fmtObj->error = "unmatched [ in format string";
return JIM_ERR;
}
end = i;
buffer[i++] = 0;
while (swapped) {
swapped = 0;
for (j = beg + 1; j < end - 1; ++j) {
if (buffer[j] == '-' && buffer[j - 1] > buffer[j + 1]) {
char tmp = buffer[j - 1];
buffer[j - 1] = buffer[j + 1];
buffer[j + 1] = tmp;
swapped = 1;
}
}
}
}
else {
if (strchr("hlL", *fmt) != 0)
descr->modifier = tolower((int)*fmt++);
descr->type = *fmt;
if (strchr("efgcsndoxui", *fmt) == 0) {
fmtObj->error = "bad scan conversion character";
return JIM_ERR;
|
| ︙ | ︙ | |||
14465 14466 14467 14468 14469 14470 14471 |
char *p = buffer;
while (*str) {
int c;
int n;
if (!sdescr && isspace(UCHAR(*str)))
| | | 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 |
char *p = buffer;
while (*str) {
int c;
int n;
if (!sdescr && isspace(UCHAR(*str)))
break;
n = utf8_tounicode(str, &c);
if (sdescr && !JimCharsetMatch(sdescr, c, JIM_CHARSET_SCAN))
break;
while (n--)
*p++ = *str++;
}
|
| ︙ | ︙ | |||
14488 14489 14490 14491 14492 14493 14494 |
const char *tok;
const ScanFmtPartDescr *descr = &fmtObj->descr[idx];
size_t scanned = 0;
size_t anchor = pos;
int i;
Jim_Obj *tmpObj = NULL;
| | | | | | | | | | | | | | | | | | | | | 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 |
const char *tok;
const ScanFmtPartDescr *descr = &fmtObj->descr[idx];
size_t scanned = 0;
size_t anchor = pos;
int i;
Jim_Obj *tmpObj = NULL;
*valObjPtr = 0;
if (descr->prefix) {
for (i = 0; pos < strLen && descr->prefix[i]; ++i) {
if (isspace(UCHAR(descr->prefix[i])))
while (pos < strLen && isspace(UCHAR(str[pos])))
++pos;
else if (descr->prefix[i] != str[pos])
break;
else
++pos;
}
if (pos >= strLen) {
return -1;
}
else if (descr->prefix[i] != 0)
return 0;
}
if (descr->type != 'c' && descr->type != '[' && descr->type != 'n')
while (isspace(UCHAR(str[pos])))
++pos;
scanned = pos - anchor;
if (descr->type == 'n') {
*valObjPtr = Jim_NewIntObj(interp, anchor + scanned);
}
else if (pos >= strLen) {
return -1;
}
else if (descr->type == 'c') {
int c;
scanned += utf8_tounicode(&str[pos], &c);
*valObjPtr = Jim_NewIntObj(interp, c);
return scanned;
}
else {
if (descr->width > 0) {
size_t sLen = utf8_strlen(&str[pos], strLen - pos);
size_t tLen = descr->width > sLen ? sLen : descr->width;
tmpObj = Jim_NewStringObjUtf8(interp, str + pos, tLen);
tok = tmpObj->bytes;
}
else {
tok = &str[pos];
}
switch (descr->type) {
case 'd':
case 'o':
case 'x':
case 'u':
case 'i':{
char *endp;
jim_wide w;
int base = descr->type == 'o' ? 8
: descr->type == 'x' ? 16 : descr->type == 'i' ? 0 : 10;
if (base == 0) {
w = jim_strtoull(tok, &endp);
}
else {
w = strtoull(tok, &endp, base);
}
if (endp != tok) {
*valObjPtr = Jim_NewIntObj(interp, w);
scanned += endp - tok;
}
else {
scanned = *tok ? 0 : -1;
}
break;
}
case 's':
case '[':{
*valObjPtr = JimScanAString(interp, descr->arg, tok);
scanned += Jim_Length(*valObjPtr);
break;
}
case 'e':
case 'f':
case 'g':{
char *endp;
double value = strtod(tok, &endp);
if (endp != tok) {
*valObjPtr = Jim_NewDoubleObj(interp, value);
scanned += endp - tok;
}
else {
scanned = *tok ? 0 : -1;
}
break;
}
|
| ︙ | ︙ | |||
14618 14619 14620 14621 14622 14623 14624 |
int strLen = Jim_Utf8Length(interp, strObjPtr);
Jim_Obj *resultList = 0;
Jim_Obj **resultVec = 0;
int resultc;
Jim_Obj *emptyStr = 0;
ScanFmtStringObj *fmtObj;
| | | | | | | | | | | | | | | | 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 |
int strLen = Jim_Utf8Length(interp, strObjPtr);
Jim_Obj *resultList = 0;
Jim_Obj **resultVec = 0;
int resultc;
Jim_Obj *emptyStr = 0;
ScanFmtStringObj *fmtObj;
JimPanic((fmtObjPtr->typePtr != &scanFmtStringObjType, "Jim_ScanString() for non-scan format"));
fmtObj = (ScanFmtStringObj *) fmtObjPtr->internalRep.ptr;
if (fmtObj->error != 0) {
if (flags & JIM_ERRMSG)
Jim_SetResultString(interp, fmtObj->error, -1);
return 0;
}
emptyStr = Jim_NewEmptyStringObj(interp);
Jim_IncrRefCount(emptyStr);
resultList = Jim_NewListObj(interp, NULL, 0);
if (fmtObj->maxPos > 0) {
for (i = 0; i < fmtObj->maxPos; ++i)
Jim_ListAppendElement(interp, resultList, emptyStr);
JimListGetElements(interp, resultList, &resultc, &resultVec);
}
for (i = 0, pos = 0; i < fmtObj->count; ++i) {
ScanFmtPartDescr *descr = &(fmtObj->descr[i]);
Jim_Obj *value = 0;
if (descr->type == 0)
continue;
if (scanned > 0)
scanned = ScanOneEntry(interp, str, pos, strLen, fmtObj, i, &value);
if (scanned == -1 && i == 0)
goto eof;
pos += scanned;
if (value == 0)
value = Jim_NewEmptyStringObj(interp);
if (descr->pos == -1) {
Jim_FreeNewObj(interp, value);
}
else if (descr->pos == 0)
Jim_ListAppendElement(interp, resultList, value);
else if (resultVec[descr->pos - 1] == emptyStr) {
Jim_DecrRefCount(interp, resultVec[descr->pos - 1]);
Jim_IncrRefCount(value);
resultVec[descr->pos - 1] = value;
}
else {
Jim_FreeNewObj(interp, value);
goto err;
}
}
Jim_DecrRefCount(interp, emptyStr);
return resultList;
eof:
|
| ︙ | ︙ | |||
14714 14715 14716 14717 14718 14719 14720 |
static void JimRandomBytes(Jim_Interp *interp, void *dest, unsigned int len)
{
Jim_PrngState *prng;
unsigned char *destByte = (unsigned char *)dest;
unsigned int si, sj, x;
| | | | | | | 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 |
static void JimRandomBytes(Jim_Interp *interp, void *dest, unsigned int len)
{
Jim_PrngState *prng;
unsigned char *destByte = (unsigned char *)dest;
unsigned int si, sj, x;
if (interp->prngState == NULL)
JimPrngInit(interp);
prng = interp->prngState;
for (x = 0; x < len; x++) {
prng->i = (prng->i + 1) & 0xff;
si = prng->sbox[prng->i];
prng->j = (prng->j + si) & 0xff;
sj = prng->sbox[prng->j];
prng->sbox[prng->i] = sj;
prng->sbox[prng->j] = si;
*destByte++ = prng->sbox[(si + sj) & 0xff];
}
}
static void JimPrngSeed(Jim_Interp *interp, unsigned char *seed, int seedLen)
{
int i;
Jim_PrngState *prng;
if (interp->prngState == NULL)
JimPrngInit(interp);
prng = interp->prngState;
for (i = 0; i < 256; i++)
prng->sbox[i] = i;
for (i = 0; i < seedLen; i++) {
unsigned char t;
t = prng->sbox[i & 0xFF];
prng->sbox[i & 0xFF] = prng->sbox[seed[i]];
prng->sbox[seed[i]] = t;
}
|
| ︙ | ︙ | |||
14775 14776 14777 14778 14779 14780 14781 |
}
if (argc == 3) {
if (Jim_GetWide(interp, argv[2], &increment) != JIM_OK)
return JIM_ERR;
}
intObjPtr = Jim_GetVariable(interp, argv[1], JIM_UNSHARED);
if (!intObjPtr) {
| | | | | | | | | 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 |
}
if (argc == 3) {
if (Jim_GetWide(interp, argv[2], &increment) != JIM_OK)
return JIM_ERR;
}
intObjPtr = Jim_GetVariable(interp, argv[1], JIM_UNSHARED);
if (!intObjPtr) {
wideValue = 0;
}
else if (Jim_GetWide(interp, intObjPtr, &wideValue) != JIM_OK) {
return JIM_ERR;
}
if (!intObjPtr || Jim_IsShared(intObjPtr)) {
intObjPtr = Jim_NewIntObj(interp, wideValue + increment);
if (Jim_SetVariable(interp, argv[1], intObjPtr) != JIM_OK) {
Jim_FreeNewObj(interp, intObjPtr);
return JIM_ERR;
}
}
else {
Jim_InvalidateStringRep(intObjPtr);
JimWideValue(intObjPtr) = wideValue + increment;
if (argv[1]->typePtr != &variableObjType) {
Jim_SetVariable(interp, argv[1], intObjPtr);
}
}
Jim_SetResult(interp, intObjPtr);
return JIM_OK;
}
#define JIM_EVAL_SARGV_LEN 8
#define JIM_EVAL_SINTV_LEN 8
static int JimUnknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int retcode;
if (interp->unknown_called > 50) {
return JIM_ERR;
}
if (Jim_GetCommand(interp, interp->unknown, JIM_NONE) == NULL)
return JIM_ERR;
interp->unknown_called++;
retcode = Jim_EvalObjPrefix(interp, interp->unknown, argc, argv);
interp->unknown_called--;
return retcode;
}
static int JimInvokeCommand(Jim_Interp *interp, int objc, Jim_Obj *const *objv)
|
| ︙ | ︙ | |||
14843 14844 14845 14846 14847 14848 14849 |
for (j = 0; j < objc; j++) {
printf(" '%s'", Jim_String(objv[j]));
}
printf("\n");
#endif
if (interp->framePtr->tailcallCmd) {
| | | | | | 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 |
for (j = 0; j < objc; j++) {
printf(" '%s'", Jim_String(objv[j]));
}
printf("\n");
#endif
if (interp->framePtr->tailcallCmd) {
cmdPtr = interp->framePtr->tailcallCmd;
interp->framePtr->tailcallCmd = NULL;
}
else {
cmdPtr = Jim_GetCommand(interp, objv[0], JIM_ERRMSG);
if (cmdPtr == NULL) {
return JimUnknown(interp, objc, objv);
}
JimIncrCmdRefCount(cmdPtr);
}
if (interp->evalDepth == interp->maxEvalDepth) {
Jim_SetResultString(interp, "Infinite eval recursion", -1);
retcode = JIM_ERR;
goto out;
}
interp->evalDepth++;
Jim_SetEmptyResult(interp);
if (cmdPtr->isproc) {
retcode = JimCallProcedure(interp, cmdPtr, objc, objv);
}
else {
interp->cmdPrivData = cmdPtr->u.native.privData;
retcode = cmdPtr->u.native.cmdProc(interp, objc, objv);
}
interp->evalDepth--;
out:
JimDecrCmdRefCount(interp, cmdPtr);
return retcode;
}
int Jim_EvalObjVector(Jim_Interp *interp, int objc, Jim_Obj *const *objv)
{
int i, retcode;
for (i = 0; i < objc; i++)
Jim_IncrRefCount(objv[i]);
retcode = JimInvokeCommand(interp, objc, objv);
for (i = 0; i < objc; i++)
Jim_DecrRefCount(interp, objv[i]);
return retcode;
}
int Jim_EvalObjPrefix(Jim_Interp *interp, Jim_Obj *prefix, int objc, Jim_Obj *const *objv)
|
| ︙ | ︙ | |||
14911 14912 14913 14914 14915 14916 14917 |
Jim_Free(nargv);
return ret;
}
static void JimAddErrorToStack(Jim_Interp *interp, ScriptObj *script)
{
if (!interp->errorFlag) {
| | | | | | 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 |
Jim_Free(nargv);
return ret;
}
static void JimAddErrorToStack(Jim_Interp *interp, ScriptObj *script)
{
if (!interp->errorFlag) {
interp->errorFlag = 1;
Jim_IncrRefCount(script->fileNameObj);
Jim_DecrRefCount(interp, interp->errorFileNameObj);
interp->errorFileNameObj = script->fileNameObj;
interp->errorLine = script->linenr;
JimResetStackTrace(interp);
interp->addStackTrace++;
}
if (interp->addStackTrace > 0) {
JimAppendStackTrace(interp, Jim_String(interp->errorProc), script->fileNameObj, script->linenr);
if (Jim_Length(script->fileNameObj)) {
interp->addStackTrace = 0;
}
|
| ︙ | ︙ | |||
14964 14965 14966 14967 14968 14969 14970 |
case JIM_TT_CMD:
switch (Jim_EvalObj(interp, token->objPtr)) {
case JIM_OK:
case JIM_RETURN:
objPtr = interp->result;
break;
case JIM_BREAK:
| | | | 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 |
case JIM_TT_CMD:
switch (Jim_EvalObj(interp, token->objPtr)) {
case JIM_OK:
case JIM_RETURN:
objPtr = interp->result;
break;
case JIM_BREAK:
return JIM_BREAK;
case JIM_CONTINUE:
return JIM_CONTINUE;
default:
return JIM_ERR;
}
break;
default:
JimPanic((1,
|
| ︙ | ︙ | |||
15006 15007 15008 15009 15010 15011 15012 |
for (i = 0; i < tokens; i++) {
switch (JimSubstOneToken(interp, &token[i], &intv[i])) {
case JIM_OK:
case JIM_RETURN:
break;
case JIM_BREAK:
if (flags & JIM_SUBST_FLAG) {
| | | | | | | | | | | 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 |
for (i = 0; i < tokens; i++) {
switch (JimSubstOneToken(interp, &token[i], &intv[i])) {
case JIM_OK:
case JIM_RETURN:
break;
case JIM_BREAK:
if (flags & JIM_SUBST_FLAG) {
tokens = i;
continue;
}
case JIM_CONTINUE:
if (flags & JIM_SUBST_FLAG) {
intv[i] = NULL;
continue;
}
default:
while (i--) {
Jim_DecrRefCount(interp, intv[i]);
}
if (intv != sintv) {
Jim_Free(intv);
}
return NULL;
}
Jim_IncrRefCount(intv[i]);
Jim_String(intv[i]);
totlen += intv[i]->length;
}
if (tokens == 1 && intv[0] && intv == sintv) {
Jim_DecrRefCount(interp, intv[0]);
return intv[0];
}
objPtr = Jim_NewStringObjNoAlloc(interp, NULL, 0);
if (tokens == 4 && token[0].type == JIM_TT_ESC && token[1].type == JIM_TT_ESC
&& token[2].type == JIM_TT_VAR) {
objPtr->typePtr = &interpolatedObjType;
objPtr->internalRep.dictSubstValue.varNameObjPtr = token[0].objPtr;
objPtr->internalRep.dictSubstValue.indexObjPtr = intv[2];
Jim_IncrRefCount(intv[2]);
}
else if (tokens && intv[0] && intv[0]->typePtr == &sourceObjType) {
JimSetSourceInfo(interp, objPtr, intv[0]->internalRep.sourceValue.fileNameObj, intv[0]->internalRep.sourceValue.lineNumber);
}
s = objPtr->bytes = Jim_Alloc(totlen + 1);
objPtr->length = totlen;
for (i = 0; i < tokens; i++) {
if (intv[i]) {
memcpy(s, intv[i]->bytes, intv[i]->length);
s += intv[i]->length;
Jim_DecrRefCount(interp, intv[i]);
}
}
objPtr->bytes[totlen] = '\0';
if (intv != sintv) {
Jim_Free(intv);
}
return objPtr;
}
|
| ︙ | ︙ | |||
15109 15110 15111 15112 15113 15114 15115 |
Jim_Obj *sargv[JIM_EVAL_SARGV_LEN], **argv = NULL;
Jim_Obj *prevScriptObj;
if (Jim_IsList(scriptObjPtr) && scriptObjPtr->bytes == NULL) {
return JimEvalObjList(interp, scriptObjPtr);
}
| | | 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 |
Jim_Obj *sargv[JIM_EVAL_SARGV_LEN], **argv = NULL;
Jim_Obj *prevScriptObj;
if (Jim_IsList(scriptObjPtr) && scriptObjPtr->bytes == NULL) {
return JimEvalObjList(interp, scriptObjPtr);
}
Jim_IncrRefCount(scriptObjPtr);
script = JimGetScript(interp, scriptObjPtr);
if (!JimScriptValid(interp, script)) {
Jim_DecrRefCount(interp, scriptObjPtr);
return JIM_ERR;
}
Jim_SetEmptyResult(interp);
|
| ︙ | ︙ | |||
15145 15146 15147 15148 15149 15150 15151 |
return JIM_OK;
}
}
#endif
script->inUse++;
| | | | | | 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 |
return JIM_OK;
}
}
#endif
script->inUse++;
prevScriptObj = interp->currentScriptObj;
interp->currentScriptObj = scriptObjPtr;
interp->errorFlag = 0;
argv = sargv;
for (i = 0; i < script->len && retcode == JIM_OK; ) {
int argc;
int j;
argc = token[i].objPtr->internalRep.scriptLineValue.argc;
script->linenr = token[i].objPtr->internalRep.scriptLineValue.line;
if (argc > JIM_EVAL_SARGV_LEN)
argv = Jim_Alloc(sizeof(Jim_Obj *) * argc);
i++;
for (j = 0; j < argc; j++) {
long wordtokens = 1;
int expand = 0;
Jim_Obj *wordObjPtr = NULL;
|
| ︙ | ︙ | |||
15224 15225 15226 15227 15228 15229 15230 |
Jim_IncrRefCount(wordObjPtr);
i += wordtokens;
if (!expand) {
argv[j] = wordObjPtr;
}
else {
| | | | | | | | | | | | | | | | | | | 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 |
Jim_IncrRefCount(wordObjPtr);
i += wordtokens;
if (!expand) {
argv[j] = wordObjPtr;
}
else {
int len = Jim_ListLength(interp, wordObjPtr);
int newargc = argc + len - 1;
int k;
if (len > 1) {
if (argv == sargv) {
if (newargc > JIM_EVAL_SARGV_LEN) {
argv = Jim_Alloc(sizeof(*argv) * newargc);
memcpy(argv, sargv, sizeof(*argv) * j);
}
}
else {
argv = Jim_Realloc(argv, sizeof(*argv) * newargc);
}
}
for (k = 0; k < len; k++) {
argv[j++] = wordObjPtr->internalRep.listValue.ele[k];
Jim_IncrRefCount(wordObjPtr->internalRep.listValue.ele[k]);
}
Jim_DecrRefCount(interp, wordObjPtr);
j--;
argc += len - 1;
}
}
if (retcode == JIM_OK && argc) {
retcode = JimInvokeCommand(interp, argc, argv);
if (Jim_CheckSignal(interp)) {
retcode = JIM_SIGNAL;
}
}
while (j-- > 0) {
Jim_DecrRefCount(interp, argv[j]);
}
if (argv != sargv) {
Jim_Free(argv);
argv = sargv;
}
}
if (retcode == JIM_ERR) {
JimAddErrorToStack(interp, script);
}
else if (retcode != JIM_RETURN || interp->returnCode != JIM_ERR) {
interp->addStackTrace = 0;
}
interp->currentScriptObj = prevScriptObj;
Jim_FreeIntRep(interp, scriptObjPtr);
scriptObjPtr->typePtr = &scriptObjType;
Jim_SetIntRepPtr(scriptObjPtr, script);
Jim_DecrRefCount(interp, scriptObjPtr);
return retcode;
}
static int JimSetProcArg(Jim_Interp *interp, Jim_Obj *argNameObj, Jim_Obj *argValObj)
{
int retcode;
const char *varname = Jim_String(argNameObj);
if (*varname == '&') {
Jim_Obj *objPtr;
Jim_CallFrame *savedCallFrame = interp->framePtr;
interp->framePtr = interp->framePtr->parent;
objPtr = Jim_GetVariable(interp, argValObj, JIM_ERRMSG);
interp->framePtr = savedCallFrame;
if (!objPtr) {
return JIM_ERR;
}
objPtr = Jim_NewStringObj(interp, varname + 1, -1);
Jim_IncrRefCount(objPtr);
retcode = Jim_SetVariableLink(interp, objPtr, argValObj, interp->framePtr->parent);
Jim_DecrRefCount(interp, objPtr);
}
else {
retcode = Jim_SetVariable(interp, argNameObj, argValObj);
}
return retcode;
}
static void JimSetProcWrongArgs(Jim_Interp *interp, Jim_Obj *procNameObj, Jim_Cmd *cmd)
{
Jim_Obj *argmsg = Jim_NewStringObj(interp, "", 0);
int i;
for (i = 0; i < cmd->u.proc.argListLen; i++) {
Jim_AppendString(interp, argmsg, " ", 1);
if (i == cmd->u.proc.argsPos) {
if (cmd->u.proc.arglist[i].defaultObjPtr) {
Jim_AppendString(interp, argmsg, "?", 1);
Jim_AppendObj(interp, argmsg, cmd->u.proc.arglist[i].defaultObjPtr);
Jim_AppendString(interp, argmsg, " ...?", -1);
}
else {
Jim_AppendString(interp, argmsg, "?arg...?", -1);
}
}
else {
if (cmd->u.proc.arglist[i].defaultObjPtr) {
Jim_AppendString(interp, argmsg, "?", 1);
Jim_AppendObj(interp, argmsg, cmd->u.proc.arglist[i].nameObjPtr);
|
| ︙ | ︙ | |||
15372 15373 15374 15375 15376 15377 15378 |
#ifdef jim_ext_namespace
int Jim_EvalNamespace(Jim_Interp *interp, Jim_Obj *scriptObj, Jim_Obj *nsObj)
{
Jim_CallFrame *callFramePtr;
int retcode;
| | | | | | | | | | | | | | | | | | | | | | 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 |
#ifdef jim_ext_namespace
int Jim_EvalNamespace(Jim_Interp *interp, Jim_Obj *scriptObj, Jim_Obj *nsObj)
{
Jim_CallFrame *callFramePtr;
int retcode;
callFramePtr = JimCreateCallFrame(interp, interp->framePtr, nsObj);
callFramePtr->argv = &interp->emptyObj;
callFramePtr->argc = 0;
callFramePtr->procArgsObjPtr = NULL;
callFramePtr->procBodyObjPtr = scriptObj;
callFramePtr->staticVars = NULL;
callFramePtr->fileNameObj = interp->emptyObj;
callFramePtr->line = 0;
Jim_IncrRefCount(scriptObj);
interp->framePtr = callFramePtr;
if (interp->framePtr->level == interp->maxCallFrameDepth) {
Jim_SetResultString(interp, "Too many nested calls. Infinite recursion?", -1);
retcode = JIM_ERR;
}
else {
retcode = Jim_EvalObj(interp, scriptObj);
}
interp->framePtr = interp->framePtr->parent;
JimFreeCallFrame(interp, callFramePtr, JIM_FCF_REUSE);
return retcode;
}
#endif
static int JimCallProcedure(Jim_Interp *interp, Jim_Cmd *cmd, int argc, Jim_Obj *const *argv)
{
Jim_CallFrame *callFramePtr;
int i, d, retcode, optargs;
ScriptObj *script;
if (argc - 1 < cmd->u.proc.reqArity ||
(cmd->u.proc.argsPos < 0 && argc - 1 > cmd->u.proc.reqArity + cmd->u.proc.optArity)) {
JimSetProcWrongArgs(interp, argv[0], cmd);
return JIM_ERR;
}
if (Jim_Length(cmd->u.proc.bodyObjPtr) == 0) {
return JIM_OK;
}
if (interp->framePtr->level == interp->maxCallFrameDepth) {
Jim_SetResultString(interp, "Too many nested calls. Infinite recursion?", -1);
return JIM_ERR;
}
callFramePtr = JimCreateCallFrame(interp, interp->framePtr, cmd->u.proc.nsObj);
callFramePtr->argv = argv;
callFramePtr->argc = argc;
callFramePtr->procArgsObjPtr = cmd->u.proc.argListObjPtr;
callFramePtr->procBodyObjPtr = cmd->u.proc.bodyObjPtr;
callFramePtr->staticVars = cmd->u.proc.staticVars;
script = JimGetScript(interp, interp->currentScriptObj);
callFramePtr->fileNameObj = script->fileNameObj;
callFramePtr->line = script->linenr;
Jim_IncrRefCount(cmd->u.proc.argListObjPtr);
Jim_IncrRefCount(cmd->u.proc.bodyObjPtr);
interp->framePtr = callFramePtr;
optargs = (argc - 1 - cmd->u.proc.reqArity);
i = 1;
for (d = 0; d < cmd->u.proc.argListLen; d++) {
Jim_Obj *nameObjPtr = cmd->u.proc.arglist[d].nameObjPtr;
if (d == cmd->u.proc.argsPos) {
Jim_Obj *listObjPtr;
int argsLen = 0;
if (cmd->u.proc.reqArity + cmd->u.proc.optArity < argc - 1) {
argsLen = argc - 1 - (cmd->u.proc.reqArity + cmd->u.proc.optArity);
}
listObjPtr = Jim_NewListObj(interp, &argv[i], argsLen);
if (cmd->u.proc.arglist[d].defaultObjPtr) {
nameObjPtr =cmd->u.proc.arglist[d].defaultObjPtr;
}
retcode = Jim_SetVariable(interp, nameObjPtr, listObjPtr);
if (retcode != JIM_OK) {
goto badargset;
}
i += argsLen;
continue;
}
if (cmd->u.proc.arglist[d].defaultObjPtr == NULL || optargs-- > 0) {
retcode = JimSetProcArg(interp, nameObjPtr, argv[i++]);
}
else {
retcode = Jim_SetVariable(interp, nameObjPtr, cmd->u.proc.arglist[d].defaultObjPtr);
}
if (retcode != JIM_OK) {
goto badargset;
}
}
retcode = Jim_EvalObj(interp, cmd->u.proc.bodyObjPtr);
badargset:
interp->framePtr = interp->framePtr->parent;
JimFreeCallFrame(interp, callFramePtr, JIM_FCF_REUSE);
if (interp->framePtr->tailcallObj) {
do {
Jim_Obj *tailcallObj = interp->framePtr->tailcallObj;
interp->framePtr->tailcallObj = NULL;
if (retcode == JIM_EVAL) {
retcode = Jim_EvalObjList(interp, tailcallObj);
if (retcode == JIM_RETURN) {
interp->returnLevel++;
}
}
Jim_DecrRefCount(interp, tailcallObj);
} while (interp->framePtr->tailcallObj);
if (interp->framePtr->tailcallCmd) {
JimDecrCmdRefCount(interp, interp->framePtr->tailcallCmd);
interp->framePtr->tailcallCmd = NULL;
}
}
if (retcode == JIM_RETURN) {
if (--interp->returnLevel <= 0) {
retcode = interp->returnCode;
interp->returnCode = JIM_OK;
interp->returnLevel = 0;
}
}
|
| ︙ | ︙ | |||
15633 15634 15635 15636 15637 15638 15639 |
Jim_IncrRefCount(scriptObjPtr);
prevScriptObj = interp->currentScriptObj;
interp->currentScriptObj = scriptObjPtr;
retcode = Jim_EvalObj(interp, scriptObjPtr);
| | | | 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 |
Jim_IncrRefCount(scriptObjPtr);
prevScriptObj = interp->currentScriptObj;
interp->currentScriptObj = scriptObjPtr;
retcode = Jim_EvalObj(interp, scriptObjPtr);
if (retcode == JIM_RETURN) {
if (--interp->returnLevel <= 0) {
retcode = interp->returnCode;
interp->returnCode = JIM_OK;
interp->returnLevel = 0;
}
}
if (retcode == JIM_ERR) {
interp->addStackTrace++;
}
interp->currentScriptObj = prevScriptObj;
Jim_DecrRefCount(interp, scriptObjPtr);
|
| ︙ | ︙ | |||
15672 15673 15674 15675 15676 15677 15678 |
JimParseCmd(pc);
return;
}
if (*pc->p == '$' && !(flags & JIM_SUBST_NOVAR)) {
if (JimParseVar(pc) == JIM_OK) {
return;
}
| | | 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 |
JimParseCmd(pc);
return;
}
if (*pc->p == '$' && !(flags & JIM_SUBST_NOVAR)) {
if (JimParseVar(pc) == JIM_OK) {
return;
}
pc->tstart = pc->p;
flags |= JIM_SUBST_NOVAR;
}
while (pc->len) {
if (*pc->p == '$' && !(flags & JIM_SUBST_NOVAR)) {
break;
}
|
| ︙ | ︙ | |||
15703 15704 15705 15706 15707 15708 15709 |
{
int scriptTextLen;
const char *scriptText = Jim_GetString(objPtr, &scriptTextLen);
struct JimParserCtx parser;
struct ScriptObj *script = Jim_Alloc(sizeof(*script));
ParseTokenList tokenlist;
| | | | | | | < < < < | | 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 |
{
int scriptTextLen;
const char *scriptText = Jim_GetString(objPtr, &scriptTextLen);
struct JimParserCtx parser;
struct ScriptObj *script = Jim_Alloc(sizeof(*script));
ParseTokenList tokenlist;
ScriptTokenListInit(&tokenlist);
JimParserInit(&parser, scriptText, scriptTextLen, 1);
while (1) {
JimParseSubst(&parser, flags);
if (parser.eof) {
break;
}
ScriptAddToken(&tokenlist, parser.tstart, parser.tend - parser.tstart + 1, parser.tt,
parser.tline);
}
script->inUse = 1;
script->substFlags = flags;
script->fileNameObj = interp->emptyObj;
Jim_IncrRefCount(script->fileNameObj);
SubstObjAddTokens(interp, script, &tokenlist);
ScriptTokenListFree(&tokenlist);
#ifdef DEBUG_SHOW_SUBST
{
int i;
printf("==== Subst ====\n");
for (i = 0; i < script->len; i++) {
printf("[%2d] %s '%s'\n", i, jim_tt_name(script->token[i].type),
Jim_String(script->token[i].objPtr));
}
}
#endif
Jim_FreeIntRep(interp, objPtr);
Jim_SetIntRepPtr(objPtr, script);
objPtr->typePtr = &scriptObjType;
return JIM_OK;
}
static ScriptObj *Jim_GetSubst(Jim_Interp *interp, Jim_Obj *objPtr, int flags)
{
if (objPtr->typePtr != &scriptObjType || ((ScriptObj *)Jim_GetIntRepPtr(objPtr))->substFlags != flags)
SetSubstFromAny(interp, objPtr, flags);
return (ScriptObj *) Jim_GetIntRepPtr(objPtr);
}
int Jim_SubstObj(Jim_Interp *interp, Jim_Obj *substObjPtr, Jim_Obj **resObjPtrPtr, int flags)
{
ScriptObj *script = Jim_GetSubst(interp, substObjPtr, flags);
Jim_IncrRefCount(substObjPtr);
script->inUse++;
*resObjPtrPtr = JimInterpolateTokens(interp, script->token, script->len, flags);
script->inUse--;
Jim_DecrRefCount(interp, substObjPtr);
if (*resObjPtrPtr == NULL) {
return JIM_ERR;
}
return JIM_OK;
}
void Jim_WrongNumArgs(Jim_Interp *interp, int argc, Jim_Obj *const *argv, const char *msg)
{
Jim_Obj *objPtr;
Jim_Obj *listObjPtr = Jim_NewListObj(interp, argv, argc);
if (*msg) {
Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, msg, -1));
}
Jim_IncrRefCount(listObjPtr);
objPtr = Jim_ListJoin(interp, listObjPtr, " ", 1);
Jim_DecrRefCount(interp, listObjPtr);
|
| ︙ | ︙ | |||
15802 15803 15804 15805 15806 15807 15808 |
static Jim_Obj *JimHashtablePatternMatch(Jim_Interp *interp, Jim_HashTable *ht, Jim_Obj *patternObjPtr,
JimHashtableIteratorCallbackType *callback, int type)
{
Jim_HashEntry *he;
Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0);
| | | 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 |
static Jim_Obj *JimHashtablePatternMatch(Jim_Interp *interp, Jim_HashTable *ht, Jim_Obj *patternObjPtr,
JimHashtableIteratorCallbackType *callback, int type)
{
Jim_HashEntry *he;
Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0);
if (patternObjPtr && JimTrivialMatch(Jim_String(patternObjPtr))) {
he = Jim_FindHashEntry(ht, Jim_String(patternObjPtr));
if (he) {
callback(interp, listObjPtr, he, type);
}
}
else {
|
| ︙ | ︙ | |||
15833 15834 15835 15836 15837 15838 15839 |
static void JimCommandMatch(Jim_Interp *interp, Jim_Obj *listObjPtr,
Jim_HashEntry *he, int type)
{
Jim_Cmd *cmdPtr = Jim_GetHashEntryVal(he);
Jim_Obj *objPtr;
if (type == JIM_CMDLIST_PROCS && !cmdPtr->isproc) {
| | | 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 |
static void JimCommandMatch(Jim_Interp *interp, Jim_Obj *listObjPtr,
Jim_HashEntry *he, int type)
{
Jim_Cmd *cmdPtr = Jim_GetHashEntryVal(he);
Jim_Obj *objPtr;
if (type == JIM_CMDLIST_PROCS && !cmdPtr->isproc) {
return;
}
objPtr = Jim_NewStringObj(interp, he->key, -1);
Jim_IncrRefCount(objPtr);
if (type != JIM_CMDLIST_CHANNELS || Jim_AioFilehandle(interp, objPtr)) {
|
| ︙ | ︙ | |||
15893 15894 15895 15896 15897 15898 15899 |
{
Jim_CallFrame *targetCallFrame;
targetCallFrame = JimGetCallFrameByInteger(interp, levelObjPtr);
if (targetCallFrame == NULL) {
return JIM_ERR;
}
| | | 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 |
{
Jim_CallFrame *targetCallFrame;
targetCallFrame = JimGetCallFrameByInteger(interp, levelObjPtr);
if (targetCallFrame == NULL) {
return JIM_ERR;
}
if (targetCallFrame == interp->topFramePtr) {
Jim_SetResultFormatted(interp, "bad level \"%#s\"", levelObjPtr);
return JIM_ERR;
}
if (info_level_cmd) {
*objPtrPtr = Jim_NewListObj(interp, targetCallFrame->argv, targetCallFrame->argc);
}
|
| ︙ | ︙ | |||
16080 16081 16082 16083 16084 16085 16086 |
objPtr = Jim_GetVariable(interp, argv[1], JIM_ERRMSG);
if (!objPtr)
return JIM_ERR;
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
| | | 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 |
objPtr = Jim_GetVariable(interp, argv[1], JIM_ERRMSG);
if (!objPtr)
return JIM_ERR;
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
if (Jim_SetVariable(interp, argv[1], argv[2]) != JIM_OK)
return JIM_ERR;
Jim_SetResult(interp, argv[2]);
return JIM_OK;
}
static int Jim_UnsetCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
| ︙ | ︙ | |||
16123 16124 16125 16126 16127 16128 16129 |
static int Jim_WhileCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc != 3) {
Jim_WrongNumArgs(interp, 1, argv, "condition body");
return JIM_ERR;
}
| | | 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 |
static int Jim_WhileCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc != 3) {
Jim_WrongNumArgs(interp, 1, argv, "condition body");
return JIM_ERR;
}
while (1) {
int boolean, retval;
if ((retval = Jim_GetBoolFromExpr(interp, argv[1], &boolean)) != JIM_OK)
return retval;
if (!boolean)
break;
|
| ︙ | ︙ | |||
16163 16164 16165 16166 16167 16168 16169 |
Jim_Obj *stopVarNamePtr = NULL;
if (argc != 5) {
Jim_WrongNumArgs(interp, 1, argv, "start test next body");
return JIM_ERR;
}
| | | | | | | | | | | | | | | | | 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 |
Jim_Obj *stopVarNamePtr = NULL;
if (argc != 5) {
Jim_WrongNumArgs(interp, 1, argv, "start test next body");
return JIM_ERR;
}
if ((retval = Jim_EvalObj(interp, argv[1])) != JIM_OK) {
return retval;
}
retval = Jim_GetBoolFromExpr(interp, argv[2], &boolean);
#ifdef JIM_OPTIMIZATION
if (retval == JIM_OK && boolean) {
ScriptObj *incrScript;
ExprByteCode *expr;
jim_wide stop, currentVal;
Jim_Obj *objPtr;
int cmpOffset;
expr = JimGetExpression(interp, argv[2]);
incrScript = JimGetScript(interp, argv[3]);
if (incrScript == NULL || incrScript->len != 3 || !expr || expr->len != 3) {
goto evalstart;
}
if (incrScript->token[1].type != JIM_TT_ESC ||
expr->token[0].type != JIM_TT_VAR ||
(expr->token[1].type != JIM_TT_EXPR_INT && expr->token[1].type != JIM_TT_VAR)) {
goto evalstart;
}
if (expr->token[2].type == JIM_EXPROP_LT) {
cmpOffset = 0;
}
else if (expr->token[2].type == JIM_EXPROP_LTE) {
cmpOffset = 1;
}
else {
goto evalstart;
}
if (!Jim_CompareStringImmediate(interp, incrScript->token[1].objPtr, "incr")) {
goto evalstart;
}
if (!Jim_StringEqObj(incrScript->token[2].objPtr, expr->token[0].objPtr)) {
goto evalstart;
}
if (expr->token[1].type == JIM_TT_EXPR_INT) {
if (Jim_GetWide(interp, expr->token[1].objPtr, &stop) == JIM_ERR) {
goto evalstart;
}
}
else {
stopVarNamePtr = expr->token[1].objPtr;
Jim_IncrRefCount(stopVarNamePtr);
stop = 0;
}
varNamePtr = expr->token[0].objPtr;
Jim_IncrRefCount(varNamePtr);
objPtr = Jim_GetVariable(interp, varNamePtr, JIM_NONE);
if (objPtr == NULL || Jim_GetWide(interp, objPtr, ¤tVal) != JIM_OK) {
goto testcond;
}
while (retval == JIM_OK) {
if (stopVarNamePtr) {
objPtr = Jim_GetVariable(interp, stopVarNamePtr, JIM_NONE);
if (objPtr == NULL || Jim_GetWide(interp, objPtr, &stop) != JIM_OK) {
goto testcond;
}
}
if (currentVal >= stop + cmpOffset) {
break;
}
retval = Jim_EvalObj(interp, argv[4]);
if (retval == JIM_OK || retval == JIM_CONTINUE) {
retval = JIM_OK;
objPtr = Jim_GetVariable(interp, varNamePtr, JIM_ERRMSG);
if (objPtr == NULL) {
retval = JIM_ERR;
goto out;
}
if (!Jim_IsShared(objPtr) && objPtr->typePtr == &intObjType) {
currentVal = ++JimWideValue(objPtr);
Jim_InvalidateStringRep(objPtr);
|
| ︙ | ︙ | |||
16284 16285 16286 16287 16288 16289 16290 |
}
goto out;
}
evalstart:
#endif
while (boolean && (retval == JIM_OK || retval == JIM_CONTINUE)) {
| | | | | | | | 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 |
}
goto out;
}
evalstart:
#endif
while (boolean && (retval == JIM_OK || retval == JIM_CONTINUE)) {
retval = Jim_EvalObj(interp, argv[4]);
if (retval == JIM_OK || retval == JIM_CONTINUE) {
evalnext:
retval = Jim_EvalObj(interp, argv[3]);
if (retval == JIM_OK || retval == JIM_CONTINUE) {
testcond:
retval = Jim_GetBoolFromExpr(interp, argv[2], &boolean);
}
}
}
out:
if (stopVarNamePtr) {
Jim_DecrRefCount(interp, stopVarNamePtr);
}
if (varNamePtr) {
Jim_DecrRefCount(interp, varNamePtr);
}
|
| ︙ | ︙ | |||
16344 16345 16346 16347 16348 16349 16350 |
while (((i < limit && incr > 0) || (i > limit && incr < 0)) && retval == JIM_OK) {
retval = Jim_EvalObj(interp, bodyObjPtr);
if (retval == JIM_OK || retval == JIM_CONTINUE) {
Jim_Obj *objPtr = Jim_GetVariable(interp, argv[1], JIM_ERRMSG);
retval = JIM_OK;
| | | 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 |
while (((i < limit && incr > 0) || (i > limit && incr < 0)) && retval == JIM_OK) {
retval = Jim_EvalObj(interp, bodyObjPtr);
if (retval == JIM_OK || retval == JIM_CONTINUE) {
Jim_Obj *objPtr = Jim_GetVariable(interp, argv[1], JIM_ERRMSG);
retval = JIM_OK;
i += incr;
if (objPtr && !Jim_IsShared(objPtr) && objPtr->typePtr == &intObjType) {
if (argv[1]->typePtr != &variableObjType) {
if (Jim_SetVariable(interp, argv[1], objPtr) != JIM_OK) {
return JIM_ERR;
}
|
| ︙ | ︙ | |||
16409 16410 16411 16412 16413 16414 16415 |
}
static int JimForeachMapHelper(Jim_Interp *interp, int argc, Jim_Obj *const *argv, int doMap)
{
int result = JIM_OK;
int i, numargs;
| | | | | 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 |
}
static int JimForeachMapHelper(Jim_Interp *interp, int argc, Jim_Obj *const *argv, int doMap)
{
int result = JIM_OK;
int i, numargs;
Jim_ListIter twoiters[2];
Jim_ListIter *iters;
Jim_Obj *script;
Jim_Obj *resultObj;
if (argc < 4 || argc % 2 != 0) {
Jim_WrongNumArgs(interp, 1, argv, "varList list ?varList list ...? script");
return JIM_ERR;
}
script = argv[argc - 1];
numargs = (argc - 1 - 1);
if (numargs == 2) {
iters = twoiters;
}
else {
iters = Jim_Alloc(numargs * sizeof(*iters));
}
|
| ︙ | ︙ | |||
16447 16448 16449 16450 16451 16452 16453 |
}
else {
resultObj = interp->emptyObj;
}
Jim_IncrRefCount(resultObj);
while (1) {
| | | | | | | | 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 |
}
else {
resultObj = interp->emptyObj;
}
Jim_IncrRefCount(resultObj);
while (1) {
for (i = 0; i < numargs; i += 2) {
if (!JimListIterDone(interp, &iters[i + 1])) {
break;
}
}
if (i == numargs) {
break;
}
for (i = 0; i < numargs; i += 2) {
Jim_Obj *varName;
JimListIterInit(&iters[i], argv[i + 1]);
while ((varName = JimListIterNext(interp, &iters[i])) != NULL) {
Jim_Obj *valObj = JimListIterNext(interp, &iters[i + 1]);
if (!valObj) {
valObj = interp->emptyObj;
}
Jim_IncrRefCount(valObj);
result = Jim_SetVariable(interp, varName, valObj);
Jim_DecrRefCount(interp, valObj);
if (result != JIM_OK) {
goto err;
}
}
|
| ︙ | ︙ | |||
16556 16557 16558 16559 16560 16561 16562 |
static int Jim_IfCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int boolean, retval, current = 1, falsebody = 0;
if (argc >= 3) {
while (1) {
| | | | | | | | 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 |
static int Jim_IfCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int boolean, retval, current = 1, falsebody = 0;
if (argc >= 3) {
while (1) {
if (current >= argc)
goto err;
if ((retval = Jim_GetBoolFromExpr(interp, argv[current++], &boolean))
!= JIM_OK)
return retval;
if (current >= argc)
goto err;
if (Jim_CompareStringImmediate(interp, argv[current], "then"))
current++;
if (current >= argc)
goto err;
if (boolean)
return Jim_EvalObj(interp, argv[current]);
if (++current >= argc) {
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
return JIM_OK;
}
falsebody = current++;
if (Jim_CompareStringImmediate(interp, argv[falsebody], "else")) {
if (current != argc - 1)
goto err;
return Jim_EvalObj(interp, argv[current]);
}
else if (Jim_CompareStringImmediate(interp, argv[falsebody], "elseif"))
continue;
else if (falsebody != argc - 1)
goto err;
return Jim_EvalObj(interp, argv[falsebody]);
}
return JIM_OK;
}
err:
|
| ︙ | ︙ | |||
16698 16699 16700 16701 16702 16703 16704 |
break;
case SWITCH_GLOB:
if (Jim_StringMatchObj(interp, patObj, strObj, 0))
script = caseList[i + 1];
break;
case SWITCH_RE:
command = Jim_NewStringObj(interp, "regexp", -1);
| | | | 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 |
break;
case SWITCH_GLOB:
if (Jim_StringMatchObj(interp, patObj, strObj, 0))
script = caseList[i + 1];
break;
case SWITCH_RE:
command = Jim_NewStringObj(interp, "regexp", -1);
case SWITCH_CMD:{
int rc = Jim_CommandMatchObj(interp, command, patObj, strObj, 0);
if (argc - opt == 1) {
Jim_Obj **vector;
JimListGetElements(interp, argv[opt], &patCount, &vector);
caseList = vector;
}
if (rc < 0) {
return -rc;
}
if (rc)
script = caseList[i + 1];
break;
}
|
| ︙ | ︙ | |||
16846 16847 16848 16849 16850 16851 16852 |
opt_all = 1;
break;
case OPT_COMMAND:
if (i >= argc - 2) {
goto wrongargs;
}
commandObj = argv[++i];
| | | 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 |
opt_all = 1;
break;
case OPT_COMMAND:
if (i >= argc - 2) {
goto wrongargs;
}
commandObj = argv[++i];
case OPT_EXACT:
case OPT_GLOB:
case OPT_REGEXP:
opt_match = option;
break;
}
}
|
| ︙ | ︙ | |||
16894 16895 16896 16897 16898 16899 16900 |
}
rc = JIM_ERR;
goto done;
}
break;
}
| | | | 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 |
}
rc = JIM_ERR;
goto done;
}
break;
}
if (!eq && opt_bool && opt_not && !opt_all) {
continue;
}
if ((!opt_bool && eq == !opt_not) || (opt_bool && (eq || opt_all))) {
Jim_Obj *resultObj;
if (opt_bool) {
resultObj = Jim_NewIntObj(interp, eq ^ opt_not);
}
else if (!opt_inline) {
resultObj = Jim_NewIntObj(interp, i);
|
| ︙ | ︙ | |||
16927 16928 16929 16930 16931 16932 16933 |
}
}
if (opt_all) {
Jim_SetResult(interp, listObjPtr);
}
else {
| | | 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 |
}
}
if (opt_all) {
Jim_SetResult(interp, listObjPtr);
}
else {
if (opt_bool) {
Jim_SetResultBool(interp, opt_not);
}
else if (!opt_inline) {
Jim_SetResultInt(interp, -1);
}
}
|
| ︙ | ︙ | |||
16956 16957 16958 16959 16960 16961 16962 |
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv, "varName ?value value ...?");
return JIM_ERR;
}
listObjPtr = Jim_GetVariable(interp, argv[1], JIM_UNSHARED);
if (!listObjPtr) {
| | | 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 |
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv, "varName ?value value ...?");
return JIM_ERR;
}
listObjPtr = Jim_GetVariable(interp, argv[1], JIM_UNSHARED);
if (!listObjPtr) {
listObjPtr = Jim_NewListObj(interp, NULL, 0);
new_obj = 1;
}
else if (Jim_IsShared(listObjPtr)) {
listObjPtr = Jim_DuplicateObj(interp, listObjPtr);
new_obj = 1;
}
|
| ︙ | ︙ | |||
17029 17030 17031 17032 17033 17034 17035 |
len = Jim_ListLength(interp, listObj);
first = JimRelToAbsIndex(len, first);
last = JimRelToAbsIndex(len, last);
JimRelToAbsRange(len, &first, &last, &rangeLen);
| | | | | | | | | 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 |
len = Jim_ListLength(interp, listObj);
first = JimRelToAbsIndex(len, first);
last = JimRelToAbsIndex(len, last);
JimRelToAbsRange(len, &first, &last, &rangeLen);
if (first < len) {
}
else if (len == 0) {
first = 0;
}
else {
Jim_SetResultString(interp, "list doesn't contain element ", -1);
Jim_AppendObj(interp, Jim_GetResult(interp), argv[2]);
return JIM_ERR;
}
newListObj = Jim_NewListObj(interp, listObj->internalRep.listValue.ele, first);
ListInsertElements(newListObj, -1, argc - 4, argv + 4);
ListInsertElements(newListObj, -1, len - first - rangeLen, listObj->internalRep.listValue.ele + first + rangeLen);
Jim_SetResult(interp, newListObj);
return JIM_OK;
}
static int Jim_LsetCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc < 3) {
Jim_WrongNumArgs(interp, 1, argv, "listVar ?index...? newVal");
return JIM_ERR;
}
else if (argc == 3) {
if (Jim_SetVariable(interp, argv[1], argv[2]) != JIM_OK)
return JIM_ERR;
Jim_SetResult(interp, argv[2]);
return JIM_OK;
}
return Jim_ListSetIndex(interp, argv[1], argv + 2, argc - 3, argv[argc - 1]);
}
|
| ︙ | ︙ | |||
17179 17180 17181 17182 17183 17184 17185 |
if (!stringObjPtr)
return JIM_ERR;
}
else {
int new_obj = 0;
stringObjPtr = Jim_GetVariable(interp, argv[1], JIM_UNSHARED);
if (!stringObjPtr) {
| | | 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 |
if (!stringObjPtr)
return JIM_ERR;
}
else {
int new_obj = 0;
stringObjPtr = Jim_GetVariable(interp, argv[1], JIM_UNSHARED);
if (!stringObjPtr) {
stringObjPtr = Jim_NewEmptyStringObj(interp);
new_obj = 1;
}
else if (Jim_IsShared(stringObjPtr)) {
new_obj = 1;
stringObjPtr = Jim_DuplicateObj(interp, stringObjPtr);
}
|
| ︙ | ︙ | |||
17228 17229 17230 17231 17232 17233 17234 |
rc = Jim_EvalObj(interp, argv[1]);
}
else {
rc = Jim_EvalObj(interp, Jim_ConcatObj(interp, argc - 1, argv + 1));
}
if (rc == JIM_ERR) {
| | | | | | 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 |
rc = Jim_EvalObj(interp, argv[1]);
}
else {
rc = Jim_EvalObj(interp, Jim_ConcatObj(interp, argc - 1, argv + 1));
}
if (rc == JIM_ERR) {
interp->addStackTrace++;
}
return rc;
}
static int Jim_UplevelCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc >= 2) {
int retcode;
Jim_CallFrame *savedCallFrame, *targetCallFrame;
const char *str;
savedCallFrame = interp->framePtr;
str = Jim_String(argv[1]);
if ((str[0] >= '0' && str[0] <= '9') || str[0] == '#') {
targetCallFrame = Jim_GetCallFrameByLevel(interp, argv[1]);
argc--;
argv++;
}
else {
targetCallFrame = Jim_GetCallFrameByLevel(interp, NULL);
}
if (targetCallFrame == NULL) {
return JIM_ERR;
}
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv - 1, "?level? command ?arg ...?");
return JIM_ERR;
}
interp->framePtr = targetCallFrame;
if (argc == 2) {
retcode = Jim_EvalObj(interp, argv[1]);
}
else {
retcode = Jim_EvalObj(interp, Jim_ConcatObj(interp, argc - 1, argv + 1));
}
|
| ︙ | ︙ | |||
17364 17365 17366 17367 17368 17369 17370 |
}
if (i != argc - 1 && i != argc) {
Jim_WrongNumArgs(interp, 1, argv,
"?-code code? ?-errorinfo stacktrace? ?-level level? ?result?");
}
| | | | | | | | | 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 |
}
if (i != argc - 1 && i != argc) {
Jim_WrongNumArgs(interp, 1, argv,
"?-code code? ?-errorinfo stacktrace? ?-level level? ?result?");
}
if (stackTraceObj && returnCode == JIM_ERR) {
JimSetStackTrace(interp, stackTraceObj);
}
if (errorCodeObj && returnCode == JIM_ERR) {
Jim_SetGlobalVariableStr(interp, "errorCode", errorCodeObj);
}
interp->returnCode = returnCode;
interp->returnLevel = level;
if (i == argc - 1) {
Jim_SetResult(interp, argv[i]);
}
return JIM_RETURN;
}
static int Jim_TailcallCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (interp->framePtr->level == 0) {
Jim_SetResultString(interp, "tailcall can only be called from a proc or lambda", -1);
return JIM_ERR;
}
else if (argc >= 2) {
Jim_CallFrame *cf = interp->framePtr->parent;
Jim_Cmd *cmdPtr = Jim_GetCommand(interp, argv[1], JIM_ERRMSG);
if (cmdPtr == NULL) {
return JIM_ERR;
}
JimPanic((cf->tailcallCmd != NULL, "Already have a tailcallCmd"));
JimIncrCmdRefCount(cmdPtr);
cf->tailcallCmd = cmdPtr;
JimPanic((cf->tailcallObj != NULL, "Already have a tailcallobj"));
cf->tailcallObj = Jim_NewListObj(interp, argv + 1, argc - 1);
Jim_IncrRefCount(cf->tailcallObj);
return JIM_EVAL;
}
return JIM_OK;
}
static int JimAliasCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *cmdList;
Jim_Obj *prefixListObj = Jim_CmdPrivData(interp);
cmdList = Jim_DuplicateObj(interp, prefixListObj);
Jim_ListInsertElements(interp, cmdList, Jim_ListLength(interp, cmdList), argc - 1, argv + 1);
return JimEvalObjList(interp, cmdList);
}
static void JimAliasCmdDelete(Jim_Interp *interp, void *privData)
|
| ︙ | ︙ | |||
17478 17479 17480 17481 17482 17483 17484 |
cmd = JimCreateProcedureCmd(interp, argv[2], NULL, argv[3], NULL);
}
else {
cmd = JimCreateProcedureCmd(interp, argv[2], argv[3], argv[4], NULL);
}
if (cmd) {
| | | | | | | 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 17598 |
cmd = JimCreateProcedureCmd(interp, argv[2], NULL, argv[3], NULL);
}
else {
cmd = JimCreateProcedureCmd(interp, argv[2], argv[3], argv[4], NULL);
}
if (cmd) {
Jim_Obj *qualifiedCmdNameObj;
const char *cmdname = JimQualifyName(interp, Jim_String(argv[1]), &qualifiedCmdNameObj);
JimCreateCommand(interp, cmdname, cmd);
JimUpdateProcNamespace(interp, cmd, cmdname);
JimFreeQualifiedName(interp, qualifiedCmdNameObj);
Jim_SetResult(interp, argv[1]);
return JIM_OK;
}
return JIM_ERR;
}
static int Jim_LocalCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int retcode;
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv, "cmd ?args ...?");
return JIM_ERR;
}
interp->local++;
retcode = Jim_EvalObjVector(interp, argc - 1, argv + 1);
interp->local--;
if (retcode == 0) {
Jim_Obj *cmdNameObj = Jim_GetResult(interp);
if (Jim_GetCommand(interp, cmdNameObj, JIM_ERRMSG) == NULL) {
return JIM_ERR;
}
if (interp->framePtr->localCommands == NULL) {
|
| ︙ | ︙ | |||
17545 17546 17547 17548 17549 17550 17551 |
int retcode;
Jim_Cmd *cmdPtr = Jim_GetCommand(interp, argv[1], JIM_ERRMSG);
if (cmdPtr == NULL || !cmdPtr->isproc || !cmdPtr->prevCmd) {
Jim_SetResultFormatted(interp, "no previous command: \"%#s\"", argv[1]);
return JIM_ERR;
}
| | | | | 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 |
int retcode;
Jim_Cmd *cmdPtr = Jim_GetCommand(interp, argv[1], JIM_ERRMSG);
if (cmdPtr == NULL || !cmdPtr->isproc || !cmdPtr->prevCmd) {
Jim_SetResultFormatted(interp, "no previous command: \"%#s\"", argv[1]);
return JIM_ERR;
}
cmdPtr->u.proc.upcall++;
JimIncrCmdRefCount(cmdPtr);
retcode = Jim_EvalObjVector(interp, argc - 1, argv + 1);
cmdPtr->u.proc.upcall--;
JimDecrCmdRefCount(interp, cmdPtr);
return retcode;
}
}
|
| ︙ | ︙ | |||
17583 17584 17585 17586 17587 17588 17589 |
if (len != 2 && len != 3) {
Jim_SetResultFormatted(interp, "can't interpret \"%#s\" as a lambda expression", argv[1]);
return JIM_ERR;
}
if (len == 3) {
#ifdef jim_ext_namespace
| | | | 17655 17656 17657 17658 17659 17660 17661 17662 17663 17664 17665 17666 17667 17668 17669 17670 17671 17672 17673 17674 17675 17676 17677 17678 17679 17680 17681 17682 |
if (len != 2 && len != 3) {
Jim_SetResultFormatted(interp, "can't interpret \"%#s\" as a lambda expression", argv[1]);
return JIM_ERR;
}
if (len == 3) {
#ifdef jim_ext_namespace
nsObj = JimQualifyNameObj(interp, Jim_ListGetIndex(interp, argv[1], 2));
#else
Jim_SetResultString(interp, "namespaces not enabled", -1);
return JIM_ERR;
#endif
}
argListObjPtr = Jim_ListGetIndex(interp, argv[1], 0);
bodyObjPtr = Jim_ListGetIndex(interp, argv[1], 1);
cmd = JimCreateProcedureCmd(interp, argListObjPtr, NULL, bodyObjPtr, nsObj);
if (cmd) {
nargv = Jim_Alloc((argc - 2 + 1) * sizeof(*nargv));
nargv[0] = Jim_NewStringObj(interp, "apply lambdaExpr", -1);
Jim_IncrRefCount(nargv[0]);
memcpy(&nargv[1], argv + 2, (argc - 2) * sizeof(*nargv));
ret = JimCallProcedure(interp, cmd, argc - 2 + 1, nargv);
Jim_DecrRefCount(interp, nargv[0]);
Jim_Free(nargv);
|
| ︙ | ︙ | |||
17626 17627 17628 17629 17630 17631 17632 |
static int Jim_UpvarCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int i;
Jim_CallFrame *targetCallFrame;
| | | | | | | | 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 17748 17749 17750 17751 17752 |
static int Jim_UpvarCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int i;
Jim_CallFrame *targetCallFrame;
if (argc > 3 && (argc % 2 == 0)) {
targetCallFrame = Jim_GetCallFrameByLevel(interp, argv[1]);
argc--;
argv++;
}
else {
targetCallFrame = Jim_GetCallFrameByLevel(interp, NULL);
}
if (targetCallFrame == NULL) {
return JIM_ERR;
}
if (argc < 3) {
Jim_WrongNumArgs(interp, 1, argv, "?level? otherVar localVar ?otherVar localVar ...?");
return JIM_ERR;
}
for (i = 1; i < argc; i += 2) {
if (Jim_SetVariableLink(interp, argv[i + 1], argv[i], targetCallFrame) != JIM_OK)
return JIM_ERR;
}
return JIM_OK;
}
static int Jim_GlobalCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int i;
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv, "varName ?varName ...?");
return JIM_ERR;
}
if (interp->framePtr->level == 0)
return JIM_OK;
for (i = 1; i < argc; i++) {
const char *name = Jim_String(argv[i]);
if (name[0] != ':' || name[1] != ':') {
if (Jim_SetVariableLink(interp, argv[i], argv[i], interp->topFramePtr) != JIM_OK)
return JIM_ERR;
}
}
return JIM_OK;
|
| ︙ | ︙ | |||
17693 17694 17695 17696 17697 17698 17699 |
Jim_SetResultString(interp, "list must contain an even number of elements", -1);
return NULL;
}
str = Jim_String(objPtr);
strLen = Jim_Utf8Length(interp, objPtr);
| | | | | | | | 17765 17766 17767 17768 17769 17770 17771 17772 17773 17774 17775 17776 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 17787 17788 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 17799 17800 17801 17802 17803 17804 17805 17806 |
Jim_SetResultString(interp, "list must contain an even number of elements", -1);
return NULL;
}
str = Jim_String(objPtr);
strLen = Jim_Utf8Length(interp, objPtr);
resultObjPtr = Jim_NewStringObj(interp, "", 0);
while (strLen) {
for (i = 0; i < numMaps; i += 2) {
Jim_Obj *objPtr;
const char *k;
int kl;
objPtr = Jim_ListGetIndex(interp, mapListObjPtr, i);
k = Jim_String(objPtr);
kl = Jim_Utf8Length(interp, objPtr);
if (strLen >= kl && kl) {
int rc;
rc = JimStringCompareLen(str, k, kl, nocase);
if (rc == 0) {
if (noMatchStart) {
Jim_AppendString(interp, resultObjPtr, noMatchStart, str - noMatchStart);
noMatchStart = NULL;
}
Jim_AppendObj(interp, resultObjPtr, Jim_ListGetIndex(interp, mapListObjPtr, i + 1));
str += utf8_index(str, kl);
strLen -= kl;
break;
}
}
}
if (i == numMaps) {
int c;
if (noMatchStart == NULL)
noMatchStart = str;
str += utf8_tounicode(str, &c);
strLen--;
}
}
|
| ︙ | ︙ | |||
17785 17786 17787 17788 17789 17790 17791 |
}
Jim_SetResultInt(interp, len);
return JIM_OK;
case OPT_CAT:{
Jim_Obj *objPtr;
if (argc == 3) {
| | | | | | | 17857 17858 17859 17860 17861 17862 17863 17864 17865 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 17880 17881 17882 17883 17884 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 |
}
Jim_SetResultInt(interp, len);
return JIM_OK;
case OPT_CAT:{
Jim_Obj *objPtr;
if (argc == 3) {
objPtr = argv[2];
}
else {
int i;
objPtr = Jim_NewStringObj(interp, "", 0);
for (i = 2; i < argc; i++) {
Jim_AppendObj(interp, objPtr, argv[i]);
}
}
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
case OPT_COMPARE:
case OPT_EQUAL:
{
long opt_length = -1;
int n = argc - 4;
int i = 2;
while (n > 0) {
int subopt;
if (Jim_GetEnum(interp, argv[i++], nocase_length_options, &subopt, NULL,
JIM_ENUM_ABBREV) != JIM_OK) {
badcompareargs:
Jim_WrongNumArgs(interp, 2, argv, "?-nocase? ?-length int? string1 string2");
return JIM_ERR;
}
if (subopt == 0) {
opt_case = 0;
n--;
}
else {
if (n < 2) {
goto badcompareargs;
}
if (Jim_GetLong(interp, argv[i++], &opt_length) != JIM_OK) {
return JIM_ERR;
}
n -= 2;
}
}
if (n) {
goto badcompareargs;
}
argv += argc - 2;
if (opt_length < 0 && option != OPT_COMPARE && opt_case) {
Jim_SetResultBool(interp, Jim_StringEqObj(argv[0], argv[1]));
}
else {
if (opt_length >= 0) {
n = JimStringCompareLen(Jim_String(argv[0]), Jim_String(argv[1]), opt_length, !opt_case);
}
else {
|
| ︙ | ︙ | |||
17951 17952 17953 17954 17955 17956 17957 17958 17959 17960 17961 17962 17963 17964 |
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
case OPT_REVERSE:{
char *buf, *p;
const char *str;
int i;
if (argc != 3) {
Jim_WrongNumArgs(interp, 2, argv, "string");
return JIM_ERR;
}
| > | 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 |
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
case OPT_REVERSE:{
char *buf, *p;
const char *str;
int len;
int i;
if (argc != 3) {
Jim_WrongNumArgs(interp, 2, argv, "string");
return JIM_ERR;
}
|
| ︙ | ︙ | |||
17994 17995 17996 17997 17998 17999 18000 |
if (idx != INT_MIN && idx != INT_MAX) {
idx = JimRelToAbsIndex(len, idx);
}
if (idx < 0 || idx >= len || str == NULL) {
Jim_SetResultString(interp, "", 0);
}
else if (len == Jim_Length(argv[2])) {
| | | 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 |
if (idx != INT_MIN && idx != INT_MAX) {
idx = JimRelToAbsIndex(len, idx);
}
if (idx < 0 || idx >= len || str == NULL) {
Jim_SetResultString(interp, "", 0);
}
else if (len == Jim_Length(argv[2])) {
Jim_SetResultString(interp, str + idx, 1);
}
else {
int c;
int i = utf8_index(str, idx);
Jim_SetResultString(interp, str + i, utf8_tounicode(str + i, &c));
}
|
| ︙ | ︙ | |||
18148 18149 18150 18151 18152 18153 18154 |
static int Jim_CatchCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int exitCode = 0;
int i;
int sig = 0;
| | | | 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 18242 18243 18244 18245 18246 |
static int Jim_CatchCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int exitCode = 0;
int i;
int sig = 0;
jim_wide ignore_mask = (1 << JIM_EXIT) | (1 << JIM_EVAL) | (1 << JIM_SIGNAL);
static const int max_ignore_code = sizeof(ignore_mask) * 8;
Jim_SetGlobalVariableStr(interp, "errorCode", Jim_NewStringObj(interp, "NONE", -1));
for (i = 1; i < argc - 1; i++) {
const char *arg = Jim_String(argv[i]);
jim_wide option;
int ignore;
if (strcmp(arg, "--") == 0) {
i++;
break;
}
if (*arg != '-') {
break;
}
|
| ︙ | ︙ | |||
18210 18211 18212 18213 18214 18215 18216 |
if ((ignore_mask & (1 << JIM_SIGNAL)) == 0) {
sig++;
}
interp->signal_level += sig;
if (Jim_CheckSignal(interp)) {
| | | | | | | 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 |
if ((ignore_mask & (1 << JIM_SIGNAL)) == 0) {
sig++;
}
interp->signal_level += sig;
if (Jim_CheckSignal(interp)) {
exitCode = JIM_SIGNAL;
}
else {
exitCode = Jim_EvalObj(interp, argv[0]);
interp->errorFlag = 0;
}
interp->signal_level -= sig;
if (exitCode >= 0 && exitCode < max_ignore_code && (((unsigned jim_wide)1 << exitCode) & ignore_mask)) {
return exitCode;
}
if (sig && exitCode == JIM_SIGNAL) {
if (interp->signal_set_result) {
interp->signal_set_result(interp, interp->sigmask);
}
else {
Jim_SetResultInt(interp, interp->sigmask);
}
interp->sigmask = 0;
|
| ︙ | ︙ | |||
18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 |
}
}
}
Jim_SetResultInt(interp, exitCode);
return JIM_OK;
}
static int Jim_RenameCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc != 3) {
Jim_WrongNumArgs(interp, 1, argv, "oldName newName");
return JIM_ERR;
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 18470 18471 |
}
}
}
Jim_SetResultInt(interp, exitCode);
return JIM_OK;
}
#ifdef JIM_REFERENCES
static int Jim_RefCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc != 3 && argc != 4) {
Jim_WrongNumArgs(interp, 1, argv, "string tag ?finalizer?");
return JIM_ERR;
}
if (argc == 3) {
Jim_SetResult(interp, Jim_NewReference(interp, argv[1], argv[2], NULL));
}
else {
Jim_SetResult(interp, Jim_NewReference(interp, argv[1], argv[2], argv[3]));
}
return JIM_OK;
}
static int Jim_GetrefCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Reference *refPtr;
if (argc != 2) {
Jim_WrongNumArgs(interp, 1, argv, "reference");
return JIM_ERR;
}
if ((refPtr = Jim_GetReference(interp, argv[1])) == NULL)
return JIM_ERR;
Jim_SetResult(interp, refPtr->objPtr);
return JIM_OK;
}
static int Jim_SetrefCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Reference *refPtr;
if (argc != 3) {
Jim_WrongNumArgs(interp, 1, argv, "reference newValue");
return JIM_ERR;
}
if ((refPtr = Jim_GetReference(interp, argv[1])) == NULL)
return JIM_ERR;
Jim_IncrRefCount(argv[2]);
Jim_DecrRefCount(interp, refPtr->objPtr);
refPtr->objPtr = argv[2];
Jim_SetResult(interp, argv[2]);
return JIM_OK;
}
static int Jim_CollectCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc != 1) {
Jim_WrongNumArgs(interp, 1, argv, "");
return JIM_ERR;
}
Jim_SetResultInt(interp, Jim_Collect(interp));
while (interp->freeList) {
Jim_Obj *nextObjPtr = interp->freeList->nextObjPtr;
Jim_Free(interp->freeList);
interp->freeList = nextObjPtr;
}
return JIM_OK;
}
static int Jim_FinalizeCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc != 2 && argc != 3) {
Jim_WrongNumArgs(interp, 1, argv, "reference ?finalizerProc?");
return JIM_ERR;
}
if (argc == 2) {
Jim_Obj *cmdNamePtr;
if (Jim_GetFinalizer(interp, argv[1], &cmdNamePtr) != JIM_OK)
return JIM_ERR;
if (cmdNamePtr != NULL)
Jim_SetResult(interp, cmdNamePtr);
}
else {
if (Jim_SetFinalizer(interp, argv[1], argv[2]) != JIM_OK)
return JIM_ERR;
Jim_SetResult(interp, argv[2]);
}
return JIM_OK;
}
static int JimInfoReferences(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *listObjPtr;
Jim_HashTableIterator htiter;
Jim_HashEntry *he;
listObjPtr = Jim_NewListObj(interp, NULL, 0);
JimInitHashTableIterator(&interp->references, &htiter);
while ((he = Jim_NextHashEntry(&htiter)) != NULL) {
char buf[JIM_REFERENCE_SPACE + 1];
Jim_Reference *refPtr = Jim_GetHashEntryVal(he);
const unsigned long *refId = he->key;
JimFormatReference(buf, refPtr, *refId);
Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, buf, -1));
}
Jim_SetResult(interp, listObjPtr);
return JIM_OK;
}
#endif
static int Jim_RenameCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc != 3) {
Jim_WrongNumArgs(interp, 1, argv, "oldName newName");
return JIM_ERR;
|
| ︙ | ︙ | |||
18304 18305 18306 18307 18308 18309 18310 |
static Jim_Obj *JimDictPatternMatch(Jim_Interp *interp, Jim_HashTable *ht, Jim_Obj *patternObjPtr,
JimDictMatchCallbackType *callback, int type)
{
Jim_HashEntry *he;
Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0);
| | | 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 |
static Jim_Obj *JimDictPatternMatch(Jim_Interp *interp, Jim_HashTable *ht, Jim_Obj *patternObjPtr,
JimDictMatchCallbackType *callback, int type)
{
Jim_HashEntry *he;
Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0);
Jim_HashTableIterator htiter;
JimInitHashTableIterator(ht, &htiter);
while ((he = Jim_NextHashEntry(&htiter)) != NULL) {
if (patternObjPtr == NULL || JimGlobMatch(Jim_String(patternObjPtr), Jim_String((Jim_Obj *)he->key), 0)) {
callback(interp, listObjPtr, he, type);
}
}
|
| ︙ | ︙ | |||
18354 18355 18356 18357 18358 18359 18360 |
if (SetDictFromAny(interp, objPtr) != JIM_OK) {
return JIM_ERR;
}
ht = (Jim_HashTable *)objPtr->internalRep.ptr;
| | | 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 |
if (SetDictFromAny(interp, objPtr) != JIM_OK) {
return JIM_ERR;
}
ht = (Jim_HashTable *)objPtr->internalRep.ptr;
printf("%d entries in table, %d buckets\n", ht->used, ht->size);
for (i = 0; i < ht->size; i++) {
Jim_HashEntry *he = ht->table[i];
if (he) {
printf("%d: ", i);
|
| ︙ | ︙ | |||
18478 18479 18480 18481 18482 18483 18484 |
case OPT_MERGE:
if (argc == 2) {
return JIM_OK;
}
if (Jim_DictSize(interp, argv[2]) < 0) {
return JIM_ERR;
}
| | | | | 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 |
case OPT_MERGE:
if (argc == 2) {
return JIM_OK;
}
if (Jim_DictSize(interp, argv[2]) < 0) {
return JIM_ERR;
}
break;
case OPT_UPDATE:
if (argc < 6 || argc % 2) {
argc = 2;
}
break;
case OPT_CREATE:
if (argc % 2) {
Jim_WrongNumArgs(interp, 2, argv, "?key value ...?");
return JIM_ERR;
}
objPtr = Jim_NewDictObj(interp, argv + 2, argc - 2);
Jim_SetResult(interp, objPtr);
return JIM_OK;
case OPT_INFO:
if (argc != 3) {
Jim_WrongNumArgs(interp, 2, argv, "dictionary");
return JIM_ERR;
}
return Jim_DictInfo(interp, argv[2]);
}
return Jim_EvalEnsemble(interp, "dict", options[option], argc - 2, argv + 2);
}
static int Jim_SubstCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
static const char * const options[] = {
|
| ︙ | ︙ | |||
18574 18575 18576 18577 18578 18579 18580 |
INFO_RETURNCODES, INFO_REFERENCES, INFO_ALIAS,
};
#ifdef jim_ext_namespace
int nons = 0;
if (argc > 2 && Jim_CompareStringImmediate(interp, argv[1], "-nons")) {
| | | | 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 |
INFO_RETURNCODES, INFO_REFERENCES, INFO_ALIAS,
};
#ifdef jim_ext_namespace
int nons = 0;
if (argc > 2 && Jim_CompareStringImmediate(interp, argv[1], "-nons")) {
argc--;
argv++;
nons = 1;
}
#endif
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv, "subcommand ?args ...?");
return JIM_ERR;
}
if (Jim_GetEnum(interp, argv[1], commands, &cmd, "subcommand", JIM_ERRMSG | JIM_ENUM_ABBREV)
!= JIM_OK) {
return JIM_ERR;
}
switch (cmd) {
case INFO_EXISTS:
if (argc != 3) {
Jim_WrongNumArgs(interp, 2, argv, "varName");
return JIM_ERR;
}
Jim_SetResultBool(interp, Jim_GetVariable(interp, argv[2], 0) != NULL);
|
| ︙ | ︙ | |||
18619 18620 18621 18622 18623 18624 18625 |
return JIM_ERR;
}
Jim_SetResult(interp, (Jim_Obj *)cmdPtr->u.native.privData);
return JIM_OK;
}
case INFO_CHANNELS:
| | | | | | | | | | | | 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 |
return JIM_ERR;
}
Jim_SetResult(interp, (Jim_Obj *)cmdPtr->u.native.privData);
return JIM_OK;
}
case INFO_CHANNELS:
mode++;
#ifndef jim_ext_aio
Jim_SetResultString(interp, "aio not enabled", -1);
return JIM_ERR;
#endif
case INFO_PROCS:
mode++;
case INFO_COMMANDS:
if (argc != 2 && argc != 3) {
Jim_WrongNumArgs(interp, 2, argv, "?pattern?");
return JIM_ERR;
}
#ifdef jim_ext_namespace
if (!nons) {
if (Jim_Length(interp->framePtr->nsObj) || (argc == 3 && JimGlobMatch("::*", Jim_String(argv[2]), 0))) {
return Jim_EvalPrefix(interp, "namespace info", argc - 1, argv + 1);
}
}
#endif
Jim_SetResult(interp, JimCommandsList(interp, (argc == 3) ? argv[2] : NULL, mode));
break;
case INFO_VARS:
mode++;
case INFO_LOCALS:
mode++;
case INFO_GLOBALS:
if (argc != 2 && argc != 3) {
Jim_WrongNumArgs(interp, 2, argv, "?pattern?");
return JIM_ERR;
}
#ifdef jim_ext_namespace
if (!nons) {
if (Jim_Length(interp->framePtr->nsObj) || (argc == 3 && JimGlobMatch("::*", Jim_String(argv[2]), 0))) {
|
| ︙ | ︙ | |||
18761 18762 18763 18764 18765 18766 18767 18768 |
Jim_SetResult(interp, cmdPtr->u.proc.bodyObjPtr);
break;
case INFO_ARGS:
Jim_SetResult(interp, cmdPtr->u.proc.argListObjPtr);
break;
case INFO_STATICS:
if (cmdPtr->u.proc.staticVars) {
Jim_SetResult(interp, JimHashtablePatternMatch(interp, cmdPtr->u.proc.staticVars,
| > | | 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 |
Jim_SetResult(interp, cmdPtr->u.proc.bodyObjPtr);
break;
case INFO_ARGS:
Jim_SetResult(interp, cmdPtr->u.proc.argListObjPtr);
break;
case INFO_STATICS:
if (cmdPtr->u.proc.staticVars) {
int mode = JIM_VARLIST_LOCALS | JIM_VARLIST_VALUES;
Jim_SetResult(interp, JimHashtablePatternMatch(interp, cmdPtr->u.proc.staticVars,
NULL, JimVariablesMatch, mode));
}
break;
}
break;
}
case INFO_VERSION:
|
| ︙ | ︙ | |||
18794 18795 18796 18797 18798 18799 18800 |
if (missing != ' ' && argc == 4) {
Jim_SetVariable(interp, argv[3], Jim_NewStringObj(interp, &missing, 1));
}
}
break;
case INFO_HOSTNAME:
| | | | 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 19000 19001 |
if (missing != ' ' && argc == 4) {
Jim_SetVariable(interp, argv[3], Jim_NewStringObj(interp, &missing, 1));
}
}
break;
case INFO_HOSTNAME:
return Jim_Eval(interp, "os.gethostname");
case INFO_NAMEOFEXECUTABLE:
return Jim_Eval(interp, "{info nameofexecutable}");
case INFO_RETURNCODES:
if (argc == 2) {
int i;
Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0);
|
| ︙ | ︙ | |||
18879 18880 18881 18882 18883 18884 18885 |
return JIM_ERR;
}
if (option == OPT_VAR) {
result = Jim_GetVariable(interp, objPtr, 0) != NULL;
}
else {
| | | 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 |
return JIM_ERR;
}
if (option == OPT_VAR) {
result = Jim_GetVariable(interp, objPtr, 0) != NULL;
}
else {
Jim_Cmd *cmd = Jim_GetCommand(interp, objPtr, JIM_NONE);
if (cmd) {
switch (option) {
case OPT_COMMAND:
result = 1;
break;
|
| ︙ | ︙ | |||
18922 18923 18924 18925 18926 18927 18928 |
str = Jim_GetString(argv[1], &len);
if (len == 0) {
return JIM_OK;
}
strLen = Jim_Utf8Length(interp, argv[1]);
| | | | 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 |
str = Jim_GetString(argv[1], &len);
if (len == 0) {
return JIM_OK;
}
strLen = Jim_Utf8Length(interp, argv[1]);
if (argc == 2) {
splitChars = " \n\t\r";
splitLen = 4;
}
else {
splitChars = Jim_String(argv[2]);
splitLen = Jim_Utf8Length(interp, argv[2]);
}
noMatchStart = str;
resObjPtr = Jim_NewListObj(interp, NULL, 0);
if (splitLen) {
Jim_Obj *objPtr;
while (strLen--) {
const char *sc = splitChars;
int scLen = splitLen;
int sl = utf8_tounicode(str, &c);
while (scLen--) {
|
| ︙ | ︙ | |||
18964 18965 18966 18967 18968 18969 18970 |
else {
Jim_Obj **commonObj = NULL;
#define NUM_COMMON (128 - 9)
while (strLen--) {
int n = utf8_tounicode(str, &c);
#ifdef JIM_OPTIMIZATION
if (c >= 9 && c < 128) {
| | | 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 |
else {
Jim_Obj **commonObj = NULL;
#define NUM_COMMON (128 - 9)
while (strLen--) {
int n = utf8_tounicode(str, &c);
#ifdef JIM_OPTIMIZATION
if (c >= 9 && c < 128) {
c -= 9;
if (!commonObj) {
commonObj = Jim_Alloc(sizeof(*commonObj) * NUM_COMMON);
memset(commonObj, 0, sizeof(*commonObj) * NUM_COMMON);
}
if (!commonObj[c]) {
commonObj[c] = Jim_NewStringObj(interp, str, 1);
|
| ︙ | ︙ | |||
18998 18999 19000 19001 19002 19003 19004 |
const char *joinStr;
int joinStrLen;
if (argc != 2 && argc != 3) {
Jim_WrongNumArgs(interp, 1, argv, "list ?joinString?");
return JIM_ERR;
}
| | | 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 |
const char *joinStr;
int joinStrLen;
if (argc != 2 && argc != 3) {
Jim_WrongNumArgs(interp, 1, argv, "list ?joinString?");
return JIM_ERR;
}
if (argc == 2) {
joinStr = " ";
joinStrLen = 1;
}
else {
joinStr = Jim_GetString(argv[2], &joinStrLen);
}
|
| ︙ | ︙ | |||
19277 19278 19279 19280 19281 19282 19283 |
return 0;
else if (step > 0 && start > end)
return -1;
else if (step < 0 && end > start)
return -1;
len = end - start;
if (len < 0)
| | | | 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 |
return 0;
else if (step > 0 && start > end)
return -1;
else if (step < 0 && end > start)
return -1;
len = end - start;
if (len < 0)
len = -len;
if (step < 0)
step = -step;
len = 1 + ((len - 1) / step);
if (len > INT_MAX)
len = INT_MAX;
return (int)((len < 0) ? -1 : len);
}
|
| ︙ | ︙ | |||
19497 19498 19499 19500 19501 19502 19503 |
int arglen;
const char *arg = Jim_GetString(objPtr, &arglen);
*indexPtr = -1;
for (entryPtr = tablePtr, i = 0; *entryPtr != NULL; entryPtr++, i++) {
if (Jim_CompareStringImmediate(interp, objPtr, *entryPtr)) {
| | | | 19686 19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 19711 19712 19713 19714 19715 19716 19717 19718 |
int arglen;
const char *arg = Jim_GetString(objPtr, &arglen);
*indexPtr = -1;
for (entryPtr = tablePtr, i = 0; *entryPtr != NULL; entryPtr++, i++) {
if (Jim_CompareStringImmediate(interp, objPtr, *entryPtr)) {
*indexPtr = i;
return JIM_OK;
}
if (flags & JIM_ENUM_ABBREV) {
if (strncmp(arg, *entryPtr, arglen) == 0) {
if (*arg == '-' && arglen == 1) {
break;
}
if (match >= 0) {
bad = "ambiguous ";
goto ambiguous;
}
match = i;
}
}
}
if (match >= 0) {
*indexPtr = match;
return JIM_OK;
}
ambiguous:
if (flags & JIM_ERRMSG) {
|
| ︙ | ︙ | |||
19552 19553 19554 19555 19556 19557 19558 |
int Jim_IsList(Jim_Obj *objPtr)
{
return objPtr->typePtr == &listObjType;
}
void Jim_SetResultFormatted(Jim_Interp *interp, const char *format, ...)
{
| | | 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 |
int Jim_IsList(Jim_Obj *objPtr)
{
return objPtr->typePtr == &listObjType;
}
void Jim_SetResultFormatted(Jim_Interp *interp, const char *format, ...)
{
int len = strlen(format);
int extra = 0;
int n = 0;
const char *params[5];
char *buf;
va_list args;
int i;
|
| ︙ | ︙ | |||
19617 19618 19619 19620 19621 19622 19623 |
#include <stdio.h>
#include <string.h>
static int subcmd_null(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
| | | 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 |
#include <stdio.h>
#include <string.h>
static int subcmd_null(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
return JIM_OK;
}
static const jim_subcmd_type dummy_subcmd = {
"dummy", NULL, subcmd_null, 0, 0, JIM_MODFLAG_HIDDEN
};
|
| ︙ | ︙ | |||
19696 19697 19698 19699 19700 19701 19702 |
" command ...\"\n", NULL);
Jim_AppendStrings(interp, Jim_GetResult(interp), "Use \"", cmdname, " -help ?command?\" for help", NULL);
return 0;
}
cmd = argv[1];
| | | | | | | | | | | | | | | | | 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 |
" command ...\"\n", NULL);
Jim_AppendStrings(interp, Jim_GetResult(interp), "Use \"", cmdname, " -help ?command?\" for help", NULL);
return 0;
}
cmd = argv[1];
if (Jim_CompareStringImmediate(interp, cmd, "-help")) {
if (argc == 2) {
show_cmd_usage(interp, command_table, argc, argv);
return &dummy_subcmd;
}
help = 1;
cmd = argv[2];
}
if (Jim_CompareStringImmediate(interp, cmd, "-commands")) {
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
add_commands(interp, command_table, " ");
return &dummy_subcmd;
}
cmdstr = Jim_GetString(cmd, &cmdlen);
for (ct = command_table; ct->cmd; ct++) {
if (Jim_CompareStringImmediate(interp, cmd, ct->cmd)) {
break;
}
if (strncmp(cmdstr, ct->cmd, cmdlen) == 0) {
if (partial) {
if (help) {
show_cmd_usage(interp, command_table, argc, argv);
return &dummy_subcmd;
}
bad_subcmd(interp, command_table, "ambiguous", argv[0], argv[1 + help]);
return 0;
}
partial = ct;
}
continue;
}
if (partial && !ct->cmd) {
ct = partial;
}
if (!ct->cmd) {
if (help) {
show_cmd_usage(interp, command_table, argc, argv);
return &dummy_subcmd;
}
bad_subcmd(interp, command_table, "unknown", argv[0], argv[1 + help]);
return 0;
}
if (help) {
Jim_SetResultString(interp, "Usage: ", -1);
add_cmd_usage(interp, ct, argv[0]);
return &dummy_subcmd;
}
if (argc - 2 < ct->minargs || (ct->maxargs >= 0 && argc - 2 > ct->maxargs)) {
Jim_SetResultString(interp, "wrong # args: should be \"", -1);
add_cmd_usage(interp, ct, argv[0]);
Jim_AppendStrings(interp, Jim_GetResult(interp), "\"", NULL);
return 0;
}
return ct;
}
int Jim_CallSubCmd(Jim_Interp *interp, const jim_subcmd_type * ct, int argc, Jim_Obj *const *argv)
{
int ret = JIM_ERR;
|
| ︙ | ︙ | |||
19828 19829 19830 19831 19832 19833 19834 |
}
else if (uc <= 0xffff) {
*p++ = 0xe0 | ((uc & 0xf000) >> 12);
*p++ = 0x80 | ((uc & 0xfc0) >> 6);
*p = 0x80 | (uc & 0x3f);
return 3;
}
| | | 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 |
}
else if (uc <= 0xffff) {
*p++ = 0xe0 | ((uc & 0xf000) >> 12);
*p++ = 0x80 | ((uc & 0xfc0) >> 6);
*p = 0x80 | (uc & 0x3f);
return 3;
}
else {
*p++ = 0xf0 | ((uc & 0x1c0000) >> 18);
*p++ = 0x80 | ((uc & 0x3f000) >> 12);
*p++ = 0x80 | ((uc & 0xfc0) >> 6);
*p = 0x80 | (uc & 0x3f);
return 4;
}
|
| ︙ | ︙ | |||
20019 20020 20021 20022 20023 20024 20025 |
useShort = 0;
if (ch == 'h') {
useShort = 1;
format += step;
step = utf8_tounicode(format, &ch);
} else if (ch == 'l') {
| | | 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 |
useShort = 0;
if (ch == 'h') {
useShort = 1;
format += step;
step = utf8_tounicode(format, &ch);
} else if (ch == 'l') {
format += step;
step = utf8_tounicode(format, &ch);
if (ch == 'l') {
format += step;
step = utf8_tounicode(format, &ch);
}
}
|
| ︙ | ︙ | |||
20046 20047 20048 20049 20050 20051 20052 |
case '\0':
msg = "format string ended in middle of field specifier";
goto errorMsg;
case 's': {
formatted_buf = Jim_GetString(objv[objIndex], &formatted_bytes);
formatted_chars = Jim_Utf8Length(interp, objv[objIndex]);
if (gotPrecision && (precision < formatted_chars)) {
| | | | | 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 |
case '\0':
msg = "format string ended in middle of field specifier";
goto errorMsg;
case 's': {
formatted_buf = Jim_GetString(objv[objIndex], &formatted_bytes);
formatted_chars = Jim_Utf8Length(interp, objv[objIndex]);
if (gotPrecision && (precision < formatted_chars)) {
formatted_chars = precision;
formatted_bytes = utf8_index(formatted_buf, precision);
}
break;
}
case 'c': {
jim_wide code;
if (Jim_GetWide(interp, objv[objIndex], &code) != JIM_OK) {
goto error;
}
formatted_bytes = utf8_getchars(spec, code);
formatted_buf = spec;
formatted_chars = 1;
break;
}
case 'b': {
unsigned jim_wide w;
int length;
int i;
int j;
if (Jim_GetWide(interp, objv[objIndex], (jim_wide *)&w) != JIM_OK) {
goto error;
}
length = sizeof(w) * 8;
if (num_buffer_size < length + 1) {
num_buffer_size = length + 1;
num_buffer = Jim_Realloc(num_buffer, num_buffer_size);
}
j = 0;
for (i = length; i > 0; ) {
|
| ︙ | ︙ | |||
20104 20105 20106 20107 20108 20109 20110 |
case 'e':
case 'E':
case 'f':
case 'g':
case 'G':
doubleType = 1;
| | | | | 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 |
case 'e':
case 'E':
case 'f':
case 'g':
case 'G':
doubleType = 1;
case 'd':
case 'u':
case 'o':
case 'x':
case 'X': {
jim_wide w;
double d;
int length;
if (width) {
p += sprintf(p, "%ld", width);
}
if (gotPrecision) {
p += sprintf(p, ".%ld", precision);
}
if (doubleType) {
if (Jim_GetDouble(interp, objv[objIndex], &d) != JIM_OK) {
goto error;
}
length = MAX_FLOAT_WIDTH;
}
else {
|
| ︙ | ︙ | |||
20153 20154 20155 20156 20157 20158 20159 |
}
#endif
}
*p++ = (char) ch;
*p = '\0';
| | | | | 20342 20343 20344 20345 20346 20347 20348 20349 20350 20351 20352 20353 20354 20355 20356 20357 20358 20359 20360 20361 20362 20363 20364 20365 20366 20367 20368 20369 20370 20371 20372 20373 20374 20375 20376 20377 20378 20379 20380 20381 20382 |
}
#endif
}
*p++ = (char) ch;
*p = '\0';
if (width > length) {
length = width;
}
if (gotPrecision) {
length += precision;
}
if (num_buffer_size < length + 1) {
num_buffer_size = length + 1;
num_buffer = Jim_Realloc(num_buffer, num_buffer_size);
}
if (doubleType) {
snprintf(num_buffer, length + 1, spec, d);
}
else {
formatted_bytes = snprintf(num_buffer, length + 1, spec, w);
}
formatted_chars = formatted_bytes = strlen(num_buffer);
formatted_buf = num_buffer;
break;
}
default: {
spec[0] = ch;
spec[1] = '\0';
Jim_SetResultFormatted(interp, "bad field specifier \"%s\"", spec);
goto error;
}
}
|
| ︙ | ︙ | |||
20231 20232 20233 20234 20235 20236 20237 | #define REG_MAX_PAREN 100 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 20420 20421 20422 20423 20424 20425 20426 20427 20428 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 |
#define REG_MAX_PAREN 100
#define END 0
#define BOL 1
#define EOL 2
#define ANY 3
#define ANYOF 4
#define ANYBUT 5
#define BRANCH 6
#define BACK 7
#define EXACTLY 8
#define NOTHING 9
#define REP 10
#define REPMIN 11
#define REPX 12
#define REPXMIN 13
#define BOLX 14
#define EOLX 15
#define WORDA 16
#define WORDZ 17
#define OPENNC 1000
#define OPEN 1001
#define CLOSENC 2000
#define CLOSE 2001
#define CLOSE_END (CLOSE+REG_MAX_PAREN)
#define REG_MAGIC 0xFADED00D
#define OP(preg, p) (preg->program[p])
#define NEXT(preg, p) (preg->program[p + 1])
#define OPERAND(p) ((p) + 2)
#define FAIL(R,M) { (R)->err = (M); return (M); }
#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?' || (c) == '{')
#define META "^$.[()|?{+*"
#define HASWIDTH 1
#define SIMPLE 2
#define SPSTART 4
#define WORST 0
#define MAX_REP_COUNT 1000000
static int reg(regex_t *preg, int paren , int *flagp );
static int regpiece(regex_t *preg, int *flagp );
static int regbranch(regex_t *preg, int *flagp );
static int regatom(regex_t *preg, int *flagp );
static int regnode(regex_t *preg, int op );
static int regnext(regex_t *preg, int p );
static void regc(regex_t *preg, int b );
static int reginsert(regex_t *preg, int op, int size, int opnd );
|
| ︙ | ︙ | |||
20329 20330 20331 20332 20333 20334 20335 | fprintf(stderr, "Compiling: '%s'\n", exp); #endif memset(preg, 0, sizeof(*preg)); if (exp == NULL) FAIL(preg, REG_ERR_NULL_ARGUMENT); | | | | | | | | | | | 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 20530 20531 20532 20533 20534 20535 20536 20537 20538 20539 20540 20541 20542 20543 20544 20545 20546 20547 20548 20549 20550 20551 20552 20553 20554 20555 20556 20557 20558 20559 20560 |
fprintf(stderr, "Compiling: '%s'\n", exp);
#endif
memset(preg, 0, sizeof(*preg));
if (exp == NULL)
FAIL(preg, REG_ERR_NULL_ARGUMENT);
preg->cflags = cflags;
preg->regparse = exp;
preg->proglen = (strlen(exp) + 1) * 5;
preg->program = malloc(preg->proglen * sizeof(int));
if (preg->program == NULL)
FAIL(preg, REG_ERR_NOMEM);
regc(preg, REG_MAGIC);
if (reg(preg, 0, &flags) == 0) {
return preg->err;
}
if (preg->re_nsub >= REG_MAX_PAREN)
FAIL(preg,REG_ERR_TOO_BIG);
preg->regstart = 0;
preg->reganch = 0;
preg->regmust = 0;
preg->regmlen = 0;
scan = 1;
if (OP(preg, regnext(preg, scan)) == END) {
scan = OPERAND(scan);
if (OP(preg, scan) == EXACTLY) {
preg->regstart = preg->program[OPERAND(scan)];
}
else if (OP(preg, scan) == BOL)
preg->reganch++;
if (flags&SPSTART) {
|
| ︙ | ︙ | |||
20388 20389 20390 20391 20392 20393 20394 | #ifdef DEBUG regdump(preg); #endif return 0; } | | | | | | | | | | | | 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 20607 20608 20609 20610 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 |
#ifdef DEBUG
regdump(preg);
#endif
return 0;
}
static int reg(regex_t *preg, int paren , int *flagp )
{
int ret;
int br;
int ender;
int parno = 0;
int flags;
*flagp = HASWIDTH;
if (paren) {
if (preg->regparse[0] == '?' && preg->regparse[1] == ':') {
preg->regparse += 2;
parno = -1;
}
else {
parno = ++preg->re_nsub;
}
ret = regnode(preg, OPEN+parno);
} else
ret = 0;
br = regbranch(preg, &flags);
if (br == 0)
return 0;
if (ret != 0)
regtail(preg, ret, br);
else
ret = br;
if (!(flags&HASWIDTH))
*flagp &= ~HASWIDTH;
*flagp |= flags&SPSTART;
while (*preg->regparse == '|') {
preg->regparse++;
br = regbranch(preg, &flags);
if (br == 0)
return 0;
regtail(preg, ret, br);
if (!(flags&HASWIDTH))
*flagp &= ~HASWIDTH;
*flagp |= flags&SPSTART;
}
ender = regnode(preg, (paren) ? CLOSE+parno : END);
regtail(preg, ret, ender);
for (br = ret; br != 0; br = regnext(preg, br))
regoptail(preg, br, ender);
if (paren && *preg->regparse++ != ')') {
preg->err = REG_ERR_UNMATCHED_PAREN;
return 0;
} else if (!paren && *preg->regparse != '\0') {
if (*preg->regparse == ')') {
preg->err = REG_ERR_UNMATCHED_PAREN;
return 0;
|
| ︙ | ︙ | |||
20466 20467 20468 20469 20470 20471 20472 |
static int regbranch(regex_t *preg, int *flagp )
{
int ret;
int chain;
int latest;
int flags;
| | | | 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 20672 20673 20674 20675 20676 20677 20678 20679 20680 20681 20682 20683 20684 20685 20686 20687 |
static int regbranch(regex_t *preg, int *flagp )
{
int ret;
int chain;
int latest;
int flags;
*flagp = WORST;
ret = regnode(preg, BRANCH);
chain = 0;
while (*preg->regparse != '\0' && *preg->regparse != ')' &&
*preg->regparse != '|') {
latest = regpiece(preg, &flags);
if (latest == 0)
return 0;
*flagp |= flags&HASWIDTH;
if (chain == 0) {
*flagp |= flags&SPSTART;
}
else {
regtail(preg, chain, latest);
}
chain = latest;
}
if (chain == 0)
(void) regnode(preg, NOTHING);
return(ret);
}
static int regpiece(regex_t *preg, int *flagp)
{
|
| ︙ | ︙ | |||
20514 20515 20516 20517 20518 20519 20520 |
}
if (!(flags&HASWIDTH) && op != '?') {
preg->err = REG_ERR_OPERAND_COULD_BE_EMPTY;
return 0;
}
| | | 20703 20704 20705 20706 20707 20708 20709 20710 20711 20712 20713 20714 20715 20716 20717 |
}
if (!(flags&HASWIDTH) && op != '?') {
preg->err = REG_ERR_OPERAND_COULD_BE_EMPTY;
return 0;
}
if (op == '{') {
char *end;
min = strtoul(preg->regparse + 1, &end, 10);
if (end == preg->regparse + 1) {
preg->err = REG_ERR_BAD_COUNT;
return 0;
|
| ︙ | ︙ | |||
20586 20587 20588 20589 20590 20591 20592 |
}
static void reg_addrange(regex_t *preg, int lower, int upper)
{
if (lower > upper) {
reg_addrange(preg, upper, lower);
}
| | | 20775 20776 20777 20778 20779 20780 20781 20782 20783 20784 20785 20786 20787 20788 20789 |
}
static void reg_addrange(regex_t *preg, int lower, int upper)
{
if (lower > upper) {
reg_addrange(preg, upper, lower);
}
regc(preg, upper - lower + 1);
regc(preg, lower);
}
static void reg_addrange_str(regex_t *preg, const char *str)
{
while (*str) {
|
| ︙ | ︙ | |||
20654 20655 20656 20657 20658 20659 20660 |
case 'f': *ch = '\f'; break;
case 'n': *ch = '\n'; break;
case 'r': *ch = '\r'; break;
case 't': *ch = '\t'; break;
case 'v': *ch = '\v'; break;
case 'u':
if (*s == '{') {
| | | | 20843 20844 20845 20846 20847 20848 20849 20850 20851 20852 20853 20854 20855 20856 20857 20858 20859 20860 20861 20862 20863 |
case 'f': *ch = '\f'; break;
case 'n': *ch = '\n'; break;
case 'r': *ch = '\r'; break;
case 't': *ch = '\t'; break;
case 'v': *ch = '\v'; break;
case 'u':
if (*s == '{') {
n = parse_hex(s + 1, 6, ch);
if (n > 0 && s[n + 1] == '}' && *ch >= 0 && *ch <= 0x1fffff) {
s += n + 2;
}
else {
*ch = 'u';
}
}
else if ((n = parse_hex(s, 4, ch)) > 0) {
s += n;
}
break;
|
| ︙ | ︙ | |||
20695 20696 20697 20698 20699 20700 20701 | int ret; int flags; int nocase = (preg->cflags & REG_ICASE); int ch; int n = reg_utf8_tounicode_case(preg->regparse, &ch, nocase); | | | | | | | | 20884 20885 20886 20887 20888 20889 20890 20891 20892 20893 20894 20895 20896 20897 20898 20899 20900 20901 20902 20903 20904 20905 20906 20907 20908 20909 20910 20911 20912 20913 20914 20915 20916 20917 20918 20919 20920 20921 20922 20923 20924 20925 20926 20927 20928 20929 20930 20931 20932 20933 20934 20935 20936 20937 20938 20939 20940 20941 20942 |
int ret;
int flags;
int nocase = (preg->cflags & REG_ICASE);
int ch;
int n = reg_utf8_tounicode_case(preg->regparse, &ch, nocase);
*flagp = WORST;
preg->regparse += n;
switch (ch) {
case '^':
ret = regnode(preg, BOL);
break;
case '$':
ret = regnode(preg, EOL);
break;
case '.':
ret = regnode(preg, ANY);
*flagp |= HASWIDTH|SIMPLE;
break;
case '[': {
const char *pattern = preg->regparse;
if (*pattern == '^') {
ret = regnode(preg, ANYBUT);
pattern++;
} else
ret = regnode(preg, ANYOF);
if (*pattern == ']' || *pattern == '-') {
reg_addrange(preg, *pattern, *pattern);
pattern++;
}
while (*pattern && *pattern != ']') {
int start;
int end;
pattern += reg_utf8_tounicode_case(pattern, &start, nocase);
if (start == '\\') {
pattern += reg_decode_escape(pattern, &start);
if (start == 0) {
preg->err = REG_ERR_NULL_CHAR;
return 0;
}
}
if (pattern[0] == '-' && pattern[1] && pattern[1] != ']') {
pattern += utf8_tounicode(pattern, &end);
pattern += reg_utf8_tounicode_case(pattern, &end, nocase);
if (end == '\\') {
pattern += reg_decode_escape(pattern, &end);
if (end == 0) {
preg->err = REG_ERR_NULL_CHAR;
return 0;
|
| ︙ | ︙ | |||
20766 20767 20768 20769 20770 20771 20772 |
CC_ALPHA, CC_ALNUM, CC_SPACE, CC_BLANK, CC_UPPER, CC_LOWER,
CC_DIGIT, CC_XDIGIT, CC_CNTRL, CC_GRAPH, CC_PRINT, CC_PUNCT,
CC_NUM
};
int i;
for (i = 0; i < CC_NUM; i++) {
| | | | | 20955 20956 20957 20958 20959 20960 20961 20962 20963 20964 20965 20966 20967 20968 20969 20970 20971 20972 20973 20974 20975 20976 20977 20978 20979 20980 |
CC_ALPHA, CC_ALNUM, CC_SPACE, CC_BLANK, CC_UPPER, CC_LOWER,
CC_DIGIT, CC_XDIGIT, CC_CNTRL, CC_GRAPH, CC_PRINT, CC_PUNCT,
CC_NUM
};
int i;
for (i = 0; i < CC_NUM; i++) {
int n = strlen(character_class[i]);
if (strncmp(pattern, character_class[i], n) == 0) {
pattern += n + 1;
break;
}
}
if (i != CC_NUM) {
switch (i) {
case CC_ALNUM:
reg_addrange(preg, '0', '9');
case CC_ALPHA:
if ((preg->cflags & REG_ICASE) == 0) {
reg_addrange(preg, 'a', 'z');
}
reg_addrange(preg, 'A', 'Z');
break;
case CC_SPACE:
|
| ︙ | ︙ | |||
20799 20800 20801 20802 20803 20804 20805 | break; case CC_LOWER: reg_addrange(preg, 'a', 'z'); break; case CC_XDIGIT: reg_addrange(preg, 'a', 'f'); reg_addrange(preg, 'A', 'F'); | | | 20988 20989 20990 20991 20992 20993 20994 20995 20996 20997 20998 20999 21000 21001 21002 | break; case CC_LOWER: reg_addrange(preg, 'a', 'z'); break; case CC_XDIGIT: reg_addrange(preg, 'a', 'f'); reg_addrange(preg, 'A', 'F'); case CC_DIGIT: reg_addrange(preg, '0', '9'); break; case CC_CNTRL: reg_addrange(preg, 0, 31); reg_addrange(preg, 127, 127); break; |
| ︙ | ︙ | |||
20823 20824 20825 20826 20827 20828 20829 |
reg_addrange(preg, '[', '`');
reg_addrange(preg, '{', '~');
break;
}
continue;
}
}
| | | 21012 21013 21014 21015 21016 21017 21018 21019 21020 21021 21022 21023 21024 21025 21026 |
reg_addrange(preg, '[', '`');
reg_addrange(preg, '{', '~');
break;
}
continue;
}
}
reg_addrange(preg, start, start);
}
regc(preg, '\0');
if (*pattern) {
pattern++;
}
|
| ︙ | ︙ | |||
20846 20847 20848 20849 20850 20851 20852 | return 0; *flagp |= flags&(HASWIDTH|SPSTART); break; case '\0': case '|': case ')': preg->err = REG_ERR_INTERNAL; | | | 21035 21036 21037 21038 21039 21040 21041 21042 21043 21044 21045 21046 21047 21048 21049 |
return 0;
*flagp |= flags&(HASWIDTH|SPSTART);
break;
case '\0':
case '|':
case ')':
preg->err = REG_ERR_INTERNAL;
return 0;
case '?':
case '+':
case '*':
case '{':
preg->err = REG_ERR_COUNT_FOLLOWS_NOTHING;
return 0;
case '\\':
|
| ︙ | ︙ | |||
20899 20900 20901 20902 20903 20904 20905 | case 's': case 'S': ret = regnode(preg, ch == 's' ? ANYOF : ANYBUT); reg_addrange_str(preg," \t\r\n\f\v"); regc(preg, '\0'); *flagp |= HASWIDTH|SIMPLE; break; | | | | | | | | | | | | 21088 21089 21090 21091 21092 21093 21094 21095 21096 21097 21098 21099 21100 21101 21102 21103 21104 21105 21106 21107 21108 21109 21110 21111 21112 21113 21114 21115 21116 21117 21118 21119 21120 21121 21122 21123 21124 21125 21126 21127 21128 21129 21130 21131 21132 21133 21134 21135 21136 21137 21138 21139 21140 21141 21142 21143 21144 21145 21146 21147 21148 21149 |
case 's':
case 'S':
ret = regnode(preg, ch == 's' ? ANYOF : ANYBUT);
reg_addrange_str(preg," \t\r\n\f\v");
regc(preg, '\0');
*flagp |= HASWIDTH|SIMPLE;
break;
default:
preg->regparse--;
goto de_fault;
}
break;
de_fault:
default: {
int added = 0;
preg->regparse -= n;
ret = regnode(preg, EXACTLY);
while (*preg->regparse && strchr(META, *preg->regparse) == NULL) {
n = reg_utf8_tounicode_case(preg->regparse, &ch, (preg->cflags & REG_ICASE));
if (ch == '\\' && preg->regparse[n]) {
if (strchr("<>mMwWdDsSAZ", preg->regparse[n])) {
break;
}
n += reg_decode_escape(preg->regparse + n, &ch);
if (ch == 0) {
preg->err = REG_ERR_NULL_CHAR;
return 0;
}
}
if (ISMULT(preg->regparse[n])) {
if (added) {
break;
}
regc(preg, ch);
added++;
preg->regparse += n;
break;
}
regc(preg, ch);
added++;
preg->regparse += n;
}
regc(preg, '\0');
*flagp |= HASWIDTH;
|
| ︙ | ︙ | |||
20977 20978 20979 20980 20981 20982 20983 |
}
static int regnode(regex_t *preg, int op)
{
reg_grow(preg, 2);
| | | | | | | | | | | | | | | | | | | | | | | 21166 21167 21168 21169 21170 21171 21172 21173 21174 21175 21176 21177 21178 21179 21180 21181 21182 21183 21184 21185 21186 21187 21188 21189 21190 21191 21192 21193 21194 21195 21196 21197 21198 21199 21200 21201 21202 21203 21204 21205 21206 21207 21208 21209 21210 21211 21212 21213 21214 21215 21216 21217 21218 21219 21220 21221 21222 21223 21224 21225 21226 21227 21228 21229 21230 21231 21232 21233 21234 21235 21236 21237 21238 21239 21240 21241 21242 21243 21244 21245 21246 21247 21248 21249 21250 21251 21252 21253 21254 21255 21256 21257 21258 21259 21260 21261 21262 21263 21264 21265 21266 21267 21268 21269 21270 21271 21272 21273 21274 21275 21276 21277 21278 21279 21280 21281 21282 21283 21284 21285 21286 21287 21288 21289 21290 21291 21292 21293 21294 21295 21296 21297 21298 21299 21300 21301 21302 21303 21304 21305 21306 21307 21308 21309 21310 21311 21312 21313 21314 21315 21316 21317 21318 21319 21320 21321 21322 21323 21324 21325 21326 21327 21328 21329 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 21345 21346 21347 21348 21349 21350 |
}
static int regnode(regex_t *preg, int op)
{
reg_grow(preg, 2);
preg->program[preg->p++] = op;
preg->program[preg->p++] = 0;
return preg->p - 2;
}
static void regc(regex_t *preg, int b )
{
reg_grow(preg, 1);
preg->program[preg->p++] = b;
}
static int reginsert(regex_t *preg, int op, int size, int opnd )
{
reg_grow(preg, size);
memmove(preg->program + opnd + size, preg->program + opnd, sizeof(int) * (preg->p - opnd));
memset(preg->program + opnd, 0, sizeof(int) * size);
preg->program[opnd] = op;
preg->p += size;
return opnd + size;
}
static void regtail(regex_t *preg, int p, int val)
{
int scan;
int temp;
int offset;
scan = p;
for (;;) {
temp = regnext(preg, scan);
if (temp == 0)
break;
scan = temp;
}
if (OP(preg, scan) == BACK)
offset = scan - val;
else
offset = val - scan;
preg->program[scan + 1] = offset;
}
static void regoptail(regex_t *preg, int p, int val )
{
if (p != 0 && OP(preg, p) == BRANCH) {
regtail(preg, OPERAND(p), val);
}
}
static int regtry(regex_t *preg, const char *string );
static int regmatch(regex_t *preg, int prog);
static int regrepeat(regex_t *preg, int p, int max);
int regexec(regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags)
{
const char *s;
int scan;
if (preg == NULL || preg->program == NULL || string == NULL) {
return REG_ERR_NULL_ARGUMENT;
}
if (*preg->program != REG_MAGIC) {
return REG_ERR_CORRUPTED;
}
#ifdef DEBUG
fprintf(stderr, "regexec: %s\n", string);
regdump(preg);
#endif
preg->eflags = eflags;
preg->pmatch = pmatch;
preg->nmatch = nmatch;
preg->start = string;
for (scan = OPERAND(1); scan != 0; scan += regopsize(preg, scan)) {
int op = OP(preg, scan);
if (op == END)
break;
if (op == REPX || op == REPXMIN)
preg->program[scan + 4] = 0;
}
if (preg->regmust != 0) {
s = string;
while ((s = str_find(s, preg->program[preg->regmust], preg->cflags & REG_ICASE)) != NULL) {
if (prefix_cmp(preg->program + preg->regmust, preg->regmlen, s, preg->cflags & REG_ICASE) >= 0) {
break;
}
s++;
}
if (s == NULL)
return REG_NOMATCH;
}
preg->regbol = string;
if (preg->reganch) {
if (eflags & REG_NOTBOL) {
goto nextline;
}
while (1) {
if (regtry(preg, string)) {
return REG_NOERROR;
}
if (*string) {
nextline:
if (preg->cflags & REG_NEWLINE) {
string = strchr(string, '\n');
if (string) {
preg->regbol = ++string;
continue;
}
}
}
return REG_NOMATCH;
}
}
s = string;
if (preg->regstart != '\0') {
while ((s = str_find(s, preg->regstart, preg->cflags & REG_ICASE)) != NULL) {
if (regtry(preg, s))
return REG_NOERROR;
s++;
}
}
else
while (1) {
if (regtry(preg, s))
return REG_NOERROR;
if (*s == '\0') {
break;
}
else {
int c;
s += utf8_tounicode(s, &c);
}
}
return REG_NOMATCH;
}
static int regtry( regex_t *preg, const char *string )
{
int i;
preg->reginput = string;
for (i = 0; i < preg->nmatch; i++) {
|
| ︙ | ︙ | |||
21188 21189 21190 21191 21192 21193 21194 |
}
return -1;
}
static int reg_range_find(const int *range, int c)
{
while (*range) {
| | | | 21377 21378 21379 21380 21381 21382 21383 21384 21385 21386 21387 21388 21389 21390 21391 21392 21393 21394 21395 21396 21397 21398 21399 21400 21401 21402 21403 |
}
return -1;
}
static int reg_range_find(const int *range, int c)
{
while (*range) {
if (c >= range[1] && c <= (range[0] + range[1] - 1)) {
return 1;
}
range += 2;
}
return 0;
}
static const char *str_find(const char *string, int c, int nocase)
{
if (nocase) {
c = utf8_upper(c);
}
while (*string) {
int ch;
int n = reg_utf8_tounicode_case(string, &ch, nocase);
if (c == ch) {
return string;
|
| ︙ | ︙ | |||
21244 21245 21246 21247 21248 21249 21250 |
}
save = preg->reginput;
no = regrepeat(preg, scan + 5, max);
if (no < min) {
return 0;
}
if (matchmin) {
| | | | | | | | | | | | | | | | | | | | | | | | 21433 21434 21435 21436 21437 21438 21439 21440 21441 21442 21443 21444 21445 21446 21447 21448 21449 21450 21451 21452 21453 21454 21455 21456 21457 21458 21459 21460 21461 21462 21463 21464 21465 21466 21467 21468 21469 21470 21471 21472 21473 21474 21475 21476 21477 21478 21479 21480 21481 21482 21483 21484 21485 21486 21487 21488 21489 21490 21491 21492 21493 21494 21495 21496 21497 21498 21499 21500 21501 21502 21503 21504 21505 21506 21507 21508 21509 21510 21511 21512 21513 21514 21515 21516 21517 21518 21519 21520 21521 21522 21523 21524 21525 21526 21527 21528 21529 21530 21531 21532 21533 21534 21535 21536 21537 21538 21539 21540 21541 21542 21543 21544 21545 21546 21547 21548 21549 21550 21551 21552 21553 21554 21555 21556 21557 21558 21559 21560 21561 21562 21563 21564 21565 21566 21567 21568 21569 21570 21571 21572 21573 21574 21575 21576 21577 21578 21579 21580 21581 21582 21583 21584 21585 21586 21587 21588 21589 21590 21591 21592 21593 21594 21595 21596 |
}
save = preg->reginput;
no = regrepeat(preg, scan + 5, max);
if (no < min) {
return 0;
}
if (matchmin) {
max = no;
no = min;
}
while (1) {
if (matchmin) {
if (no > max) {
break;
}
}
else {
if (no < min) {
break;
}
}
preg->reginput = save + utf8_index(save, no);
reg_utf8_tounicode_case(preg->reginput, &c, (preg->cflags & REG_ICASE));
if (reg_iseol(preg, nextch) || c == nextch) {
if (regmatch(preg, next)) {
return(1);
}
}
if (matchmin) {
no++;
}
else {
no--;
}
}
return(0);
}
static int regmatchrepeat(regex_t *preg, int scan, int matchmin)
{
int *scanpt = preg->program + scan;
int max = scanpt[2];
int min = scanpt[3];
if (scanpt[4] < min) {
scanpt[4]++;
if (regmatch(preg, scan + 5)) {
return 1;
}
scanpt[4]--;
return 0;
}
if (scanpt[4] > max) {
return 0;
}
if (matchmin) {
if (regmatch(preg, regnext(preg, scan))) {
return 1;
}
scanpt[4]++;
if (regmatch(preg, scan + 5)) {
return 1;
}
scanpt[4]--;
return 0;
}
if (scanpt[4] < max) {
scanpt[4]++;
if (regmatch(preg, scan + 5)) {
return 1;
}
scanpt[4]--;
}
return regmatch(preg, regnext(preg, scan));
}
static int regmatch(regex_t *preg, int prog)
{
int scan;
int next;
const char *save;
scan = prog;
#ifdef DEBUG
if (scan != 0 && regnarrate)
fprintf(stderr, "%s(\n", regprop(scan));
#endif
while (scan != 0) {
int n;
int c;
#ifdef DEBUG
if (regnarrate) {
fprintf(stderr, "%3d: %s...\n", scan, regprop(OP(preg, scan)));
}
#endif
next = regnext(preg, scan);
n = reg_utf8_tounicode_case(preg->reginput, &c, (preg->cflags & REG_ICASE));
switch (OP(preg, scan)) {
case BOLX:
if ((preg->eflags & REG_NOTBOL)) {
return(0);
}
case BOL:
if (preg->reginput != preg->regbol) {
return(0);
}
break;
case EOLX:
if (c != 0) {
return 0;
}
break;
case EOL:
if (!reg_iseol(preg, c)) {
return(0);
}
break;
case WORDA:
if ((!isalnum(UCHAR(c))) && c != '_')
return(0);
if (preg->reginput > preg->regbol &&
(isalnum(UCHAR(preg->reginput[-1])) || preg->reginput[-1] == '_'))
return(0);
break;
case WORDZ:
if (preg->reginput > preg->regbol) {
if (reg_iseol(preg, c) || !isalnum(UCHAR(c)) || c != '_') {
c = preg->reginput[-1];
if (isalnum(UCHAR(c)) || c == '_') {
break;
}
}
}
return(0);
case ANY:
if (reg_iseol(preg, c))
return 0;
preg->reginput += n;
break;
|
| ︙ | ︙ | |||
21433 21434 21435 21436 21437 21438 21439 | preg->reginput += n; break; case NOTHING: break; case BACK: break; case BRANCH: | | | | | | 21622 21623 21624 21625 21626 21627 21628 21629 21630 21631 21632 21633 21634 21635 21636 21637 21638 21639 21640 21641 21642 21643 21644 21645 21646 21647 21648 21649 21650 21651 21652 21653 21654 21655 21656 21657 21658 21659 21660 |
preg->reginput += n;
break;
case NOTHING:
break;
case BACK:
break;
case BRANCH:
if (OP(preg, next) != BRANCH)
next = OPERAND(scan);
else {
do {
save = preg->reginput;
if (regmatch(preg, OPERAND(scan))) {
return(1);
}
preg->reginput = save;
scan = regnext(preg, scan);
} while (scan != 0 && OP(preg, scan) == BRANCH);
return(0);
}
break;
case REP:
case REPMIN:
return regmatchsimplerepeat(preg, scan, OP(preg, scan) == REPMIN);
case REPX:
case REPXMIN:
return regmatchrepeat(preg, scan, OP(preg, scan) == REPXMIN);
case END:
return 1;
case OPENNC:
case CLOSENC:
return regmatch(preg, next);
default:
if (OP(preg, scan) >= OPEN+1 && OP(preg, scan) < CLOSE_END) {
|
| ︙ | ︙ | |||
21504 21505 21506 21507 21508 21509 21510 |
int ch;
int n;
scan = preg->reginput;
opnd = OPERAND(p);
switch (OP(preg, p)) {
case ANY:
| | | 21693 21694 21695 21696 21697 21698 21699 21700 21701 21702 21703 21704 21705 21706 21707 |
int ch;
int n;
scan = preg->reginput;
opnd = OPERAND(p);
switch (OP(preg, p)) {
case ANY:
while (!reg_iseol(preg, *scan) && count < max) {
count++;
scan++;
}
break;
case EXACTLY:
while (count < max) {
|
| ︙ | ︙ | |||
21540 21541 21542 21543 21544 21545 21546 |
if (reg_iseol(preg, ch) || reg_range_find(preg->program + opnd, ch) != 0) {
break;
}
count++;
scan += n;
}
break;
| | | | 21729 21730 21731 21732 21733 21734 21735 21736 21737 21738 21739 21740 21741 21742 21743 21744 21745 |
if (reg_iseol(preg, ch) || reg_range_find(preg->program + opnd, ch) != 0) {
break;
}
count++;
scan += n;
}
break;
default:
preg->err = REG_ERR_INTERNAL;
count = 0;
break;
}
preg->reginput = scan;
return(count);
}
|
| ︙ | ︙ | |||
21567 21568 21569 21570 21571 21572 21573 |
return(p-offset);
else
return(p+offset);
}
static int regopsize(regex_t *preg, int p )
{
| | | 21756 21757 21758 21759 21760 21761 21762 21763 21764 21765 21766 21767 21768 21769 21770 |
return(p-offset);
else
return(p+offset);
}
static int regopsize(regex_t *preg, int p )
{
switch (OP(preg, p)) {
case REP:
case REPMIN:
case REPX:
case REPXMIN:
return 5;
|
| ︙ | ︙ | |||
21688 21689 21690 21691 21692 21693 21694 |
DIR *opendir(const char *name)
{
DIR *dir = 0;
if (name && name[0]) {
size_t base_length = strlen(name);
| | | | | 21877 21878 21879 21880 21881 21882 21883 21884 21885 21886 21887 21888 21889 21890 21891 21892 21893 21894 21895 21896 21897 21898 21899 21900 21901 21902 21903 21904 21905 21906 |
DIR *opendir(const char *name)
{
DIR *dir = 0;
if (name && name[0]) {
size_t base_length = strlen(name);
const char *all =
strchr("/\\", name[base_length - 1]) ? "*" : "/*";
if ((dir = (DIR *) Jim_Alloc(sizeof *dir)) != 0 &&
(dir->name = (char *)Jim_Alloc(base_length + strlen(all) + 1)) != 0) {
strcat(strcpy(dir->name, name), all);
if ((dir->handle = (long)_findfirst(dir->name, &dir->info)) != -1)
dir->result.d_name = 0;
else {
Jim_Free(dir->name);
Jim_Free(dir);
dir = 0;
}
}
else {
Jim_Free(dir);
dir = 0;
errno = ENOMEM;
}
}
else {
errno = EINVAL;
|
| ︙ | ︙ | |||
21725 21726 21727 21728 21729 21730 21731 |
if (dir) {
if (dir->handle != -1)
result = _findclose(dir->handle);
Jim_Free(dir->name);
Jim_Free(dir);
}
| | | 21914 21915 21916 21917 21918 21919 21920 21921 21922 21923 21924 21925 21926 21927 21928 |
if (dir) {
if (dir->handle != -1)
result = _findclose(dir->handle);
Jim_Free(dir->name);
Jim_Free(dir);
}
if (result == -1)
errno = EBADF;
return result;
}
struct dirent *readdir(DIR * dir)
{
struct dirent *result = 0;
|
| ︙ | ︙ | |||
21808 21809 21810 21811 21812 21813 21814 |
linenoiseHistorySave(filename);
#endif
}
void Jim_HistoryShow(void)
{
#ifdef USE_LINENOISE
| | | 21997 21998 21999 22000 22001 22002 22003 22004 22005 22006 22007 22008 22009 22010 22011 |
linenoiseHistorySave(filename);
#endif
}
void Jim_HistoryShow(void)
{
#ifdef USE_LINENOISE
int i;
int len;
char **history = linenoiseHistory(&len);
for (i = 0; i < len; i++) {
printf("%4d %s\n", i + 1, history[i]);
}
#endif
|
| ︙ | ︙ | |||
21874 21875 21876 21877 21878 21879 21880 |
continue;
}
Jim_DecrRefCount(interp, scriptObjPtr);
retcode = JIM_OK;
goto out;
}
if (Jim_Length(scriptObjPtr) != 0) {
| | | | 22063 22064 22065 22066 22067 22068 22069 22070 22071 22072 22073 22074 22075 22076 22077 22078 22079 22080 22081 22082 22083 22084 22085 22086 22087 22088 22089 |
continue;
}
Jim_DecrRefCount(interp, scriptObjPtr);
retcode = JIM_OK;
goto out;
}
if (Jim_Length(scriptObjPtr) != 0) {
Jim_AppendString(interp, scriptObjPtr, "\n", 1);
}
Jim_AppendString(interp, scriptObjPtr, line, -1);
free(line);
if (Jim_ScriptIsComplete(interp, scriptObjPtr, &state))
break;
snprintf(prompt, sizeof(prompt), "%c> ", state);
}
#ifdef USE_LINENOISE
if (strcmp(Jim_String(scriptObjPtr), "h") == 0) {
Jim_HistoryShow();
Jim_DecrRefCount(interp, scriptObjPtr);
continue;
}
Jim_HistoryAdd(Jim_String(scriptObjPtr));
if (history_file) {
|
| ︙ | ︙ | |||
21929 21930 21931 21932 21933 21934 21935 |
extern int Jim_initjimshInit(Jim_Interp *interp);
static void JimSetArgv(Jim_Interp *interp, int argc, char *const argv[])
{
int n;
Jim_Obj *listObj = Jim_NewListObj(interp, NULL, 0);
| | | 22118 22119 22120 22121 22122 22123 22124 22125 22126 22127 22128 22129 22130 22131 22132 |
extern int Jim_initjimshInit(Jim_Interp *interp);
static void JimSetArgv(Jim_Interp *interp, int argc, char *const argv[])
{
int n;
Jim_Obj *listObj = Jim_NewListObj(interp, NULL, 0);
for (n = 0; n < argc; n++) {
Jim_Obj *obj = Jim_NewStringObj(interp, argv[n], -1);
Jim_ListAppendElement(interp, listObj, obj);
}
Jim_SetVariableStr(interp, "argv", listObj);
|
| ︙ | ︙ | |||
21969 21970 21971 21972 21973 21974 21975 |
int main(int argc, char *const argv[])
{
int retcode;
Jim_Interp *interp;
char *const orig_argv0 = argv[0];
| | | | | | | | 22158 22159 22160 22161 22162 22163 22164 22165 22166 22167 22168 22169 22170 22171 22172 22173 22174 22175 22176 22177 22178 22179 22180 22181 22182 22183 22184 22185 22186 22187 22188 22189 22190 22191 22192 22193 22194 22195 22196 22197 22198 22199 22200 22201 22202 22203 22204 22205 22206 22207 22208 |
int main(int argc, char *const argv[])
{
int retcode;
Jim_Interp *interp;
char *const orig_argv0 = argv[0];
if (argc > 1 && strcmp(argv[1], "--version") == 0) {
printf("%d.%d\n", JIM_VERSION / 100, JIM_VERSION % 100);
return 0;
}
else if (argc > 1 && strcmp(argv[1], "--help") == 0) {
usage(argv[0]);
return 0;
}
interp = Jim_CreateInterp();
Jim_RegisterCoreCommands(interp);
if (Jim_InitStaticExtensions(interp) != JIM_OK) {
JimPrintErrorMessage(interp);
}
Jim_SetVariableStrWithStr(interp, "jim::argv0", orig_argv0);
Jim_SetVariableStrWithStr(interp, JIM_INTERACTIVE, argc == 1 ? "1" : "0");
retcode = Jim_initjimshInit(interp);
if (argc == 1) {
if (retcode == JIM_ERR) {
JimPrintErrorMessage(interp);
}
if (retcode != JIM_EXIT) {
JimSetArgv(interp, 0, NULL);
retcode = Jim_InteractivePrompt(interp);
}
}
else {
if (argc > 2 && strcmp(argv[1], "-e") == 0) {
JimSetArgv(interp, argc - 3, argv + 3);
retcode = Jim_Eval(interp, argv[2]);
if (retcode != JIM_ERR) {
printf("%s\n", Jim_String(Jim_GetResult(interp)));
}
}
else {
|
| ︙ | ︙ |
Changes to autosetup/local.tcl.
|
| | > | | 1 2 3 4 5 6 7 8 9 10 |
# For this project, disable the pager for --help and --ref
# The user can still enable by using --nopager=0 or --disable-nopager
dict set autosetup(optdefault) nopager 1
# Searches for a usable Tcl (prefer 8.6, 8.5, 8.4) in the given paths
# Returns a dictionary of the contents of the tclConfig.sh file, or
# empty if not found
proc parse-tclconfig-sh {args} {
foreach p $args {
# Allow pointing directly to the path containing tclConfig.sh
|
| ︙ | ︙ | |||
24 25 26 27 28 29 30 |
if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} {
set value [regsub -all {\$\{.*\}} $value ""]
set tclconfig($name) [string trim $value ']
}
}
return [array get tclconfig]
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 25 26 27 28 29 30 31 |
if {[regexp {^(TCL_[^=]*)=(.*)$} $line -> name value]} {
set value [regsub -all {\$\{.*\}} $value ""]
set tclconfig($name) [string trim $value ']
}
}
return [array get tclconfig]
}
|
Changes to autosetup/pkg-config.tcl.
| ︙ | ︙ | |||
33 34 35 36 37 38 39 | return [get-define HAVE_PKG_CONFIG] } set found 0 define PKG_CONFIG [get-env PKG_CONFIG pkg-config] msg-checking "Checking for pkg-config..." | < | > > > > > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
return [get-define HAVE_PKG_CONFIG]
}
set found 0
define PKG_CONFIG [get-env PKG_CONFIG pkg-config]
msg-checking "Checking for pkg-config..."
if {[catch {exec [get-define PKG_CONFIG] --version} version]} {
msg-result "[get-define PKG_CONFIG] (not found)"
if {$required} {
user-error "No usable pkg-config"
}
} else {
msg-result $version
define PKG_CONFIG_VERSION $version
set found 1
if {[opt-val sysroot] ne ""} {
define SYSROOT [file-normalize [opt-val sysroot]]
|
| ︙ | ︙ | |||
68 69 70 71 72 73 74 | # XXX: It's possible that these should be set only when invoking pkg-config global env set env(PKG_CONFIG_DIR) "" # Do we need to try /usr/local as well or instead? set env(PKG_CONFIG_LIBDIR) $sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig set env(PKG_CONFIG_SYSROOT_DIR) $sysroot } | < < < < < < | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | # XXX: It's possible that these should be set only when invoking pkg-config global env set env(PKG_CONFIG_DIR) "" # Do we need to try /usr/local as well or instead? set env(PKG_CONFIG_LIBDIR) $sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig set env(PKG_CONFIG_SYSROOT_DIR) $sysroot } } define HAVE_PKG_CONFIG $found return $found } # @pkg-config module ?requirements? # |
| ︙ | ︙ | |||
105 106 107 108 109 110 111 |
msg-checking "Checking for $module $args..."
if {!$ok} {
msg-result "no pkg-config"
return 0
}
| < | > > > > | | | | | | | | < < < < < | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
msg-checking "Checking for $module $args..."
if {!$ok} {
msg-result "no pkg-config"
return 0
}
if {[catch {exec [get-define PKG_CONFIG] --modversion "$module $args"} version]} {
msg-result "not found"
configlog "pkg-config --modversion $module $args: $version"
return 0
}
msg-result $version
set prefix [feature-define-name $module PKG_]
define HAVE_${prefix}
define ${prefix}_VERSION $version
define ${prefix}_LIBS [exec pkg-config --libs-only-l $module]
define ${prefix}_LDFLAGS [exec pkg-config --libs-only-L $module]
define ${prefix}_CFLAGS [exec pkg-config --cflags $module]
return 1
}
# @pkg-config-get module setting
#
# Convenience access to the results of pkg-config
#
# For example, [pkg-config-get pango CFLAGS] returns
# the value of PKG_PANGO_CFLAGS, or "" if not defined.
proc pkg-config-get {module name} {
set prefix [feature-define-name $module PKG_]
get-define ${prefix}_${name} ""
}
|
Changes to autosetup/system.tcl.
1 2 3 4 5 6 7 8 9 10 11 | # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ # All rights reserved # @synopsis: # # This module supports common system interrogation and options # such as --host, --build, --prefix, and setting srcdir, builddir, and EXEEXT # # It also support the 'feature' naming convention, where searching # for a feature such as sys/type.h defines HAVE_SYS_TYPES_H # | > > > > > > > > > > > > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
# All rights reserved
# @synopsis:
#
# This module supports common system interrogation and options
# such as --host, --build, --prefix, and setting srcdir, builddir, and EXEEXT
#
# It also support the 'feature' naming convention, where searching
# for a feature such as sys/type.h defines HAVE_SYS_TYPES_H
#
# It defines the following variables, based on --prefix unless overridden by the user:
#
## datadir
## sysconfdir
## sharedstatedir
## localstatedir
## infodir
## mandir
## includedir
# Do "define defaultprefix myvalue" to set the default prefix *before* the first "use"
set defaultprefix [get-define defaultprefix /usr/local]
module-options [subst -noc -nob {
host:host-alias => {a complete or partial cpu-vendor-opsys for the system where
the application will run (defaults to the same value as --build)}
build:build-alias => {a complete or partial cpu-vendor-opsys for the system
where the application will be built (defaults to the
result of running config.guess)}
prefix:dir => {the target directory for the build (defaults to '$defaultprefix')}
# These (hidden) options are supported for autoconf/automake compatibility
exec-prefix:
bindir:
sbindir:
includedir:
mandir:
infodir:
libexecdir:
datadir:
libdir:
sysconfdir:
sharedstatedir:
localstatedir:
maintainer-mode=0
dependency-tracking=0
}]
# Returns 1 if exists, or 0 if not
#
proc check-feature {name code} {
msg-checking "Checking for $name..."
set r [uplevel 1 $code]
define-feature $name $r
|
| ︙ | ︙ | |||
104 105 106 107 108 109 110 | # # Reads the input file <srcdir>/$template and writes the output file $outfile. # If $outfile is blank/omitted, $template should end with ".in" which # is removed to create the output file name. # # Each pattern of the form @define@ is replaced with the corresponding # define, if it exists, or left unchanged if not. | | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | # # Reads the input file <srcdir>/$template and writes the output file $outfile. # If $outfile is blank/omitted, $template should end with ".in" which # is removed to create the output file name. # # Each pattern of the form @define@ is replaced with the corresponding # define, if it exists, or left unchanged if not. # # The special value @srcdir@ is substituted with the relative # path to the source directory from the directory where the output # file is created, while the special value @top_srcdir@ is substituted # with the relative path to the top level source directory. # # Conditional sections may be specified as follows: ## @if name == value |
| ︙ | ︙ | |||
215 216 217 218 219 220 221 |
set cross ""
} else {
define host [config_sub $host]
set cross $host-
}
define cross [get-env CROSS $cross]
| < | | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
set cross ""
} else {
define host [config_sub $host]
set cross $host-
}
define cross [get-env CROSS $cross]
set prefix [opt-val prefix $defaultprefix]
# These are for compatibility with autoconf
define target [get-define host]
define prefix $prefix
define builddir $autosetup(builddir)
define srcdir $autosetup(srcdir)
# Allow this to come from the environment
|
| ︙ | ︙ |
Changes to compat/zlib/win32/Makefile.msc.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 | IMPLIB = zdll.lib CC = cl AS = ml LD = link AR = lib RC = rc | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | IMPLIB = zdll.lib CC = cl AS = ml LD = link AR = lib RC = rc CFLAGS = -nologo -MT -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC) WFLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE ASFLAGS = -coff -Zi $(LOC) LDFLAGS = -nologo -debug -incremental:no -opt:ref ARFLAGS = -nologo RCFLAGS = /dWIN32 /r OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj \ |
| ︙ | ︙ |
Changes to debian/makedeb.sh.
| ︙ | ︙ | |||
57 58 59 60 61 62 63 |
This package was created by fossil-scm <fossil-dev@lists.fossil-scm.org>
on ${PACKAGE_TIME}.
The original sources for fossil can be downloaded for free from:
http://www.fossil-scm.org/
| | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
This package was created by fossil-scm <fossil-dev@lists.fossil-scm.org>
on ${PACKAGE_TIME}.
The original sources for fossil can be downloaded for free from:
http://www.fossil-scm.org/
fossil is released under the terms of the 2-clause BSD License.
EOF
}
true && {
CHANGELOG=${DEBLOCALPREFIX}/share/doc/${PACKAGE_DEBNAME}/changelog.gz
cat <<EOF | gzip -c > ${CHANGELOG}
|
| ︙ | ︙ | |||
96 97 98 99 100 101 102 | Description: Fossil is a unique SCM (Software Configuration Management) system. This package contains the Fossil binary for *buntu/Debian systems. Fossil is a unique SCM program which supports distributed source control management using local repositories, access over HTTP CGI, or using the built-in HTTP server. It has a built-in wiki, file browsing, etc. Fossil home page: http://fossil-scm.org Fossil author: D. Richard Hipp | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
Description: Fossil is a unique SCM (Software Configuration Management) system.
This package contains the Fossil binary for *buntu/Debian systems.
Fossil is a unique SCM program which supports distributed source control
management using local repositories, access over HTTP CGI, or using the
built-in HTTP server. It has a built-in wiki, file browsing, etc.
Fossil home page: http://fossil-scm.org
Fossil author: D. Richard Hipp
License: 2-clause BSD
EOF
}
true && {
# GZ_CONTROL=control.tar.gz
|
| ︙ | ︙ |
Added skins/bootstrap/css.txt.
cannot compute difference between binary files
Added skins/bootstrap/details.txt.
> > > > | 1 2 3 4 | timeline-arrowheads: 1 timeline-circle-nodes: 1 timeline-color-graph-lines: 1 white-foreground: 0 |
Added skins/bootstrap/footer.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<th1>
if {! $is_index && ! $is_home} {
html "</div>"
}
</th1>
</div>
<div id="push"></div>
</div>
<footer id="footer">
<p>© Copyright $<project_name>. All right reserved. Fossil $release_version · <a href="$home/timeline.rss">RSS</a></p>
</footer>
<script>
var tables = document.querySelectorAll('table');
for (var i = 0; i < tables.length; i++) {
if (tables[i].id !== "timelineTable")
tables[i].classList.add('table');
};
var submenus = document.querySelectorAll('.submenu');
for (var i = 0; i < submenus.length; i++) {
submenus[i].classList.add('btn-group');
var labels = submenus[i].querySelectorAll('.label');
for (var j = 0; j < labels.length; j++) {
labels[j].classList.remove('label');
labels[j].classList.add('btn');
labels[j].classList.add('btn-default');
labels[j].classList.add('btn-sm');
}
};
//Handle the collapsible navbar
var collapse = document.querySelector('[data-toggle="collapse"]');
collapse.onclick = function(){
var target = document.querySelector(
collapse.getAttribute('data-target')
);
target.classList.toggle('collapse');
target.classList.toggle('collapsed');
};
</script>
</body></html>
|
Added skins/bootstrap/header.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
<html lang="en">
<head>
<meta charset="utf-8">
<base href="$baseurl/$current_page" />
<title>$<project_name>: $<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="$home/timeline.rss" />
<link rel="stylesheet" href="$home/style.css?default" type="text/css" media="screen" />
<script>
function gebi(x){
if(/^#/.test(x)) x = x.substr(1);
var e = document.getElementById(x);
if(!e) throw new Error("Expecting element with ID "+x);
else return e;
}
</script>
</head>
<body data-spy="scroll" data-target=".sidebar">
<div id="wrap">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<th1>html "<a class='navbar-brand' href='$home$index_page'>$project_name</a>"</th1>
</div>
<div class="collapse navbar-collapse">
<p class="navbar-text pull-right"><th1>
if {[info exists login]} {
puts "Logged in as $login"
html " · <a href='$home/login'>Logout</a>"
} else {
puts "Not logged in"
html " · <a href='$home/login'>Login</a>"
}
</th1></p>
<ul class="nav navbar-nav">
<th1>
set is_index [expr [string compare [string range $current_page 0 4] "index"]==0]
set is_home [expr [string compare [string range $current_page 0 [expr [string length $index_page]-1] ] $index_page]==0]
if {$is_index || $is_home} {
html "<li class='active'><a href='$home$index_page'>Home</a></li>\n"
} else {
html "<li><a href='$home$index_page'>Home</a></li>\n"
}
if {[hascap j]} {
if {[string compare [string range $current_page 0 3] "wiki"] == 0} {
html "<li class='active'><a href='$home/wiki'>Wiki</a></li>\n"
} else {
html "<li><a href='$home/wiki'>Wiki</a></li>\n"
}
}
if {[anycap jor]} {
if {[string compare $current_page "timeline"] == 0} {
html "<li class='active'><a href='$home/timeline'>Timeline</a></li>\n"
} else {
html "<li><a href='$home/timeline'>Timeline</a></li>\n"
}
}
if {[hascap oh]} {
if {[string compare [string range $current_page 0 2] "dir"] == 0} {
html "<li class='active'><a href='$home/dir?ci=tip'>Files</a></li>\n"
} else {
html "<li><a href='$home/dir?ci=tip'>Files</a></li>\n"
}
}
if {[hascap o]} {
if {[string compare $current_page "brlist"] == 0} {
html "<li class='active'><a href='$home/brlist'>Branches</a></li>\n"
} else {
html "<li><a href='$home/brlist'>Branches</a></li>\n"
}
if {[string compare $current_page "taglist"] == 0} {
html "<li class='active'><a href='$home/taglist'>Tags</a></li>\n"
} else {
html "<li><a href='$home/taglist'>Tags</a></li>\n"
}
}
if {[hascap r]} {
if {[string compare $current_page "reportlist"] == 0} {
html "<li class='active'><a href='$home/reportlist'>Tickets</a></li>\n"
} else {
html "<li><a href='$home/reportlist'>Tickets</a></li>\n"
}
}
if {[hascap s]} {
if {[string compare [string range $current_page 0 4] "setup"] == 0} {
html "<li class='active'><a href='$home/setup'>Admin</a></li>\n"
} else {
html "<li><a href='$home/setup'>Admin</a></li>\n"
}
} elseif {[hascap a]} {
if {[string compare [string range $current_page 0 4] "setup"] == 0} {
html "<li class='active'><a href='$home/setup_ulist'>Users</a></li>\n"
} else {
html "<li><a href='$home/setup_ulist'>Users</a></li>\n"
}
}
</th1>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<div class="content">
<th1>
html "<div class='container'>"
html "<ul class='breadcrumb'>"
html "<li><a href='$index_page'>Home</a></li>"
html "<li><a href='$home/$current_page'>$title</a></li>"
html "</ul>"
</th1>
|
Changes to skins/xekri/css.txt.
| ︙ | ︙ | |||
374 375 376 377 378 379 380 | } /************************************** * File List : Age */ | | | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
}
/**************************************
* File List : Age
*/
.fileage tr:hover {
background-color: #225;
}
/**************************************
* File List : Tree
*/
|
| ︙ | ︙ |
Changes to src/add.c.
| ︙ | ︙ | |||
270 271 272 273 274 275 276 |
** depends on the global setting, or the operating system default, if not set.
**
** Options:
**
** --case-sensitive <BOOL> Override the case-sensitive setting.
** --dotfiles include files beginning with a dot (".")
** -f|--force Add files without prompting
| | | < | 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
** depends on the global setting, or the operating system default, if not set.
**
** Options:
**
** --case-sensitive <BOOL> Override the case-sensitive setting.
** --dotfiles include files beginning with a dot (".")
** -f|--force Add files without prompting
** --ignore <CSG> Ignore unmanaged files matching patterns from
** the comma separated list of glob patterns.
** --clean <CSG> Also ignore files matching patterns from
** the comma separated list of glob patterns.
**
** See also: addremove, rm
*/
void add_cmd(void){
int i; /* Loop counter */
int vid; /* Currently checked out version */
int nRoot; /* Full path characters in g.zLocalRoot */
|
| ︙ | ︙ | |||
440 441 442 443 444 445 446 | ** ** Options: ** --soft Skip removing files from the checkout. ** This supersedes the --hard option. ** --hard Remove files from the checkout. ** --case-sensitive <BOOL> Override the case-sensitive setting. ** -n|--dry-run If given, display instead of run actions. | < | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
**
** Options:
** --soft Skip removing files from the checkout.
** This supersedes the --hard option.
** --hard Remove files from the checkout.
** --case-sensitive <BOOL> Override the case-sensitive setting.
** -n|--dry-run If given, display instead of run actions.
**
** See also: addremove, add
*/
void delete_cmd(void){
int i;
int removeFiles;
int dryRunFlag;
|
| ︙ | ︙ | |||
617 618 619 620 621 622 623 |
** anything.
**
** This command can be used to track third party software.
**
** Options:
** --case-sensitive <BOOL> Override the case-sensitive setting.
** --dotfiles Include files beginning with a dot (".")
| | | < | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
** anything.
**
** This command can be used to track third party software.
**
** Options:
** --case-sensitive <BOOL> Override the case-sensitive setting.
** --dotfiles Include files beginning with a dot (".")
** --ignore <CSG> Ignore unmanaged files matching patterns from
** the comma separated list of glob patterns.
** --clean <CSG> Also ignore files matching patterns from
** the comma separated list of glob patterns.
** -n|--dry-run If given, display instead of run actions.
**
** See also: add, rm
*/
void addremove_cmd(void){
Blob path;
const char *zCleanFlag = find_option("clean",0,1);
const char *zIgnoreFlag = find_option("ignore",0,1);
|
| ︙ | ︙ | |||
850 851 852 853 854 855 856 | ** ** Options: ** --soft Skip moving files within the checkout. ** This supersedes the --hard option. ** --hard Move files within the checkout. ** --case-sensitive <BOOL> Override the case-sensitive setting. ** -n|--dry-run If given, display instead of run actions. | < | 847 848 849 850 851 852 853 854 855 856 857 858 859 860 |
**
** Options:
** --soft Skip moving files within the checkout.
** This supersedes the --hard option.
** --hard Move files within the checkout.
** --case-sensitive <BOOL> Override the case-sensitive setting.
** -n|--dry-run If given, display instead of run actions.
**
** See also: changes, status
*/
void mv_cmd(void){
int i;
int vid;
int moveFiles;
|
| ︙ | ︙ |
Changes to src/blob.c.
| ︙ | ︙ | |||
787 788 789 790 791 792 793 | ** is blank or "-" then read from standard input. ** ** Any prior content of the blob is discarded, not freed. ** ** Return the number of bytes read. Calls fossil_fatal() on error (i.e. ** it exit()s and does not return). */ | | | | 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 |
** is blank or "-" then read from standard input.
**
** Any prior content of the blob is discarded, not freed.
**
** Return the number of bytes read. Calls fossil_fatal() on error (i.e.
** it exit()s and does not return).
*/
sqlite3_int64 blob_read_from_file(Blob *pBlob, const char *zFilename){
sqlite3_int64 size, got;
FILE *in;
if( zFilename==0 || zFilename[0]==0
|| (zFilename[0]=='-' && zFilename[1]==0) ){
return blob_read_from_channel(pBlob, stdin, -1);
}
size = file_wd_size(zFilename);
blob_zero(pBlob);
|
| ︙ | ︙ | |||
1167 1168 1169 1170 1171 1172 1173 |
}else{
z[--j] = z[i];
}
}
}
/*
| > | > > > > > > > > > > | > > > | | > > > > | | > | > > | < > > | | < | > > > > > | 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 |
}else{
z[--j] = z[i];
}
}
}
/*
** pBlob is a shell command under construction. This routine safely
** appends argument zIn.
**
** The argument is escaped if it contains white space or other characters
** that need to be escaped for the shell. If zIn contains characters
** that cannot be safely escaped, then throw a fatal error.
**
** The argument is expected to a filename of some kinds. As shell commands
** commonly have command-line options that begin with "-" and since we
** do not want an attacker to be able to invoke these switches using
** filenames that begin with "-", if zIn begins with "-", prepend
** an additional "./".
*/
void blob_append_escaped_arg(Blob *pBlob, const char *zIn){
int i;
char c;
int needEscape = 0;
int n = blob_size(pBlob);
char *z = blob_buffer(pBlob);
#if defined(_WIN32)
const char cQuote = '"'; /* Use "..." quoting on windows */
#else
const char cQuote = '\''; /* Use '...' quoting on unix */
#endif
for(i=0; (c = zIn[i])!=0; i++){
if( c==cQuote || c=='\\' || c<' ' || c==';' || c=='*' || c=='?' || c=='[') {
Blob bad;
blob_token(pBlob, &bad);
fossil_fatal("the [%s] argument to the \"%s\" command contains "
"a character (ascii 0x%02x) that is a security risk",
zIn, blob_str(&bad), c);
}
if( !needEscape && !fossil_isalnum(c) && c!='/' && c!='.' && c!='_' ){
needEscape = 1;
}
}
if( n>0 && !fossil_isspace(z[n-1]) ){
blob_append(pBlob, " ", 1);
}
if( needEscape ) blob_append(pBlob, &cQuote, 1);
if( zIn[0]=='-' ) blob_append(pBlob, "./", 2);
blob_append(pBlob, zIn, -1);
if( needEscape ) blob_append(pBlob, &cQuote, 1);
}
/*
** A read(2)-like impl for the Blob class. Reads (copies) up to nLen
** bytes from pIn, starting at position pIn->iCursor, and copies them
** to pDest (which must be valid memory at least nLen bytes long).
**
|
| ︙ | ︙ |
Changes to src/branch.c.
| ︙ | ︙ | |||
155 156 157 158 159 160 161 |
fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
if( manifest_crosslink(brid, &branch, MC_PERMIT_HOOKS)==0 ){
fossil_fatal("%s", g.zErrMsg);
}
assert( blob_is_reset(&branch) );
| | | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
if( manifest_crosslink(brid, &branch, MC_PERMIT_HOOKS)==0 ){
fossil_fatal("%s", g.zErrMsg);
}
assert( blob_is_reset(&branch) );
content_deltify(rootid, &brid, 1, 0);
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid);
fossil_print("New branch: %s\n", zUuid);
if( g.argc==3 ){
fossil_print(
"\n"
"Note: the local check-out has not been updated to the new\n"
" branch. To begin working on the new branch, do this:\n"
|
| ︙ | ︙ | |||
386 387 388 389 390 391 392 |
Stmt q;
double rNow;
int show_colors = PB("colors");
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
style_header("Branches");
style_adunit_config(ADUNIT_RIGHT_OK);
| | | 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
Stmt q;
double rNow;
int show_colors = PB("colors");
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
style_header("Branches");
style_adunit_config(ADUNIT_RIGHT_OK);
style_submenu_checkbox("colors", "Use Branch Colors", 0, 0);
login_anonymous_available();
db_prepare(&q, brlistQuery/*works-like:""*/);
rNow = db_double(0.0, "SELECT julianday('now')");
@ <div class="brlist"><table id="branchlisttable">
@ <thead><tr>
@ <th>Branch Name</th>
|
| ︙ | ︙ |
Changes to src/browse.c.
| ︙ | ︙ | |||
184 185 186 187 188 189 190 |
url_render(&sURI, "ci", "trunk", 0, 0));
}
if( linkTip ){
style_submenu_element("Tip", "%s", url_render(&sURI, "ci", "tip", 0, 0));
}
if( zCI ){
@ <h2>Files of check-in [%z(href("vinfo?name=%!S",zUuid))%S(zUuid)</a>]
| | > > > > | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
url_render(&sURI, "ci", "trunk", 0, 0));
}
if( linkTip ){
style_submenu_element("Tip", "%s", url_render(&sURI, "ci", "tip", 0, 0));
}
if( zCI ){
@ <h2>Files of check-in [%z(href("vinfo?name=%!S",zUuid))%S(zUuid)</a>]
@ %s(blob_str(&dirname))
if( zD ){
@ %z(href("%R/timeline?chng=%T/*", zD))[history]</a>
}
@ </h2>
zSubdirLink = mprintf("%R/dir?ci=%!S&name=%T", zUuid, zPrefix);
if( nD==0 ){
style_submenu_element("File Ages", "%R/fileage?name=%!S", zUuid);
}
}else{
@ <h2>The union of all files from all check-ins
@ %s(blob_str(&dirname))</h2>
|
| ︙ | ︙ | |||
293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
}
@ <li class="%z(fileext_class(zFN))">%z(zLink)%h(zFN)</a></li>
}
}
db_finalize(&q);
manifest_destroy(pM);
@ </ul></td></tr></table>
style_footer();
}
/*
** Objects used by the "tree" webpage.
*/
typedef struct FileTreeNode FileTreeNode;
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
}
@ <li class="%z(fileext_class(zFN))">%z(zLink)%h(zFN)</a></li>
}
}
db_finalize(&q);
manifest_destroy(pM);
@ </ul></td></tr></table>
/* If the directory contains a readme file, then display its content below
** the list of files
*/
db_prepare(&q,
"SELECT x, u FROM localfiles"
" WHERE x COLLATE nocase IN"
" ('readme','readme.txt','readme.md','readme.wiki','readme.markdown',"
" 'readme.html') ORDER BY x LIMIT 1;"
);
if( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q,0);
const char *zUuid = db_column_text(&q,1);
if( zUuid ){
rid = fast_uuid_to_rid(zUuid);
}else{
if( zD ){
rid = db_int(0,
"SELECT fid FROM filename, mlink, event"
" WHERE name='%q/%q'"
" AND mlink.fnid=filename.fnid"
" AND event.objid=mlink.mid"
" ORDER BY event.mtime DESC LIMIT 1",
zD, zName
);
}else{
rid = db_int(0,
"SELECT fid FROM filename, mlink, event"
" WHERE name='%q'"
" AND mlink.fnid=filename.fnid"
" AND event.objid=mlink.mid"
" ORDER BY event.mtime DESC LIMIT 1",
zName
);
}
}
if( rid ){
@ <hr>
if( sqlite3_strlike("readme.html", zName, 0)==0 ){
if( zUuid==0 ){
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
}
@ <iframe src="%R/raw/%s(zUuid)"
@ width="100%%" frameborder="0" marginwidth="0" marginheight="0"
@ sandbox="allow-same-origin"
@ onload="this.height=this.contentDocument.documentElement.scrollHeight;">
@ </iframe>
}else{
Blob content;
const char *zMime = mimetype_from_name(zName);
content_get(rid, &content);
wiki_render_by_mimetype(&content, zMime);
}
}
}
db_finalize(&q);
style_footer();
}
/*
** Objects used by the "tree" webpage.
*/
typedef struct FileTreeNode FileTreeNode;
|
| ︙ | ︙ | |||
691 692 693 694 695 696 697 |
if( p->pChild!=0 && p->nFullName>nD ) nFile++;
}
zObjType = "Folders";
}else{
zObjType = "Files";
}
| | | 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 |
if( p->pChild!=0 && p->nFullName>nD ) nFile++;
}
zObjType = "Folders";
}else{
zObjType = "Files";
}
style_submenu_checkbox("nofiles", "Folders Only", 0, 0);
if( zCI ){
@ <h2>%s(zObjType) from
if( sqlite3_strnicmp(zCI, zUuid, (int)strlen(zCI))!=0 ){
@ "%h(zCI)"
}
@ [%z(href("vinfo?name=%!S",zUuid))%S(zUuid)</a>] %s(blob_str(&dirname))
|
| ︙ | ︙ | |||
1028 1029 1030 1031 1032 1033 1034 |
" WHERE objid=%d", rid);
style_submenu_element("Tree-View", "%R/tree?ci=%T&mtime=1&type=tree", zName);
style_header("File Ages");
zGlob = P("glob");
compute_fileage(rid,zGlob);
db_multi_exec("CREATE INDEX fileage_ix1 ON fileage(mid,pathname);");
| | | | | | | | 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 |
" WHERE objid=%d", rid);
style_submenu_element("Tree-View", "%R/tree?ci=%T&mtime=1&type=tree", zName);
style_header("File Ages");
zGlob = P("glob");
compute_fileage(rid,zGlob);
db_multi_exec("CREATE INDEX fileage_ix1 ON fileage(mid,pathname);");
@ <h1>Files in
@ %z(href("%R/info/%!S",zUuid))[%S(zUuid)]</a>
if( zGlob && zGlob[0] ){
@ that match "%h(zGlob)"
}
@ ordered by age</h1>
@
@ <p>File ages are expressed relative to the
@ %z(href("%R/ci/%!S",zUuid))[%S(zUuid)]</a> check-in time of
@ %z(href("%R/timeline?c=%t",zNow))%s(zNow)</a>.</p>
@
@ <div class='fileage'><table>
@ <tr><th>Age</th><th>Files</th><th>Check-in</th></tr>
db_prepare(&q1,
"SELECT event.mtime, event.objid, blob.uuid,\n"
" coalesce(event.ecomment,event.comment),\n"
" coalesce(event.euser,event.user),\n"
" coalesce((SELECT value FROM tagxref\n"
" WHERE tagtype>0 AND tagid=%d\n"
" AND rid=event.objid),'trunk')\n"
|
| ︙ | ︙ |
Changes to src/cgi.c.
| ︙ | ︙ | |||
380 381 382 383 384 385 386 |
}
total_size = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
}else{
total_size = 0;
}
fprintf(g.httpOut, "\r\n");
| | > > | 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
}
total_size = blob_size(&cgiContent[0]) + blob_size(&cgiContent[1]);
fprintf(g.httpOut, "Content-Length: %d\r\n", total_size);
}else{
total_size = 0;
}
fprintf(g.httpOut, "\r\n");
if( total_size>0 && iReplyStatus != 304
&& fossil_strcmp(P("REQUEST_METHOD"),"HEAD")!=0
){
int i, size;
for(i=0; i<2; i++){
size = blob_size(&cgiContent[i]);
if( size>0 ){
fwrite(blob_buffer(&cgiContent[i]), 1, size, g.httpOut);
}
}
|
| ︙ | ︙ | |||
435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
}
NORETURN void cgi_redirectf(const char *zFormat, ...){
va_list ap;
va_start(ap, zFormat);
cgi_redirect(vmprintf(zFormat, ap));
va_end(ap);
}
/*
** Information about all query parameters and cookies are stored
** in these variables.
*/
static int nAllocQP = 0; /* Space allocated for aParamQP[] */
static int nUsedQP = 0; /* Space actually used in aParamQP[] */
| > > > > > > > > > > > > > > | 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
}
NORETURN void cgi_redirectf(const char *zFormat, ...){
va_list ap;
va_start(ap, zFormat);
cgi_redirect(vmprintf(zFormat, ap));
va_end(ap);
}
/*
** Return the URL for the caller. This is obtained from either the
** referer CGI parameter, if it exists, or the HTTP_REFERER HTTP parameter.
** If neither exist, return zDefault.
*/
const char *cgi_referer(const char *zDefault){
const char *zRef = P("referer");
if( zRef==0 ){
zRef = P("HTTP_REFERER");
if( zRef==0 ) zRef = zDefault;
}
return zRef;
}
/*
** Information about all query parameters and cookies are stored
** in these variables.
*/
static int nAllocQP = 0; /* Space allocated for aParamQP[] */
static int nUsedQP = 0; /* Space actually used in aParamQP[] */
|
| ︙ | ︙ | |||
1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 |
cgi_setenv("HTTP_IF_NONE_MATCH", zVal);
}else if( fossil_strcmp(zFieldName,"if-modified-since:")==0 ){
cgi_setenv("HTTP_IF_MODIFIED_SINCE", zVal);
}else if( fossil_strcmp(zFieldName,"referer:")==0 ){
cgi_setenv("HTTP_REFERER", zVal);
}else if( fossil_strcmp(zFieldName,"user-agent:")==0 ){
cgi_setenv("HTTP_USER_AGENT", zVal);
}else if( fossil_strcmp(zFieldName,"x-forwarded-for:")==0 ){
const char *zIpAddr = cgi_accept_forwarded_for(zVal);
if( zIpAddr!=0 ){
g.zIpAddr = mprintf("%s", zIpAddr);
cgi_replace_parameter("REMOTE_ADDR", g.zIpAddr);
}
}
| > > | 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 |
cgi_setenv("HTTP_IF_NONE_MATCH", zVal);
}else if( fossil_strcmp(zFieldName,"if-modified-since:")==0 ){
cgi_setenv("HTTP_IF_MODIFIED_SINCE", zVal);
}else if( fossil_strcmp(zFieldName,"referer:")==0 ){
cgi_setenv("HTTP_REFERER", zVal);
}else if( fossil_strcmp(zFieldName,"user-agent:")==0 ){
cgi_setenv("HTTP_USER_AGENT", zVal);
}else if( fossil_strcmp(zFieldName,"authorization:")==0 ){
cgi_setenv("HTTP_AUTHORIZATION", zVal);
}else if( fossil_strcmp(zFieldName,"x-forwarded-for:")==0 ){
const char *zIpAddr = cgi_accept_forwarded_for(zVal);
if( zIpAddr!=0 ){
g.zIpAddr = mprintf("%s", zIpAddr);
cgi_replace_parameter("REMOTE_ADDR", g.zIpAddr);
}
}
|
| ︙ | ︙ |
Changes to src/checkin.c.
| ︙ | ︙ | |||
415 416 417 418 419 420 421 | ** --rel-paths Display pathnames relative to the current working ** directory. ** --hash Verify file status using hashing rather than ** relying on file mtimes. ** --case-sensitive <BOOL> Override case-sensitive setting. ** --dotfiles Include unmanaged files beginning with a dot. ** --ignore <CSG> Ignore unmanaged files matching CSG glob patterns. | < | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | ** --rel-paths Display pathnames relative to the current working ** directory. ** --hash Verify file status using hashing rather than ** relying on file mtimes. ** --case-sensitive <BOOL> Override case-sensitive setting. ** --dotfiles Include unmanaged files beginning with a dot. ** --ignore <CSG> Ignore unmanaged files matching CSG glob patterns. ** ** Options specific to the changes command: ** --header Identify the repository if report is non-empty. ** -v|--verbose Say "(none)" if the change report is empty. ** --classify Start each line with the file's change type. ** --no-classify Do not print file change types. ** |
| ︙ | ︙ | |||
824 825 826 827 828 829 830 |
**
** Options:
** --abs-paths Display absolute pathnames.
** --case-sensitive <BOOL> override case-sensitive setting
** --dotfiles include files beginning with a dot (".")
** --header Identify the repository if there are extras
** --ignore <CSG> ignore files matching patterns from the argument
| < | 823 824 825 826 827 828 829 830 831 832 833 834 835 836 |
**
** Options:
** --abs-paths Display absolute pathnames.
** --case-sensitive <BOOL> override case-sensitive setting
** --dotfiles include files beginning with a dot (".")
** --header Identify the repository if there are extras
** --ignore <CSG> ignore files matching patterns from the argument
** --rel-paths Display pathnames relative to the current working
** directory.
**
** See also: changes, clean, status
*/
void extras_cmd(void){
Blob report = BLOB_INITIALIZER;
|
| ︙ | ︙ | |||
854 855 856 857 858 859 860 861 862 863 864 865 866 867 |
/* We should be done with options.. */
verify_all_options();
if( zIgnoreFlag==0 ){
zIgnoreFlag = db_get("ignore-glob", 0);
}
pIgnore = glob_create(zIgnoreFlag);
locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore);
glob_free(pIgnore);
blob_zero(&report);
status_report(&report, flags);
if( blob_size(&report) ){
if( showHdr ){
| > > | 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 |
/* We should be done with options.. */
verify_all_options();
if( zIgnoreFlag==0 ){
zIgnoreFlag = db_get("ignore-glob", 0);
}
pIgnore = glob_create(zIgnoreFlag);
/* Always consider symlinks. */
g.allowSymlinks = db_allow_symlinks_by_default();
locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore);
glob_free(pIgnore);
blob_zero(&report);
status_report(&report, flags);
if( blob_size(&report) ){
if( showHdr ){
|
| ︙ | ︙ | |||
899 900 901 902 903 904 905 | ** ever be deleted. Files and subdirectories whose names begin with "." ** are automatically ignored unless the --dotfiles option is used. ** ** The default values for --clean, --ignore, and --keep are determined by ** the (versionable) clean-glob, ignore-glob, and keep-glob settings. ** ** The --verily option ignores the keep-glob and ignore-glob settings and | | | | < | 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | ** ever be deleted. Files and subdirectories whose names begin with "." ** are automatically ignored unless the --dotfiles option is used. ** ** The default values for --clean, --ignore, and --keep are determined by ** the (versionable) clean-glob, ignore-glob, and keep-glob settings. ** ** The --verily option ignores the keep-glob and ignore-glob settings and ** turns on --force, --emptydirs, --dotfiles, and --disable-undo. Use the ** --verily option when you really want to clean up everything. Extreme ** care should be exercised when using the --verily option. ** ** Options: ** --allckouts Check for empty directories within any checkouts ** that may be nested within the current one. This ** option should be used with great care because the ** empty-dirs setting (and other applicable settings) ** belonging to the other repositories, if any, will |
| ︙ | ︙ | |||
932 933 934 935 936 937 938 | ** that were removed will be removed as well. ** -f|--force Remove files without prompting. ** -i|--prompt Prompt before removing each file. This option ** implies the --disable-undo option. ** -x|--verily WARNING: Removes everything that is not a managed ** file or the repository itself. This option ** implies the --force, --emptydirs, --dotfiles, and | | < | 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 |
** that were removed will be removed as well.
** -f|--force Remove files without prompting.
** -i|--prompt Prompt before removing each file. This option
** implies the --disable-undo option.
** -x|--verily WARNING: Removes everything that is not a managed
** file or the repository itself. This option
** implies the --force, --emptydirs, --dotfiles, and
** --disable-undo options.
** Furthermore, it completely disregards the keep-glob
** and ignore-glob settings. However, it does honor
** the --ignore and --keep options.
** --clean <CSG> WARNING: Never prompt to delete any files matching
** this comma separated list of glob patterns. Also,
** deletions of any files matching this pattern list
** cannot be undone.
** --ignore <CSG> Ignore files matching patterns from the
** comma separated list of glob patterns.
** --keep <CSG> Keep files matching this comma separated
** list of glob patterns.
** -n|--dry-run Delete nothing, but display what would have been
** deleted.
** --no-prompt This option disables prompting the user for input
** and assumes an answer of 'No' for every question.
** --temp Remove only Fossil-generated temporary files.
** -v|--verbose Show all files as they are removed.
**
** See also: addremove, extras, status
*/
void clean_cmd(void){
int allFileFlag, allDirFlag, dryRunFlag, verboseFlag;
|
| ︙ | ︙ | |||
997 998 999 1000 1001 1002 1003 |
db_must_be_within_tree();
if( find_option("verily","x",0)!=0 ){
verilyFlag = allFileFlag = allDirFlag = 1;
emptyDirsFlag = 1;
disableUndo = 1;
scanFlags |= SCAN_ALL;
zCleanFlag = 0;
| < < > > | 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 |
db_must_be_within_tree();
if( find_option("verily","x",0)!=0 ){
verilyFlag = allFileFlag = allDirFlag = 1;
emptyDirsFlag = 1;
disableUndo = 1;
scanFlags |= SCAN_ALL;
zCleanFlag = 0;
}
if( zIgnoreFlag==0 && !verilyFlag ){
zIgnoreFlag = db_get("ignore-glob", 0);
}
if( zKeepFlag==0 && !verilyFlag ){
zKeepFlag = db_get("keep-glob", 0);
}
if( zCleanFlag==0 && !verilyFlag ){
zCleanFlag = db_get("clean-glob", 0);
}
if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL;
verify_all_options();
pIgnore = glob_create(zIgnoreFlag);
pKeep = glob_create(zKeepFlag);
pClean = glob_create(zCleanFlag);
nRoot = (int)strlen(g.zLocalRoot);
/* Always consider symlinks. */
g.allowSymlinks = db_allow_symlinks_by_default();
if( !dirsOnlyFlag ){
Stmt q;
Blob repo;
if( !dryRunFlag && !disableUndo ) undo_begin();
locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore);
db_prepare(&q,
"SELECT %Q || pathname FROM sfile"
|
| ︙ | ︙ | |||
1200 1201 1202 1203 1204 1205 1206 |
"# and because no comment was specified using the \"-m\" or \"-M\"\n"
"# command-line options, you will need to enter the comment below.\n"
"# Type \".\" on a line by itself when you are done:\n", -1);
zFile = mprintf("-");
}else{
Blob fname;
blob_zero(&fname);
| > | | | > > > > | 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 |
"# and because no comment was specified using the \"-m\" or \"-M\"\n"
"# command-line options, you will need to enter the comment below.\n"
"# Type \".\" on a line by itself when you are done:\n", -1);
zFile = mprintf("-");
}else{
Blob fname;
blob_zero(&fname);
if( g.zLocalRoot!=0 ){
file_relative_name(g.zLocalRoot, &fname, 1);
zFile = db_text(0, "SELECT '%qci-comment-'||hex(randomblob(6))||'.txt'",
blob_str(&fname));
}else{
file_tempname(&fname, "ci-comment");
zFile = mprintf("%s", blob_str(&fname));
}
blob_reset(&fname);
}
#if defined(_WIN32)
blob_add_cr(pPrompt);
#endif
blob_write_to_file(pPrompt, zFile);
if( zEditor ){
|
| ︙ | ︙ | |||
2393 2394 2395 2396 2397 2398 2399 |
fossil_print("possible unresolved merge conflict in %s\n",
blob_str(&fname));
blob_reset(&fname);
}
nrid = content_put(&content);
blob_reset(&content);
if( rid>0 ){
| | | 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 |
fossil_print("possible unresolved merge conflict in %s\n",
blob_str(&fname));
blob_reset(&fname);
}
nrid = content_put(&content);
blob_reset(&content);
if( rid>0 ){
content_deltify(rid, &nrid, 1, 0);
}
db_multi_exec("UPDATE vfile SET mrid=%d, rid=%d WHERE id=%d", nrid,nrid,id);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
}
db_finalize(&q);
if( nConflict && !allowConflict ){
fossil_fatal("abort due to unresolved merge conflicts; "
|
| ︙ | ︙ | |||
2500 2501 2502 2503 2504 2505 2506 |
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
if( manifest_crosslink(nvid, &manifest,
dryRunFlag ? MC_NONE : MC_PERMIT_HOOKS)==0 ){
fossil_fatal("%s", g.zErrMsg);
}
assert( blob_is_reset(&manifest) );
| | | 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 |
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
if( manifest_crosslink(nvid, &manifest,
dryRunFlag ? MC_NONE : MC_PERMIT_HOOKS)==0 ){
fossil_fatal("%s", g.zErrMsg);
}
assert( blob_is_reset(&manifest) );
content_deltify(vid, &nvid, 1, 0);
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
db_prepare(&q, "SELECT uuid,merge FROM vmerge JOIN blob ON merge=rid"
" WHERE id=-4");
while( db_step(&q)==SQLITE_ROW ){
const char *zIntegrateUuid = db_column_text(&q, 0);
if( is_a_leaf(db_column_int(&q, 1)) ){
|
| ︙ | ︙ |
Changes to src/codecheck1.c.
| ︙ | ︙ | |||
508 509 510 511 512 513 514 |
** the number of errors.
*/
static int scan_file(const char *zName, const char *zContent){
const char *z;
int ln = 0;
int szToken;
int eToken;
| | | | | | 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
** the number of errors.
*/
static int scan_file(const char *zName, const char *zContent){
const char *z;
int ln = 0;
int szToken;
int eToken;
const char *zPrev = 0;
int ePrev = 0;
int szPrev = 0;
int lnPrev = 0;
int nCurly = 0;
int x;
unsigned fmtFlags = 0;
int nErr = 0;
if( zContent==0 ){
printf("cannot read file: %s\n", zName);
|
| ︙ | ︙ |
Changes to src/comformat.c.
| ︙ | ︙ | |||
224 225 226 227 228 229 230 |
}
charCnt++;
}else{
charCnt++;
}
assert( c!='\n' || charCnt==0 );
fossil_print("%c", c);
| | | < | 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
}
charCnt++;
}else{
charCnt++;
}
assert( c!='\n' || charCnt==0 );
fossil_print("%c", c);
if( (c&0x80)==0 || (zLine[index+1]&0xc0)!=0xc0 ) maxChars -= useChars;
if( maxChars<=0 ) break;
if( c=='\n' ) break;
}
if( charCnt>0 ){
fossil_print("\n");
lineCnt++;
}
if( pLineCnt ){
|
| ︙ | ︙ |
Changes to src/config.h.
| ︙ | ︙ | |||
171 172 173 174 175 176 177 | # else # define COMPILER_NAME "unknown" # endif #endif #if !defined(_RC_COMPILE_) && !defined(SQLITE_AMALGAMATION) | > > > > > > > > > | > > > > > | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | # else # define COMPILER_NAME "unknown" # endif #endif #if !defined(_RC_COMPILE_) && !defined(SQLITE_AMALGAMATION) /* ** MSVC does not include the "stdint.h" header file until 2010. */ #if defined(_MSC_VER) && _MSC_VER<1600 typedef __int32 int32_t; typedef unsigned __int32 uint32_t; typedef __int64 int64_t; typedef unsigned __int64 uint64_t; #else # include <stdint.h> #endif #if USE_SEE && !defined(SQLITE_HAS_CODEC) # define SQLITE_HAS_CODEC #endif #include "sqlite3.h" /* ** On Solaris, getpass() will only return up to 8 characters. getpassphrase() returns up to 257. */ #if HAVE_GETPASSPHRASE #define getpass getpassphrase |
| ︙ | ︙ | |||
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | #endif /* ** A marker for functions that never return. */ #if defined(__GNUC__) || defined(__clang__) # define NORETURN __attribute__((__noreturn__)) #else # define NORETURN #endif /* ** Number of elements in an array */ #define count(X) (sizeof(X)/sizeof(X[0])) #endif /* _RC_COMPILE_ */ | > > | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | #endif /* ** A marker for functions that never return. */ #if defined(__GNUC__) || defined(__clang__) # define NORETURN __attribute__((__noreturn__)) #elif defined(_MSC_VER) && (_MSC_VER >= 1310) # define NORETURN __declspec(noreturn) #else # define NORETURN #endif /* ** Number of elements in an array */ #define count(X) (sizeof(X)/sizeof(X[0])) #endif /* _RC_COMPILE_ */ |
Changes to src/configure.c.
| ︙ | ︙ | |||
33 34 35 36 37 38 39 40 | #define CONFIGSET_SKIN 0x000002 /* WWW interface appearance */ #define CONFIGSET_TKT 0x000004 /* Ticket configuration */ #define CONFIGSET_PROJ 0x000008 /* Project name */ #define CONFIGSET_SHUN 0x000010 /* Shun settings */ #define CONFIGSET_USER 0x000020 /* The USER table */ #define CONFIGSET_ADDR 0x000040 /* The CONCEALED table */ #define CONFIGSET_XFER 0x000080 /* Transfer configuration */ | > | < | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #define CONFIGSET_SKIN 0x000002 /* WWW interface appearance */ #define CONFIGSET_TKT 0x000004 /* Ticket configuration */ #define CONFIGSET_PROJ 0x000008 /* Project name */ #define CONFIGSET_SHUN 0x000010 /* Shun settings */ #define CONFIGSET_USER 0x000020 /* The USER table */ #define CONFIGSET_ADDR 0x000040 /* The CONCEALED table */ #define CONFIGSET_XFER 0x000080 /* Transfer configuration */ #define CONFIGSET_ALIAS 0x000100 /* URL Aliases */ #define CONFIGSET_ALL 0x0001ff /* Everything */ #define CONFIGSET_OVERWRITE 0x100000 /* Causes overwrite instead of merge */ /* ** This mask is used for the common TH1 configuration settings (i.e. those ** that are not specific to one particular subsystem, such as the transfer ** subsystem). */ #define CONFIGSET_TH1 (CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER) |
| ︙ | ︙ | |||
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
{ "/skin", CONFIGSET_SKIN | CONFIGSET_CSS,
"Web interface appearance settings" },
{ "/css", CONFIGSET_CSS, "Style sheet" },
{ "/shun", CONFIGSET_SHUN, "List of shunned artifacts" },
{ "/ticket", CONFIGSET_TKT, "Ticket setup", },
{ "/user", CONFIGSET_USER, "Users and privilege settings" },
{ "/xfer", CONFIGSET_XFER, "Transfer setup", },
{ "/all", CONFIGSET_ALL, "All of the above" },
};
/*
** The following is a list of settings that we are willing to
** transfer.
| > | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
{ "/skin", CONFIGSET_SKIN | CONFIGSET_CSS,
"Web interface appearance settings" },
{ "/css", CONFIGSET_CSS, "Style sheet" },
{ "/shun", CONFIGSET_SHUN, "List of shunned artifacts" },
{ "/ticket", CONFIGSET_TKT, "Ticket setup", },
{ "/user", CONFIGSET_USER, "Users and privilege settings" },
{ "/xfer", CONFIGSET_XFER, "Transfer setup", },
{ "/alias", CONFIGSET_ALIAS, "URL Aliases", },
{ "/all", CONFIGSET_ALL, "All of the above" },
};
/*
** The following is a list of settings that we are willing to
** transfer.
|
| ︙ | ︙ | |||
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
{ "@user", CONFIGSET_USER },
{ "@concealed", CONFIGSET_ADDR },
{ "@shun", CONFIGSET_SHUN },
{ "xfer-common-script", CONFIGSET_XFER },
{ "xfer-push-script", CONFIGSET_XFER },
{ "xfer-commit-script", CONFIGSET_XFER },
{ "xfer-ticket-script", CONFIGSET_XFER },
};
static int iConfig = 0;
/*
** Return name of first configuration property matching the given mask.
*/
const char *configure_first_name(int iMask){
iConfig = 0;
return configure_next_name(iMask);
}
const char *configure_next_name(int iMask){
| > > < < < < < < < < < | | | | | | | | | < | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
{ "@user", CONFIGSET_USER },
{ "@concealed", CONFIGSET_ADDR },
{ "@shun", CONFIGSET_SHUN },
{ "@alias", CONFIGSET_ALIAS },
{ "xfer-common-script", CONFIGSET_XFER },
{ "xfer-push-script", CONFIGSET_XFER },
{ "xfer-commit-script", CONFIGSET_XFER },
{ "xfer-ticket-script", CONFIGSET_XFER },
};
static int iConfig = 0;
/*
** Return name of first configuration property matching the given mask.
*/
const char *configure_first_name(int iMask){
iConfig = 0;
return configure_next_name(iMask);
}
const char *configure_next_name(int iMask){
if( iConfig==0 && (iMask & CONFIGSET_ALL)==CONFIGSET_ALL ){
iConfig = count(aGroupName);
return "/all";
}
while( iConfig<count(aGroupName)-1 ){
if( aGroupName[iConfig].groupMask & iMask ){
return aGroupName[iConfig++].zName;
}else{
iConfig++;
}
}
return 0;
}
/*
** Return a pointer to a string that contains the RHS of an IN operator
|
| ︙ | ︙ | |||
242 243 244 245 246 247 248 |
}
if( !g.perm.RdAddr ){
m &= ~CONFIGSET_ADDR;
}
return m;
}
}
| > | | | < < < < < < < < < < < < < < | < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
}
if( !g.perm.RdAddr ){
m &= ~CONFIGSET_ADDR;
}
return m;
}
}
if( strncmp(zName, "walias:/", 8)==0 ){
return CONFIGSET_ALIAS;
}
return 0;
}
/*
** A mask of all configuration tables that have been reset already.
*/
static int configHasBeenReset = 0;
/*
** Mask of modified configuration sets
*/
static int rebuildMask = 0;
/*
|
| ︙ | ︙ | |||
512 513 514 515 516 517 518 519 520 521 522 523 524 525 | ** /concealed $MTIME $HASH content $VALUE ** ** OLD FORMAT: ** ** The old format is retained for backwards compatibility, but is deprecated. ** The cutover from old format to new was on 2011-04-25. After sufficient ** time has passed, support for the old format will be removed. ** ** zName is either the NAME of an element of the CONFIG table, or else ** one of the special names "@shun", "@reportfmt", "@user", or "@concealed". ** If zName is a CONFIG table name, then CONTENT replaces (overwrites) the ** element in the CONFIG table. For one of the @-labels, CONTENT is raw ** SQL that is evaluated. Note that the raw SQL in CONTENT might not ** insert directly into the target table but might instead use a proxy | > | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | ** /concealed $MTIME $HASH content $VALUE ** ** OLD FORMAT: ** ** The old format is retained for backwards compatibility, but is deprecated. ** The cutover from old format to new was on 2011-04-25. After sufficient ** time has passed, support for the old format will be removed. ** Update: Support for the old format was remoed on 2017-09-20. ** ** zName is either the NAME of an element of the CONFIG table, or else ** one of the special names "@shun", "@reportfmt", "@user", or "@concealed". ** If zName is a CONFIG table name, then CONTENT replaces (overwrites) the ** element in the CONFIG table. For one of the @-labels, CONTENT is raw ** SQL that is evaluated. Note that the raw SQL in CONTENT might not ** insert directly into the target table but might instead use a proxy |
| ︙ | ︙ | |||
607 608 609 610 611 612 613 |
blob_append_sql(&sql, " WHERE \"%w\"=%s AND mtime<%s",
aType[ii].zPrimKey, azToken[1]/*safe-for-%s*/,
azToken[0]/*safe-for-%s*/);
db_multi_exec("%s", blob_sql_text(&sql));
}
blob_reset(&sql);
rebuildMask |= thisMask;
| < < < < < < < < < < < < < < < < < < < < < < < < < | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
blob_append_sql(&sql, " WHERE \"%w\"=%s AND mtime<%s",
aType[ii].zPrimKey, azToken[1]/*safe-for-%s*/,
azToken[0]/*safe-for-%s*/);
db_multi_exec("%s", blob_sql_text(&sql));
}
blob_reset(&sql);
rebuildMask |= thisMask;
}
}
/*
** Process a file full of "config" cards.
*/
void configure_receive_all(Blob *pIn, int groupMask){
|
| ︙ | ︙ | |||
755 756 757 758 759 760 761 762 763 764 765 766 767 768 |
);
blob_appendf(pOut, "config /concealed %d\n%s\n",
blob_size(&rec), blob_str(&rec));
nCard++;
blob_reset(&rec);
}
db_finalize(&q);
}
db_prepare(&q, "SELECT mtime, quote(name), quote(value) FROM config"
" WHERE name=:name AND mtime>=%lld", iStart);
for(ii=0; ii<count(aConfig); ii++){
if( (aConfig[ii].groupMask & groupMask)!=0 && aConfig[ii].zName[0]!='@' ){
db_bind_text(&q, ":name", aConfig[ii].zName);
while( db_step(&q)==SQLITE_ROW ){
| > > > > > > > > > > > > > > > > | 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
);
blob_appendf(pOut, "config /concealed %d\n%s\n",
blob_size(&rec), blob_str(&rec));
nCard++;
blob_reset(&rec);
}
db_finalize(&q);
}
if( groupMask & CONFIGSET_ALIAS ){
db_prepare(&q, "SELECT mtime, quote(name), quote(value) FROM config"
" WHERE name GLOB 'walias:/*' AND mtime>=%lld", iStart);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(&rec,"%s %s value %s",
db_column_text(&q, 0),
db_column_text(&q, 1),
db_column_text(&q, 2)
);
blob_appendf(pOut, "config /config %d\n%s\n",
blob_size(&rec), blob_str(&rec));
nCard++;
blob_reset(&rec);
}
db_finalize(&q);
}
db_prepare(&q, "SELECT mtime, quote(name), quote(value) FROM config"
" WHERE name=:name AND mtime>=%lld", iStart);
for(ii=0; ii<count(aConfig); ii++){
if( (aConfig[ii].groupMask & groupMask)!=0 && aConfig[ii].zName[0]!='@' ){
db_bind_text(&q, ":name", aConfig[ii].zName);
while( db_step(&q)==SQLITE_ROW ){
|
| ︙ | ︙ | |||
837 838 839 840 841 842 843 | ** ** Where METHOD is one of: export import merge pull push reset. All methods ** accept the -R or --repository option to specify a repository. ** ** %fossil configuration export AREA FILENAME ** ** Write to FILENAME exported configuration information for AREA. | | | < | < < | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 | ** ** Where METHOD is one of: export import merge pull push reset. All methods ** accept the -R or --repository option to specify a repository. ** ** %fossil configuration export AREA FILENAME ** ** Write to FILENAME exported configuration information for AREA. ** AREA can be one of: all email project shun skin ticket user alias ** ** %fossil configuration import FILENAME ** ** Read a configuration from FILENAME, overwriting the current ** configuration. ** ** %fossil configuration merge FILENAME ** ** Read a configuration from FILENAME and merge its values into ** the current configuration. Existing values take priority over ** values read from FILENAME. ** ** %fossil configuration pull AREA ?URL? ** ** Pull and install the configuration from a different server ** identified by URL. If no URL is specified, then the default ** server is used. Use the --overwrite flag to completely ** replace local settings with content received from URL. ** ** %fossil configuration push AREA ?URL? ** ** Push the local configuration into the remote server identified ** by URL. Admin privilege is required on the remote server for ** this to work. When the same record exists both locally and on ** the remote end, the one that was most recently changed wins. ** ** %fossil configuration reset AREA ** ** Restore the configuration to the default. AREA as above. ** ** %fossil configuration sync AREA ?URL? ** |
| ︙ | ︙ | |||
930 931 932 933 934 935 936 |
}else
if( strncmp(zMethod, "pull", n)==0
|| strncmp(zMethod, "push", n)==0
|| strncmp(zMethod, "sync", n)==0
){
int mask;
const char *zServer = 0;
| < < < | 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 |
}else
if( strncmp(zMethod, "pull", n)==0
|| strncmp(zMethod, "push", n)==0
|| strncmp(zMethod, "sync", n)==0
){
int mask;
const char *zServer = 0;
int overwriteFlag = 0;
if( strncmp(zMethod,"pull",n)==0 ){
overwriteFlag = find_option("overwrite",0,0)!=0;
}
url_proxy_options();
if( g.argc!=4 && g.argc!=5 ){
usage(mprintf("%s AREA ?URL?", zMethod));
}
mask = configure_name_to_mask(g.argv[3], 1);
if( g.argc==5 ){
zServer = g.argv[4];
}
url_parse(zServer, URL_PROMPT_PW);
if( g.url.protocol==0 ) fossil_fatal("no server URL specified");
user_select();
url_enable_proxy("via proxy: ");
if( overwriteFlag ) mask |= CONFIGSET_OVERWRITE;
if( strncmp(zMethod, "push", n)==0 ){
client_sync(0,0,(unsigned)mask);
}else if( strncmp(zMethod, "pull", n)==0 ){
client_sync(0,(unsigned)mask,0);
}else{
client_sync(0,(unsigned)mask,(unsigned)mask);
|
| ︙ | ︙ |
Changes to src/content.c.
| ︙ | ︙ | |||
115 116 117 118 119 120 121 | contentCache.szTotal = 0; } /* ** Return the srcid associated with rid. Or return 0 if rid is ** original content and not a delta. */ | | | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
contentCache.szTotal = 0;
}
/*
** Return the srcid associated with rid. Or return 0 if rid is
** original content and not a delta.
*/
int delta_source_rid(int rid){
static Stmt q;
int srcid;
db_static_prepare(&q, "SELECT srcid FROM delta WHERE rid=:rid");
db_bind_int(&q, ":rid", rid);
if( db_step(&q)==SQLITE_ROW ){
srcid = db_column_int(&q, 0);
}else{
|
| ︙ | ︙ | |||
163 164 165 166 167 168 169 |
if( bag_find(&contentCache.available, rid) ){
return 1;
}
if( content_size(rid, -1)<0 ){
bag_insert(&contentCache.missing, rid);
return 0;
}
| | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
if( bag_find(&contentCache.available, rid) ){
return 1;
}
if( content_size(rid, -1)<0 ){
bag_insert(&contentCache.missing, rid);
return 0;
}
srcid = delta_source_rid(rid);
if( srcid==0 ){
bag_insert(&contentCache.available, rid);
return 1;
}
rid = srcid;
}
fossil_panic("delta-loop in repository");
|
| ︙ | ︙ | |||
248 249 250 251 252 253 254 |
blob_copy(pBlob, &contentCache.a[i].content);
contentCache.a[i].age = contentCache.nextAge++;
return 1;
}
}
}
| | | | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
blob_copy(pBlob, &contentCache.a[i].content);
contentCache.a[i].age = contentCache.nextAge++;
return 1;
}
}
}
nextRid = delta_source_rid(rid);
if( nextRid==0 ){
rc = content_of_blob(rid, pBlob);
}else{
int n = 1;
int nAlloc = 10;
int *a = 0;
int mx;
Blob delta, next;
a = fossil_malloc( sizeof(a[0])*nAlloc );
a[0] = rid;
a[1] = nextRid;
n = 1;
while( !bag_find(&contentCache.inCache, nextRid)
&& (nextRid = delta_source_rid(nextRid))>0 ){
n++;
if( n>=nAlloc ){
if( n>db_int(0, "SELECT max(rid) FROM blob") ){
fossil_panic("infinite loop in DELTA table");
}
nAlloc = nAlloc*2 + 10;
a = fossil_realloc(a, nAlloc*sizeof(a[0]));
|
| ︙ | ︙ | |||
713 714 715 716 717 718 719 |
}
/*
** Make sure the content at rid is the original content and is not a
** delta.
*/
void content_undelta(int rid){
| | | 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
}
/*
** Make sure the content at rid is the original content and is not a
** delta.
*/
void content_undelta(int rid){
if( delta_source_rid(rid)>0 ){
Blob x;
if( content_get(rid, &x) ){
Stmt s;
db_prepare(&s, "UPDATE blob SET content=:c, size=%d WHERE rid=%d",
blob_size(&x), rid);
blob_compress(&x, &x);
db_bind_blob(&s, ":c", &x);
|
| ︙ | ︙ | |||
770 771 772 773 774 775 776 |
"DELETE FROM private WHERE rid=:rid"
);
db_bind_int(&s1, ":rid", rid);
db_exec(&s1);
}
/*
| | > > | > | | > | | | | > > > | | < < < < | < < | > > | < | < | < < > | < > < > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > | | | < | > > | > > > > | > > > | | 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 |
"DELETE FROM private WHERE rid=:rid"
);
db_bind_int(&s1, ":rid", rid);
db_exec(&s1);
}
/*
** Try to change the storage of rid so that it is a delta from one
** of the artifacts given in aSrc[0]..aSrc[nSrc-1]. The aSrc[*] that
** gives the smallest delta is choosen.
**
** If rid is already a delta from some other place then no
** conversion occurs and this is a no-op unless force==1. If force==1,
** then nSrc must also be 1.
**
** Never generate a delta that carries a private artifact into a public
** artifact. Otherwise, when we go to send the public artifact on a
** sync operation, the other end of the sync will never be able to receive
** the source of the delta. It is OK to delta private->private and
** public->private and public->public. Just no private->public delta.
**
** If aSrc[bestSrc] is already a dleta that depends on rid, then it is
** converted to undeltaed text before the aSrc[bestSrc]->rid delta is
** created, in order to prevent a delta loop.
**
** If either rid or aSrc[i] contain less than 50 bytes, or if the
** resulting delta does not achieve a compression of at least 25%
** the rid is left untouched.
**
** Return 1 if a delta is made and 0 if no delta occurs.
*/
int content_deltify(int rid, int *aSrc, int nSrc, int force){
int s;
Blob data; /* Content of rid */
Blob src; /* Content of aSrc[i] */
Blob delta; /* Delta from aSrc[i] to rid */
Blob bestDelta; /* Best delta seen so far */
int bestSrc = 0; /* Which aSrc is the source of the best delta */
int rc = 0; /* Value to return */
int i; /* Loop variable for aSrc[] */
/* If rid is already a child (a delta) of some other artifact, return
** immediately if the force flags is false
*/
if( !force && delta_source_rid(rid)>0 ) return 0;
/* Get the complete content of the object to be delta-ed. If the size
** is less than 50 bytes, then there really is no point in trying to do
** a delta, so return immediately
*/
content_get(rid, &data);
if( blob_size(&data)<50 ){
/* Do not try to create a delta for objects smaller than 50 bytes */
blob_reset(&data);
return 0;
}
blob_init(&bestDelta, 0, 0);
/* Loop over all candidate delta sources */
for(i=0; i<nSrc; i++){
int srcid = aSrc[i];
if( srcid==rid ) continue;
if( content_is_private(srcid) && !content_is_private(rid) ) continue;
/* Compute all ancestors of srcid and make sure rid is not one of them.
** If rid is an ancestor of srcid, then making rid a decendent of srcid
** would create a delta loop. */
s = srcid;
while( (s = delta_source_rid(s))>0 ){
if( s==rid ){
content_undelta(srcid);
break;
}
}
if( s!=0 ) continue;
content_get(srcid, &src);
if( blob_size(&src)<50 ){
/* The source is smaller then 50 bytes, so don't bother trying to use it*/
blob_reset(&src);
continue;
}
blob_delta_create(&src, &data, &delta);
if( blob_size(&delta) < blob_size(&data)*0.75
&& (bestSrc<=0 || blob_size(&delta)<blob_size(&bestDelta))
){
/* This is the best delta seen so far. Remember it */
blob_reset(&bestDelta);
bestDelta = delta;
bestSrc = srcid;
}else{
/* This delta is not a candidate for becoming the new parent of rid */
blob_reset(&delta);
}
blob_reset(&src);
}
/* If there is a winning candidate for the new parent of rid, then
** make that candidate the new parent now */
if( bestSrc>0 ){
Stmt s1, s2; /* Statements used to create the delta */
blob_compress(&bestDelta, &bestDelta);
db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid);
db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,%d)", rid, bestSrc);
db_bind_blob(&s1, ":data", &bestDelta);
db_begin_transaction();
db_exec(&s1);
db_exec(&s2);
db_end_transaction(0);
db_finalize(&s1);
db_finalize(&s2);
verify_before_commit(rid);
rc = 1;
}
blob_reset(&data);
blob_reset(&bestDelta);
return rc;
}
/*
** COMMAND: test-content-deltify
**
** Usage: %fossil RID SRCID SRCID ... [-force]
**
** Convert the content at RID into a delta one of the from SRCIDs.
*/
void test_content_deltify_cmd(void){
int nSrc;
int *aSrc;
int i;
int bForce = find_option("force",0,0)!=0;
if( g.argc<3 ) usage("[--force] RID SRCID SRCID...");
aSrc = fossil_malloc( (g.argc-2)*sizeof(aSrc[0]) );
nSrc = 0;
for(i=2; i<g.argc; i++) aSrc[nSrc++] = atoi(g.argv[i]);
db_must_be_within_tree();
content_deltify(atoi(g.argv[2]), aSrc, nSrc, bForce);
}
/*
** Return true if Blob p looks like it might be a parsable control artifact.
*/
static int looks_like_control_artifact(Blob *p){
const char *z = blob_buffer(p);
|
| ︙ | ︙ |
Changes to src/db.c.
| ︙ | ︙ | |||
32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #if defined(_WIN32) # if USE_SEE # include <windows.h> # endif #else # include <pwd.h> #endif #include <sqlite3.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <time.h> #include "db.h" | > > > | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #if defined(_WIN32) # if USE_SEE # include <windows.h> # endif #else # include <pwd.h> #endif #if USE_SEE && !defined(SQLITE_HAS_CODEC) # define SQLITE_HAS_CODEC #endif #include <sqlite3.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <time.h> #include "db.h" |
| ︙ | ︙ | |||
237 238 239 240 241 242 243 244 245 246 247 248 |
}
}
db.aHook[db.nCommitHook].sequence = sequence;
db.aHook[db.nCommitHook].xHook = x;
db.nCommitHook++;
}
/*
** Prepare a Stmt. Assume that the Stmt is previously uninitialized.
** If the input string contains multiple SQL statements, only the first
** one is processed. All statements beyond the first are silently ignored.
*/
| > > > > > > > > | > > > > | | | | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
}
}
db.aHook[db.nCommitHook].sequence = sequence;
db.aHook[db.nCommitHook].xHook = x;
db.nCommitHook++;
}
#if INTERFACE
/*
** Possible flags to db_vprepare
*/
#define DB_PREPARE_IGNORE_ERROR 0x001 /* Suppress errors */
#define DB_PREPARE_PERSISTENT 0x002 /* Stmt will stick around for a while */
#endif
/*
** Prepare a Stmt. Assume that the Stmt is previously uninitialized.
** If the input string contains multiple SQL statements, only the first
** one is processed. All statements beyond the first are silently ignored.
*/
int db_vprepare(Stmt *pStmt, int flags, const char *zFormat, va_list ap){
int rc;
int prepFlags = 0;
char *zSql;
blob_zero(&pStmt->sql);
blob_vappendf(&pStmt->sql, zFormat, ap);
va_end(ap);
zSql = blob_str(&pStmt->sql);
db.nPrepare++;
if( flags & DB_PREPARE_PERSISTENT ){
prepFlags = SQLITE_PREPARE_PERSISTENT;
}
rc = sqlite3_prepare_v3(g.db, zSql, -1, prepFlags, &pStmt->pStmt, 0);
if( rc!=0 && (flags & DB_PREPARE_IGNORE_ERROR)!=0 ){
db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
}
pStmt->pNext = pStmt->pPrev = 0;
pStmt->nStep = 0;
return rc;
}
int db_prepare(Stmt *pStmt, const char *zFormat, ...){
int rc;
va_list ap;
va_start(ap, zFormat);
rc = db_vprepare(pStmt, 0, zFormat, ap);
va_end(ap);
return rc;
}
int db_prepare_ignore_error(Stmt *pStmt, const char *zFormat, ...){
int rc;
va_list ap;
va_start(ap, zFormat);
rc = db_vprepare(pStmt, DB_PREPARE_IGNORE_ERROR, zFormat, ap);
va_end(ap);
return rc;
}
int db_static_prepare(Stmt *pStmt, const char *zFormat, ...){
int rc = SQLITE_OK;
if( blob_size(&pStmt->sql)==0 ){
va_list ap;
va_start(ap, zFormat);
rc = db_vprepare(pStmt, DB_PREPARE_PERSISTENT, zFormat, ap);
pStmt->pNext = db.pAllStmt;
pStmt->pPrev = 0;
if( db.pAllStmt ) db.pAllStmt->pPrev = pStmt;
db.pAllStmt = pStmt;
va_end(ap);
}
return rc;
|
| ︙ | ︙ | |||
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 |
fossil_free(zPrompt);
db_set_saved_encryption_key(pKey);
}
}
#endif
}
/*
** Open a database file. Return a pointer to the new database
** connection. An error results in process abort.
*/
LOCAL sqlite3 *db_open(const char *zDbName){
int rc;
sqlite3 *db;
| > > > > > > > > > > > > > > > > > > > > > > < < | < < < < < < < | 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 |
fossil_free(zPrompt);
db_set_saved_encryption_key(pKey);
}
}
#endif
}
/*
** Sets the encryption key for the database, if necessary.
*/
void db_maybe_set_encryption_key(sqlite3 *db, const char *zDbName){
Blob key;
blob_init(&key, 0, 0);
db_maybe_obtain_encryption_key(zDbName, &key);
if( blob_size(&key)>0 ){
if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){
char *zCmd = sqlite3_mprintf("PRAGMA key(%Q)", blob_str(&key));
sqlite3_exec(db, zCmd, 0, 0, 0);
fossil_secure_zero(zCmd, strlen(zCmd));
sqlite3_free(zCmd);
#if USE_SEE
}else{
sqlite3_key(db, blob_str(&key), -1);
#endif
}
}
blob_reset(&key);
}
/*
** Open a database file. Return a pointer to the new database
** connection. An error results in process abort.
*/
LOCAL sqlite3 *db_open(const char *zDbName){
int rc;
sqlite3 *db;
if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName);
rc = sqlite3_open_v2(
zDbName, &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
g.zVfsName
);
if( rc!=SQLITE_OK ){
db_err("[%s]: %s", zDbName, sqlite3_errmsg(db));
}
db_maybe_set_encryption_key(db, zDbName);
sqlite3_busy_timeout(db, 5000);
sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */
sqlite3_create_function(db, "user", 0, SQLITE_UTF8, 0, db_sql_user, 0, 0);
sqlite3_create_function(db, "cgi", 1, SQLITE_UTF8, 0, db_sql_cgi, 0, 0);
sqlite3_create_function(db, "cgi", 2, SQLITE_UTF8, 0, db_sql_cgi, 0, 0);
sqlite3_create_function(db, "print", -1, SQLITE_UTF8, 0,db_sql_print,0,0);
sqlite3_create_function(
|
| ︙ | ︙ | |||
1098 1099 1100 1101 1102 1103 1104 |
}
/*
** zDbName is the name of a database file. Attach zDbName using
** the name zLabel.
*/
void db_attach(const char *zDbName, const char *zLabel){
| < > | | | | | > > > > > > > > > > > | 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 |
}
/*
** zDbName is the name of a database file. Attach zDbName using
** the name zLabel.
*/
void db_attach(const char *zDbName, const char *zLabel){
Blob key;
blob_init(&key, 0, 0);
db_maybe_obtain_encryption_key(zDbName, &key);
if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){
char *zCmd = sqlite3_mprintf("ATTACH DATABASE %Q AS %Q KEY %Q",
zDbName, zLabel, blob_str(&key));
db_multi_exec(zCmd /*works-like:""*/);
fossil_secure_zero(zCmd, strlen(zCmd));
sqlite3_free(zCmd);
}else{
char *zCmd = sqlite3_mprintf("ATTACH DATABASE %Q AS %Q KEY ''",
zDbName, zLabel);
db_multi_exec(zCmd /*works-like:""*/);
sqlite3_free(zCmd);
#if USE_SEE
if( blob_size(&key)>0 ){
sqlite3_key_v2(g.db, zLabel, blob_str(&key), -1);
}
#endif
}
blob_reset(&key);
}
/*
** Change the schema name of the "main" database to zLabel.
** zLabel must be a static string that is unchanged for the life of
** the database connection.
|
| ︙ | ︙ | |||
1434 1435 1436 1437 1438 1439 1440 | return 1; #endif } /* ** Returns non-zero if support for symlinks is currently enabled. */ | | < < < < | < | 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 |
return 1;
#endif
}
/*
** Returns non-zero if support for symlinks is currently enabled.
*/
int db_allow_symlinks(void){
return g.allowSymlinks;
}
/*
** Open the repository database given by zDbName. If zDbName==NULL then
** get the name from the already open local database.
*/
void db_open_repository(const char *zDbName){
|
| ︙ | ︙ | |||
1489 1490 1491 1492 1493 1494 1495 |
g.zAuxSchema = db_get("aux-schema","");
g.eHashPolicy = db_get_int("hash-policy",-1);
if( g.eHashPolicy<0 ){
g.eHashPolicy = hname_default_policy();
db_set_int("hash-policy", g.eHashPolicy, 0);
}
| | | | 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 |
g.zAuxSchema = db_get("aux-schema","");
g.eHashPolicy = db_get_int("hash-policy",-1);
if( g.eHashPolicy<0 ){
g.eHashPolicy = hname_default_policy();
db_set_int("hash-policy", g.eHashPolicy, 0);
}
/* Make a change to the CHECK constraint on the BLOB table for
** version 2.0 and later.
*/
rebuild_schema_update_2_0(); /* Do the Fossil-2.0 schema updates */
}
/*
** Flags for the db_find_and_open_repository() function.
*/
|
| ︙ | ︙ | |||
1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 |
}
/*
** Open the local database. If unable, exit with an error.
*/
void db_must_be_within_tree(void){
if( db_open_local(0)==0 ){
fossil_fatal("current directory is not within an open checkout");
}
db_open_repository(0);
db_verify_schema();
}
| > > > > | 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 |
}
/*
** Open the local database. If unable, exit with an error.
*/
void db_must_be_within_tree(void){
if( find_repository_option() ){
fossil_fatal("the \"%s\" command only works from within an open check-out",
g.argv[1]);
}
if( db_open_local(0)==0 ){
fossil_fatal("current directory is not within an open checkout");
}
db_open_repository(0);
db_verify_schema();
}
|
| ︙ | ︙ | |||
1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 |
fprintf(stderr, "-- prepared statements %10d\n", db.nPrepare);
}
while( db.pAllStmt ){
db_finalize(db.pAllStmt);
}
db_end_transaction(1);
pStmt = 0;
sqlite3_exec(g.db, "PRAGMA optimize", 0, 0, 0);
db_close_config();
/* If the localdb has a lot of unused free space,
** then VACUUM it as we shut down.
*/
if( db_database_slot("localdb")>=0 ){
int nFree = db_int(0, "PRAGMA localdb.freelist_count");
| > > | 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 |
fprintf(stderr, "-- prepared statements %10d\n", db.nPrepare);
}
while( db.pAllStmt ){
db_finalize(db.pAllStmt);
}
db_end_transaction(1);
pStmt = 0;
g.dbIgnoreErrors++; /* Stop "database locked" warnings from PRAGMA optimize */
sqlite3_exec(g.db, "PRAGMA optimize", 0, 0, 0);
g.dbIgnoreErrors--;
db_close_config();
/* If the localdb has a lot of unused free space,
** then VACUUM it as we shut down.
*/
if( db_database_slot("localdb")>=0 ){
int nFree = db_int(0, "PRAGMA localdb.freelist_count");
|
| ︙ | ︙ | |||
1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 |
** Return a pointer to a string that contains the RHS of an IN operator
** that will select CONFIG table names that are in the list of control
** settings.
*/
const char *db_setting_inop_rhs(){
Blob x;
int i;
const char *zSep = "";
blob_zero(&x);
blob_append_sql(&x, "(");
| > > | | 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 |
** Return a pointer to a string that contains the RHS of an IN operator
** that will select CONFIG table names that are in the list of control
** settings.
*/
const char *db_setting_inop_rhs(){
Blob x;
int i;
int nSetting;
const Setting *aSetting = setting_info(&nSetting);
const char *zSep = "";
blob_zero(&x);
blob_append_sql(&x, "(");
for(i=0; i<nSetting; i++){
blob_append_sql(&x, "%s%Q", zSep/*safe-for-%s*/, aSetting[i].name);
zSep = ",";
}
blob_append_sql(&x, ")");
return blob_sql_text(&x);
}
|
| ︙ | ︙ | |||
1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 |
char *zDate;
Blob hash;
Blob manifest;
db_set("content-schema", CONTENT_SCHEMA, 0);
db_set("aux-schema", AUX_SCHEMA_MAX, 0);
db_set("rebuilt", get_version(), 0);
db_multi_exec(
"INSERT INTO config(name,value,mtime)"
" VALUES('server-code', lower(hex(randomblob(20))),now());"
"INSERT INTO config(name,value,mtime)"
" VALUES('project-code', lower(hex(randomblob(20))),now());"
);
if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
| > > | 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 |
char *zDate;
Blob hash;
Blob manifest;
db_set("content-schema", CONTENT_SCHEMA, 0);
db_set("aux-schema", AUX_SCHEMA_MAX, 0);
db_set("rebuilt", get_version(), 0);
db_set("admin-log", "1", 0);
db_set("access-log", "1", 0);
db_multi_exec(
"INSERT INTO config(name,value,mtime)"
" VALUES('server-code', lower(hex(randomblob(20))),now());"
"INSERT INTO config(name,value,mtime)"
" VALUES('project-code', lower(hex(randomblob(20))),now());"
);
if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
|
| ︙ | ︙ | |||
1826 1827 1828 1829 1830 1831 1832 |
if( zTemplate ){
/*
** Copy all settings from the supplied template repository.
*/
db_multi_exec(
"INSERT OR REPLACE INTO config"
" SELECT name,value,mtime FROM settingSrc.config"
| | | 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 |
if( zTemplate ){
/*
** Copy all settings from the supplied template repository.
*/
db_multi_exec(
"INSERT OR REPLACE INTO config"
" SELECT name,value,mtime FROM settingSrc.config"
" WHERE (name IN %s OR name IN %s OR name GLOB 'walias:/*')"
" AND name NOT GLOB 'project-*'"
" AND name NOT GLOB 'short-project-*';",
configure_inop_rhs(CONFIGSET_ALL),
db_setting_inop_rhs()
);
g.eHashPolicy = db_get_int("hash-policy", g.eHashPolicy);
db_multi_exec(
|
| ︙ | ︙ | |||
2691 2692 2693 2694 2695 2696 2697 |
fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
pSetting->name);
}
}
db_finalize(&q);
}
| < | 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 |
fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
pSetting->name);
}
}
db_finalize(&q);
}
#if INTERFACE
/*
** Define all settings, which can be controlled via the set/unset
** command.
**
** var is the name of the internal configuration name for db_(un)set.
** If var is 0, the settings name is used.
|
| ︙ | ︙ | |||
2716 2717 2718 2719 2720 2721 2722 | int width; /* Width of display. 0 for boolean values. */ int versionable; /* Is this setting versionable? */ int forceTextArea; /* Force using a text area for display? */ const char *def; /* Default value */ }; #endif /* INTERFACE */ | > > > | | > > > | > > > > > | > > | > > | > > > | > > > > > | > > > > > > | > | > > > > > > > > > > | > > > > > | > > > > | < > | > > > > > | > > | > > > > > > | > > > > > > | > > > > | > > > | > > > > > > | > > > > | > > > > > | > > > > | > > > > > > > > > | > | > > | > > > > > > | > > > > > > > | > > > | > > | > > > > | > > > > | > > > > > > > > | > > > | > > > > | > > > > | > > > > > > > | > > > > | > > > > > > | > > > > > > > | > > > > | > > > > > > > > | > > > | > > > > > > | > > > > > > > | > > > > > | > > > > > | > > > > | > > > > > | > > > > > > | > > > > > > > > > > > > > > | > > | > > > > > > > > < > > > > > > > > > | > > > > | > | > > > > > > > > > | > > > > | > > > > > | > > > > > | > > > > > > | < < > > > > > | > > | | | | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < > > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < > > < < < < < < < < < < < | | 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 |
int width; /* Width of display. 0 for boolean values. */
int versionable; /* Is this setting versionable? */
int forceTextArea; /* Force using a text area for display? */
const char *def; /* Default value */
};
#endif /* INTERFACE */
/*
** SETTING: access-log boolean default=off
**
** When the access-log setting is enabled, all login attempts (successful
** and unsuccessful) on the web interface are recorded in the "access" table
** of the repository.
*/
/*
** SETTING: admin-log boolean default=off
**
** When the admin-log setting is enabled, configuration changes are recorded
** in the "admin_log" table of the repository.
*/
#if defined(_WIN32)
/*
** SETTING: allow-symlinks boolean default=off versionable
** Allows symbolic links in the repository when enabled.
*/
#endif
#if !defined(_WIN32)
/*
** SETTING: allow-symlinks boolean default=on versionable
** Allows symbolic links in the repository when enabled.
*/
#endif
/*
** SETTING: auto-captcha boolean default=on variable=autocaptcha
** If enabled, the /login page provides a button that will automatically
** fill in the captcha password. This makes things easier for human users,
** at the expense of also making logins easier for malecious robots.
*/
/*
** SETTING: auto-hyperlink boolean default=on
** Use javascript to enable hyperlinks on web pages
** for all users (regardless of the "h" privilege) if the
** User-Agent string in the HTTP header look like it came
** from real person, not a spider or bot.
*/
/*
** SETTING: auto-shun boolean default=on
** If enabled, automatically pull the shunning list
** from a server to which the client autosyncs.
*/
/*
** SETTING: autosync width=16 default=on
** This setting can take either a boolean value or "pullonly"
** If enabled, automatically pull prior to commit
** or update and automatically push after commit or
** tag or branch creation. If the value is "pullonly"
** then only pull operations occur automatically.
*/
/*
** SETTING: autosync-tries width=16 default=1
** If autosync is enabled setting this to a value greater
** than zero will cause autosync to try no more than this
** number of attempts if there is a sync failure.
*/
/*
** SETTING: binary-glob width=40 versionable block-text
** The VALUE of this setting is a comma or newline-separated list of
** GLOB patterns that should be treated as binary files
** for committing and merging purposes. Example: *.jpg
*/
#if defined(_WIN32)||defined(__CYGWIN__)||defined(__DARWIN__)
/*
** SETTING: case-sensitive boolean default=off
** If TRUE, the files whose names differ only in case
** are considered distinct. If FALSE files whose names
** differ only in case are the same file. Defaults to
** TRUE for unix and FALSE for Cygwin, Mac and Windows.
*/
#endif
#if !(defined(_WIN32)||defined(__CYGWIN__)||defined(__DARWIN__))
/*
** SETTING: case-sensitive boolean default=on
** If TRUE, the files whose names differ only in case
** are considered distinct. If FALSE files whose names
** differ only in case are the same file. Defaults to
** TRUE for unix and FALSE for Cygwin, Mac and Windows.
*/
#endif
/*
** SETTING: clean-glob width=40 versionable block-text
** The VALUE of this setting is a comma or newline-separated list of GLOB
** patterns specifying files that the "clean" command will
** delete without prompting or allowing undo.
** Example: *.a,*.lib,*.o
*/
/*
** SETTING: clearsign boolean default=off
** When enabled, fossil will attempt to sign all commits
** with gpg. When disabled, commits will be unsigned.
*/
/*
** SETTING: crlf-glob width=40 versionable block-text
** The value is a comma or newline-separated list of GLOB patterns for
** text files in which it is ok to have CR, CR+LF or mixed
** line endings. Set to "*" to disable CR+LF checking.
** The crnl-glob setting is a compatibility alias.
*/
/*
** SETTING: crnl-glob width=40 versionable block-text
** This is an alias for the crlf-glob setting
*/
/*
** SETTING: default-perms width=16 default=u
** Permissions given automatically to new users. For more
** information on permissions see the Users page in Server
** Administration of the HTTP UI.
*/
/* SETTING: diff-binary boolean default=on
** If enabled, permit files that may be binary
** or that match the "binary-glob" setting to be used with
** external diff programs. If disabled, skip these files.
*/
/*
** SETTING: diff-command width=40
** The value is an external command to run when performing a diff.
** If undefined, the internal text diff will be used.
*/
/*
** SETTING: dont-push boolean default=off
** If enabled, prevent this repository from pushing from client to
** server. This can be used as an extra precaution to prevent
** accidental pushes to a public server from a private clone.
*/
/*
** SETTING: dotfiles boolean versionable default=off
** If enabled, include --dotfiles option for all compatible commands.
*/
/*
** SETTING: editor width=32
** The value is an external command that will launch the
** text editor command used for check-in comments.
*/
/*
** SETTING: empty-dirs width=40 versionable block-text
** The value is a comma or newline-separated list of pathnames. On
** update and checkout commands, if no file or directory
** exists with that name, an empty directory will be
** created.
*/
/*
** SETTING: encoding-glob width=40 versionable block-text
** The value is a comma or newline-separated list of GLOB
** patterns specifying files that the "commit" command will
** ignore when issuing warnings about text files that may
** use another encoding than ASCII or UTF-8. Set to "*"
** to disable encoding checking.
*/
#if defined(FOSSIL_ENABLE_EXEC_REL_PATHS)
/*
** SETTING: exec-rel-paths boolean default=on
** When executing certain external commands (e.g. diff and
** gdiff), use relative paths.
*/
#endif
#if !defined(FOSSIL_ENABLE_EXEC_REL_PATHS)
/*
** SETTING: exec-rel-paths boolean default=off
** When executing certain external commands (e.g. diff and
** gdiff), use relative paths.
*/
#endif
/*
** SETTING; gdiff-command width=40 default=gdiff
** The value is an external command to run when performing a graphical
** diff. If undefined, text diff will be used.
*/
/*
** SETTING: gmerge-command width=40
** The value is a graphical merge conflict resolver command operating
** on four files. Examples:
**
** kdiff3 "%baseline" "%original" "%merge" -o "%output"
** xxdiff "%original" "%baseline" "%merge" -M "%output"
** meld "%baseline" "%original" "%merge" "%output"
*/
/*
** SETTING: hash-digits width=5 default=10
** The number of hexadecimal digits of the SHA3 hash to display.
*/
/*
** SETTING: http-port width=16 default=8080
** The default TCP/IP port number to use by the "server"
** and "ui" commands.
*/
/*
** SETTING: https-login boolean default=off
** If true, then the Fossil web server will redirect unencrypted
** login screeen requests to HTTPS.
*/
/*
** SETTING: ignore-glob width=40 versionable block-text
** The value is a comma or newline-separated list of GLOB
** patterns specifying files that the "add", "addremove",
** "clean", and "extras" commands will ignore.
**
** Example: *.log customCode.c notes.txt
*/
/*
** SETTING: keep-glob width=40 versionable block-text
** The value is a comma or newline-separated list of GLOB
** patterns specifying files that the "clean" command will keep
*/
/*
** SETTING: localauth boolean default=off
** If enabled, require that HTTP connections from
** 127.0.0.1 be authenticated by password. If
** false, all HTTP requests from localhost have
** unrestricted access to the repository.
*/
/*
** SETTING: main-branch width=40 default=trunk
** The value is the primary branch for the project.
*/
/*
** SETTING: manifest width=5 versionable
** If enabled, automatically create files "manifest" and "manifest.uuid"
** in every checkout.
**
** Optionally use combinations of characters 'r' for "manifest",
** 'u' for "manifest.uuid" and 't' for "manifest.tags". The SQLite
** and Fossil repositories both require manifests.
*/
/*
** SETTING: max-loadavg width=25 default=0.0
** Some CPU-intensive web pages (ex: /zip, /tarball, /blame)
** are disallowed if the system load average goes above this
** value. "0.0" means no limit. This only works on unix.
** Only local settings of this value make a difference since
** when running as a web-server, Fossil does not open the
** global configuration database.
*/
/*
** SETTING: max-upload width=25 default=250000
** A limit on the size of uplink HTTP requests.
*/
/*
** SETTING: mtime-changes boolean default=on
** Use file modification times (mtimes) to detect when
** files have been modified. If disabled, all managed files
** are hashed to detect changes, which can be slow for large
** projects.
*/
#if FOSSIL_ENABLE_LEGACY_MV_RM
/*
** SETTING: mv-rm-files boolean default=off
** If enabled, the "mv" and "rename" commands will also move
** the associated files within the checkout -AND- the "rm"
** and "delete" commands will also remove the associated
** files from within the checkout.
*/
#endif
/*
** SETTING; pgp-command width=40
** DEFAULT: gpg --clearsign -o
**
** Command used to clear-sign manifests at check-in.
*/
/*
** SETTING: proxy width=32 default=off
** URL of the HTTP proxy. If undefined or "off" then
** the "http_proxy" environment variable is consulted.
** If the http_proxy environment variable is undefined
** then a direct HTTP connection is used.
*/
/*
** SETTING: relative-paths boolean default=on
** When showing changes and extras, report paths relative
** to the current working directory.
*/
/*
** SETTING: repo-cksum boolean default=on
** Compute checksums over all files in each checkout as a double-check
** of correctness. Disable this on large repositories for a performance
** improvement.
*/
/*
** SETTING: self-register boolean default=off
** Allow users to register themselves through the HTTP UI.
** This is useful if you want to see other names than
** "Anonymous" in e.g. ticketing system. On the other hand
** users can not be deleted.
*/
/*
** SETTING: ssh-command width=40
** The command used to talk to a remote machine with the "ssh://" protocol.
*/
/*
** SETTING: ssl-ca-location width=40
** The full pathname to a file containing PEM encoded
** CA root certificates, or a directory of certificates
** with filenames formed from the certificate hashes as
** required by OpenSSL.
**
** If set, this will override the OS default list of
** OpenSSL CAs. If unset, the default list will be used.
** Some platforms may add additional certificates.
** Checking your platform behaviour is required if the
** exact contents of the CA root is critical for your
** application.
*/
/*
** SETTING: ssl-identity width=40
** The full pathname to a file containing a certificate
** and private key in PEM format. Create by concatenating
** the certificate and private key files.
**
** This identity will be presented to SSL servers to
** authenticate this client, in addition to the normal
** password authentication.
*/
#ifdef FOSSIL_ENABLE_TCL
/*
** SETTING: tcl boolean default=off
** If enabled Tcl integration commands will be added to the TH1
** interpreter, allowing arbitrary Tcl expressions and
** scripts to be evaluated from TH1. Additionally, the Tcl
** interpreter will be able to evaluate arbitrary TH1
** expressions and scripts.
*/
/*
** SETTING: tcl-setup width=40 versionable block-text
** This is the setup script to be evaluated after creating
** and initializing the Tcl interpreter. By default, this
** is empty and no extra setup is performed.
*/
#endif /* FOSSIL_ENABLE_TCL */
#ifdef FOSSIL_ENABLE_TH1_DOCS
/*
** SETTING: th1-docs boolean default=off
** If enabled, this allows embedded documentation files to contain
** arbitrary TH1 scripts that are evaluated on the server. If native
** Tcl integration is also enabled, this setting has the
** potential to allow anybody with check-in privileges to
** do almost anything that the associated operating system
** user account could do. Extreme caution should be used
** when enabling this setting.
*/
#endif
#ifdef FOSSIL_ENABLE_TH1_HOOKS
/*
** SETTING: th1-hooks boolean default=off
** If enabled, special TH1 commands will be called before and
** after any Fossil command or web page.
*/
#endif
/*
** SETTING: th1-setup width=40 versionable block-text
** This is the setup script to be evaluated after creating
** and initializing the TH1 interpreter. By default, this
** is empty and no extra setup is performed.
*/
/*
** SETTING: th1-uri-regexp width=40 versionable block-text
** Specify which URI's are allowed in HTTP requests from
** TH1 scripts. If empty, no HTTP requests are allowed
** whatsoever.
*/
/*
** SETTING: uv-sync boolean default=off
** If true, automatically send unversioned files as part
** of a "fossil clone" or "fossil sync" command. The
** default is false, in which case the -u option is
** needed to clone or sync unversioned files.
*/
/*
** SETTING: web-browser width=30
** A shell command used to launch your preferred
** web browser when given a URL as an argument.
** Defaults to "start" on windows, "open" on Mac,
** and "firefox" on Unix.
*/
/*
** Look up a control setting by its name. Return a pointer to the Setting
** object, or NULL if there is no such setting.
**
** If allowPrefix is true, then the Setting returned is the first one for
** which zName is a prefix of the Setting name.
*/
Setting *db_find_setting(const char *zName, int allowPrefix){
int lwr, mid, upr, c;
int n = (int)strlen(zName) + !allowPrefix;
int nSetting;
const Setting *aSetting = setting_info(&nSetting);
lwr = 0;
upr = nSetting - 1;
while( upr>=lwr ){
mid = (upr+lwr)/2;
c = fossil_strncmp(zName, aSetting[mid].name, n);
if( c<0 ){
upr = mid - 1;
}else if( c>0 ){
lwr = mid + 1;
}else{
if( allowPrefix ){
while( mid>lwr && fossil_strncmp(zName, aSetting[mid-1].name, n)==0 ){
mid--;
}
}
return (Setting*)&aSetting[mid];
}
}
return 0;
}
/*
** COMMAND: settings
** COMMAND: unset*
**
** Usage: %fossil settings ?SETTING? ?VALUE? ?OPTIONS?
** or: %fossil unset SETTING ?OPTIONS?
**
** The "settings" command with no arguments lists all settings and their
** values. With just a SETTING name it shows the current value of that setting.
** With a VALUE argument it changes the property for the current repository.
**
** Settings marked as versionable are overridden by the contents of the
** file named .fossil-settings/PROPERTY in the check-out root, if that
** file exists.
**
** The "unset" command clears a setting.
**
** Settings can have both a "local" repository-only value and "global" value
** that applies to all repositories. The local values are stored in the
** "config" table of the repository and the global values are stored in the
** $HOME/.fossil file on unix or in the %LOCALAPPDATA%/_fossil file on Windows.
** If both a local and a global value exists for a setting, the local value
** takes precedence. This command normally operates on the local settings.
** Use the --global option to change global settings.
**
** Options:
** --global set or unset the given property globally instead of
** setting or unsetting it for the open repository only.
**
** --exact only consider exact name matches.
**
** See also: configuration
*/
void setting_cmd(void){
int i;
int globalFlag = find_option("global","g",0)!=0;
int exactFlag = find_option("exact",0,0)!=0;
int unsetFlag = g.argv[1][0]=='u';
int nSetting;
const Setting *aSetting = setting_info(&nSetting);
find_repository_option();
verify_all_options();
db_open_config(1, 0);
if( !globalFlag ){
db_find_and_open_repository(OPEN_ANY_SCHEMA | OPEN_OK_NOT_FOUND, 0);
}
if( !g.repositoryOpen ){
globalFlag = 1;
}
if( unsetFlag && g.argc!=3 ){
usage("PROPERTY ?-global?");
}
if( g.argc==2 ){
for(i=0; i<nSetting; i++){
print_setting(&aSetting[i]);
}
}else if( g.argc==3 || g.argc==4 ){
const char *zName = g.argv[2];
int n = (int)strlen(zName);
const Setting *pSetting = db_find_setting(zName, !exactFlag);
if( pSetting==0 ){
|
| ︙ | ︙ |
Changes to src/diff.c.
| ︙ | ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
#define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */
#define DIFF_IGNORE_ALLWS ((u64)0x03000000) /* Ignore all whitespace */
#define DIFF_SIDEBYSIDE ((u64)0x04000000) /* Generate a side-by-side diff */
#define DIFF_VERBOSE ((u64)0x08000000) /* Missing shown as empty files */
#define DIFF_BRIEF ((u64)0x10000000) /* Show filenames only */
#define DIFF_HTML ((u64)0x20000000) /* Render for HTML */
#define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */
#define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */
#define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */
#define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
#define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
#define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
/*
** These error messages are shared in multiple locations. They are defined
** here for consistency.
*/
#define DIFF_CANNOT_COMPUTE_BINARY \
"cannot compute difference between binary files\n"
| > > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
#define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */
#define DIFF_IGNORE_ALLWS ((u64)0x03000000) /* Ignore all whitespace */
#define DIFF_SIDEBYSIDE ((u64)0x04000000) /* Generate a side-by-side diff */
#define DIFF_VERBOSE ((u64)0x08000000) /* Missing shown as empty files */
#define DIFF_BRIEF ((u64)0x10000000) /* Show filenames only */
#define DIFF_HTML ((u64)0x20000000) /* Render for HTML */
#define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */
#define DIFF_NUMSTAT ((u64)0x80000000) /* Show line count of changes */
#define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */
#define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */
#define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
#define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */
#define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */
#define DIFF_SLOW_SBS (((u64)0x20)<<32) /* Better but slower side-by-side */
/*
** These error messages are shared in multiple locations. They are defined
** here for consistency.
*/
#define DIFF_CANNOT_COMPUTE_BINARY \
"cannot compute difference between binary files\n"
|
| ︙ | ︙ | |||
1035 1036 1037 1038 1039 1040 1041 | ** adding a cost to each match based on how well the two rows match ** each other. Insertion and deletion costs are 50. Match costs ** are between 0 and 100 where 0 is a perfect match 100 is a complete ** mismatch. */ static unsigned char *sbsAlignment( DLine *aLeft, int nLeft, /* Text on the left */ | | > | 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 |
** adding a cost to each match based on how well the two rows match
** each other. Insertion and deletion costs are 50. Match costs
** are between 0 and 100 where 0 is a perfect match 100 is a complete
** mismatch.
*/
static unsigned char *sbsAlignment(
DLine *aLeft, int nLeft, /* Text on the left */
DLine *aRight, int nRight, /* Text on the right */
u64 diffFlags /* Flags passed into the original diff */
){
int i, j, k; /* Loop counters */
int *a; /* One row of the Wagner matrix */
int *pToFree; /* Space that needs to be freed */
unsigned char *aM; /* Wagner result matrix */
int nMatch, iMatch; /* Number of matching lines and match score */
int mnLen; /* MIN(nLeft, nRight) */
|
| ︙ | ︙ | |||
1059 1060 1061 1062 1063 1064 1065 |
memset(aM, 1, nLeft);
return aM;
}
/* This algorithm is O(N**2). So if N is too big, bail out with a
** simple (but stupid and ugly) result that doesn't take too long. */
mnLen = nLeft<nRight ? nLeft : nRight;
| | | 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 |
memset(aM, 1, nLeft);
return aM;
}
/* This algorithm is O(N**2). So if N is too big, bail out with a
** simple (but stupid and ugly) result that doesn't take too long. */
mnLen = nLeft<nRight ? nLeft : nRight;
if( nLeft*nRight>100000 && (diffFlags & DIFF_SLOW_SBS)==0 ){
memset(aM, 4, mnLen);
if( nLeft>mnLen ) memset(aM+mnLen, 1, nLeft-mnLen);
if( nRight>mnLen ) memset(aM+mnLen, 2, nRight-mnLen);
return aM;
}
if( nRight < count(aBuf)-1 ){
|
| ︙ | ︙ | |||
1323 1324 1325 1326 1327 1328 1329 |
while( i<nr-1 && smallGap(&R[r+i*3]) ){
i++;
m = R[r+i*3];
ma += R[r+i*3+1] + m;
mb += R[r+i*3+2] + m;
}
| | | 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 |
while( i<nr-1 && smallGap(&R[r+i*3]) ){
i++;
m = R[r+i*3];
ma += R[r+i*3+1] + m;
mb += R[r+i*3+2] + m;
}
alignment = sbsAlignment(&A[a], ma, &B[b], mb, diffFlags);
for(j=0; ma+mb>0; j++){
if( alignment[j]==1 ){
/* Delete one line from the left */
sbsWriteLineno(&s, a, SBS_LNA);
s.iStart = 0;
s.zStart = "<span class=\"diffrm\">";
s.iEnd = LENGTH(&A[a]);
|
| ︙ | ︙ | |||
1914 1915 1916 1917 1918 1919 1920 |
}
}
if( (diffFlags & DIFF_NOOPT)==0 ){
diff_optimize(&c);
}
if( pOut ){
| | > > > > > > | | 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 |
}
}
if( (diffFlags & DIFF_NOOPT)==0 ){
diff_optimize(&c);
}
if( pOut ){
if( diffFlags & DIFF_NUMSTAT ){
int nDel = 0, nIns = 0, i;
for(i=0; c.aEdit[i] || c.aEdit[i+1] || c.aEdit[i+2]; i+=3){
nDel += c.aEdit[i+1];
nIns += c.aEdit[i+2];
}
blob_appendf(pOut, "%10d %10d", nIns, nDel);
}else if( diffFlags & DIFF_SIDEBYSIDE ){
sbsDiff(&c, pOut, pRe, diffFlags);
}else{
contextDiff(&c, pOut, pRe, diffFlags);
}
fossil_free(c.aFrom);
fossil_free(c.aTo);
fossil_free(c.aEdit);
|
| ︙ | ︙ | |||
1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 | ** ** --brief Show filenames only DIFF_BRIEF ** -c|--context N N lines of context. DIFF_CONTEXT_MASK ** --html Format for HTML DIFF_HTML ** --invert Invert the diff DIFF_INVERT ** -n|--linenum Show line numbers DIFF_LINENO ** --noopt Disable optimization DIFF_NOOPT ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR ** --unified Unified diff. ~DIFF_SIDEBYSIDE ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS ** -W|--width N N character lines. DIFF_WIDTH_MASK ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS */ | > | 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 | ** ** --brief Show filenames only DIFF_BRIEF ** -c|--context N N lines of context. DIFF_CONTEXT_MASK ** --html Format for HTML DIFF_HTML ** --invert Invert the diff DIFF_INVERT ** -n|--linenum Show line numbers DIFF_LINENO ** --noopt Disable optimization DIFF_NOOPT ** --numstat Show change counts DIFF_NUMSTAT ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR ** --unified Unified diff. ~DIFF_SIDEBYSIDE ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS ** -W|--width N N character lines. DIFF_WIDTH_MASK ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS */ |
| ︙ | ︙ | |||
1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 |
if( find_option("ignore-all-space","w",0)!=0 ){
diffFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_EOLWS */
}
if( find_option("strip-trailing-cr",0,0)!=0 ){
diffFlags |= DIFF_STRIP_EOLCR;
}
if( find_option("side-by-side","y",0)!=0 ) diffFlags |= DIFF_SIDEBYSIDE;
if( find_option("unified",0,0)!=0 ) diffFlags &= ~DIFF_SIDEBYSIDE;
if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>=0 ){
if( f > DIFF_CONTEXT_MASK ) f = DIFF_CONTEXT_MASK;
diffFlags |= f + DIFF_CONTEXT_EX;
}
if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){
f *= DIFF_CONTEXT_MASK+1;
if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
diffFlags |= f;
}
if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
return diffFlags;
}
/*
** COMMAND: test-rawdiff
| > > > > | 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 |
if( find_option("ignore-all-space","w",0)!=0 ){
diffFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_EOLWS */
}
if( find_option("strip-trailing-cr",0,0)!=0 ){
diffFlags |= DIFF_STRIP_EOLCR;
}
if( find_option("side-by-side","y",0)!=0 ) diffFlags |= DIFF_SIDEBYSIDE;
if( find_option("yy",0,0)!=0 ){
diffFlags |= DIFF_SIDEBYSIDE | DIFF_SLOW_SBS;
}
if( find_option("unified",0,0)!=0 ) diffFlags &= ~DIFF_SIDEBYSIDE;
if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>=0 ){
if( f > DIFF_CONTEXT_MASK ) f = DIFF_CONTEXT_MASK;
diffFlags |= f + DIFF_CONTEXT_EX;
}
if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){
f *= DIFF_CONTEXT_MASK+1;
if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
diffFlags |= f;
}
if( find_option("html",0,0)!=0 ) diffFlags |= DIFF_HTML;
if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO;
if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT;
if( find_option("numstat",0,0)!=0 ) diffFlags |= DIFF_NUMSTAT;
if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT;
if( find_option("brief",0,0)!=0 ) diffFlags |= DIFF_BRIEF;
return diffFlags;
}
/*
** COMMAND: test-rawdiff
|
| ︙ | ︙ | |||
2067 2068 2069 2070 2071 2072 2073 |
struct AnnLine { /* Lines of the original files... */
const char *z; /* The text of the line */
short int n; /* Number of bytes (omitting trailing \n) */
short int iVers; /* Level at which tag was set */
} *aOrig;
int nOrig; /* Number of elements in aOrig[] */
int nVers; /* Number of versions analyzed */
| | > > | 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 |
struct AnnLine { /* Lines of the original files... */
const char *z; /* The text of the line */
short int n; /* Number of bytes (omitting trailing \n) */
short int iVers; /* Level at which tag was set */
} *aOrig;
int nOrig; /* Number of elements in aOrig[] */
int nVers; /* Number of versions analyzed */
int bMoreToDo; /* True if the limit was reached */
int origId; /* RID for the zOrigin version */
int showId; /* RID for the version being analyzed */
struct AnnVers {
const char *zFUuid; /* File being analyzed */
const char *zMUuid; /* Check-in containing the file */
const char *zDate; /* Date of the check-in */
const char *zBgColor; /* Suggested background color */
const char *zUser; /* Name of user who did the check-in */
unsigned cnt; /* Number of lines contributed by this check-in */
|
| ︙ | ︙ | |||
2160 2161 2162 2163 2164 2165 2166 | /* Clear out the from file */ free(p->c.aFrom); /* Return no errors */ return 0; } | > > > > > > > > > > > | < < < > | > | | | | | | > | | | > > > | > | > | > | > > > > > | | | > | < > | < | > > > < < < | | > > | > > > > | > > > > > > | | > > > > > > | | | | | | | > | | < < > < < | > > > > > > > > | > > > > > > > > > > | < < < < < < < < | 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 |
/* Clear out the from file */
free(p->c.aFrom);
/* Return no errors */
return 0;
}
/* Return the current time as milliseconds since the Julian epoch */
static sqlite3_int64 current_time_in_milliseconds(void){
static sqlite3_vfs *clockVfs = 0;
sqlite3_int64 t;
if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){
clockVfs->xCurrentTimeInt64(clockVfs, &t);
}else{
double r;
clockVfs->xCurrentTime(clockVfs, &r);
t = (sqlite3_int64)(r*86400000.0);
}
return t;
}
/*
** Compute a complete annotation on a file. The file is identified by its
** filename and check-in name (NULL for current check-in).
*/
static void annotate_file(
Annotator *p, /* The annotator */
const char *zFilename, /* The name of the file to be annotated */
const char *zRevision, /* Use the version of the file in this check-in */
const char *zLimit, /* Limit the number of versions analyzed */
const char *zOrigin, /* The origin check-in, or NULL for root-of-tree */
u64 annFlags /* Flags to alter the annotation */
){
Blob toAnnotate; /* Text of the final (mid) version of the file */
Blob step; /* Text of previous revision */
Blob treename; /* FILENAME translated to canonical form */
int cid; /* Selected check-in ID */
int origid = 0; /* The origin ID or zero */
int rid; /* Artifact ID of the file being annotated */
int fnid; /* Filename ID */
Stmt q; /* Query returning all ancestor versions */
int cnt = 0; /* Number of versions analyzed */
int iLimit; /* Maximum number of versions to analyze */
sqlite3_int64 mxTime; /* Halt at this time if not already complete */
if( zLimit ){
if( strcmp(zLimit,"none")==0 ){
iLimit = 0;
mxTime = 0;
}else if( sqlite3_strglob("*[0-9]s", zLimit)==0 ){
iLimit = 0;
mxTime = current_time_in_milliseconds() + 1000.0*atof(zLimit);
}else{
iLimit = atoi(zLimit);
if( iLimit<=0 ) iLimit = 30;
mxTime = 0;
}
}else{
/* Default limit is as much as we can do in 1.000 seconds */
iLimit = 0;
mxTime = current_time_in_milliseconds()+1000;
}
db_begin_transaction();
/* Get the artificate ID for the check-in begin analyzed */
if( zRevision ){
cid = name_to_typed_rid(zRevision, "ci");
}else{
db_must_be_within_tree();
cid = db_lget_int("checkout", 0);
}
origid = zOrigin ? name_to_typed_rid(zOrigin, "ci") : 0;
/* Compute all direct ancestors of the check-in being analyzed into
** the "ancestor" table. */
if( origid ){
path_shortest_stored_in_ancestor_table(origid, cid);
}else{
compute_direct_ancestors(cid);
}
/* Get filename ID */
file_tree_name(zFilename, &treename, 0, 1);
zFilename = blob_str(&treename);
fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
db_prepare(&q,
"SELECT DISTINCT"
" (SELECT uuid FROM blob WHERE rid=mlink.fid),"
" (SELECT uuid FROM blob WHERE rid=mlink.mid),"
" date(event.mtime),"
" coalesce(event.euser,event.user),"
" mlink.fid"
" FROM mlink, event, ancestor"
" WHERE mlink.fnid=%d"
" AND ancestor.rid=mlink.mid"
" AND event.objid=mlink.mid"
" AND mlink.mid!=mlink.pid"
" ORDER BY ancestor.generation;",
fnid
);
while( db_step(&q)==SQLITE_ROW ){
if( cnt>=3 ){ /* Process at least 3 rows before imposing limits */
if( (iLimit>0 && cnt>=iLimit)
|| (cnt>0 && mxTime>0 && current_time_in_milliseconds()>mxTime)
){
p->bMoreToDo = 1;
break;
}
}
rid = db_column_int(&q, 4);
if( cnt==0 ){
if( !content_get(rid, &toAnnotate) ){
fossil_fatal("unable to retrieve content of artifact #%d", rid);
}
blob_to_utf8_no_bom(&toAnnotate, 0);
annotation_start(p, &toAnnotate, annFlags);
p->bMoreToDo = origid!=0;
p->origId = origid;
p->showId = cid;
}
p->aVers = fossil_realloc(p->aVers, (p->nVers+1)*sizeof(p->aVers[0]));
p->aVers[p->nVers].zFUuid = fossil_strdup(db_column_text(&q, 0));
p->aVers[p->nVers].zMUuid = fossil_strdup(db_column_text(&q, 1));
p->aVers[p->nVers].zDate = fossil_strdup(db_column_text(&q, 2));
p->aVers[p->nVers].zUser = fossil_strdup(db_column_text(&q, 3));
if( cnt>0 ){
content_get(rid, &step);
blob_to_utf8_no_bom(&step, 0);
annotation_step(p, &step, p->nVers-1, annFlags);
blob_reset(&step);
}
p->nVers++;
cnt++;
}
db_finalize(&q);
db_end_transaction(0);
}
/*
** Return a color from a gradient.
*/
unsigned gradient_color(unsigned c1, unsigned c2, int n, int i){
|
| ︙ | ︙ | |||
2279 2280 2281 2282 2283 2284 2285 2286 2287 | ** URL: /blame?checkin=ID&filename=FILENAME ** URL: /praise?checkin=ID&filename=FILENAME ** ** Show the most recent change to each line of a text file. /annotate shows ** the date of the changes and the check-in hash (with a link to the ** check-in). /blame and /praise also show the user who made the check-in. ** ** Query parameters: ** | > > > > > > > > | | > | > > > > > | > < < | | | > | > > > > < < > | < | > | | < < | < < | | | > < | < < < | < < < | < | < | < | < < < < < < < > | > > | > | | | | | | | < < < < < < < < < < < | < < < | | > > > > > > > > | | > | > > > > > | > | > | | | > | | | | | | > | | > > > > > > > > > > > > > | > > > < < < < < | | | | | | | | | > > < | < < < < < | < < < < < < < < < < < < < < < < < | | > | < > | > < | | 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 |
** URL: /blame?checkin=ID&filename=FILENAME
** URL: /praise?checkin=ID&filename=FILENAME
**
** Show the most recent change to each line of a text file. /annotate shows
** the date of the changes and the check-in hash (with a link to the
** check-in). /blame and /praise also show the user who made the check-in.
**
** Reverse Annotations: Normally, these web pages look at versions of
** FILENAME moving backwards in time back toward the root check-in. However,
** if the origin= query parameter is used to specify some future check-in
** (example: "origin=trunk") then these pages show changes moving towards
** that alternative origin. Thus using "origin=trunk" on an historical
** version of the file shows the first time each line in the file was been
** changed in subsequent check-ins.
**
** Query parameters:
**
** checkin=ID The check-in at which to start the annotation
** filename=FILENAME The filename.
** filevers=BOOLEAN Show file versions rather than check-in versions
** limit=LIMIT Limit the amount of analysis:
** "none" No limit
** "Xs" As much as can be computed in X seconds
** "N" N versions
** log=BOOLEAN Show a log of versions analyzed
** origin=ID The origin checkin. If unspecified, the root
** check-in over the entire repository is used.
** Specify "origin=trunk" or similar for a reverse
** annotation
** w=BOOLEAN Ignore whitespace
**
*/
void annotation_page(void){
int i;
const char *zLimit; /* Depth limit */
u64 annFlags = DIFF_STRIP_EOLCR;
int showLog; /* True to display the log */
int fileVers; /* Show file version instead of check-in versions */
int ignoreWs; /* Ignore whitespace */
const char *zFilename; /* Name of file to annotate */
const char *zRevision; /* Name of check-in from which to start annotation */
const char *zCI; /* The check-in containing zFilename */
const char *zOrigin; /* The origin of the analysis */
int szHash; /* Number of characters in %S display */
char *zLink;
Annotator ann;
HQuery url;
struct AnnVers *p;
unsigned clr1, clr2, clr;
int bBlame = g.zPath[0]!='a';/* True for BLAME output. False for ANNOTATE. */
/* Gather query parameters */
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
if( exclude_spiders() ) return;
load_control();
zFilename = P("filename");
zRevision = PD("checkin",0);
zOrigin = P("origin");
zLimit = P("limit");
showLog = PB("log");
fileVers = PB("filevers");
ignoreWs = PB("w");
if( ignoreWs ) annFlags |= DIFF_IGNORE_ALLWS;
/* compute the annotation */
annotate_file(&ann, zFilename, zRevision, zLimit, zOrigin, annFlags);
zCI = ann.aVers[0].zMUuid;
/* generate the web page */
style_header("Annotation For %h", zFilename);
if( bBlame ){
url_initialize(&url, "blame");
}else{
url_initialize(&url, "annotate");
}
url_add_parameter(&url, "checkin", P("checkin"));
url_add_parameter(&url, "filename", zFilename);
if( zLimit ){
url_add_parameter(&url, "limit", zLimit);
}
url_add_parameter(&url, "w", ignoreWs ? "1" : "0");
url_add_parameter(&url, "log", showLog ? "1" : "0");
url_add_parameter(&url, "filevers", fileVers ? "1" : "0");
style_submenu_checkbox("w", "Ignore Whitespace", 0, 0);
style_submenu_checkbox("log", "Log", 0, "toggle_annotation_log()");
style_submenu_checkbox("filevers", "Link to Files", 0, 0);
if( ann.bMoreToDo ){
style_submenu_element("All Ancestors", "%s",
url_render(&url, "limit", "none", 0, 0));
}
if( skin_detail_boolean("white-foreground") ){
clr1 = 0xa04040;
clr2 = 0x4059a0;
}else{
clr1 = 0xffb5b5; /* Recent changes: red (hot) */
clr2 = 0xb5e0ff; /* Older changes: blue (cold) */
}
for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){
clr = gradient_color(clr1, clr2, ann.nVers-1, i);
ann.aVers[i].zBgColor = mprintf("#%06x", clr);
}
@ <div id="annotation_log" style='display:%s(showLog?"block":"none");'>
if( zOrigin ){
zLink = href("%R/finfo?name=%t&ci=%!S&orig=%!S",zFilename,zCI,zOrigin);
}else{
zLink = href("%R/finfo?name=%t&ci=%!S",zFilename,zCI);
}
@ <h2>Versions of %z(zLink)%h(zFilename)</a> analyzed:</h2>
@ <ol>
for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){
@ <li><span style='background-color:%s(p->zBgColor);'>%s(p->zDate)
@ check-in %z(href("%R/info/%!S",p->zMUuid))%S(p->zMUuid)</a>
@ artifact %z(href("%R/artifact/%!S",p->zFUuid))%S(p->zFUuid)</a>
@ </span>
}
@ </ol>
@ <hr />
@ </div>
@ <script>
@ function toggle_annotation_log(){
@ var w = gebi("annotation_log");
@ var x = document.forms["f01"].elements["log"].checked
@ w.style.display = x ? "block" : "none";
@ }
@ </script>
if( !ann.bMoreToDo ){
assert( ann.origId==0 ); /* bMoreToDo always set for a point-to-point */
@ <h2>Origin for each line in
@ %z(href("%R/finfo?name=%h&ci=%!S", zFilename, zCI))%h(zFilename)</a>
@ from check-in %z(href("%R/info/%!S",zCI))%S(zCI)</a>:</h2>
}else if( ann.origId>0 ){
@ <h2>Lines of
@ %z(href("%R/finfo?name=%h&ci=%!S", zFilename, zCI))%h(zFilename)</a>
@ from check-in %z(href("%R/info/%!S",zCI))%S(zCI)</a>
@ that are changed by the sequence of edits moving toward
@ check-in %z(href("%R/info/%!S",zOrigin))%S(zOrigin)</a>:</h2>
}else{
@ <h2>Lines added by the %d(ann.nVers) most recent ancestors of
@ %z(href("%R/finfo?name=%h&ci=%!S", zFilename, zCI))%h(zFilename)</a>
@ from check-in %z(href("%R/info/%!S",zCI))%S(zCI)</a>:</h2>
}
@ <pre>
szHash = 10;
for(i=0; i<ann.nOrig; i++){
int iVers = ann.aOrig[i].iVers;
char *z = (char*)ann.aOrig[i].z;
int n = ann.aOrig[i].n;
char zPrefix[300];
z[n] = 0;
if( iVers<0 && !ann.bMoreToDo ) iVers = ann.nVers-1;
if( bBlame ){
if( iVers>=0 ){
struct AnnVers *p = ann.aVers+iVers;
const char *zUuid = fileVers ? p->zFUuid : p->zMUuid;
char *zLink = xhref("target='infowindow'", "%R/info/%!S", zUuid);
sqlite3_snprintf(sizeof(zPrefix), zPrefix,
"<span style='background-color:%s'>"
"%s%.10s</a> %s</span> %13.13s:",
p->zBgColor, zLink, zUuid, p->zDate, p->zUser);
fossil_free(zLink);
}else{
sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%*s", szHash+26, "");
}
}else{
if( iVers>=0 ){
struct AnnVers *p = ann.aVers+iVers;
const char *zUuid = fileVers ? p->zFUuid : p->zMUuid;
char *zLink = xhref("target='infowindow'", "%R/info/%!S", zUuid);
sqlite3_snprintf(sizeof(zPrefix), zPrefix,
"<span style='background-color:%s'>"
"%s%.10s</a> %s</span> %4d:",
p->zBgColor, zLink, zUuid, p->zDate, i+1);
fossil_free(zLink);
}else{
sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%*s%4d:",szHash+12,"",i+1);
}
}
@ %s(zPrefix) %h(z)
}
@ </pre>
style_footer();
}
/*
** COMMAND: annotate
** COMMAND: blame
** COMMAND: praise
**
** Usage: %fossil annotate|blame|praise ?OPTIONS? FILENAME
**
** Output the text of a file with markings to show when each line of the file
** was last modified. The version currently checked out is shown by default.
** Other versions may be specified using the -r option. The "annotate" command
** shows line numbers and omits the username. The "blame" and "praise" commands
** show the user who made each check-in.
**
** Reverse Annotations: Normally, these commands look at versions of
** FILENAME moving backwards in time back toward the root check-in, and
** thus the output shows the most recent change to each line. However,
** if the -o|--origin option is used to specify some future check-in
** (example: "-o trunk") then these commands show changes moving towards
** that alternative origin. Thus using "-o trunk" on an historical version
** of the file shows the first time each line in the file was been changed
** by subsequent check-ins.
**
** Options:
** --filevers Show file version numbers rather than
** check-in versions
** -r|--revision VERSION The specific check-in containing the file
** -l|--log List all versions analyzed
** -n|--limit LIMIT Limit the amount of analysis:
** N Up to N versions
** Xs As much as possible in X seconds
** none No limit
** -o|--origin VERSION The origin check-in. By default this is the
** root of the repository. Set to "trunk" or
** similar for a reverse annotation.
** -w|--ignore-all-space Ignore white space when comparing lines
** -Z|--ignore-trailing-space Ignore whitespace at line end
**
** See also: info, finfo, timeline
*/
void annotate_cmd(void){
const char *zRevision; /* Revision name, or NULL for current check-in */
Annotator ann; /* The annotation of the file */
int i; /* Loop counter */
const char *zLimit; /* The value to the -n|--limit option */
const char *zOrig; /* The value for -o|--origin */
int showLog; /* True to show the log */
int fileVers; /* Show file version instead of check-in versions */
u64 annFlags = 0; /* Flags to control annotation properties */
int bBlame = 0; /* True for BLAME output. False for ANNOTATE. */
int szHash; /* Display size of a version hash */
bBlame = g.argv[1][0]!='a';
zRevision = find_option("r","revision",1);
zLimit = find_option("limit","n",1);
zOrig = find_option("origin","o",1);
showLog = find_option("log","l",0)!=0;
if( find_option("ignore-trailing-space","Z",0)!=0 ){
annFlags = DIFF_IGNORE_EOLWS;
}
if( find_option("ignore-all-space","w",0)!=0 ){
annFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_EOLWS */
}
fileVers = find_option("filevers",0,0)!=0;
db_must_be_within_tree();
/* We should be done with options.. */
verify_all_options();
if( g.argc<3 ) {
usage("FILENAME");
}
annFlags |= DIFF_STRIP_EOLCR;
annotate_file(&ann, g.argv[2], zRevision, zLimit, zOrig, annFlags);
if( showLog ){
struct AnnVers *p;
for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){
fossil_print("version %3d: %s %S file %S\n",
i+1, p->zDate, p->zMUuid, p->zFUuid);
}
fossil_print("---------------------------------------------------\n");
}
szHash = length_of_S_display();
for(i=0; i<ann.nOrig; i++){
int iVers = ann.aOrig[i].iVers;
char *z = (char*)ann.aOrig[i].z;
int n = ann.aOrig[i].n;
struct AnnVers *p;
if( iVers<0 && !ann.bMoreToDo ) iVers = ann.nVers-1;
if( bBlame ){
if( iVers>=0 ){
p = ann.aVers + iVers;
fossil_print("%S %s %13.13s: %.*s\n",
fileVers ? p->zFUuid : p->zMUuid, p->zDate, p->zUser, n, z);
}else{
fossil_print("%*s %.*s\n", szHash+26, "", n, z);
}
}else{
if( iVers>=0 ){
p = ann.aVers + iVers;
fossil_print("%S %s %5d: %.*s\n",
fileVers ? p->zFUuid : p->zMUuid, p->zDate, i+1, n, z);
}else{
fossil_print("%*s %5d: %.*s\n", szHash+11, "", i+1, n, z);
}
}
}
}
|
Changes to src/diffcmd.c.
| ︙ | ︙ | |||
105 106 107 108 109 110 111 |
return 0;
}
/*
** Print the "Index:" message that patches wants to see at the top of a diff.
*/
void diff_print_index(const char *zFile, u64 diffFlags){
| | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
return 0;
}
/*
** Print the "Index:" message that patches wants to see at the top of a diff.
*/
void diff_print_index(const char *zFile, u64 diffFlags){
if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF|DIFF_NUMSTAT))==0 ){
char *z = mprintf("Index: %s\n%.66c\n", zFile, '=');
fossil_print("%s", z);
fossil_free(z);
}
}
/*
|
| ︙ | ︙ | |||
202 203 204 205 206 207 208 |
blob_zero(&out);
if( fSwapDiff ){
text_diff(&file2, pFile1, &out, 0, diffFlags);
}else{
text_diff(pFile1, &file2, &out, 0, diffFlags);
}
if( blob_size(&out) ){
| > > > | | > | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
blob_zero(&out);
if( fSwapDiff ){
text_diff(&file2, pFile1, &out, 0, diffFlags);
}else{
text_diff(pFile1, &file2, &out, 0, diffFlags);
}
if( blob_size(&out) ){
if( diffFlags & DIFF_NUMSTAT ){
fossil_print("%s %s\n", blob_str(&out), zName);
}else{
diff_print_filenames(zName, zName2, diffFlags);
fossil_print("%s\n", blob_str(&out));
}
}
blob_reset(&out);
}
/* Release memory resources */
blob_reset(&file2);
}else{
|
| ︙ | ︙ | |||
257 258 259 260 261 262 263 |
blob_reset(&nameFile1);
blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++);
}while( file_access(blob_str(&nameFile1),F_OK)==0 );
blob_write_to_file(pFile1, blob_str(&nameFile1));
/* Construct the external diff command */
blob_zero(&cmd);
| | | < | | < | | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
blob_reset(&nameFile1);
blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++);
}while( file_access(blob_str(&nameFile1),F_OK)==0 );
blob_write_to_file(pFile1, blob_str(&nameFile1));
/* Construct the external diff command */
blob_zero(&cmd);
blob_append(&cmd, zDiffCmd, -1);
if( fSwapDiff ){
blob_append_escaped_arg(&cmd, zFile2);
blob_append_escaped_arg(&cmd, blob_str(&nameFile1));
}else{
blob_append_escaped_arg(&cmd, blob_str(&nameFile1));
blob_append_escaped_arg(&cmd, zFile2);
}
/* Run the external diff command */
fossil_system(blob_str(&cmd));
/* Delete the temporary file and clean up memory used */
file_delete(blob_str(&nameFile1));
|
| ︙ | ︙ | |||
308 309 310 311 312 313 314 |
){
if( diffFlags & DIFF_BRIEF ) return;
if( zDiffCmd==0 ){
Blob out; /* Diff output text */
blob_zero(&out);
text_diff(pFile1, pFile2, &out, 0, diffFlags);
| > > > | | > | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
){
if( diffFlags & DIFF_BRIEF ) return;
if( zDiffCmd==0 ){
Blob out; /* Diff output text */
blob_zero(&out);
text_diff(pFile1, pFile2, &out, 0, diffFlags);
if( diffFlags & DIFF_NUMSTAT ){
fossil_print("%s %s\n", blob_str(&out), zName);
}else{
diff_print_filenames(zName, zName, diffFlags);
fossil_print("%s\n", blob_str(&out));
}
/* Release memory resources */
blob_reset(&out);
}else{
Blob cmd;
Blob temp1;
Blob temp2;
|
| ︙ | ︙ | |||
350 351 352 353 354 355 356 |
file_tempname(&temp1, blob_str(&prefix1));
file_tempname(&temp2, blob_str(&prefix2));
blob_write_to_file(pFile1, blob_str(&temp1));
blob_write_to_file(pFile2, blob_str(&temp2));
/* Construct the external diff command */
blob_zero(&cmd);
| < < | > | | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
file_tempname(&temp1, blob_str(&prefix1));
file_tempname(&temp2, blob_str(&prefix2));
blob_write_to_file(pFile1, blob_str(&temp1));
blob_write_to_file(pFile2, blob_str(&temp2));
/* Construct the external diff command */
blob_zero(&cmd);
blob_append(&cmd, zDiffCmd, -1);
blob_append_escaped_arg(&cmd, blob_str(&temp1));
blob_append_escaped_arg(&cmd, blob_str(&temp2));
/* Run the external diff command */
fossil_system(blob_str(&cmd));
/* Delete the temporary file and clean up memory used */
file_delete(blob_str(&temp1));
file_delete(blob_str(&temp2));
|
| ︙ | ︙ | |||
394 395 396 397 398 399 400 401 |
u64 diffFlags, /* Flags controlling diff output */
FileDirList *pFileDir /* Which files to diff */
){
int vid;
Blob sql;
Stmt q;
int asNewFile; /* Treat non-existant files as empty files */
| > | > | 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
u64 diffFlags, /* Flags controlling diff output */
FileDirList *pFileDir /* Which files to diff */
){
int vid;
Blob sql;
Stmt q;
int asNewFile; /* Treat non-existant files as empty files */
int isNumStat; /* True for --numstat */
asNewFile = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT))!=0;
isNumStat = (diffFlags & DIFF_NUMSTAT)!=0;
vid = db_lget_int("checkout", 0);
vfile_check_signature(vid, CKSIG_ENOTFILE);
blob_zero(&sql);
db_begin_transaction();
if( zFrom ){
int rid = name_to_typed_rid(zFrom, "ci");
if( !is_a_version(rid) ){
|
| ︙ | ︙ | |||
459 460 461 462 463 464 465 |
file_relative_name(zPathname, &fname, 1);
}else{
blob_set(&fname, g.zLocalRoot);
blob_append(&fname, zPathname, -1);
}
zFullName = blob_str(&fname);
if( isDeleted ){
| | | | | | | 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
file_relative_name(zPathname, &fname, 1);
}else{
blob_set(&fname, g.zLocalRoot);
blob_append(&fname, zPathname, -1);
}
zFullName = blob_str(&fname);
if( isDeleted ){
if( !isNumStat ){ fossil_print("DELETED %s\n", zPathname); }
if( !asNewFile ){ showDiff = 0; zFullName = NULL_DEVICE; }
}else if( file_access(zFullName, F_OK) ){
if( !isNumStat ){ fossil_print("MISSING %s\n", zPathname); }
if( !asNewFile ){ showDiff = 0; }
}else if( isNew ){
if( !isNumStat ){ fossil_print("ADDED %s\n", zPathname); }
srcid = 0;
if( !asNewFile ){ showDiff = 0; }
}else if( isChnged==3 ){
if( !isNumStat ){ fossil_print("ADDED_BY_MERGE %s\n", zPathname); }
srcid = 0;
if( !asNewFile ){ showDiff = 0; }
}else if( isChnged==5 ){
if( !isNumStat ){ fossil_print("ADDED_BY_INTEGRATE %s\n", zPathname); }
srcid = 0;
if( !asNewFile ){ showDiff = 0; }
}
if( showDiff ){
Blob content;
int isBin;
if( !isLink != !file_wd_islink(zFullName) ){
|
| ︙ | ︙ | |||
611 612 613 614 615 616 617 |
const char *zBinGlob,
int fIncludeBinary,
u64 diffFlags,
FileDirList *pFileDir
){
Manifest *pFrom, *pTo;
ManifestFile *pFromFile, *pToFile;
| | > | > > | > | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
const char *zBinGlob,
int fIncludeBinary,
u64 diffFlags,
FileDirList *pFileDir
){
Manifest *pFrom, *pTo;
ManifestFile *pFromFile, *pToFile;
int asNewFlag = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT))!=0 ? 1 : 0;
pFrom = manifest_get_by_name(zFrom, 0);
manifest_file_rewind(pFrom);
pFromFile = manifest_file_next(pFrom,0);
pTo = manifest_get_by_name(zTo, 0);
manifest_file_rewind(pTo);
pToFile = manifest_file_next(pTo,0);
while( pFromFile || pToFile ){
int cmp;
if( pFromFile==0 ){
cmp = +1;
}else if( pToFile==0 ){
cmp = -1;
}else{
cmp = fossil_strcmp(pFromFile->zName, pToFile->zName);
}
if( cmp<0 ){
if( file_dir_match(pFileDir, pFromFile->zName) ){
if( (diffFlags & DIFF_NUMSTAT)==0 ){
fossil_print("DELETED %s\n", pFromFile->zName);
}
if( asNewFlag ){
diff_manifest_entry(pFromFile, 0, zDiffCmd, zBinGlob,
fIncludeBinary, diffFlags);
}
}
pFromFile = manifest_file_next(pFrom,0);
}else if( cmp>0 ){
if( file_dir_match(pFileDir, pToFile->zName) ){
if( (diffFlags & DIFF_NUMSTAT)==0 ){
fossil_print("ADDED %s\n", pToFile->zName);
}
if( asNewFlag ){
diff_manifest_entry(0, pToFile, zDiffCmd, zBinGlob,
fIncludeBinary, diffFlags);
}
}
pToFile = manifest_file_next(pTo,0);
}else if( fossil_strcmp(pFromFile->zUuid, pToFile->zUuid)==0 ){
|
| ︙ | ︙ | |||
831 832 833 834 835 836 837 838 839 840 841 842 843 844 | ** --command PROG External diff program - overrides "diff-command" ** --context|-c N Use N lines of context ** --diff-binary BOOL Include binary files when using external commands ** --exec-abs-paths Force absolute path names with external commands. ** --exec-rel-paths Force relative path names with external commands. ** --from|-r VERSION Select VERSION as source for the diff ** --internal|-i Use internal diff logic ** --side-by-side|-y Side-by-side diff ** --strip-trailing-cr Strip trailing CR ** --tk Launch a Tcl/Tk GUI for display ** --to VERSION Select VERSION as target for the diff ** --undo Diff against the "undo" buffer ** --unified Unified diff ** -v|--verbose Output complete text of added or deleted files | > | 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 | ** --command PROG External diff program - overrides "diff-command" ** --context|-c N Use N lines of context ** --diff-binary BOOL Include binary files when using external commands ** --exec-abs-paths Force absolute path names with external commands. ** --exec-rel-paths Force relative path names with external commands. ** --from|-r VERSION Select VERSION as source for the diff ** --internal|-i Use internal diff logic ** --numstat Show only the number of lines delete and added ** --side-by-side|-y Side-by-side diff ** --strip-trailing-cr Strip trailing CR ** --tk Launch a Tcl/Tk GUI for display ** --to VERSION Select VERSION as target for the diff ** --undo Diff against the "undo" buffer ** --unified Unified diff ** -v|--verbose Output complete text of added or deleted files |
| ︙ | ︙ |
Changes to src/dispatch.c.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 | ** that implement those commands and web pages and their associated help ** text. */ #include "config.h" #include <assert.h> #include "dispatch.h" | < | | | | | | | > > > > | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
** that implement those commands and web pages and their associated help
** text.
*/
#include "config.h"
#include <assert.h>
#include "dispatch.h"
#if INTERFACE
/*
** An instance of this object defines everything we need to know about an
** individual command, webpage, or setting.
*/
struct CmdOrPage {
const char *zName; /* Name. Webpages start with "/". Commands do not */
void (*xFunc)(void); /* Implementation function, or NULL for settings */
const char *zHelp; /* Raw help text */
unsigned int eCmdFlags; /* Flags */
};
/***************************************************************************
** These macros must match similar macros in mkindex.c
** Allowed values for CmdOrPage.eCmdFlags.
*/
#define CMDFLAG_1ST_TIER 0x0001 /* Most important commands */
#define CMDFLAG_2ND_TIER 0x0002 /* Obscure and seldom used commands */
#define CMDFLAG_TEST 0x0004 /* Commands for testing only */
#define CMDFLAG_WEBPAGE 0x0008 /* Web pages */
#define CMDFLAG_COMMAND 0x0010 /* A command */
#define CMDFLAG_SETTING 0x0020 /* A setting */
#define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
#define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
#define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
/**************************************************************************/
/* Values for the 2nd parameter to dispatch_name_search() */
#define CMDFLAG_ANY 0x0038 /* Match anything */
#define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
#endif /* INTERFACE */
/*
** The page_index.h file contains the definition for aCommand[] - an array
** of CmdOrPage objects that defines all available commands and webpages
** known to Fossil.
|
| ︙ | ︙ | |||
70 71 72 73 74 75 76 | ** source code files looking for header comments on the functions that ** implement command and webpages. */ #include "page_index.h" #define MX_COMMAND count(aCommand) /* | | | | | | > > > > | > > | | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
** source code files looking for header comments on the functions that
** implement command and webpages.
*/
#include "page_index.h"
#define MX_COMMAND count(aCommand)
/*
** Given a command, webpage, or setting name in zName, find the corresponding
** CmdOrPage object and return a pointer to that object in *ppCmd.
**
** The eType field is CMDFLAG_COMMAND to look up commands, CMDFLAG_WEBPAGE to
** look up webpages, CMDFLAG_SETTING to look up settings, or CMDFLAG_ANY to look
** for any. If the CMDFLAG_PREFIX bit is set, then a prefix match is allowed.
**
** Return values:
** 0: Success. *ppCmd is set to the appropriate CmdOrPage
** 1: Not found.
** 2: Ambiguous. Two or more entries match.
*/
int dispatch_name_search(
const char *zName, /* Look for this name */
unsigned eType, /* CMDFLAGS_* bits */
const CmdOrPage **ppCmd /* Write the matching CmdOrPage object here */
){
int upr, lwr, mid;
int nName = strlen(zName);
lwr = 0;
upr = MX_COMMAND - 1;
while( lwr<=upr ){
int c;
mid = (upr+lwr)/2;
c = strcmp(zName, aCommand[mid].zName);
if( c==0 ){
if( (aCommand[mid].eCmdFlags & eType)==0 ) return 1;
*ppCmd = &aCommand[mid];
return 0; /* An exact match */
}else if( c<0 ){
upr = mid - 1;
}else{
lwr = mid + 1;
}
}
if( (eType & CMDFLAG_PREFIX)!=0
&& lwr<MX_COMMAND
&& strncmp(zName, aCommand[lwr].zName, nName)==0
){
/* An inexact prefix match was found. Scan the name table to try to find
* exactly one entry with this prefix and the requested type. */
for( mid=-1; lwr<MX_COMMAND
&& strncmp(zName, aCommand[lwr].zName, nName)==0; ++lwr ){
if( aCommand[lwr].eCmdFlags & eType ){
if( mid<0 ){
mid = lwr; /* Potential ambiguous prefix */
}else{
return 2; /* Confirmed ambiguous prefix */
}
}
}
if( mid>=0 ){
*ppCmd = &aCommand[mid];
return 0; /* Prefix match */
}
}
return 1; /* Not found */
}
/*
** zName is the name of a webpage (eType==CMDFLAGS_WEBPAGE) that does not
** exist in the dispatch table. Check to see if this webpage name exists
** as an alias in the CONFIG table of the repository. If it is, then make
** appropriate changes to the CGI environment and set *ppCmd to point to the
** aliased command.
**
** Return 0 if the command is successfully aliased. Return 1 if there
** is not alias for zName. Any kind of error in the alias value causes a
** error to be thrown.
**
** Alias entries in the CONFIG table have a "name" value of "walias:NAME"
** where NAME is the input page name. The value is a string of the form
** "NEWNAME?QUERYPARAMS". The ?QUERYPARAMS is optional. If present (and it
** usually is), then all query parameters are added to the CGI environment.
** Except, query parameters of the form "X!" cause any CGI X variable to be
** removed.
*/
int dispatch_alias(const char *zName, const CmdOrPage **ppCmd){
char *z;
char *zQ;
int i;
z = db_text(0, "SELECT value FROM config WHERE name='walias:%q'",zName);
if( z==0 ) return 1;
for(i=0; z[i] && z[i]!='?'; i++){}
if( z[i]=='?' ){
z[i] = 0;
zQ = &z[i+1];
}else{
zQ = &z[i];
}
if( dispatch_name_search(z, CMDFLAG_WEBPAGE, ppCmd) ){
fossil_fatal("\"%s\" aliased to \"%s\" but \"%s\" does not exist",
zName, z, z);
}
z = zQ;
while( *z ){
char *zName = z;
char *zValue = 0;
while( *z && *z!='=' && *z!='&' && *z!='!' ){ z++; }
if( *z=='=' ){
*z = 0;
z++;
zValue = z;
while( *z && *z!='&' ){ z++; }
if( *z ){
*z = 0;
z++;
}
dehttpize(zValue);
}else if( *z=='!' ){
*(z++) = 0;
cgi_delete_query_parameter(zName);
zName = "";
}else{
if( *z ){ *z++ = 0; }
zValue = "";
}
if( fossil_islower(zName[0]) ){
cgi_replace_query_parameter(zName, zValue);
}
}
return 0;
}
/*
** Fill Blob with a space-separated list of all command names that
** match the prefix zPrefix.
*/
void dispatch_matching_names(const char *zPrefix, Blob *pList){
int i;
|
| ︙ | ︙ | |||
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
** Defaults to just the CLI commands. Specify --www to see only the
** web pages, or --everything to see both commands and pages.
**
** Options:
** -e|--everything Show all commands and pages.
** -t|--test Include test- commands
** -w|--www Show WWW pages.
** -h|--html Transform output to HTML.
*/
void test_all_help_cmd(void){
int i;
int mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER;
int useHtml = find_option("html","h",0)!=0;
if( find_option("www","w",0) ){
mask = CMDFLAG_WEBPAGE;
}
if( find_option("everything","e",0) ){
mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE;
}
if( find_option("test","t",0) ){
mask |= CMDFLAG_TEST;
}
if( useHtml ) fossil_print("<!--\n");
fossil_print("Help text for:\n");
if( mask & CMDFLAG_1ST_TIER ) fossil_print(" * Commands\n");
if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
if( useHtml ){
fossil_print("-->\n");
fossil_print("<!-- start_all_help -->\n");
}else{
fossil_print("---\n");
}
for(i=0; i<MX_COMMAND; i++){
| > > > > > | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
** Defaults to just the CLI commands. Specify --www to see only the
** web pages, or --everything to see both commands and pages.
**
** Options:
** -e|--everything Show all commands and pages.
** -t|--test Include test- commands
** -w|--www Show WWW pages.
** -s|--settings Show settings.
** -h|--html Transform output to HTML.
*/
void test_all_help_cmd(void){
int i;
int mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER;
int useHtml = find_option("html","h",0)!=0;
if( find_option("www","w",0) ){
mask = CMDFLAG_WEBPAGE;
}
if( find_option("everything","e",0) ){
mask = CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER | CMDFLAG_WEBPAGE;
}
if( find_option("settings","s",0) ){
mask = CMDFLAG_SETTING;
}
if( find_option("test","t",0) ){
mask |= CMDFLAG_TEST;
}
if( useHtml ) fossil_print("<!--\n");
fossil_print("Help text for:\n");
if( mask & CMDFLAG_1ST_TIER ) fossil_print(" * Commands\n");
if( mask & CMDFLAG_2ND_TIER ) fossil_print(" * Auxiliary commands\n");
if( mask & CMDFLAG_TEST ) fossil_print(" * Test commands\n");
if( mask & CMDFLAG_WEBPAGE ) fossil_print(" * Web pages\n");
if( mask & CMDFLAG_SETTING ) fossil_print(" * Settings\n");
if( useHtml ){
fossil_print("-->\n");
fossil_print("<!-- start_all_help -->\n");
}else{
fossil_print("---\n");
}
for(i=0; i<MX_COMMAND; i++){
|
| ︙ | ︙ | |||
225 226 227 228 229 230 231 | } /* ** WEBPAGE: help ** URL: /help?name=CMD ** ** Show the built-in help text for CMD. CMD can be a command-line interface | | > | > > | < | | | | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
}
/*
** WEBPAGE: help
** URL: /help?name=CMD
**
** Show the built-in help text for CMD. CMD can be a command-line interface
** command or a page name from the web interface or a setting.
*/
void help_page(void){
const char *zCmd = P("cmd");
if( zCmd==0 ) zCmd = P("name");
if( zCmd && *zCmd ){
int rc;
const CmdOrPage *pCmd = 0;
style_header("Help: %s", zCmd);
style_submenu_element("Command-List", "%s/help", g.zTop);
rc = dispatch_name_search(zCmd, CMDFLAG_ANY, &pCmd);
if( *zCmd=='/' ){
/* Some of the webpages require query parameters in order to work.
** @ <h1>The "<a href='%R%s(zCmd)'>%s(zCmd)</a>" page:</h1> */
@ <h1>The "%h(zCmd)" page:</h1>
}else if( rc==0 && (pCmd->eCmdFlags & CMDFLAG_SETTING)!=0 ){
@ <h1>The "%h(pCmd->zName)" setting:</h1>
}else{
@ <h1>The "%h(zCmd)" command:</h1>
}
if( rc==1 ){
@ unknown command: %h(zCmd)
}else if( rc==2 ){
@ ambiguous command prefix: %h(zCmd)
}else{
if( pCmd->zHelp[0]==0 ){
@ No help available for "%h(pCmd->zName)"
}else{
@ <blockquote>
help_to_html(pCmd->zHelp, cgi_output_blob());
@ </blockquote>
}
}
}else{
|
| ︙ | ︙ | |||
335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
}
n = (j+3)/4;
for(i=j=0; i<MX_COMMAND; i++){
const char *z = aCommand[i].zName;
if( strncmp(z,"test",4)!=0 ) continue;
if( j==0 ){
@ <td valign="top"><ul>
}
if( aCommand[i].zHelp[0] ){
@ <li><a href="%R/help?cmd=%s(z)">%s(z)</a></li>
}else{
@ <li>%s(z)</li>
}
j++;
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
}
n = (j+3)/4;
for(i=j=0; i<MX_COMMAND; i++){
const char *z = aCommand[i].zName;
if( strncmp(z,"test",4)!=0 ) continue;
if( j==0 ){
@ <td valign="top"><ul>
}
if( aCommand[i].zHelp[0] ){
@ <li><a href="%R/help?cmd=%s(z)">%s(z)</a></li>
}else{
@ <li>%s(z)</li>
}
j++;
if( j>=n ){
@ </ul></td>
j = 0;
}
}
if( j>0 ){
@ </ul></td>
}
@ </tr></table>
@ <h1>Settings:</h1>
@ <table border="0"><tr>
for(i=j=0; i<MX_COMMAND; i++){
if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)==0 ) continue;
j++;
}
n = (j+4)/5;
for(i=j=0; i<MX_COMMAND; i++){
const char *z = aCommand[i].zName;
if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)==0 ) continue;
if( j==0 ){
@ <td valign="top"><ul>
}
if( aCommand[i].zHelp[0] ){
@ <li><a href="%R/help?cmd=%s(z)">%s(z)</a></li>
}else{
@ <li>%s(z)</li>
}
j++;
|
| ︙ | ︙ | |||
433 434 435 436 437 438 439 | } multi_column_list(aCmd, nCmd); } /* ** COMMAND: help ** | | | | > | | | > | | | | | > > > > | | | < | > > > > > > > > > > > > > > > > > > > | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 |
}
multi_column_list(aCmd, nCmd);
}
/*
** COMMAND: help
**
** Usage: %fossil help TOPIC
** or: %fossil TOPIC --help
**
** Display information on how to use TOPIC, which may be a command, webpage, or
** setting. Webpage names begin with "/". To display a list of available
** topics, use one of:
**
** %fossil help Show common commands
** %fossil help -a|--all Show both common and auxiliary commands
** %fossil help -s|--settings Show setting names
** %fossil help -t|--test Show test commands only
** %fossil help -x|--aux Show auxiliary commands only
** %fossil help -w|--www Show list of webpages
*/
void help_cmd(void){
int rc;
int isPage = 0;
const char *z;
const char *zCmdOrPage;
const char *zCmdOrPagePlural;
const CmdOrPage *pCmd = 0;
if( g.argc<3 ){
z = g.argv[0];
fossil_print(
"Usage: %s help TOPIC\n"
"Common commands: (use \"%s help -a|--all\" for a complete list)\n",
z, z);
command_list(0, CMDFLAG_1ST_TIER);
version_cmd();
return;
}
if( find_option("all","a",0) ){
command_list(0, CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER);
return;
}
else if( find_option("www","w",0) ){
command_list(0, CMDFLAG_WEBPAGE);
return;
}
else if( find_option("aux","x",0) ){
command_list(0, CMDFLAG_2ND_TIER);
return;
}
else if( find_option("test","t",0) ){
command_list(0, CMDFLAG_TEST);
return;
}
else if( find_option("setting","s",0) ){
command_list(0, CMDFLAG_SETTING);
return;
}
isPage = ('/' == *g.argv[2]) ? 1 : 0;
if(isPage){
zCmdOrPage = "page";
zCmdOrPagePlural = "pages";
}else{
zCmdOrPage = "command or setting";
zCmdOrPagePlural = "commands and settings";
}
rc = dispatch_name_search(g.argv[2], CMDFLAG_ANY|CMDFLAG_PREFIX, &pCmd);
if( rc==1 ){
fossil_print("unknown %s: %s\nConsider using:\n", zCmdOrPage, g.argv[2]);
fossil_print(" fossil help -a ;# show all commands\n");
fossil_print(" fossil help -w ;# show all web-pages\n");
fossil_print(" fossil help -s ;# show all settings\n");
fossil_exit(1);
}else if( rc==2 ){
fossil_print("ambiguous %s prefix: %s\nMatching %s:\n",
zCmdOrPage, g.argv[2], zCmdOrPagePlural);
command_list(g.argv[2], 0xff);
fossil_exit(1);
}
z = pCmd->zHelp;
if( z==0 ){
fossil_fatal("no help available for the %s %s",
pCmd->zName, zCmdOrPage);
}
if( pCmd->eCmdFlags & CMDFLAG_SETTING ){
fossil_print("Setting: \"%s\"%s\n\n",
pCmd->zName,
(pCmd->eCmdFlags & CMDFLAG_VERSIONABLE)!=0 ? " (versionable)" : ""
);
}
while( *z ){
if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
fossil_print("%s", g.argv[0]);
z += 7;
}else{
putchar(*z);
z++;
}
}
putchar('\n');
}
/*
** Return a pointer to the setting information array.
**
** This routine provides access to the aSetting2[] array which is created
** by the mkindex utility program and included with <page_index.h>.
*/
const Setting *setting_info(int *pnCount){
if( pnCount ) *pnCount = (int)(sizeof(aSetting)/sizeof(aSetting[0]));
return aSetting;
}
|
Changes to src/doc.c.
| ︙ | ︙ | |||
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
{ "asf", 3, "video/x-ms-asf" },
{ "asx", 3, "video/x-ms-asx" },
{ "au", 2, "audio/ulaw" },
{ "avi", 3, "video/x-msvideo" },
{ "bat", 3, "application/x-msdos-program" },
{ "bcpio", 5, "application/x-bcpio" },
{ "bin", 3, "application/octet-stream" },
{ "bz2", 3, "application/x-bzip2" },
{ "bzip", 4, "application/x-bzip" },
{ "c", 1, "text/plain" },
{ "cc", 2, "text/plain" },
{ "ccad", 4, "application/clariscad" },
{ "cdf", 3, "application/x-netcdf" },
{ "class", 5, "application/octet-stream" },
{ "cod", 3, "application/vnd.rim.cod" },
{ "com", 3, "application/x-msdos-program" },
{ "cpio", 4, "application/x-cpio" },
{ "cpt", 3, "application/mac-compactpro" },
{ "cs", 2, "text/plain" },
{ "csh", 3, "application/x-csh" },
{ "css", 3, "text/css" },
{ "csv", 3, "text/csv" },
{ "dcr", 3, "application/x-director" },
{ "deb", 3, "application/x-debian-package" },
{ "dir", 3, "application/x-director" },
{ "dl", 2, "video/dl" },
{ "dms", 3, "application/octet-stream" },
{ "doc", 3, "application/msword" },
{ "docx", 4, "application/vnd.openxmlformats-"
"officedocument.wordprocessingml.document"},
{ "dot", 3, "application/msword" },
| > > | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
{ "asf", 3, "video/x-ms-asf" },
{ "asx", 3, "video/x-ms-asx" },
{ "au", 2, "audio/ulaw" },
{ "avi", 3, "video/x-msvideo" },
{ "bat", 3, "application/x-msdos-program" },
{ "bcpio", 5, "application/x-bcpio" },
{ "bin", 3, "application/octet-stream" },
{ "bmp", 3, "image/bmp" },
{ "bz2", 3, "application/x-bzip2" },
{ "bzip", 4, "application/x-bzip" },
{ "c", 1, "text/plain" },
{ "cc", 2, "text/plain" },
{ "ccad", 4, "application/clariscad" },
{ "cdf", 3, "application/x-netcdf" },
{ "class", 5, "application/octet-stream" },
{ "cod", 3, "application/vnd.rim.cod" },
{ "com", 3, "application/x-msdos-program" },
{ "cpio", 4, "application/x-cpio" },
{ "cpt", 3, "application/mac-compactpro" },
{ "cs", 2, "text/plain" },
{ "csh", 3, "application/x-csh" },
{ "css", 3, "text/css" },
{ "csv", 3, "text/csv" },
{ "dcr", 3, "application/x-director" },
{ "deb", 3, "application/x-debian-package" },
{ "dib", 3, "image/bmp" },
{ "dir", 3, "application/x-director" },
{ "dl", 2, "video/dl" },
{ "dms", 3, "application/octet-stream" },
{ "doc", 3, "application/msword" },
{ "docx", 4, "application/vnd.openxmlformats-"
"officedocument.wordprocessingml.document"},
{ "dot", 3, "application/msword" },
|
| ︙ | ︙ | |||
132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
{ "h", 1, "text/plain" },
{ "hdf", 3, "application/x-hdf" },
{ "hh", 2, "text/plain" },
{ "hqx", 3, "application/mac-binhex40" },
{ "htm", 3, "text/html" },
{ "html", 4, "text/html" },
{ "ice", 3, "x-conference/x-cooltalk" },
{ "ief", 3, "image/ief" },
{ "iges", 4, "model/iges" },
{ "igs", 3, "model/iges" },
{ "ips", 3, "application/x-ipscript" },
{ "ipx", 3, "application/x-ipix" },
{ "jad", 3, "text/vnd.sun.j2me.app-descriptor" },
{ "jar", 3, "application/java-archive" },
| > | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
{ "h", 1, "text/plain" },
{ "hdf", 3, "application/x-hdf" },
{ "hh", 2, "text/plain" },
{ "hqx", 3, "application/mac-binhex40" },
{ "htm", 3, "text/html" },
{ "html", 4, "text/html" },
{ "ice", 3, "x-conference/x-cooltalk" },
{ "ico", 3, "image/vnd.microsoft.icon" },
{ "ief", 3, "image/ief" },
{ "iges", 4, "model/iges" },
{ "igs", 3, "model/iges" },
{ "ips", 3, "application/x-ipscript" },
{ "ipx", 3, "application/x-ipix" },
{ "jad", 3, "text/vnd.sun.j2me.app-descriptor" },
{ "jar", 3, "application/java-archive" },
|
| ︙ | ︙ | |||
459 460 461 462 463 464 465 466 |
/*
** Look for a file named zName in the check-in with RID=vid. Load the content
** of that file into pContent and return the RID for the file. Or return 0
** if the file is not found or could not be loaded.
*/
int doc_load_content(int vid, const char *zName, Blob *pContent){
int rid; /* The RID of the file being loaded */
| > | | | | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
/*
** Look for a file named zName in the check-in with RID=vid. Load the content
** of that file into pContent and return the RID for the file. Or return 0
** if the file is not found or could not be loaded.
*/
int doc_load_content(int vid, const char *zName, Blob *pContent){
int writable = db_is_writeable("repository");
int rid; /* The RID of the file being loaded */
if( !db_table_exists("repository", "vcache") || !writable ){
db_multi_exec(
"CREATE %s TABLE IF NOT EXISTS vcache(\n"
" vid INTEGER, -- check-in ID\n"
" fname TEXT, -- filename\n"
" rid INTEGER, -- artifact ID\n"
" PRIMARY KEY(vid,fname)\n"
") WITHOUT ROWID", writable ? "" : "TEMPORARY"
);
}
if( !db_exists("SELECT 1 FROM vcache WHERE vid=%d", vid) ){
db_multi_exec(
"DELETE FROM vcache;\n"
"CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin;\n"
"INSERT INTO vcache(vid,fname,rid)"
|
| ︙ | ︙ | |||
491 492 493 494 495 496 497 |
rid = 0;
}
return rid;
}
/*
** Transfer content to the output. During the transfer, when text of
| | | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
rid = 0;
}
return rid;
}
/*
** Transfer content to the output. During the transfer, when text of
** the following form is seen:
**
** href="$ROOT/
** action="$ROOT/
**
** Convert $ROOT to the root URI of the repository. Allow ' in place of "
** and any case for href or action.
*/
static void convert_href_and_output(Blob *pIn){
int i, base;
int n = blob_size(pIn);
char *z = blob_buffer(pIn);
for(base=0, i=7; i<n; i++){
if( z[i]=='$'
|
| ︙ | ︙ | |||
571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
** to the top-level of the repository.
*/
void doc_page(void){
const char *zName; /* Argument to the /doc page */
const char *zOrigName = "?"; /* Original document name */
const char *zMime; /* Document MIME type */
char *zCheckin = "tip"; /* The check-in holding the document */
int vid = 0; /* Artifact of check-in */
int rid = 0; /* Artifact of file */
int i; /* Loop counter */
Blob filebody; /* Content of the documentation file */
Blob title; /* Document title */
int nMiss = (-1); /* Failed attempts to find the document */
int isUV = g.zPath[0]=='u'; /* True for /uv. False for /doc */
| > | 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
** to the top-level of the repository.
*/
void doc_page(void){
const char *zName; /* Argument to the /doc page */
const char *zOrigName = "?"; /* Original document name */
const char *zMime; /* Document MIME type */
char *zCheckin = "tip"; /* The check-in holding the document */
char *zPathSuffix = ""; /* Text to append to g.zPath */
int vid = 0; /* Artifact of check-in */
int rid = 0; /* Artifact of file */
int i; /* Loop counter */
Blob filebody; /* Content of the documentation file */
Blob title; /* Document title */
int nMiss = (-1); /* Failed attempts to find the document */
int isUV = g.zPath[0]=='u'; /* True for /uv. False for /doc */
|
| ︙ | ︙ | |||
614 615 616 617 618 619 620 |
assert( nMiss>=0 && nMiss<count(azSuffix) );
zName = azSuffix[nMiss];
}else if( !isUV ){
zName += i;
}
while( zName[0]=='/' ){ zName++; }
if( isUV ){
| | | > | > > | 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
assert( nMiss>=0 && nMiss<count(azSuffix) );
zName = azSuffix[nMiss];
}else if( !isUV ){
zName += i;
}
while( zName[0]=='/' ){ zName++; }
if( isUV ){
zPathSuffix = fossil_strdup(zName);
}else{
zPathSuffix = mprintf("%s/%s", zCheckin, zName);
}
if( nMiss==0 ) zOrigName = zName;
if( !file_is_simple_pathname(zName, 1) ){
if( sqlite3_strglob("*/", zName)==0 ){
assert( nMiss>=0 && nMiss<count(azSuffix) );
zName = mprintf("%s%s", zName, azSuffix[nMiss]);
if( !file_is_simple_pathname(zName, 1) ){
goto doc_not_found;
}
}else{
goto doc_not_found;
}
}
if( isUV ){
if( db_table_exists("repository","unversioned")
&& unversioned_content(zName, &filebody)==0
){
rid = 1;
zDfltTitle = zName;
}
}else if( fossil_strcmp(zCheckin,"ckout")==0 ){
/* Read from the local checkout */
char *zFullpath;
db_must_be_within_tree();
zFullpath = mprintf("%s/%s", g.zLocalRoot, zName);
if( file_isfile(zFullpath)
&& blob_read_from_file(&filebody, zFullpath)>0 ){
rid = 1; /* Fake RID just to get the loop to end */
}
fossil_free(zFullpath);
}else{
vid = name_to_typed_rid(zCheckin, "ci");
rid = doc_load_content(vid, zName, &filebody);
}
}
g.zPath = mprintf("%s/%s", g.zPath, zPathSuffix);
if( rid==0 ) goto doc_not_found;
blob_to_utf8_no_bom(&filebody, 0);
/* The file is now contained in the filebody blob. Deliver the
** file to the user
*/
zMime = nMiss==0 ? P("mimetype") : 0;
|
| ︙ | ︙ | |||
716 717 718 719 720 721 722 723 724 725 726 727 728 729 |
style_header("%s", blob_str(&title));
Th_Render(blob_str(&tail));
blob_reset(&tail);
}else{
style_header("%h", zName);
Th_Render(blob_str(&filebody));
}
}
if( !raw ){
style_footer();
}
#endif
}else{
cgi_set_content_type(zMime);
| > > | 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
style_header("%s", blob_str(&title));
Th_Render(blob_str(&tail));
blob_reset(&tail);
}else{
style_header("%h", zName);
Th_Render(blob_str(&filebody));
}
}else{
Th_Render(blob_str(&filebody));
}
if( !raw ){
style_footer();
}
#endif
}else{
cgi_set_content_type(zMime);
|
| ︙ | ︙ |
Changes to src/event.c.
| ︙ | ︙ | |||
330 331 332 333 334 335 336 |
nrid = content_put(&event);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
if( manifest_crosslink(nrid, &event, MC_NONE)==0 ){
db_end_transaction(1);
return 0;
}
assert( blob_is_reset(&event) );
| | | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
nrid = content_put(&event);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
if( manifest_crosslink(nrid, &event, MC_NONE)==0 ){
db_end_transaction(1);
return 0;
}
assert( blob_is_reset(&event) );
content_deltify(rid, &nrid, 1, 0);
db_end_transaction(0);
return 1;
}
/*
** WEBPAGE: technoteedit
** WEBPAGE: eventedit
|
| ︙ | ︙ |
Changes to src/export.c.
| ︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ** This file contains code used to export the content of a Fossil ** repository in the git-fast-import format. */ #include "config.h" #include "export.h" #include <assert.h> #if INTERFACE /* ** struct mark_t ** holds information for translating between git commits ** and fossil commits. ** -git_name: This is the mark name that identifies the commit to git. ** It will always begin with a ':'. | > > > > > > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
** This file contains code used to export the content of a Fossil
** repository in the git-fast-import format.
*/
#include "config.h"
#include "export.h"
#include <assert.h>
/*
** State information common to all export types.
*/
static struct {
const char *zTrunkName; /* Name of trunk branch */
} gexport;
#if INTERFACE
/*
** struct mark_t
** holds information for translating between git commits
** and fossil commits.
** -git_name: This is the mark name that identifies the commit to git.
** It will always begin with a ':'.
|
| ︙ | ︙ | |||
159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
zName[j] = 0;
printf(" %s <%s>", zName, zEmail);
free(zName);
free(zEmail);
db_reset(&q);
}
#define BLOBMARK(rid) ((rid) * 2)
#define COMMITMARK(rid) ((rid) * 2 + 1)
/*
** insert_commit_xref()
** Insert a new (mark,rid,uuid) entry into the 'xmark' table.
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
zName[j] = 0;
printf(" %s <%s>", zName, zEmail);
free(zName);
free(zEmail);
db_reset(&q);
}
#define REFREPLACEMENT '_'
/*
** Output a sanitized git named reference.
** https://git-scm.com/docs/git-check-ref-format
** This implementation assumes we are only printing
** the branch or tag part of the reference.
*/
static void print_ref(const char *zRef){
char *zEncoded = mprintf("%s", zRef);
int i, w;
if (zEncoded[0]=='@' && zEncoded[1]=='\0'){
putchar(REFREPLACEMENT);
return;
}
for(i=0, w=0; zEncoded[i]; i++, w++){
if( i!=0 ){ /* Two letter tests */
if( (zEncoded[i-1]=='.' && zEncoded[i]=='.') ||
(zEncoded[i-1]=='@' && zEncoded[i]=='{') ){
zEncoded[w]=zEncoded[w-1]=REFREPLACEMENT;
continue;
}
if( zEncoded[i-1]=='/' && zEncoded[i]=='/' ){
w--; /* Normalise to a single / by rolling back w */
continue;
}
}
/* No control characters */
if( (unsigned)zEncoded[i]<0x20 || zEncoded[i]==0x7f ){
zEncoded[w]=REFREPLACEMENT;
continue;
}
switch( zEncoded[i] ){
case ' ':
case '^':
case ':':
case '?':
case '*':
case '[':
case '\\':
zEncoded[w]=REFREPLACEMENT;
break;
}
}
/* Cannot begin with a . or / */
if( zEncoded[0]=='.' || zEncoded[0] == '/' ) zEncoded[0]=REFREPLACEMENT;
if( i>0 ){
i--; w--;
/* Or end with a . or / */
if( zEncoded[i]=='.' || zEncoded[i] == '/' ) zEncoded[w]=REFREPLACEMENT;
/* Cannot end with .lock */
if ( i>4 && strcmp((zEncoded+i)-5, ".lock")==0 )
memset((zEncoded+w)-5, REFREPLACEMENT, 5);
}
printf("%s", zEncoded);
free(zEncoded);
}
#define BLOBMARK(rid) ((rid) * 2)
#define COMMITMARK(rid) ((rid) * 2 + 1)
/*
** insert_commit_xref()
** Insert a new (mark,rid,uuid) entry into the 'xmark' table.
|
| ︙ | ︙ | |||
411 412 413 414 415 416 417 418 419 420 421 422 423 |
**
** If the "--export-marks FILE" option is used, the rid of all commits and
** blobs written on exit for use with "--import-marks" on the next run.
**
** Options:
** --export-marks FILE export rids of exported data to FILE
** --import-marks FILE read rids of data to ignore from FILE
** --repository|-R REPOSITORY export the given REPOSITORY
**
** See also: import
*/
void export_cmd(void){
Stmt q, q2, q3;
| > < > > > > > | 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
**
** If the "--export-marks FILE" option is used, the rid of all commits and
** blobs written on exit for use with "--import-marks" on the next run.
**
** Options:
** --export-marks FILE export rids of exported data to FILE
** --import-marks FILE read rids of data to ignore from FILE
** --rename-trunk NAME use NAME as name of exported trunk branch
** --repository|-R REPOSITORY export the given REPOSITORY
**
** See also: import
*/
void export_cmd(void){
Stmt q, q2, q3;
Bag blobs, vers;
unsigned int unused_mark = 1;
const char *markfile_in;
const char *markfile_out;
bag_init(&blobs);
bag_init(&vers);
find_option("git", 0, 0); /* Ignore the --git option for now */
markfile_in = find_option("import-marks", 0, 1);
markfile_out = find_option("export-marks", 0, 1);
if( !(gexport.zTrunkName = find_option("rename-trunk", 0, 1)) ){
gexport.zTrunkName = "trunk";
}
db_find_and_open_repository(0, 2);
verify_all_options();
if( g.argc!=2 && g.argc!=3 ){ usage("--git ?REPOSITORY?"); }
db_multi_exec("CREATE TEMPORARY TABLE oldblob(rid INTEGER PRIMARY KEY)");
db_multi_exec("CREATE TEMPORARY TABLE oldcommit(rid INTEGER PRIMARY KEY)");
db_multi_exec("CREATE TEMP TABLE xmark(tname TEXT UNIQUE, trid INT, tuuid TEXT)");
db_multi_exec("CREATE INDEX xmark_trid ON xmark(trid)");
if( markfile_in!=0 ){
Stmt qb,qc;
FILE *f;
int rid;
f = fossil_fopen(markfile_in, "r");
if( f==0 ){
|
| ︙ | ︙ | |||
545 546 547 548 549 550 551 |
while( db_step(&q)==SQLITE_ROW ){
Stmt q4;
const char *zSecondsSince1970 = db_column_text(&q, 0);
int ckinId = db_column_int(&q, 1);
const char *zComment = db_column_text(&q, 2);
const char *zUser = db_column_text(&q, 3);
const char *zBranch = db_column_text(&q, 4);
| < | < < < < | > | | | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 |
while( db_step(&q)==SQLITE_ROW ){
Stmt q4;
const char *zSecondsSince1970 = db_column_text(&q, 0);
int ckinId = db_column_int(&q, 1);
const char *zComment = db_column_text(&q, 2);
const char *zUser = db_column_text(&q, 3);
const char *zBranch = db_column_text(&q, 4);
char *zMark;
bag_insert(&vers, ckinId);
db_bind_int(&q2, ":rid", ckinId);
db_step(&q2);
db_reset(&q2);
if( zBranch==0 || fossil_strcmp(zBranch, "trunk")==0 ) zBranch = gexport.zTrunkName;
zMark = mark_name_from_rid(ckinId, &unused_mark);
printf("commit refs/heads/");
print_ref(zBranch);
printf("\nmark %s\n", zMark);
free(zMark);
printf("committer");
print_person(zUser);
printf(" %s +0000\n", zSecondsSince1970);
if( zComment==0 ) zComment = "null comment";
printf("data %d\n%s\n", (int)strlen(zComment), zComment);
db_prepare(&q3,
"SELECT pid FROM plink"
|
| ︙ | ︙ | |||
628 629 630 631 632 633 634 | db_finalize(&q2); db_finalize(&q); manifest_cache_clear(); /* Output tags */ db_prepare(&q, | | > > < | > < < < < | > | > > | | | | 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 |
db_finalize(&q2);
db_finalize(&q);
manifest_cache_clear();
/* Output tags */
db_prepare(&q,
"SELECT tagname, rid, strftime('%%s',mtime),"
" (SELECT coalesce(euser, user) FROM event WHERE objid=rid),"
" value"
" FROM tagxref JOIN tag USING(tagid)"
" WHERE tagtype=1 AND tagname GLOB 'sym-*'"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zTagname = db_column_text(&q, 0);
int rid = db_column_int(&q, 1);
char *zMark = mark_name_from_rid(rid, &unused_mark);
const char *zSecSince1970 = db_column_text(&q, 2);
const char *zUser = db_column_text(&q, 3);
const char *zValue = db_column_text(&q, 4);
if( rid==0 || !bag_find(&vers, rid) ) continue;
zTagname += 4;
printf("tag ");
print_ref(zTagname);
printf("\nfrom %s\n", zMark);
free(zMark);
printf("tagger");
print_person(zUser);
printf(" %s +0000\n", zSecSince1970);
printf("data %d\n", zValue==NULL?0:(int)strlen(zValue)+1);
if( zValue!=NULL ) printf("%s\n",zValue);
}
db_finalize(&q);
if( markfile_out!=0 ){
FILE *f;
f = fossil_fopen(markfile_out, "w");
if( f == 0 ){
|
| ︙ | ︙ |
Changes to src/file.c.
| ︙ | ︙ | |||
86 87 88 89 90 91 92 | ** Fill stat buf with information received from stat() or lstat(). ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. ** */ static int fossil_stat( const char *zFilename, /* name of file or directory to inspect. */ struct fossilStat *buf, /* pointer to buffer where info should go. */ | | < | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
** Fill stat buf with information received from stat() or lstat().
** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
**
*/
static int fossil_stat(
const char *zFilename, /* name of file or directory to inspect. */
struct fossilStat *buf, /* pointer to buffer where info should go. */
int isWd /* non-zero to consider look at symlink itself. */
){
int rc;
void *zMbcs = fossil_utf8_to_path(zFilename, 0);
#if !defined(_WIN32)
if( isWd && db_allow_symlinks() ){
rc = lstat(zMbcs, buf);
}else{
rc = stat(zMbcs, buf);
}
#else
rc = win32_stat(zMbcs, buf, isWd);
#endif
|
| ︙ | ︙ | |||
126 127 128 129 130 131 132 |
** Return the number of errors. No error messages are generated.
*/
static int getStat(const char *zFilename, int isWd){
int rc = 0;
if( zFilename==0 ){
if( fileStatValid==0 ) rc = 1;
}else{
| | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
** Return the number of errors. No error messages are generated.
*/
static int getStat(const char *zFilename, int isWd){
int rc = 0;
if( zFilename==0 ){
if( fileStatValid==0 ) rc = 1;
}else{
if( fossil_stat(zFilename, &fileStat, isWd)!=0 ){
fileStatValid = 0;
rc = 1;
}else{
fileStatValid = 1;
rc = 0;
}
}
|
| ︙ | ︙ | |||
218 219 220 221 222 223 224 |
** Create symlink to file on Unix, or plain-text file with
** symlink target if "allow-symlinks" is off or we're on Windows.
**
** Arguments: target file (symlink will point to it), link file
**/
void symlink_create(const char *zTargetFile, const char *zLinkFile){
#if !defined(_WIN32)
| | | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
** Create symlink to file on Unix, or plain-text file with
** symlink target if "allow-symlinks" is off or we're on Windows.
**
** Arguments: target file (symlink will point to it), link file
**/
void symlink_create(const char *zTargetFile, const char *zLinkFile){
#if !defined(_WIN32)
if( db_allow_symlinks() ){
int i, nName;
char *zName, zBuf[1000];
nName = strlen(zLinkFile);
if( nName>=sizeof(zBuf) ){
zName = mprintf("%s", zLinkFile);
}else{
|
| ︙ | ︙ | |||
275 276 277 278 279 280 281 |
** - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_wd_perm(const char *zFilename){
#if !defined(_WIN32)
if( !getStat(zFilename, 1) ){
if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
return PERM_EXE;
| | | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
** - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_wd_perm(const char *zFilename){
#if !defined(_WIN32)
if( !getStat(zFilename, 1) ){
if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
return PERM_EXE;
else if( db_allow_symlinks() && S_ISLNK(fileStat.st_mode) )
return PERM_LNK;
}
#endif
return PERM_REG;
}
/*
|
| ︙ | ︙ | |||
328 329 330 331 332 333 334 |
** zFilename is a directory -OR- a symlink that points to a directory.
** Return 0 if zFilename does not exist. Return 2 if zFilename exists
** but is something other than a directory.
*/
int file_wd_isdir(const char *zFilename){
int rc;
char *zFN;
| < < | | | | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
** zFilename is a directory -OR- a symlink that points to a directory.
** Return 0 if zFilename does not exist. Return 2 if zFilename exists
** but is something other than a directory.
*/
int file_wd_isdir(const char *zFilename){
int rc;
char *zFN;
zFN = mprintf("%s", zFilename);
file_simplify_name(zFN, -1, 0);
rc = getStat(zFN, 1);
if( rc ){
rc = 0; /* It does not exist at all. */
}else if( S_ISDIR(fileStat.st_mode) ){
rc = 1; /* It exists and is a real directory. */
}else if( S_ISLNK(fileStat.st_mode) ){
Blob content;
blob_read_link(&content, zFN); /* It exists and is a link. */
rc = file_wd_isdir(blob_str(&content)); /* Points to directory? */
blob_reset(&content);
}else{
rc = 2; /* It exists and is something else. */
}
|
| ︙ | ︙ | |||
509 510 511 512 513 514 515 |
** Set or clear the execute bit on a file. Return true if a change
** occurred and false if this routine is a no-op.
*/
int file_wd_setexe(const char *zFilename, int onoff){
int rc = 0;
#if !defined(_WIN32)
struct stat buf;
| | | 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
** Set or clear the execute bit on a file. Return true if a change
** occurred and false if this routine is a no-op.
*/
int file_wd_setexe(const char *zFilename, int onoff){
int rc = 0;
#if !defined(_WIN32)
struct stat buf;
if( fossil_stat(zFilename, &buf, 1)!=0 || S_ISLNK(buf.st_mode) ) return 0;
if( onoff ){
int targetMode = (buf.st_mode & 0444)>>2;
if( (buf.st_mode & 0100)==0 ){
chmod(zFilename, buf.st_mode | targetMode);
rc = 1;
}
}else{
|
| ︙ | ︙ | |||
624 625 626 627 628 629 630 |
** Create the tree of directories in which zFilename belongs, if that sequence
** of directories does not already exist.
**
** On success, return zero. On error, return errorReturn if positive, otherwise
** print an error message and abort.
*/
int file_mkfolder(const char *zFilename, int forceFlag, int errorReturn){
| | > | | | < < < < < < | | | < < < < | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
** Create the tree of directories in which zFilename belongs, if that sequence
** of directories does not already exist.
**
** On success, return zero. On error, return errorReturn if positive, otherwise
** print an error message and abort.
*/
int file_mkfolder(const char *zFilename, int forceFlag, int errorReturn){
int nName, rc = 0;
char *zName;
nName = strlen(zFilename);
zName = mprintf("%s", zFilename);
nName = file_simplify_name(zName, nName, 0);
while( nName>0 && zName[nName-1]!='/' ){ nName--; }
if( nName ){
zName[nName-1] = 0;
if( file_wd_isdir(zName)!=1 ){
rc = file_mkfolder(zName, forceFlag, errorReturn);
if( rc==0 ){
if( file_mkdir(zName, forceFlag) && file_wd_isdir(zName)!=1 ){
if( errorReturn <= 0 ){
fossil_fatal_recursive("unable to create directory %s", zName);
}
rc = errorReturn;
}
}
}
}
free(zName);
return rc;
}
/*
|
| ︙ | ︙ | |||
797 798 799 800 801 802 803 804 805 806 807 808 809 810 |
**
** Changes are made in-place. Return the new name length.
** If the slash parameter is non-zero, the trailing slash, if any,
** is retained.
*/
int file_simplify_name(char *z, int n, int slash){
int i = 1, j;
if( n<0 ) n = strlen(z);
/* On windows and cygwin convert all \ characters to /
* and remove extended path prefix if present */
#if defined(_WIN32) || defined(__CYGWIN__)
for(j=0; j<n; j++){
if( z[j]=='\\' ) z[j] = '/';
| > | 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 |
**
** Changes are made in-place. Return the new name length.
** If the slash parameter is non-zero, the trailing slash, if any,
** is retained.
*/
int file_simplify_name(char *z, int n, int slash){
int i = 1, j;
assert( z!=0 );
if( n<0 ) n = strlen(z);
/* On windows and cygwin convert all \ characters to /
* and remove extended path prefix if present */
#if defined(_WIN32) || defined(__CYGWIN__)
for(j=0; j<n; j++){
if( z[j]=='\\' ) z[j] = '/';
|
| ︙ | ︙ | |||
984 985 986 987 988 989 990 |
file_canonical_name(zPath, &x, slash);
fossil_print("%s[%s] -> [%s]\n", raw ? "RAW " : "", zPath, blob_buffer(&x));
blob_reset(&x);
if( raw ){
int rc;
struct fossilStat testFileStat;
memset(&testFileStat, 0, sizeof(struct fossilStat));
| | | | 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 |
file_canonical_name(zPath, &x, slash);
fossil_print("%s[%s] -> [%s]\n", raw ? "RAW " : "", zPath, blob_buffer(&x));
blob_reset(&x);
if( raw ){
int rc;
struct fossilStat testFileStat;
memset(&testFileStat, 0, sizeof(struct fossilStat));
rc = fossil_stat(zPath, &testFileStat, 0);
fossil_print(" stat_rc = %d\n", rc);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_size);
fossil_print(" stat_size = %s\n", zBuf);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime);
fossil_print(" stat_mtime = %s\n", zBuf);
fossil_print(" stat_mode = %d\n", testFileStat.st_mode);
memset(&testFileStat, 0, sizeof(struct fossilStat));
rc = fossil_stat(zPath, &testFileStat, 1);
fossil_print(" l_stat_rc = %d\n", rc);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_size);
fossil_print(" l_stat_size = %s\n", zBuf);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime);
fossil_print(" l_stat_mtime = %s\n", zBuf);
fossil_print(" l_stat_mode = %d\n", testFileStat.st_mode);
}else{
|
| ︙ | ︙ | |||
1036 1037 1038 1039 1040 1041 1042 |
void cmd_test_file_environment(void){
int i;
int slashFlag = find_option("slash",0,0)!=0;
int resetFlag = find_option("reset",0,0)!=0;
if( find_option("open-config", 0, 0)!=0 ){
Th_OpenConfig(1);
}
| < < < | < < < < < < < > < | < < > | > > > > > > > > > > > > | 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 |
void cmd_test_file_environment(void){
int i;
int slashFlag = find_option("slash",0,0)!=0;
int resetFlag = find_option("reset",0,0)!=0;
if( find_option("open-config", 0, 0)!=0 ){
Th_OpenConfig(1);
}
fossil_print("filenames_are_case_sensitive() = %d\n",
filenames_are_case_sensitive());
fossil_print("db_allow_symlinks_by_default() = %d\n",
db_allow_symlinks_by_default());
fossil_print("db_allow_symlinks() = %d\n", db_allow_symlinks());
for(i=2; i<g.argc; i++){
emitFileStat(g.argv[i], 1, slashFlag, resetFlag);
emitFileStat(g.argv[i], 0, slashFlag, resetFlag);
}
}
/*
** COMMAND: test-canonical-name
**
** Usage: %fossil test-canonical-name FILENAME...
**
** Test the operation of the canonical name generator.
** Also test Fossil's ability to measure attributes of a file.
*/
void cmd_test_canonical_name(void){
int i;
Blob x;
int slashFlag = find_option("slash",0,0)!=0;
blob_zero(&x);
for(i=2; i<g.argc; i++){
char zBuf[100];
const char *zName = g.argv[i];
file_canonical_name(zName, &x, slashFlag);
fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x));
blob_reset(&x);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zName));
fossil_print(" file_size = %s\n", zBuf);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_mtime(zName));
fossil_print(" file_mtime = %s\n", zBuf);
fossil_print(" file_isfile = %d\n", file_wd_isfile(zName));
fossil_print(" file_isfile_or_link = %d\n",file_wd_isfile_or_link(zName));
fossil_print(" file_islink = %d\n", file_wd_islink(zName));
fossil_print(" file_isexe = %d\n", file_wd_isexe(zName));
fossil_print(" file_isdir = %d\n", file_wd_isdir(zName));
}
}
/*
** Return TRUE if the given filename is canonical.
**
** Canonical names are full pathnames using "/" not "\" and which
|
| ︙ | ︙ | |||
1188 1189 1190 1191 1192 1193 1194 | } } /* ** COMMAND: test-relative-name ** ** Test the operation of the relative name generator. | < < < < | 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 |
}
}
/*
** COMMAND: test-relative-name
**
** Test the operation of the relative name generator.
*/
void cmd_test_relative_name(void){
int i;
Blob x;
int slashFlag = find_option("slash",0,0)!=0;
blob_zero(&x);
for(i=2; i<g.argc; i++){
|
| ︙ | ︙ | |||
1311 1312 1313 1314 1315 1316 1317 | ** ** Test the operation of the tree name generator. ** ** Options: ** --absolute Return an absolute path instead of a relative one. ** --case-sensitive B Enable or disable case-sensitive filenames. B is ** a boolean: "yes", "no", "true", "false", etc. | < | 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 |
**
** Test the operation of the tree name generator.
**
** Options:
** --absolute Return an absolute path instead of a relative one.
** --case-sensitive B Enable or disable case-sensitive filenames. B is
** a boolean: "yes", "no", "true", "false", etc.
*/
void cmd_test_tree_name(void){
int i;
Blob x;
int absoluteFlag = find_option("absolute",0,0)!=0;
db_find_and_open_repository(0,0);
blob_zero(&x);
|
| ︙ | ︙ | |||
1379 1380 1381 1382 1383 1384 1385 1386 |
#if defined(_WIN32)
const char *azDirs[] = {
0, /* GetTempPath */
0, /* TEMP */
0, /* TMP */
".",
};
#else
| > | > | 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 |
#if defined(_WIN32)
const char *azDirs[] = {
0, /* GetTempPath */
0, /* TEMP */
0, /* TMP */
".",
};
char *z;
#else
static const char *azDirs[] = {
0, /* TMPDIR */
"/var/tmp",
"/usr/tmp",
"/tmp",
"/temp",
".",
};
#endif
|
| ︙ | ︙ | |||
1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 |
char zRand[16];
#if defined(_WIN32)
wchar_t zTmpPath[MAX_PATH];
if( GetTempPathW(MAX_PATH, zTmpPath) ){
azDirs[0] = fossil_path_to_utf8(zTmpPath);
}
azDirs[1] = fossil_getenv("TEMP");
azDirs[2] = fossil_getenv("TMP");
#endif
| > > > > > > < | > > > > > > > > > > > > > > > > > > > > > > > | 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 |
char zRand[16];
#if defined(_WIN32)
wchar_t zTmpPath[MAX_PATH];
if( GetTempPathW(MAX_PATH, zTmpPath) ){
azDirs[0] = fossil_path_to_utf8(zTmpPath);
/* Removing trailing \ from the temp path */
z = (char*)azDirs[0];
i = (int)strlen(z)-1;
if( i>0 && z[i]=='\\' ) z[i] = 0;
}
azDirs[1] = fossil_getenv("TEMP");
azDirs[2] = fossil_getenv("TMP");
#else
azDirs[0] = fossil_getenv("TMPDIR");
#endif
for(i=0; i<count(azDirs); i++){
if( azDirs[i]==0 ) continue;
if( !file_isdir(azDirs[i]) ) continue;
zDir = azDirs[i];
break;
}
do{
blob_zero(pBuf);
if( cnt++>20 ) fossil_panic("cannot generate a temporary filename");
sqlite3_randomness(15, zRand);
for(i=0; i<15; i++){
zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ];
}
zRand[15] = 0;
blob_appendf(pBuf, "%s/%s-%s.txt", zDir, zPrefix ? zPrefix : "", zRand);
}while( file_size(blob_str(pBuf))>=0 );
#if defined(_WIN32)
fossil_path_free((char *)azDirs[0]);
fossil_path_free((char *)azDirs[1]);
fossil_path_free((char *)azDirs[2]);
/* Change all \ characters in the windows path into / so that they can
** be safely passed to a subcommand, such as by gdiff */
z = blob_buffer(pBuf);
for(i=0; z[i]; i++) if( z[i]=='\\' ) z[i] = '/';
#else
fossil_path_free((char *)azDirs[0]);
#endif
}
/*
** COMMAND: test-tempname
** Usage: fossil test-name BASENAME ...
**
** Generate temporary filenames derived from BASENAME
*/
void file_test_tempname(void){
int i;
Blob x = BLOB_INITIALIZER;
for(i=2; i<g.argc; i++){
file_tempname(&x, g.argv[i]);
fossil_print("%s\n", blob_str(&x));
blob_reset(&x);
}
}
/*
** Return true if a file named zName exists and has identical content
** to the blob pContent. If zName does not exist or if the content is
** different in any way, then return false.
*/
int file_is_the_same(Blob *pContent, const char *zName){
|
| ︙ | ︙ |
Changes to src/finfo.c.
| ︙ | ︙ | |||
43 44 45 46 47 48 49 | ** Options: ** -b|--brief display a brief (one line / revision) summary ** --case-sensitive B Enable or disable case-sensitive filenames. B is a ** boolean: "yes", "no", "true", "false", etc. ** -l|--log select log mode (the default) ** -n|--limit N Display the first N changes (default unlimited). ** N<=0 means no limit. | < | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | ** Options: ** -b|--brief display a brief (one line / revision) summary ** --case-sensitive B Enable or disable case-sensitive filenames. B is a ** boolean: "yes", "no", "true", "false", etc. ** -l|--log select log mode (the default) ** -n|--limit N Display the first N changes (default unlimited). ** N<=0 means no limit. ** --offset P skip P changes ** -p|--print select print mode ** -r|--revision R print the given revision (or ckout, if none is given) ** to stdout (only in print mode) ** -s|--status select status mode (print a status indicator for FILE) ** -W|--width <num> Width of lines (default is to auto-detect). Must be ** >22 or 0 (= no limit, resulting in a single line per |
| ︙ | ︙ | |||
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
**
** a=DATETIME Only show changes after DATETIME
** b=DATETIME Only show changes before DATETIME
** n=NUM Show the first NUM changes only
** brbg Background color by branch name
** ubg Background color by user name
** ci=UUID Ancestors of a particular check-in
** showid Show RID values for debugging
**
** DATETIME may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in
** year-month-day form, it may be truncated, and it may also name a
** timezone offset from UTC as "-HH:MM" (westward) or "+HH:MM"
** (eastward). Either no timezone suffix or "Z" means UTC.
*/
void finfo_page(void){
Stmt q;
const char *zFilename;
char zPrevDate[20];
const char *zA;
const char *zB;
int n;
int baseCheckin;
int fnid;
Blob title;
Blob sql;
HQuery url;
GraphContext *pGraph;
int brBg = P("brbg")!=0;
int uBg = P("ubg")!=0;
int fDebug = atoi(PD("debug","0"));
int fShowId = P("showid")!=0;
Stmt qparent;
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
style_header("File History");
login_anonymous_available();
url_initialize(&url, "finfo");
if( brBg ) url_add_parameter(&url, "brbg", 0);
| > > > > | 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
**
** a=DATETIME Only show changes after DATETIME
** b=DATETIME Only show changes before DATETIME
** n=NUM Show the first NUM changes only
** brbg Background color by branch name
** ubg Background color by user name
** ci=UUID Ancestors of a particular check-in
** orig=UUID If both ci and orig are supplied, only show those
** changes on a direct path from orig to ci.
** showid Show RID values for debugging
**
** DATETIME may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in
** year-month-day form, it may be truncated, and it may also name a
** timezone offset from UTC as "-HH:MM" (westward) or "+HH:MM"
** (eastward). Either no timezone suffix or "Z" means UTC.
*/
void finfo_page(void){
Stmt q;
const char *zFilename;
char zPrevDate[20];
const char *zA;
const char *zB;
int n;
int baseCheckin;
int origCheckin = 0;
int fnid;
Blob title;
Blob sql;
HQuery url;
GraphContext *pGraph;
int brBg = P("brbg")!=0;
int uBg = P("ubg")!=0;
int fDebug = atoi(PD("debug","0"));
int fShowId = P("showid")!=0;
Stmt qparent;
int iTableId = timeline_tableid();
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
style_header("File History");
login_anonymous_available();
url_initialize(&url, "finfo");
if( brBg ) url_add_parameter(&url, "brbg", 0);
|
| ︙ | ︙ | |||
329 330 331 332 333 334 335 |
style_footer();
return;
}
if( g.perm.Admin ){
style_submenu_element("MLink Table", "%R/mlink?name=%t", zFilename);
}
if( baseCheckin ){
| > > > > | > | > | | | > | 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
style_footer();
return;
}
if( g.perm.Admin ){
style_submenu_element("MLink Table", "%R/mlink?name=%t", zFilename);
}
if( baseCheckin ){
if( P("orig")!=0 ){
origCheckin = name_to_typed_rid(P("orig"),"ci");
path_shortest_stored_in_ancestor_table(origCheckin, baseCheckin);
}else{
compute_direct_ancestors(baseCheckin);
}
}
url_add_parameter(&url, "name", zFilename);
blob_zero(&sql);
blob_append_sql(&sql,
"SELECT"
" datetime(min(event.mtime),toLocal())," /* Date of change */
" coalesce(event.ecomment, event.comment)," /* Check-in comment */
" coalesce(event.euser, event.user)," /* User who made chng */
" mlink.pid," /* Parent file rid */
" mlink.fid," /* File rid */
" (SELECT uuid FROM blob WHERE rid=mlink.pid)," /* Parent file uuid */
" blob.uuid," /* Current file uuid */
" (SELECT uuid FROM blob WHERE rid=mlink.mid)," /* Check-in uuid */
" event.bgcolor," /* Background color */
" (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
" AND tagxref.rid=mlink.mid)," /* Branchname */
" mlink.mid," /* check-in ID */
" mlink.pfnid," /* Previous filename */
" blob.size" /* File size */
" FROM mlink, event, blob"
" WHERE mlink.fnid=%d"
" AND event.objid=mlink.mid"
" AND mlink.fid=blob.rid",
TAG_BRANCH, fnid
);
if( (zA = P("a"))!=0 ){
blob_append_sql(&sql, " AND event.mtime>=julianday('%q')", zA);
url_add_parameter(&url, "a", zA);
}
if( (zB = P("b"))!=0 ){
|
| ︙ | ︙ | |||
394 395 396 397 398 399 400 |
@ <p>SQL: %h(blob_str(&sql))</p>
}
blob_reset(&sql);
blob_zero(&title);
if( baseCheckin ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", baseCheckin);
char *zLink = href("%R/info/%!S", zUuid);
| > > | > | > > > > > > | | 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
@ <p>SQL: %h(blob_str(&sql))</p>
}
blob_reset(&sql);
blob_zero(&title);
if( baseCheckin ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", baseCheckin);
char *zLink = href("%R/info/%!S", zUuid);
if( origCheckin ){
blob_appendf(&title, "Changes to file ");
}else if( n>0 ){
blob_appendf(&title, "First %d ancestors of file ", n);
}else{
blob_appendf(&title, "Ancestors of file ");
}
blob_appendf(&title,"<a href='%R/finfo?name=%T'>%h</a>",
zFilename, zFilename);
if( fShowId ) blob_appendf(&title, " (%d)", fnid);
blob_append(&title, origCheckin ? " between " : " from ", -1);
blob_appendf(&title, "check-in %z%S</a>", zLink, zUuid);
if( fShowId ) blob_appendf(&title, " (%d)", baseCheckin);
fossil_free(zUuid);
if( origCheckin ){
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", origCheckin);
zLink = href("%R/info/%!S", zUuid);
blob_appendf(&title, " and check-in %z%S</a>", zLink, zUuid);
fossil_free(zUuid);
}
}else{
blob_appendf(&title, "History of ");
hyperlinked_path(zFilename, &title, 0, "tree", "");
if( fShowId ) blob_appendf(&title, " (%d)", fnid);
}
@ <h2>%b(&title)</h2>
blob_reset(&title);
pGraph = graph_init();
@ <table id="timelineTable%d(iTableId)" class="timelineTable">
if( baseCheckin ){
db_prepare(&qparent,
"SELECT DISTINCT pid FROM mlink"
" WHERE fid=:fid AND mid=:mid AND pid>0 AND fnid=:fnid"
" AND pmid IN (SELECT rid FROM ancestor)"
" ORDER BY isaux /*sort*/"
);
|
| ︙ | ︙ | |||
441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
const char *zPUuid = db_column_text(&q, 5);
const char *zUuid = db_column_text(&q, 6);
const char *zCkin = db_column_text(&q,7);
const char *zBgClr = db_column_text(&q, 8);
const char *zBr = db_column_text(&q, 9);
int fmid = db_column_int(&q, 10);
int pfnid = db_column_int(&q, 11);
int gidx;
char zTime[10];
int nParent = 0;
int aParent[GR_MAX_RAIL];
db_bind_int(&qparent, ":fid", frid);
db_bind_int(&qparent, ":mid", fmid);
| > | 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
const char *zPUuid = db_column_text(&q, 5);
const char *zUuid = db_column_text(&q, 6);
const char *zCkin = db_column_text(&q,7);
const char *zBgClr = db_column_text(&q, 8);
const char *zBr = db_column_text(&q, 9);
int fmid = db_column_int(&q, 10);
int pfnid = db_column_int(&q, 11);
int szFile = db_column_int(&q, 12);
int gidx;
char zTime[10];
int nParent = 0;
int aParent[GR_MAX_RAIL];
db_bind_int(&qparent, ":fid", frid);
db_bind_int(&qparent, ":mid", fmid);
|
| ︙ | ︙ | |||
481 482 483 484 485 486 487 |
@ </td>
if( zBgClr && zBgClr[0] ){
@ <td class="timelineTableCell" style="background-color: %h(zBgClr);">
}else{
@ <td class="timelineTableCell">
}
if( zUuid ){
| > | | | | | | | > > > > > | > | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
@ </td>
if( zBgClr && zBgClr[0] ){
@ <td class="timelineTableCell" style="background-color: %h(zBgClr);">
}else{
@ <td class="timelineTableCell">
}
if( zUuid ){
if( origCheckin==0 ){
if( nParent==0 ){
@ <b>Added</b>
}else if( pfnid ){
char *zPrevName = db_text(0,"SELECT name FROM filename WHERE fnid=%d",
pfnid);
@ <b>Renamed</b> from
@ %z(href("%R/finfo?name=%t", zPrevName))%h(zPrevName)</a>
}
}
@ %z(href("%R/artifact/%!S",zUuid))[%S(zUuid)]</a>
if( fShowId ){
int srcId = delta_source_rid(frid);
if( srcId>0 ){
@ (%d(frid)←%d(srcId))
}else{
@ (%d(frid))
}
}
@ part of check-in
}else{
char *zNewName;
zNewName = db_text(0,
"SELECT name FROM filename WHERE fnid = "
" (SELECT fnid FROM mlink"
|
| ︙ | ︙ | |||
515 516 517 518 519 520 521 |
}
}
hyperlink_to_uuid(zCkin);
if( fShowId ){
@ (%d(fmid))
}
@ %W(zCom) (user:
| | | > | 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
}
}
hyperlink_to_uuid(zCkin);
if( fShowId ){
@ (%d(fmid))
}
@ %W(zCom) (user:
hyperlink_to_user(zUser, zDate, ",");
@ branch: %z(href("%R/timeline?t=%T&n=200",zBr))%h(zBr)</a>,
@ size: %d(szFile))
if( g.perm.Hyperlink && zUuid ){
const char *z = zFilename;
@ %z(href("%R/annotate?filename=%h&checkin=%s",z,zCkin))
@ [annotate]</a>
@ %z(href("%R/blame?filename=%h&checkin=%s",z,zCkin))
@ [blame]</a>
@ %z(href("%R/timeline?n=200&uf=%!S",zUuid))[check-ins using]</a>
|
| ︙ | ︙ | |||
556 557 558 559 560 561 562 |
graph_free(pGraph);
pGraph = 0;
}else{
@ <tr class="timelineBottom"><td></td><td></td><td></td></tr>
}
}
@ </table>
| | | 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
graph_free(pGraph);
pGraph = 0;
}else{
@ <tr class="timelineBottom"><td></td><td></td><td></td></tr>
}
}
@ </table>
timeline_output_graph_javascript(pGraph, 0, iTableId, 1);
style_footer();
}
/*
** WEBPAGE: mlink
** URL: /mlink?name=FILENAME
** URL: /mlink?ci=NAME
|
| ︙ | ︙ |
Changes to src/foci.c.
| ︙ | ︙ | |||
262 263 264 265 266 267 268 269 270 271 272 |
0, /* xUpdate */
0, /* xBegin */
0, /* xSync */
0, /* xCommit */
0, /* xRollback */
0, /* xFindMethod */
0, /* xRename */
};
sqlite3_create_module(db, "files_of_checkin", &foci_module, 0);
return SQLITE_OK;
}
| > > > | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
0, /* xUpdate */
0, /* xBegin */
0, /* xSync */
0, /* xCommit */
0, /* xRollback */
0, /* xFindMethod */
0, /* xRename */
0, /* xSavepoint */
0, /* xRelease */
0 /* xRollbackTo */
};
sqlite3_create_module(db, "files_of_checkin", &foci_module, 0);
return SQLITE_OK;
}
|
Changes to src/graph.c.
| ︙ | ︙ | |||
182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
const char *zBranch, /* Branch for this check-in */
const char *zBgClr, /* Background color. NULL or "" for white. */
const char *zUuid, /* hash name of the object being graphed */
int isLeaf /* True if this row is a leaf */
){
GraphRow *pRow;
int nByte;
if( p->nErr ) return 0;
nByte = sizeof(GraphRow);
nByte += sizeof(pRow->aParent[0])*nParent;
pRow = (GraphRow*)safeMalloc( nByte );
pRow->aParent = (int*)&pRow[1];
pRow->rid = rid;
| > | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
const char *zBranch, /* Branch for this check-in */
const char *zBgClr, /* Background color. NULL or "" for white. */
const char *zUuid, /* hash name of the object being graphed */
int isLeaf /* True if this row is a leaf */
){
GraphRow *pRow;
int nByte;
static int nRow = 0;
if( p->nErr ) return 0;
nByte = sizeof(GraphRow);
nByte += sizeof(pRow->aParent[0])*nParent;
pRow = (GraphRow*)safeMalloc( nByte );
pRow->aParent = (int*)&pRow[1];
pRow->rid = rid;
|
| ︙ | ︙ | |||
205 206 207 208 209 210 211 |
if( p->pFirst==0 ){
p->pFirst = pRow;
}else{
p->pLast->pNext = pRow;
}
p->pLast = pRow;
p->nRow++;
| | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
if( p->pFirst==0 ){
p->pFirst = pRow;
}else{
p->pLast->pNext = pRow;
}
p->pLast = pRow;
p->nRow++;
pRow->idx = pRow->idxTop = ++nRow;
return pRow->idx;
}
/*
** Return the index of a rail currently not in use for any row between
** top and bottom, inclusive.
*/
|
| ︙ | ︙ |
Changes to src/gzip.c.
| ︙ | ︙ | |||
63 64 65 66 67 68 69 |
aHdr[2] = 8;
aHdr[3] = 0;
if( now==-1 ){
now = db_int64(0, "SELECT (julianday('now') - 2440587.5)*86400.0");
}
put32(&aHdr[4], now&0xffffffff);
aHdr[8] = 2;
| | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
aHdr[2] = 8;
aHdr[3] = 0;
if( now==-1 ){
now = db_int64(0, "SELECT (julianday('now') - 2440587.5)*86400.0");
}
put32(&aHdr[4], now&0xffffffff);
aHdr[8] = 2;
aHdr[9] = -1;
blob_append(&gzip.out, aHdr, 10);
gzip.iCRC = 0;
gzip.eState = 1;
}
/*
** Add nIn bytes of content from pIn to the gzip file.
|
| ︙ | ︙ |
Changes to src/http.c.
| ︙ | ︙ | |||
174 175 176 177 178 179 180 |
if ( g.url.user && g.url.passwd && use_fossil_creds_for_httpauth_prompt() ){
zHttpAuth = mprintf("%s:%s", g.url.user, g.url.passwd);
}else{
prompt_user("Basic Authorization user: ", &x);
zUser = mprintf("%b", &x);
zPrompt = mprintf("HTTP password for %b: ", &x);
blob_reset(&x);
| | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
if ( g.url.user && g.url.passwd && use_fossil_creds_for_httpauth_prompt() ){
zHttpAuth = mprintf("%s:%s", g.url.user, g.url.passwd);
}else{
prompt_user("Basic Authorization user: ", &x);
zUser = mprintf("%b", &x);
zPrompt = mprintf("HTTP password for %b: ", &x);
blob_reset(&x);
prompt_for_password(zPrompt, &x, 0);
zPw = mprintf("%b", &x);
zHttpAuth = mprintf("%s:%s", zUser, zPw);
free(zUser);
free(zPw);
free(zPrompt);
blob_reset(&x);
}
|
| ︙ | ︙ |
Changes to src/http_ssl.c.
| ︙ | ︙ | |||
250 251 252 253 254 255 256 |
X509_STORE_add_cert(SSL_CTX_get_cert_store(sslCtx), cert);
X509_free(cert);
hasSavedCertificate = 1;
}
if( pUrlData->useProxy ){
int rc;
| < < | | | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
X509_STORE_add_cert(SSL_CTX_get_cert_store(sslCtx), cert);
X509_free(cert);
hasSavedCertificate = 1;
}
if( pUrlData->useProxy ){
int rc;
char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
BIO *sBio = BIO_new_connect(connStr);
free(connStr);
if( BIO_do_connect(sBio)<=0 ){
ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)",
pUrlData->name, pUrlData->port, ERR_reason_error_string(ERR_get_error()));
ssl_close();
return 1;
}
|
| ︙ | ︙ | |||
291 292 293 294 295 296 297 |
"continuing without it.\n");
}
#endif
SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
if( !pUrlData->useProxy ){
| > | < > | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
"continuing without it.\n");
}
#endif
SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
if( !pUrlData->useProxy ){
char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
BIO_set_conn_hostname(iBio, connStr);
free(connStr);
if( BIO_do_connect(iBio)<=0 ){
ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)",
pUrlData->name, pUrlData->port, ERR_reason_error_string(ERR_get_error()));
ssl_close();
return 1;
}
}
|
| ︙ | ︙ |
Changes to src/http_transport.c.
| ︙ | ︙ | |||
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
if( pnSent ) *pnSent = transport.nSent;
if( pnRcvd ) *pnRcvd = transport.nRcvd;
if( resetFlag ){
transport.nSent = 0;
transport.nRcvd = 0;
}
}
/*
** Default SSH command
*/
#ifdef _WIN32
static const char zDefaultSshCmd[] = "plink -ssh -T";
#else
static const char zDefaultSshCmd[] = "ssh -e none -T";
#endif
/*
** SSH initialization of the transport layer
*/
int transport_ssh_open(UrlData *pUrlData){
/* For SSH we need to create and run SSH fossil http
** to talk to the remote machine.
*/
char *zSsh; /* The base SSH command */
Blob zCmd; /* The SSH command */
char *zHost; /* The host name to contact */
| > > > > > > > > > > > > > > > < < < < < > > | > > | < < < > | < | > > | < | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
if( pnSent ) *pnSent = transport.nSent;
if( pnRcvd ) *pnRcvd = transport.nRcvd;
if( resetFlag ){
transport.nSent = 0;
transport.nRcvd = 0;
}
}
/*
** Check zFossil to see if it is a reasonable "fossil" command to
** run on the server. Do not allow an attacker to substitute something
** like "/bin/rm".
*/
static int is_safe_fossil_command(const char *zFossil){
static const char *azSafe[] = { "*/fossil", "*/echo" };
int i;
for(i=0; i<sizeof(azSafe)/sizeof(azSafe[0]); i++){
if( sqlite3_strglob(azSafe[i], zFossil)==0 ) return 1;
if( strcmp(azSafe[i]+2, zFossil)==0 ) return 1;
}
return 0;
}
/*
** Default SSH command
*/
#ifdef _WIN32
static const char zDefaultSshCmd[] = "plink -ssh -T";
#else
static const char zDefaultSshCmd[] = "ssh -e none -T";
#endif
/*
** SSH initialization of the transport layer
*/
int transport_ssh_open(UrlData *pUrlData){
/* For SSH we need to create and run SSH fossil http
** to talk to the remote machine.
*/
char *zSsh; /* The base SSH command */
Blob zCmd; /* The SSH command */
char *zHost; /* The host name to contact */
socket_ssh_resolve_addr(pUrlData);
zSsh = db_get("ssh-command", zDefaultSshCmd);
blob_init(&zCmd, zSsh, -1);
if( pUrlData->port!=pUrlData->dfltPort && pUrlData->port ){
#ifdef _WIN32
blob_appendf(&zCmd, " -P %d", pUrlData->port);
#else
blob_appendf(&zCmd, " -p %d", pUrlData->port);
#endif
}
if( pUrlData->user && pUrlData->user[0] ){
zHost = mprintf("%s@%s", pUrlData->user, pUrlData->name);
blob_append_escaped_arg(&zCmd, zHost);
fossil_free(zHost);
}else{
blob_append_escaped_arg(&zCmd, pUrlData->name);
}
if( !is_safe_fossil_command(pUrlData->fossil) ){
fossil_fatal("the ssh:// URL is asking to run an unsafe command [%s] on "
"the server.", pUrlData->fossil);
}
blob_append_escaped_arg(&zCmd, pUrlData->fossil);
blob_append(&zCmd, " test-http", 10);
if( pUrlData->path && pUrlData->path[0] ){
blob_append_escaped_arg(&zCmd, pUrlData->path);
}else{
fossil_fatal("ssh:// URI does not specify a path to the repository");
}
if( g.fSshTrace ){
fossil_print("%s\n", blob_str(&zCmd)); /* Show the whole SSH command */
}
popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid);
if( sshPid==0 ){
socket_set_errmsg("cannot start ssh tunnel using [%b]", &zCmd);
}
blob_reset(&zCmd);
return sshPid==0;
}
|
| ︙ | ︙ |
Changes to src/import.c.
| ︙ | ︙ | |||
67 68 69 70 71 72 73 | int nMerge; /* Number of merge values */ int nMergeAlloc; /* Number of slots in azMerge[] */ char **azMerge; /* Merge values */ int nFile; /* Number of aFile values */ int nFileAlloc; /* Number of slots in aFile[] */ ImportFile *aFile; /* Information about files in a commit */ int fromLoaded; /* True zFrom content loaded into aFile[] */ | < | > | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
int nMerge; /* Number of merge values */
int nMergeAlloc; /* Number of slots in azMerge[] */
char **azMerge; /* Merge values */
int nFile; /* Number of aFile values */
int nFileAlloc; /* Number of slots in aFile[] */
ImportFile *aFile; /* Information about files in a commit */
int fromLoaded; /* True zFrom content loaded into aFile[] */
int tagCommit; /* True if the commit adds a tag */
} gg;
/*
** Duplicate a string.
*/
char *fossil_strndup(const char *zOrig, int len){
char *z = 0;
if( zOrig ){
int n;
if( len<0 ){
n = strlen(zOrig);
}else{
for( n=0; zOrig[n] && n<len; ++n );
}
z = fossil_malloc( n+1 );
memcpy(z, zOrig, n);
z[n] = 0;
}
return z;
}
char *fossil_strdup(const char *zOrig){
return fossil_strndup(zOrig, -1);
}
|
| ︙ | ︙ | |||
214 215 216 217 218 219 220 |
** control artifact to the BLOB table.
*/
static void finish_tag(void){
Blob record, cksum;
if( gg.zDate && gg.zTag && gg.zFrom && gg.zUser ){
blob_zero(&record);
blob_appendf(&record, "D %s\n", gg.zDate);
| | > | > > | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
** control artifact to the BLOB table.
*/
static void finish_tag(void){
Blob record, cksum;
if( gg.zDate && gg.zTag && gg.zFrom && gg.zUser ){
blob_zero(&record);
blob_appendf(&record, "D %s\n", gg.zDate);
blob_appendf(&record, "T +sym-%F%F%F %s", gimport.zTagPre, gg.zTag,
gimport.zTagSuf, gg.zFrom);
if( gg.zComment ){
blob_appendf(&record, " %F", gg.zComment);
}
blob_appendf(&record, "\nU %F\n", gg.zUser);
md5sum_blob(&record, &cksum);
blob_appendf(&record, "Z %b\n", &cksum);
fast_insert_content(&record, 0, 0, 1);
blob_reset(&cksum);
}
import_reset(0);
}
|
| ︙ | ︙ | |||
271 272 273 274 275 276 277 |
const char *zUuid = gg.aFile[i].zUuid;
if( zUuid==0 ) continue;
blob_appendf(&record, "F %F %s", gg.aFile[i].zName, zUuid);
if( gg.aFile[i].isExe ){
blob_append(&record, " x\n", 3);
}else if( gg.aFile[i].isLink ){
blob_append(&record, " l\n", 3);
| < | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
const char *zUuid = gg.aFile[i].zUuid;
if( zUuid==0 ) continue;
blob_appendf(&record, "F %F %s", gg.aFile[i].zName, zUuid);
if( gg.aFile[i].isExe ){
blob_append(&record, " x\n", 3);
}else if( gg.aFile[i].isLink ){
blob_append(&record, " l\n", 3);
}else{
blob_append(&record, "\n", 1);
}
}
if( gg.zFrom ){
blob_appendf(&record, "P %s", gg.zFrom);
for(i=0; i<gg.nMerge; i++){
|
| ︙ | ︙ | |||
511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
}
zName[i++] = c;
}
zName[i] = 0;
}
/*
** Read the git-fast-import format from pIn and insert the corresponding
** content into the database.
*/
static void git_fast_import(FILE *pIn){
ImportFile *pFile, *pNew;
int i, mx;
| > > > > | 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
}
zName[i++] = c;
}
zName[i] = 0;
}
static struct{
const char *zMasterName; /* Name of master branch */
} ggit;
/*
** Read the git-fast-import format from pIn and insert the corresponding
** content into the database.
*/
static void git_fast_import(FILE *pIn){
ImportFile *pFile, *pNew;
int i, mx;
|
| ︙ | ︙ | |||
534 535 536 537 538 539 540 541 542 543 |
while( fgets(zLine, sizeof(zLine), pIn) ){
if( zLine[0]=='\n' || zLine[0]=='#' ) continue;
if( strncmp(zLine, "blob", 4)==0 ){
gg.xFinish();
gg.xFinish = finish_blob;
}else
if( strncmp(zLine, "commit ", 7)==0 ){
gg.xFinish();
gg.xFinish = finish_commit;
trim_newline(&zLine[7]);
| > | | | | | | | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
while( fgets(zLine, sizeof(zLine), pIn) ){
if( zLine[0]=='\n' || zLine[0]=='#' ) continue;
if( strncmp(zLine, "blob", 4)==0 ){
gg.xFinish();
gg.xFinish = finish_blob;
}else
if( strncmp(zLine, "commit ", 7)==0 ){
const char *zRefName;
gg.xFinish();
gg.xFinish = finish_commit;
trim_newline(&zLine[7]);
zRefName = &zLine[7];
/* The argument to the "commit" line might match either of these
** patterns:
**
** (A) refs/heads/BRANCHNAME
** (B) refs/tags/TAGNAME
**
** If pattern A is used, then the branchname used is as shown.
** Except, the "master" branch which is the default branch name in
** Git is changed to "trunk" which is the default name in Fossil.
** If the pattern is B, then the new commit should be on the same
** branch as its parent. And, we might need to add the TAGNAME
** tag to the new commit. However, if there are multiple instances
** of pattern B with the same TAGNAME, then only put the tag on the
** last commit that holds that tag.
**
** None of the above is explained in the git-fast-export
** documentation. We had to figure it out via trial and error.
*/
for(i=5; i<strlen(zRefName) && zRefName[i]!='/'; i++){}
gg.tagCommit = strncmp(&zRefName[5], "tags", 4)==0; /* True for pattern B */
if( zRefName[i+1]!=0 ) zRefName += i+1;
if( fossil_strcmp(zRefName, "master")==0 ) zRefName = ggit.zMasterName;
gg.zBranch = fossil_strdup(zRefName);
gg.fromLoaded = 0;
}else
if( strncmp(zLine, "tag ", 4)==0 ){
gg.xFinish();
gg.xFinish = finish_tag;
trim_newline(&zLine[4]);
gg.zTag = fossil_strdup(&zLine[4]);
|
| ︙ | ︙ | |||
598 599 600 601 602 603 604 |
if( gg.nData ){
int got;
gg.aData = fossil_malloc( gg.nData+1 );
got = fread(gg.aData, 1, gg.nData, pIn);
if( got!=gg.nData ){
fossil_fatal("short read: got %d of %d bytes", got, gg.nData);
}
| | | > > > > < < | < > | | > > > > > > > > | > | | | 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
if( gg.nData ){
int got;
gg.aData = fossil_malloc( gg.nData+1 );
got = fread(gg.aData, 1, gg.nData, pIn);
if( got!=gg.nData ){
fossil_fatal("short read: got %d of %d bytes", got, gg.nData);
}
gg.aData[got] = '\0';
if( gg.zComment==0 &&
(gg.xFinish==finish_commit || gg.xFinish==finish_tag) ){
/* Strip trailing newline, it's appended to the comment. */
if( gg.aData[got-1] == '\n' )
gg.aData[got-1] = '\0';
gg.zComment = gg.aData;
gg.aData = 0;
gg.nData = 0;
}
}
}else
if( strncmp(zLine, "author ", 7)==0 ){
/* No-op */
}else
if( strncmp(zLine, "mark ", 5)==0 ){
trim_newline(&zLine[5]);
fossil_free(gg.zMark);
gg.zMark = fossil_strdup(&zLine[5]);
}else
if( strncmp(zLine, "tagger ", 7)==0 || strncmp(zLine, "committer ",10)==0 ){
sqlite3_int64 secSince1970;
z = strchr(zLine, ' ');
while( fossil_isspace(*z) ) z++;
if( (zTo=strchr(z, '>'))==NULL ) goto malformed_line;
*(++zTo) = '\0';
/* Lookup user by contact info. */
fossil_free(gg.zUser);
gg.zUser = db_text(0, "SELECT login FROM user WHERE info=%Q", z);
if( gg.zUser==NULL ){
/* If there is no user with this contact info,
* then use the email address as the username. */
if ( (z=strchr(z, '<'))==NULL ) goto malformed_line;
z++;
*(zTo-1) = '\0';
gg.zUser = fossil_strdup(z);
}
secSince1970 = 0;
for(zTo++; fossil_isdigit(*zTo); zTo++){
secSince1970 = secSince1970*10 + *zTo - '0';
}
fossil_free(gg.zDate);
gg.zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", secSince1970);
gg.zDate[10] = 'T';
}else
if( strncmp(zLine, "from ", 5)==0 ){
trim_newline(&zLine[5]);
|
| ︙ | ︙ | |||
746 747 748 749 750 751 752 |
}else
{
goto malformed_line;
}
}
gg.xFinish();
| < < < | 764 765 766 767 768 769 770 771 772 773 774 775 776 777 |
}else
{
goto malformed_line;
}
}
gg.xFinish();
import_reset(1);
return;
malformed_line:
trim_newline(zLine);
fossil_fatal("bad fast-import line: [%s]", zLine);
return;
|
| ︙ | ︙ | |||
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 |
db_multi_exec("INSERT INTO xbranches (tname, ttype) VALUES(%Q, %d)",
zBranch, *type);
branchId = db_last_insert_rowid();
}
}
return branchId;
}
/*
** Read the svn-dump format from pIn and insert the corresponding
** content into the database.
*/
static void svn_dump_import(FILE *pIn){
SvnRecord rec;
| > > > > > > > > > > > > > > > > > > > > > > > > | 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 |
db_multi_exec("INSERT INTO xbranches (tname, ttype) VALUES(%Q, %d)",
zBranch, *type);
branchId = db_last_insert_rowid();
}
}
return branchId;
}
/*
** Insert content of corresponding content blob into the database.
** If content is identified as a symbolic link, then trailing
** "link " characters are removed from content.
**
** content is considered to be a symlink if zPerm contains at least
** one "l" character.
*/
static int svn_handle_symlinks(const char *perms, Blob *content){
Blob link_blob;
if( perms && strstr(perms, "l")!=0 ){
if( blob_size(content)>5 ){
/* Skip trailing 'link ' characters */
blob_seek(content, 5, BLOB_SEEK_SET);
blob_tail(content, &link_blob);
return content_put(&link_blob);
}else{
fossil_fatal("Too short symbolic link path");
}
}else{
return content_put(content);
}
}
/*
** Read the svn-dump format from pIn and insert the corresponding
** content into the database.
*/
static void svn_dump_import(FILE *pIn){
SvnRecord rec;
|
| ︙ | ︙ | |||
1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 |
int branchType;
int branchId = svn_parse_path(zTemp, &zFile, &branchType);
char *zAction = svn_find_header(rec, "Node-action");
char *zKind = svn_find_header(rec, "Node-kind");
char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0;
int deltaFlag = 0;
int srcRev = 0;
if( branchId==0 ){
svn_free_rec(&rec);
continue;
}
if( (zTemp = svn_find_header(rec, "Text-delta")) ){
deltaFlag = strncmp(zTemp, "true", 4)==0;
}
| > > > > | 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 |
int branchType;
int branchId = svn_parse_path(zTemp, &zFile, &branchType);
char *zAction = svn_find_header(rec, "Node-action");
char *zKind = svn_find_header(rec, "Node-kind");
char *zPerm = svn_find_prop(rec, "svn:executable") ? "x" : 0;
int deltaFlag = 0;
int srcRev = 0;
if ( zPerm==0 ){
zPerm = svn_find_prop(rec, "svn:special") ? "l" : 0;
}
if( branchId==0 ){
svn_free_rec(&rec);
continue;
}
if( (zTemp = svn_find_header(rec, "Text-delta")) ){
deltaFlag = strncmp(zTemp, "true", 4)==0;
}
|
| ︙ | ︙ | |||
1462 1463 1464 1465 1466 1467 1468 |
Blob target;
if( rid!=0 ){
content_get(rid, &deltaSrc);
}else{
blob_zero(&deltaSrc);
}
svn_apply_svndiff(&rec.content, &deltaSrc, &target);
| | | > > > > > > > > > > > > | | | 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 |
Blob target;
if( rid!=0 ){
content_get(rid, &deltaSrc);
}else{
blob_zero(&deltaSrc);
}
svn_apply_svndiff(&rec.content, &deltaSrc, &target);
rid = svn_handle_symlinks(zPerm, &target);
}else if( rec.contentFlag ){
rid = svn_handle_symlinks(zPerm, &rec.content);
}else if( zSrcPath ){
if ( zPerm==0 ){
zPerm = db_text(0, "SELECT tperm FROM xfiles"
" WHERE tpath=%Q AND tbranch=%d"
"", zSrcPath, branchId);
}
}
db_bind_text(&addFile, ":path", zFile);
db_bind_int(&addFile, ":branch", branchId);
db_bind_int(&addFile, ":rid", rid);
db_bind_text(&addFile, ":perm", zPerm);
db_step(&addFile);
db_reset(&addFile);
db_bind_int(&addRev, ":branch", branchId);
db_step(&addRev);
db_reset(&addRev);
}
}else
if( strncmp(zAction, "change", 6)==0 ){
int rid = 0;
if( zKind==0 ){
fossil_fatal("Missing Node-kind");
}
if( rec.contentFlag && strncmp(zKind, "dir", 3)!=0 ){
if ( zPerm==0 ){
zPerm = db_text(0, "SELECT tperm FROM xfiles"
" WHERE tpath=%Q AND tbranch=%d"
"", zFile, branchId);
}
if( deltaFlag ){
Blob deltaSrc;
Blob target;
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=("
" SELECT tuuid FROM xfiles"
" WHERE tpath=%Q AND tbranch=%d"
")", zFile, branchId);
content_get(rid, &deltaSrc);
svn_apply_svndiff(&rec.content, &deltaSrc, &target);
rid = svn_handle_symlinks(zPerm, &target);
}else{
rid = svn_handle_symlinks(zPerm, &rec.content);
}
db_bind_text(&addFile, ":path", zFile);
db_bind_int(&addFile, ":branch", branchId);
db_bind_int(&addFile, ":rid", rid);
db_bind_text(&addFile, ":perm", zPerm);
db_step(&addFile);
db_reset(&addFile);
|
| ︙ | ︙ | |||
1543 1544 1545 1546 1547 1548 1549 | ** argument. If no input file is supplied the interchange format ** data is read from standard input. ** ** The following formats are currently understood by this command ** ** --git Import from the git-fast-export file format (default) ** Options: | | | > | 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 | ** argument. If no input file is supplied the interchange format ** data is read from standard input. ** ** The following formats are currently understood by this command ** ** --git Import from the git-fast-export file format (default) ** Options: ** --import-marks FILE Restore marks table from FILE ** --export-marks FILE Save marks table to FILE ** --rename-master NAME Renames the master branch to NAME ** ** --svn Import from the svnadmin-dump file format. The default ** behaviour (unless overridden by --flat) is to treat 3 ** folders in the SVN root as special, following the ** common layout of SVN repositories. These are (by ** default) trunk/, branches/ and tags/. The SVN --deltas ** format is supported but not required. |
| ︙ | ︙ | |||
1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 |
gsvn.zBranches = find_option("branches", 0, 1);
gsvn.zTags = find_option("tags", 0, 1);
gsvn.revFlag = find_option("rev-tags", 0, 0)
|| (incrFlag && !find_option("no-rev-tags", 0, 0));
}else if( gitFlag ){
markfile_in = find_option("import-marks", 0, 1);
markfile_out = find_option("export-marks", 0, 1);
}
verify_all_options();
if( g.argc!=3 && g.argc!=4 ){
usage("--git|--svn ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?");
}
if( g.argc==4 ){
pIn = fossil_fopen(g.argv[3], "rb");
}else{
pIn = stdin;
fossil_binary_mode(pIn);
}
if( !incrFlag ){
if( forceFlag ) file_delete(g.argv[2]);
db_create_repository(g.argv[2]);
}
db_open_repository(g.argv[2]);
db_open_config(0, 0);
db_begin_transaction();
| > > > > | > > > | 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 |
gsvn.zBranches = find_option("branches", 0, 1);
gsvn.zTags = find_option("tags", 0, 1);
gsvn.revFlag = find_option("rev-tags", 0, 0)
|| (incrFlag && !find_option("no-rev-tags", 0, 0));
}else if( gitFlag ){
markfile_in = find_option("import-marks", 0, 1);
markfile_out = find_option("export-marks", 0, 1);
if( !(ggit.zMasterName = find_option("rename-master", 0, 1)) ){
ggit.zMasterName = "master";
}
}
verify_all_options();
if( g.argc!=3 && g.argc!=4 ){
usage("--git|--svn ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?");
}
if( g.argc==4 ){
pIn = fossil_fopen(g.argv[3], "rb");
if( pIn==0 ) fossil_fatal("cannot open input file \"%s\"", g.argv[3]);
}else{
pIn = stdin;
fossil_binary_mode(pIn);
}
if( !incrFlag ){
if( forceFlag ) file_delete(g.argv[2]);
db_create_repository(g.argv[2]);
}
db_open_repository(g.argv[2]);
db_open_config(0, 0);
db_begin_transaction();
if( !incrFlag ){
db_initial_setup(0, 0, 0);
db_set("main-branch", gimport.zTrunkName, 0);
}
if( svnFlag ){
db_multi_exec(
"CREATE TEMP TABLE xrevisions("
" trev INTEGER, tbranch INT, trid INT, tparent INT DEFAULT 0,"
" UNIQUE(tbranch, trev)"
");"
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
128 129 130 131 132 133 134 |
** Print information about the URLs used to access a repository and
** checkouts in a repository.
*/
static void extraRepoInfo(void){
Stmt s;
db_prepare(&s, "SELECT substr(name,7), date(mtime,'unixepoch')"
" FROM config"
| | > | | > > > > > > | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
** Print information about the URLs used to access a repository and
** checkouts in a repository.
*/
static void extraRepoInfo(void){
Stmt s;
db_prepare(&s, "SELECT substr(name,7), date(mtime,'unixepoch')"
" FROM config"
" WHERE name GLOB 'ckout:*' ORDER BY mtime DESC");
while( db_step(&s)==SQLITE_ROW ){
const char *zName;
const char *zCkout = db_column_text(&s, 0);
if( !vfile_top_of_checkout(zCkout) ) continue;
if( g.localOpen ){
if( fossil_strcmp(zCkout, g.zLocalRoot)==0 ) continue;
zName = "alt-root:";
}else{
zName = "check-out:";
}
fossil_print("%-11s %-54s %s\n", zName, zCkout,
db_column_text(&s, 1));
}
db_finalize(&s);
db_prepare(&s, "SELECT substr(name,9), date(mtime,'unixepoch')"
" FROM config"
" WHERE name GLOB 'baseurl:*' ORDER BY mtime DESC");
while( db_step(&s)==SQLITE_ROW ){
fossil_print("access-url: %-54s %s\n", db_column_text(&s, 0),
db_column_text(&s, 1));
}
db_finalize(&s);
}
/*
** Show the parent project, if any
*/
static void showParentProject(void){
const char *zParentCode;
zParentCode = db_get("parent-project-code",0);
if( zParentCode ){
fossil_print("derived-from: %s %s\n", zParentCode,
db_get("parent-project-name",""));
}
}
/*
** COMMAND: info
**
** Usage: %fossil info ?VERSION | REPOSITORY_FILENAME? ?OPTIONS?
**
** With no arguments, provide information about the current tree.
** If an argument is specified, provide information about the object
** in the repository of the current tree that the argument refers
** to. Or if the argument is the name of a repository, show
** information about that repository.
**
** If the argument is a repository name, then the --verbose option shows
** known the check-out locations for that repository and all URLs used
** to access the repository. The --verbose is (currently) a no-op if
** the argument is the name of a object within the repository.
**
** Use the "finfo" command to get information about a specific
** file in a checkout.
**
** Options:
**
** -R|--repository FILE Extract info from repository FILE
** -v|--verbose Show extra information about repositories
**
** See also: annotate, artifact, finfo, timeline
*/
void info_cmd(void){
i64 fsize;
int verboseFlag = find_option("verbose","v",0)!=0;
if( !verboseFlag ){
|
| ︙ | ︙ | |||
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
void render_checkin_context(int rid, int parentsOnly){
Blob sql;
Stmt q;
blob_zero(&sql);
blob_append(&sql, timeline_query_for_www(), -1);
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);"
"INSERT INTO ok VALUES(%d);"
"INSERT OR IGNORE INTO ok SELECT pid FROM plink WHERE cid=%d;",
rid, rid
);
if( !parentsOnly ){
db_multi_exec(
"INSERT OR IGNORE INTO ok SELECT cid FROM plink WHERE pid=%d;", rid
);
}
blob_append_sql(&sql, " AND event.objid IN ok ORDER BY mtime DESC");
db_prepare(&q, "%s", blob_sql_text(&sql));
www_print_timeline(&q, TIMELINE_DISJOINT|TIMELINE_GRAPH, 0, 0, rid, 0);
db_finalize(&q);
}
/*
** Append the difference between artifacts to the output
*/
static void append_diff(
const char *zFrom, /* Diff from this artifact */
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
void render_checkin_context(int rid, int parentsOnly){
Blob sql;
Stmt q;
blob_zero(&sql);
blob_append(&sql, timeline_query_for_www(), -1);
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);"
"DELETE FROM ok;"
"INSERT INTO ok VALUES(%d);"
"INSERT OR IGNORE INTO ok SELECT pid FROM plink WHERE cid=%d;",
rid, rid
);
if( !parentsOnly ){
db_multi_exec(
"INSERT OR IGNORE INTO ok SELECT cid FROM plink WHERE pid=%d;", rid
);
}
blob_append_sql(&sql, " AND event.objid IN ok ORDER BY mtime DESC");
db_prepare(&q, "%s", blob_sql_text(&sql));
www_print_timeline(&q, TIMELINE_DISJOINT|TIMELINE_GRAPH, 0, 0, rid, 0);
db_finalize(&q);
}
/*
** Show a graph all wiki, tickets, and check-ins that refer to object zUuid.
**
** If zLabel is not NULL and the graph is not empty, then output zLabel as
** a prefix to the graph.
*/
void render_backlink_graph(const char *zUuid, const char *zLabel){
Blob sql;
Stmt q;
char *zGlob;
zGlob = mprintf("%.5s*", zUuid);
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);"
"DELETE FROM ok;"
"INSERT OR IGNORE INTO ok"
" SELECT srcid FROM backlink"
" WHERE target GLOB %Q"
" AND %Q GLOB (target || '*');",
zGlob, zUuid
);
if( !db_exists("SELECT 1 FROM ok") ) return;
if( zLabel ) cgi_printf("%s", zLabel);
blob_zero(&sql);
blob_append(&sql, timeline_query_for_www(), -1);
blob_append_sql(&sql, " AND event.objid IN ok ORDER BY mtime DESC");
db_prepare(&q, "%s", blob_sql_text(&sql));
www_print_timeline(&q, TIMELINE_DISJOINT|TIMELINE_GRAPH, 0, 0, 0, 0);
db_finalize(&q);
}
/*
** WEBPAGE: test-backlinks
**
** Show a timeline of all check-ins and other events that have entries
** in the backlink table. This is used for testing the rendering
** of the "References" section of the /info page.
*/
void backlink_timeline_page(void){
Blob sql;
Stmt q;
login_check_credentials();
if( !g.perm.Read || !g.perm.RdTkt || !g.perm.RdWiki ){
login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
return;
}
style_header("Backlink Timeline (Internal Testing Use)");
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);"
"DELETE FROM ok;"
"INSERT OR IGNORE INTO ok"
" SELECT blob.rid FROM backlink, blob"
" WHERE blob.uuid BETWEEN backlink.target AND (backlink.target||'x')"
);
blob_zero(&sql);
blob_append(&sql, timeline_query_for_www(), -1);
blob_append_sql(&sql, " AND event.objid IN ok ORDER BY mtime DESC");
db_prepare(&q, "%s", blob_sql_text(&sql));
www_print_timeline(&q, TIMELINE_DISJOINT|TIMELINE_GRAPH, 0, 0, 0, 0);
db_finalize(&q);
style_footer();
}
/*
** Append the difference between artifacts to the output
*/
static void append_diff(
const char *zFrom, /* Diff from this artifact */
|
| ︙ | ︙ | |||
704 705 706 707 708 709 710 711 712 713 714 715 716 717 |
}
@ </table>
}else{
style_header("Check-in Information");
login_anonymous_available();
}
db_finalize(&q1);
showTags(rid);
@ <div class="section">Context</div>
render_checkin_context(rid, 0);
@ <div class="section">Changes</div>
@ <div class="sectionmenu">
verboseFlag = g.zPath[0]!='c';
if( db_get_boolean("show-version-diffs", 0)==0 ){
| > | 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 |
}
@ </table>
}else{
style_header("Check-in Information");
login_anonymous_available();
}
db_finalize(&q1);
render_backlink_graph(zUuid, "<div class=\"section\">References</div>\n");
showTags(rid);
@ <div class="section">Context</div>
render_checkin_context(rid, 0);
@ <div class="section">Changes</div>
@ <div class="sectionmenu">
verboseFlag = g.zPath[0]!='c';
if( db_get_boolean("show-version-diffs", 0)==0 ){
|
| ︙ | ︙ | |||
997 998 999 1000 1001 1002 1003 | ** from=TAG Left side of the comparison ** to=TAG Right side of the comparison ** branch=TAG Show all changes on a particular branch ** v=BOOLEAN Default true. If false, only list files that have changed ** sbs=BOOLEAN Side-by-side diff if true. Unified diff if false ** glob=STRING only diff files matching this glob ** dc=N show N lines of context around each diff | | | | | 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
** from=TAG Left side of the comparison
** to=TAG Right side of the comparison
** branch=TAG Show all changes on a particular branch
** v=BOOLEAN Default true. If false, only list files that have changed
** sbs=BOOLEAN Side-by-side diff if true. Unified diff if false
** glob=STRING only diff files matching this glob
** dc=N show N lines of context around each diff
** w=BOOLEAN ignore whitespace when computing diffs
** nohdr omit the description at the top of the page
**
**
** Show all differences between two check-ins.
*/
void vdiff_page(void){
int ridFrom, ridTo;
int verboseFlag;
int sideBySide;
u64 diffFlags = 0;
Manifest *pFrom, *pTo;
ManifestFile *pFileFrom, *pFileTo;
const char *zBranch;
const char *zFrom;
const char *zTo;
const char *zRe;
|
| ︙ | ︙ | |||
1080 1081 1082 1083 1084 1085 1086 |
style_submenu_element("Clear glob",
"%R/vdiff?from=%T&to=%T&sbs=%d%s%s", zFrom, zTo,
sideBySide, (verboseFlag && !sideBySide)?"&v":"", zW);
}else{
style_submenu_element("Patch", "%R/vpatch?from=%T&to=%T%s", zFrom, zTo, zW);
}
if( sideBySide || verboseFlag ){
| < < < < < < | < < < < | 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 |
style_submenu_element("Clear glob",
"%R/vdiff?from=%T&to=%T&sbs=%d%s%s", zFrom, zTo,
sideBySide, (verboseFlag && !sideBySide)?"&v":"", zW);
}else{
style_submenu_element("Patch", "%R/vpatch?from=%T&to=%T%s", zFrom, zTo, zW);
}
if( sideBySide || verboseFlag ){
style_submenu_checkbox("w", "Ignore Whitespace", 0, 0);
}
style_header("Check-in Differences");
if( P("nohdr")==0 ){
@ <h2>Difference From:</h2><blockquote>
checkin_description(ridFrom);
@ </blockquote><h2>To:</h2><blockquote>
checkin_description(ridTo);
|
| ︙ | ︙ | |||
1211 1212 1213 1214 1215 1216 1217 |
db_prepare(&q,
"SELECT filename.name, datetime(event.mtime,toLocal()),"
" coalesce(event.ecomment,event.comment),"
" coalesce(event.euser,event.user),"
" b.uuid, mlink.mperm,"
" coalesce((SELECT value FROM tagxref"
| | > > | 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 |
db_prepare(&q,
"SELECT filename.name, datetime(event.mtime,toLocal()),"
" coalesce(event.ecomment,event.comment),"
" coalesce(event.euser,event.user),"
" b.uuid, mlink.mperm,"
" coalesce((SELECT value FROM tagxref"
" WHERE tagid=%d AND tagtype>0 AND rid=mlink.mid),'trunk'),"
" a.size"
" FROM mlink, filename, event, blob a, blob b"
" WHERE filename.fnid=mlink.fnid"
" AND event.objid=mlink.mid"
" AND a.rid=mlink.fid"
" AND b.rid=mlink.mid"
" AND mlink.fid=%d"
" ORDER BY filename.name, event.mtime /*sort*/",
TAG_BRANCH, rid
);
@ <ul>
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
const char *zDate = db_column_text(&q, 1);
const char *zCom = db_column_text(&q, 2);
const char *zUser = db_column_text(&q, 3);
const char *zVers = db_column_text(&q, 4);
int mPerm = db_column_int(&q, 5);
const char *zBr = db_column_text(&q, 6);
int szFile = db_column_int(&q,7);
int sameFilename = prevName!=0 && fossil_strcmp(zName,prevName)==0;
if( sameFilename && !showDetail ){
if( cnt==1 ){
@ %z(href("%R/whatis/%!S",zUuid))[more...]</a>
}
cnt++;
continue;
|
| ︙ | ︙ | |||
1274 1275 1276 1277 1278 1279 1280 |
@ at
hyperlink_to_date(zDate,"");
}
if( zBr && zBr[0] ){
@ on branch %z(href("%R/timeline?r=%T",zBr))%h(zBr)</a>
}
@ — %!W(zCom) (user:
| | > | 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 |
@ at
hyperlink_to_date(zDate,"");
}
if( zBr && zBr[0] ){
@ on branch %z(href("%R/timeline?r=%T",zBr))%h(zBr)</a>
}
@ — %!W(zCom) (user:
hyperlink_to_user(zUser,zDate,",");
@ size: %d(szFile))
if( g.perm.Hyperlink ){
@ %z(href("%R/finfo?name=%T&ci=%!S",zName,zVers))[ancestry]</a>
@ %z(href("%R/annotate?filename=%T&checkin=%!S",zName,zVers))
@ [annotate]</a>
@ %z(href("%R/blame?filename=%T&checkin=%!S",zName,zVers))
@ [blame]</a>
}
|
| ︙ | ︙ | |||
1454 1455 1456 1457 1458 1459 1460 | } return objType; } /* ** WEBPAGE: fdiff | | | | | > > > > > > | > > > > | < | | | > < > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < | < | < < < | < < < < < < < < < < < < | 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 |
}
return objType;
}
/*
** WEBPAGE: fdiff
** URL: fdiff?v1=UUID&v2=UUID
**
** Two arguments, v1 and v2, identify the artifacts to be diffed.
** Show diff side by side unless sbs is 0. Generate plain text if
** "patch" is present, otherwise generate "pretty" HTML.
**
** Alternative URL: fdiff?from=filename1&to=filename2&ci=checkin
**
** If the "from" and "to" query parameters are both present, then they are
** the names of two files within the check-in "ci" that are diffed. If the
** "ci" parameter is omitted, then the most recent check-in ("tip") is
** used.
**
** Additional parameters:
**
** dc=N Show N lines of context around each diff
** patch Use the patch diff format
** regex=REGEX Only show differences that match REGEX
** sbs=BOOLEAN Turn side-by-side diffs on and off (default: on)
** verbose=BOOLEAN Show more detail when describing artifacts
** w=BOOLEAN Ignore whitespace
*/
void diff_page(void){
int v1, v2;
int isPatch = P("patch")!=0;
int sideBySide = PB("sbs");
int verbose = PB("verbose");
char *zV1;
char *zV2;
const char *zRe;
ReCompiled *pRe = 0;
u64 diffFlags;
u32 objdescFlags = 0;
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
if( P("from") && P("to") ){
v1 = artifact_from_ci_and_filename(0, "from");
v2 = artifact_from_ci_and_filename(0, "to");
}else{
Stmt q;
v1 = name_to_rid_www("v1");
v2 = name_to_rid_www("v2");
/* If the two file versions being compared both have the same
** filename, then offer an "Annotate" link that constructs an
** annotation between those version. */
db_prepare(&q,
"SELECT (SELECT substr(uuid,1,20) FROM blob WHERE rid=a.mid),"
" (SELECT substr(uuid,1,20) FROM blob WHERE rid=b.mid),"
" (SELECT name FROM filename WHERE filename.fnid=a.fnid)"
" FROM mlink a, event ea, mlink b, event eb"
" WHERE a.fid=%d"
" AND b.fid=%d"
" AND a.fnid=b.fnid"
" AND a.fid!=a.pid"
" AND b.fid!=b.pid"
" AND ea.objid=a.mid"
" AND eb.objid=b.mid"
" ORDER BY ea.mtime ASC, eb.mtime ASC",
v1, v2
);
if( db_step(&q)==SQLITE_ROW ){
const char *zCkin = db_column_text(&q, 0);
const char *zOrig = db_column_text(&q, 1);
const char *zFN = db_column_text(&q, 2);
style_submenu_element("Annotate",
"%R/annotate?origin=%s&checkin=%s&filename=%T",
zOrig, zCkin, zFN);
}
db_finalize(&q);
}
if( v1==0 || v2==0 ) fossil_redirect_home();
zRe = P("regex");
if( zRe ) re_compile(&pRe, zRe, 0);
if( verbose ) objdescFlags |= OBJDESC_DETAIL;
if( isPatch ){
Blob c1, c2, *pOut;
pOut = cgi_output_blob();
cgi_set_content_type("text/plain");
diffFlags = 4;
content_get(v1, &c1);
content_get(v2, &c2);
text_diff(&c1, &c2, pOut, pRe, diffFlags);
blob_reset(&c1);
blob_reset(&c2);
return;
}
zV1 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v1);
zV2 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v2);
diffFlags = construct_diff_flags(1, sideBySide) | DIFF_HTML;
style_header("Diff");
style_submenu_checkbox("w", "Ignore Whitespace", 0, 0);
style_submenu_checkbox("sbs", "Side-by-Side Diff", 0, 0);
style_submenu_checkbox("verbose", "Verbose", 0, 0);
style_submenu_element("Patch", "%s/fdiff?v1=%T&v2=%T&patch",
g.zTop, P("v1"), P("v2"));
if( P("smhdr")!=0 ){
@ <h2>Differences From Artifact
@ %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a> To
@ %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>.</h2>
}else{
@ <h2>Differences From
|
| ︙ | ︙ | |||
1565 1566 1567 1568 1569 1570 1571 |
void rawartifact_page(void){
int rid = 0;
char *zUuid;
const char *zMime;
Blob content;
if( P("ci") && P("filename") ){
| | | 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 |
void rawartifact_page(void){
int rid = 0;
char *zUuid;
const char *zMime;
Blob content;
if( P("ci") && P("filename") ){
rid = artifact_from_ci_and_filename(0, 0);
}
if( rid==0 ){
rid = name_to_rid_www("name");
}
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
if( rid==0 ) fossil_redirect_home();
|
| ︙ | ︙ | |||
1706 1707 1708 1709 1710 1711 1712 1713 | /* ** Look for "ci" and "filename" query parameters. If found, try to ** use them to extract the record ID of an artifact for the file. ** ** Also look for "fn" as an alias for "filename". If either "filename" ** or "fn" is present but "ci" is missing, use "tip" as a default value ** for "ci". */ | > > > > > > > > | > > > | | | > > | | > | 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 |
/*
** Look for "ci" and "filename" query parameters. If found, try to
** use them to extract the record ID of an artifact for the file.
**
** Also look for "fn" as an alias for "filename". If either "filename"
** or "fn" is present but "ci" is missing, use "tip" as a default value
** for "ci".
**
** If zNameParam is not NULL, this use that parameter as the filename
** rather than "fn" or "filename".
**
** If pUrl is not NULL, then record the "ci" and "filename" values in
** pUrl.
**
** At least one of pUrl or zNameParam must be NULL.
*/
int artifact_from_ci_and_filename(HQuery *pUrl, const char *zNameParam){
const char *zFilename;
const char *zCI;
int cirid;
Manifest *pManifest;
ManifestFile *pFile;
if( zNameParam ){
zFilename = P(zNameParam);
}else{
zFilename = P("filename");
if( zFilename==0 ){
zFilename = P("fn");
}
}
if( zFilename==0 ) return 0;
zCI = P("ci");
cirid = name_to_typed_rid(zCI ? zCI : "tip", "ci");
if( cirid<=0 ) return 0;
pManifest = manifest_get(cirid, CFTYPE_MANIFEST, 0);
if( pManifest==0 ) return 0;
manifest_file_rewind(pManifest);
while( (pFile = manifest_file_next(pManifest,0))!=0 ){
if( fossil_strcmp(zFilename, pFile->zName)==0 ){
int rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", pFile->zUuid);
manifest_destroy(pManifest);
if( pUrl ){
assert( zNameParam==0 );
url_add_parameter(pUrl, "fn", zFilename);
if( zCI ) url_add_parameter(pUrl, "ci", zCI);
}
return rid;
}
}
manifest_destroy(pManifest);
|
| ︙ | ︙ | |||
1831 1832 1833 1834 1835 1836 1837 | /* ** WEBPAGE: artifact ** WEBPAGE: file ** WEBPAGE: whatis ** ** Typical usage: ** | | | | | > > | > > | > > > > > > > > > > > > > > > > > > > > > | 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 |
/*
** WEBPAGE: artifact
** WEBPAGE: file
** WEBPAGE: whatis
**
** Typical usage:
**
** /artifact/HASH
** /whatis/HASH
** /file/NAME
**
** Additional query parameters:
**
** ln - show line numbers
** ln=N - highlight line number N
** ln=M-N - highlight lines M through N inclusive
** ln=M-N+Y-Z - highlight lines M through N and Y through Z (inclusive)
** verbose - show more detail in the description
** download - redirect to the download (artifact page only)
** name=SHA1HASH - Provide the SHA1HASH as a query parameter
** filename=NAME - Show information for content file NAME
** fn=NAME - "fn" is shorthand for "filename"
** ci=VERSION - The specific check-in to use for "filename=".
**
** The /artifact page show the complete content of a file
** identified by HASH as preformatted text. The
** /whatis page shows only a description of the file. The /file
** page shows the most recent version of the file or directory
** called NAME, or a list of the top-level directory if NAME is
** omitted.
*/
void artifact_page(void){
int rid = 0;
Blob content;
const char *zMime;
Blob downloadName;
int renderAsWiki = 0;
int renderAsHtml = 0;
int objType;
int asText;
const char *zUuid;
u32 objdescFlags = 0;
int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
int isFile = fossil_strcmp(g.zPath,"file")==0;
const char *zLn = P("ln");
const char *zName = P("name");
HQuery url;
url_initialize(&url, g.zPath);
rid = artifact_from_ci_and_filename(&url, 0);
if( rid==0 ){
url_add_parameter(&url, "name", zName);
if( isFile ){
/* Do a top-level directory listing in /file mode if no argument
** specified */
if( zName==0 || zName[0]==0 ){
if( P("ci")==0 ) cgi_set_query_parameter("ci","tip");
page_tree();
return;
}
/* Look for a single file with the given name */
rid = db_int(0,
"SELECT fid FROM filename, mlink, event"
" WHERE name=%Q"
" AND mlink.fnid=filename.fnid"
" AND event.objid=mlink.mid"
" ORDER BY event.mtime DESC LIMIT 1",
zName
);
/* If no file called NAME exists, instead look for a directory
** with that name, and do a directory listing */
if( rid==0 ){
int nName = (int)strlen(zName);
if( nName && zName[nName-1]=='/' ) nName--;
if( db_exists(
"SELECT 1 FROM filename"
" WHERE name GLOB '%.*q/*' AND substr(name,1,%d)=='%.*q/';",
nName, zName, nName+1, nName, zName
) ){
if( P("ci")==0 ) cgi_set_query_parameter("ci","tip");
page_tree();
return;
}
}
/* If no file or directory called NAME: issue an error */
if( rid==0 ){
style_header("No such file");
@ File '%h(zName)' does not exist in this repository.
style_footer();
return;
}
}else{
|
| ︙ | ︙ | |||
1982 1983 1984 1985 1986 1987 1988 |
if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){
style_submenu_element("Parsed", "%R/info/%s", zUuid);
}
if( descOnly ){
style_submenu_element("Content", "%R/artifact/%s", zUuid);
}else{
if( zLn==0 || atoi(zLn)==0 ){
| | | 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 |
if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){
style_submenu_element("Parsed", "%R/info/%s", zUuid);
}
if( descOnly ){
style_submenu_element("Content", "%R/artifact/%s", zUuid);
}else{
if( zLn==0 || atoi(zLn)==0 ){
style_submenu_checkbox("ln", "Line Numbers", 0, 0);
}
@ <hr />
content_get(rid, &content);
if( renderAsWiki ){
wiki_render_by_mimetype(&content, zMime);
}else if( renderAsHtml ){
@ <iframe src="%R/raw/%T(blob_str(&downloadName))?name=%s(zUuid)"
|
| ︙ | ︙ |
Changes to src/json.c.
| ︙ | ︙ | |||
1261 1262 1263 1264 1265 1266 1267 | VAL(capabilities, json_cap_value()); INT(g, argc); INT(g, isConst); CSTR(g, zConfigDbName); INT(g, repositoryOpen); INT(g, localOpen); INT(g, minPrefix); | < | 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 | VAL(capabilities, json_cap_value()); INT(g, argc); INT(g, isConst); CSTR(g, zConfigDbName); INT(g, repositoryOpen); INT(g, localOpen); INT(g, minPrefix); INT(g, fSqlTrace); INT(g, fSqlStats); INT(g, fSqlPrint); INT(g, fQuiet); INT(g, fHttpTrace); INT(g, fSystemTrace); INT(g, fNoSync); |
| ︙ | ︙ | |||
2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 | ** COMMAND: json ** ** Usage: %fossil json SUBCOMMAND ?OPTIONS? ** ** In CLI mode, the -R REPO common option is supported. Due to limitations ** in the argument dispatching code, any -FLAGS must come after the final ** sub- (or subsub-) command. ** ** The commands include: ** ** anonymousPassword ** artifact ** branch ** cap | > > > > > | 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 | ** COMMAND: json ** ** Usage: %fossil json SUBCOMMAND ?OPTIONS? ** ** In CLI mode, the -R REPO common option is supported. Due to limitations ** in the argument dispatching code, any -FLAGS must come after the final ** sub- (or subsub-) command. ** ** The -json-input FILE option can be used to read JSON data and process ** it like the HTTP interface would. For example: ** ** %fossil json -json-input my.json ** ** The commands include: ** ** anonymousPassword ** artifact ** branch ** cap |
| ︙ | ︙ |
Changes to src/json_branch.c.
| ︙ | ︙ | |||
293 294 295 296 297 298 299 |
fossil_fatal("Problem committing manifest: %s", g.zErrMsg);
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
if( manifest_crosslink(brid, &branch, MC_PERMIT_HOOKS)==0 ){
fossil_fatal("%s", g.zErrMsg);
}
assert( blob_is_reset(&branch) );
| | | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
fossil_fatal("Problem committing manifest: %s", g.zErrMsg);
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
if( manifest_crosslink(brid, &branch, MC_PERMIT_HOOKS)==0 ){
fossil_fatal("%s", g.zErrMsg);
}
assert( blob_is_reset(&branch) );
content_deltify(rootid, &brid, 1, 0);
if( zNewRid ){
*zNewRid = brid;
}
/* Commit */
db_end_transaction(0);
|
| ︙ | ︙ |
Changes to src/login.c.
| ︙ | ︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#if defined(_WIN32)
# include <windows.h> /* for Sleep */
# if defined(__MINGW32__) || defined(_MSC_VER)
# define sleep Sleep /* windows does not have sleep, but Sleep */
# endif
#endif
#include <time.h>
/*
** Return the login-group name. Or return 0 if this repository is
** not a member of a login-group.
*/
const char *login_group_name(void){
static const char *zGroup = 0;
| > | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
#if defined(_WIN32)
# include <windows.h> /* for Sleep */
# if defined(__MINGW32__) || defined(_MSC_VER)
# define sleep Sleep /* windows does not have sleep, but Sleep */
# endif
#endif
#include <time.h>
/*
** Return the login-group name. Or return 0 if this repository is
** not a member of a login-group.
*/
const char *login_group_name(void){
static const char *zGroup = 0;
|
| ︙ | ︙ | |||
844 845 846 847 848 849 850 851 852 853 854 855 856 857 |
int login_wants_https_redirect(void){
if( g.sslNotAvailable ) return 0;
if( db_get_boolean("redirect-to-https",0)==0 ) return 0;
if( P("HTTPS")!=0 ) return 0;
return 1;
}
/*
** This routine examines the login cookie to see if it exists and
** is valid. If the login cookie checks out, it then sets global
** variables appropriately.
**
** g.userUid Database USER.UID value. Might be -1 for "nobody"
** g.zLogin Database USER.LOGIN value. NULL for user "nobody"
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
int login_wants_https_redirect(void){
if( g.sslNotAvailable ) return 0;
if( db_get_boolean("redirect-to-https",0)==0 ) return 0;
if( P("HTTPS")!=0 ) return 0;
return 1;
}
/*
** Attempt to use Basic Authentication to establish the user. Return the
** (non-zero) uid if successful. Return 0 if it does not work.
*/
static int logic_basic_authentication(const char *zIpAddr){
const char *zAuth = PD("HTTP_AUTHORIZATION", 0);
int i;
int uid = 0;
int nDecode = 0;
char *zDecode = 0;
const char *zUsername = 0;
const char *zPasswd = 0;
if( zAuth==0 ) return 0; /* Fail: No Authentication: header */
while( fossil_isspace(zAuth[0]) ) zAuth++; /* Skip leading whitespace */
if( strncmp(zAuth, "Basic ", 6)!=0 ) return 0; /* Fail: Not Basic Authentication */
/* Parse out the username and password, separated by a ":" */
zAuth += 6;
while( fossil_isspace(zAuth[0]) ) zAuth++;
zDecode = decode64(zAuth, &nDecode);
for(i=0; zDecode[i] && zDecode[i]!=':'; i++){}
if( zDecode[i] ){
zDecode[i] = 0;
zUsername = zDecode;
zPasswd = &zDecode[i+1];
/* Attempting to log in as the user provided by HTTP
** basic auth
*/
uid = login_search_uid(zUsername, zPasswd);
if( uid>0 ){
record_login_attempt(zUsername, zIpAddr, 1);
}else{
record_login_attempt(zUsername, zIpAddr, 0);
/* The user attempted to login specifically with HTTP basic
** auth, but provided invalid credentials. Inform them of
** the failed login attempt via 401.
*/
cgi_set_status(401, "Unauthorized");
cgi_reply();
fossil_exit(0);
}
}
fossil_free(zDecode);
return uid;
}
/*
** This routine examines the login cookie to see if it exists and
** is valid. If the login cookie checks out, it then sets global
** variables appropriately.
**
** g.userUid Database USER.UID value. Might be -1 for "nobody"
** g.zLogin Database USER.LOGIN value. NULL for user "nobody"
|
| ︙ | ︙ | |||
964 965 966 967 968 969 970 971 972 973 974 975 976 977 |
if( uid==0 ){
const char *zRemoteUser = P("REMOTE_USER");
if( zRemoteUser && db_get_boolean("remote_user_ok",0) ){
uid = db_int(0, "SELECT uid FROM user WHERE login=%Q"
" AND length(cap)>0 AND length(pw)>0", zRemoteUser);
}
}
/* If no user found yet, try to log in as "nobody" */
if( uid==0 ){
uid = db_int(0, "SELECT uid FROM user WHERE login='nobody'");
if( uid==0 ){
/* If there is no user "nobody", then make one up - with no privileges */
uid = -1;
| > > > > > > > > | 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 |
if( uid==0 ){
const char *zRemoteUser = P("REMOTE_USER");
if( zRemoteUser && db_get_boolean("remote_user_ok",0) ){
uid = db_int(0, "SELECT uid FROM user WHERE login=%Q"
" AND length(cap)>0 AND length(pw)>0", zRemoteUser);
}
}
/* If the request didn't provide a login cookie or the login cookie didn't
** match a known valid user, check the HTTP "Authorization" header and
** see if those credentials are valid for a known user.
*/
if( uid==0 && db_get_boolean("http_authentication_ok",0) ){
uid = logic_basic_authentication(zIpAddr);
}
/* If no user found yet, try to log in as "nobody" */
if( uid==0 ){
uid = db_int(0, "SELECT uid FROM user WHERE login='nobody'");
if( uid==0 ){
/* If there is no user "nobody", then make one up - with no privileges */
uid = -1;
|
| ︙ | ︙ | |||
1396 1397 1398 1399 1400 1401 1402 |
blob_init(&caps, db_get("default-perms", "u"), -1);
blob_init(&passwd, zPasswd, -1);
if( db_exists("SELECT 1 FROM user WHERE login=%B", &login) ){
/* Here lies the reason I don't use zErrMsg - it would not substitute
* this %s(zUsername), or at least I don't know how to force it to.*/
@ <p><span class="loginError">
| | | 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 |
blob_init(&caps, db_get("default-perms", "u"), -1);
blob_init(&passwd, zPasswd, -1);
if( db_exists("SELECT 1 FROM user WHERE login=%B", &login) ){
/* Here lies the reason I don't use zErrMsg - it would not substitute
* this %s(zUsername), or at least I don't know how to force it to.*/
@ <p><span class="loginError">
@ %h(zUsername) already exists.
@ </span></p>
}else{
char *zPw = sha1_shared_secret(blob_str(&passwd), blob_str(&login), 0);
int uid;
db_multi_exec(
"INSERT INTO user(login,pw,cap,info,mtime)"
"VALUES(%B,%Q,%B,%B,strftime('%%s','now'))",
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
139 140 141 142 143 144 145 | char *zRepositoryName; /* Name of the repository database file */ char *zLocalDbName; /* Name of the local database file */ char *zOpenRevision; /* Check-in version to use during database open */ int localOpen; /* True if the local database is open */ char *zLocalRoot; /* The directory holding the local database */ int minPrefix; /* Number of digits needed for a distinct UUID */ int eHashPolicy; /* Current hash policy. One of HPOLICY_* */ | < | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | char *zRepositoryName; /* Name of the repository database file */ char *zLocalDbName; /* Name of the local database file */ char *zOpenRevision; /* Check-in version to use during database open */ int localOpen; /* True if the local database is open */ char *zLocalRoot; /* The directory holding the local database */ int minPrefix; /* Number of digits needed for a distinct UUID */ int eHashPolicy; /* Current hash policy. One of HPOLICY_* */ int fSqlTrace; /* True if --sqltrace flag is present */ int fSqlStats; /* True if --sqltrace or --sqlstats are present */ int fSqlPrint; /* True if -sqlprint flag is present */ int fQuiet; /* True if -quiet flag is present */ int fJail; /* True if running with a chroot jail */ int fHttpTrace; /* Trace outbound HTTP requests */ int fAnyTrace; /* Any kind of tracing */ |
| ︙ | ︙ | |||
551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
#endif
int main(int argc, char **argv)
#endif
{
const char *zCmdName = "unknown";
const CmdOrPage *pCmd = 0;
int rc;
if( sqlite3_libversion_number()<3014000 ){
fossil_fatal("Unsuitable SQLite version %s, must be at least 3.14.0",
sqlite3_libversion());
}
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
memset(&g, 0, sizeof(g));
| > > | 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
#endif
int main(int argc, char **argv)
#endif
{
const char *zCmdName = "unknown";
const CmdOrPage *pCmd = 0;
int rc;
fossil_limit_memory(1);
if( sqlite3_libversion_number()<3014000 ){
fossil_fatal("Unsuitable SQLite version %s, must be at least 3.14.0",
sqlite3_libversion());
}
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
memset(&g, 0, sizeof(g));
|
| ︙ | ︙ | |||
618 619 620 621 622 623 624 |
"another flag and is treated as such. --args FILENAME may be used\n"
"in conjunction with any other flags.\n");
fossil_exit(1);
}else{
const char *zChdir = find_option("chdir",0,1);
g.isHTTP = 0;
g.rcvid = 0;
| < | 619 620 621 622 623 624 625 626 627 628 629 630 631 632 |
"another flag and is treated as such. --args FILENAME may be used\n"
"in conjunction with any other flags.\n");
fossil_exit(1);
}else{
const char *zChdir = find_option("chdir",0,1);
g.isHTTP = 0;
g.rcvid = 0;
g.fQuiet = find_option("quiet", 0, 0)!=0;
g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
g.fSshClient = 0;
g.zSshCmd = 0;
|
| ︙ | ︙ | |||
733 734 735 736 737 738 739 | atexit( fossil_atexit ); #ifdef FOSSIL_ENABLE_TH1_HOOKS /* ** The TH1 return codes from the hook will be handled as follows: ** ** TH_OK: The xFunc() and the TH1 notification will both be executed. ** | | | 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | atexit( fossil_atexit ); #ifdef FOSSIL_ENABLE_TH1_HOOKS /* ** The TH1 return codes from the hook will be handled as follows: ** ** TH_OK: The xFunc() and the TH1 notification will both be executed. ** ** TH_ERROR: The xFunc() will be skipped, the TH1 notification will be ** skipped. If the xFunc() is being hooked, the error message ** will be emitted. ** ** TH_BREAK: The xFunc() and the TH1 notification will both be skipped. ** ** TH_RETURN: The xFunc() will be executed, the TH1 notification will be ** skipped. |
| ︙ | ︙ | |||
887 888 889 890 891 892 893 |
** Verify that there are no unprocessed command-line options. If
** Any remaining command-line argument begins with "-" print
** an error message and quit.
*/
void verify_all_options(void){
int i;
for(i=1; i<g.argc; i++){
| | | 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
** Verify that there are no unprocessed command-line options. If
** Any remaining command-line argument begins with "-" print
** an error message and quit.
*/
void verify_all_options(void){
int i;
for(i=1; i<g.argc; i++){
if( g.argv[i][0]=='-' && g.argv[i][1]!=0 ){
fossil_fatal(
"unrecognized command-line option, or missing argument: %s",
g.argv[i]);
}
}
}
|
| ︙ | ︙ | |||
1059 1060 1061 1062 1063 1064 1065 |
*/
void test_version_page(void){
Blob versionInfo;
int verboseFlag;
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
| | | 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
*/
void test_version_page(void){
Blob versionInfo;
int verboseFlag;
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
verboseFlag = PD("verbose", 0) != 0;
style_header("Version Information");
style_submenu_element("Stat", "stat");
get_version_blob(&versionInfo, verboseFlag);
@ <pre>
@ %h(blob_str(&versionInfo))
@ </pre>
style_footer();
|
| ︙ | ︙ | |||
1614 1615 1616 1617 1618 1619 1620 |
}
#endif
}
/* Locate the method specified by the path and execute the function
** that implements that method.
*/
| | > > | 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 |
}
#endif
}
/* Locate the method specified by the path and execute the function
** that implements that method.
*/
if( dispatch_name_search(g.zPath-1, CMDFLAG_WEBPAGE, &pCmd)
&& dispatch_alias(g.zPath-1, &pCmd)
){
#ifdef FOSSIL_ENABLE_JSON
if(g.json.isJsonMode){
json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,0);
}else
#endif
{
#ifdef FOSSIL_ENABLE_TH1_HOOKS
|
| ︙ | ︙ | |||
1660 1661 1662 1663 1664 1665 1666 |
}else{
#ifdef FOSSIL_ENABLE_TH1_HOOKS
/*
** The TH1 return codes from the hook will be handled as follows:
**
** TH_OK: The xFunc() and the TH1 notification will both be executed.
**
| | | 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 |
}else{
#ifdef FOSSIL_ENABLE_TH1_HOOKS
/*
** The TH1 return codes from the hook will be handled as follows:
**
** TH_OK: The xFunc() and the TH1 notification will both be executed.
**
** TH_ERROR: The xFunc() will be skipped, the TH1 notification will be
** skipped. If the xFunc() is being hooked, the error message
** will be emitted.
**
** TH_BREAK: The xFunc() and the TH1 notification will both be skipped.
**
** TH_RETURN: The xFunc() will be executed, the TH1 notification will be
** skipped.
|
| ︙ | ︙ |
Changes to src/main.mk.
| ︙ | ︙ | |||
99 100 101 102 103 104 105 106 107 108 109 110 111 112 | $(SRCDIR)/purge.c \ $(SRCDIR)/rebuild.c \ $(SRCDIR)/regexp.c \ $(SRCDIR)/report.c \ $(SRCDIR)/rss.c \ $(SRCDIR)/schema.c \ $(SRCDIR)/search.c \ $(SRCDIR)/setup.c \ $(SRCDIR)/sha1.c \ $(SRCDIR)/sha1hard.c \ $(SRCDIR)/sha3.c \ $(SRCDIR)/shun.c \ $(SRCDIR)/sitemap.c \ $(SRCDIR)/skins.c \ | > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | $(SRCDIR)/purge.c \ $(SRCDIR)/rebuild.c \ $(SRCDIR)/regexp.c \ $(SRCDIR)/report.c \ $(SRCDIR)/rss.c \ $(SRCDIR)/schema.c \ $(SRCDIR)/search.c \ $(SRCDIR)/security_audit.c \ $(SRCDIR)/setup.c \ $(SRCDIR)/sha1.c \ $(SRCDIR)/sha1hard.c \ $(SRCDIR)/sha3.c \ $(SRCDIR)/shun.c \ $(SRCDIR)/sitemap.c \ $(SRCDIR)/skins.c \ |
| ︙ | ︙ | |||
153 154 155 156 157 158 159 160 161 162 163 164 165 166 | $(SRCDIR)/../skins/blitz/header.txt \ $(SRCDIR)/../skins/blitz/ticket.txt \ $(SRCDIR)/../skins/blitz_no_logo/css.txt \ $(SRCDIR)/../skins/blitz_no_logo/details.txt \ $(SRCDIR)/../skins/blitz_no_logo/footer.txt \ $(SRCDIR)/../skins/blitz_no_logo/header.txt \ $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \ $(SRCDIR)/../skins/default/css.txt \ $(SRCDIR)/../skins/default/details.txt \ $(SRCDIR)/../skins/default/footer.txt \ $(SRCDIR)/../skins/default/header.txt \ $(SRCDIR)/../skins/eagle/css.txt \ $(SRCDIR)/../skins/eagle/details.txt \ $(SRCDIR)/../skins/eagle/footer.txt \ | > > > > | 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | $(SRCDIR)/../skins/blitz/header.txt \ $(SRCDIR)/../skins/blitz/ticket.txt \ $(SRCDIR)/../skins/blitz_no_logo/css.txt \ $(SRCDIR)/../skins/blitz_no_logo/details.txt \ $(SRCDIR)/../skins/blitz_no_logo/footer.txt \ $(SRCDIR)/../skins/blitz_no_logo/header.txt \ $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \ $(SRCDIR)/../skins/bootstrap/css.txt \ $(SRCDIR)/../skins/bootstrap/details.txt \ $(SRCDIR)/../skins/bootstrap/footer.txt \ $(SRCDIR)/../skins/bootstrap/header.txt \ $(SRCDIR)/../skins/default/css.txt \ $(SRCDIR)/../skins/default/details.txt \ $(SRCDIR)/../skins/default/footer.txt \ $(SRCDIR)/../skins/default/header.txt \ $(SRCDIR)/../skins/eagle/css.txt \ $(SRCDIR)/../skins/eagle/details.txt \ $(SRCDIR)/../skins/eagle/footer.txt \ |
| ︙ | ︙ | |||
277 278 279 280 281 282 283 284 285 286 287 288 289 290 | $(OBJDIR)/purge_.c \ $(OBJDIR)/rebuild_.c \ $(OBJDIR)/regexp_.c \ $(OBJDIR)/report_.c \ $(OBJDIR)/rss_.c \ $(OBJDIR)/schema_.c \ $(OBJDIR)/search_.c \ $(OBJDIR)/setup_.c \ $(OBJDIR)/sha1_.c \ $(OBJDIR)/sha1hard_.c \ $(OBJDIR)/sha3_.c \ $(OBJDIR)/shun_.c \ $(OBJDIR)/sitemap_.c \ $(OBJDIR)/skins_.c \ | > | 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | $(OBJDIR)/purge_.c \ $(OBJDIR)/rebuild_.c \ $(OBJDIR)/regexp_.c \ $(OBJDIR)/report_.c \ $(OBJDIR)/rss_.c \ $(OBJDIR)/schema_.c \ $(OBJDIR)/search_.c \ $(OBJDIR)/security_audit_.c \ $(OBJDIR)/setup_.c \ $(OBJDIR)/sha1_.c \ $(OBJDIR)/sha1hard_.c \ $(OBJDIR)/sha3_.c \ $(OBJDIR)/shun_.c \ $(OBJDIR)/sitemap_.c \ $(OBJDIR)/skins_.c \ |
| ︙ | ︙ | |||
404 405 406 407 408 409 410 411 412 413 414 415 416 417 | $(OBJDIR)/purge.o \ $(OBJDIR)/rebuild.o \ $(OBJDIR)/regexp.o \ $(OBJDIR)/report.o \ $(OBJDIR)/rss.o \ $(OBJDIR)/schema.o \ $(OBJDIR)/search.o \ $(OBJDIR)/setup.o \ $(OBJDIR)/sha1.o \ $(OBJDIR)/sha1hard.o \ $(OBJDIR)/sha3.o \ $(OBJDIR)/shun.o \ $(OBJDIR)/sitemap.o \ $(OBJDIR)/skins.o \ | > | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | $(OBJDIR)/purge.o \ $(OBJDIR)/rebuild.o \ $(OBJDIR)/regexp.o \ $(OBJDIR)/report.o \ $(OBJDIR)/rss.o \ $(OBJDIR)/schema.o \ $(OBJDIR)/search.o \ $(OBJDIR)/security_audit.o \ $(OBJDIR)/setup.o \ $(OBJDIR)/sha1.o \ $(OBJDIR)/sha1hard.o \ $(OBJDIR)/sha3.o \ $(OBJDIR)/shun.o \ $(OBJDIR)/sitemap.o \ $(OBJDIR)/skins.o \ |
| ︙ | ︙ | |||
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
SQLITE_OPTIONS = -DNDEBUG=1 \
-DSQLITE_THREADSAFE=0 \
-DSQLITE_DEFAULT_MEMSTATUS=0 \
-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
-DSQLITE_OMIT_DECLTYPE \
-DSQLITE_OMIT_DEPRECATED \
-DSQLITE_OMIT_PROGRESS_CALLBACK \
-DSQLITE_OMIT_SHARED_CACHE \
-DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_MAX_EXPR_DEPTH=0 \
-DSQLITE_USE_ALLOCA \
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
-DSQLITE_ENABLE_FTS4 \
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
-DSQLITE_ENABLE_DBSTAT_VTAB \
-DSQLITE_ENABLE_JSON1 \
| > | > | 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 |
SQLITE_OPTIONS = -DNDEBUG=1 \
-DSQLITE_THREADSAFE=0 \
-DSQLITE_DEFAULT_MEMSTATUS=0 \
-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
-DSQLITE_OMIT_DECLTYPE \
-DSQLITE_OMIT_DEPRECATED \
-DSQLITE_OMIT_GET_TABLE \
-DSQLITE_OMIT_PROGRESS_CALLBACK \
-DSQLITE_OMIT_SHARED_CACHE \
-DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_MAX_EXPR_DEPTH=0 \
-DSQLITE_USE_ALLOCA \
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
-DSQLITE_ENABLE_FTS4 \
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
-DSQLITE_ENABLE_DBSTAT_VTAB \
-DSQLITE_ENABLE_JSON1 \
-DSQLITE_ENABLE_FTS5 \
-DSQLITE_ENABLE_STMTVTAB
# Setup the options used to compile the included SQLite shell.
SHELL_OPTIONS = -Dmain=sqlite3_shell \
-DSQLITE_SHELL_IS_UTF8=1 \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
-DSQLITE_SHELL_DBNAME_PROC=fossil_open
|
| ︙ | ︙ | |||
567 568 569 570 571 572 573 | SQLITE3_SRC. = sqlite3.c SQLITE3_SRC = $(SRCDIR)/$(SQLITE3_SRC.$(USE_SEE)) SQLITE3_SHELL_SRC.0 = shell.c SQLITE3_SHELL_SRC.1 = shell-see.c SQLITE3_SHELL_SRC. = shell.c SQLITE3_SHELL_SRC = $(SRCDIR)/$(SQLITE3_SHELL_SRC.$(USE_SEE)) SEE_FLAGS.0 = | | | 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | SQLITE3_SRC. = sqlite3.c SQLITE3_SRC = $(SRCDIR)/$(SQLITE3_SRC.$(USE_SEE)) SQLITE3_SHELL_SRC.0 = shell.c SQLITE3_SHELL_SRC.1 = shell-see.c SQLITE3_SHELL_SRC. = shell.c SQLITE3_SHELL_SRC = $(SRCDIR)/$(SQLITE3_SHELL_SRC.$(USE_SEE)) SEE_FLAGS.0 = SEE_FLAGS.1 = -DSQLITE_HAS_CODEC -DSQLITE_SHELL_DBKEY_PROC=fossil_key SEE_FLAGS. = SEE_FLAGS = $(SEE_FLAGS.$(USE_SEE)) EXTRAOBJ = \ $(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) \ $(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) \ |
| ︙ | ︙ | |||
693 694 695 696 697 698 699 700 701 702 703 704 705 706 | $(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \ $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \ $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \ $(OBJDIR)/report_.c:$(OBJDIR)/report.h \ $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \ $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \ $(OBJDIR)/search_.c:$(OBJDIR)/search.h \ $(OBJDIR)/setup_.c:$(OBJDIR)/setup.h \ $(OBJDIR)/sha1_.c:$(OBJDIR)/sha1.h \ $(OBJDIR)/sha1hard_.c:$(OBJDIR)/sha1hard.h \ $(OBJDIR)/sha3_.c:$(OBJDIR)/sha3.h \ $(OBJDIR)/shun_.c:$(OBJDIR)/shun.h \ $(OBJDIR)/sitemap_.c:$(OBJDIR)/sitemap.h \ $(OBJDIR)/skins_.c:$(OBJDIR)/skins.h \ | > | 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | $(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \ $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \ $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \ $(OBJDIR)/report_.c:$(OBJDIR)/report.h \ $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \ $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \ $(OBJDIR)/search_.c:$(OBJDIR)/search.h \ $(OBJDIR)/security_audit_.c:$(OBJDIR)/security_audit.h \ $(OBJDIR)/setup_.c:$(OBJDIR)/setup.h \ $(OBJDIR)/sha1_.c:$(OBJDIR)/sha1.h \ $(OBJDIR)/sha1hard_.c:$(OBJDIR)/sha1hard.h \ $(OBJDIR)/sha3_.c:$(OBJDIR)/sha3.h \ $(OBJDIR)/shun_.c:$(OBJDIR)/shun.h \ $(OBJDIR)/sitemap_.c:$(OBJDIR)/sitemap.h \ $(OBJDIR)/skins_.c:$(OBJDIR)/skins.h \ |
| ︙ | ︙ | |||
948 949 950 951 952 953 954 | $(XTCC) -o $(OBJDIR)/diffcmd.o -c $(OBJDIR)/diffcmd_.c $(OBJDIR)/diffcmd.h: $(OBJDIR)/headers $(OBJDIR)/dispatch_.c: $(SRCDIR)/dispatch.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/dispatch.c >$@ | | | 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | $(XTCC) -o $(OBJDIR)/diffcmd.o -c $(OBJDIR)/diffcmd_.c $(OBJDIR)/diffcmd.h: $(OBJDIR)/headers $(OBJDIR)/dispatch_.c: $(SRCDIR)/dispatch.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/dispatch.c >$@ $(OBJDIR)/dispatch.o: $(OBJDIR)/dispatch_.c $(OBJDIR)/dispatch.h $(OBJDIR)/page_index.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/dispatch.o -c $(OBJDIR)/dispatch_.c $(OBJDIR)/dispatch.h: $(OBJDIR)/headers $(OBJDIR)/doc_.c: $(SRCDIR)/doc.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/doc.c >$@ |
| ︙ | ︙ | |||
1260 1261 1262 1263 1264 1265 1266 | $(XTCC) -o $(OBJDIR)/lookslike.o -c $(OBJDIR)/lookslike_.c $(OBJDIR)/lookslike.h: $(OBJDIR)/headers $(OBJDIR)/main_.c: $(SRCDIR)/main.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/main.c >$@ | | | 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 | $(XTCC) -o $(OBJDIR)/lookslike.o -c $(OBJDIR)/lookslike_.c $(OBJDIR)/lookslike.h: $(OBJDIR)/headers $(OBJDIR)/main_.c: $(SRCDIR)/main.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/main.c >$@ $(OBJDIR)/main.o: $(OBJDIR)/main_.c $(OBJDIR)/main.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/main.o -c $(OBJDIR)/main_.c $(OBJDIR)/main.h: $(OBJDIR)/headers $(OBJDIR)/manifest_.c: $(SRCDIR)/manifest.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/manifest.c >$@ |
| ︙ | ︙ | |||
1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 | $(OBJDIR)/search_.c: $(SRCDIR)/search.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/search.c >$@ $(OBJDIR)/search.o: $(OBJDIR)/search_.c $(OBJDIR)/search.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/search.o -c $(OBJDIR)/search_.c $(OBJDIR)/search.h: $(OBJDIR)/headers $(OBJDIR)/setup_.c: $(SRCDIR)/setup.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/setup.c >$@ $(OBJDIR)/setup.o: $(OBJDIR)/setup_.c $(OBJDIR)/setup.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/setup.o -c $(OBJDIR)/setup_.c | > > > > > > > > | 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 | $(OBJDIR)/search_.c: $(SRCDIR)/search.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/search.c >$@ $(OBJDIR)/search.o: $(OBJDIR)/search_.c $(OBJDIR)/search.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/search.o -c $(OBJDIR)/search_.c $(OBJDIR)/search.h: $(OBJDIR)/headers $(OBJDIR)/security_audit_.c: $(SRCDIR)/security_audit.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/security_audit.c >$@ $(OBJDIR)/security_audit.o: $(OBJDIR)/security_audit_.c $(OBJDIR)/security_audit.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/security_audit.o -c $(OBJDIR)/security_audit_.c $(OBJDIR)/security_audit.h: $(OBJDIR)/headers $(OBJDIR)/setup_.c: $(SRCDIR)/setup.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/setup.c >$@ $(OBJDIR)/setup.o: $(OBJDIR)/setup_.c $(OBJDIR)/setup.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/setup.o -c $(OBJDIR)/setup_.c |
| ︙ | ︙ | |||
1741 1742 1743 1744 1745 1746 1747 | $(OBJDIR)/zip.h: $(OBJDIR)/headers $(OBJDIR)/sqlite3.o: $(SQLITE3_SRC) $(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $(SEE_FLAGS) \ -c $(SQLITE3_SRC) -o $@ $(OBJDIR)/shell.o: $(SQLITE3_SHELL_SRC) $(SRCDIR)/sqlite3.h | | | 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 | $(OBJDIR)/zip.h: $(OBJDIR)/headers $(OBJDIR)/sqlite3.o: $(SQLITE3_SRC) $(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $(SEE_FLAGS) \ -c $(SQLITE3_SRC) -o $@ $(OBJDIR)/shell.o: $(SQLITE3_SHELL_SRC) $(SRCDIR)/sqlite3.h $(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) $(SEE_FLAGS) $(LINENOISE_DEF.$(USE_LINENOISE)) -c $(SQLITE3_SHELL_SRC) -o $@ $(OBJDIR)/linenoise.o: $(SRCDIR)/linenoise.c $(SRCDIR)/linenoise.h $(XTCC) -c $(SRCDIR)/linenoise.c -o $@ $(OBJDIR)/th.o: $(SRCDIR)/th.c $(XTCC) -c $(SRCDIR)/th.c -o $@ |
| ︙ | ︙ |
Changes to src/makemake.tcl.
| ︙ | ︙ | |||
104 105 106 107 108 109 110 111 112 113 114 115 116 117 | purge rebuild regexp report rss schema search setup sha1 sha1hard sha3 shun sitemap skins | > | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | purge rebuild regexp report rss schema search security_audit setup sha1 sha1hard sha3 shun sitemap skins |
| ︙ | ︙ | |||
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 } #lappend SQLITE_OPTIONS -DSQLITE_ENABLE_FTS3=1 #lappend SQLITE_OPTIONS -DSQLITE_ENABLE_STAT4 #lappend SQLITE_OPTIONS -DSQLITE_WIN32_NO_ANSI #lappend SQLITE_OPTIONS -DSQLITE_WINNT_MAX_PATH_CHARS=4096 # Options used to compile the included SQLite shell. | > > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB } #lappend SQLITE_OPTIONS -DSQLITE_ENABLE_FTS3=1 #lappend SQLITE_OPTIONS -DSQLITE_ENABLE_STAT4 #lappend SQLITE_OPTIONS -DSQLITE_WIN32_NO_ANSI #lappend SQLITE_OPTIONS -DSQLITE_WINNT_MAX_PATH_CHARS=4096 # Options used to compile the included SQLite shell. |
| ︙ | ︙ | |||
385 386 387 388 389 390 391 | SQLITE3_SRC. = sqlite3.c SQLITE3_SRC = $(SRCDIR)/$(SQLITE3_SRC.$(USE_SEE)) SQLITE3_SHELL_SRC.0 = shell.c SQLITE3_SHELL_SRC.1 = shell-see.c SQLITE3_SHELL_SRC. = shell.c SQLITE3_SHELL_SRC = $(SRCDIR)/$(SQLITE3_SHELL_SRC.$(USE_SEE)) SEE_FLAGS.0 = | | | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
SQLITE3_SRC. = sqlite3.c
SQLITE3_SRC = $(SRCDIR)/$(SQLITE3_SRC.$(USE_SEE))
SQLITE3_SHELL_SRC.0 = shell.c
SQLITE3_SHELL_SRC.1 = shell-see.c
SQLITE3_SHELL_SRC. = shell.c
SQLITE3_SHELL_SRC = $(SRCDIR)/$(SQLITE3_SHELL_SRC.$(USE_SEE))
SEE_FLAGS.0 =
SEE_FLAGS.1 = -DSQLITE_HAS_CODEC -DSQLITE_SHELL_DBKEY_PROC=fossil_key
SEE_FLAGS. =
SEE_FLAGS = $(SEE_FLAGS.$(USE_SEE))
}]
writeln [string map [list <<<NEXT_LINE>>> \\] {
EXTRAOBJ = <<<NEXT_LINE>>>
$(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) <<<NEXT_LINE>>>
|
| ︙ | ︙ | |||
440 441 442 443 444 445 446 | writeln "\$(OBJDIR)/headers:\t\$(OBJDIR)/page_index.h \$(OBJDIR)/builtin_data.h \$(OBJDIR)/makeheaders \$(OBJDIR)/VERSION.h" writeln "\t\$(OBJDIR)/makeheaders $mhargs" writeln "\ttouch \$(OBJDIR)/headers" writeln "\$(OBJDIR)/headers: Makefile" writeln "\$(OBJDIR)/json.o \$(OBJDIR)/json_artifact.o \$(OBJDIR)/json_branch.o \$(OBJDIR)/json_config.o \$(OBJDIR)/json_diff.o \$(OBJDIR)/json_dir.o \$(OBJDIR)/json_finfo.o \$(OBJDIR)/json_login.o \$(OBJDIR)/json_query.o \$(OBJDIR)/json_report.o \$(OBJDIR)/json_status.o \$(OBJDIR)/json_tag.o \$(OBJDIR)/json_timeline.o \$(OBJDIR)/json_user.o \$(OBJDIR)/json_wiki.o : \$(SRCDIR)/json_detail.h" writeln "Makefile:" | | | | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
writeln "\$(OBJDIR)/headers:\t\$(OBJDIR)/page_index.h \$(OBJDIR)/builtin_data.h \$(OBJDIR)/makeheaders \$(OBJDIR)/VERSION.h"
writeln "\t\$(OBJDIR)/makeheaders $mhargs"
writeln "\ttouch \$(OBJDIR)/headers"
writeln "\$(OBJDIR)/headers: Makefile"
writeln "\$(OBJDIR)/json.o \$(OBJDIR)/json_artifact.o \$(OBJDIR)/json_branch.o \$(OBJDIR)/json_config.o \$(OBJDIR)/json_diff.o \$(OBJDIR)/json_dir.o \$(OBJDIR)/json_finfo.o \$(OBJDIR)/json_login.o \$(OBJDIR)/json_query.o \$(OBJDIR)/json_report.o \$(OBJDIR)/json_status.o \$(OBJDIR)/json_tag.o \$(OBJDIR)/json_timeline.o \$(OBJDIR)/json_user.o \$(OBJDIR)/json_wiki.o : \$(SRCDIR)/json_detail.h"
writeln "Makefile:"
set extra_h(dispatch) " \$(OBJDIR)/page_index.h "
set extra_h(builtin) " \$(OBJDIR)/builtin_data.h "
foreach s [lsort $src] {
writeln "\$(OBJDIR)/${s}_.c:\t\$(SRCDIR)/$s.c \$(OBJDIR)/translate"
writeln "\t\$(OBJDIR)/translate \$(SRCDIR)/$s.c >\$@\n"
writeln "\$(OBJDIR)/$s.o:\t\$(OBJDIR)/${s}_.c \$(OBJDIR)/$s.h$extra_h($s)\$(SRCDIR)/config.h"
writeln "\t\$(XTCC) -o \$(OBJDIR)/$s.o -c \$(OBJDIR)/${s}_.c\n"
writeln "\$(OBJDIR)/$s.h:\t\$(OBJDIR)/headers\n"
}
writeln "\$(OBJDIR)/sqlite3.o:\t\$(SQLITE3_SRC)"
writeln "\t\$(XTCC) \$(SQLITE_OPTIONS) \$(SQLITE_CFLAGS) \$(SEE_FLAGS) \\"
writeln "\t\t-c \$(SQLITE3_SRC) -o \$@"
writeln "\$(OBJDIR)/shell.o:\t\$(SQLITE3_SHELL_SRC) \$(SRCDIR)/sqlite3.h"
writeln "\t\$(XTCC) \$(SHELL_OPTIONS) \$(SHELL_CFLAGS) \$(SEE_FLAGS) \$(LINENOISE_DEF.\$(USE_LINENOISE)) -c \$(SQLITE3_SHELL_SRC) -o \$@\n"
writeln "\$(OBJDIR)/linenoise.o:\t\$(SRCDIR)/linenoise.c \$(SRCDIR)/linenoise.h"
writeln "\t\$(XTCC) -c \$(SRCDIR)/linenoise.c -o \$@\n"
writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
writeln "\t\$(XTCC) -c \$(SRCDIR)/th.c -o \$@\n"
|
| ︙ | ︙ | |||
671 672 673 674 675 676 677 | endif #### The directories where the OpenSSL include and library files are located. # The recommended usage here is to use the Sysinternals junction tool # to create a hard link between an "openssl-1.x" sub-directory of the # Fossil source code directory and the target OpenSSL source directory. # | | | 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | endif #### The directories where the OpenSSL include and library files are located. # The recommended usage here is to use the Sysinternals junction tool # to create a hard link between an "openssl-1.x" sub-directory of the # Fossil source code directory and the target OpenSSL source directory. # OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2l OPENSSLINCDIR = $(OPENSSLDIR)/include OPENSSLLIBDIR = $(OPENSSLDIR) #### Either the directory where the Tcl library is installed or the Tcl # source code directory resides (depending on the value of the macro # FOSSIL_TCL_SOURCE). If this points to the Tcl install directory, # this directory must have "include" and "lib" sub-directories. If |
| ︙ | ︙ | |||
726 727 728 729 730 731 732 | #### C compiler and options for use in building executables that will # run on the target platform. This is usually the almost the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # | | | 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 | #### C compiler and options for use in building executables that will # run on the target platform. This is usually the almost the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # TCC = $(PREFIX)$(TCCEXE) -Wall -Wdeclaration-after-statement #### Add the necessary command line options to build with debugging # symbols, if enabled. # ifdef FOSSIL_ENABLE_SYMBOLS TCC += -g else |
| ︙ | ︙ | |||
1070 1071 1072 1073 1074 1075 1076 | SQLITE3_SRC. = sqlite3.c SQLITE3_SRC = $(SRCDIR)/$(SQLITE3_SRC.$(USE_SEE)) SQLITE3_SHELL_SRC.0 = shell.c SQLITE3_SHELL_SRC.1 = shell-see.c SQLITE3_SHELL_SRC. = shell.c SQLITE3_SHELL_SRC = $(SRCDIR)/$(SQLITE3_SHELL_SRC.$(USE_SEE)) SEE_FLAGS.0 = | | | 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 |
SQLITE3_SRC. = sqlite3.c
SQLITE3_SRC = $(SRCDIR)/$(SQLITE3_SRC.$(USE_SEE))
SQLITE3_SHELL_SRC.0 = shell.c
SQLITE3_SHELL_SRC.1 = shell-see.c
SQLITE3_SHELL_SRC. = shell.c
SQLITE3_SHELL_SRC = $(SRCDIR)/$(SQLITE3_SHELL_SRC.$(USE_SEE))
SEE_FLAGS.0 =
SEE_FLAGS.1 = -DSQLITE_HAS_CODEC -DSQLITE_SHELL_DBKEY_PROC=fossil_key
SEE_FLAGS. =
SEE_FLAGS = $(SEE_FLAGS.$(USE_SEE))
}
writeln [string map [list <<<NEXT_LINE>>> \\] {
EXTRAOBJ = <<<NEXT_LINE>>>
$(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) <<<NEXT_LINE>>>
|
| ︙ | ︙ | |||
1211 1212 1213 1214 1215 1216 1217 | writeln "\t\t-c \$(SQLITE3_SRC) -o \$@\n" writeln "\$(OBJDIR)/cson_amalgamation.o:\t\$(SRCDIR)/cson_amalgamation.c" writeln "\t\$(XTCC) -c \$(SRCDIR)/cson_amalgamation.c -o \$@\n" writeln "\$(OBJDIR)/json.o \$(OBJDIR)/json_artifact.o \$(OBJDIR)/json_branch.o \$(OBJDIR)/json_config.o \$(OBJDIR)/json_diff.o \$(OBJDIR)/json_dir.o \$(OBJDIR)/jsos_finfo.o \$(OBJDIR)/json_login.o \$(OBJDIR)/json_query.o \$(OBJDIR)/json_report.o \$(OBJDIR)/json_status.o \$(OBJDIR)/json_tag.o \$(OBJDIR)/json_timeline.o \$(OBJDIR)/json_user.o \$(OBJDIR)/json_wiki.o : \$(SRCDIR)/json_detail.h\n" writeln "\$(OBJDIR)/shell.o:\t\$(SQLITE3_SHELL_SRC) \$(SRCDIR)/sqlite3.h \$(SRCDIR)/../win/Makefile.mingw" | | | 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 | writeln "\t\t-c \$(SQLITE3_SRC) -o \$@\n" writeln "\$(OBJDIR)/cson_amalgamation.o:\t\$(SRCDIR)/cson_amalgamation.c" writeln "\t\$(XTCC) -c \$(SRCDIR)/cson_amalgamation.c -o \$@\n" writeln "\$(OBJDIR)/json.o \$(OBJDIR)/json_artifact.o \$(OBJDIR)/json_branch.o \$(OBJDIR)/json_config.o \$(OBJDIR)/json_diff.o \$(OBJDIR)/json_dir.o \$(OBJDIR)/jsos_finfo.o \$(OBJDIR)/json_login.o \$(OBJDIR)/json_query.o \$(OBJDIR)/json_report.o \$(OBJDIR)/json_status.o \$(OBJDIR)/json_tag.o \$(OBJDIR)/json_timeline.o \$(OBJDIR)/json_user.o \$(OBJDIR)/json_wiki.o : \$(SRCDIR)/json_detail.h\n" writeln "\$(OBJDIR)/shell.o:\t\$(SQLITE3_SHELL_SRC) \$(SRCDIR)/sqlite3.h \$(SRCDIR)/../win/Makefile.mingw" writeln "\t\$(XTCC) \$(SHELL_OPTIONS) \$(SHELL_CFLAGS) \$(SEE_FLAGS) -c \$(SQLITE3_SHELL_SRC) -o \$@\n" writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c" writeln "\t\$(XTCC) -c \$(SRCDIR)/th.c -o \$@\n" writeln "\$(OBJDIR)/th_lang.o:\t\$(SRCDIR)/th_lang.c" writeln "\t\$(XTCC) -c \$(SRCDIR)/th_lang.c -o \$@\n" |
| ︙ | ︙ | |||
1502 1503 1504 1505 1506 1507 1508 | # Enable support for the SQLite Encryption Extension? !ifndef USE_SEE USE_SEE = 0 !endif !if $(FOSSIL_ENABLE_SSL)!=0 | | | 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 | # Enable support for the SQLite Encryption Extension? !ifndef USE_SEE USE_SEE = 0 !endif !if $(FOSSIL_ENABLE_SSL)!=0 SSLDIR = $(B)\compat\openssl-1.0.2l SSLINCDIR = $(SSLDIR)\inc32 !if $(FOSSIL_DYNAMIC_BUILD)!=0 SSLLIBDIR = $(SSLDIR)\out32dll !else SSLLIBDIR = $(SSLDIR)\out32 !endif SSLLFLAGS = /nologo /opt:ref /debug |
| ︙ | ︙ | |||
1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 | mkversion$E: $(SRCDIR)\mkversion.c $(BCC) $** codecheck1$E: $(SRCDIR)\codecheck1.c $(BCC) $** !if $(USE_SEE)!=0 SQLITE3_SHELL_SRC = $(SRCDIR)\shell-see.c !else SQLITE3_SHELL_SRC = $(SRCDIR)\shell.c !endif $(OX)\shell$O : $(SQLITE3_SHELL_SRC) $B\win\Makefile.msc | > > > > | < < < < < < | 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 | mkversion$E: $(SRCDIR)\mkversion.c $(BCC) $** codecheck1$E: $(SRCDIR)\codecheck1.c $(BCC) $** !if $(USE_SEE)!=0 SEE_FLAGS = /DSQLITE_HAS_CODEC=1 /DSQLITE_SHELL_DBKEY_PROC=fossil_key SQLITE3_SHELL_SRC = $(SRCDIR)\shell-see.c SQLITE3_SRC = $(SRCDIR)\sqlite3-see.c !else SEE_FLAGS = SQLITE3_SHELL_SRC = $(SRCDIR)\shell.c SQLITE3_SRC = $(SRCDIR)\sqlite3.c !endif $(OX)\shell$O : $(SQLITE3_SHELL_SRC) $B\win\Makefile.msc $(TCC) /Fo$@ $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) $(SEE_FLAGS) -c $(SQLITE3_SHELL_SRC) $(OX)\sqlite3$O : $(SQLITE3_SRC) $B\win\Makefile.msc $(TCC) /Fo$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $(SEE_FLAGS) $(SQLITE3_SRC) $(OX)\th$O : $(SRCDIR)\th.c $(TCC) /Fo$@ -c $** |
| ︙ | ︙ |
Changes to src/manifest.c.
| ︙ | ︙ | |||
802 803 804 805 806 807 808 |
** Identify the user who created this control file by their
** login. Only one U line is allowed. Prohibited in clusters.
** If the user name is omitted, take that to be "anonymous".
*/
case 'U': {
if( p->zUser!=0 ) SYNTAX("more than one U-card");
p->zUser = next_token(&x, 0);
| | | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
** Identify the user who created this control file by their
** login. Only one U line is allowed. Prohibited in clusters.
** If the user name is omitted, take that to be "anonymous".
*/
case 'U': {
if( p->zUser!=0 ) SYNTAX("more than one U-card");
p->zUser = next_token(&x, 0);
if( p->zUser==0 || p->zUser[0]==0 ){
p->zUser = "anonymous";
}else{
defossilize(p->zUser);
}
break;
}
|
| ︙ | ︙ | |||
1244 1245 1246 1247 1248 1249 1250 |
db_bind_int(&s1, ":n", fnid);
db_bind_int(&s1, ":pfn", pfnid);
db_bind_int(&s1, ":mp", mperm);
db_bind_int(&s1, ":isaux", isPrimary==0);
db_exec(&s1);
}
if( pid && fid ){
| | | 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
db_bind_int(&s1, ":n", fnid);
db_bind_int(&s1, ":pfn", pfnid);
db_bind_int(&s1, ":mp", mperm);
db_bind_int(&s1, ":isaux", isPrimary==0);
db_exec(&s1);
}
if( pid && fid ){
content_deltify(pid, &fid, 1, 0);
}
}
/*
** Do a binary search to find a file in the p->aFile[] array.
**
** As an optimization, guess that the file we seek is at index p->iFile.
|
| ︙ | ︙ | |||
1433 1434 1435 1436 1437 1438 1439 |
}
/* Try to make the parent manifest a delta from the child, if that
** is an appropriate thing to do. For a new baseline, make the
** previous baseline a delta from the current baseline.
*/
if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){
| | | | 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 |
}
/* Try to make the parent manifest a delta from the child, if that
** is an appropriate thing to do. For a new baseline, make the
** previous baseline a delta from the current baseline.
*/
if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){
content_deltify(pmid, &mid, 1, 0);
}else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){
content_deltify(pParent->pBaseline->rid, &mid, 1, 0);
}
/* Remember all children less than a few seconds younger than their parent,
** as we might want to fudge the times for those children.
*/
if( pChild->rDate<pParent->rDate+AGE_FUDGE_WINDOW
&& manifest_crosslink_busy
|
| ︙ | ︙ | |||
2057 2058 2059 2060 2061 2062 2063 |
prior = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=%d AND mtime<%.17g"
" ORDER BY mtime DESC",
tagid, p->rDate
);
if( prior ){
| | | 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 |
prior = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=%d AND mtime<%.17g"
" ORDER BY mtime DESC",
tagid, p->rDate
);
if( prior ){
content_deltify(prior, &rid, 1, 0);
}
if( nWiki>0 ){
zComment = mprintf("Changes to wiki page [%h]", p->zWikiTitle);
}else{
zComment = mprintf("Deleted wiki page [%h]", p->zWikiTitle);
}
search_doc_touch('w',rid,p->zWikiTitle);
|
| ︙ | ︙ | |||
2104 2105 2106 2107 2108 2109 2110 |
subsequent = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=%d AND mtime>=%.17g AND rid!=%d"
" ORDER BY mtime",
tagid, p->rDate, rid
);
if( prior ){
| | | | 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 |
subsequent = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=%d AND mtime>=%.17g AND rid!=%d"
" ORDER BY mtime",
tagid, p->rDate, rid
);
if( prior ){
content_deltify(prior, &rid, 1, 0);
if( !subsequent ){
db_multi_exec(
"DELETE FROM event"
" WHERE type='e'"
" AND tagid=%d"
" AND objid IN (SELECT rid FROM tagxref WHERE tagid=%d)",
tagid, tagid
);
}
}
if( subsequent ){
content_deltify(rid, &subsequent, 1, 0);
}else{
search_doc_touch('e',rid,0);
db_multi_exec(
"REPLACE INTO event(type,mtime,objid,tagid,user,comment,bgcolor)"
"VALUES('e',%.17g,%d,%d,%Q,%Q,"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
p->rEventDate, rid, tagid, p->zUser, p->zComment,
|
| ︙ | ︙ |
Changes to src/markdown.c.
| ︙ | ︙ | |||
457 458 459 460 461 462 463 |
/* find_emph_char -- looks for the next emph char, skipping other constructs */
static size_t find_emph_char(char *data, size_t size, char c){
size_t i = 1;
while( i<size ){
while( i<size && data[i]!=c && data[i]!='`' && data[i]!='[' ){ i++; }
if( i>=size ) return 0;
| < > > | 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
/* find_emph_char -- looks for the next emph char, skipping other constructs */
static size_t find_emph_char(char *data, size_t size, char c){
size_t i = 1;
while( i<size ){
while( i<size && data[i]!=c && data[i]!='`' && data[i]!='[' ){ i++; }
if( i>=size ) return 0;
/* not counting escaped chars */
if( i && data[i-1]=='\\' ){
i++;
continue;
}
if( data[i]==c ) return i;
/* skipping a code span */
if( data[i]=='`' ){
size_t span_nb = 0, bt;
size_t tmp_i = 0;
/* counting the number of opening backticks */
|
| ︙ | ︙ |
Changes to src/markdown.md.
1 2 3 4 | # Markdown Overview # ## Paragraphs ## | | > | | | | > > > > > > | | > > > > > > | | | < > > > > | | | > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > | | > | | < > > | > | | | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# Markdown Overview #
## Paragraphs ##
> Paragraphs are divided by blank lines.
> End a line with two or more spaces to force a mid-paragraph line break.
## Headings ##
>
# Top Level Heading Alternative Top Level Heading
# Top Level Heading Variant # =============================
>
## 2nd Level Heading Alternative 2nd Level Heading
## 2nd Level Heading Variant ## -----------------------------
>
### 3rd Level Heading ### 3rd Level Heading Variant ###
#### 4th Level Heading #### 4th Level Heading Variant ####
##### 5th Level Heading ##### 5th Level Heading Variant #####
###### 6th Level Heading ###### 6th Level Heading Variant ######
## Links ##
> 1. **\[display text\]\(URL\)**
> 2. **\[display text\]\(URL "Title"\)**
> 3. **\[display text\]\(URL 'Title'\)**
> 4. **\<URL\>**
> 5. **\[display text\]\[label\]**
> 6. **\[display text\]\[\]**
> **URL** may optionally be written **\<URL\>**. With link formats 5 and 6
> ("reference links"), the URL is supplied elsewhere in the document, as shown
> below. Link format 6 reuses the display text as the label. Labels are
> case-insensitive. The title may be split onto the next line with optional
> indenting.
> * **\[label\]: URL**
> * **\[label\]: URL "Title"**
> * **\[label\]: URL 'Title'**
> * **\[label\]: URL (Title)**
## Fonts ##
> * _\*italic\*_
> * *\_italic\_*
> * __\*\*bold\*\*__
> * **\_\_bold\_\_**
> * ___\*\*\*italic+bold\*\*\*___
> * ***\_\_\_italic+bold\_\_\_***
> * \``code`\`
> The **\`code\`** construct disables HTML markup, so one can write, for
> example, **\`\<html\>\`** to yield **`<html>`**.
## Lists ##
>
* bullet item
+ bullet item
- bullet item
1. numbered item
> A two-level list is created by placing additional whitespace before the
> **\***/**+**/**-**/**1.** of the secondary items.
>
* top-level item
* secondary item
## Block Quotes ##
> Begin each line of a paragraph with **>** to block quote that paragraph.
> >
> This paragraph is indented
> >
> > Double-indented paragraph
> Begin each line with at least four spaces or one tab to produce a verbatim
> code block.
## Tables ##
>
| Header 1 | Header 2 | Header 3 |
----------------------------------------------
| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |
|:Left-aligned |:Centered :| Right-aligned:|
| | ← Blank → | |
| Row 4 Col 1 | Row 4 Col 2 | Row 4 Col 3 |
> The first row is a header if followed by a horizontal rule or a blank line.
> Placing **:** at the left, both, or right sides of a cell gives left-aligned,
> centered, or right-aligned text, respectively. By default, header cells are
> centered, and body cells are left-aligned.
> The leftmost **\|** is required if the first column contains at least one
> blank cell. The rightmost **\|** is optional.
## Miscellaneous ##
> * In-line images are made using **\!\[alt-text\]\(image-URL\)**.
> * Use HTML for advanced formatting such as forms.
> * **\<!--** HTML-style comments **-->** are supported.
> * Escape special characters (ex: **\[** **\(** **\|** **\***)
> using backslash (ex: **\\\[** **\\\(** **\\\|** **\\\***).
> * A line consisting of **---**, **\*\*\***, or **\_\_\_** is a horizontal
> rule. Spaces and extra **-**/**\***/**_** are allowed.
> * See [daringfireball.net][] for additional information.
> * See this page's [Markdown source](/md_rules?txt=1) for complex examples.
## Special Features For Fossil ##
> * In hyperlinks, if the URL begins with **/** then the root of the Fossil
> repository is prepended. This allows for repository-relative hyperlinks.
> * For documents that begin with a top-level heading (ex: **# heading #**),
> the heading is omitted from the body of the document and becomes the
> document title displayed at the top of the Fossil page.
[daringfireball.net]: http://daringfireball.net/projects/markdown/syntax
|
Changes to src/markdown_html.c.
| ︙ | ︙ | |||
295 296 297 298 299 300 301 |
html_escape(ob, blob_buffer(link), blob_size(link));
}
BLOB_APPEND_LITERAL(ob, "</a>");
return 1;
}
static int html_code_span(struct Blob *ob, struct Blob *text, void *opaque){
| > | | | > | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
html_escape(ob, blob_buffer(link), blob_size(link));
}
BLOB_APPEND_LITERAL(ob, "</a>");
return 1;
}
static int html_code_span(struct Blob *ob, struct Blob *text, void *opaque){
if( text ){
BLOB_APPEND_LITERAL(ob, "<code>");
html_escape(ob, blob_buffer(text), blob_size(text));
BLOB_APPEND_LITERAL(ob, "</code>");
}
return 1;
}
static int html_double_emphasis(
struct Blob *ob,
struct Blob *text,
char c,
|
| ︙ | ︙ | |||
402 403 404 405 406 407 408 |
** output_title is NULL, the document title appears in the body.
*/
void markdown_to_html(
struct Blob *input_markdown, /* Markdown content to be rendered */
struct Blob *output_title, /* Put title here. May be NULL */
struct Blob *output_body /* Put document body here. */
){
| > > > | | > | > > > > > > > > > | 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
** output_title is NULL, the document title appears in the body.
*/
void markdown_to_html(
struct Blob *input_markdown, /* Markdown content to be rendered */
struct Blob *output_title, /* Put title here. May be NULL */
struct Blob *output_body /* Put document body here. */
){
blob_reset(output_body);
char * markdown_string = blob_str(input_markdown);
char *cmark_result = cmark_markdown_to_html(markdown_string, blob_size(input_markdown), 0 );
if( output_title ) {
blob_reset(output_title);
if (strlen(markdown_string) > 0 && markdown_string[0] == '#' ) {
if (strlen(markdown_string + 1) > 0) {
int i = 1;
while (markdown_string[i]!='\0' &&
(markdown_string[i]!='\n' && markdown_string[i]!='\r') ) {
blob_append(output_title, markdown_string+i, 1);
i++;
}
}
}
}
html_prolog(output_body,0);
blob_append(output_body, cmark_result, strlen(cmark_result));
html_epilog(output_body,0);
free(cmark_result);
}
|
Changes to src/merge.c.
| ︙ | ︙ | |||
204 205 206 207 208 209 210 | ** ** -f|--force Force the merge even if it would be a no-op. ** ** --force-missing Force the merge even if there is missing content. ** ** --integrate Merged branch will be closed when committing. ** | < < | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
**
** -f|--force Force the merge even if it would be a no-op.
**
** --force-missing Force the merge even if there is missing content.
**
** --integrate Merged branch will be closed when committing.
**
** -n|--dry-run If given, display instead of run actions
**
** -v|--verbose Show additional details of the merge
*/
void merge_cmd(void){
int vid; /* Current version "V" */
int mid; /* Version we are merging from "M" */
|
| ︙ | ︙ |
Changes to src/merge3.c.
| ︙ | ︙ | |||
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
** cp Xup.c Xbase.c
** # Verify that everything still works
** fossil commit
**
*/
void delta_3waymerge_cmd(void){
Blob pivot, v1, v2, merged;
/* We should be done with options.. */
verify_all_options();
if( g.argc!=6 ){
usage("PIVOT V1 V2 MERGED");
}
if( blob_read_from_file(&pivot, g.argv[2])<0 ){
fossil_fatal("cannot read %s", g.argv[2]);
}
if( blob_read_from_file(&v1, g.argv[3])<0 ){
fossil_fatal("cannot read %s", g.argv[3]);
}
if( blob_read_from_file(&v2, g.argv[4])<0 ){
fossil_fatal("cannot read %s", g.argv[4]);
}
| > | > | 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
** cp Xup.c Xbase.c
** # Verify that everything still works
** fossil commit
**
*/
void delta_3waymerge_cmd(void){
Blob pivot, v1, v2, merged;
int nConflict;
/* We should be done with options.. */
verify_all_options();
if( g.argc!=6 ){
usage("PIVOT V1 V2 MERGED");
}
if( blob_read_from_file(&pivot, g.argv[2])<0 ){
fossil_fatal("cannot read %s", g.argv[2]);
}
if( blob_read_from_file(&v1, g.argv[3])<0 ){
fossil_fatal("cannot read %s", g.argv[3]);
}
if( blob_read_from_file(&v2, g.argv[4])<0 ){
fossil_fatal("cannot read %s", g.argv[4]);
}
nConflict = blob_merge(&pivot, &v1, &v2, &merged);
if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){
fossil_fatal("cannot write %s", g.argv[4]);
}
blob_reset(&pivot);
blob_reset(&v1);
blob_reset(&v2);
blob_reset(&merged);
if( nConflict>0 ) fossil_warning("WARNING: %d merge conflicts", nConflict);
}
/*
** aSubst is an array of string pairs. The first element of each pair is
** a string that begins with %. The second element is a replacement for that
** string.
**
|
| ︙ | ︙ |
Changes to src/mkindex.c.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 | ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ******************************************************************************* ** | | | | < < > | | < < < > > > > > > | | > > > > > > > > > > | | | | | > > > > > > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** This utility program scans Fossil source text looking for specially
** formatted comments and generates C source code for constant tables
** that define the behavior of commands, webpages, and settings.
**
** The source code is scanned for comment lines of the form:
**
** WEBPAGE: /abc/xyz
** COMMAND: cmdname
** SETTING: access-log
**
** The WEBPAGE and COMMAND comments should be followed by a function that
** implements the webpage or command. The form of this function is:
**
** void function_name(void){
**
** Command names can divided into three classes: 1st-tier, 2nd-tier,
** and test. 1st-tier commands are the most frequently used and the
** ones that show up with "fossil help". 2nd-tier are seldom-used and/or
** legacy command. Test commands are unsupported commands used for testing
** and analysis only.
**
** Commands are 1st-tier by default. If the command name begins with
** "test-" or if the command name has a "test" argument, then it becomes
** a test command. If the command name has a "2nd-tier" argument or ends
** with a "*" character, it is second tier. Examples:
**
** COMMAND: abcde*
** COMMAND: fghij 2nd-tier
** COMMAND: test-xyzzy
** COMMAND: xyzzy test
**
** A SETTING: may be followed by arguments that give additional attributes
** to that setting:
**
** SETTING: clean-blob versionable width=40 block-text
** SETTING: auto-shun boolean default=on
**
** New arguments may be added in future releases that set additional
** bits in the eCmdFlags field.
**
** Additional lines of comment after the COMMAND: or WEBPAGE: or SETTING:
** become the built-in help text for that command or webpage or setting.
**
** Multiple COMMAND: entries can be attached to the same command, thus
** creating multiple aliases for that command. Similarly, multiple
** WEBPAGE: entries can be attached to the same webpage function, to give
** that page aliases.
**
** For SETTING: entries, the default value for the setting can be specified
** using a default=VALUE argument if the default contains no spaces. If the
** default value does contain spaces, use a separate line like this:
**
** SETTING: pgp-command
** DEFAULT: gpg --clearsign -o
**
** If no default is supplied, the default is assumed to be an empty string
** or "off" in the case of a boolean.
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
/***************************************************************************
** These macros must match similar macros in dispatch.c.
**
** Allowed values for CmdOrPage.eCmdFlags. */
#define CMDFLAG_1ST_TIER 0x0001 /* Most important commands */
#define CMDFLAG_2ND_TIER 0x0002 /* Obscure and seldom used commands */
#define CMDFLAG_TEST 0x0004 /* Commands for testing only */
#define CMDFLAG_WEBPAGE 0x0008 /* Web pages */
#define CMDFLAG_COMMAND 0x0010 /* A command */
#define CMDFLAG_SETTING 0x0020 /* A setting */
#define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
#define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
#define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
/**************************************************************************/
/*
** Each entry looks like this:
*/
typedef struct Entry {
int eType; /* CMDFLAG_* values */
char *zIf; /* Enclose in #if */
char *zFunc; /* Name of implementation */
char *zPath; /* Webpage or command name */
char *zHelp; /* Help text */
char *zDflt; /* Default value for settings */
char *zVar; /* config.name for settings, if different from zPath */
int iHelp; /* Index of Help text */
int iWidth; /* Display width for SETTING: values */
} Entry;
/*
** Maximum number of entries
*/
#define N_ENTRY 5000
|
| ︙ | ︙ | |||
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
aEntry[nUsed].eType |= CMDFLAG_1ST_TIER;
}else if( j==8 && strncmp(&zLine[i], "2nd-tier", j)==0 ){
aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_TEST);
aEntry[nUsed].eType |= CMDFLAG_2ND_TIER;
}else if( j==4 && strncmp(&zLine[i], "test", j)==0 ){
aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_2ND_TIER);
aEntry[nUsed].eType |= CMDFLAG_TEST;
}else{
fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
zFile, nLine, j, &zLine[i]);
nErr++;
}
}
nUsed++;
}
/*
** Check to see if the current line is an #if and if it is, add it to
** the zIf[] string. If the current line is an #endif or #else or #elif
** then cancel the current zIf[] string.
*/
| > > > > > > > > > > > > > > > > | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
aEntry[nUsed].eType |= CMDFLAG_1ST_TIER;
}else if( j==8 && strncmp(&zLine[i], "2nd-tier", j)==0 ){
aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_TEST);
aEntry[nUsed].eType |= CMDFLAG_2ND_TIER;
}else if( j==4 && strncmp(&zLine[i], "test", j)==0 ){
aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_2ND_TIER);
aEntry[nUsed].eType |= CMDFLAG_TEST;
}else if( j==7 && strncmp(&zLine[i], "boolean", j)==0 ){
aEntry[nUsed].eType &= ~(CMDFLAG_BLOCKTEXT);
aEntry[nUsed].iWidth = 0;
aEntry[nUsed].eType |= CMDFLAG_BOOLEAN;
}else if( j==10 && strncmp(&zLine[i], "block-text", j)==0 ){
aEntry[nUsed].eType &= ~(CMDFLAG_BOOLEAN);
aEntry[nUsed].eType |= CMDFLAG_BLOCKTEXT;
}else if( j==11 && strncmp(&zLine[i], "versionable", j)==0 ){
aEntry[nUsed].eType |= CMDFLAG_VERSIONABLE;
}else if( j>6 && strncmp(&zLine[i], "width=", 6)==0 ){
aEntry[nUsed].iWidth = atoi(&zLine[i+6]);
}else if( j>8 && strncmp(&zLine[i], "default=", 8)==0 ){
aEntry[nUsed].zDflt = string_dup(&zLine[i+8], j-8);
}else if( j>9 && strncmp(&zLine[i], "variable=", 9)==0 ){
aEntry[nUsed].zVar = string_dup(&zLine[i+9], j-9);
}else{
fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
zFile, nLine, j, &zLine[i]);
nErr++;
}
}
nUsed++;
return;
}
/*
** Check to see if the current line is an #if and if it is, add it to
** the zIf[] string. If the current line is an #endif or #else or #elif
** then cancel the current zIf[] string.
*/
|
| ︙ | ︙ | |||
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
if( strncmp(&zLine[i],"if",2)==0 ){
zIf[0] = '#';
memcpy(&zIf[1], &zLine[i], len+1);
}else if( zLine[i]=='e' ){
zIf[0] = 0;
}
}
/*
** Scan a line for a function that implements a web page or command.
*/
void scan_for_func(char *zLine){
int i,j,k;
char *z;
if( nUsed<=nFixed ) return;
if( strncmp(zLine, "**", 2)==0
&& fossil_isspace(zLine[2])
&& strlen(zLine)<sizeof(zHelp)-nHelp-1
&& nUsed>nFixed
&& strncmp(zLine,"** COMMAND:",11)!=0
&& strncmp(zLine,"** WEBPAGE:",11)!=0
){
if( zLine[2]=='\n' ){
zHelp[nHelp++] = '\n';
}else{
if( strncmp(&zLine[3], "Usage: ", 6)==0 ) nHelp = 0;
strcpy(&zHelp[nHelp], &zLine[3]);
nHelp += strlen(&zHelp[nHelp]);
}
return;
}
for(i=0; fossil_isspace(zLine[i]); i++){}
if( zLine[i]==0 ) return;
| > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | > | > | | | > | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
if( strncmp(&zLine[i],"if",2)==0 ){
zIf[0] = '#';
memcpy(&zIf[1], &zLine[i], len+1);
}else if( zLine[i]=='e' ){
zIf[0] = 0;
}
}
/*
** Check to see if the current line is a "** DEFAULT: ..." line for a
** SETTING definition. If so, remember the default value.
*/
void scan_for_default(const char *zLine){
int len;
const char *z;
if( nUsed<1 ) return;
if( (aEntry[nUsed-1].eType & CMDFLAG_SETTING)==0 ) return;
if( strncmp(zLine, "** DEFAULT: ", 12)!=0 ) return;
z = zLine + 12;
while( fossil_isspace(z[0]) ) z++;
len = (int)strlen(z);
while( len>0 && fossil_isspace(z[len-1]) ){ len--; }
aEntry[nUsed-1].zDflt = string_dup(z,len);
}
/*
** Scan a line for a function that implements a web page or command.
*/
void scan_for_func(char *zLine){
int i,j,k;
char *z;
int isSetting;
if( nUsed<=nFixed ) return;
if( strncmp(zLine, "**", 2)==0
&& fossil_isspace(zLine[2])
&& strlen(zLine)<sizeof(zHelp)-nHelp-1
&& nUsed>nFixed
&& strncmp(zLine,"** COMMAND:",11)!=0
&& strncmp(zLine,"** WEBPAGE:",11)!=0
&& strncmp(zLine,"** SETTING:",11)!=0
&& strncmp(zLine,"** DEFAULT:",11)!=0
){
if( zLine[2]=='\n' ){
zHelp[nHelp++] = '\n';
}else{
if( strncmp(&zLine[3], "Usage: ", 6)==0 ) nHelp = 0;
strcpy(&zHelp[nHelp], &zLine[3]);
nHelp += strlen(&zHelp[nHelp]);
}
return;
}
for(i=0; fossil_isspace(zLine[i]); i++){}
if( zLine[i]==0 ) return;
isSetting = (aEntry[nFixed].eType & CMDFLAG_SETTING)!=0;
if( !isSetting ){
if( strncmp(&zLine[i],"void",4)!=0 ){
if( zLine[i]!='*' ) goto page_skip;
return;
}
i += 4;
if( !fossil_isspace(zLine[i]) ) goto page_skip;
while( fossil_isspace(zLine[i]) ){ i++; }
for(j=0; fossil_isident(zLine[i+j]); j++){}
if( j==0 ) goto page_skip;
}
for(k=nHelp-1; k>=0 && fossil_isspace(zHelp[k]); k--){}
nHelp = k+1;
zHelp[nHelp] = 0;
for(k=0; k<nHelp && fossil_isspace(zHelp[k]); k++){}
if( k<nHelp ){
z = string_dup(&zHelp[k], nHelp-k);
}else{
z = "";
}
for(k=nFixed; k<nUsed; k++){
aEntry[k].zIf = zIf[0] ? string_dup(zIf, -1) : 0;
aEntry[k].zFunc = isSetting ? "0" : string_dup(&zLine[i], j);
aEntry[k].zHelp = z;
z = 0;
aEntry[k].iHelp = nFixed;
}
if( !isSetting ){
i+=j;
while( fossil_isspace(zLine[i]) ){ i++; }
if( zLine[i]!='(' ) goto page_skip;
}
nFixed = nUsed;
nHelp = 0;
return;
page_skip:
for(i=nFixed; i<nUsed; i++){
fprintf(stderr,"%s:%d: skipping page \"%s\"\n",
|
| ︙ | ︙ | |||
339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
"** This file was generated by the mkindex.exe program based on\n"
"** comments in other Fossil source files.\n"
"*/\n"
);
/* Output declarations for all the action functions */
for(i=0; i<nFixed; i++){
if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
printf("extern void %s(void);\n", aEntry[i].zFunc);
if( aEntry[i].zIf ) printf("#endif\n");
}
/* Output strings for all the help text */
for(i=0; i<nFixed; i++){
| > | 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
"** This file was generated by the mkindex.exe program based on\n"
"** comments in other Fossil source files.\n"
"*/\n"
);
/* Output declarations for all the action functions */
for(i=0; i<nFixed; i++){
if( aEntry[i].eType & CMDFLAG_SETTING ) continue;
if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
printf("extern void %s(void);\n", aEntry[i].zFunc);
if( aEntry[i].zIf ) printf("#endif\n");
}
/* Output strings for all the help text */
for(i=0; i<nFixed; i++){
|
| ︙ | ︙ | |||
374 375 376 377 378 379 380 |
const char *z = aEntry[i].zPath;
int n = strlen(z);
if( aEntry[i].zIf ){
printf("%s", aEntry[i].zIf);
}else if( (aEntry[i].eType & CMDFLAG_WEBPAGE)!=0 ){
nWeb++;
}
| | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
const char *z = aEntry[i].zPath;
int n = strlen(z);
if( aEntry[i].zIf ){
printf("%s", aEntry[i].zIf);
}else if( (aEntry[i].eType & CMDFLAG_WEBPAGE)!=0 ){
nWeb++;
}
printf(" { \"%.*s\",%*s%s,%*szHelp%03d, 0x%03x },\n",
n, z,
25-n, "",
aEntry[i].zFunc,
(int)(29-strlen(aEntry[i].zFunc)), "",
aEntry[i].iHelp,
aEntry[i].eType
);
if( aEntry[i].zIf ) printf("#endif\n");
}
printf("};\n");
printf("#define FOSSIL_FIRST_CMD %d\n", nWeb);
/* Generate the aSetting[] table */
printf("const Setting aSetting[] = {\n");
for(i=0; i<nFixed; i++){
const char *z;
const char *zVar;
const char *zDef;
if( (aEntry[i].eType & CMDFLAG_SETTING)==0 ) continue;
z = aEntry[i].zPath;
zVar = aEntry[i].zVar;
zDef = aEntry[i].zDflt;
if( zDef==0 ) zDef = "";
if( aEntry[i].zIf ){
printf("%s", aEntry[i].zIf);
}
printf(" { \"%s\",%*s", z, (int)(20-strlen(z)), "");
if( zVar ){
printf(" \"%s\",%*s", zVar, (int)(15-strlen(zVar)), "");
}else{
printf(" 0,%*s", 16, "");
}
printf(" %3d, %d, %d, \"%s\"%*s },\n",
aEntry[i].iWidth,
(aEntry[i].eType & CMDFLAG_VERSIONABLE)!=0,
(aEntry[i].eType & CMDFLAG_BLOCKTEXT)!=0,
zDef, (int)(10-strlen(zDef)), ""
);
if( aEntry[i].zIf ){
printf("#endif\n");
}
}
printf("};\n");
}
/*
** Process a single file of input
*/
void process_file(void){
FILE *in = fopen(zFile, "r");
char zLine[2000];
if( in==0 ){
fprintf(stderr,"%s: cannot open\n", zFile);
return;
}
nLine = 0;
while( fgets(zLine, sizeof(zLine), in) ){
nLine++;
scan_for_if(zLine);
scan_for_label("WEBPAGE:",zLine,CMDFLAG_WEBPAGE);
scan_for_label("COMMAND:",zLine,CMDFLAG_COMMAND);
scan_for_func(zLine);
scan_for_label("SETTING:",zLine,CMDFLAG_SETTING);
scan_for_default(zLine);
}
fclose(in);
nUsed = nFixed;
}
int main(int argc, char **argv){
int i;
|
| ︙ | ︙ |
Changes to src/mkversion.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/*
** This C program generates the "VERSION.h" header file from information
** extracted out of the "manifest", "manifest.uuid", and "VERSION" files.
** Call this program with three arguments:
**
** ./a.out manifest.uuid manifest VERSION
**
** Note that the manifest.uuid and manifest files are generated by Fossil.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
FILE *m,*u,*v;
char *z;
| > > > > > > > > > > | > > > > > > | | | < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
/*
** This C program generates the "VERSION.h" header file from information
** extracted out of the "manifest", "manifest.uuid", and "VERSION" files.
** Call this program with three arguments:
**
** ./a.out manifest.uuid manifest VERSION
**
** Note that the manifest.uuid and manifest files are generated by Fossil.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static FILE *open_for_reading(const char *zFilename){
FILE *f = fopen(zFilename, "r");
if( f==0 ){
fprintf(stderr, "cannot open \"%s\" for reading\n", zFilename);
exit(1);
}
return f;
}
int main(int argc, char *argv[]){
FILE *m,*u,*v;
char *z;
#if defined(__DMC__) /* e.g. 0x857 */
int i = 0;
#endif
int j = 0, x = 0, d = 0;
int vn[3];
char b[1000];
char vx[1000];
if( argc!=4 ){
fprintf(stderr, "Usage: %s manifest.uuid manifest VERSION\n", argv[0]);
exit(1);
}
memset(b,0,sizeof(b));
memset(vx,0,sizeof(vx));
u = open_for_reading(argv[1]);
if( fgets(b, sizeof(b)-1,u)==0 ){
fprintf(stderr, "malformed manifest.uuid file: %s\n", argv[1]);
exit(1);
}
fclose(u);
for(z=b; z[0] && z[0]!='\r' && z[0]!='\n'; z++){}
*z = 0;
printf("#define MANIFEST_UUID \"%s\"\n",b);
printf("#define MANIFEST_VERSION \"[%10.10s]\"\n",b);
m = open_for_reading(argv[2]);
while(b == fgets(b, sizeof(b)-1,m)){
if(0 == strncmp("D ",b,2)){
printf("#define MANIFEST_DATE \"%.10s %.8s\"\n",b+2,b+13);
printf("#define MANIFEST_YEAR \"%.4s\"\n",b+2);
}
}
fclose(m);
v = open_for_reading(argv[3]);
if( fgets(b, sizeof(b)-1,v)==0 ){
fprintf(stderr, "malformed VERSION file: %s\n", argv[3]);
exit(1);
}
fclose(v);
for(z=b; z[0] && z[0]!='\r' && z[0]!='\n'; z++){}
*z = 0;
printf("#define RELEASE_VERSION \"%s\"\n", b);
z=b;
vn[0] = vn[1] = vn[2] = 0;
while(1){
if( z[0]>='0' && z[0]<='9' ){
x = x*10 + z[0] - '0';
}else{
if( j<3 ) vn[j++] = x;
x = 0;
if( z[0]==0 ) break;
}
z++;
}
for(z=vx; z[0]=='0'; z++){}
printf("#define RELEASE_VERSION_NUMBER %d%02d%02d\n", vn[0], vn[1], vn[2]);
memset(vx,0,sizeof(vx));
strcpy(vx,b);
for(z=vx; z[0]; z++){
if( z[0]=='-' ){
z[0] = 0;
break;
}
if( z[0]!='.' ) continue;
if ( d<3 ){
|
| ︙ | ︙ |
Changes to src/name.c.
| ︙ | ︙ | |||
465 466 467 468 469 470 471 |
const char *zUuid = db_column_text(&q, 1);
const char *zTitle = db_column_text(&q, 2);
@ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
@ %s(zUuid)</a> -
@ <ul></ul>
@ Ticket
hyperlink_to_uuid(zUuid);
| | | 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
const char *zUuid = db_column_text(&q, 1);
const char *zTitle = db_column_text(&q, 2);
@ <li><p><a href="%R/%T(zSrc)/%!S(zUuid)">
@ %s(zUuid)</a> -
@ <ul></ul>
@ Ticket
hyperlink_to_uuid(zUuid);
@ - %h(zTitle).
@ <ul><li>
object_description(rid, 0, 0);
@ </li></ul>
@ </p></li>
}
db_finalize(&q);
db_prepare(&q,
|
| ︙ | ︙ | |||
988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 |
** WEBPAGE: bloblist
**
** Return a page showing all artifacts in the repository. Query parameters:
**
** n=N Show N artifacts
** s=S Start with artifact number S
** unpub Show only unpublished artifacts
*/
void bloblist_page(void){
Stmt q;
int s = atoi(PD("s","0"));
int n = atoi(PD("n","5000"));
int mx = db_int(0, "SELECT max(rid) FROM blob");
int unpubOnly = PB("unpub");
char *zRange;
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
style_header("List Of Artifacts");
style_submenu_element("250 Largest", "bigbloblist");
if( !unpubOnly && mx>n && P("s")==0 ){
int i;
@ <p>Select a range of artifacts to view:</p>
@ <ul>
for(i=1; i<=mx; i+=n){
@ <li> %z(href("%R/bloblist?s=%d&n=%d",i,n))
@ %d(i)..%d(i+n-1<mx?i+n-1:mx)</a>
| > > > > > > > | 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 |
** WEBPAGE: bloblist
**
** Return a page showing all artifacts in the repository. Query parameters:
**
** n=N Show N artifacts
** s=S Start with artifact number S
** unpub Show only unpublished artifacts
** hclr Color code hash types (SHA1 vs SHA3)
*/
void bloblist_page(void){
Stmt q;
int s = atoi(PD("s","0"));
int n = atoi(PD("n","5000"));
int mx = db_int(0, "SELECT max(rid) FROM blob");
int unpubOnly = PB("unpub");
int hashClr = PB("hclr");
char *zRange;
char *zSha1Bg;
char *zSha3Bg;
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
style_header("List Of Artifacts");
style_submenu_element("250 Largest", "bigbloblist");
if( g.perm.Admin ){
style_submenu_element("Artifact Log", "rcvfromlist");
}
if( !unpubOnly && mx>n && P("s")==0 ){
int i;
@ <p>Select a range of artifacts to view:</p>
@ <ul>
for(i=1; i<=mx; i+=n){
@ <li> %z(href("%R/bloblist?s=%d&n=%d",i,n))
@ %d(i)..%d(i+n-1<mx?i+n-1:mx)</a>
|
| ︙ | ︙ | |||
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 |
zRange = mprintf("BETWEEN %d AND %d", s, s+n-1);
}
describe_artifacts(zRange);
fossil_free(zRange);
db_prepare(&q,
"SELECT rid, uuid, summary, isPrivate FROM description ORDER BY rid"
);
@ <table cellpadding="0" cellspacing="0">
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q,0);
const char *zUuid = db_column_text(&q, 1);
const char *zDesc = db_column_text(&q, 2);
int isPriv = db_column_int(&q,3);
| > > > > > > > > > > > | > | 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 |
zRange = mprintf("BETWEEN %d AND %d", s, s+n-1);
}
describe_artifacts(zRange);
fossil_free(zRange);
db_prepare(&q,
"SELECT rid, uuid, summary, isPrivate FROM description ORDER BY rid"
);
if( skin_detail_boolean("white-foreground") ){
zSha1Bg = "#714417";
zSha3Bg = "#177117";
}else{
zSha1Bg = "#ebffb0";
zSha3Bg = "#b0ffb0";
}
@ <table cellpadding="0" cellspacing="0">
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q,0);
const char *zUuid = db_column_text(&q, 1);
const char *zDesc = db_column_text(&q, 2);
int isPriv = db_column_int(&q,3);
if( hashClr ){
const char *zClr = db_column_bytes(&q,1)>40 ? zSha3Bg : zSha1Bg;
@ <tr style='background-color:%s(zClr);'><td align="right">%d(rid)</td>
}else{
@ <tr><td align="right">%d(rid)</td>
}
@ <td> %z(href("%R/info/%!S",zUuid))%S(zUuid)</a> </td>
@ <td align="left">%h(zDesc)</td>
if( isPriv ){
@ <td>(unpublished)</td>
}
@ </tr>
}
|
| ︙ | ︙ | |||
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 |
*/
void bigbloblist_page(void){
Stmt q;
int n = atoi(PD("n","250"));
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
style_header("%d Largest Artifacts", n);
db_multi_exec(
"CREATE TEMP TABLE toshow(rid INTEGER PRIMARY KEY);"
"INSERT INTO toshow(rid)"
" SELECT rid FROM blob"
" ORDER BY length(content) DESC"
" LIMIT %d;", n
| > > > > | 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 |
*/
void bigbloblist_page(void){
Stmt q;
int n = atoi(PD("n","250"));
login_check_credentials();
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
if( g.perm.Admin ){
style_submenu_element("Artifact Log", "rcvfromlist");
}
style_submenu_element("All Artifacts", "bloblist");
style_header("%d Largest Artifacts", n);
db_multi_exec(
"CREATE TEMP TABLE toshow(rid INTEGER PRIMARY KEY);"
"INSERT INTO toshow(rid)"
" SELECT rid FROM blob"
" ORDER BY length(content) DESC"
" LIMIT %d;", n
|
| ︙ | ︙ |
Changes to src/path.c.
| ︙ | ︙ | |||
43 44 45 46 47 48 49 |
*/
static struct {
PathNode *pCurrent; /* Current generation of nodes */
PathNode *pAll; /* All nodes */
Bag seen; /* Nodes seen before */
int nStep; /* Number of steps from first to last */
PathNode *pStart; /* Earliest node */
| < | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
*/
static struct {
PathNode *pCurrent; /* Current generation of nodes */
PathNode *pAll; /* All nodes */
Bag seen; /* Nodes seen before */
int nStep; /* Number of steps from first to last */
PathNode *pStart; /* Earliest node */
PathNode *pEnd; /* Most recent */
} path;
/*
** Return the first (last) element of the computed path.
*/
PathNode *path_first(void){ return path.pStart; }
|
| ︙ | ︙ | |||
191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
PathNode *path_midpoint(void){
PathNode *p;
int i;
if( path.nStep<2 ) return 0;
for(p=path.pEnd, i=0; p && i<path.nStep/2; p=p->pFrom, i++){}
return p;
}
/*
** COMMAND: test-shortest-path
**
** Usage: %fossil test-shortest-path ?--no-merge? VERSION1 VERSION2
**
** Report the shortest path between two check-ins. If the --no-merge flag
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
PathNode *path_midpoint(void){
PathNode *p;
int i;
if( path.nStep<2 ) return 0;
for(p=path.pEnd, i=0; p && i<path.nStep/2; p=p->pFrom, i++){}
return p;
}
/*
** Compute the shortest path between two check-ins and then transfer
** that path into the "ancestor" table. This is a utility used by
** both /annotate and /finfo. See also: compute_direct_ancestors().
*/
void path_shortest_stored_in_ancestor_table(
int origid, /* RID for check-in at start of the path */
int cid /* RID for check-in at the end of the path */
){
PathNode *pPath;
int gen = 0;
Stmt ins;
pPath = path_shortest(cid, origid, 1, 0);
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS ancestor("
" rid INT UNIQUE,"
" generation INTEGER PRIMARY KEY"
");"
"DELETE FROM ancestor;"
);
db_prepare(&ins, "INSERT INTO ancestor(rid, generation) VALUES(:rid,:gen)");
while( pPath ){
db_bind_int(&ins, ":rid", pPath->rid);
db_bind_int(&ins, ":gen", ++gen);
db_step(&ins);
db_reset(&ins);
pPath = pPath->u.pTo;
}
db_finalize(&ins);
path_reset();
}
/*
** COMMAND: test-shortest-path
**
** Usage: %fossil test-shortest-path ?--no-merge? VERSION1 VERSION2
**
** Report the shortest path between two check-ins. If the --no-merge flag
|
| ︙ | ︙ |
Changes to src/pivot.c.
| ︙ | ︙ | |||
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
**
** Options:
** --ignore-merges Ignore merges for discovering name pivots
*/
void test_find_pivot(void){
int i, rid;
int ignoreMerges = find_option("ignore-merges",0,0)!=0;
if( g.argc<4 ){
usage("?options? PRIMARY SECONDARY ...");
}
db_must_be_within_tree();
pivot_set_primary(name_to_rid(g.argv[2]));
for(i=3; i<g.argc; i++){
pivot_set_secondary(name_to_rid(g.argv[i]));
}
rid = pivot_find(ignoreMerges);
printf("pivot=%s\n",
db_text("?","SELECT uuid FROM blob WHERE rid=%d",rid)
);
}
| > > > > > > > > > > > > > > > > > > > | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
**
** Options:
** --ignore-merges Ignore merges for discovering name pivots
*/
void test_find_pivot(void){
int i, rid;
int ignoreMerges = find_option("ignore-merges",0,0)!=0;
int showDetails = find_option("details",0,0)!=0;
if( g.argc<4 ){
usage("?options? PRIMARY SECONDARY ...");
}
db_must_be_within_tree();
pivot_set_primary(name_to_rid(g.argv[2]));
for(i=3; i<g.argc; i++){
pivot_set_secondary(name_to_rid(g.argv[i]));
}
rid = pivot_find(ignoreMerges);
printf("pivot=%s\n",
db_text("?","SELECT uuid FROM blob WHERE rid=%d",rid)
);
if( showDetails ){
Stmt q;
db_prepare(&q,
"SELECT substr(uuid,1,12), aqueue.rid, datetime(aqueue.mtime),"
" aqueue.pending, aqueue.src\n"
" FROM aqueue JOIN blob ON aqueue.rid=blob.rid\n"
" ORDER BY aqueue.mtime DESC"
);
while( db_step(&q)==SQLITE_ROW ){
printf("\"%s\",%d,\"%s\",%d,%d\n",
db_column_text(&q, 0),
db_column_int(&q, 1),
db_column_text(&q, 2),
db_column_int(&q, 3),
db_column_int(&q, 4));
}
db_finalize(&q);
}
}
|
Changes to src/printf.c.
| ︙ | ︙ | |||
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
if( nDigitHuman > 40 ) nDigitHuman = 40;
nDigitUrl = nDigitHuman + 6;
if( nDigitUrl < FOSSIL_HASH_DIGITS_URL ) nDigitUrl = FOSSIL_HASH_DIGITS_URL;
if( nDigitUrl > 40 ) nDigitUrl = 40;
}
return bForUrl ? nDigitUrl : nDigitHuman;
}
/*
** Conversion types fall into various categories as defined by the
** following enumeration.
*/
#define etRADIX 1 /* Integer types. %d, %x, %o, and so forth */
#define etFLOAT 2 /* Floating point. %f */
| > > > > > > > | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
if( nDigitHuman > 40 ) nDigitHuman = 40;
nDigitUrl = nDigitHuman + 6;
if( nDigitUrl < FOSSIL_HASH_DIGITS_URL ) nDigitUrl = FOSSIL_HASH_DIGITS_URL;
if( nDigitUrl > 40 ) nDigitUrl = 40;
}
return bForUrl ? nDigitUrl : nDigitHuman;
}
/*
** Return the number of characters in a %S output.
*/
int length_of_S_display(void){
return hashDigits(0);
}
/*
** Conversion types fall into various categories as defined by the
** following enumeration.
*/
#define etRADIX 1 /* Integer types. %d, %x, %o, and so forth */
#define etFLOAT 2 /* Floating point. %f */
|
| ︙ | ︙ |
Changes to src/rebuild.c.
| ︙ | ︙ | |||
362 363 364 365 366 367 368 |
"'config','shun','private','reportfmt',"
"'concealed','accesslog','modreq',"
"'purgeevent','purgeitem','unversioned')"
" AND name NOT GLOB 'sqlite_*'"
" AND name NOT GLOB 'fx_*'"
);
while( db_step(&q)==SQLITE_ROW ){
| | | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
"'config','shun','private','reportfmt',"
"'concealed','accesslog','modreq',"
"'purgeevent','purgeitem','unversioned')"
" AND name NOT GLOB 'sqlite_*'"
" AND name NOT GLOB 'fx_*'"
);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(&sql, "DROP TABLE IF EXISTS \"%w\";\n", db_column_text(&q,0));
}
db_finalize(&q);
db_multi_exec("%s", blob_str(&sql)/*safe-for-%s*/);
blob_reset(&sql);
db_multi_exec("%s", zRepositorySchema2/*safe-for-%s*/);
ticket_create_table(0);
shun_artifacts();
|
| ︙ | ︙ | |||
445 446 447 448 449 450 451 452 453 454 455 456 457 |
if(!g.fQuiet && ttyOutput ){
percent_complete(1000);
fossil_print("\n");
}
return errCnt;
}
/*
** Attempt to convert more full-text blobs into delta-blobs for
** storage efficiency.
*/
void extra_deltification(void){
Stmt q;
| > > > > > > > | > > > > | | < < < | | > | > > > > > > > > | | | | < < | | > | > > > > | 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
if(!g.fQuiet && ttyOutput ){
percent_complete(1000);
fossil_print("\n");
}
return errCnt;
}
/*
** Number of neighbors to search
*/
#define N_NEIGHBOR 5
/*
** Attempt to convert more full-text blobs into delta-blobs for
** storage efficiency.
*/
void extra_deltification(void){
Stmt q;
int aPrev[N_NEIGHBOR];
int nPrev;
int rid;
int prevfnid, fnid;
db_begin_transaction();
/* Look for manifests that have not been deltaed and try to make them
** children of one of the 5 chronologically subsequent check-ins
*/
db_prepare(&q,
"SELECT rid FROM event, blob"
" WHERE blob.rid=event.objid"
" AND event.type='ci'"
" AND NOT EXISTS(SELECT 1 FROM delta WHERE rid=blob.rid)"
" ORDER BY event.mtime DESC"
);
nPrev = 0;
while( db_step(&q)==SQLITE_ROW ){
rid = db_column_int(&q, 0);
if( nPrev>0 ){
content_deltify(rid, aPrev, nPrev, 0);
}
if( nPrev<N_NEIGHBOR ){
aPrev[nPrev++] = rid;
}else{
int i;
for(i=0; i<N_NEIGHBOR-1; i++) aPrev[i] = aPrev[i+1];
aPrev[N_NEIGHBOR-1] = rid;
}
}
db_finalize(&q);
/* For individual files that have not been deltaed, try to find
** a parent which is an undeltaed file with the same name in a
** more recent branch.
*/
db_prepare(&q,
"SELECT DISTINCT blob.rid, mlink.fnid FROM blob, mlink, plink"
" WHERE NOT EXISTS(SELECT 1 FROM delta WHERE rid=blob.rid)"
" AND mlink.fid=blob.rid"
" AND mlink.mid=plink.cid"
" AND plink.cid=mlink.mid"
" ORDER BY mlink.fnid, plink.mtime DESC"
);
prevfnid = 0;
while( db_step(&q)==SQLITE_ROW ){
rid = db_column_int(&q, 0);
fnid = db_column_int(&q, 1);
if( fnid!=prevfnid ) nPrev = 0;
prevfnid = fnid;
if( nPrev>0 ){
content_deltify(rid, aPrev, nPrev, 0);
}
if( nPrev<N_NEIGHBOR ){
aPrev[nPrev++] = rid;
}else{
int i;
for(i=0; i<N_NEIGHBOR-1; i++) aPrev[i] = aPrev[i+1];
aPrev[N_NEIGHBOR-1] = rid;
}
}
db_finalize(&q);
db_end_transaction(0);
}
|
| ︙ | ︙ |
Changes to src/report.c.
| ︙ | ︙ | |||
160 161 162 163 164 165 166 | /* ** This is the SQLite authorizer callback used to make sure that the ** SQL statements entered by users do not try to do anything untoward. ** If anything suspicious is tried, set *(char**)pError to an error ** message obtained from malloc. */ | | | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
/*
** This is the SQLite authorizer callback used to make sure that the
** SQL statements entered by users do not try to do anything untoward.
** If anything suspicious is tried, set *(char**)pError to an error
** message obtained from malloc.
*/
static int report_query_authorizer(
void *pError,
int code,
const char *zArg1,
const char *zArg2,
const char *zArg3,
const char *zArg4
){
|
| ︙ | ︙ | |||
219 220 221 222 223 224 225 | } return rc; } /* ** Activate the query authorizer */ | | > | | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
}
return rc;
}
/*
** Activate the query authorizer
*/
void report_restrict_sql(char **pzErr){
sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)pzErr);
sqlite3_limit(g.db, SQLITE_LIMIT_VDBE_OP, 10000);
}
void report_unrestrict_sql(void){
sqlite3_set_authorizer(g.db, 0, 0);
}
/*
** Check the given SQL to see if is a valid query that does not
** attempt to do anything dangerous. Return 0 on success and a
|
| ︙ | ︙ |
Changes to src/search.c.
| ︙ | ︙ | |||
595 596 597 598 599 600 601 |
fossil_fatal("-W|--width value must be >20 or 0");
}
}else{
width = -1;
}
db_find_and_open_repository(0, 0);
| | | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
fossil_fatal("-W|--width value must be >20 or 0");
}
}else{
width = -1;
}
db_find_and_open_repository(0, 0);
if( g.argc<3 ) return;
blob_init(&pattern, g.argv[2], -1);
for(i=3; i<g.argc; i++){
blob_appendf(&pattern, " %s", g.argv[i]);
}
(void)search_init(blob_str(&pattern),"*","*","...",SRCHFLG_STATIC);
blob_reset(&pattern);
search_sql_setup(g.db);
|
| ︙ | ︙ | |||
631 632 633 634 635 636 637 | blob_reset(&sql); print_timeline(&q, nLimit, width, 0); db_finalize(&q); } #if INTERFACE /* What to search for */ | | | | | > | | | | | > | | 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
blob_reset(&sql);
print_timeline(&q, nLimit, width, 0);
db_finalize(&q);
}
#if INTERFACE
/* What to search for */
#define SRCH_CKIN 0x0001 /* Search over check-in comments */
#define SRCH_DOC 0x0002 /* Search over embedded documents */
#define SRCH_TKT 0x0004 /* Search over tickets */
#define SRCH_WIKI 0x0008 /* Search over wiki */
#define SRCH_TECHNOTE 0x0010 /* Search over tech notes */
#define SRCH_ALL 0x001f /* Search over everything */
#endif
/*
** Remove bits from srchFlags which are disallowed by either the
** current server configuration or by user permissions.
*/
unsigned int search_restrict(unsigned int srchFlags){
static unsigned int knownGood = 0;
static unsigned int knownBad = 0;
static const struct { unsigned m; const char *zKey; } aSetng[] = {
{ SRCH_CKIN, "search-ci" },
{ SRCH_DOC, "search-doc" },
{ SRCH_TKT, "search-tkt" },
{ SRCH_WIKI, "search-wiki" },
{ SRCH_TECHNOTE, "search-technote" },
};
int i;
if( g.perm.Read==0 ) srchFlags &= ~(SRCH_CKIN|SRCH_DOC|SRCH_TECHNOTE);
if( g.perm.RdTkt==0 ) srchFlags &= ~(SRCH_TKT);
if( g.perm.RdWiki==0 ) srchFlags &= ~(SRCH_WIKI);
for(i=0; i<count(aSetng); i++){
unsigned int m = aSetng[i].m;
if( (srchFlags & m)==0 ) continue;
if( ((knownGood|knownBad) & m)!=0 ) continue;
if( db_get_boolean(aSetng[i].zKey,0) ){
|
| ︙ | ︙ | |||
768 769 770 771 772 773 774 775 776 777 778 779 780 781 |
" search_score(),"
" 't'||tkt_id,"
" datetime(tkt_mtime),"
" search_snippet()"
" FROM ticket"
" WHERE search_match(title('t',tkt_id,NULL),body('t',tkt_id,NULL));"
);
}
}
/*
** Number of significant bits in a u32
*/
static int nbits(u32 x){
| > > > > > > > > > > > > > > > > > > > > | 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 |
" search_score(),"
" 't'||tkt_id,"
" datetime(tkt_mtime),"
" search_snippet()"
" FROM ticket"
" WHERE search_match(title('t',tkt_id,NULL),body('t',tkt_id,NULL));"
);
}
if( (srchFlags & SRCH_TECHNOTE)!=0 ){
db_multi_exec(
"WITH technote(uuid,rid,mtime) AS ("
" SELECT substr(tagname,7), tagxref.rid, max(tagxref.mtime)"
" FROM tag, tagxref"
" WHERE tag.tagname GLOB 'event-*'"
" AND tagxref.tagid=tag.tagid"
" GROUP BY 1"
")"
"INSERT INTO x(label,url,score,id,date,snip)"
" SELECT printf('Tech Note: %%s',uuid),"
" printf('/technote/%%s',uuid),"
" search_score(),"
" 'e'||rid,"
" datetime(mtime),"
" search_snippet()"
" FROM technote"
" WHERE search_match('',body('e',rid,NULL));"
);
}
}
/*
** Number of significant bits in a u32
*/
static int nbits(u32 x){
|
| ︙ | ︙ | |||
884 885 886 887 888 889 890 |
" WHERE ftsidx MATCH %Q"
" AND ftsdocs.rowid=ftsidx.docid",
zPattern
);
if( srchFlags!=SRCH_ALL ){
const char *zSep = " AND (";
static const struct { unsigned m; char c; } aMask[] = {
| | | | | > | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 |
" WHERE ftsidx MATCH %Q"
" AND ftsdocs.rowid=ftsidx.docid",
zPattern
);
if( srchFlags!=SRCH_ALL ){
const char *zSep = " AND (";
static const struct { unsigned m; char c; } aMask[] = {
{ SRCH_CKIN, 'c' },
{ SRCH_DOC, 'd' },
{ SRCH_TKT, 't' },
{ SRCH_WIKI, 'w' },
{ SRCH_TECHNOTE, 'e' },
};
int i;
for(i=0; i<count(aMask); i++){
if( srchFlags & aMask[i].m ){
blob_appendf(&sql, "%sftsdocs.type='%c'", zSep, aMask[i].c);
zSep = " OR ";
}
|
| ︙ | ︙ | |||
1035 1036 1037 1038 1039 1040 1041 |
const char *zClass = 0;
const char *zDisable1;
const char *zDisable2;
const char *zPattern;
int fDebug = PB("debug");
srchFlags = search_restrict(srchFlags);
switch( srchFlags ){
| | | | | > | | | | | > | 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 |
const char *zClass = 0;
const char *zDisable1;
const char *zDisable2;
const char *zPattern;
int fDebug = PB("debug");
srchFlags = search_restrict(srchFlags);
switch( srchFlags ){
case SRCH_CKIN: zType = " Check-ins"; zClass = "Ckin"; break;
case SRCH_DOC: zType = " Docs"; zClass = "Doc"; break;
case SRCH_TKT: zType = " Tickets"; zClass = "Tkt"; break;
case SRCH_WIKI: zType = " Wiki"; zClass = "Wiki"; break;
case SRCH_TECHNOTE: zType = " Tech Notes"; zClass = "Note"; break;
}
if( srchFlags==0 ){
zDisable1 = " disabled";
zDisable2 = " disabled";
zPattern = "";
}else{
zDisable1 = " autofocus";
zDisable2 = "";
zPattern = PD("s","");
}
@ <form method='GET' action='%R/%T(g.zPath)'>
if( zClass ){
@ <div class='searchForm searchForm%s(zClass)'>
}else{
@ <div class='searchForm'>
}
@ <input type="text" name="s" size="40" value="%h(zPattern)"%s(zDisable1)>
if( useYparam && (srchFlags & (srchFlags-1))!=0 && useYparam ){
static const struct { char *z; char *zNm; unsigned m; } aY[] = {
{ "all", "All", SRCH_ALL },
{ "c", "Check-ins", SRCH_CKIN },
{ "d", "Docs", SRCH_DOC },
{ "t", "Tickets", SRCH_TKT },
{ "w", "Wiki", SRCH_WIKI },
{ "e", "Tech Notes", SRCH_TECHNOTE },
};
const char *zY = PD("y","all");
unsigned newFlags = srchFlags;
int i;
@ <select size='1' name='y'>
for(i=0; i<count(aY); i++){
if( (aY[i].m & srchFlags)==0 ) continue;
|
| ︙ | ︙ | |||
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 |
**
** s=PATTERN Specify the full-text pattern to search for
** y=TYPE What to search.
** c -> check-ins
** d -> documentation
** t -> tickets
** w -> wiki
** all -> everything
*/
void search_page(void){
login_check_credentials();
style_header("Search");
search_screen(SRCH_ALL, 1);
style_footer();
| > | 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 |
**
** s=PATTERN Specify the full-text pattern to search for
** y=TYPE What to search.
** c -> check-ins
** d -> documentation
** t -> tickets
** w -> wiki
** e -> tech notes
** all -> everything
*/
void search_page(void){
login_check_credentials();
style_header("Search");
search_screen(SRCH_ALL, 1);
style_footer();
|
| ︙ | ︙ | |||
1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 | ** Return "search text" - a reduced version of a document appropriate for ** full text search and/or for constructing a search result snippet. ** ** cType: d Embedded documentation ** w Wiki page ** c Check-in comment ** t Ticket text ** ** rid The RID of an artifact that defines the object ** being searched. ** ** zName Name of the object being searched. This is used ** only to help figure out the mimetype (text/plain, ** test/html, test/x-fossil-wiki, or text/x-markdown) | > | 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 | ** Return "search text" - a reduced version of a document appropriate for ** full text search and/or for constructing a search result snippet. ** ** cType: d Embedded documentation ** w Wiki page ** c Check-in comment ** t Ticket text ** e Tech note ** ** rid The RID of an artifact that defines the object ** being searched. ** ** zName Name of the object being searched. This is used ** only to help figure out the mimetype (text/plain, ** test/html, test/x-fossil-wiki, or text/x-markdown) |
| ︙ | ︙ | |||
1245 1246 1247 1248 1249 1250 1251 1252 |
Blob doc;
content_get(rid, &doc);
blob_to_utf8_no_bom(&doc, 0);
get_stext_by_mimetype(&doc, mimetype_from_name(zName), pOut);
blob_reset(&doc);
break;
}
case 'w': { /* Wiki */
| > | > | 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 |
Blob doc;
content_get(rid, &doc);
blob_to_utf8_no_bom(&doc, 0);
get_stext_by_mimetype(&doc, mimetype_from_name(zName), pOut);
blob_reset(&doc);
break;
}
case 'e': /* Tech Notes */
case 'w': { /* Wiki */
Manifest *pWiki = manifest_get(rid,
cType == 'e' ? CFTYPE_EVENT : CFTYPE_WIKI, 0);
Blob wiki;
if( pWiki==0 ) break;
blob_init(&wiki, pWiki->zWiki, -1);
get_stext_by_mimetype(&wiki, wiki_filter_mimetypes(pWiki->zMimetype),
pOut);
blob_reset(&wiki);
manifest_destroy(pWiki);
|
| ︙ | ︙ | |||
1365 1366 1367 1368 1369 1370 1371 | /* ** COMMAND: test-search-stext ** ** Usage: fossil test-search-stext TYPE RID NAME ** ** Compute the search text for document TYPE-RID whose name is NAME. | | | 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 |
/*
** COMMAND: test-search-stext
**
** Usage: fossil test-search-stext TYPE RID NAME
**
** Compute the search text for document TYPE-RID whose name is NAME.
** The TYPE is one of "c", "d", "t", "w", or "e". The RID is the document
** ID. The NAME is used to figure out a mimetype to use for formatting
** the raw document text.
*/
void test_search_stext(void){
Blob out;
db_find_and_open_repository(0,0);
if( g.argc!=5 ) usage("TYPE RID NAME");
|
| ︙ | ︙ | |||
1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 |
") INSERT OR IGNORE INTO ftsdocs(type,rid,name,idxed)"
" SELECT 'w', rid, name, 0 FROM latest_wiki;"
);
db_multi_exec(
"INSERT OR IGNORE INTO ftsdocs(type,rid,idxed)"
" SELECT 't', tkt_id, 0 FROM ticket;"
);
}
/*
** The document described by cType,rid,zName is about to be added or
** updated. If the document has already been indexed, then unindex it
** now while we still have access to the old content. Add the document
** to the queue of documents that need to be indexed or reindexed.
| > > > > | 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 |
") INSERT OR IGNORE INTO ftsdocs(type,rid,name,idxed)"
" SELECT 'w', rid, name, 0 FROM latest_wiki;"
);
db_multi_exec(
"INSERT OR IGNORE INTO ftsdocs(type,rid,idxed)"
" SELECT 't', tkt_id, 0 FROM ticket;"
);
db_multi_exec(
"INSERT OR IGNORE INTO ftsdocs(type,rid,name,idxed)"
" SELECT 'e', objid, comment, 0 FROM event WHERE type='e';"
);
}
/*
** The document described by cType,rid,zName is about to be added or
** updated. If the document has already been indexed, then unindex it
** now while we still have access to the old content. Add the document
** to the queue of documents that need to be indexed or reindexed.
|
| ︙ | ︙ | |||
1506 1507 1508 1509 1510 1511 1512 |
zType, rid
);
db_multi_exec(
"REPLACE INTO ftsdocs(type,rid,name,idxed)"
" VALUES(%Q,%d,%Q,0)",
zType, rid, zName
);
| | | | | | | 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 |
zType, rid
);
db_multi_exec(
"REPLACE INTO ftsdocs(type,rid,name,idxed)"
" VALUES(%Q,%d,%Q,0)",
zType, rid, zName
);
if( cType=='w' || cType=='e' ){
db_multi_exec(
"DELETE FROM ftsidx WHERE docid IN"
" (SELECT rowid FROM ftsdocs WHERE type='%c' AND name=%Q AND idxed)",
cType, zName
);
db_multi_exec(
"DELETE FROM ftsdocs WHERE type='%c' AND name=%Q AND rid!=%d",
cType, zName, rid
);
}
}
}
/*
** If the doc-glob and doc-br settings are valid for document search
|
| ︙ | ︙ | |||
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 |
" 'Wiki: '||ftsdocs.name,"
" '/wiki?name='||urlencode(ftsdocs.name),"
" tagxref.mtime"
" FROM tagxref WHERE tagxref.rid=ftsdocs.rid)"
" WHERE ftsdocs.type='w' AND NOT ftsdocs.idxed"
);
}
/*
** Deal with all of the unindexed entries in the FTSDOCS table - that
** is to say, all the entries with FTSDOCS.IDXED=0. Add them to the
** index.
*/
void search_update_index(unsigned int srchFlags){
if( !search_index_exists() ) return;
if( !db_exists("SELECT 1 FROM ftsdocs WHERE NOT idxed") ) return;
search_sql_setup(g.db);
if( srchFlags & (SRCH_CKIN|SRCH_DOC) ){
search_update_doc_index();
search_update_checkin_index();
}
if( srchFlags & SRCH_TKT ){
search_update_ticket_index();
}
if( srchFlags & SRCH_WIKI ){
search_update_wiki_index();
}
}
/*
** Construct, prepopulate, and then update the full-text index.
*/
void search_rebuild_index(void){
fossil_print("rebuilding the search index...");
| > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 |
" 'Wiki: '||ftsdocs.name,"
" '/wiki?name='||urlencode(ftsdocs.name),"
" tagxref.mtime"
" FROM tagxref WHERE tagxref.rid=ftsdocs.rid)"
" WHERE ftsdocs.type='w' AND NOT ftsdocs.idxed"
);
}
/*
** Deal with all of the unindexed 'e' terms in FTSDOCS
*/
static void search_update_technote_index(void){
db_multi_exec(
"INSERT INTO ftsidx(docid,title,body)"
" SELECT rowid, title('e',rid,NULL),body('e',rid,NULL) FROM ftsdocs"
" WHERE type='e' AND NOT idxed;"
);
if( db_changes()==0 ) return;
db_multi_exec(
"UPDATE ftsdocs SET idxed=1,"
" (name,label,url,mtime) = "
" (SELECT ftsdocs.name,"
" 'Tech Note: '||ftsdocs.name,"
" '/technote/'||substr(tag.tagname,7),"
" tagxref.mtime"
" FROM tagxref, tag USING (tagid)"
" WHERE tagxref.rid=ftsdocs.rid"
" AND tagname GLOB 'event-*')"
" WHERE ftsdocs.type='e' AND NOT ftsdocs.idxed"
);
}
/*
** Deal with all of the unindexed entries in the FTSDOCS table - that
** is to say, all the entries with FTSDOCS.IDXED=0. Add them to the
** index.
*/
void search_update_index(unsigned int srchFlags){
if( !search_index_exists() ) return;
if( !db_exists("SELECT 1 FROM ftsdocs WHERE NOT idxed") ) return;
search_sql_setup(g.db);
if( srchFlags & (SRCH_CKIN|SRCH_DOC) ){
search_update_doc_index();
search_update_checkin_index();
}
if( srchFlags & SRCH_TKT ){
search_update_ticket_index();
}
if( srchFlags & SRCH_WIKI ){
search_update_wiki_index();
}
if( srchFlags & SRCH_TECHNOTE ){
search_update_technote_index();
}
}
/*
** Construct, prepopulate, and then update the full-text index.
*/
void search_rebuild_index(void){
fossil_print("rebuilding the search index...");
|
| ︙ | ︙ | |||
1692 1693 1694 1695 1696 1697 1698 | ** of the repository. Subcommands: ** ** reindex Rebuild the search index. This is a no-op if ** index search is disabled ** ** index (on|off) Turn the search index on or off ** | | | | | | | | > | 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 |
** of the repository. Subcommands:
**
** reindex Rebuild the search index. This is a no-op if
** index search is disabled
**
** index (on|off) Turn the search index on or off
**
** enable cdtwe Enable various kinds of search. c=Check-ins,
** d=Documents, t=Tickets, w=Wiki, e=Tech Notes.
**
** disable cdtwe Disable various kinds of search
**
** stemmer (on|off) Turn the Porter stemmer on or off for indexed
** search. (Unindexed search is never stemmed.)
**
** The current search settings are displayed after any changes are applied.
** Run this command with no arguments to simply see the settings.
*/
void fts_config_cmd(void){
static const struct { int iCmd; const char *z; } aCmd[] = {
{ 1, "reindex" },
{ 2, "index" },
{ 3, "disable" },
{ 4, "enable" },
{ 5, "stemmer" },
};
static const struct { char *zSetting; char *zName; char *zSw; } aSetng[] = {
{ "search-ckin", "check-in search:", "c" },
{ "search-doc", "document search:", "d" },
{ "search-tkt", "ticket search:", "t" },
{ "search-wiki", "wiki search:", "w" },
{ "search-technote", "tech note search:", "e" },
};
char *zSubCmd = 0;
int i, j, n;
int iCmd = 0;
int iAction = 0;
db_find_and_open_repository(0, 0);
if( g.argc>2 ){
|
| ︙ | ︙ | |||
1777 1778 1779 1780 1781 1782 1783 |
}
if( iAction>=2 ){
search_rebuild_index();
}
/* Always show the status before ending */
for(i=0; i<count(aSetng); i++){
| | | | | | | 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 |
}
if( iAction>=2 ){
search_rebuild_index();
}
/* Always show the status before ending */
for(i=0; i<count(aSetng); i++){
fossil_print("%-17s %s\n", aSetng[i].zName,
db_get_boolean(aSetng[i].zSetting,0) ? "on" : "off");
}
fossil_print("%-17s %s\n", "Porter stemmer:",
db_get_boolean("search-stemmer",0) ? "on" : "off");
if( search_index_exists() ){
fossil_print("%-17s enabled\n", "full-text index:");
fossil_print("%-17s %d\n", "documents:",
db_int(0, "SELECT count(*) FROM ftsdocs"));
}else{
fossil_print("%-17s disabled\n", "full-text index:");
}
db_end_transaction(0);
}
/*
** WEBPAGE: test-ftsdocs
**
|
| ︙ | ︙ |
Added src/security_audit.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
/*
** Copyright (c) 2017 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the Simplified BSD License (also
** known as the "2-Clause License" or "FreeBSD License".)
** This program is distributed in the hope that it will be useful,
** but without any warranty; without even the implied warranty of
** merchantability or fitness for a particular purpose.
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** This file implements various web pages use for running a security audit
** of a Fossil configuration.
*/
#include "config.h"
#include <assert.h>
#include "security_audit.h"
/*
** Return TRUE if any of the capability letters in zTest are found
** in the capability string zCap.
*/
static int hasAnyCap(const char *zCap, const char *zTest){
while( zTest[0] ){
if( strchr(zCap, zTest[0]) ) return 1;
zTest++;
}
return 0;
}
/*
** WEBPAGE: secaudit0
**
** Run a security audit of the current Fossil setup.
** This page requires administrator access
*/
void secaudit0_page(void){
const char *zAnonCap; /* Capabilities of user "anonymous" and "nobody" */
const char *zPubPages; /* GLOB pattern for public pages */
char *z;
int n;
login_check_credentials();
if( !g.perm.Setup && !g.perm.Admin ){
login_needed(0);
return;
}
style_header("Security Audit");
@ <ol>
/* Step 1: Determine if the repository is public or private. "Public"
** means that any anonymous user on the internet can access all content.
** "Private" repos require (non-anonymous) login to access all content,
** though some content may be accessible anonymously.
*/
zAnonCap = db_text("", "SELECT group_concat(coalesce(cap,'')) FROM user"
" WHERE login IN ('anonymous','nobody')");
zPubPages = db_get("public-pages",0);
if( hasAnyCap(zAnonCap,"as") ){
@ <li><p>This repository is <big><b>Wildly INSECURE</b></big> because
@ it grants administrator privileges to anonymous users. You
@ should <a href="takeitprivate">take this repository private</a>
@ immediately! Or, at least remove the Setup and Admin privileges
@ for users "anonymous" and "login" on the
@ <a href="setup_ulist">User Configuration</a> page.
}else if( hasAnyCap(zAnonCap,"y") ){
@ <li><p>This repository is <big><b>INSECURE</b></big> because
@ it allows anonymous users to push unversioned files.
@ <p>Fix this by <a href="takeitprivate">taking the repository private</a>
@ or by removing the "y" permission from users "anonymous" and
@ "nobody" on the <a href="setup_ulist">User Configuration</a> page.
}else if( hasAnyCap(zAnonCap,"goz") ){
@ <li><p>This repository is <big><b>PUBLIC</b></big>. All
@ checked-in content can be accessed by anonymous users.
@ <a href="takeitprivate">Take it private</a>.<p>
}else if( !hasAnyCap(zAnonCap, "jry") && (zPubPages==0 || zPubPages[0]==0) ){
@ <li><p>This repository is <big><b>Completely PRIVATE</b></big>.
@ A valid login and password is required to access any content.
}else{
@ <li><p>This repository is <big><b>Mostly PRIVATE</b></big>.
@ A valid login and password is usually required, however some
@ content can be accessed anonymously:
@ <ul>
if( hasAnyCap(zAnonCap,"j") ){
@ <li> Wiki pages
}
if( hasAnyCap(zAnonCap,"r") ){
@ <li> Tickets
}
if( zPubPages && zPubPages[0] ){
Glob *pGlob = glob_create(zPubPages);
int i;
@ <li> URLs that match any of these GLOB patterns:
@ <ul>
for(i=0; i<pGlob->nPattern; i++){
@ <li> %h(pGlob->azPattern[i])
}
@ </ul>
}
@ </ul>
if( zPubPages && zPubPages[0] ){
@ <p>Change GLOB patterns exceptions using the "Public pages" setting
@ on the <a href="setup_access">Access Settings</a> page.</p>
}
}
/* Make sure the HTTPS is required for login, so that the password
** does not go across the internet in the clear.
*/
if( db_get_boolean("redirect-to-https",0)==0 ){
@ <li><p><b>WARNING:</b>
@ Login passwords can be sent over an unencrypted connection.
@ <p>Fix this by activating the "Redirect to HTTPS on the Login page"
@ setting on the <a href="setup_access">Access Control</a> page.
}
/* Anonymous users should not be able to harvest email addresses
** from tickets.
*/
if( hasAnyCap(zAnonCap, "e") ){
@ <li><p><b>WARNING:</b>
@ Anonymous users can view email addresses and other personally
@ identifiable information on tickets.
@ <p>Fix this by removing the "Email" privilege from users
@ "anonymous" and "nobody" on the
@ <a href="setup_ulist">User Configuration</a> page.
}
/* Anonymous users probably should not be allowed to push content
** to the repository.
*/
if( hasAnyCap(zAnonCap, "i") ){
@ <li><p><b>WARNING:</b>
@ Anonymous users can push new check-ins into the repository.
@ <p>Fix this by removing the "Check-in" privilege from users
@ "anonymous" and "nobody" on the
@ <a href="setup_ulist">User Configuration</a> page.
}
/* Anonymous users probably should not be allowed act as moderators
** for wiki or tickets.
*/
if( hasAnyCap(zAnonCap, "lq") ){
@ <li><p><b>WARNING:</b>
@ Anonymous users can act as moderators for wiki and/or tickets.
@ This defeats the whole purpose of moderation.
@ <p>Fix this by removing the "Mod-Wiki" and "Mod-Tkt"
@ privilege from users "anonymous" and "nobody" on the
@ <a href="setup_ulist">User Configuration</a> page.
}
/* Anonymous users probably should not be allowed to delete
** wiki or tickets.
*/
if( hasAnyCap(zAnonCap, "d") ){
@ <li><p><b>WARNING:</b>
@ Anonymous users can delete wiki and tickets.
@ <p>Fix this by removing the "Delete"
@ privilege from users "anonymous" and "nobody" on the
@ <a href="setup_ulist">User Configuration</a> page.
}
/* If anonymous users are allowed to create new Wiki, then
** wiki moderation should be activated to pervent spam.
*/
if( hasAnyCap(zAnonCap, "fk") ){
if( db_get_boolean("modreq-wiki",0)==0 ){
@ <li><p><b>WARNING:</b>
@ Anonymous users can create or edit wiki without moderation.
@ This can result in robots inserting lots of wiki spam into
@ repository.
@ <p>Fix this by removing the "New-Wiki" and "Write-Wiki"
@ privileges from users "anonymous" and "nobody" on the
@ <a href="setup_ulist">User Configuration</a> page or
@ by enabling wiki moderation on the
@ <a href="setup_modreq">Moderation Setup</a> page.
}else{
@ <li><p>
@ Anonymous users can create or edit wiki, but moderator
@ approval is required before the edits become permanent.
}
}
/* Administrative privilege should only be provided to
** specific individuals, not to entire classes of people.
** And not too many people should have administrator privilege.
*/
z = db_text(0, "SELECT group_concat(login,' AND ') FROM user"
" WHERE cap GLOB '*[as]*'"
" AND login in ('anonymous','nobody','reader','developer')");
if( z && z[0] ){
@ <li><p>
@ Adminstrative privilege is granted to an entire class of users
@ (%h(z)). Ideally, the Write-Unver privilege should only be
@ granted to specific individuals.
}
n = db_int(0,"SELECT count(*) FROM user WHERE cap GLOB '*[as]*'");
if( n==0 ){
@ <li><p>
@ No users have administrator privilege.
}else{
z = db_text(0,
"SELECT group_concat("
"printf('<a href=''setup_uedit?id=%%d''>%%s</a>',uid,login),"
"', ')"
" FROM user"
" WHERE cap GLOB '*[as]*'"
);
@ <li><p>
@ Users with administrator privilege are: %s(z)
fossil_free(z);
if( n>3 ){
@ <p><b>Caution</b>:
@ Administrator privilege is granted to
@ <a href='setup_ulist?with=as'>%d(n) users</a>.
@ Ideally, administator privilege ('s' or 'a') should only
@ be granted to one or two users.
}
}
/* The push-unversioned privilege should only be provided to
** specific individuals, not to entire classes of people.
** And no too many people should have this privilege.
*/
z = db_text(0,
"SELECT group_concat("
"printf('<a href=''setup_uedit?id=%%d''>%%s</a>',uid,login),"
"' and ')"
" FROM user"
" WHERE cap GLOB '*y*'"
" AND login in ('anonymous','nobody','reader','developer')"
);
if( z && z[0] ){
@ <li><p>
@ The "Write-Unver" privilege is granted to an entire class of users
@ (%s(z)). Ideally, the Write-Unver privilege should only be
@ granted to specific individuals.
fossil_free(z);
}
n = db_int(0,"SELECT count(*) FROM user WHERE cap GLOB '*y*'");
if( n>0 ){
z = db_text(0,
"SELECT group_concat("
"printf('<a href=''setup_uedit?id=%%d''>%%s</a>',uid,login),', ')"
" FROM user WHERE cap GLOB '*y*'"
);
@ <li><p>
@ Users with "Write-Unver" privilege: %s(z)
fossil_free(z);
if( n>3 ){
@ <p><b>Caution:</b>
@ The "Write-Unver" privilege ('y') is granted to an excessive
@ number of users (%d(n)).
@ Ideally, the Write-Unver privilege should only
@ be granted to one or two users.
}
}
/* Notify if REMOTE_USER or HTTP_AUTHENTICATION is used for login.
*/
if( db_get_boolean("remote_user_ok", 0) ){
@ <li><p>
@ This repository trusts that the REMOTE_USER environment variable set
@ up by the webserver contains the name of an authenticated user.
@ Fossil's built-in authentication mechanism is bypassed.
@ <p>Fix this by deactivating the "Allow REMOTE_USER authentication"
@ checkbox on the <a href="setup_access">Access Control</a> page.
}
if( db_get_boolean("http_authentication_ok", 0) ){
@ <li><p>
@ This repository trusts that the HTTP_AUTHENITICATION environment
@ variable set up by the webserver contains the name of an
@ authenticated user.
@ Fossil's built-in authentication mechanism is bypassed.
@ <p>Fix this by deactivating the "Allow HTTP_AUTHENTICATION authentication"
@ checkbox on the <a href="setup_access">Access Control</a> page.
}
/* Logging should be turned on
*/
if( db_get_boolean("access-log",0)==0 ){
@ <li><p>
@ The <a href="access_log">User Log</a> is disabled. The user log
@ keeps a record of successful and unsucessful login attempts and is
@ useful for security monitoring.
}
if( db_get_boolean("admin-log",0)==0 ){
@ <li><p>
@ The <a href="admin_log">Administrative Log</a> is disabled.
@ The administrative log provides a record of configuration changes
@ and is useful for security monitoring.
}
#if !defined(_WIN32) && !defined(FOSSIL_OMIT_LOAD_AVERAGE)
/* Make sure that the load-average limiter is armed and working */
if( load_average()==0.0 ){
@ <li><p>
@ Unable to get the system load average. This can prevent Fossil
@ from throttling expensive operations during peak demand.
@ <p>If running in a chroot jail on Linux, verify that the /proc
@ filesystem is mounted within the jail, so that the load average
@ can be obtained from the /proc/loadavg file.
}else {
double r = atof(db_get("max-loadavg", "0"));
if( r<=0.0 ){
@ <li><p>
@ Load average limiting is turned off. This can cause the server
@ to bog down if many requests for expensive services (such as
@ large diffs or tarballs) arrive at about the same time.
@ <p>To fix this, set the "Server Load Average Limit" on the
@ <a href="setup_access">Access Control</a> page to approximately
@ the number of available cores on your server, or maybe just a little
@ less.
}else if( r>=8.0 ){
@ <li><p>
@ The "Server Load Average Limit" on the
@ <a href="setup_access">Access Control</a> page is set to %g(r),
@ which seems high. Is this server really a %d((int)r)-core machine?
}
}
#endif
@ </ol>
style_footer();
}
/*
** WEBPAGE: takeitprivate
**
** Disable anonymous access to this website
*/
void takeitprivate_page(void){
login_check_credentials();
if( !g.perm.Setup && !g.perm.Admin ){
login_needed(0);
return;
}
if( P("cancel") ){
/* User pressed the cancel button. Go back */
cgi_redirect("secaudit0");
}
if( P("apply") ){
db_multi_exec(
"UPDATE user SET cap=''"
" WHERE login IN ('nobody','anonymous');"
"DELETE FROM config WHERE name='public-pages';"
);
cgi_redirect("secaudit0");
}
style_header("Make This Website Private");
@ <p>Click the "Make It Private" button below to disable all
@ anonymous access to this repository. A valid login and password
@ will be required to access this repository after clicking that
@ button.</p>
@
@ <p>Click the "Cancel" button to leave things as they are.</p>
@
@ <form action="%s(g.zPath)" method="post">
@ <input type="submit" name="apply" value="Make It Private">
@ <input type="submit" name="cancel" value="Cancel">
@ </form>
style_footer();
}
|
Changes to src/setup.c.
| ︙ | ︙ | |||
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
@ <table border="0" cellspacing="3">
setup_menu_entry("Users", "setup_ulist",
"Grant privileges to individual users.");
setup_menu_entry("Access", "setup_access",
"Control access settings.");
setup_menu_entry("Configuration", "setup_config",
"Configure the WWW components of the repository");
setup_menu_entry("Settings", "setup_settings",
"Web interface to the \"fossil settings\" command");
setup_menu_entry("Timeline", "setup_timeline",
"Timeline display preferences");
setup_menu_entry("Login-Group", "setup_login_group",
"Manage single sign-on between this repository and others"
" on the same server");
setup_menu_entry("Tickets", "tktsetup",
"Configure the trouble-ticketing system for this repository");
setup_menu_entry("Search","srchsetup",
"Configure the built-in search engine");
setup_menu_entry("Transfers", "xfersetup",
"Configure the transfer system for this repository");
setup_menu_entry("Skins", "setup_skin",
"Select and/or modify the web interface \"skins\"");
setup_menu_entry("Moderation", "setup_modreq",
"Enable/Disable requiring moderator approval of Wiki and/or Ticket"
" changes and attachments.");
setup_menu_entry("Ad-Unit", "setup_adunit",
"Edit HTML text for an ad unit inserted after the menu bar");
setup_menu_entry("Web-Cache", "cachestat",
"View the status of the expensive-page cache");
setup_menu_entry("Logo", "setup_logo",
"Change the logo and background images for the server");
setup_menu_entry("Shunned", "shun",
"Show artifacts that are shunned by this repository");
setup_menu_entry("Artifact Receipts Log", "rcvfromlist",
| > > > > > > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
@ <table border="0" cellspacing="3">
setup_menu_entry("Users", "setup_ulist",
"Grant privileges to individual users.");
setup_menu_entry("Access", "setup_access",
"Control access settings.");
setup_menu_entry("Configuration", "setup_config",
"Configure the WWW components of the repository");
setup_menu_entry("Security-Audit", "secaudit0",
"Analyze the current configuration for security problems");
setup_menu_entry("Settings", "setup_settings",
"Web interface to the \"fossil settings\" command");
setup_menu_entry("Timeline", "setup_timeline",
"Timeline display preferences");
setup_menu_entry("Login-Group", "setup_login_group",
"Manage single sign-on between this repository and others"
" on the same server");
setup_menu_entry("Tickets", "tktsetup",
"Configure the trouble-ticketing system for this repository");
setup_menu_entry("Search","srchsetup",
"Configure the built-in search engine");
setup_menu_entry("URL Aliases", "waliassetup",
"Configure URL aliases");
setup_menu_entry("Transfers", "xfersetup",
"Configure the transfer system for this repository");
setup_menu_entry("Skins", "setup_skin",
"Select and/or modify the web interface \"skins\"");
setup_menu_entry("Moderation", "setup_modreq",
"Enable/Disable requiring moderator approval of Wiki and/or Ticket"
" changes and attachments.");
setup_menu_entry("Ad-Unit", "setup_adunit",
"Edit HTML text for an ad unit inserted after the menu bar");
setup_menu_entry("URLs & Checkouts", "urllist",
"Show URLs used to access this repo and known check-outs");
setup_menu_entry("Web-Cache", "cachestat",
"View the status of the expensive-page cache");
setup_menu_entry("Logo", "setup_logo",
"Change the logo and background images for the server");
setup_menu_entry("Shunned", "shun",
"Show artifacts that are shunned by this repository");
setup_menu_entry("Artifact Receipts Log", "rcvfromlist",
|
| ︙ | ︙ | |||
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
}
/*
** WEBPAGE: setup_ulist
**
** Show a list of users. Clicking on any user jumps to the edit
** screen for that user. Requires Admin privileges.
*/
void setup_ulist(void){
Stmt s;
login_check_credentials();
if( !g.perm.Admin ){
login_needed(0);
return;
}
| > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > | > > > > > > > > > > > > > > > > > > | > | | | > > > > > > > > | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
}
/*
** WEBPAGE: setup_ulist
**
** Show a list of users. Clicking on any user jumps to the edit
** screen for that user. Requires Admin privileges.
**
** Query parameters:
**
** with=CAP Only show users that have one or more capabilities in CAP.
*/
void setup_ulist(void){
Stmt s;
double rNow;
const char *zWith = P("with");
login_check_credentials();
if( !g.perm.Admin ){
login_needed(0);
return;
}
if( zWith==0 || zWith[0]==0 ){
style_submenu_element("Add", "setup_uedit");
style_submenu_element("Log", "access_log");
style_submenu_element("Help", "setup_ulist_notes");
style_header("User List");
@ <table border=1 cellpadding=2 cellspacing=0 class='userTable'>
@ <thead><tr>
@ <th>UID <th>Category
@ <th>Capabilities (<a href='%R/setup_ucap_list'>key</a>)
@ <th>Info <th>Last Change</tr></thead>
@ <tbody>
db_prepare(&s,
"SELECT uid, login, cap, date(mtime,'unixepoch')"
" FROM user"
" WHERE login IN ('anonymous','nobody','developer','reader')"
" ORDER BY login"
);
while( db_step(&s)==SQLITE_ROW ){
int uid = db_column_int(&s, 0);
const char *zLogin = db_column_text(&s, 1);
const char *zCap = db_column_text(&s, 2);
const char *zDate = db_column_text(&s, 4);
@ <tr>
@ <td><a href='setup_uedit?id=%d(uid)'>%d(uid)</a>
@ <td><a href='setup_uedit?id=%d(uid)'>%h(zLogin)</a>
@ <td>%h(zCap)
if( fossil_strcmp(zLogin,"anonymous")==0 ){
@ <td>All logged-in users
}else if( fossil_strcmp(zLogin,"developer")==0 ){
@ <td>Users with '<b>v</b>' capability
}else if( fossil_strcmp(zLogin,"nobody")==0 ){
@ <td>All users without login
}else if( fossil_strcmp(zLogin,"reader")==0 ){
@ <td>Users with '<b>u</b>' capability
}else{
@ <td>
}
if( zDate && zDate[0] ){
@ <td>%h(zDate)
}else{
@ <td>
}
@ </tr>
}
db_finalize(&s);
}else{
style_header("Users With Capabilities \"%h\"", zWith);
}
@ </tbody></table>
@ <div class='section'>Users</div>
@ <table border=1 cellpadding=2 cellspacing=0 class='userTable' id='userlist'>
@ <thead><tr>
@ <th>ID<th>Login Name<th>Caps<th>Info<th>Date<th>Expire<th>Last Login</tr></thead>
@ <tbody>
db_multi_exec(
"CREATE TEMP TABLE lastAccess(uname TEXT PRIMARY KEY, atime REAL) WITHOUT ROWID;"
);
if( db_table_exists("repository","accesslog") ){
db_multi_exec(
"INSERT INTO lastAccess(uname, atime)"
" SELECT uname, max(mtime) FROM ("
" SELECT uname, mtime FROM accesslog WHERE success"
" UNION ALL"
" SELECT login AS uname, rcvfrom.mtime AS mtime FROM rcvfrom JOIN user USING(uid))"
" GROUP BY 1;"
);
}
if( zWith && zWith[0] ){
zWith = mprintf(" AND cap GLOB '*[%q]*'", zWith);
}else{
zWith = "";
}
db_prepare(&s,
"SELECT uid, login, cap, info, date(mtime,'unixepoch'), lower(login) AS sortkey, "
" CASE WHEN info LIKE '%%expires 20%%'"
" THEN substr(info,instr(lower(info),'expires')+8,10)"
" END AS exp,"
"atime"
" FROM user LEFT JOIN lastAccess ON login=uname"
" WHERE login NOT IN ('anonymous','nobody','developer','reader') %s"
" ORDER BY sortkey", zWith/*safe-for-%s*/
);
rNow = db_double(0.0, "SELECT julianday('now');");
while( db_step(&s)==SQLITE_ROW ){
int uid = db_column_int(&s, 0);
const char *zLogin = db_column_text(&s, 1);
const char *zCap = db_column_text(&s, 2);
const char *zInfo = db_column_text(&s, 3);
const char *zDate = db_column_text(&s, 4);
const char *zSortKey = db_column_text(&s,5);
const char *zExp = db_column_text(&s,6);
double rATime = db_column_double(&s,7);
char *zAge = 0;
if( rATime>0.0 ){
zAge = human_readable_age(rNow - rATime);
}
@ <tr>
@ <td><a href='setup_uedit?id=%d(uid)'>%d(uid)</a>
@ <td data-sortkey='%h(zSortKey)'><a href='setup_uedit?id=%d(uid)'>%h(zLogin)</a>
@ <td>%h(zCap)
@ <td>%h(zInfo)
@ <td>%h(zDate?zDate:"")
@ <td>%h(zExp?zExp:"")
@ <td data-sortkey='%f(rATime)' style='white-space:nowrap'>%s(zAge?zAge:"")
@ </tr>
fossil_free(zAge);
}
@ </tbody></table>
db_finalize(&s);
output_table_sorting_javascript("userlist","nktxTTK",2);
style_footer();
}
/*
** Render the user-capability table
*/
static void setup_usercap_table(void){
|
| ︙ | ︙ | |||
396 397 398 399 400 401 402 |
if( zId && !g.perm.Setup && uid>0 ){
char *zOldCaps;
zOldCaps = db_text(0, "SELECT cap FROM user WHERE uid=%d",uid);
higherUser = zOldCaps && strchr(zOldCaps,'s');
}
if( P("can") ){
| | > | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
if( zId && !g.perm.Setup && uid>0 ){
char *zOldCaps;
zOldCaps = db_text(0, "SELECT cap FROM user WHERE uid=%d",uid);
higherUser = zOldCaps && strchr(zOldCaps,'s');
}
if( P("can") ){
/* User pressed the cancel button */
cgi_redirect(cgi_referer("setup_ulist"));
return;
}
/* If we have all the necessary information, write the new or
** modified user record. After writing the user record, redirect
** to the page that displays a list of users.
*/
|
| ︙ | ︙ | |||
423 424 425 426 427 428 429 |
zCap[i] = 0;
zPw = P("pw");
zLogin = P("login");
if( strlen(zLogin)==0 ){
style_header("User Creation Error");
@ <span class="loginError">Empty login not allowed.</span>
@
| | > | > | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
zCap[i] = 0;
zPw = P("pw");
zLogin = P("login");
if( strlen(zLogin)==0 ){
style_header("User Creation Error");
@ <span class="loginError">Empty login not allowed.</span>
@
@ <p><a href="setup_uedit?id=%d(uid)&referer=%T(cgi_referer("setup_ulist"))">
@ [Bummer]</a></p>
style_footer();
return;
}
if( isValidPwString(zPw) ){
zPw = sha1_shared_secret(zPw, zLogin, 0);
}else{
zPw = db_text(0, "SELECT pw FROM user WHERE uid=%d", uid);
}
zOldLogin = db_text(0, "SELECT login FROM user WHERE uid=%d", uid);
if( db_exists("SELECT 1 FROM user WHERE login=%Q AND uid!=%d", zLogin, uid) ){
style_header("User Creation Error");
@ <span class="loginError">Login "%h(zLogin)" is already used by
@ a different user.</span>
@
@ <p><a href="setup_uedit?id=%d(uid)&referer=%T(cgi_referer("setup_ulist"))">
@ [Bummer]</a></p>
style_footer();
return;
}
login_verify_csrf_secret();
db_multi_exec(
"REPLACE INTO user(uid,login,info,pw,cap,mtime) "
"VALUES(nullif(%d,0),%Q,%Q,%Q,%Q,now())",
|
| ︙ | ︙ | |||
481 482 483 484 485 486 487 |
blob_reset(&sql);
admin_log( "Updated user [%q] in all login groups "
"with capabilities [%q].",
zLogin, zCap );
if( zErr ){
style_header("User Change Error");
admin_log( "Error updating user '%q': %s'.", zLogin, zErr );
| | | > | | 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
blob_reset(&sql);
admin_log( "Updated user [%q] in all login groups "
"with capabilities [%q].",
zLogin, zCap );
if( zErr ){
style_header("User Change Error");
admin_log( "Error updating user '%q': %s'.", zLogin, zErr );
@ <span class="loginError">%h(zErr)</span>
@
@ <p><a href="setup_uedit?id=%d(uid)&referer=%T(cgi_referer("setup_ulist"))">
@ [Bummer]</a></p>
style_footer();
return;
}
}
cgi_redirect(cgi_referer("setup_ulist"));
return;
}
/* Load the existing information about the user, if any
*/
zLogin = "";
zInfo = "";
|
| ︙ | ︙ | |||
551 552 553 554 555 556 557 |
"<span class=\"ueditInheritNobody\"><sub>[N]</sub></span>";
}
free(z2);
}
/* Begin generating the page
*/
| | > | 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
"<span class=\"ueditInheritNobody\"><sub>[N]</sub></span>";
}
free(z2);
}
/* Begin generating the page
*/
style_submenu_element("Cancel", cgi_referer("setup_ulist"));
if( uid ){
style_header("Edit User %h", zLogin);
}else{
style_header("Add A New User");
}
@ <div class="ueditCapBox">
@ <form action="%s(g.zPath)" method="post"><div>
login_insert_csrf_secret();
if( login_is_special(zLogin) ){
@ <input type="hidden" name="login" value="%s(zLogin)">
@ <input type="hidden" name="info" value="">
@ <input type="hidden" name="pw" value="*">
}
@ <input type="hidden" name="referer" value="%h(cgi_referer("setup_ulist"))">
@ <script>
@ function updateCapabilityString(){
@ /*
@ ** This function updates the "#usetupEditCapability" span content
@ ** with the capabilities selected by the interactive user, based
@ ** upon the state of the capability checkboxes.
@ */
|
| ︙ | ︙ | |||
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 |
return;
}
style_header("Access Control Settings");
db_begin_transaction();
@ <form action="%s(g.zTop)/setup_access" method="post"><div>
login_insert_csrf_secret();
@ <hr />
onoff_attribute("Redirect to HTTPS on the Login page",
"redirect-to-https", "redirhttps", 0, 0);
@ <p>When selected, force the use of HTTPS for the Login page.
@ <p>Details: When enabled, this option causes the $secureurl TH1
@ variable is set to an "https:" variant of $baseurl. Otherwise,
@ $secureurl is just an alias for $baseurl. Also when enabled, the
@ Login page redirects to https if accessed via http.
@ <hr />
onoff_attribute("Require password for local access",
"localauth", "localauth", 0, 0);
@ <p>When enabled, the password sign-in is always required for
@ web access. When disabled, unrestricted web access from 127.0.0.1
@ is allowed for the <a href="%R/help/ui">fossil ui</a> command or
@ from the <a href="%R/help/server">fossil server</a>,
| > > | 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 |
return;
}
style_header("Access Control Settings");
db_begin_transaction();
@ <form action="%s(g.zTop)/setup_access" method="post"><div>
login_insert_csrf_secret();
@ <input type="submit" name="submit" value="Apply Changes" /></p>
@ <hr />
onoff_attribute("Redirect to HTTPS on the Login page",
"redirect-to-https", "redirhttps", 0, 0);
@ <p>When selected, force the use of HTTPS for the Login page.
@ <p>Details: When enabled, this option causes the $secureurl TH1
@ variable is set to an "https:" variant of $baseurl. Otherwise,
@ $secureurl is just an alias for $baseurl. Also when enabled, the
@ Login page redirects to https if accessed via http.
@ (Property: "redirhttps")
@ <hr />
onoff_attribute("Require password for local access",
"localauth", "localauth", 0, 0);
@ <p>When enabled, the password sign-in is always required for
@ web access. When disabled, unrestricted web access from 127.0.0.1
@ is allowed for the <a href="%R/help/ui">fossil ui</a> command or
@ from the <a href="%R/help/server">fossil server</a>,
|
| ︙ | ︙ | |||
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 |
@ <li> The server is started using either of the
@ <a href="%R/help/server">fossil server</a> or
@ <a href="%R/help/server">fossil http</a> commands
@ without the "--localauth" option.
@ <li> The server is started from CGI without the "localauth" keyword
@ in the CGI script.
@ </ol>
@
@ <hr />
onoff_attribute("Enable /test_env",
"test_env_enable", "test_env_enable", 0, 0);
@ <p>When enabled, the %h(g.zBaseURL)/test_env URL is available to all
@ users. When disabled (the default) only users Admin and Setup can visit
@ the /test_env page.
@ </p>
@
@ <hr />
onoff_attribute("Allow REMOTE_USER authentication",
"remote_user_ok", "remote_user_ok", 0, 0);
@ <p>When enabled, if the REMOTE_USER environment variable is set to the
@ login name of a valid user and no other login credentials are available,
@ then the REMOTE_USER is accepted as an authenticated user.
@ </p>
@
@ <hr />
entry_attribute("IP address terms used in login cookie", 3,
"ip-prefix-terms", "ipt", "2", 0);
@ <p>The number of octets of of the IP address used in the login cookie.
@ Set to zero to omit the IP address from the login cookie. A value of
@ 2 is recommended.
@ </p>
@
@ <hr />
entry_attribute("Login expiration time", 6, "cookie-expire", "cex",
"8766", 0);
@ <p>The number of hours for which a login is valid. This must be a
@ positive number. The default is 8766 hours which is approximately equal
| > > > > > > > > > > > > > | > | | > | > | | < | | > > | > | > | | 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 |
@ <li> The server is started using either of the
@ <a href="%R/help/server">fossil server</a> or
@ <a href="%R/help/server">fossil http</a> commands
@ without the "--localauth" option.
@ <li> The server is started from CGI without the "localauth" keyword
@ in the CGI script.
@ </ol>
@ (Property: "localauth")
@
@ <hr />
onoff_attribute("Enable /test_env",
"test_env_enable", "test_env_enable", 0, 0);
@ <p>When enabled, the %h(g.zBaseURL)/test_env URL is available to all
@ users. When disabled (the default) only users Admin and Setup can visit
@ the /test_env page.
@ (Property: "test_env_enable")
@ </p>
@
@ <hr />
onoff_attribute("Allow REMOTE_USER authentication",
"remote_user_ok", "remote_user_ok", 0, 0);
@ <p>When enabled, if the REMOTE_USER environment variable is set to the
@ login name of a valid user and no other login credentials are available,
@ then the REMOTE_USER is accepted as an authenticated user.
@ (Property: "remote_user_ok")
@ </p>
@
@ <hr />
onoff_attribute("Allow HTTP_AUTHENTICATION authentication",
"http_authentication_ok", "http_authentication_ok", 0, 0);
@ <p>When enabled, allow the use of the HTTP_AUTHENTICATION environment
@ variable or the "Authentication:" HTTP header to find the username and
@ password. This is another way of supporting Basic Authenitication.
@ (Property: "http_authentication_ok")
@ </p>
@
@ <hr />
entry_attribute("IP address terms used in login cookie", 3,
"ip-prefix-terms", "ipt", "2", 0);
@ <p>The number of octets of of the IP address used in the login cookie.
@ Set to zero to omit the IP address from the login cookie. A value of
@ 2 is recommended.
@ (Property: "ip-prefix-terms")
@ </p>
@
@ <hr />
entry_attribute("Login expiration time", 6, "cookie-expire", "cex",
"8766", 0);
@ <p>The number of hours for which a login is valid. This must be a
@ positive number. The default is 8766 hours which is approximately equal
@ to a year.
@ (Property: "cookie-expire")</p>
@ <hr />
entry_attribute("Download packet limit", 10, "max-download", "mxdwn",
"5000000", 0);
@ <p>Fossil tries to limit out-bound sync, clone, and pull packets
@ to this many bytes, uncompressed. If the client requires more data
@ than this, then the client will issue multiple HTTP requests.
@ Values below 1 million are not recommended. 5 million is a
@ reasonable number. (Property: "max-download")</p>
@ <hr />
entry_attribute("Download time limit", 11, "max-download-time", "mxdwnt",
"30", 0);
@ <p>Fossil tries to spend less than this many seconds gathering
@ the out-bound data of sync, clone, and pull packets.
@ If the client request takes longer, a partial reply is given similar
@ to the download packet limit. 30s is a reasonable default.
@ (Property: "max-download-time")</p>
@ <hr />
entry_attribute("Server Load Average Limit", 11, "max-loadavg", "mxldavg",
"0.0", 0);
@ <p>Some expensive operations (such as computing tarballs, zip archives,
@ or annotation/blame pages) are prohibited if the load average on the host
@ computer is too large. Set the threshold for disallowing expensive
@ computations here. Set this to 0.0 to disable the load average limit.
@ This limit is only enforced on Unix servers. On Linux systems,
@ access to the /proc virtual filesystem is required, which means this limit
@ might not work inside a chroot() jail.
@ (Property: "max-loadavg")</p>
@ <hr />
onoff_attribute(
"Enable hyperlinks for \"nobody\" based on User-Agent and Javascript",
"auto-hyperlink", "autohyperlink", 1, 0);
@ <p>Enable hyperlinks (the equivalent of the "h" permission) for all users
@ including user "nobody", as long as (1) the User-Agent string in the
@ HTTP header indicates that the request is coming from an actual human
@ being and not a robot or spider and (2) the user agent is able to
@ run Javascript in order to set the href= attribute of hyperlinks. Bots
@ and spiders can forge a User-Agent string that makes them seem to be a
@ normal browser and they can run javascript just like browsers. But most
@ bots do not go to that much trouble so this is normally an effective
@ defense.<p>
@
@ <p>You do not normally want a bot to walk your entire repository because
@ if it does, your server will end up computing diffs and annotations for
@ every historical version of every file and creating ZIPs and tarballs of
@ every historical check-in, which can use a lot of CPU and bandwidth
@ even for relatively small projects.</p>
@
@ <p>Additional parameters that control this behavior:</p>
@ <blockquote>
onoff_attribute("Enable hyperlinks for humans as deduced from the UserAgent "
"string", "auto-hyperlink-ishuman", "ahis", 0, 0);
@ <br />
onoff_attribute("Require mouse movement before enabling hyperlinks",
"auto-hyperlink-mouseover", "ahmo", 0, 0);
@ <br />
entry_attribute("Delay in milliseconds before enabling hyperlinks", 5,
"auto-hyperlink-delay", "ah-delay", "10", 0);
@ </blockquote>
@ <p>Hyperlinks for user "nobody" are normally enabled as soon as the page
@ finishes loading. But the first check-box below can be set to require mouse
@ movement before enabling the links. One can also set a delay prior to enabling
@ links by enter a positive number of milliseconds in the entry box above.</p>
@ (Properties: "auto-hyperlink", "auto-hyperlink-ishuman",
@ "auto-hyperlink-mouseover", and "auto-hyperlink-delay")</p>
@ <hr />
onoff_attribute("Require a CAPTCHA if not logged in",
"require-captcha", "reqcapt", 1, 0);
@ <p>Require a CAPTCHA for edit operations (appending, creating, or
@ editing wiki or tickets or adding attachments to wiki or tickets)
@ for users who are not logged in. (Property: "require-captcha")</p>
@ <hr />
entry_attribute("Public pages", 30, "public-pages",
"pubpage", "", 0);
@ <p>A comma-separated list of glob patterns for pages that are accessible
@ without needing a login and using the privileges given by the
@ "Default privileges" setting below. Example use case: Set this field
@ to "/doc/trunk/www/*" to give anonymous users read-only permission to the
@ latest version of the embedded documentation in the www/ folder without
@ allowing them to see the rest of the source code.
@ (Property: "public-pages")
@ </p>
@ <hr />
onoff_attribute("Allow users to register themselves",
"self-register", "selfregister", 0, 0);
@ <p>Allow users to register themselves through the HTTP UI.
@ The registration form always requires filling in a CAPTCHA
@ (<em>auto-captcha</em> setting is ignored). Still, bear in mind that anyone
@ can register under any user name. This option is useful for public projects
@ where you do not want everyone in any ticket discussion to be named
@ "Anonymous". (Property: "self-register")</p>
@ <hr />
entry_attribute("Default privileges", 10, "default-perms",
"defaultperms", "u", 0);
@ <p>Permissions given to users that... <ul><li>register themselves using
@ the self-registration procedure (if enabled), or <li>access "public"
@ pages identified by the public-pages glob pattern above, or <li>
@ are users newly created by the administrator.</ul>
@ (Property: "default-perms")
@ </p>
@ <hr />
onoff_attribute("Show javascript button to fill in CAPTCHA",
"auto-captcha", "autocaptcha", 0, 0);
@ <p>When enabled, a button appears on the login screen for user
@ "anonymous" that will automatically fill in the CAPTCHA password.
@ This is less secure than forcing the user to do it manually, but is
@ probably secure enough and it is certainly more convenient for
@ anonymous users. (Property: "auto-captcha")</p>
@ <hr />
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
@ </div></form>
db_end_transaction(0);
style_footer();
}
|
| ︙ | ︙ | |||
1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 |
@ </table>
@
@ <p><form action="%s(g.zTop)/setup_login_group" method="post"><div>
login_insert_csrf_secret();
@ To leave this login group press
@ <input type="submit" value="Leave Login Group" name="leave">
@ </form></p>
@ <hr /><h2>Implementation Details</h2>
@ <p>The following are fields from the CONFIG table related to login-groups,
@ provided here for instructional and debugging purposes:</p>
@ <table border='1' id='configTab'>
| > > > > | > > | 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 |
@ </table>
@
@ <p><form action="%s(g.zTop)/setup_login_group" method="post"><div>
login_insert_csrf_secret();
@ To leave this login group press
@ <input type="submit" value="Leave Login Group" name="leave">
@ </form></p>
@ <br />For best results, use the same number of <a href="setup_access#ipt">
@ IP octets</a> in the login cookie across all repositories in the
@ same Login Group.
@ <hr /><h2>Implementation Details</h2>
@ <p>The following are fields from the CONFIG table related to login-groups,
@ provided here for instructional and debugging purposes:</p>
@ <table border='1' id='configTab'>
@ <thead><tr>
@ <th>Config.Name<th>Config.Value<th>Config.mtime</tr>
@ </thead><tbody>
db_prepare(&q, "SELECT name, value, datetime(mtime,'unixepoch') FROM config"
" WHERE name GLOB 'peer-*'"
" OR name GLOB 'project-*'"
" OR name GLOB 'login-group-*'"
" ORDER BY name");
while( db_step(&q)==SQLITE_ROW ){
@ <tr><td>%h(db_column_text(&q,0))</td>
@ <td>%h(db_column_text(&q,1))</td>
@ <td>%h(db_column_text(&q,2))</td></tr>
}
db_finalize(&q);
|
| ︙ | ︙ | |||
1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 |
}
style_header("Timeline Display Preferences");
db_begin_transaction();
@ <form action="%s(g.zTop)/setup_timeline" method="post"><div>
login_insert_csrf_secret();
@ <hr />
onoff_attribute("Allow block-markup in timeline",
"timeline-block-markup", "tbm", 0, 0);
@ <p>In timeline displays, check-in comments can be displayed with or
| > | > | | > | | | > | > | > > > > | > | > | > | | > | | > > | | > > > > | | | < < < < < < < | < | | > > | > > > | < < < < < < < > | > | > > | > | 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 |
}
style_header("Timeline Display Preferences");
db_begin_transaction();
@ <form action="%s(g.zTop)/setup_timeline" method="post"><div>
login_insert_csrf_secret();
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
@ <hr />
onoff_attribute("Allow block-markup in timeline",
"timeline-block-markup", "tbm", 0, 0);
@ <p>In timeline displays, check-in comments can be displayed with or
@ without block markup such as paragraphs, tables, etc.
@ (Property: "timeline-block-markup")</p>
@ <hr />
onoff_attribute("Plaintext comments on timelines",
"timeline-plaintext", "tpt", 0, 0);
@ <p>In timeline displays, check-in comments are displayed literally,
@ without any wiki or HTML interpretation. Use CSS to change
@ display formatting features such as fonts and line-wrapping behavior.
@ (Property: "timeline-plaintext")</p>
@ <hr />
onoff_attribute("Truncate comment at first blank line",
"timeline-truncate-at-blank", "ttb", 0, 0);
@ <p>In timeline displays, check-in comments are displayed only through
@ the first blank line. (Property: "timeline-truncate-at-blank")</p>
@ <hr />
onoff_attribute("Use Universal Coordinated Time (UTC)",
"timeline-utc", "utc", 1, 0);
@ <p>Show times as UTC (also sometimes called Greenwich Mean Time (GMT) or
@ Zulu) instead of in local time. On this server, local time is currently
tmDiff = db_double(0.0, "SELECT julianday('now')");
tmDiff = db_double(0.0,
"SELECT (julianday(%.17g,'localtime')-julianday(%.17g))*24.0",
tmDiff, tmDiff);
sqlite3_snprintf(sizeof(zTmDiff), zTmDiff, "%.1f", tmDiff);
if( strcmp(zTmDiff, "0.0")==0 ){
@ the same as UTC and so this setting will make no difference in
@ the display.</p>
}else if( tmDiff<0.0 ){
sqlite3_snprintf(sizeof(zTmDiff), zTmDiff, "%.1f", -tmDiff);
@ %s(zTmDiff) hours behind UTC.</p>
}else{
@ %s(zTmDiff) hours ahead of UTC.</p>
}
@ <p>(Property: "timeline-utc")
@ <hr />
multiple_choice_attribute("Per-Item Time Format", "timeline-date-format",
"tdf", "0", count(azTimeFormats)/2, azTimeFormats);
@ <p>If the "HH:MM" or "HH:MM:SS" format is selected, then the date is shown
@ in a separate box (using CSS class "timelineDate") whenever the date changes.
@ With the "YYYY-MM-DD HH:MM" and "YYMMDD ..." formats, the complete date
@ and time is shown on every timeline entry using the CSS class "timelineTime".
@ (Preperty: "timeline-date-format")</p>
@ <hr />
onoff_attribute("Show version differences by default",
"show-version-diffs", "vdiff", 0, 0);
@ <p>The version-information pages linked from the timeline can either
@ show complete diffs of all file changes, or can just list the names of
@ the files that have changed. Users can get to either page by
@ clicking. This setting selects the default.
@ (Property: "show-version-diffs")</p>
@ <hr />
entry_attribute("Max timeline comment length", 6,
"timeline-max-comment", "tmc", "0", 0);
@ <p>The maximum length of a comment to be displayed in a timeline.
@ "0" there is no length limit.
@ (Property: "timeline-max-comment")</p>
@ <hr />
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
@ </div></form>
db_end_transaction(0);
style_footer();
}
/*
** WEBPAGE: setup_settings
**
** Change or view miscellaneous settings. Part of the
** Admin pages requiring Admin privileges.
*/
void setup_settings(void){
int nSetting;
int i;
Setting const *pSet;
const Setting *aSetting = setting_info(&nSetting);
login_check_credentials();
if( !g.perm.Setup ){
login_needed(0);
return;
}
style_header("Settings");
if(!g.repositoryOpen){
/* Provide read-only access to versioned settings,
but only if no repo file was explicitly provided. */
db_open_local(0);
}
db_begin_transaction();
@ <p>Settings marked with (v) are "versionable" and will be overridden
@ by the contents of managed files named
@ "<tt>.fossil-settings/</tt><i>SETTING-NAME</i>".
@ If the file for a versionable setting exists, the value cannot be
@ changed on this screen.</p><hr /><p>
@
@ <form action="%s(g.zTop)/setup_settings" method="post"><div>
@ <table border="0"><tr><td valign="top">
login_insert_csrf_secret();
for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
if( pSet->width==0 ){
int hasVersionableValue = pSet->versionable &&
(db_get_versioned(pSet->name, NULL)!=0);
onoff_attribute("", pSet->name,
pSet->var!=0 ? pSet->var : pSet->name,
is_truth(pSet->def), hasVersionableValue);
@ <a href='%R/help?cmd=%s(pSet->name)'>%h(pSet->name)</a>
if( pSet->versionable ){
@ (v)<br />
} else {
@ <br />
}
}
}
@ <br /><input type="submit" name="submit" value="Apply Changes" />
@ </td><td style="width:50px;"></td><td valign="top">
for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
if( pSet->width!=0 && !pSet->forceTextArea ){
int hasVersionableValue = pSet->versionable &&
(db_get_versioned(pSet->name, NULL)!=0);
entry_attribute("", /*pSet->width*/ 25, pSet->name,
pSet->var!=0 ? pSet->var : pSet->name,
(char*)pSet->def, hasVersionableValue);
@ <a href='%R/help?cmd=%s(pSet->name)'>%h(pSet->name)</a>
if( pSet->versionable ){
@ (v)<br />
} else {
@ <br />
}
}
}
@ </td><td style="width:50px;"></td><td valign="top">
for(i=0, pSet=aSetting; i<nSetting; i++, pSet++){
if( pSet->width!=0 && pSet->forceTextArea ){
int hasVersionableValue = db_get_versioned(pSet->name, NULL)!=0;
@ <a href='%R/help?cmd=%s(pSet->name)'>%s(pSet->name)</a>
if( pSet->versionable ){
@ (v)<br />
} else {
@ <br />
}
textarea_attribute("", /*rows*/ 2, /*cols*/ 35, pSet->name,
pSet->var!=0 ? pSet->var : pSet->name,
(char*)pSet->def, hasVersionableValue);
@<br />
}
}
@ </td></tr></table>
@ </div></form>
db_end_transaction(0);
style_footer();
}
/*
** WEBPAGE: setup_config
**
** The "Admin/Configuration" page. Requires Admin privilege.
*/
void setup_config(void){
login_check_credentials();
if( !g.perm.Setup ){
login_needed(0);
return;
}
style_header("WWW Configuration");
db_begin_transaction();
@ <form action="%s(g.zTop)/setup_config" method="post"><div>
login_insert_csrf_secret();
@ <input type="submit" name="submit" value="Apply Changes" /></p>
@ <hr />
entry_attribute("Project Name", 60, "project-name", "pn", "", 0);
@ <p>A brief project name so visitors know what this site is about.
@ The project name will also be used as the RSS feed title.
@ (Property: "project-name")
@ </p>
@ <hr />
textarea_attribute("Project Description", 3, 80,
"project-description", "pd", "", 0);
@ <p>Describe your project. This will be used in page headers for search
@ engines as well as a short RSS description.
@ (Property: "project-description")</p>
@ <hr />
entry_attribute("Tarball and ZIP-archive Prefix", 20, "short-project-name", "spn", "", 0);
@ <p>This is used as a prefix on the names of generated tarballs and ZIP archive.
@ For best results, keep this prefix brief and avoid special characters such
@ as "/" and "\".
@ If no tarball prefix is specified, then the full Project Name above is used.
@ (Property: "short-project-name")
@ </p>
@ <hr />
onoff_attribute("Enable WYSIWYG Wiki Editing",
"wysiwyg-wiki", "wysiwyg-wiki", 0, 0);
@ <p>Enable what-you-see-is-what-you-get (WYSIWYG) editing of wiki pages.
@ The WYSIWYG editor generates HTML instead of markup, which makes
@ subsequent manual editing more difficult.
@ (Property: "wysiwyg-wiki")</p>
@ <hr />
entry_attribute("Index Page", 60, "index-page", "idxpg", "/home", 0);
@ <p>Enter the pathname of the page to display when the "Home" menu
@ option is selected and when no pathname is
@ specified in the URL. For example, if you visit the url:</p>
@
@ <blockquote><p>%h(g.zBaseURL)</p></blockquote>
|
| ︙ | ︙ | |||
1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 |
@ as the Project Name specified above. Some sites prefer to redirect
@ to a documentation page (ex: "/doc/tip/index.wiki") or to "/timeline".</p>
@
@ <p>Note: To avoid a redirect loop or other problems, this entry must
@ begin with "/" and it must specify a valid page. For example,
@ "<b>/home</b>" will work but "<b>home</b>" will not, since it omits the
@ leading "/".</p>
@ <hr />
onoff_attribute("Use HTML as wiki markup language",
"wiki-use-html", "wiki-use-html", 0, 0);
@ <p>Use HTML as the wiki markup language. Wiki links will still be parsed
@ but all other wiki formatting will be ignored. This option is helpful
@ if you have chosen to use a rich HTML editor for wiki markup such as
@ TinyMCE.</p>
@ <p><strong>CAUTION:</strong> when
@ enabling, <i>all</i> HTML tags and attributes are accepted in the wiki.
@ No sanitization is done. This means that it is very possible for malicious
@ users to inject dangerous HTML, CSS and JavaScript code into your wiki.</p>
@ <p>This should <strong>only</strong> be enabled when wiki editing is limited
@ to trusted users. It should <strong>not</strong> be used on a publically
@ editable wiki.</p>
@ <hr />
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
@ </div></form>
db_end_transaction(0);
style_footer();
}
| > > | 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 |
@ as the Project Name specified above. Some sites prefer to redirect
@ to a documentation page (ex: "/doc/tip/index.wiki") or to "/timeline".</p>
@
@ <p>Note: To avoid a redirect loop or other problems, this entry must
@ begin with "/" and it must specify a valid page. For example,
@ "<b>/home</b>" will work but "<b>home</b>" will not, since it omits the
@ leading "/".</p>
@ <p>(Property: "index-page")
@ <hr />
onoff_attribute("Use HTML as wiki markup language",
"wiki-use-html", "wiki-use-html", 0, 0);
@ <p>Use HTML as the wiki markup language. Wiki links will still be parsed
@ but all other wiki formatting will be ignored. This option is helpful
@ if you have chosen to use a rich HTML editor for wiki markup such as
@ TinyMCE.</p>
@ <p><strong>CAUTION:</strong> when
@ enabling, <i>all</i> HTML tags and attributes are accepted in the wiki.
@ No sanitization is done. This means that it is very possible for malicious
@ users to inject dangerous HTML, CSS and JavaScript code into your wiki.</p>
@ <p>This should <strong>only</strong> be enabled when wiki editing is limited
@ to trusted users. It should <strong>not</strong> be used on a publically
@ editable wiki.</p>
@ (Property: "wiki-use-html")
@ <hr />
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
@ </div></form>
db_end_transaction(0);
style_footer();
}
|
| ︙ | ︙ | |||
1643 1644 1645 1646 1647 1648 1649 |
"modreq-tkt", "modreq-tkt", 0, 0);
@ <p>When enabled, any change to tickets is subject to the approval
@ by a ticket moderator - a user with the "q" or Mod-Tkt privilege.
@ Ticket changes enter the system and are shown locally, but are not
@ synced until they are approved. The moderator has the option to
@ delete the change rather than approve it. Ticket changes made by
@ a user who has the Mod-Tkt privilege are never subject to
| | | | 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 |
"modreq-tkt", "modreq-tkt", 0, 0);
@ <p>When enabled, any change to tickets is subject to the approval
@ by a ticket moderator - a user with the "q" or Mod-Tkt privilege.
@ Ticket changes enter the system and are shown locally, but are not
@ synced until they are approved. The moderator has the option to
@ delete the change rather than approve it. Ticket changes made by
@ a user who has the Mod-Tkt privilege are never subject to
@ moderation. (Property: "modreq-tkt")
@
@ <hr />
onoff_attribute("Moderate wiki changes",
"modreq-wiki", "modreq-wiki", 0, 0);
@ <p>When enabled, any change to wiki is subject to the approval
@ by a wiki moderator - a user with the "l" or Mod-Wiki privilege.
@ Wiki changes enter the system and are shown locally, but are not
@ synced until they are approved. The moderator has the option to
@ delete the change rather than approve it. Wiki changes made by
@ a user who has the Mod-Wiki privilege are never subject to
@ moderation. (Property: "modreq-wiki")
@ </p>
@ <hr />
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
@ </div></form>
db_end_transaction(0);
style_footer();
|
| ︙ | ︙ | |||
1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 |
textarea_attribute("", 6, 80, "adunit-right", "adright", "", 0);
@ <br />
onoff_attribute("Omit ads to administrator",
"adunit-omit-if-admin", "oia", 0, 0);
@ <br />
onoff_attribute("Omit ads to logged-in users",
"adunit-omit-if-user", "oiu", 0, 0);
@ <br />
@ <input type="submit" name="submit" value="Apply Changes" />
@ <input type="submit" name="clear" value="Delete Ad-Unit" />
@ </div></form>
@ <hr />
@ <b>Ad-Unit Notes:</b><ul>
@ <li>Leave both Ad-Units blank to disable all advertising.
@ <li>The "Banner Ad-Unit" is used for wide pages.
@ <li>The "Right-Column Ad-Unit" is used on pages with tall, narrow content.
@ <li>If the "Right-Column Ad-Unit" is blank, the "Banner Ad-Unit" is used on all pages.
@ <li>Suggested <a href="setup_skinedit?w=0">CSS</a> changes:
@ <blockquote><pre>
@ div.adunit_banner {
@ margin: auto;
| > > > > > | | 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 |
textarea_attribute("", 6, 80, "adunit-right", "adright", "", 0);
@ <br />
onoff_attribute("Omit ads to administrator",
"adunit-omit-if-admin", "oia", 0, 0);
@ <br />
onoff_attribute("Omit ads to logged-in users",
"adunit-omit-if-user", "oiu", 0, 0);
@ <br />
onoff_attribute("Temporarily disable all ads",
"adunit-disable", "oall", 0, 0);
@ <br />
@ <input type="submit" name="submit" value="Apply Changes" />
@ <input type="submit" name="clear" value="Delete Ad-Unit" />
@ </div></form>
@ <hr />
@ <b>Ad-Unit Notes:</b><ul>
@ <li>Leave both Ad-Units blank to disable all advertising.
@ <li>The "Banner Ad-Unit" is used for wide pages.
@ <li>The "Right-Column Ad-Unit" is used on pages with tall, narrow content.
@ <li>If the "Right-Column Ad-Unit" is blank, the "Banner Ad-Unit" is used on all pages.
@ <li>Properties: "adunit", "adunit-right", "adunit-omit-if-admin", and
@ "adunit-omit-if-user".
@ <li>Suggested <a href="setup_skinedit?w=0">CSS</a> changes:
@ <blockquote><pre>
@ div.adunit_banner {
@ margin: auto;
@ width: 100%%;
@ }
@ div.adunit_right {
@ float: right;
@ }
@ div.adunit_right_container {
@ min-height: <i>height-of-right-column-ad-unit</i>;
@ }
|
| ︙ | ︙ | |||
1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 | @ To change the logo image, use the following form:</p> login_insert_csrf_secret(); @ Logo Image file: @ <input type="file" name="logoim" size="60" accept="image/*" /> @ <p align="center"> @ <input type="submit" name="setlogo" value="Change Logo" /> @ <input type="submit" name="clrlogo" value="Revert To Default" /></p> @ </div></form> @ <hr /> @ @ <p>The current background image has a MIME-Type of <b>%h(zBgMime)</b> @ and looks like this:</p> @ <blockquote><p><img src="%s(g.zTop)/background/%z(zBgMtime)" alt="background" border=1 /> @ </p></blockquote> | > | 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 | @ To change the logo image, use the following form:</p> login_insert_csrf_secret(); @ Logo Image file: @ <input type="file" name="logoim" size="60" accept="image/*" /> @ <p align="center"> @ <input type="submit" name="setlogo" value="Change Logo" /> @ <input type="submit" name="clrlogo" value="Revert To Default" /></p> @ <p>(Properties: "logo-image" and "logo-mimetype") @ </div></form> @ <hr /> @ @ <p>The current background image has a MIME-Type of <b>%h(zBgMime)</b> @ and looks like this:</p> @ <blockquote><p><img src="%s(g.zTop)/background/%z(zBgMtime)" alt="background" border=1 /> @ </p></blockquote> |
| ︙ | ︙ | |||
1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 | login_insert_csrf_secret(); @ Background image file: @ <input type="file" name="bgim" size="60" accept="image/*" /> @ <p align="center"> @ <input type="submit" name="setbg" value="Change Background" /> @ <input type="submit" name="clrbg" value="Revert To Default" /></p> @ </div></form> @ <hr /> @ @ <p><span class="note">Note:</span> Your browser has probably cached these @ images, so you may need to press the Reload button before changes will @ take effect. </p> style_footer(); db_end_transaction(0); | > | 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 | login_insert_csrf_secret(); @ Background image file: @ <input type="file" name="bgim" size="60" accept="image/*" /> @ <p align="center"> @ <input type="submit" name="setbg" value="Change Background" /> @ <input type="submit" name="clrbg" value="Revert To Default" /></p> @ </div></form> @ <p>(Properties: "background-image" and "background-mimetype") @ <hr /> @ @ <p><span class="note">Note:</span> Your browser has probably cached these @ images, so you may need to press the Reload button before changes will @ take effect. </p> style_footer(); db_end_transaction(0); |
| ︙ | ︙ | |||
1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 |
add_content_sql_commands(g.db);
db_begin_transaction();
style_header("Raw SQL Commands");
@ <p><b>Caution:</b> There are no restrictions on the SQL that can be
@ run by this page. You can do serious and irrepairable damage to the
@ repository. Proceed with extreme caution.</p>
@
@ <p>Only the first statement in the entry box will be run.
@ Any subsequent statements will be silently ignored.</p>
@
@ <p>Database names:<ul><li>repository
if( g.zConfigDbName ){
@ <li>configdb
}
if( g.localOpen ){
@ <li>localdb
}
@ </ul></p>
@
@ <form method="post" action="%s(g.zTop)/admin_sql">
login_insert_csrf_secret();
@ SQL:<br />
| > > > > > > > > > > > > > > > | > | | 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 |
add_content_sql_commands(g.db);
db_begin_transaction();
style_header("Raw SQL Commands");
@ <p><b>Caution:</b> There are no restrictions on the SQL that can be
@ run by this page. You can do serious and irrepairable damage to the
@ repository. Proceed with extreme caution.</p>
@
#if 0
@ <p>Only the first statement in the entry box will be run.
@ Any subsequent statements will be silently ignored.</p>
@
@ <p>Database names:<ul><li>repository
if( g.zConfigDbName ){
@ <li>configdb
}
if( g.localOpen ){
@ <li>localdb
}
@ </ul></p>
#endif
if( P("configtab") ){
/* If the user presses the "CONFIG Table Query" button, populate the
** query text with a pre-packaged query against the CONFIG table */
zQ = "SELECT\n"
" CASE WHEN length(name)<50 THEN name ELSE printf('%.50s...',name) END AS name,\n"
" CASE WHEN typeof(value)<>'blob' AND length(value)<80 THEN value\n"
" ELSE '...' END AS value,\n"
" datetime(mtime, 'unixepoch') AS mtime\n"
"FROM config\n"
"-- ORDER BY mtime DESC; -- optional";
go = 1;
}
@
@ <form method="post" action="%s(g.zTop)/admin_sql">
login_insert_csrf_secret();
@ SQL:<br />
@ <textarea name="q" rows="8" cols="80">%h(zQ)</textarea><br />
@ <input type="submit" name="go" value="Run SQL">
@ <input type="submit" name="schema" value="Show Schema">
@ <input type="submit" name="tablelist" value="List Tables">
@ <input type="submit" name="configtab" value="CONFIG Table Query">
@ </form>
if( P("schema") ){
zQ = sqlite3_mprintf(
"SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL ORDER BY name");
go = 1;
}else if( P("tablelist") ){
zQ = sqlite3_mprintf(
"SELECT name FROM repository.sqlite_master WHERE type='table'"
" ORDER BY name");
go = 1;
}
|
| ︙ | ︙ | |||
2052 2053 2054 2055 2056 2057 2058 |
}else{
@ <pre class="th1error">%h(zR)</pre>
}
}
style_footer();
}
| < < < < < < < < < < < < < < | < | > | > | | > | < | | | | | < < < | < < > > > | | | > > | 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 |
}else{
@ <pre class="th1error">%h(zR)</pre>
}
}
style_footer();
}
/*
** WEBPAGE: admin_log
**
** Shows the contents of the admin_log table, which is only created if
** the admin-log setting is enabled. Requires Admin or Setup ('a' or
** 's') permissions.
*/
void page_admin_log(){
Stmt stLog;
int limit; /* How many entries to show */
int ofst; /* Offset to the first entry */
int fLogEnabled;
int counter = 0;
login_check_credentials();
if( !g.perm.Setup && !g.perm.Admin ){
login_needed(0);
return;
}
style_header("Admin Log");
create_admin_log_table();
limit = atoi(PD("n","200"));
ofst = atoi(PD("x","0"));
fLogEnabled = db_get_boolean("admin-log", 0);
@ <div>Admin logging is %s(fLogEnabled?"on":"off").
@ (Change this on the <a href="setup_settings">settings</a> page.)</div>
if( ofst>0 ){
int prevx = ofst - limit;
if( prevx<0 ) prevx = 0;
@ <p><a href="admin_log?n=%d(limit)&x=%d(prevx)">[Newer]</a></p>
}
db_prepare(&stLog,
"SELECT datetime(time,'unixepoch'), who, page, what "
"FROM admin_log "
"ORDER BY time DESC");
@ <table id="adminLogTable" class="adminLogTable" width="100%%">
@ <thead>
@ <th>Time</th>
@ <th>User</th>
@ <th>Page</th>
@ <th width="60%%">Message</th>
@ </thead><tbody>
while( SQLITE_ROW == db_step(&stLog) ){
const char *zTime = db_column_text(&stLog, 0);
const char *zUser = db_column_text(&stLog, 1);
const char *zPage = db_column_text(&stLog, 2);
const char *zMessage = db_column_text(&stLog, 3);
counter++;
if( counter<ofst ) continue;
if( counter>ofst+limit ) break;
@ <tr class="row%d(counter%2)">
@ <td class="adminTime">%s(zTime)</td>
@ <td>%s(zUser)</td>
@ <td>%s(zPage)</td>
@ <td>%h(zMessage)</td>
@ </tr>
}
@ </tbody></table>
if( counter>ofst+limit ){
@ <p><a href="admin_log?n=%d(limit)&x=%d(limit+ofst)">[Older]</a></p>
}
output_table_sorting_javascript("adminLogTable", "Tttx", 1);
style_footer();
}
/*
** WEBPAGE: srchsetup
**
** Configure the search engine. Requires Admin privilege.
|
| ︙ | ︙ | |||
2178 2179 2180 2181 2182 2183 2184 |
@ <hr />
onoff_attribute("Search Check-in Comments", "search-ci", "sc", 0, 0);
@ <br />
onoff_attribute("Search Documents", "search-doc", "sd", 0, 0);
@ <br />
onoff_attribute("Search Tickets", "search-tkt", "st", 0, 0);
@ <br />
| | > > | 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 |
@ <hr />
onoff_attribute("Search Check-in Comments", "search-ci", "sc", 0, 0);
@ <br />
onoff_attribute("Search Documents", "search-doc", "sd", 0, 0);
@ <br />
onoff_attribute("Search Tickets", "search-tkt", "st", 0, 0);
@ <br />
onoff_attribute("Search Wiki", "search-wiki", "sw", 0, 0);
@ <br />
onoff_attribute("Search Tech Notes", "search-technote", "se", 0, 0);
@ <hr />
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
@ <hr />
if( P("fts0") ){
search_drop_index();
}else if( P("fts1") ){
search_drop_index();
|
| ︙ | ︙ | |||
2206 2207 2208 2209 2210 2211 2212 |
@ larger repositories.</p>
onoff_attribute("Use Porter Stemmer","search-stemmer","ss",0,0);
@ <p><input type="submit" name="fts1" value="Create A Full-Text Index">
}
@ </div></form>
style_footer();
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 |
@ larger repositories.</p>
onoff_attribute("Use Porter Stemmer","search-stemmer","ss",0,0);
@ <p><input type="submit" name="fts1" value="Create A Full-Text Index">
}
@ </div></form>
style_footer();
}
/*
** A URL Alias originally called zOldName is now zNewName/zValue.
** Write SQL to make this change into pSql.
**
** If zNewName or zValue is an empty string, then delete the entry.
**
** If zOldName is an empty string, create a new entry.
*/
static void setup_update_url_alias(
Blob *pSql,
const char *zOldName,
const char *zNewName,
const char *zValue
){
if( zNewName[0]==0 || zValue[0]==0 ){
if( zOldName[0] ){
blob_append_sql(pSql,
"DELETE FROM config WHERE name='walias:%q';\n",
zOldName);
}
return;
}
if( zOldName[0]==0 ){
blob_append_sql(pSql,
"INSERT INTO config(name,value,mtime) VALUES('walias:%q',%Q,now());\n",
zNewName, zValue);
return;
}
if( strcmp(zOldName, zNewName)!=0 ){
blob_append_sql(pSql,
"UPDATE config SET name='walias:%q', value=%Q, mtime=now()"
" WHERE name='walias:%q';\n",
zNewName, zValue, zOldName);
}else{
blob_append_sql(pSql,
"UPDATE config SET value=%Q, mtime=now()"
" WHERE name='walias:%q' AND value<>%Q;\n",
zValue, zOldName, zValue);
}
}
/*
** WEBPAGE: waliassetup
**
** Configure the URL aliases
*/
void page_waliassetup(){
Stmt q;
int cnt = 0;
Blob namelist;
login_check_credentials();
if( !g.perm.Setup && !g.perm.Admin ){
login_needed(0);
return;
}
style_header("URL Alias Configuration");
if( P("submit")!=0 ){
Blob token;
Blob sql;
const char *zNewName;
const char *zValue;
char zCnt[10];
login_verify_csrf_secret();
blob_init(&namelist, PD("namelist",""), -1);
blob_init(&sql, 0, 0);
while( blob_token(&namelist, &token) ){
const char *zOldName = blob_str(&token);
sqlite3_snprintf(sizeof(zCnt), zCnt, "n%d", cnt);
zNewName = PD(zCnt, "");
sqlite3_snprintf(sizeof(zCnt), zCnt, "v%d", cnt);
zValue = PD(zCnt, "");
setup_update_url_alias(&sql, zOldName, zNewName, zValue);
cnt++;
blob_reset(&token);
}
sqlite3_snprintf(sizeof(zCnt), zCnt, "n%d", cnt);
zNewName = PD(zCnt,"");
sqlite3_snprintf(sizeof(zCnt), zCnt, "v%d", cnt);
zValue = PD(zCnt,"");
setup_update_url_alias(&sql, "", zNewName, zValue);
db_multi_exec("%s", blob_sql_text(&sql));
blob_reset(&sql);
blob_reset(&namelist);
cnt = 0;
}
db_prepare(&q,
"SELECT substr(name,8), value FROM config WHERE name GLOB 'walias:/*'"
" UNION ALL SELECT '', ''"
);
@ <form action="%s(g.zTop)/waliassetup" method="post"><div>
login_insert_csrf_secret();
@ <table border=0 cellpadding=5>
@ <tr><th>Alias<th>URI That The Alias Maps Into
blob_init(&namelist, 0, 0);
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
const char *zValue = db_column_text(&q, 1);
@ <tr><td>
@ <input type='text' size='20' value='%h(zName)' name='n%d(cnt)'>
@ </td><td>
@ <input type='text' size='80' value='%h(zValue)' name='v%d(cnt)'>
@ </td></tr>
cnt++;
if( blob_size(&namelist)>0 ) blob_append(&namelist, " ", 1);
blob_append(&namelist, zName, -1);
}
db_finalize(&q);
@ <tr><td>
@ <input type='hidden' name='namelist' value='%h(blob_str(&namelist))'>
@ <input type='submit' name='submit' value="Apply Changes">
@ </td><td></td></tr>
@ </table></form>
@ <hr>
@ <p>When the first term of an incoming URL exactly matches one of the "Aliases" on
@ the left-hand side (LHS) above, the URL is converted into the corresponding form
@ on the right-hand side (RHS).
@ <ul>
@ <li><p>
@ The LHS is compared against only the first term of the incoming URL.
@ All LHS entries in the alias table should therefore begin with a
@ single "/" followed by a single path element.
@ <li><p>
@ The RHS entries in the alias table should begin with a single "/" followed by
@ a path element, and optionally followed by "?" and a list of query parameters.
@ <li><p>
@ Query parameters on the RHS are added to the set of query parameters
@ in the incoming URL.
@ <li><p>
@ If the same query parameter appears in both the incoming URL and on the RHS of the
@ alias, the RHS query parameter value overwrites the value on the incoming URL.
@ <li><p>
@ If a query parameter on the RHS of the alias is of the form "X!" (a name followed
@ by "!") then the X query parameter is removed from the incoming URL if it exists.
@ <li><p>
@ Only a single alias operation occurs. It is not possible to nest aliases.
@ The RHS entries must be built-in webpage names.
@ <li><p>
@ The alias table is only checked if no built-in webpage matches the incoming URL.
@ Hence, it is not possible to override a built-in webpage using aliases. This is
@ by design.
@ </ul>
@
@ <p>To delete an entry from the alias table, change its name or value to an
@ empty string and press "Apply Changes".
@
@ <p>To add a new alias, fill in the name and value in the bottom row of the table
@ above and press "Apply Changes".
style_footer();
}
|
Changes to src/sha1.c.
| ︙ | ︙ | |||
15 16 17 18 19 20 21 | ** ******************************************************************************* ** ** This implementation of SHA1. */ #include "config.h" #include <sys/types.h> | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ** ******************************************************************************* ** ** This implementation of SHA1. */ #include "config.h" #include <sys/types.h> #include "sha1.h" /* ** SHA1 Implementation #1 is the hardened SHA1 implementation by ** Marc Stevens. Code obtained from GitHub ** |
| ︙ | ︙ |
Changes to src/sha3.c.
| ︙ | ︙ | |||
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
blob_zero(pCksum);
}
blob_resize(pCksum, iSize/4);
DigestToBase16(SHA3Final(&ctx), blob_buffer(pCksum), iSize/8);
return 0;
}
/*
** Compute the SHA3 checksum of a zero-terminated string. The
** result is held in memory obtained from mprintf().
*/
char *sha3sum(const char *zIn, int iSize){
SHA3Context ctx;
char zDigest[132];
SHA3Init(&ctx, iSize);
SHA3Update(&ctx, (unsigned const char*)zIn, strlen(zIn));
| > | > > > > | 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
blob_zero(pCksum);
}
blob_resize(pCksum, iSize/4);
DigestToBase16(SHA3Final(&ctx), blob_buffer(pCksum), iSize/8);
return 0;
}
#if 0 /* NOT USED */
/*
** Compute the SHA3 checksum of a zero-terminated string. The
** result is held in memory obtained from mprintf().
*/
char *sha3sum(const char *zIn, int iSize){
SHA3Context ctx;
char zDigest[132];
SHA3Init(&ctx, iSize);
SHA3Update(&ctx, (unsigned const char*)zIn, strlen(zIn));
DigestToBase16(SHA3Final(&ctx), zDigest, iSize/8);
return mprintf("%s", zDigest);
}
#endif
/*
** COMMAND: sha3sum*
**
** Usage: %fossil sha3sum FILE...
**
** Compute an SHA3 checksum of all files named on the command-line.
** If a file is named "-" then take its content from standard input.
**
** To be clear: The official NIST FIPS-202 implementation of SHA3
** with the added 01 padding is used, not the original Keccak submission.
**
** Options:
**
** --224 Compute a SHA3-224 hash
** --256 Compute a SHA3-256 hash (the default)
** --384 Compute a SHA3-384 hash
** --512 Compute a SHA3-512 hash
** --size N An N-bit hash. N must be a multiple of 32 between 128
|
| ︙ | ︙ |
Changes to src/shell.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. */ #if (defined(_WIN32) || defined(WIN32)) && !defined(_CRT_SECURE_NO_WARNINGS) /* This needs to come before any includes for MSVC compiler */ #define _CRT_SECURE_NO_WARNINGS #endif /* | > > > > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | /* DO NOT EDIT! ** This file is automatically generated by the script in the canonical ** SQLite source tree at tool/mkshellc.tcl. That script combines source ** code from various constituent source files of SQLite into this single ** "shell.c" file used to implement the SQLite command-line shell. ** ** Most of the code found below comes from the "src/shell.c.in" file in ** the canonical SQLite source tree. That main file contains "INCLUDE" ** lines that specify other files in the canonical source tree that are ** inserted to getnerate this complete program source file. ** ** The code from multiple files is combined into this single "shell.c" ** source file to help make the command-line program easier to compile. ** ** To modify this program, get a copy of the canonical SQLite source tree, ** edit the src/shell.c.in" and/or some of the other files that are included ** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script. */ /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. */ #if (defined(_WIN32) || defined(WIN32)) && !defined(_CRT_SECURE_NO_WARNINGS) /* This needs to come before any includes for MSVC compiler */ #define _CRT_SECURE_NO_WARNINGS #endif /* ** Warning pragmas copied from msvc.h in the core. */ #if defined(_MSC_VER) #pragma warning(disable : 4054) #pragma warning(disable : 4055) #pragma warning(disable : 4100) #pragma warning(disable : 4127) #pragma warning(disable : 4130) #pragma warning(disable : 4152) #pragma warning(disable : 4189) #pragma warning(disable : 4206) #pragma warning(disable : 4210) #pragma warning(disable : 4232) #pragma warning(disable : 4244) #pragma warning(disable : 4305) #pragma warning(disable : 4306) #pragma warning(disable : 4702) #pragma warning(disable : 4706) #endif /* defined(_MSC_VER) */ /* ** No support for loadable extensions in VxWorks. */ #if (defined(__RTP__) || defined(_WRS_KERNEL)) && !SQLITE_OMIT_LOAD_EXTENSION # define SQLITE_OMIT_LOAD_EXTENSION 1 #endif |
| ︙ | ︙ | |||
423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
z = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
utf8_printf(iotrace, "%s", z);
sqlite3_free(z);
}
#endif
/*
** Determines if a string is a number of not.
*/
static int isNumber(const char *z, int *realnum){
if( *z=='-' || *z=='+' ) z++;
if( !IsDigit(*z) ){
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
z = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
utf8_printf(iotrace, "%s", z);
sqlite3_free(z);
}
#endif
/*
** Output string zUtf to stream pOut as w characters. If w is negative,
** then right-justify the text. W is the width in UTF-8 characters, not
** in bytes. This is different from the %*.*s specification in printf
** since with %*.*s the width is measured in bytes, not characters.
*/
static void utf8_width_print(FILE *pOut, int w, const char *zUtf){
int i;
int n;
int aw = w<0 ? -w : w;
char zBuf[1000];
if( aw>(int)sizeof(zBuf)/3 ) aw = (int)sizeof(zBuf)/3;
for(i=n=0; zUtf[i]; i++){
if( (zUtf[i]&0xc0)!=0x80 ){
n++;
if( n==aw ){
do{ i++; }while( (zUtf[i]&0xc0)==0x80 );
break;
}
}
}
if( n>=aw ){
utf8_printf(pOut, "%.*s", i, zUtf);
}else if( w<0 ){
utf8_printf(pOut, "%*s%s", aw-n, "", zUtf);
}else{
utf8_printf(pOut, "%s%*s", zUtf, aw-n, "");
}
}
/*
** Determines if a string is a number of not.
*/
static int isNumber(const char *z, int *realnum){
if( *z=='-' || *z=='+' ) z++;
if( !IsDigit(*z) ){
|
| ︙ | ︙ | |||
460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
** lower 30 bits of a 32-bit signed integer.
*/
static int strlen30(const char *z){
const char *z2 = z;
while( *z2 ){ z2++; }
return 0x3fffffff & (int)(z2 - z);
}
/*
** This routine reads a line of text from FILE in, stores
** the text in memory obtained from malloc() and returns a pointer
** to the text. NULL is returned at end of file, or if malloc()
** fails.
**
| > > > > > > > > > > > > | 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
** lower 30 bits of a 32-bit signed integer.
*/
static int strlen30(const char *z){
const char *z2 = z;
while( *z2 ){ z2++; }
return 0x3fffffff & (int)(z2 - z);
}
/*
** Return the length of a string in characters. Multibyte UTF8 characters
** count as a single character.
*/
static int strlenChar(const char *z){
int n = 0;
while( *z ){
if( (0xc0&*(z++))!=0x80 ) n++;
}
return n;
}
/*
** This routine reads a line of text from FILE in, stores
** the text in memory obtained from malloc() and returns a pointer
** to the text. NULL is returned at end of file, or if malloc()
** fails.
**
|
| ︙ | ︙ | |||
669 670 671 672 673 674 675 |
}else{
upr = mid-1;
}
}
return 0;
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > > > > > > > > > > > > > > > > > > > > > | 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 |
}else{
upr = mid-1;
}
}
return 0;
}
/*
** SQL function: shell_add_schema(S,X)
**
** Add the schema name X to the CREATE statement in S and return the result.
** Examples:
**
** CREATE TABLE t1(x) -> CREATE TABLE xyz.t1(x);
**
** Also works on
**
** CREATE INDEX
** CREATE UNIQUE INDEX
** CREATE VIEW
** CREATE TRIGGER
** CREATE VIRTUAL TABLE
**
** This UDF is used by the .schema command to insert the schema name of
** attached databases into the middle of the sqlite_master.sql field.
*/
static void shellAddSchemaName(
sqlite3_context *pCtx,
int nVal,
sqlite3_value **apVal
){
static const char *aPrefix[] = {
"TABLE",
"INDEX",
"UNIQUE INDEX",
"VIEW",
"TRIGGER",
"VIRTUAL TABLE"
};
int i = 0;
const char *zIn = (const char*)sqlite3_value_text(apVal[0]);
const char *zSchema = (const char*)sqlite3_value_text(apVal[1]);
assert( nVal==2 );
if( zIn!=0 && strncmp(zIn, "CREATE ", 7)==0 ){
for(i=0; i<(int)(sizeof(aPrefix)/sizeof(aPrefix[0])); i++){
int n = strlen30(aPrefix[i]);
if( strncmp(zIn+7, aPrefix[i], n)==0 && zIn[n+7]==' ' ){
char cQuote = quoteChar(zSchema);
char *z;
if( cQuote ){
z = sqlite3_mprintf("%.*s \"%w\".%s", n+7, zIn, zSchema, zIn+n+8);
}else{
z = sqlite3_mprintf("%.*s %s.%s", n+7, zIn, zSchema, zIn+n+8);
}
sqlite3_result_text(pCtx, z, -1, sqlite3_free);
return;
}
}
}
sqlite3_result_value(pCtx, apVal[0]);
}
/*
** The source code for several run-time loadable extensions is inserted
** below by the ../tool/mkshellc.tcl script. Before processing that included
** code, we need to override some macros to make the included program code
** work here in the middle of this regular program.
*/
#define SQLITE_EXTENSION_INIT1
#define SQLITE_EXTENSION_INIT2(X) (void)(X)
/************************* Begin ../ext/misc/shathree.c ******************/
/*
** 2017-03-08
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
******************************************************************************
**
** This SQLite extension implements a functions that compute SHA1 hashes.
** Two SQL functions are implemented:
**
** sha3(X,SIZE)
** sha3_query(Y,SIZE)
**
** The sha3(X) function computes the SHA3 hash of the input X, or NULL if
** X is NULL.
**
** The sha3_query(Y) function evalutes all queries in the SQL statements of Y
** and returns a hash of their results.
**
** The SIZE argument is optional. If omitted, the SHA3-256 hash algorithm
** is used. If SIZE is included it must be one of the integers 224, 256,
** 384, or 512, to determine SHA3 hash variant that is computed.
*/
SQLITE_EXTENSION_INIT1
#include <assert.h>
#include <string.h>
#include <stdarg.h>
typedef sqlite3_uint64 u64;
/******************************************************************************
** The Hash Engine
*/
/*
** Macros to determine whether the machine is big or little endian,
** and whether or not that determination is run-time or compile-time.
**
** For best performance, an attempt is made to guess at the byte-order
** using C-preprocessor macros. If that is unsuccessful, or if
** -DSHA3_BYTEORDER=0 is set, then byte-order is determined
|
| ︙ | ︙ | |||
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 |
SHA3Update(p, &c3, 1);
}
for(i=0; i<p->nRate; i++){
p->u.x[i+p->nRate] = p->u.x[i^p->ixMask];
}
return &p->u.x[p->nRate];
}
/*
** Implementation of the sha3(X,SIZE) function.
**
** Return a BLOB which is the SIZE-bit SHA3 hash of X. The default
** size is 256. If X is a BLOB, it is hashed as is.
** For all other non-NULL types of input, X is converted into a UTF-8 string
| > > | 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 |
SHA3Update(p, &c3, 1);
}
for(i=0; i<p->nRate; i++){
p->u.x[i+p->nRate] = p->u.x[i^p->ixMask];
}
return &p->u.x[p->nRate];
}
/* End of the hashing logic
*****************************************************************************/
/*
** Implementation of the sha3(X,SIZE) function.
**
** Return a BLOB which is the SIZE-bit SHA3 hash of X. The default
** size is 256. If X is a BLOB, it is hashed as is.
** For all other non-NULL types of input, X is converted into a UTF-8 string
|
| ︙ | ︙ | |||
1256 1257 1258 1259 1260 1261 1262 |
sqlite3_finalize(pStmt);
sqlite3_result_error(context, zMsg, -1);
sqlite3_free(zMsg);
return;
}
nCol = sqlite3_column_count(pStmt);
z = sqlite3_sql(pStmt);
| < < < < | 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 |
sqlite3_finalize(pStmt);
sqlite3_result_error(context, zMsg, -1);
sqlite3_free(zMsg);
return;
}
nCol = sqlite3_column_count(pStmt);
z = sqlite3_sql(pStmt);
n = (int)strlen(z);
hash_step_vformat(&cx,"S%d:",n);
SHA3Update(&cx,(unsigned char*)z,n);
/* Compute a hash over the result of the query */
while( SQLITE_ROW==sqlite3_step(pStmt) ){
SHA3Update(&cx,(const unsigned char*)"R",1);
|
| ︙ | ︙ | |||
1322 1323 1324 1325 1326 1327 1328 |
}
}
}
sqlite3_finalize(pStmt);
}
sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 |
}
}
}
sqlite3_finalize(pStmt);
}
sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);
}
#ifdef _WIN32
#endif
int sqlite3_shathree_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
){
int rc = SQLITE_OK;
SQLITE_EXTENSION_INIT2(pApi);
(void)pzErrMsg; /* Unused parameter */
rc = sqlite3_create_function(db, "sha3", 1, SQLITE_UTF8, 0,
sha3Func, 0, 0);
if( rc==SQLITE_OK ){
rc = sqlite3_create_function(db, "sha3", 2, SQLITE_UTF8, 0,
sha3Func, 0, 0);
}
if( rc==SQLITE_OK ){
rc = sqlite3_create_function(db, "sha3_query", 1, SQLITE_UTF8, 0,
sha3QueryFunc, 0, 0);
}
if( rc==SQLITE_OK ){
rc = sqlite3_create_function(db, "sha3_query", 2, SQLITE_UTF8, 0,
sha3QueryFunc, 0, 0);
}
return rc;
}
/************************* End ../ext/misc/shathree.c ********************/
/************************* Begin ../ext/misc/fileio.c ******************/
/*
** 2014-06-13
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
******************************************************************************
**
** This SQLite extension implements SQL functions readfile() and
** writefile().
*/
SQLITE_EXTENSION_INIT1
#include <stdio.h>
/*
** Implementation of the "readfile(X)" SQL function. The entire content
** of the file named X is read and returned as a BLOB. NULL is returned
** if the file does not exist or is unreadable.
*/
static void readfileFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
const char *zName;
FILE *in;
long nIn;
void *pBuf;
(void)(argc); /* Unused parameter */
zName = (const char*)sqlite3_value_text(argv[0]);
if( zName==0 ) return;
in = fopen(zName, "rb");
if( in==0 ) return;
fseek(in, 0, SEEK_END);
nIn = ftell(in);
rewind(in);
pBuf = sqlite3_malloc( nIn );
if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
}else{
sqlite3_free(pBuf);
}
fclose(in);
}
/*
** Implementation of the "writefile(X,Y)" SQL function. The argument Y
** is written into file X. The number of bytes written is returned. Or
** NULL is returned if something goes wrong, such as being unable to open
** file X for writing.
*/
static void writefileFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
FILE *out;
const char *z;
sqlite3_int64 rc;
const char *zFile;
(void)(argc); /* Unused parameter */
zFile = (const char*)sqlite3_value_text(argv[0]);
if( zFile==0 ) return;
out = fopen(zFile, "wb");
if( out==0 ) return;
z = (const char*)sqlite3_value_blob(argv[1]);
if( z==0 ){
rc = 0;
}else{
rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);
}
fclose(out);
sqlite3_result_int64(context, rc);
}
#ifdef _WIN32
#endif
int sqlite3_fileio_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
){
int rc = SQLITE_OK;
SQLITE_EXTENSION_INIT2(pApi);
(void)pzErrMsg; /* Unused parameter */
rc = sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
readfileFunc, 0, 0);
if( rc==SQLITE_OK ){
rc = sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
writefileFunc, 0, 0);
}
return rc;
}
/************************* End ../ext/misc/fileio.c ********************/
/************************* Begin ../ext/misc/completion.c ******************/
/*
** 2017-07-10
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file implements an eponymous virtual table that returns suggested
** completions for a partial SQL input.
**
** Suggested usage:
**
** SELECT DISTINCT candidate COLLATE nocase
** FROM completion($prefix,$wholeline)
** ORDER BY 1;
**
** The two query parameters are optional. $prefix is the text of the
** current word being typed and that is to be completed. $wholeline is
** the complete input line, used for context.
**
** The raw completion() table might return the same candidate multiple
** times, for example if the same column name is used to two or more
** tables. And the candidates are returned in an arbitrary order. Hence,
** the DISTINCT and ORDER BY are recommended.
**
** This virtual table operates at the speed of human typing, and so there
** is no attempt to make it fast. Even a slow implementation will be much
** faster than any human can type.
**
*/
SQLITE_EXTENSION_INIT1
#include <assert.h>
#include <string.h>
#include <ctype.h>
#ifndef SQLITE_OMIT_VIRTUALTABLE
/* completion_vtab is a subclass of sqlite3_vtab which will
** serve as the underlying representation of a completion virtual table
*/
typedef struct completion_vtab completion_vtab;
struct completion_vtab {
sqlite3_vtab base; /* Base class - must be first */
sqlite3 *db; /* Database connection for this completion vtab */
};
/* completion_cursor is a subclass of sqlite3_vtab_cursor which will
** serve as the underlying representation of a cursor that scans
** over rows of the result
*/
typedef struct completion_cursor completion_cursor;
struct completion_cursor {
sqlite3_vtab_cursor base; /* Base class - must be first */
sqlite3 *db; /* Database connection for this cursor */
int nPrefix, nLine; /* Number of bytes in zPrefix and zLine */
char *zPrefix; /* The prefix for the word we want to complete */
char *zLine; /* The whole that we want to complete */
const char *zCurrentRow; /* Current output row */
sqlite3_stmt *pStmt; /* Current statement */
sqlite3_int64 iRowid; /* The rowid */
int ePhase; /* Current phase */
int j; /* inter-phase counter */
};
/* Values for ePhase:
*/
#define COMPLETION_FIRST_PHASE 1
#define COMPLETION_KEYWORDS 1
#define COMPLETION_PRAGMAS 2
#define COMPLETION_FUNCTIONS 3
#define COMPLETION_COLLATIONS 4
#define COMPLETION_INDEXES 5
#define COMPLETION_TRIGGERS 6
#define COMPLETION_DATABASES 7
#define COMPLETION_TABLES 8
#define COMPLETION_COLUMNS 9
#define COMPLETION_MODULES 10
#define COMPLETION_EOF 11
/*
** The completionConnect() method is invoked to create a new
** completion_vtab that describes the completion virtual table.
**
** Think of this routine as the constructor for completion_vtab objects.
**
** All this routine needs to do is:
**
** (1) Allocate the completion_vtab object and initialize all fields.
**
** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
** result set of queries against completion will look like.
*/
static int completionConnect(
sqlite3 *db,
void *pAux,
int argc, const char *const*argv,
sqlite3_vtab **ppVtab,
char **pzErr
){
completion_vtab *pNew;
int rc;
(void)(pAux); /* Unused parameter */
(void)(argc); /* Unused parameter */
(void)(argv); /* Unused parameter */
(void)(pzErr); /* Unused parameter */
/* Column numbers */
#define COMPLETION_COLUMN_CANDIDATE 0 /* Suggested completion of the input */
#define COMPLETION_COLUMN_PREFIX 1 /* Prefix of the word to be completed */
#define COMPLETION_COLUMN_WHOLELINE 2 /* Entire line seen so far */
#define COMPLETION_COLUMN_PHASE 3 /* ePhase - used for debugging only */
rc = sqlite3_declare_vtab(db,
"CREATE TABLE x("
" candidate TEXT,"
" prefix TEXT HIDDEN,"
" wholeline TEXT HIDDEN,"
" phase INT HIDDEN" /* Used for debugging only */
")");
if( rc==SQLITE_OK ){
pNew = sqlite3_malloc( sizeof(*pNew) );
*ppVtab = (sqlite3_vtab*)pNew;
if( pNew==0 ) return SQLITE_NOMEM;
memset(pNew, 0, sizeof(*pNew));
pNew->db = db;
}
return rc;
}
/*
** This method is the destructor for completion_cursor objects.
*/
static int completionDisconnect(sqlite3_vtab *pVtab){
sqlite3_free(pVtab);
return SQLITE_OK;
}
/*
** Constructor for a new completion_cursor object.
*/
static int completionOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
completion_cursor *pCur;
pCur = sqlite3_malloc( sizeof(*pCur) );
if( pCur==0 ) return SQLITE_NOMEM;
memset(pCur, 0, sizeof(*pCur));
pCur->db = ((completion_vtab*)p)->db;
*ppCursor = &pCur->base;
return SQLITE_OK;
}
/*
** Reset the completion_cursor.
*/
static void completionCursorReset(completion_cursor *pCur){
sqlite3_free(pCur->zPrefix); pCur->zPrefix = 0; pCur->nPrefix = 0;
sqlite3_free(pCur->zLine); pCur->zLine = 0; pCur->nLine = 0;
sqlite3_finalize(pCur->pStmt); pCur->pStmt = 0;
pCur->j = 0;
}
/*
** Destructor for a completion_cursor.
*/
static int completionClose(sqlite3_vtab_cursor *cur){
completionCursorReset((completion_cursor*)cur);
sqlite3_free(cur);
return SQLITE_OK;
}
/*
** All SQL keywords understood by SQLite
*/
static const char *completionKwrds[] = {
"ABORT", "ACTION", "ADD", "AFTER", "ALL", "ALTER", "ANALYZE", "AND", "AS",
"ASC", "ATTACH", "AUTOINCREMENT", "BEFORE", "BEGIN", "BETWEEN", "BY",
"CASCADE", "CASE", "CAST", "CHECK", "COLLATE", "COLUMN", "COMMIT",
"CONFLICT", "CONSTRAINT", "CREATE", "CROSS", "CURRENT_DATE",
"CURRENT_TIME", "CURRENT_TIMESTAMP", "DATABASE", "DEFAULT", "DEFERRABLE",
"DEFERRED", "DELETE", "DESC", "DETACH", "DISTINCT", "DROP", "EACH",
"ELSE", "END", "ESCAPE", "EXCEPT", "EXCLUSIVE", "EXISTS", "EXPLAIN",
"FAIL", "FOR", "FOREIGN", "FROM", "FULL", "GLOB", "GROUP", "HAVING", "IF",
"IGNORE", "IMMEDIATE", "IN", "INDEX", "INDEXED", "INITIALLY", "INNER",
"INSERT", "INSTEAD", "INTERSECT", "INTO", "IS", "ISNULL", "JOIN", "KEY",
"LEFT", "LIKE", "LIMIT", "MATCH", "NATURAL", "NO", "NOT", "NOTNULL",
"NULL", "OF", "OFFSET", "ON", "OR", "ORDER", "OUTER", "PLAN", "PRAGMA",
"PRIMARY", "QUERY", "RAISE", "RECURSIVE", "REFERENCES", "REGEXP",
"REINDEX", "RELEASE", "RENAME", "REPLACE", "RESTRICT", "RIGHT",
"ROLLBACK", "ROW", "SAVEPOINT", "SELECT", "SET", "TABLE", "TEMP",
"TEMPORARY", "THEN", "TO", "TRANSACTION", "TRIGGER", "UNION", "UNIQUE",
"UPDATE", "USING", "VACUUM", "VALUES", "VIEW", "VIRTUAL", "WHEN", "WHERE",
"WITH", "WITHOUT",
};
#define completionKwCount \
(int)(sizeof(completionKwrds)/sizeof(completionKwrds[0]))
/*
** Advance a completion_cursor to its next row of output.
**
** The ->ePhase, ->j, and ->pStmt fields of the completion_cursor object
** record the current state of the scan. This routine sets ->zCurrentRow
** to the current row of output and then returns. If no more rows remain,
** then ->ePhase is set to COMPLETION_EOF which will signal the virtual
** table that has reached the end of its scan.
**
** The current implementation just lists potential identifiers and
** keywords and filters them by zPrefix. Future enhancements should
** take zLine into account to try to restrict the set of identifiers and
** keywords based on what would be legal at the current point of input.
*/
static int completionNext(sqlite3_vtab_cursor *cur){
completion_cursor *pCur = (completion_cursor*)cur;
int eNextPhase = 0; /* Next phase to try if current phase reaches end */
int iCol = -1; /* If >=0, step pCur->pStmt and use the i-th column */
pCur->iRowid++;
while( pCur->ePhase!=COMPLETION_EOF ){
switch( pCur->ePhase ){
case COMPLETION_KEYWORDS: {
if( pCur->j >= completionKwCount ){
pCur->zCurrentRow = 0;
pCur->ePhase = COMPLETION_DATABASES;
}else{
pCur->zCurrentRow = completionKwrds[pCur->j++];
}
iCol = -1;
break;
}
case COMPLETION_DATABASES: {
if( pCur->pStmt==0 ){
sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1,
&pCur->pStmt, 0);
}
iCol = 1;
eNextPhase = COMPLETION_TABLES;
break;
}
case COMPLETION_TABLES: {
if( pCur->pStmt==0 ){
sqlite3_stmt *pS2;
char *zSql = 0;
const char *zSep = "";
sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
while( sqlite3_step(pS2)==SQLITE_ROW ){
const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
zSql = sqlite3_mprintf(
"%z%s"
"SELECT name FROM \"%w\".sqlite_master"
" WHERE type='table'",
zSql, zSep, zDb
);
if( zSql==0 ) return SQLITE_NOMEM;
zSep = " UNION ";
}
sqlite3_finalize(pS2);
sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
sqlite3_free(zSql);
}
iCol = 0;
eNextPhase = COMPLETION_COLUMNS;
break;
}
case COMPLETION_COLUMNS: {
if( pCur->pStmt==0 ){
sqlite3_stmt *pS2;
char *zSql = 0;
const char *zSep = "";
sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
while( sqlite3_step(pS2)==SQLITE_ROW ){
const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
zSql = sqlite3_mprintf(
"%z%s"
"SELECT pti.name FROM \"%w\".sqlite_master AS sm"
" JOIN pragma_table_info(sm.name,%Q) AS pti"
" WHERE sm.type='table'",
zSql, zSep, zDb, zDb
);
if( zSql==0 ) return SQLITE_NOMEM;
zSep = " UNION ";
}
sqlite3_finalize(pS2);
sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
sqlite3_free(zSql);
}
iCol = 0;
eNextPhase = COMPLETION_EOF;
break;
}
}
if( iCol<0 ){
/* This case is when the phase presets zCurrentRow */
if( pCur->zCurrentRow==0 ) continue;
}else{
if( sqlite3_step(pCur->pStmt)==SQLITE_ROW ){
/* Extract the next row of content */
pCur->zCurrentRow = (const char*)sqlite3_column_text(pCur->pStmt, iCol);
}else{
/* When all rows are finished, advance to the next phase */
sqlite3_finalize(pCur->pStmt);
pCur->pStmt = 0;
pCur->ePhase = eNextPhase;
continue;
}
}
if( pCur->nPrefix==0 ) break;
if( sqlite3_strnicmp(pCur->zPrefix, pCur->zCurrentRow, pCur->nPrefix)==0 ){
break;
}
}
return SQLITE_OK;
}
/*
** Return values of columns for the row at which the completion_cursor
** is currently pointing.
*/
static int completionColumn(
sqlite3_vtab_cursor *cur, /* The cursor */
sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
int i /* Which column to return */
){
completion_cursor *pCur = (completion_cursor*)cur;
switch( i ){
case COMPLETION_COLUMN_CANDIDATE: {
sqlite3_result_text(ctx, pCur->zCurrentRow, -1, SQLITE_TRANSIENT);
break;
}
case COMPLETION_COLUMN_PREFIX: {
sqlite3_result_text(ctx, pCur->zPrefix, -1, SQLITE_TRANSIENT);
break;
}
case COMPLETION_COLUMN_WHOLELINE: {
sqlite3_result_text(ctx, pCur->zLine, -1, SQLITE_TRANSIENT);
break;
}
case COMPLETION_COLUMN_PHASE: {
sqlite3_result_int(ctx, pCur->ePhase);
break;
}
}
return SQLITE_OK;
}
/*
** Return the rowid for the current row. In this implementation, the
** rowid is the same as the output value.
*/
static int completionRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
completion_cursor *pCur = (completion_cursor*)cur;
*pRowid = pCur->iRowid;
return SQLITE_OK;
}
/*
** Return TRUE if the cursor has been moved off of the last
** row of output.
*/
static int completionEof(sqlite3_vtab_cursor *cur){
completion_cursor *pCur = (completion_cursor*)cur;
return pCur->ePhase >= COMPLETION_EOF;
}
/*
** This method is called to "rewind" the completion_cursor object back
** to the first row of output. This method is always called at least
** once prior to any call to completionColumn() or completionRowid() or
** completionEof().
*/
static int completionFilter(
sqlite3_vtab_cursor *pVtabCursor,
int idxNum, const char *idxStr,
int argc, sqlite3_value **argv
){
completion_cursor *pCur = (completion_cursor *)pVtabCursor;
int iArg = 0;
(void)(idxStr); /* Unused parameter */
(void)(argc); /* Unused parameter */
completionCursorReset(pCur);
if( idxNum & 1 ){
pCur->nPrefix = sqlite3_value_bytes(argv[iArg]);
if( pCur->nPrefix>0 ){
pCur->zPrefix = sqlite3_mprintf("%s", sqlite3_value_text(argv[iArg]));
if( pCur->zPrefix==0 ) return SQLITE_NOMEM;
}
iArg++;
}
if( idxNum & 2 ){
pCur->nLine = sqlite3_value_bytes(argv[iArg]);
if( pCur->nLine>0 ){
pCur->zLine = sqlite3_mprintf("%s", sqlite3_value_text(argv[iArg]));
if( pCur->zLine==0 ) return SQLITE_NOMEM;
}
iArg++;
}
if( pCur->zLine!=0 && pCur->zPrefix==0 ){
int i = pCur->nLine;
while( i>0 && (isalnum(pCur->zLine[i-1]) || pCur->zLine[i-1]=='_') ){
i--;
}
pCur->nPrefix = pCur->nLine - i;
if( pCur->nPrefix>0 ){
pCur->zPrefix = sqlite3_mprintf("%.*s", pCur->nPrefix, pCur->zLine + i);
if( pCur->zPrefix==0 ) return SQLITE_NOMEM;
}
}
pCur->iRowid = 0;
pCur->ePhase = COMPLETION_FIRST_PHASE;
return completionNext(pVtabCursor);
}
/*
** SQLite will invoke this method one or more times while planning a query
** that uses the completion virtual table. This routine needs to create
** a query plan for each invocation and compute an estimated cost for that
** plan.
**
** There are two hidden parameters that act as arguments to the table-valued
** function: "prefix" and "wholeline". Bit 0 of idxNum is set if "prefix"
** is available and bit 1 is set if "wholeline" is available.
*/
static int completionBestIndex(
sqlite3_vtab *tab,
sqlite3_index_info *pIdxInfo
){
int i; /* Loop over constraints */
int idxNum = 0; /* The query plan bitmask */
int prefixIdx = -1; /* Index of the start= constraint, or -1 if none */
int wholelineIdx = -1; /* Index of the stop= constraint, or -1 if none */
int nArg = 0; /* Number of arguments that completeFilter() expects */
const struct sqlite3_index_constraint *pConstraint;
(void)(tab); /* Unused parameter */
pConstraint = pIdxInfo->aConstraint;
for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
if( pConstraint->usable==0 ) continue;
if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
switch( pConstraint->iColumn ){
case COMPLETION_COLUMN_PREFIX:
prefixIdx = i;
idxNum |= 1;
break;
case COMPLETION_COLUMN_WHOLELINE:
wholelineIdx = i;
idxNum |= 2;
break;
}
}
if( prefixIdx>=0 ){
pIdxInfo->aConstraintUsage[prefixIdx].argvIndex = ++nArg;
pIdxInfo->aConstraintUsage[prefixIdx].omit = 1;
}
if( wholelineIdx>=0 ){
pIdxInfo->aConstraintUsage[wholelineIdx].argvIndex = ++nArg;
pIdxInfo->aConstraintUsage[wholelineIdx].omit = 1;
}
pIdxInfo->idxNum = idxNum;
pIdxInfo->estimatedCost = (double)5000 - 1000*nArg;
pIdxInfo->estimatedRows = 500 - 100*nArg;
return SQLITE_OK;
}
/*
** This following structure defines all the methods for the
** completion virtual table.
*/
static sqlite3_module completionModule = {
0, /* iVersion */
0, /* xCreate */
completionConnect, /* xConnect */
completionBestIndex, /* xBestIndex */
completionDisconnect, /* xDisconnect */
0, /* xDestroy */
completionOpen, /* xOpen - open a cursor */
completionClose, /* xClose - close a cursor */
completionFilter, /* xFilter - configure scan constraints */
completionNext, /* xNext - advance a cursor */
completionEof, /* xEof - check for end of scan */
completionColumn, /* xColumn - read data */
completionRowid, /* xRowid - read data */
0, /* xUpdate */
0, /* xBegin */
0, /* xSync */
0, /* xCommit */
0, /* xRollback */
0, /* xFindMethod */
0, /* xRename */
0, /* xSavepoint */
0, /* xRelease */
0 /* xRollbackTo */
};
#endif /* SQLITE_OMIT_VIRTUALTABLE */
int sqlite3CompletionVtabInit(sqlite3 *db){
int rc = SQLITE_OK;
#ifndef SQLITE_OMIT_VIRTUALTABLE
rc = sqlite3_create_module(db, "completion", &completionModule, 0);
#endif
return rc;
}
#ifdef _WIN32
#endif
int sqlite3_completion_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
){
int rc = SQLITE_OK;
SQLITE_EXTENSION_INIT2(pApi);
(void)(pzErrMsg); /* Unused parameter */
#ifndef SQLITE_OMIT_VIRTUALTABLE
rc = sqlite3CompletionVtabInit(db);
#endif
return rc;
}
/************************* End ../ext/misc/completion.c ********************/
#if defined(SQLITE_ENABLE_SESSION)
/*
** State information for a single open session
*/
typedef struct OpenSession OpenSession;
struct OpenSession {
|
| ︙ | ︙ | |||
1399 1400 1401 1402 1403 1404 1405 | OpenSession aSession[4]; /* Array of sessions. [0] is in focus. */ #endif }; /* ** These are the allowed shellFlgs values */ | < | | | | > | 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 | OpenSession aSession[4]; /* Array of sessions. [0] is in focus. */ #endif }; /* ** These are the allowed shellFlgs values */ #define SHFLG_Pagecache 0x00000001 /* The --pagecache option is used */ #define SHFLG_Lookaside 0x00000002 /* Lookaside memory is used */ #define SHFLG_Backslash 0x00000004 /* The --backslash option is used */ #define SHFLG_PreserveRowid 0x00000008 /* .dump preserves rowid values */ #define SHFLG_Newlines 0x00000010 /* .dump --newline flag */ #define SHFLG_CountChanges 0x00000020 /* .changes setting */ #define SHFLG_Echo 0x00000040 /* .echo or --echo setting */ /* ** Macros for testing and setting shellFlgs */ #define ShellHasFlag(P,X) (((P)->shellFlgs & (X))!=0) |
| ︙ | ︙ | |||
1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 |
static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
int i;
char *zBlob = (char *)pBlob;
raw_printf(out,"X'");
for(i=0; i<nBlob; i++){ raw_printf(out,"%02x",zBlob[i]&0xff); }
raw_printf(out,"'");
}
/*
** Output the given string as a quoted string using SQL quoting conventions.
*/
static void output_quoted_string(FILE *out, const char *z){
int i;
| > > > > > > > > > > > > > > > > > > > > > > > < > | > > > > > > | > > > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > | | < < < | | < > > | > > > > > > > | | > > > > > > > > | 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 |
static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
int i;
char *zBlob = (char *)pBlob;
raw_printf(out,"X'");
for(i=0; i<nBlob; i++){ raw_printf(out,"%02x",zBlob[i]&0xff); }
raw_printf(out,"'");
}
/*
** Find a string that is not found anywhere in z[]. Return a pointer
** to that string.
**
** Try to use zA and zB first. If both of those are already found in z[]
** then make up some string and store it in the buffer zBuf.
*/
static const char *unused_string(
const char *z, /* Result must not appear anywhere in z */
const char *zA, const char *zB, /* Try these first */
char *zBuf /* Space to store a generated string */
){
unsigned i = 0;
if( strstr(z, zA)==0 ) return zA;
if( strstr(z, zB)==0 ) return zB;
do{
sqlite3_snprintf(20,zBuf,"(%s%u)", zA, i++);
}while( strstr(z,zBuf)!=0 );
return zBuf;
}
/*
** Output the given string as a quoted string using SQL quoting conventions.
**
** See also: output_quoted_escaped_string()
*/
static void output_quoted_string(FILE *out, const char *z){
int i;
char c;
setBinaryMode(out, 1);
for(i=0; (c = z[i])!=0 && c!='\''; i++){}
if( c==0 ){
utf8_printf(out,"'%s'",z);
}else{
raw_printf(out, "'");
while( *z ){
for(i=0; (c = z[i])!=0 && c!='\''; i++){}
if( c=='\'' ) i++;
if( i ){
utf8_printf(out, "%.*s", i, z);
z += i;
}
if( c=='\'' ){
raw_printf(out, "'");
continue;
}
if( c==0 ){
break;
}
z++;
}
raw_printf(out, "'");
}
setTextMode(out, 1);
}
/*
** Output the given string as a quoted string using SQL quoting conventions.
** Additionallly , escape the "\n" and "\r" characters so that they do not
** get corrupted by end-of-line translation facilities in some operating
** systems.
**
** This is like output_quoted_string() but with the addition of the \r\n
** escape mechanism.
*/
static void output_quoted_escaped_string(FILE *out, const char *z){
int i;
char c;
setBinaryMode(out, 1);
for(i=0; (c = z[i])!=0 && c!='\'' && c!='\n' && c!='\r'; i++){}
if( c==0 ){
utf8_printf(out,"'%s'",z);
}else{
const char *zNL = 0;
const char *zCR = 0;
int nNL = 0;
int nCR = 0;
char zBuf1[20], zBuf2[20];
for(i=0; z[i]; i++){
if( z[i]=='\n' ) nNL++;
if( z[i]=='\r' ) nCR++;
}
if( nNL ){
raw_printf(out, "replace(");
zNL = unused_string(z, "\\n", "\\012", zBuf1);
}
if( nCR ){
raw_printf(out, "replace(");
zCR = unused_string(z, "\\r", "\\015", zBuf2);
}
raw_printf(out, "'");
while( *z ){
for(i=0; (c = z[i])!=0 && c!='\n' && c!='\r' && c!='\''; i++){}
if( c=='\'' ) i++;
if( i ){
utf8_printf(out, "%.*s", i, z);
z += i;
}
if( c=='\'' ){
raw_printf(out, "'");
continue;
}
if( c==0 ){
break;
}
z++;
if( c=='\n' ){
raw_printf(out, "%s", zNL);
continue;
}
raw_printf(out, "%s", zCR);
}
raw_printf(out, "'");
if( nCR ){
raw_printf(out, ",'%s',char(13))", zCR);
}
if( nNL ){
raw_printf(out, ",'%s',char(10))", zNL);
}
}
setTextMode(out, 1);
}
/*
** Output the given string as a quoted according to C or TCL quoting rules.
*/
|
| ︙ | ︙ | |||
1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 |
char **azArg, /* Text of each result column */
char **azCol, /* Column names */
int *aiType /* Column types */
){
int i;
ShellState *p = (ShellState*)pArg;
switch( p->cMode ){
case MODE_Line: {
int w = 5;
if( azArg==0 ) break;
for(i=0; i<nArg; i++){
int len = strlen30(azCol[i] ? azCol[i] : "");
if( len>w ) w = len;
| > | 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 |
char **azArg, /* Text of each result column */
char **azCol, /* Column names */
int *aiType /* Column types */
){
int i;
ShellState *p = (ShellState*)pArg;
if( azArg==0 ) return 0;
switch( p->cMode ){
case MODE_Line: {
int w = 5;
if( azArg==0 ) break;
for(i=0; i<nArg; i++){
int len = strlen30(azCol[i] ? azCol[i] : "");
if( len>w ) w = len;
|
| ︙ | ︙ | |||
1774 1775 1776 1777 1778 1779 1780 |
int w, n;
if( i<ArraySize(p->colWidth) ){
w = colWidth[i];
}else{
w = 0;
}
if( w==0 ){
| | | < | | < < < < | 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 |
int w, n;
if( i<ArraySize(p->colWidth) ){
w = colWidth[i];
}else{
w = 0;
}
if( w==0 ){
w = strlenChar(azCol[i] ? azCol[i] : "");
if( w<10 ) w = 10;
n = strlenChar(azArg && azArg[i] ? azArg[i] : p->nullValue);
if( w<n ) w = n;
}
if( i<ArraySize(p->actualWidth) ){
p->actualWidth[i] = w;
}
if( showHdr ){
utf8_width_print(p->out, w, azCol[i]);
utf8_printf(p->out, "%s", i==nArg-1 ? rowSep : " ");
}
}
if( showHdr ){
for(i=0; i<nArg; i++){
int w;
if( i<ArraySize(p->actualWidth) ){
w = p->actualWidth[i];
|
| ︙ | ︙ | |||
1816 1817 1818 1819 1820 1821 1822 |
for(i=0; i<nArg; i++){
int w;
if( i<ArraySize(p->actualWidth) ){
w = p->actualWidth[i];
}else{
w = 10;
}
| | | < < | | < < < < < | 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 |
for(i=0; i<nArg; i++){
int w;
if( i<ArraySize(p->actualWidth) ){
w = p->actualWidth[i];
}else{
w = 10;
}
if( p->cMode==MODE_Explain && azArg[i] && strlenChar(azArg[i])>w ){
w = strlenChar(azArg[i]);
}
if( i==1 && p->aiIndent && p->pStmt ){
if( p->iIndent<p->nIndent ){
utf8_printf(p->out, "%*.s", p->aiIndent[p->iIndent], "");
}
p->iIndent++;
}
utf8_width_print(p->out, w, azArg[i] ? azArg[i] : p->nullValue);
utf8_printf(p->out, "%s", i==nArg-1 ? rowSep : " ");
}
break;
}
case MODE_Semi: { /* .schema and .fullschema output */
printSchemaLine(p->out, azArg[0], ";\n");
break;
}
|
| ︙ | ︙ | |||
1974 1975 1976 1977 1978 1979 1980 |
output_csv(p, azArg[i], i<nArg-1);
}
utf8_printf(p->out, "%s", p->rowSeparator);
}
setTextMode(p->out, 1);
break;
}
| < < | | | | > > | | > > > > | | > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > | | | < | > | > > > | < | < | | 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 |
output_csv(p, azArg[i], i<nArg-1);
}
utf8_printf(p->out, "%s", p->rowSeparator);
}
setTextMode(p->out, 1);
break;
}
case MODE_Insert: {
if( azArg==0 ) break;
utf8_printf(p->out,"INSERT INTO %s",p->zDestTable);
if( p->showHeader ){
raw_printf(p->out,"(");
for(i=0; i<nArg; i++){
if( i>0 ) raw_printf(p->out, ",");
if( quoteChar(azCol[i]) ){
char *z = sqlite3_mprintf("\"%w\"", azCol[i]);
utf8_printf(p->out, "%s", z);
sqlite3_free(z);
}else{
raw_printf(p->out, "%s", azCol[i]);
}
}
raw_printf(p->out,")");
}
p->cnt++;
for(i=0; i<nArg; i++){
raw_printf(p->out, i>0 ? "," : " VALUES(");
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
utf8_printf(p->out,"NULL");
}else if( aiType && aiType[i]==SQLITE_TEXT ){
if( ShellHasFlag(p, SHFLG_Newlines) ){
output_quoted_string(p->out, azArg[i]);
}else{
output_quoted_escaped_string(p->out, azArg[i]);
}
}else if( aiType && aiType[i]==SQLITE_INTEGER ){
utf8_printf(p->out,"%s", azArg[i]);
}else if( aiType && aiType[i]==SQLITE_FLOAT ){
char z[50];
double r = sqlite3_column_double(p->pStmt, i);
sqlite3_snprintf(50,z,"%!.20g", r);
raw_printf(p->out, "%s", z);
}else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
const void *pBlob = sqlite3_column_blob(p->pStmt, i);
int nBlob = sqlite3_column_bytes(p->pStmt, i);
output_hex_blob(p->out, pBlob, nBlob);
}else if( isNumber(azArg[i], 0) ){
utf8_printf(p->out,"%s", azArg[i]);
}else if( ShellHasFlag(p, SHFLG_Newlines) ){
output_quoted_string(p->out, azArg[i]);
}else{
output_quoted_escaped_string(p->out, azArg[i]);
}
}
raw_printf(p->out,");\n");
break;
}
case MODE_Quote: {
if( azArg==0 ) break;
if( p->cnt==0 && p->showHeader ){
for(i=0; i<nArg; i++){
if( i>0 ) raw_printf(p->out, ",");
output_quoted_string(p->out, azCol[i]);
}
raw_printf(p->out,"\n");
}
p->cnt++;
for(i=0; i<nArg; i++){
if( i>0 ) raw_printf(p->out, ",");
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
utf8_printf(p->out,"NULL");
}else if( aiType && aiType[i]==SQLITE_TEXT ){
output_quoted_string(p->out, azArg[i]);
}else if( aiType && aiType[i]==SQLITE_INTEGER ){
utf8_printf(p->out,"%s", azArg[i]);
}else if( aiType && aiType[i]==SQLITE_FLOAT ){
char z[50];
double r = sqlite3_column_double(p->pStmt, i);
sqlite3_snprintf(50,z,"%!.20g", r);
raw_printf(p->out, "%s", z);
}else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
const void *pBlob = sqlite3_column_blob(p->pStmt, i);
int nBlob = sqlite3_column_bytes(p->pStmt, i);
output_hex_blob(p->out, pBlob, nBlob);
}else if( isNumber(azArg[i], 0) ){
utf8_printf(p->out,"%s", azArg[i]);
}else{
output_quoted_string(p->out, azArg[i]);
}
}
raw_printf(p->out,"\n");
break;
}
case MODE_Ascii: {
if( p->cnt++==0 && p->showHeader ){
for(i=0; i<nArg; i++){
if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator);
utf8_printf(p->out,"%s",azCol[i] ? azCol[i] : "");
|
| ︙ | ︙ | |||
2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 |
/*
** This is the callback routine from sqlite3_exec() that appends all
** output onto the end of a ShellText object.
*/
static int captureOutputCallback(void *pArg, int nArg, char **azArg, char **az){
ShellText *p = (ShellText*)pArg;
int i;
if( p->n ) appendText(p, "|", 0);
for(i=0; i<nArg; i++){
if( i ) appendText(p, ",", 0);
if( azArg[i] ) appendText(p, azArg[i], 0);
}
return 0;
}
| > > | 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 |
/*
** This is the callback routine from sqlite3_exec() that appends all
** output onto the end of a ShellText object.
*/
static int captureOutputCallback(void *pArg, int nArg, char **azArg, char **az){
ShellText *p = (ShellText*)pArg;
int i;
UNUSED_PARAMETER(az);
if( azArg==0 ) return 0;
if( p->n ) appendText(p, "|", 0);
for(i=0; i<nArg; i++){
if( i ) appendText(p, ",", 0);
if( azArg[i] ) appendText(p, azArg[i], 0);
}
return 0;
}
|
| ︙ | ︙ | |||
2121 2122 2123 2124 2125 2126 2127 |
/*
** Set the destination table field of the ShellState structure to
** the name of the table given. Escape any quote characters in the
** table name.
*/
static void set_table_name(ShellState *p, const char *zName){
int i, n;
| | | | 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 |
/*
** Set the destination table field of the ShellState structure to
** the name of the table given. Escape any quote characters in the
** table name.
*/
static void set_table_name(ShellState *p, const char *zName){
int i, n;
char cQuote;
char *z;
if( p->zDestTable ){
free(p->zDestTable);
p->zDestTable = 0;
}
if( zName==0 ) return;
cQuote = quoteChar(zName);
n = strlen30(zName);
if( cQuote ) n += n+2;
z = p->zDestTable = malloc( n+1 );
if( z==0 ){
raw_printf(stderr,"Error: out of memory\n");
exit(1);
}
n = 0;
if( cQuote ) z[n++] = cQuote;
|
| ︙ | ︙ | |||
2303 2304 2305 2306 2307 2308 2309 |
"%lld (max %lld)", SQLITE_STATUS_MALLOC_COUNT, bReset);
if( pArg->shellFlgs & SHFLG_Pagecache ){
displayStatLine(pArg, "Number of Pcache Pages Used:",
"%lld (max %lld) pages", SQLITE_STATUS_PAGECACHE_USED, bReset);
}
displayStatLine(pArg, "Number of Pcache Overflow Bytes:",
"%lld (max %lld) bytes", SQLITE_STATUS_PAGECACHE_OVERFLOW, bReset);
| < < < < < < < < | 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 |
"%lld (max %lld)", SQLITE_STATUS_MALLOC_COUNT, bReset);
if( pArg->shellFlgs & SHFLG_Pagecache ){
displayStatLine(pArg, "Number of Pcache Pages Used:",
"%lld (max %lld) pages", SQLITE_STATUS_PAGECACHE_USED, bReset);
}
displayStatLine(pArg, "Number of Pcache Overflow Bytes:",
"%lld (max %lld) bytes", SQLITE_STATUS_PAGECACHE_OVERFLOW, bReset);
displayStatLine(pArg, "Largest Allocation:",
"%lld bytes", SQLITE_STATUS_MALLOC_SIZE, bReset);
displayStatLine(pArg, "Largest Pcache Allocation:",
"%lld bytes", SQLITE_STATUS_PAGECACHE_SIZE, bReset);
#ifdef YYTRACKMAXSTACKDEPTH
displayStatLine(pArg, "Deepest Parser Stack:",
"%lld (max %lld)", SQLITE_STATUS_PARSER_STACK, bReset);
#endif
}
if( pArg && pArg->out && db ){
|
| ︙ | ︙ | |||
2846 2847 2848 2849 2850 2851 2852 |
}
}
azCol[++nCol] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 1));
if( sqlite3_column_int(pStmt, 5) ){
nPK++;
if( nPK==1
&& sqlite3_stricmp((const char*)sqlite3_column_text(pStmt,2),
| | | 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 |
}
}
azCol[++nCol] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 1));
if( sqlite3_column_int(pStmt, 5) ){
nPK++;
if( nPK==1
&& sqlite3_stricmp((const char*)sqlite3_column_text(pStmt,2),
"INTEGER")==0
){
isIPK = 1;
}else{
isIPK = 0;
}
}
}
|
| ︙ | ︙ | |||
2898 2899 2900 2901 2902 2903 2904 |
if( sqlite3_stricmp(azRowid[j],azCol[i])==0 ) break;
}
if( i>nCol ){
/* At this point, we know that azRowid[j] is not the name of any
** ordinary column in the table. Verify that azRowid[j] is a valid
** name for the rowid before adding it to azCol[0]. WITHOUT ROWID
** tables will fail this last check */
| < | 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 |
if( sqlite3_stricmp(azRowid[j],azCol[i])==0 ) break;
}
if( i>nCol ){
/* At this point, we know that azRowid[j] is not the name of any
** ordinary column in the table. Verify that azRowid[j] is a valid
** name for the rowid before adding it to azCol[0]. WITHOUT ROWID
** tables will fail this last check */
rc = sqlite3_table_column_metadata(p->db,0,zTab,azRowid[j],0,0,0,0,0);
if( rc==SQLITE_OK ) azCol[0] = azRowid[j];
break;
}
}
}
return azCol;
|
| ︙ | ︙ | |||
2931 2932 2933 2934 2935 2936 2937 |
/*
** This is a different callback routine used for dumping the database.
** Each row received by this callback consists of a table name,
** the table type ("index" or "table") and SQL to create the table.
** This routine should print text sufficient to recreate the table.
*/
| | | | | 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 |
/*
** This is a different callback routine used for dumping the database.
** Each row received by this callback consists of a table name,
** the table type ("index" or "table") and SQL to create the table.
** This routine should print text sufficient to recreate the table.
*/
static int dump_callback(void *pArg, int nArg, char **azArg, char **azNotUsed){
int rc;
const char *zTable;
const char *zType;
const char *zSql;
ShellState *p = (ShellState *)pArg;
UNUSED_PARAMETER(azNotUsed);
if( nArg!=3 || azArg==0 ) return 0;
zTable = azArg[0];
zType = azArg[1];
zSql = azArg[2];
if( strcmp(zTable, "sqlite_sequence")==0 ){
raw_printf(p->out, "DELETE FROM sqlite_sequence;\n");
}else if( sqlite3_strglob("sqlite_stat?", zTable)==0 ){
|
| ︙ | ︙ | |||
3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 | static char zHelp[] = #ifndef SQLITE_OMIT_AUTHORIZATION ".auth ON|OFF Show authorizer callbacks\n" #endif ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" ".bail on|off Stop after hitting an error. Default OFF\n" ".binary on|off Turn binary output on or off. Default OFF\n" ".changes on|off Show number of rows changed by SQL\n" ".check GLOB Fail if output since .testcase does not match\n" ".clone NEWDB Clone data into NEWDB from the existing database\n" ".databases List names and files of attached databases\n" ".dbinfo ?DB? Show status information about the database\n" ".dump ?TABLE? ... Dump the database in an SQL text format\n" " If TABLE specified, only dump tables matching\n" " LIKE pattern TABLE.\n" ".echo on|off Turn command echo on or off\n" ".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN\n" ".exit Exit this program\n" | > > > | | 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 | static char zHelp[] = #ifndef SQLITE_OMIT_AUTHORIZATION ".auth ON|OFF Show authorizer callbacks\n" #endif ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" ".bail on|off Stop after hitting an error. Default OFF\n" ".binary on|off Turn binary output on or off. Default OFF\n" ".cd DIRECTORY Change the working directory to DIRECTORY\n" ".changes on|off Show number of rows changed by SQL\n" ".check GLOB Fail if output since .testcase does not match\n" ".clone NEWDB Clone data into NEWDB from the existing database\n" ".databases List names and files of attached databases\n" ".dbinfo ?DB? Show status information about the database\n" ".dump ?TABLE? ... Dump the database in an SQL text format\n" " If TABLE specified, only dump tables matching\n" " LIKE pattern TABLE.\n" ".echo on|off Turn command echo on or off\n" ".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN\n" ".exit Exit this program\n" /* Because explain mode comes on automatically now, the ".explain" mode ** is removed from the help screen. It is still supported for legacy, however */ /*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\n"*/ ".fullschema ?--indent? Show schema and the content of sqlite_stat tables\n" ".headers on|off Turn display of headers on or off\n" ".help Show this message\n" ".import FILE TABLE Import data from FILE into TABLE\n" #ifndef SQLITE_OMIT_TEST_CONTROL ".imposter INDEX TABLE Create imposter table TABLE on index INDEX\n" #endif |
| ︙ | ︙ | |||
3129 3130 3131 3132 3133 3134 3135 | " line One value per line\n" " list Values delimited by \"|\"\n" " quote Escape answers as for SQL\n" " tabs Tab-separated values\n" " tcl TCL list elements\n" ".nullvalue STRING Use STRING in place of NULL values\n" ".once FILENAME Output for the next SQL command only to FILENAME\n" | | | > | 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 | " line One value per line\n" " list Values delimited by \"|\"\n" " quote Escape answers as for SQL\n" " tabs Tab-separated values\n" " tcl TCL list elements\n" ".nullvalue STRING Use STRING in place of NULL values\n" ".once FILENAME Output for the next SQL command only to FILENAME\n" ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE\n" " The --new option starts with an empty file\n" ".output ?FILENAME? Send output to FILENAME or stdout\n" ".print STRING... Print literal STRING\n" ".prompt MAIN CONTINUE Replace the standard prompts\n" ".quit Exit this program\n" ".read FILENAME Execute SQL in FILENAME\n" ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n" ".save FILE Write in-memory database into FILE\n" ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off\n" ".schema ?PATTERN? Show the CREATE statements matching PATTERN\n" " Add --indent for pretty-printing\n" ".selftest ?--init? Run tests defined in the SELFTEST table\n" ".separator COL ?ROW? Change the column separator and optionally the row\n" " separator for both the output mode and .import\n" #if defined(SQLITE_ENABLE_SESSION) ".session CMD ... Create or control sessions\n" #endif ".sha3sum ?OPTIONS...? Compute a SHA3 hash of database content\n" ".shell CMD ARGS... Run CMD ARGS... in a system shell\n" |
| ︙ | ︙ | |||
3194 3195 3196 3197 3198 3199 3200 | /* Forward reference */ static int process_input(ShellState *p, FILE *in); /* ** Read the content of file zName into memory obtained from sqlite3_malloc64() | | | | 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 | /* Forward reference */ static int process_input(ShellState *p, FILE *in); /* ** Read the content of file zName into memory obtained from sqlite3_malloc64() ** and return a pointer to the buffer. The caller is responsible for freeing ** the memory. ** ** If parameter pnByte is not NULL, (*pnByte) is set to the number of bytes ** read. ** ** For convenience, a nul-terminator byte is always appended to the data read ** from the file before the buffer is returned. This byte is not included in ** the final value of (*pnByte), if applicable. |
| ︙ | ︙ | |||
3229 3230 3231 3232 3233 3234 3235 |
return 0;
}
pBuf[nIn] = 0;
if( pnByte ) *pnByte = nIn;
return pBuf;
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 |
return 0;
}
pBuf[nIn] = 0;
if( pnByte ) *pnByte = nIn;
return pBuf;
}
#if defined(SQLITE_ENABLE_SESSION)
/*
** Close a single OpenSession object and release all of its associated
** resources.
*/
static void session_close(OpenSession *pSession){
int i;
|
| ︙ | ︙ | |||
3346 3347 3348 3349 3350 3351 3352 |
p->zDbFilename, sqlite3_errmsg(p->db));
if( keepAlive ) return;
exit(1);
}
#ifndef SQLITE_OMIT_LOAD_EXTENSION
sqlite3_enable_load_extension(p->db, 1);
#endif
| | | < | | | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > | > > | > > > > > > > > > > | | > > > > > > | | > > > | 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 |
p->zDbFilename, sqlite3_errmsg(p->db));
if( keepAlive ) return;
exit(1);
}
#ifndef SQLITE_OMIT_LOAD_EXTENSION
sqlite3_enable_load_extension(p->db, 1);
#endif
sqlite3_fileio_init(p->db, 0, 0);
sqlite3_shathree_init(p->db, 0, 0);
sqlite3_completion_init(p->db, 0, 0);
sqlite3_create_function(p->db, "shell_add_schema", 2, SQLITE_UTF8, 0,
shellAddSchemaName, 0, 0);
}
}
#if HAVE_READLINE || HAVE_EDITLINE
/*
** Readline completion callbacks
*/
static char *readline_completion_generator(const char *text, int state){
static sqlite3_stmt *pStmt = 0;
char *zRet;
if( state==0 ){
char *zSql;
sqlite3_finalize(pStmt);
zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
" FROM completion(%Q) ORDER BY 1", text);
sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
}
if( sqlite3_step(pStmt)==SQLITE_ROW ){
zRet = strdup((const char*)sqlite3_column_text(pStmt, 0));
}else{
sqlite3_finalize(pStmt);
pStmt = 0;
zRet = 0;
}
return zRet;
}
static char **readline_completion(const char *zText, int iStart, int iEnd){
rl_attempted_completion_over = 1;
return rl_completion_matches(zText, readline_completion_generator);
}
#elif HAVE_LINENOISE
/*
** Linenoise completion callback
*/
static void linenoise_completion(const char *zLine, linenoiseCompletions *lc){
int nLine = (int)strlen(zLine);
int i, iStart;
sqlite3_stmt *pStmt = 0;
char *zSql;
char zBuf[1000];
if( nLine>sizeof(zBuf)-30 ) return;
if( zLine[0]=='.' ) return;
for(i=nLine-1; i>=0 && (isalnum(zLine[i]) || zLine[i]=='_'); i--){}
if( i==nLine-1 ) return;
iStart = i+1;
memcpy(zBuf, zLine, iStart);
zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
" FROM completion(%Q,%Q) ORDER BY 1",
&zLine[iStart], zLine);
sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
sqlite3_exec(globalDb, "PRAGMA page_count", 0, 0, 0); /* Load the schema */
while( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zCompletion = (const char*)sqlite3_column_text(pStmt, 0);
int nCompletion = sqlite3_column_bytes(pStmt, 0);
if( iStart+nCompletion < sizeof(zBuf)-1 ){
memcpy(zBuf+iStart, zCompletion, nCompletion+1);
linenoiseAddCompletion(lc, zBuf);
}
}
sqlite3_finalize(pStmt);
}
#endif
/*
** Do C-language style dequoting.
**
** \a -> alarm
** \b -> backspace
** \t -> tab
|
| ︙ | ︙ | |||
3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 |
struct ImportCtx {
const char *zFile; /* Name of the input file */
FILE *in; /* Read the CSV text from this input stream */
char *z; /* Accumulated text for a field */
int n; /* Number of bytes in z */
int nAlloc; /* Space allocated for z[] */
int nLine; /* Current line number */
int cTerm; /* Character that terminated the most recent field */
int cColSep; /* The column separator character. (Usually ",") */
int cRowSep; /* The row separator character. (Usually "\n") */
};
/* Append a single byte to z[] */
static void import_append_char(ImportCtx *p, int c){
| > | 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 |
struct ImportCtx {
const char *zFile; /* Name of the input file */
FILE *in; /* Read the CSV text from this input stream */
char *z; /* Accumulated text for a field */
int n; /* Number of bytes in z */
int nAlloc; /* Space allocated for z[] */
int nLine; /* Current line number */
int bNotFirst; /* True if one or more bytes already read */
int cTerm; /* Character that terminated the most recent field */
int cColSep; /* The column separator character. (Usually ",") */
int cRowSep; /* The row separator character. (Usually "\n") */
};
/* Append a single byte to z[] */
static void import_append_char(ImportCtx *p, int c){
|
| ︙ | ︙ | |||
3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 |
break;
}
import_append_char(p, c);
ppc = pc;
pc = c;
}
}else{
while( c!=EOF && c!=cSep && c!=rSep ){
import_append_char(p, c);
c = fgetc(p->in);
}
if( c==rSep ){
p->nLine++;
if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--;
}
p->cTerm = c;
}
if( p->z ) p->z[p->n] = 0;
return p->z;
}
/* Read a single field of ASCII delimited text.
**
** + Input comes from p->in.
** + Store results in p->z of length p->n. Space to hold p->z comes
| > > > > > > > > > > > > > > > > | 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 |
break;
}
import_append_char(p, c);
ppc = pc;
pc = c;
}
}else{
/* If this is the first field being parsed and it begins with the
** UTF-8 BOM (0xEF BB BF) then skip the BOM */
if( (c&0xff)==0xef && p->bNotFirst==0 ){
import_append_char(p, c);
c = fgetc(p->in);
if( (c&0xff)==0xbb ){
import_append_char(p, c);
c = fgetc(p->in);
if( (c&0xff)==0xbf ){
p->bNotFirst = 1;
p->n = 0;
return csv_read_one_field(p);
}
}
}
while( c!=EOF && c!=cSep && c!=rSep ){
import_append_char(p, c);
c = fgetc(p->in);
}
if( c==rSep ){
p->nLine++;
if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--;
}
p->cTerm = c;
}
if( p->z ) p->z[p->n] = 0;
p->bNotFirst = 1;
return p->z;
}
/* Read a single field of ASCII delimited text.
**
** + Input comes from p->in.
** + Store results in p->z of length p->n. Space to hold p->z comes
|
| ︙ | ︙ | |||
4202 4203 4204 4205 4206 4207 4208 |
** by the ".lint fkey-indexes" command. This scalar function is always
** called with four arguments - the parent table name, the parent column name,
** the child table name and the child column name.
**
** fkey_collate_clause('parent-tab', 'parent-col', 'child-tab', 'child-col')
**
** If either of the named tables or columns do not exist, this function
| | | | | | 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 |
** by the ".lint fkey-indexes" command. This scalar function is always
** called with four arguments - the parent table name, the parent column name,
** the child table name and the child column name.
**
** fkey_collate_clause('parent-tab', 'parent-col', 'child-tab', 'child-col')
**
** If either of the named tables or columns do not exist, this function
** returns an empty string. An empty string is also returned if both tables
** and columns exist but have the same default collation sequence. Or,
** if both exist but the default collation sequences are different, this
** function returns the string " COLLATE <parent-collation>", where
** <parent-collation> is the default collation sequence of the parent column.
*/
static void shellFkeyCollateClause(
sqlite3_context *pCtx,
int nVal,
sqlite3_value **apVal
){
sqlite3 *db = sqlite3_context_db_handle(pCtx);
const char *zParent;
const char *zParentCol;
const char *zParentSeq;
const char *zChild;
const char *zChildCol;
const char *zChildSeq = 0; /* Initialize to avoid false-positive warning */
int rc;
assert( nVal==4 );
zParent = (const char*)sqlite3_value_text(apVal[0]);
zParentCol = (const char*)sqlite3_value_text(apVal[1]);
zChild = (const char*)sqlite3_value_text(apVal[2]);
zChildCol = (const char*)sqlite3_value_text(apVal[3]);
sqlite3_result_text(pCtx, "", -1, SQLITE_STATIC);
|
| ︙ | ︙ | |||
4302 4303 4304 4305 4306 4307 4308 |
**
** These six values are used by the C logic below to generate the report.
*/
const char *zSql =
"SELECT "
" 'EXPLAIN QUERY PLAN SELECT rowid FROM ' || quote(s.name) || ' WHERE '"
" || group_concat(quote(s.name) || '.' || quote(f.[from]) || '=?' "
| | > | < < | > < > > | | 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 |
**
** These six values are used by the C logic below to generate the report.
*/
const char *zSql =
"SELECT "
" 'EXPLAIN QUERY PLAN SELECT rowid FROM ' || quote(s.name) || ' WHERE '"
" || group_concat(quote(s.name) || '.' || quote(f.[from]) || '=?' "
" || fkey_collate_clause("
" f.[table], COALESCE(f.[to], p.[name]), s.name, f.[from]),' AND ')"
", "
" 'SEARCH TABLE ' || s.name || ' USING COVERING INDEX*('"
" || group_concat('*=?', ' AND ') || ')'"
", "
" s.name || '(' || group_concat(f.[from], ', ') || ')'"
", "
" f.[table] || '(' || group_concat(COALESCE(f.[to], p.[name])) || ')'"
", "
" 'CREATE INDEX ' || quote(s.name ||'_'|| group_concat(f.[from], '_'))"
" || ' ON ' || quote(s.name) || '('"
" || group_concat(quote(f.[from]) ||"
" fkey_collate_clause("
" f.[table], COALESCE(f.[to], p.[name]), s.name, f.[from]), ', ')"
" || ');'"
", "
" f.[table] "
"FROM sqlite_master AS s, pragma_foreign_key_list(s.name) AS f "
"LEFT JOIN pragma_table_info AS p ON (pk-1=seq AND p.arg=f.[table]) "
"GROUP BY s.name, f.id "
"ORDER BY (CASE WHEN ? THEN f.[table] ELSE s.name END)"
;
const char *zGlobIPK = "SEARCH TABLE * USING INTEGER PRIMARY KEY (rowid=?)";
for(i=2; i<nArg; i++){
int n = (int)strlen(azArg[i]);
if( n>1 && sqlite3_strnicmp("-verbose", azArg[i], n)==0 ){
bVerbose = 1;
}
else if( n>1 && sqlite3_strnicmp("-groupbyparent", azArg[i], n)==0 ){
bGroupByParent = 1;
zIndent = " ";
}
else{
raw_printf(stderr, "Usage: %s %s ?-verbose? ?-groupbyparent?\n",
azArg[0], azArg[1]
);
return SQLITE_ERROR;
}
}
/* Register the fkey_collate_clause() SQL function */
rc = sqlite3_create_function(db, "fkey_collate_clause", 4, SQLITE_UTF8,
0, shellFkeyCollateClause, 0, 0
);
if( rc==SQLITE_OK ){
|
| ︙ | ︙ | |||
4373 4374 4375 4376 4377 4378 4379 |
const char *zCI = (const char*)sqlite3_column_text(pSql, 4);
const char *zParent = (const char*)sqlite3_column_text(pSql, 5);
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc!=SQLITE_OK ) break;
if( SQLITE_ROW==sqlite3_step(pExplain) ){
const char *zPlan = (const char*)sqlite3_column_text(pExplain, 3);
| > | > > | | | | 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 |
const char *zCI = (const char*)sqlite3_column_text(pSql, 4);
const char *zParent = (const char*)sqlite3_column_text(pSql, 5);
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc!=SQLITE_OK ) break;
if( SQLITE_ROW==sqlite3_step(pExplain) ){
const char *zPlan = (const char*)sqlite3_column_text(pExplain, 3);
res = (
0==sqlite3_strglob(zGlob, zPlan)
|| 0==sqlite3_strglob(zGlobIPK, zPlan)
);
}
rc = sqlite3_finalize(pExplain);
if( rc!=SQLITE_OK ) break;
if( res<0 ){
raw_printf(stderr, "Error: internal error");
break;
}else{
if( bGroupByParent
&& (bVerbose || res==0)
&& (zPrev==0 || sqlite3_stricmp(zParent, zPrev))
){
raw_printf(out, "-- Parent table %s\n", zParent);
sqlite3_free(zPrev);
zPrev = sqlite3_mprintf("%s", zParent);
}
if( res==0 ){
raw_printf(out, "%s%s --> %s\n", zIndent, zCI, zTarget);
}else if( bVerbose ){
raw_printf(out, "%s/* no extra indexes required for %s -> %s */\n",
zIndent, zFrom, zTarget
);
}
}
}
sqlite3_free(zPrev);
|
| ︙ | ︙ | |||
4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 |
setTextMode(p->out, 1);
}
}else{
raw_printf(stderr, "Usage: .binary on|off\n");
rc = 1;
}
}else
/* The undocumented ".breakpoint" command causes a call to the no-op
** routine named test_breakpoint().
*/
if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){
test_breakpoint();
}else
| > > > > > > > > > > > > > > > > > > > | 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 |
setTextMode(p->out, 1);
}
}else{
raw_printf(stderr, "Usage: .binary on|off\n");
rc = 1;
}
}else
if( c=='c' && strcmp(azArg[0],"cd")==0 ){
if( nArg==2 ){
#if defined(_WIN32) || defined(WIN32)
wchar_t *z = sqlite3_win32_utf8_to_unicode(azArg[1]);
rc = !SetCurrentDirectoryW(z);
sqlite3_free(z);
#else
rc = chdir(azArg[1]);
#endif
if( rc ){
utf8_printf(stderr, "Cannot change to directory \"%s\"\n", azArg[1]);
rc = 1;
}
}else{
raw_printf(stderr, "Usage: .cd DIRECTORY\n");
rc = 1;
}
}else
/* The undocumented ".breakpoint" command causes a call to the no-op
** routine named test_breakpoint().
*/
if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){
test_breakpoint();
}else
|
| ︙ | ︙ | |||
4651 4652 4653 4654 4655 4656 4657 |
if( c=='d' && strncmp(azArg[0], "dbinfo", n)==0 ){
rc = shell_dbinfo_command(p, nArg, azArg);
}else
if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
const char *zLike = 0;
int i;
| > | > > > > > > > > > > | > > | 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 |
if( c=='d' && strncmp(azArg[0], "dbinfo", n)==0 ){
rc = shell_dbinfo_command(p, nArg, azArg);
}else
if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
const char *zLike = 0;
int i;
int savedShowHeader = p->showHeader;
ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines);
for(i=1; i<nArg; i++){
if( azArg[i][0]=='-' ){
const char *z = azArg[i]+1;
if( z[0]=='-' ) z++;
if( strcmp(z,"preserve-rowids")==0 ){
#ifdef SQLITE_OMIT_VIRTUALTABLE
raw_printf(stderr, "The --preserve-rowids option is not compatible"
" with SQLITE_OMIT_VIRTUALTABLE\n");
rc = 1;
goto meta_command_exit;
#else
ShellSetFlag(p, SHFLG_PreserveRowid);
#endif
}else
if( strcmp(z,"newlines")==0 ){
ShellSetFlag(p, SHFLG_Newlines);
}else
{
raw_printf(stderr, "Unknown option \"%s\" on \".dump\"\n", azArg[i]);
rc = 1;
goto meta_command_exit;
}
}else if( zLike ){
raw_printf(stderr, "Usage: .dump ?--preserve-rowids? "
"?--newlines? ?LIKE-PATTERN?\n");
rc = 1;
goto meta_command_exit;
}else{
zLike = azArg[i];
}
}
open_db(p, 0);
/* When playing back a "dump", the content might appear in an order
** which causes immediate foreign key constraints to be violated.
** So disable foreign-key constraint enforcement to prevent problems. */
raw_printf(p->out, "PRAGMA foreign_keys=OFF;\n");
raw_printf(p->out, "BEGIN TRANSACTION;\n");
p->writableSchema = 0;
p->showHeader = 0;
/* Set writable_schema=ON since doing so forces SQLite to initialize
** as much of the schema as it can even if the sqlite_master table is
** corrupt. */
sqlite3_exec(p->db, "SAVEPOINT dump; PRAGMA writable_schema=ON", 0, 0, 0);
p->nErr = 0;
if( zLike==0 ){
run_schema_dump_query(p,
|
| ︙ | ︙ | |||
4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 |
if( p->writableSchema ){
raw_printf(p->out, "PRAGMA writable_schema=OFF;\n");
p->writableSchema = 0;
}
sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0);
sqlite3_exec(p->db, "RELEASE dump;", 0, 0, 0);
raw_printf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n");
}else
if( c=='e' && strncmp(azArg[0], "echo", n)==0 ){
if( nArg==2 ){
setOrClearFlag(p, SHFLG_Echo, azArg[1]);
}else{
raw_printf(stderr, "Usage: .echo on|off\n");
| > | 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 |
if( p->writableSchema ){
raw_printf(p->out, "PRAGMA writable_schema=OFF;\n");
p->writableSchema = 0;
}
sqlite3_exec(p->db, "PRAGMA writable_schema=OFF;", 0, 0, 0);
sqlite3_exec(p->db, "RELEASE dump;", 0, 0, 0);
raw_printf(p->out, p->nErr ? "ROLLBACK; -- due to errors\n" : "COMMIT;\n");
p->showHeader = savedShowHeader;
}else
if( c=='e' && strncmp(azArg[0], "echo", n)==0 ){
if( nArg==2 ){
setOrClearFlag(p, SHFLG_Echo, azArg[1]);
}else{
raw_printf(stderr, "Usage: .echo on|off\n");
|
| ︙ | ︙ | |||
4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 |
}else
if( c=='e' && strncmp(azArg[0], "exit", n)==0 ){
if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc);
rc = 2;
}else
if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){
int val = 1;
if( nArg>=2 ){
if( strcmp(azArg[1],"auto")==0 ){
val = 99;
}else{
val = booleanValue(azArg[1]);
| > > | 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 |
}else
if( c=='e' && strncmp(azArg[0], "exit", n)==0 ){
if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc);
rc = 2;
}else
/* The ".explain" command is automatic now. It is largely pointless. It
** retained purely for backwards compatibility */
if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){
int val = 1;
if( nArg>=2 ){
if( strcmp(azArg[1],"auto")==0 ){
val = 99;
}else{
val = booleanValue(azArg[1]);
|
| ︙ | ︙ | |||
5265 5266 5267 5268 5269 5270 5271 |
set_table_name(p, nArg>=3 ? azArg[2] : "table");
}else if( c2=='q' && strncmp(azArg[1],"quote",n2)==0 ){
p->mode = MODE_Quote;
}else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
p->mode = MODE_Ascii;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
| > > | | 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 |
set_table_name(p, nArg>=3 ? azArg[2] : "table");
}else if( c2=='q' && strncmp(azArg[1],"quote",n2)==0 ){
p->mode = MODE_Quote;
}else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
p->mode = MODE_Ascii;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
}else if( nArg==1 ){
raw_printf(p->out, "current output mode: %s\n", modeDescr[p->mode]);
}else{
raw_printf(stderr, "Error: mode should be one of: "
"ascii column csv html insert line list quote tabs tcl\n");
rc = 1;
}
p->cMode = p->mode;
}else
|
| ︙ | ︙ | |||
5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 |
}else{
raw_printf(stderr, "Usage: .scanstats on|off\n");
rc = 1;
}
}else
if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){
ShellState data;
char *zErrMsg = 0;
open_db(p, 0);
memcpy(&data, p, sizeof(data));
data.showHeader = 0;
data.cMode = data.mode = MODE_Semi;
if( nArg>=2 && optionMatch(azArg[1], "indent") ){
data.cMode = data.mode = MODE_Pretty;
nArg--;
if( nArg==2 ) azArg[1] = azArg[2];
}
if( nArg==2 && azArg[1][0]!='-' ){
int i;
| > > > > > | 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 |
}else{
raw_printf(stderr, "Usage: .scanstats on|off\n");
rc = 1;
}
}else
if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){
ShellText sSelect;
ShellState data;
char *zErrMsg = 0;
const char *zDiv = 0;
int iSchema = 0;
open_db(p, 0);
memcpy(&data, p, sizeof(data));
data.showHeader = 0;
data.cMode = data.mode = MODE_Semi;
initText(&sSelect);
if( nArg>=2 && optionMatch(azArg[1], "indent") ){
data.cMode = data.mode = MODE_Pretty;
nArg--;
if( nArg==2 ) azArg[1] = azArg[2];
}
if( nArg==2 && azArg[1][0]!='-' ){
int i;
|
| ︙ | ︙ | |||
5521 5522 5523 5524 5525 5526 5527 |
")";
new_argv[1] = 0;
new_colv[0] = "sql";
new_colv[1] = 0;
callback(&data, 1, new_argv, new_colv);
rc = SQLITE_OK;
}else{
| < | < < < < < < < < < | < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 |
")";
new_argv[1] = 0;
new_colv[0] = "sql";
new_colv[1] = 0;
callback(&data, 1, new_argv, new_colv);
rc = SQLITE_OK;
}else{
zDiv = "(";
}
}else if( nArg==1 ){
zDiv = "(";
}else{
raw_printf(stderr, "Usage: .schema ?--indent? ?LIKE-PATTERN?\n");
rc = 1;
goto meta_command_exit;
}
if( zDiv ){
sqlite3_stmt *pStmt = 0;
rc = sqlite3_prepare_v2(p->db, "SELECT name FROM pragma_database_list",
-1, &pStmt, 0);
if( rc ){
utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
sqlite3_finalize(pStmt);
rc = 1;
goto meta_command_exit;
}
appendText(&sSelect, "SELECT sql FROM", 0);
iSchema = 0;
while( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zDb = (const char*)sqlite3_column_text(pStmt, 0);
char zScNum[30];
sqlite3_snprintf(sizeof(zScNum), zScNum, "%d", ++iSchema);
appendText(&sSelect, zDiv, 0);
zDiv = " UNION ALL ";
if( strcmp(zDb, "main")!=0 ){
appendText(&sSelect, "SELECT shell_add_schema(sql,", 0);
appendText(&sSelect, zDb, '"');
appendText(&sSelect, ") AS sql, type, tbl_name, name, rowid,", 0);
appendText(&sSelect, zScNum, 0);
appendText(&sSelect, " AS snum, ", 0);
appendText(&sSelect, zDb, '\'');
appendText(&sSelect, " AS sname FROM ", 0);
appendText(&sSelect, zDb, '"');
appendText(&sSelect, ".sqlite_master", 0);
}else{
appendText(&sSelect, "SELECT sql, type, tbl_name, name, rowid, ", 0);
appendText(&sSelect, zScNum, 0);
appendText(&sSelect, " AS snum, 'main' AS sname FROM sqlite_master",0);
}
}
sqlite3_finalize(pStmt);
appendText(&sSelect, ") WHERE ", 0);
if( nArg>1 ){
char *zQarg = sqlite3_mprintf("%Q", azArg[1]);
if( strchr(azArg[1], '.') ){
appendText(&sSelect, "lower(printf('%s.%s',sname,tbl_name))", 0);
}else{
appendText(&sSelect, "lower(tbl_name)", 0);
}
appendText(&sSelect, strchr(azArg[1], '*') ? " GLOB " : " LIKE ", 0);
appendText(&sSelect, zQarg, 0);
appendText(&sSelect, " AND ", 0);
sqlite3_free(zQarg);
}
appendText(&sSelect, "type!='meta' AND sql IS NOT NULL"
" ORDER BY snum, rowid", 0);
rc = sqlite3_exec(p->db, sSelect.z, callback, &data, &zErrMsg);
freeText(&sSelect);
}
if( zErrMsg ){
utf8_printf(stderr,"Error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
rc = 1;
}else if( rc != SQLITE_OK ){
raw_printf(stderr,"Error: querying schema information\n");
rc = 1;
|
| ︙ | ︙ | |||
5789 5790 5791 5792 5793 5794 5795 |
}else
#endif
if( c=='s' && n>=4 && strncmp(azArg[0],"selftest",n)==0 ){
int bIsInit = 0; /* True to initialize the SELFTEST table */
int bVerbose = 0; /* Verbose output */
int bSelftestExists; /* True if SELFTEST already exists */
| < < < | < < | < < < | 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 |
}else
#endif
if( c=='s' && n>=4 && strncmp(azArg[0],"selftest",n)==0 ){
int bIsInit = 0; /* True to initialize the SELFTEST table */
int bVerbose = 0; /* Verbose output */
int bSelftestExists; /* True if SELFTEST already exists */
int i, k; /* Loop counters */
int nTest = 0; /* Number of tests runs */
int nErr = 0; /* Number of errors seen */
ShellText str; /* Answer for a query */
sqlite3_stmt *pStmt = 0; /* Query against the SELFTEST table */
open_db(p,0);
for(i=1; i<nArg; i++){
const char *z = azArg[i];
if( z[0]=='-' && z[1]=='-' ) z++;
if( strcmp(z,"-init")==0 ){
bIsInit = 1;
|
| ︙ | ︙ | |||
5831 5832 5833 5834 5835 5836 5837 |
}else{
bSelftestExists = 1;
}
if( bIsInit ){
createSelftestTable(p);
bSelftestExists = 1;
}
| > > | > | | | > > > > > > | < < < < < < < < < < | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > < | 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 |
}else{
bSelftestExists = 1;
}
if( bIsInit ){
createSelftestTable(p);
bSelftestExists = 1;
}
initText(&str);
appendText(&str, "x", 0);
for(k=bSelftestExists; k>=0; k--){
if( k==1 ){
rc = sqlite3_prepare_v2(p->db,
"SELECT tno,op,cmd,ans FROM selftest ORDER BY tno",
-1, &pStmt, 0);
}else{
rc = sqlite3_prepare_v2(p->db,
"VALUES(0,'memo','Missing SELFTEST table - default checks only',''),"
" (1,'run','PRAGMA integrity_check','ok')",
-1, &pStmt, 0);
}
if( rc ){
raw_printf(stderr, "Error querying the selftest table\n");
rc = 1;
sqlite3_finalize(pStmt);
goto meta_command_exit;
}
for(i=1; sqlite3_step(pStmt)==SQLITE_ROW; i++){
int tno = sqlite3_column_int(pStmt, 0);
const char *zOp = (const char*)sqlite3_column_text(pStmt, 1);
const char *zSql = (const char*)sqlite3_column_text(pStmt, 2);
const char *zAns = (const char*)sqlite3_column_text(pStmt, 3);
k = 0;
if( bVerbose>0 ){
char *zQuote = sqlite3_mprintf("%q", zSql);
printf("%d: %s %s\n", tno, zOp, zSql);
sqlite3_free(zQuote);
}
if( strcmp(zOp,"memo")==0 ){
utf8_printf(p->out, "%s\n", zSql);
}else
if( strcmp(zOp,"run")==0 ){
char *zErrMsg = 0;
str.n = 0;
str.z[0] = 0;
rc = sqlite3_exec(p->db, zSql, captureOutputCallback, &str, &zErrMsg);
nTest++;
if( bVerbose ){
utf8_printf(p->out, "Result: %s\n", str.z);
}
if( rc || zErrMsg ){
nErr++;
rc = 1;
utf8_printf(p->out, "%d: error-code-%d: %s\n", tno, rc, zErrMsg);
sqlite3_free(zErrMsg);
}else if( strcmp(zAns,str.z)!=0 ){
nErr++;
rc = 1;
utf8_printf(p->out, "%d: Expected: [%s]\n", tno, zAns);
utf8_printf(p->out, "%d: Got: [%s]\n", tno, str.z);
}
}else
{
utf8_printf(stderr,
"Unknown operation \"%s\" on selftest line %d\n", zOp, tno);
rc = 1;
break;
}
} /* End loop over rows of content from SELFTEST */
sqlite3_finalize(pStmt);
} /* End loop over k */
freeText(&str);
utf8_printf(p->out, "%d errors out of %d tests\n", nErr, nTest);
}else
if( c=='s' && strncmp(azArg[0], "separator", n)==0 ){
if( nArg<2 || nArg>3 ){
raw_printf(stderr, "Usage: .separator COL ?ROW?\n");
rc = 1;
|
| ︙ | ︙ | |||
5934 5935 5936 5937 5938 5939 5940 |
const char *z = azArg[i];
if( z[0]=='-' ){
z++;
if( z[0]=='-' ) z++;
if( strcmp(z,"schema")==0 ){
bSchema = 1;
}else
| | | | 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 |
const char *z = azArg[i];
if( z[0]=='-' ){
z++;
if( z[0]=='-' ) z++;
if( strcmp(z,"schema")==0 ){
bSchema = 1;
}else
if( strcmp(z,"sha3-224")==0 || strcmp(z,"sha3-256")==0
|| strcmp(z,"sha3-384")==0 || strcmp(z,"sha3-512")==0
){
iSize = atoi(&z[5]);
}else
if( strcmp(z,"debug")==0 ){
bDebug = 1;
}else
{
|
| ︙ | ︙ | |||
6103 6104 6105 6106 6107 6108 6109 |
if( (c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0)
|| (c=='i' && (strncmp(azArg[0], "indices", n)==0
|| strncmp(azArg[0], "indexes", n)==0) )
){
sqlite3_stmt *pStmt;
char **azResult;
int nRow, nAlloc;
| < > > < < < < < < < < < | < < < < < | | > > > > > > > > > > < < < | | | < < < | | < | | < | < | 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 |
if( (c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0)
|| (c=='i' && (strncmp(azArg[0], "indices", n)==0
|| strncmp(azArg[0], "indexes", n)==0) )
){
sqlite3_stmt *pStmt;
char **azResult;
int nRow, nAlloc;
int ii;
ShellText s;
initText(&s);
open_db(p, 0);
rc = sqlite3_prepare_v2(p->db, "PRAGMA database_list", -1, &pStmt, 0);
if( rc ) return shellDatabaseError(p->db);
if( nArg>2 && c=='i' ){
/* It is an historical accident that the .indexes command shows an error
** when called with the wrong number of arguments whereas the .tables
** command does not. */
raw_printf(stderr, "Usage: .indexes ?LIKE-PATTERN?\n");
rc = 1;
goto meta_command_exit;
}
for(ii=0; sqlite3_step(pStmt)==SQLITE_ROW; ii++){
const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);
if( zDbName==0 ) continue;
if( s.z && s.z[0] ) appendText(&s, " UNION ALL ", 0);
if( sqlite3_stricmp(zDbName, "main")==0 ){
appendText(&s, "SELECT name FROM ", 0);
}else{
appendText(&s, "SELECT ", 0);
appendText(&s, zDbName, '\'');
appendText(&s, "||'.'||name FROM ", 0);
}
appendText(&s, zDbName, '"');
appendText(&s, ".sqlite_master ", 0);
if( c=='t' ){
appendText(&s," WHERE type IN ('table','view')"
" AND name NOT LIKE 'sqlite_%'"
" AND name LIKE ?1", 0);
}else{
appendText(&s," WHERE type='index'"
" AND tbl_name LIKE ?1", 0);
}
}
rc = sqlite3_finalize(pStmt);
appendText(&s, " ORDER BY 1", 0);
rc = sqlite3_prepare_v2(p->db, s.z, -1, &pStmt, 0);
freeText(&s);
if( rc ) return shellDatabaseError(p->db);
/* Run the SQL statement prepared by the above block. Store the results
** as an array of nul-terminated strings in azResult[]. */
nRow = nAlloc = 0;
azResult = 0;
if( nArg>1 ){
|
| ︙ | ︙ | |||
6248 6249 6250 6251 6252 6253 6254 |
{ "benign_malloc_hooks", SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS },
{ "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE },
{ "assert", SQLITE_TESTCTRL_ASSERT },
{ "always", SQLITE_TESTCTRL_ALWAYS },
{ "reserve", SQLITE_TESTCTRL_RESERVE },
{ "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS },
{ "iskeyword", SQLITE_TESTCTRL_ISKEYWORD },
| < | 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 |
{ "benign_malloc_hooks", SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS },
{ "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE },
{ "assert", SQLITE_TESTCTRL_ASSERT },
{ "always", SQLITE_TESTCTRL_ALWAYS },
{ "reserve", SQLITE_TESTCTRL_RESERVE },
{ "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS },
{ "iskeyword", SQLITE_TESTCTRL_ISKEYWORD },
{ "byteorder", SQLITE_TESTCTRL_BYTEORDER },
{ "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT },
{ "imposter", SQLITE_TESTCTRL_IMPOSTER },
};
int testctrl = -1;
int rc2 = 0;
int i, n2;
|
| ︙ | ︙ | |||
6361 6362 6363 6364 6365 6366 6367 |
raw_printf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n");
}
break;
case SQLITE_TESTCTRL_BITVEC_TEST:
case SQLITE_TESTCTRL_FAULT_INSTALL:
case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS:
| < | 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 |
raw_printf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n");
}
break;
case SQLITE_TESTCTRL_BITVEC_TEST:
case SQLITE_TESTCTRL_FAULT_INSTALL:
case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS:
default:
utf8_printf(stderr,
"Error: CLI support for testctrl %s not implemented\n",
azArg[1]);
break;
}
}
|
| ︙ | ︙ | |||
6880 6881 6882 6883 6884 6885 6886 | " -mmap N default mmap size set to N\n" #ifdef SQLITE_ENABLE_MULTIPLEX " -multiplex enable the multiplexor VFS\n" #endif " -newline SEP set output row separator. Default: '\\n'\n" " -nullvalue TEXT set text string for NULL values. Default ''\n" " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n" | | | 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 | " -mmap N default mmap size set to N\n" #ifdef SQLITE_ENABLE_MULTIPLEX " -multiplex enable the multiplexor VFS\n" #endif " -newline SEP set output row separator. Default: '\\n'\n" " -nullvalue TEXT set text string for NULL values. Default ''\n" " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n" " -quote set output mode to 'quote'\n" " -separator SEP set output column separator. Default: '|'\n" " -stats print memory stats before each finalize\n" " -version show SQLite version\n" " -vfs NAME use NAME as the default VFS\n" #ifdef SQLITE_ENABLE_VFSTRACE " -vfstrace enable tracing of all VFS calls\n" #endif |
| ︙ | ︙ | |||
6983 6984 6985 6986 6987 6988 6989 | setBinaryMode(stdin, 0); setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */ stdin_is_interactive = isatty(0); stdout_is_console = isatty(1); #if USE_SYSTEM_SQLITE+0!=1 | | | 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 |
setBinaryMode(stdin, 0);
setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
stdin_is_interactive = isatty(0);
stdout_is_console = isatty(1);
#if USE_SYSTEM_SQLITE+0!=1
if( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,60)!=0 ){
utf8_printf(stderr, "SQLite header and source version mismatch\n%s\n%s\n",
sqlite3_sourceid(), SQLITE_SOURCE_ID);
exit(1);
}
#endif
main_init(&data);
#if !SQLITE_SHELL_IS_UTF8
|
| ︙ | ︙ | |||
7078 7079 7080 7081 7082 7083 7084 |
zSize = cmdline_option_value(argc, argv, ++i);
szHeap = integerValue(zSize);
if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;
sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
#else
(void)cmdline_option_value(argc, argv, ++i);
#endif
| < < < < < < < < < < | 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 |
zSize = cmdline_option_value(argc, argv, ++i);
szHeap = integerValue(zSize);
if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;
sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
#else
(void)cmdline_option_value(argc, argv, ++i);
#endif
}else if( strcmp(z,"-pagecache")==0 ){
int n, sz;
sz = (int)integerValue(cmdline_option_value(argc,argv,++i));
if( sz>70000 ) sz = 70000;
if( sz<0 ) sz = 0;
n = (int)integerValue(cmdline_option_value(argc,argv,++i));
sqlite3_config(SQLITE_CONFIG_PAGECACHE,
|
| ︙ | ︙ | |||
7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 |
if( z[1]=='-' ){ z++; }
if( strcmp(z,"-init")==0 ){
i++;
}else if( strcmp(z,"-html")==0 ){
data.mode = MODE_Html;
}else if( strcmp(z,"-list")==0 ){
data.mode = MODE_List;
}else if( strcmp(z,"-line")==0 ){
data.mode = MODE_Line;
}else if( strcmp(z,"-column")==0 ){
data.mode = MODE_Column;
}else if( strcmp(z,"-csv")==0 ){
data.mode = MODE_Csv;
memcpy(data.colSeparator,",",2);
| > > | 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 |
if( z[1]=='-' ){ z++; }
if( strcmp(z,"-init")==0 ){
i++;
}else if( strcmp(z,"-html")==0 ){
data.mode = MODE_Html;
}else if( strcmp(z,"-list")==0 ){
data.mode = MODE_List;
}else if( strcmp(z,"-quote")==0 ){
data.mode = MODE_Quote;
}else if( strcmp(z,"-line")==0 ){
data.mode = MODE_Line;
}else if( strcmp(z,"-column")==0 ){
data.mode = MODE_Column;
}else if( strcmp(z,"-csv")==0 ){
data.mode = MODE_Csv;
memcpy(data.colSeparator,",",2);
|
| ︙ | ︙ | |||
7229 7230 7231 7232 7233 7234 7235 |
return 0;
}else if( strcmp(z,"-interactive")==0 ){
stdin_is_interactive = 1;
}else if( strcmp(z,"-batch")==0 ){
stdin_is_interactive = 0;
}else if( strcmp(z,"-heap")==0 ){
i++;
| < < | 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 |
return 0;
}else if( strcmp(z,"-interactive")==0 ){
stdin_is_interactive = 1;
}else if( strcmp(z,"-batch")==0 ){
stdin_is_interactive = 0;
}else if( strcmp(z,"-heap")==0 ){
i++;
}else if( strcmp(z,"-pagecache")==0 ){
i+=2;
}else if( strcmp(z,"-lookaside")==0 ){
i+=2;
}else if( strcmp(z,"-mmap")==0 ){
i++;
}else if( strcmp(z,"-vfs")==0 ){
|
| ︙ | ︙ | |||
7326 7327 7328 7329 7330 7331 7332 7333 7334 |
if( zHome ){
nHistory = strlen30(zHome) + 20;
if( (zHistory = malloc(nHistory))!=0 ){
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
}
}
if( zHistory ){ shell_read_history(zHistory); }
rc = process_input(&data, 0);
if( zHistory ){
| > > > > > | | 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 |
if( zHome ){
nHistory = strlen30(zHome) + 20;
if( (zHistory = malloc(nHistory))!=0 ){
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
}
}
if( zHistory ){ shell_read_history(zHistory); }
#if HAVE_READLINE || HAVE_EDITLINE
rl_attempted_completion_function = readline_completion;
#elif HAVE_LINENOISE
linenoiseSetCompletionCallback(linenoise_completion);
#endif
rc = process_input(&data, 0);
if( zHistory ){
shell_stifle_history(2000);
shell_write_history(zHistory);
free(zHistory);
}
}else{
rc = process_input(&data, stdin);
}
}
|
| ︙ | ︙ |
Changes to src/shun.c.
| ︙ | ︙ | |||
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
** Access requires Admin privilege.
*/
void rcvfromlist_page(void){
int ofst = atoi(PD("ofst","0"));
int showAll = P("all")!=0;
int cnt;
Stmt q;
login_check_credentials();
if( !g.perm.Admin ){
login_needed(0);
return;
}
style_header("Artifact Receipts");
if( showAll ){
ofst = 0;
}else{
style_submenu_element("All", "rcvfromlist?all=1");
}
if( ofst>0 ){
style_submenu_element("Newer", "rcvfromlist?ofst=%d",
| > | > > > > > > > > > > > > | > > | > > > > > | | > | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
** Access requires Admin privilege.
*/
void rcvfromlist_page(void){
int ofst = atoi(PD("ofst","0"));
int showAll = P("all")!=0;
int cnt;
Stmt q;
const int perScreen = 500; /* RCVIDs per page */
login_check_credentials();
if( !g.perm.Admin ){
login_needed(0);
return;
}
style_header("Artifact Receipts");
if( showAll ){
ofst = 0;
}else{
style_submenu_element("All", "rcvfromlist?all=1");
}
if( ofst>0 ){
style_submenu_element("Newer", "rcvfromlist?ofst=%d",
ofst>perScreen ? ofst-perScreen : 0);
}
style_submenu_element("Artifacts", "bloblist");
style_submenu_element("Top-250", "bigbloblist");
db_multi_exec(
"CREATE TEMP TABLE rcvidUsed(x INTEGER PRIMARY KEY);"
"CREATE TEMP TABLE rcvidSha1(x INTEGER PRIMARY KEY);"
"CREATE TEMP TABLE rcvidSha3(x INTEGER PRIMARY KEY);"
"INSERT OR IGNORE INTO rcvidUsed(x) SELECT rcvid FROM blob;"
"INSERT OR IGNORE INTO rcvidSha1(x)"
" SELECT rcvid FROM blob WHERE length(uuid)==40;"
"INSERT OR IGNORE INTO rcvidSha3(x)"
" SELECT rcvid FROM blob WHERE length(uuid)==64;"
);
if( db_table_exists("repository","unversioned") ){
db_multi_exec(
"INSERT OR IGNORE INTO rcvidUsed(x) SELECT rcvid FROM unversioned;"
"INSERT OR IGNORE INTO rcvidSha1(x)"
" SELECT rcvid FROM unversioned WHERE length(hash)==40;"
"INSERT OR IGNORE INTO rcvidSha3(x)"
" SELECT rcvid FROM unversioned WHERE length(hash)==64;"
);
}
db_prepare(&q,
"SELECT rcvid, login, datetime(rcvfrom.mtime), rcvfrom.ipaddr,"
" EXISTS(SELECT 1 FROM rcvidUsed WHERE x=rcvfrom.rcvid),"
" EXISTS(SELECT 1 FROM rcvidSha1 WHERE x=rcvfrom.rcvid),"
" EXISTS(SELECT 1 FROM rcvidSha3 WHERE x=rcvfrom.rcvid)"
" FROM rcvfrom LEFT JOIN user USING(uid)"
" ORDER BY rcvid DESC LIMIT %d OFFSET %d",
showAll ? -1 : perScreen+1, ofst
);
@ <p>Whenever new artifacts are added to the repository, either by
@ push or using the web interface, an entry is made in the RCVFROM table
@ to record the source of that artifact. This log facilitates
@ finding and fixing attempts to inject illicit content into the
@ repository.</p>
@
@ <p>Click on the "rcvid" to show a list of specific artifacts received
@ by a transaction. After identifying illicit artifacts, remove them
@ using the "Shun" button. If an "rcvid" is not hyperlinked, that means
@ all artifacts associated with that rcvid have already been shunned
@ or purged.</p>
@
@ <table cellpadding="0" cellspacing="0" border="0">
@ <tr><th style="padding-right: 15px;text-align: right;">rcvid</th>
@ <th style="padding-right: 15px;text-align: left;">Date</th>
@ <th style="padding-right: 15px;text-align: left;">User</th>
@ <th style="padding-right: 15px;text-align: left;">Hash</th>
@ <th style="text-align: left;">IP Address</th></tr>
cnt = 0;
while( db_step(&q)==SQLITE_ROW ){
int rcvid = db_column_int(&q, 0);
const char *zUser = db_column_text(&q, 1);
const char *zDate = db_column_text(&q, 2);
const char *zIpAddr = db_column_text(&q, 3);
int usesSha1 = db_column_int(&q, 5)!=0;
int usesSha3 = db_column_int(&q, 6)!=0;
static const char *zHashType[] = { "", "sha1", "sha3", "both" };
const char *zHash = zHashType[usesSha1+usesSha3*2];
if( cnt==perScreen && !showAll ){
style_submenu_element("Older", "rcvfromlist?ofst=%d", ofst+perScreen);
}else{
cnt++;
@ <tr>
if( db_column_int(&q,4) ){
@ <td style="padding-right: 15px;text-align: right;">
@ <a href="rcvfrom?rcvid=%d(rcvid)">%d(rcvid)</a></td>
}else{
@ <td style="padding-right: 15px;text-align: right;">%d(rcvid)</td>
}
@ <td style="padding-right: 15px;text-align: left;">%s(zDate)</td>
@ <td style="padding-right: 15px;text-align: left;">%h(zUser)</td>
@ <td style="padding-right: 15px;text-align: left;">%s(zHash)</td>
@ <td style="text-align: left;">%s(zIpAddr)</td>
@ </tr>
}
}
db_finalize(&q);
@ </table>
style_footer();
|
| ︙ | ︙ |
Changes to src/skins.c.
| ︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
const char *zDesc; /* Description of this skin */
const char *zLabel; /* The directory under skins/ holding this skin */
char *zSQL; /* Filled in at run-time with SQL to insert this skin */
} aBuiltinSkin[] = {
{ "Default", "default", 0 },
{ "Blitz", "blitz", 0 },
{ "Blitz, No Logo", "blitz_no_logo", 0 },
{ "Xekri", "xekri", 0 },
{ "Original", "original", 0 },
{ "Enhanced Original", "enhanced1", 0 },
{ "Shadow boxes & Rounded Corners", "rounded1", 0 },
{ "Eagle", "eagle", 0 },
{ "Black & White, Menu on Left", "black_and_white", 0 },
{ "Plain Gray, No Logo", "plain_gray", 0 },
| > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
const char *zDesc; /* Description of this skin */
const char *zLabel; /* The directory under skins/ holding this skin */
char *zSQL; /* Filled in at run-time with SQL to insert this skin */
} aBuiltinSkin[] = {
{ "Default", "default", 0 },
{ "Blitz", "blitz", 0 },
{ "Blitz, No Logo", "blitz_no_logo", 0 },
{ "Bootstrap", "bootstrap", 0 },
{ "Xekri", "xekri", 0 },
{ "Original", "original", 0 },
{ "Enhanced Original", "enhanced1", 0 },
{ "Shadow boxes & Rounded Corners", "rounded1", 0 },
{ "Eagle", "eagle", 0 },
{ "Black & White, Menu on Left", "black_and_white", 0 },
{ "Plain Gray, No Logo", "plain_gray", 0 },
|
| ︙ | ︙ | |||
155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
z = mprintf("skins/default/%s.txt", zWhat);
zOut = builtin_text(z);
fossil_free(z);
}
}
return zOut;
}
/*
** Return a pointer to a SkinDetail element. Return 0 if not found.
*/
static struct SkinDetail *skin_detail_find(const char *zName){
int lwr = 0;
int upr = count(aSkinDetail);
| > > > > > > > > > > | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
z = mprintf("skins/default/%s.txt", zWhat);
zOut = builtin_text(z);
fossil_free(z);
}
}
return zOut;
}
/*
** Return the command-line option used to set the skin, or return NULL
** if the default skin is being used.
*/
const char *skin_in_use(void){
if( zAltSkinDir ) return zAltSkinDir;
if( pAltSkin ) return pAltSkin->zLabel;
return 0;
}
/*
** Return a pointer to a SkinDetail element. Return 0 if not found.
*/
static struct SkinDetail *skin_detail_find(const char *zName){
int lwr = 0;
int upr = count(aSkinDetail);
|
| ︙ | ︙ |
Changes to src/sqlcmd.c.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ** This module contains the code that initializes the "sqlite3" command-line ** shell against the repository database. The command-line shell itself ** is a copy of the "shell.c" code from SQLite. This file contains logic ** to initialize the code in shell.c. */ #include "config.h" #include "sqlcmd.h" #if defined(FOSSIL_ENABLE_MINIZ) # define MINIZ_HEADER_FILE_ONLY # include "miniz.c" #else # include <zlib.h> #endif | > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ** This module contains the code that initializes the "sqlite3" command-line ** shell against the repository database. The command-line shell itself ** is a copy of the "shell.c" code from SQLite. This file contains logic ** to initialize the code in shell.c. */ #include "config.h" #include "sqlcmd.h" #include <stdlib.h> /* atexit() */ #if defined(FOSSIL_ENABLE_MINIZ) # define MINIZ_HEADER_FILE_ONLY # include "miniz.c" #else # include <zlib.h> #endif |
| ︙ | ︙ | |||
148 149 150 151 152 153 154 155 |
db_add_aux_functions(db);
re_add_sql_func(db);
search_sql_setup(db);
foci_register(db);
g.repositoryOpen = 1;
g.db = db;
sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, "repository");
if( g.zLocalDbName ){
| > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
db_add_aux_functions(db);
re_add_sql_func(db);
search_sql_setup(db);
foci_register(db);
g.repositoryOpen = 1;
g.db = db;
sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, "repository");
db_maybe_set_encryption_key(db, g.zRepositoryName);
if( g.zLocalDbName ){
char *zSql = sqlite3_mprintf("ATTACH %Q AS 'localdb' KEY ''",
g.zLocalDbName);
sqlite3_exec(db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}
if( g.zConfigDbName ){
char *zSql = sqlite3_mprintf("ATTACH %Q AS 'configdb' KEY ''",
g.zConfigDbName);
sqlite3_exec(db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}
return SQLITE_OK;
}
/*
** atexit() handler that cleans up global state modified by this module.
*/
static void sqlcmd_atexit(void) {
g.zConfigDbName = 0; /* prevent panic */
}
/*
** This routine is called by the patched sqlite3 command-line shell in order
** to load the name and database connection for the open Fossil database.
*/
void fossil_open(const char **pzRepoName){
sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
*pzRepoName = g.zRepositoryName;
}
#if USE_SEE
/*
** This routine is called by the patched sqlite3 command-line shell in order
** to load the encryption key for the open Fossil database. The memory that
** is pointed to by the value placed in pzKey must be obtained from SQLite.
*/
void fossil_key(const char **pzKey, int *pnKey){
char *zSavedKey = db_get_saved_encryption_key();
char *zKey;
size_t savedKeySize = db_get_saved_encryption_key_size();
size_t nByte;
if( zSavedKey==0 || savedKeySize==0 ) return;
nByte = savedKeySize * sizeof(char);
zKey = sqlite3_malloc( (int)nByte );
if( zKey ){
memcpy(zKey, zSavedKey, nByte);
*pzKey = zKey;
if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){
*pnKey = (int)strlen(zKey);
}else{
*pnKey = -1;
}
}else{
fossil_fatal("failed to allocate %u bytes for key", nByte);
}
}
#endif
/*
** This routine closes the Fossil databases and/or invalidates the global
** state variables that keep track of them.
*/
static void fossil_close(int bDb, int noRepository){
if( bDb ) db_close(1);
if( noRepository ) g.zRepositoryName = 0;
g.db = 0;
g.repositoryOpen = 0;
g.localOpen = 0;
}
/*
** COMMAND: sqlite3
**
** Usage: %fossil sql ?OPTIONS?
**
** Run the standalone sqlite3 command-line shell on DATABASE with SHELL_OPTS.
|
| ︙ | ︙ | |||
224 225 226 227 228 229 230 231 232 233 234 235 | db_open_config(1,0); zConfigDb = g.zConfigDbName; fossil_close(1, noRepository); sqlite3_shutdown(); #ifndef _WIN32 linenoiseSetMultiLine(1); #endif g.zConfigDbName = zConfigDb; sqlite3_shell(g.argc-1, g.argv+1); sqlite3_cancel_auto_extension((void(*)(void))sqlcmd_autoinit); fossil_close(0, noRepository); } | > < < < < < < < < < < < < < < < < < < < < < | 285 286 287 288 289 290 291 292 293 294 295 296 297 | db_open_config(1,0); zConfigDb = g.zConfigDbName; fossil_close(1, noRepository); sqlite3_shutdown(); #ifndef _WIN32 linenoiseSetMultiLine(1); #endif atexit(sqlcmd_atexit); g.zConfigDbName = zConfigDb; sqlite3_shell(g.argc-1, g.argv+1); sqlite3_cancel_auto_extension((void(*)(void))sqlcmd_autoinit); fossil_close(0, noRepository); } |
Changes to src/sqlite3.c.
more than 10,000 changes
Changes to src/sqlite3.h.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* ** 2001-09-15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. |
| ︙ | ︙ | |||
110 111 112 113 114 115 116 | ** ** Since [version 3.6.18] ([dateof:3.6.18]), ** SQLite source code has been stored in the ** <a href="http://www.fossil-scm.org/">Fossil configuration management ** system</a>. ^The SQLITE_SOURCE_ID macro evaluates to ** a string which identifies a particular check-in of SQLite ** within its configuration management system. ^The SQLITE_SOURCE_ID | | | > > | | | | | | > > | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | ** ** Since [version 3.6.18] ([dateof:3.6.18]), ** SQLite source code has been stored in the ** <a href="http://www.fossil-scm.org/">Fossil configuration management ** system</a>. ^The SQLITE_SOURCE_ID macro evaluates to ** a string which identifies a particular check-in of SQLite ** within its configuration management system. ^The SQLITE_SOURCE_ID ** string contains the date and time of the check-in (UTC) and a SHA1 ** or SHA3-256 hash of the entire source tree. If the source code has ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.21.0" #define SQLITE_VERSION_NUMBER 3021000 #define SQLITE_SOURCE_ID "2017-10-02 02:52:54 c9104b59c7ed360291f7f6fc8caae938e9840c77620d598e4096f78183bf807a" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros ** but are associated with the library instead of the header file. ^(Cautious ** programmers might include assert() statements in their application to ** verify that values returned by these interfaces match the macros in ** the header, and thus ensure that the application is ** compiled with matching library and header files. ** ** <blockquote><pre> ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER ); ** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 ); ** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 ); ** </pre></blockquote>)^ ** ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] ** macro. ^The sqlite3_libversion() function returns a pointer to the ** to the sqlite3_version[] string constant. The sqlite3_libversion() ** function is provided for use in DLLs since DLL users usually do not have ** direct access to string constants within the DLL. ^The ** sqlite3_libversion_number() function returns an integer equal to ** [SQLITE_VERSION_NUMBER]. ^(The sqlite3_sourceid() function returns ** a pointer to a string constant whose value is the same as the ** [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built ** using an edited copy of [the amalgamation], then the last four characters ** of the hash might be different from [SQLITE_SOURCE_ID].)^ ** ** See also: [sqlite_version()] and [sqlite_source_id()]. */ SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; SQLITE_API const char *sqlite3_libversion(void); SQLITE_API const char *sqlite3_sourceid(void); SQLITE_API int sqlite3_libversion_number(void); |
| ︙ | ︙ | |||
413 414 415 416 417 418 419 | ** ** New error codes may be added in future versions of SQLite. ** ** See also: [extended result code definitions] */ #define SQLITE_OK 0 /* Successful result */ /* beginning-of-error-codes */ | | | | | 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | ** ** New error codes may be added in future versions of SQLite. ** ** See also: [extended result code definitions] */ #define SQLITE_OK 0 /* Successful result */ /* beginning-of-error-codes */ #define SQLITE_ERROR 1 /* Generic error */ #define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ #define SQLITE_PERM 3 /* Access permission denied */ #define SQLITE_ABORT 4 /* Callback routine requested an abort */ #define SQLITE_BUSY 5 /* The database file is locked */ #define SQLITE_LOCKED 6 /* A table in the database is locked */ #define SQLITE_NOMEM 7 /* A malloc() failed */ #define SQLITE_READONLY 8 /* Attempt to write a readonly database */ #define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ #define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ #define SQLITE_CORRUPT 11 /* The database disk image is malformed */ #define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */ #define SQLITE_FULL 13 /* Insertion failed because database is full */ #define SQLITE_CANTOPEN 14 /* Unable to open the database file */ #define SQLITE_PROTOCOL 15 /* Database lock protocol error */ #define SQLITE_EMPTY 16 /* Internal use only */ #define SQLITE_SCHEMA 17 /* The database schema changed */ #define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ #define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ #define SQLITE_MISMATCH 20 /* Data type mismatch */ #define SQLITE_MISUSE 21 /* Library used incorrectly */ #define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ #define SQLITE_AUTH 23 /* Authorization denied */ #define SQLITE_FORMAT 24 /* Not used */ #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ #define SQLITE_NOTADB 26 /* File opened that is not a database file */ #define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */ #define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */ #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ /* end-of-error-codes */ |
| ︙ | ︙ | |||
490 491 492 493 494 495 496 497 498 499 500 501 502 503 | #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8)) #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8)) #define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8)) #define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27<<8)) #define SQLITE_IOERR_AUTH (SQLITE_IOERR | (28<<8)) #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8)) #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) | > > > | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8)) #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8)) #define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8)) #define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27<<8)) #define SQLITE_IOERR_AUTH (SQLITE_IOERR | (28<<8)) #define SQLITE_IOERR_BEGIN_ATOMIC (SQLITE_IOERR | (29<<8)) #define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8)) #define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8)) #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8)) #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) |
| ︙ | ︙ | |||
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | ** file that were written at the application level might have changed ** and that adjacent bytes, even bytes within the same sector are ** guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN ** flag indicates that a file cannot be deleted when open. The ** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on ** read-only media and cannot be changed even by processes with ** elevated privileges. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 #define SQLITE_IOCAP_ATOMIC1K 0x00000004 #define SQLITE_IOCAP_ATOMIC2K 0x00000008 #define SQLITE_IOCAP_ATOMIC4K 0x00000010 #define SQLITE_IOCAP_ATOMIC8K 0x00000020 #define SQLITE_IOCAP_ATOMIC16K 0x00000040 #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 #define SQLITE_IOCAP_IMMUTABLE 0x00002000 /* ** CAPI3REF: File Locking Levels ** ** SQLite uses one of these integer values as the second ** argument to calls it makes to the xLock() and xUnlock() methods ** of an [sqlite3_io_methods] object. | > > > > > > | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | ** file that were written at the application level might have changed ** and that adjacent bytes, even bytes within the same sector are ** guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN ** flag indicates that a file cannot be deleted when open. The ** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on ** read-only media and cannot be changed even by processes with ** elevated privileges. ** ** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying ** filesystem supports doing multiple write operations atomically when those ** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and ** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 #define SQLITE_IOCAP_ATOMIC1K 0x00000004 #define SQLITE_IOCAP_ATOMIC2K 0x00000008 #define SQLITE_IOCAP_ATOMIC4K 0x00000010 #define SQLITE_IOCAP_ATOMIC8K 0x00000020 #define SQLITE_IOCAP_ATOMIC16K 0x00000040 #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 #define SQLITE_IOCAP_IMMUTABLE 0x00002000 #define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 /* ** CAPI3REF: File Locking Levels ** ** SQLite uses one of these integer values as the second ** argument to calls it makes to the xLock() and xUnlock() methods ** of an [sqlite3_io_methods] object. |
| ︙ | ︙ | |||
725 726 727 728 729 730 731 732 733 734 735 736 737 738 | ** <li> [SQLITE_IOCAP_ATOMIC32K] ** <li> [SQLITE_IOCAP_ATOMIC64K] ** <li> [SQLITE_IOCAP_SAFE_APPEND] ** <li> [SQLITE_IOCAP_SEQUENTIAL] ** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN] ** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE] ** <li> [SQLITE_IOCAP_IMMUTABLE] ** </ul> ** ** The SQLITE_IOCAP_ATOMIC property means that all writes of ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values ** mean that writes of blocks that are nnn bytes in size and ** are aligned to an address which is an integer multiple of ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means | > | 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | ** <li> [SQLITE_IOCAP_ATOMIC32K] ** <li> [SQLITE_IOCAP_ATOMIC64K] ** <li> [SQLITE_IOCAP_SAFE_APPEND] ** <li> [SQLITE_IOCAP_SEQUENTIAL] ** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN] ** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE] ** <li> [SQLITE_IOCAP_IMMUTABLE] ** <li> [SQLITE_IOCAP_BATCH_ATOMIC] ** </ul> ** ** The SQLITE_IOCAP_ATOMIC property means that all writes of ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values ** mean that writes of blocks that are nnn bytes in size and ** are aligned to an address which is an integer multiple of ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means |
| ︙ | ︙ | |||
853 854 855 856 857 858 859 | ** anti-virus programs. By default, the windows VFS will retry file read, ** file write, and file delete operations up to 10 times, with a delay ** of 25 milliseconds before the first retry and with the delay increasing ** by an additional 25 milliseconds with each subsequent retry. This ** opcode allows these two values (10 retries and 25 milliseconds of delay) ** to be adjusted. The values are changed for all database connections ** within the same process. The argument is a pointer to an array of two | | | 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 | ** anti-virus programs. By default, the windows VFS will retry file read, ** file write, and file delete operations up to 10 times, with a delay ** of 25 milliseconds before the first retry and with the delay increasing ** by an additional 25 milliseconds with each subsequent retry. This ** opcode allows these two values (10 retries and 25 milliseconds of delay) ** to be adjusted. The values are changed for all database connections ** within the same process. The argument is a pointer to an array of two ** integers where the first integer is the new retry count and the second ** integer is the delay. If either integer is negative, then the setting ** is not changed but instead the prior value of that setting is written ** into the array entry, allowing the current retry settings to be ** interrogated. The zDbName parameter is ignored. ** ** <li>[[SQLITE_FCNTL_PERSIST_WAL]] ** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the |
| ︙ | ︙ | |||
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 | ** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other ** VFS should return SQLITE_NOTFOUND for this opcode. ** ** <li>[[SQLITE_FCNTL_RBU]] ** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by ** the RBU extension only. All other VFS should return SQLITE_NOTFOUND for ** this opcode. ** </ul> */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 #define SQLITE_FCNTL_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 | ** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other ** VFS should return SQLITE_NOTFOUND for this opcode. ** ** <li>[[SQLITE_FCNTL_RBU]] ** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by ** the RBU extension only. All other VFS should return SQLITE_NOTFOUND for ** this opcode. ** ** <li>[[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]] ** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then ** the file descriptor is placed in "batch write mode", which ** means all subsequent write operations will be deferred and done ** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. Systems ** that do not support batch atomic writes will return SQLITE_NOTFOUND. ** ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to ** the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or ** [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make ** no VFS interface calls on the same [sqlite3_file] file descriptor ** except for calls to the xWrite method and the xFileControl method ** with [SQLITE_FCNTL_SIZE_HINT]. ** ** <li>[[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]] ** The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write ** operations since the previous successful call to ** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically. ** This file control returns [SQLITE_OK] if and only if the writes were ** all performed successfully and have been committed to persistent storage. ** ^Regardless of whether or not it is successful, this file control takes ** the file descriptor out of batch write mode so that all subsequent ** write operations are independent. ** ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without ** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. ** ** <li>[[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]] ** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write ** operations since the previous successful call to ** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back. ** ^This file control takes the file descriptor out of batch write mode ** so that all subsequent write operations are independent. ** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without ** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. ** </ul> */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 #define SQLITE_FCNTL_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 |
| ︙ | ︙ | |||
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 | #define SQLITE_FCNTL_WAL_BLOCK 24 #define SQLITE_FCNTL_ZIPVFS 25 #define SQLITE_FCNTL_RBU 26 #define SQLITE_FCNTL_VFS_POINTER 27 #define SQLITE_FCNTL_JOURNAL_POINTER 28 #define SQLITE_FCNTL_WIN32_GET_HANDLE 29 #define SQLITE_FCNTL_PDB 30 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO | > > > | 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 | #define SQLITE_FCNTL_WAL_BLOCK 24 #define SQLITE_FCNTL_ZIPVFS 25 #define SQLITE_FCNTL_RBU 26 #define SQLITE_FCNTL_VFS_POINTER 27 #define SQLITE_FCNTL_JOURNAL_POINTER 28 #define SQLITE_FCNTL_WIN32_GET_HANDLE 29 #define SQLITE_FCNTL_PDB 30 #define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
| ︙ | ︙ | |||
1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 | ** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which ** is a pointer to an instance of the [sqlite3_mem_methods] structure. ** The [sqlite3_mem_methods] ** structure is filled with the currently defined memory allocation routines.)^ ** This option can be used to overload the default memory allocation ** routines with a wrapper that simulations memory allocation failure or ** tracks memory usage, for example. </dd> ** ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt> ** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int, ** interpreted as a boolean, which enables or disables the collection of ** memory allocation statistics. ^(When memory allocation statistics are ** disabled, the following SQLite interfaces become non-operational: ** <ul> ** <li> [sqlite3_memory_used()] ** <li> [sqlite3_memory_highwater()] ** <li> [sqlite3_soft_heap_limit64()] ** <li> [sqlite3_status64()] ** </ul>)^ ** ^Memory allocation statistics are enabled by default unless SQLite is ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory ** allocation statistics are disabled by default. ** </dd> ** ** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt> | > > > > > > > > > > | < < < < < < < < < < < < < < < < < < | 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 | ** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which ** is a pointer to an instance of the [sqlite3_mem_methods] structure. ** The [sqlite3_mem_methods] ** structure is filled with the currently defined memory allocation routines.)^ ** This option can be used to overload the default memory allocation ** routines with a wrapper that simulations memory allocation failure or ** tracks memory usage, for example. </dd> ** ** [[SQLITE_CONFIG_SMALL_MALLOC]] <dt>SQLITE_CONFIG_SMALL_MALLOC</dt> ** <dd> ^The SQLITE_CONFIG_SMALL_MALLOC option takes single argument of ** type int, interpreted as a boolean, which if true provides a hint to ** SQLite that it should avoid large memory allocations if possible. ** SQLite will run faster if it is free to make large memory allocations, ** but some application might prefer to run slower in exchange for ** guarantees about memory fragmentation that are possible if large ** allocations are avoided. This hint is normally off. ** </dd> ** ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt> ** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int, ** interpreted as a boolean, which enables or disables the collection of ** memory allocation statistics. ^(When memory allocation statistics are ** disabled, the following SQLite interfaces become non-operational: ** <ul> ** <li> [sqlite3_memory_used()] ** <li> [sqlite3_memory_highwater()] ** <li> [sqlite3_soft_heap_limit64()] ** <li> [sqlite3_status64()] ** </ul>)^ ** ^Memory allocation statistics are enabled by default unless SQLite is ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory ** allocation statistics are disabled by default. ** </dd> ** ** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt> ** <dd> The SQLITE_CONFIG_SCRATCH option is no longer used. ** </dd> ** ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> ** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool ** that SQLite can use for the database page cache with the default page ** cache implementation. ** This configuration option is a no-op if an application-define page |
| ︙ | ︙ | |||
1680 1681 1682 1683 1684 1685 1686 | ** page cache memory is needed beyond what is provided by the initial ** allocation, then SQLite goes to [sqlite3_malloc()] separately for each ** additional cache line. </dd> ** ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt> ** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer ** that SQLite will use for all of its dynamic memory allocation needs | | < | 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 | ** page cache memory is needed beyond what is provided by the initial ** allocation, then SQLite goes to [sqlite3_malloc()] separately for each ** additional cache line. </dd> ** ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt> ** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer ** that SQLite will use for all of its dynamic memory allocation needs ** beyond those provided for by [SQLITE_CONFIG_PAGECACHE]. ** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled ** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns ** [SQLITE_ERROR] if invoked otherwise. ** ^There are three arguments to SQLITE_CONFIG_HEAP: ** An 8-byte aligned pointer to the memory, ** the number of bytes in the memory buffer, and the minimum allocation size. ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts |
| ︙ | ︙ | |||
1874 1875 1876 1877 1878 1879 1880 | ** </dl> */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ | | > | 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 | ** </dl> */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_SCRATCH 6 /* No longer used */ #define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ #define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ /* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ #define SQLITE_CONFIG_PCACHE 14 /* no-op */ #define SQLITE_CONFIG_GETPCACHE 15 /* no-op */ #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ #define SQLITE_CONFIG_URI 17 /* int */ #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */ #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */ #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */ #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ #define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */ #define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */ #define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */ #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ /* ** CAPI3REF: Database Connection Configuration Options ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** |
| ︙ | ︙ | |||
2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 | ** override this behaviour. The first parameter passed to this operation ** is an integer - non-zero to disable checkpoints-on-close, or zero (the ** default) to enable them. The second parameter is a pointer to an integer ** into which is written 0 or 1 to indicate whether checkpoints-on-close ** have been disabled - 0 if they are not disabled, 1 if they are. ** </dd> ** ** </dl> */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */ #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes ** METHOD: sqlite3 ** ** ^The sqlite3_extended_result_codes() routine enables or disables the | > > > > > > > > > > > > | 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 | ** override this behaviour. The first parameter passed to this operation ** is an integer - non-zero to disable checkpoints-on-close, or zero (the ** default) to enable them. The second parameter is a pointer to an integer ** into which is written 0 or 1 to indicate whether checkpoints-on-close ** have been disabled - 0 if they are not disabled, 1 if they are. ** </dd> ** ** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt> ** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates ** the [query planner stability guarantee] (QPSG). When the QPSG is active, ** a single SQL query statement will always use the same algorithm regardless ** of values of [bound parameters].)^ The QPSG disables some query optimizations ** that look at the values of bound parameters, which can make some queries ** slower. But the QPSG has the advantage of more predictable behavior. With ** the QPSG active, SQLite will always use the same query plan in the field as ** was used during testing in the lab. ** </dd> ** ** </dl> */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */ #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes ** METHOD: sqlite3 ** ** ^The sqlite3_extended_result_codes() routine enables or disables the |
| ︙ | ︙ | |||
2207 2208 2209 2210 2211 2212 2213 | ** running statements reaches zero are interrupted as if they had been ** running prior to the sqlite3_interrupt() call. ^New SQL statements ** that are started after the running statement count reaches zero are ** not effected by the sqlite3_interrupt(). ** ^A call to sqlite3_interrupt(D) that occurs when there are no running ** SQL statements is a no-op and has no effect on SQL statements ** that are started after the sqlite3_interrupt() call returns. | < < < | 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 | ** running statements reaches zero are interrupted as if they had been ** running prior to the sqlite3_interrupt() call. ^New SQL statements ** that are started after the running statement count reaches zero are ** not effected by the sqlite3_interrupt(). ** ^A call to sqlite3_interrupt(D) that occurs when there are no running ** SQL statements is a no-op and has no effect on SQL statements ** that are started after the sqlite3_interrupt() call returns. */ SQLITE_API void sqlite3_interrupt(sqlite3*); /* ** CAPI3REF: Determine If An SQL Statement Is Complete ** ** These routines are useful during command-line input to determine if the |
| ︙ | ︙ | |||
2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 | ** method. */ SQLITE_API void sqlite3_randomness(int N, void *P); /* ** CAPI3REF: Compile-Time Authorization Callbacks ** METHOD: sqlite3 ** ** ^This routine registers an authorizer callback with a particular ** [database connection], supplied in the first argument. ** ^The authorizer callback is invoked as SQL statements are being compiled ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], | > > | | 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 |
** method.
*/
SQLITE_API void sqlite3_randomness(int N, void *P);
/*
** CAPI3REF: Compile-Time Authorization Callbacks
** METHOD: sqlite3
** KEYWORDS: {authorizer callback}
**
** ^This routine registers an authorizer callback with a particular
** [database connection], supplied in the first argument.
** ^The authorizer callback is invoked as SQL statements are being compiled
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],
** and [sqlite3_prepare16_v3()]. ^At various
** points during the compilation process, as logic is being created
** to perform various actions, the authorizer callback is invoked to
** see if those actions are allowed. ^The authorizer callback should
** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
** specific action but allow the SQL statement to continue to be
** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
** rejected with an error. ^If the authorizer callback returns
|
| ︙ | ︙ | |||
2699 2700 2701 2702 2703 2704 2705 | ** authorizer will fail with an error message explaining that ** access is denied. ** ** ^The first parameter to the authorizer callback is a copy of the third ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter ** to the callback is an integer [SQLITE_COPY | action code] that specifies ** the particular action to be authorized. ^The third through sixth parameters | | | > > > > > > | 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 | ** authorizer will fail with an error message explaining that ** access is denied. ** ** ^The first parameter to the authorizer callback is a copy of the third ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter ** to the callback is an integer [SQLITE_COPY | action code] that specifies ** the particular action to be authorized. ^The third through sixth parameters ** to the callback are either NULL pointers or zero-terminated strings ** that contain additional details about the action to be authorized. ** Applications must always be prepared to encounter a NULL pointer in any ** of the third through the sixth parameters of the authorization callback. ** ** ^If the action code is [SQLITE_READ] ** and the callback returns [SQLITE_IGNORE] then the ** [prepared statement] statement is constructed to substitute ** a NULL value in place of the table column that would have ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] ** return can be used to deny an untrusted user access to individual ** columns of a table. ** ^When a table is referenced by a [SELECT] but no column values are ** extracted from that table (for example in a query like ** "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback ** is invoked once for that table with a column name that is an empty string. ** ^If the action code is [SQLITE_DELETE] and the callback returns ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the ** [truncate optimization] is disabled and all rows are deleted individually. ** ** An authorizer is used when [sqlite3_prepare | preparing] ** SQL statements from an untrusted source, to ensure that the SQL statements ** do not try to access data they are not allowed to see, or that they do not |
| ︙ | ︙ | |||
3078 3079 3080 3081 3082 3083 3084 | ** automatically deleted as soon as the database connection is closed. ** ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3> ** ** ^If [URI filename] interpretation is enabled, and the filename argument ** begins with "file:", then the filename is interpreted as a URI. ^URI ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is | | | | 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 | ** automatically deleted as soon as the database connection is closed. ** ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3> ** ** ^If [URI filename] interpretation is enabled, and the filename argument ** begins with "file:", then the filename is interpreted as a URI. ^URI ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is ** set in the third argument to sqlite3_open_v2(), or if it has ** been enabled globally using the [SQLITE_CONFIG_URI] option with the ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. ** URI filename interpretation is turned off ** by default, but future releases of SQLite might enable URI filename ** interpretation by default. See "[URI filenames]" for additional ** information. ** ** URI filenames are parsed according to RFC 3986. ^If the URI contains an ** authority, then it must be either an empty string or the string ** "localhost". ^If the authority is not an empty string or "localhost", an |
| ︙ | ︙ | |||
3420 3421 3422 3423 3424 3425 3426 | ** <dd>The maximum depth of the parse tree on any expression.</dd>)^ ** ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt> ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^ ** ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt> ** <dd>The maximum number of instructions in a virtual machine program | | | | | 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 | ** <dd>The maximum depth of the parse tree on any expression.</dd>)^ ** ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt> ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^ ** ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt> ** <dd>The maximum number of instructions in a virtual machine program ** used to implement an SQL statement. If [sqlite3_prepare_v2()] or ** the equivalent tries to allocate space for more than this many opcodes ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^ ** ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt> ** <dd>The maximum number of arguments on a function.</dd>)^ ** ** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt> ** <dd>The maximum number of [ATTACH | attached databases].)^</dd> ** |
| ︙ | ︙ | |||
3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 |
#define SQLITE_LIMIT_FUNCTION_ARG 6
#define SQLITE_LIMIT_ATTACHED 7
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
#define SQLITE_LIMIT_WORKER_THREADS 11
/*
** CAPI3REF: Compiling An SQL Statement
** KEYWORDS: {SQL statement compiler}
** METHOD: sqlite3
** CONSTRUCTOR: sqlite3_stmt
**
| > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > | > | | | 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 |
#define SQLITE_LIMIT_FUNCTION_ARG 6
#define SQLITE_LIMIT_ATTACHED 7
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
#define SQLITE_LIMIT_WORKER_THREADS 11
/*
** CAPI3REF: Prepare Flags
**
** These constants define various flags that can be passed into
** "prepFlags" parameter of the [sqlite3_prepare_v3()] and
** [sqlite3_prepare16_v3()] interfaces.
**
** New flags may be added in future releases of SQLite.
**
** <dl>
** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>
** <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner
** that the prepared statement will be retained for a long time and
** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]
** and [sqlite3_prepare16_v3()] assume that the prepared statement will
** be used just once or at most a few times and then destroyed using
** [sqlite3_finalize()] relatively soon. The current implementation acts
** on this hint by avoiding the use of [lookaside memory] so as not to
** deplete the limited store of lookaside memory. Future versions of
** SQLite may act on this hint differently.
** </dl>
*/
#define SQLITE_PREPARE_PERSISTENT 0x01
/*
** CAPI3REF: Compiling An SQL Statement
** KEYWORDS: {SQL statement compiler}
** METHOD: sqlite3
** CONSTRUCTOR: sqlite3_stmt
**
** To execute an SQL statement, it must first be compiled into a byte-code
** program using one of these routines. Or, in other words, these routines
** are constructors for the [prepared statement] object.
**
** The preferred routine to use is [sqlite3_prepare_v2()]. The
** [sqlite3_prepare()] interface is legacy and should be avoided.
** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
** for special purposes.
**
** The use of the UTF-8 interfaces is preferred, as SQLite currently
** does all parsing using UTF-8. The UTF-16 interfaces are provided
** as a convenience. The UTF-16 interfaces work by converting the
** input text into UTF-8, then invoking the corresponding UTF-8 interface.
**
** The first argument, "db", is a [database connection] obtained from a
** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
** [sqlite3_open16()]. The database connection must not have been closed.
**
** The second argument, "zSql", is the statement to be compiled, encoded
** as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(),
** and sqlite3_prepare_v3()
** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),
** and sqlite3_prepare16_v3() use UTF-16.
**
** ^If the nByte argument is negative, then zSql is read up to the
** first zero terminator. ^If nByte is positive, then it is the
** number of bytes read from zSql. ^If nByte is zero, then no prepared
** statement is generated.
** If the caller knows that the supplied string is nul-terminated, then
** there is a small performance advantage to passing an nByte parameter that
|
| ︙ | ︙ | |||
3503 3504 3505 3506 3507 3508 3509 | ** The calling procedure is responsible for deleting the compiled ** SQL statement using [sqlite3_finalize()] after it has finished with it. ** ppStmt may not be NULL. ** ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; ** otherwise an [error code] is returned. ** | | | > | | | 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 | ** The calling procedure is responsible for deleting the compiled ** SQL statement using [sqlite3_finalize()] after it has finished with it. ** ppStmt may not be NULL. ** ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; ** otherwise an [error code] is returned. ** ** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(), ** and sqlite3_prepare16_v3() interfaces are recommended for all new programs. ** The older interfaces (sqlite3_prepare() and sqlite3_prepare16()) ** are retained for backwards compatibility, but their use is discouraged. ** ^In the "vX" interfaces, the prepared statement ** that is returned (the [sqlite3_stmt] object) contains a copy of the ** original SQL text. This causes the [sqlite3_step()] interface to ** behave differently in three ways: ** ** <ol> ** <li> ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it |
| ︙ | ︙ | |||
3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 | ** a schema change, on the first [sqlite3_step()] call following any change ** to the [sqlite3_bind_text | bindings] of that [parameter]. ** ^The specific value of WHERE-clause [parameter] might influence the ** choice of query plan if the parameter is the left-hand side of a [LIKE] ** or [GLOB] operator or if the parameter is compared to an indexed column ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. ** </li> ** </ol> */ SQLITE_API int sqlite3_prepare( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare_v2( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare16( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare16_v2( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); /* ** CAPI3REF: Retrieving Statement SQL ** METHOD: sqlite3_stmt ** ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8 ** SQL text used to create [prepared statement] P if P was | > > > > > > > > > > > > > > > > > > > > > > > | | 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 | ** a schema change, on the first [sqlite3_step()] call following any change ** to the [sqlite3_bind_text | bindings] of that [parameter]. ** ^The specific value of WHERE-clause [parameter] might influence the ** choice of query plan if the parameter is the left-hand side of a [LIKE] ** or [GLOB] operator or if the parameter is compared to an indexed column ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. ** </li> ** ** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having ** the extra prepFlags parameter, which is a bit array consisting of zero or ** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The ** sqlite3_prepare_v2() interface works exactly the same as ** sqlite3_prepare_v3() with a zero prepFlags parameter. ** </ol> */ SQLITE_API int sqlite3_prepare( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare_v2( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare_v3( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare16( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare16_v2( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare16_v3( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); /* ** CAPI3REF: Retrieving Statement SQL ** METHOD: sqlite3_stmt ** ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8 ** SQL text used to create [prepared statement] P if P was ** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()]. ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8 ** string containing the SQL text of prepared statement P with ** [bound parameters] expanded. ** ** ^(For example, if a prepared statement is created using the SQL ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345 ** and parameter :xyz is unbound, then sqlite3_sql() will return |
| ︙ | ︙ | |||
3695 3696 3697 3698 3699 3700 3701 | ** still make the distinction between protected and unprotected ** sqlite3_value objects even when not strictly required. ** ** ^The sqlite3_value objects that are passed as parameters into the ** implementation of [application-defined SQL functions] are protected. ** ^The sqlite3_value object returned by ** [sqlite3_column_value()] is unprotected. | | | > | | 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 | ** still make the distinction between protected and unprotected ** sqlite3_value objects even when not strictly required. ** ** ^The sqlite3_value objects that are passed as parameters into the ** implementation of [application-defined SQL functions] are protected. ** ^The sqlite3_value object returned by ** [sqlite3_column_value()] is unprotected. ** Unprotected sqlite3_value objects may only be used as arguments ** to [sqlite3_result_value()], [sqlite3_bind_value()], and ** [sqlite3_value_dup()]. ** The [sqlite3_value_blob | sqlite3_value_type()] family of ** interfaces require protected sqlite3_value objects. */ typedef struct sqlite3_value sqlite3_value; /* ** CAPI3REF: SQL Function Context Object ** ** The context in which an SQL function executes is stored in an ** sqlite3_context object. ^A pointer to an sqlite3_context object ** is always first parameter to [application-defined SQL functions]. |
| ︙ | ︙ | |||
3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 | ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory ** (just an integer to hold its size) while it is being processed. ** Zeroblobs are intended to serve as placeholders for BLOBs whose ** content is later written using ** [sqlite3_blob_open | incremental BLOB I/O] routines. ** ^A negative value for the zeroblob results in a zero-length BLOB. ** ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer ** for the [prepared statement] or with a prepared statement for which ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() ** routine is passed a [prepared statement] that has been finalized, the ** result is undefined and probably harmful. | > > > > > > > > > | 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 | ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory ** (just an integer to hold its size) while it is being processed. ** Zeroblobs are intended to serve as placeholders for BLOBs whose ** content is later written using ** [sqlite3_blob_open | incremental BLOB I/O] routines. ** ^A negative value for the zeroblob results in a zero-length BLOB. ** ** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in ** [prepared statement] S to have an SQL value of NULL, but to also be ** associated with the pointer P of type T. ^D is either a NULL pointer or ** a pointer to a destructor function for P. ^SQLite will invoke the ** destructor D with a single argument of P when it is finished using ** P. The T parameter should be a static string, preferably a string ** literal. The sqlite3_bind_pointer() routine is part of the ** [pointer passing interface] added for SQLite 3.20.0. ** ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer ** for the [prepared statement] or with a prepared statement for which ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() ** routine is passed a [prepared statement] that has been finalized, the ** result is undefined and probably harmful. |
| ︙ | ︙ | |||
3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 |
SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
void(*)(void*), unsigned char encoding);
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
/*
** CAPI3REF: Number Of SQL Parameters
** METHOD: sqlite3_stmt
**
| > | 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 |
SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
void(*)(void*), unsigned char encoding);
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*));
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
/*
** CAPI3REF: Number Of SQL Parameters
** METHOD: sqlite3_stmt
**
|
| ︙ | ︙ | |||
3878 3879 3880 3881 3882 3883 3884 | ** and are referred to as "nameless" or "anonymous parameters". ** ** ^The first host parameter has an index of 1, not 0. ** ** ^If the value N is out of range or if the N-th parameter is ** nameless, then NULL is returned. ^The returned string is ** always in UTF-8 encoding even if the named parameter was | | | | > | 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 | ** and are referred to as "nameless" or "anonymous parameters". ** ** ^The first host parameter has an index of 1, not 0. ** ** ^If the value N is out of range or if the N-th parameter is ** nameless, then NULL is returned. ^The returned string is ** always in UTF-8 encoding even if the named parameter was ** originally specified as UTF-16 in [sqlite3_prepare16()], ** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()]. ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_index()]. */ SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); /* ** CAPI3REF: Index Of A Parameter With A Given Name ** METHOD: sqlite3_stmt ** ** ^Return the index of an SQL parameter given its name. ^The ** index value returned is suitable for use as the second ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero ** is returned if no matching parameter is found. ^The parameter ** name must be given in UTF-8 even if the original statement ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or ** [sqlite3_prepare16_v3()]. ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_name()]. */ SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); |
| ︙ | ︙ | |||
4050 4051 4052 4053 4054 4055 4056 | SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); /* ** CAPI3REF: Evaluate An SQL Statement ** METHOD: sqlite3_stmt ** | | > | | > | | | | 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 | SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); /* ** CAPI3REF: Evaluate An SQL Statement ** METHOD: sqlite3_stmt ** ** After a [prepared statement] has been prepared using any of ** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()], ** or [sqlite3_prepare16_v3()] or one of the legacy ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function ** must be called one or more times to evaluate the statement. ** ** The details of the behavior of the sqlite3_step() interface depend ** on whether the statement was prepared using the newer "vX" interfaces ** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()], ** [sqlite3_prepare16_v2()] or the older legacy ** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the ** new "vX" interface is recommended for new applications but the legacy ** interface will continue to be supported. ** ** ^In the legacy interface, the return value will be either [SQLITE_BUSY], ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE]. ** ^With the "v2" interface, any of the other [result codes] or ** [extended result codes] might be returned as well. ** |
| ︙ | ︙ | |||
4120 4121 4122 4123 4124 4125 4126 | ** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step() ** API always returns a generic error code, [SQLITE_ERROR], following any ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the ** specific [error codes] that better describes the error. ** We admit that this is a goofy design. The problem has been fixed ** with the "v2" interface. If you prepare all of your SQL statements | > | | | 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 | ** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step() ** API always returns a generic error code, [SQLITE_ERROR], following any ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the ** specific [error codes] that better describes the error. ** We admit that this is a goofy design. The problem has been fixed ** with the "v2" interface. If you prepare all of your SQL statements ** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()] ** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, ** then the more specific [error codes] are returned directly ** by sqlite3_step(). The use of the "vX" interfaces is recommended. */ SQLITE_API int sqlite3_step(sqlite3_stmt*); /* ** CAPI3REF: Number of columns in a result set ** METHOD: sqlite3_stmt ** |
| ︙ | ︙ | |||
4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 |
#endif
#define SQLITE3_TEXT 3
/*
** CAPI3REF: Result Values From A Query
** KEYWORDS: {column access functions}
** METHOD: sqlite3_stmt
**
** ^These routines return information about a single column of the current
** result row of a query. ^In every case the first argument is a pointer
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
** that was returned from [sqlite3_prepare_v2()] or one of its variants)
** and the second argument is the index of the column for which information
** should be returned. ^The leftmost column of the result set has the index 0.
| > > > > > > > > > > > > > > > > > > > > > > | 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 |
#endif
#define SQLITE3_TEXT 3
/*
** CAPI3REF: Result Values From A Query
** KEYWORDS: {column access functions}
** METHOD: sqlite3_stmt
**
** <b>Summary:</b>
** <blockquote><table border=0 cellpadding=0 cellspacing=0>
** <tr><td><b>sqlite3_column_blob</b><td>→<td>BLOB result
** <tr><td><b>sqlite3_column_double</b><td>→<td>REAL result
** <tr><td><b>sqlite3_column_int</b><td>→<td>32-bit INTEGER result
** <tr><td><b>sqlite3_column_int64</b><td>→<td>64-bit INTEGER result
** <tr><td><b>sqlite3_column_text</b><td>→<td>UTF-8 TEXT result
** <tr><td><b>sqlite3_column_text16</b><td>→<td>UTF-16 TEXT result
** <tr><td><b>sqlite3_column_value</b><td>→<td>The result as an
** [sqlite3_value|unprotected sqlite3_value] object.
** <tr><td> <td> <td>
** <tr><td><b>sqlite3_column_bytes</b><td>→<td>Size of a BLOB
** or a UTF-8 TEXT result in bytes
** <tr><td><b>sqlite3_column_bytes16 </b>
** <td>→ <td>Size of UTF-16
** TEXT in bytes
** <tr><td><b>sqlite3_column_type</b><td>→<td>Default
** datatype of the result
** </table></blockquote>
**
** <b>Details:</b>
**
** ^These routines return information about a single column of the current
** result row of a query. ^In every case the first argument is a pointer
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
** that was returned from [sqlite3_prepare_v2()] or one of its variants)
** and the second argument is the index of the column for which information
** should be returned. ^The leftmost column of the result set has the index 0.
|
| ︙ | ︙ | |||
4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 | ** If any of these routines are called after [sqlite3_reset()] or ** [sqlite3_finalize()] or after [sqlite3_step()] has returned ** something other than [SQLITE_ROW], the results are undefined. ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] ** are called from a different thread while any of these routines ** are pending, then the results are undefined. ** ** ^The sqlite3_column_type() routine returns the ** [SQLITE_INTEGER | datatype code] for the initial data type ** of the result column. ^The returned value is one of [SQLITE_INTEGER], | > > > > > > | > > | | | > > > > > | 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 | ** If any of these routines are called after [sqlite3_reset()] or ** [sqlite3_finalize()] or after [sqlite3_step()] has returned ** something other than [SQLITE_ROW], the results are undefined. ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] ** are called from a different thread while any of these routines ** are pending, then the results are undefined. ** ** The first six interfaces (_blob, _double, _int, _int64, _text, and _text16) ** each return the value of a result column in a specific data format. If ** the result column is not initially in the requested format (for example, ** if the query returns an integer but the sqlite3_column_text() interface ** is used to extract the value) then an automatic type conversion is performed. ** ** ^The sqlite3_column_type() routine returns the ** [SQLITE_INTEGER | datatype code] for the initial data type ** of the result column. ^The returned value is one of [SQLITE_INTEGER], ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. ** The return value of sqlite3_column_type() can be used to decide which ** of the first six interface should be used to extract the column value. ** The value returned by sqlite3_column_type() is only meaningful if no ** automatic type conversions have occurred for the value in question. ** After a type conversion, the result of calling sqlite3_column_type() ** is undefined, though harmless. Future ** versions of SQLite may change the behavior of sqlite3_column_type() ** following a type conversion. ** ** If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes() ** or sqlite3_column_bytes16() interfaces can be used to determine the size ** of that BLOB or string. ** ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() ** routine returns the number of bytes in that BLOB or string. ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts ** the string to UTF-8 and then returns the number of bytes. ** ^If the result is a numeric value then sqlite3_column_bytes() uses ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns |
| ︙ | ︙ | |||
4252 4253 4254 4255 4256 4257 4258 4259 | ** [unprotected sqlite3_value] object. In a multithreaded environment, ** an unprotected sqlite3_value object may only be used safely with ** [sqlite3_bind_value()] and [sqlite3_result_value()]. ** If the [unprotected sqlite3_value] object returned by ** [sqlite3_column_value()] is used in any other way, including calls ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], ** or [sqlite3_value_bytes()], the behavior is not threadsafe. ** | > > > > | | | 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 | ** [unprotected sqlite3_value] object. In a multithreaded environment, ** an unprotected sqlite3_value object may only be used safely with ** [sqlite3_bind_value()] and [sqlite3_result_value()]. ** If the [unprotected sqlite3_value] object returned by ** [sqlite3_column_value()] is used in any other way, including calls ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], ** or [sqlite3_value_bytes()], the behavior is not threadsafe. ** Hence, the sqlite3_column_value() interface ** is normally only useful within the implementation of ** [application-defined SQL functions] or [virtual tables], not within ** top-level application code. ** ** The these routines may attempt to convert the datatype of the result. ** ^For example, if the internal representation is FLOAT and a text result ** is requested, [sqlite3_snprintf()] is used internally to perform the ** conversion automatically. ^(The following table details the conversions ** that are applied: ** ** <blockquote> ** <table border="1"> ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion |
| ︙ | ︙ | |||
4326 4327 4328 4329 4330 4331 4332 | ** to sqlite3_column_text() or sqlite3_column_blob() with calls to ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() ** with calls to sqlite3_column_bytes(). ** ** ^The pointers returned are valid until a type conversion occurs as ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or ** [sqlite3_finalize()] is called. ^The memory space used to hold strings | | < < < > > > | 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 | ** to sqlite3_column_text() or sqlite3_column_blob() with calls to ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() ** with calls to sqlite3_column_bytes(). ** ** ^The pointers returned are valid until a type conversion occurs as ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or ** [sqlite3_finalize()] is called. ^The memory space used to hold strings ** and BLOBs is freed automatically. Do not pass the pointers returned ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into ** [sqlite3_free()]. ** ** ^(If a memory allocation error occurs during the evaluation of any ** of these routines, a default value is returned. The default value ** is either the integer 0, the floating point number 0.0, or a NULL ** pointer. Subsequent calls to [sqlite3_errcode()] will return ** [SQLITE_NOMEM].)^ */ SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); /* ** CAPI3REF: Destroy A Prepared Statement Object ** DESTRUCTOR: sqlite3_stmt ** ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. ** ^If the most recent evaluation of the statement encountered no errors |
| ︙ | ︙ | |||
4579 4580 4581 4582 4583 4584 4585 |
void*,sqlite3_int64);
#endif
/*
** CAPI3REF: Obtaining SQL Values
** METHOD: sqlite3_value
**
| | | > > > > > > > | > > > > > > > > > > > > > < < < < > > > | > | < | > > > > > > > > > > > > > > > > > > < < > > > < < < < | 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 |
void*,sqlite3_int64);
#endif
/*
** CAPI3REF: Obtaining SQL Values
** METHOD: sqlite3_value
**
** <b>Summary:</b>
** <blockquote><table border=0 cellpadding=0 cellspacing=0>
** <tr><td><b>sqlite3_value_blob</b><td>→<td>BLOB value
** <tr><td><b>sqlite3_value_double</b><td>→<td>REAL value
** <tr><td><b>sqlite3_value_int</b><td>→<td>32-bit INTEGER value
** <tr><td><b>sqlite3_value_int64</b><td>→<td>64-bit INTEGER value
** <tr><td><b>sqlite3_value_pointer</b><td>→<td>Pointer value
** <tr><td><b>sqlite3_value_text</b><td>→<td>UTF-8 TEXT value
** <tr><td><b>sqlite3_value_text16</b><td>→<td>UTF-16 TEXT value in
** the native byteorder
** <tr><td><b>sqlite3_value_text16be</b><td>→<td>UTF-16be TEXT value
** <tr><td><b>sqlite3_value_text16le</b><td>→<td>UTF-16le TEXT value
** <tr><td> <td> <td>
** <tr><td><b>sqlite3_value_bytes</b><td>→<td>Size of a BLOB
** or a UTF-8 TEXT in bytes
** <tr><td><b>sqlite3_value_bytes16 </b>
** <td>→ <td>Size of UTF-16
** TEXT in bytes
** <tr><td><b>sqlite3_value_type</b><td>→<td>Default
** datatype of the value
** <tr><td><b>sqlite3_value_numeric_type </b>
** <td>→ <td>Best numeric datatype of the value
** </table></blockquote>
**
** <b>Details:</b>
**
** These routines extract type, size, and content information from
** [protected sqlite3_value] objects. Protected sqlite3_value objects
** are used to pass parameter information into implementation of
** [application-defined SQL functions] and [virtual tables].
**
** These routines work only with [protected sqlite3_value] objects.
** Any attempt to use these routines on an [unprotected sqlite3_value]
** is not threadsafe.
**
** ^These routines work just like the corresponding [column access functions]
** except that these routines take a single [protected sqlite3_value] object
** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
**
** ^The sqlite3_value_text16() interface extracts a UTF-16 string
** in the native byte-order of the host machine. ^The
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
** extract UTF-16 strings as big-endian and little-endian respectively.
**
** ^If [sqlite3_value] object V was initialized
** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)]
** and if X and Y are strings that compare equal according to strcmp(X,Y),
** then sqlite3_value_pointer(V,Y) will return the pointer P. ^Otherwise,
** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer()
** routine is part of the [pointer passing interface] added for SQLite 3.20.0.
**
** ^(The sqlite3_value_type(V) interface returns the
** [SQLITE_INTEGER | datatype code] for the initial datatype of the
** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
** Other interfaces might change the datatype for an sqlite3_value object.
** For example, if the datatype is initially SQLITE_INTEGER and
** sqlite3_value_text(V) is called to extract a text value for that
** integer, then subsequent calls to sqlite3_value_type(V) might return
** SQLITE_TEXT. Whether or not a persistent internal datatype conversion
** occurs is undefined and may change from one release of SQLite to the next.
**
** ^(The sqlite3_value_numeric_type() interface attempts to apply
** numeric affinity to the value. This means that an attempt is
** made to convert the value to an integer or floating point. If
** such a conversion is possible without loss of information (in other
** words, if the value is a string that looks like a number)
** then the conversion is performed. Otherwise no conversion occurs.
** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
**
** Please pay particular attention to the fact that the pointer returned
** from [sqlite3_value_blob()], [sqlite3_value_text()], or
** [sqlite3_value_text16()] can be invalidated by a subsequent call to
** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
** or [sqlite3_value_text16()].
**
** These routines must be called from the same thread as
** the SQL function that supplied the [sqlite3_value*] parameters.
*/
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
SQLITE_API double sqlite3_value_double(sqlite3_value*);
SQLITE_API int sqlite3_value_int(sqlite3_value*);
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
SQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*);
SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
SQLITE_API int sqlite3_value_type(sqlite3_value*);
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
/*
** CAPI3REF: Finding The Subtype Of SQL Values
** METHOD: sqlite3_value
**
** The sqlite3_value_subtype(V) function returns the subtype for
** an [application-defined SQL function] argument V. The subtype
** information can be used to pass a limited amount of context from
** one SQL function to another. Use the [sqlite3_result_subtype()]
** routine to set the subtype for the return value of an SQL function.
*/
SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
/*
** CAPI3REF: Copy And Free SQL Values
** METHOD: sqlite3_value
**
|
| ︙ | ︙ | |||
4754 4755 4756 4757 4758 4759 4760 | ** of where this might be useful is in a regular-expression matching ** function. The compiled version of the regular expression can be stored as ** metadata associated with the pattern string. ** Then as long as the pattern string remains the same, ** the compiled regular expression can be reused on multiple ** invocations of the same function. ** | | | | > | | 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 | ** of where this might be useful is in a regular-expression matching ** function. The compiled version of the regular expression can be stored as ** metadata associated with the pattern string. ** Then as long as the pattern string remains the same, ** the compiled regular expression can be reused on multiple ** invocations of the same function. ** ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument ** value to the application-defined function. ^N is zero for the left-most ** function argument. ^If there is no metadata ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface ** returns a NULL pointer. ** ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th ** argument of the application-defined function. ^Subsequent ** calls to sqlite3_get_auxdata(C,N) return P from the most recent ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or ** NULL if the metadata has been discarded. |
| ︙ | ︙ | |||
4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 | ** should be called near the end of the function implementation and the ** function implementation should not make any use of P after ** sqlite3_set_auxdata() has been called. ** ** ^(In practice, metadata is preserved between function calls for ** function parameters that are compile-time constants, including literal ** values and [parameters] and expressions composed from the same.)^ ** ** These routines must be called from the same thread in which ** the SQL function is running. */ SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); | > > > > | 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 | ** should be called near the end of the function implementation and the ** function implementation should not make any use of P after ** sqlite3_set_auxdata() has been called. ** ** ^(In practice, metadata is preserved between function calls for ** function parameters that are compile-time constants, including literal ** values and [parameters] and expressions composed from the same.)^ ** ** The value of the N parameter to these interfaces should be non-negative. ** Future enhancements may make use of negative N values to define new ** kinds of function caching behavior. ** ** These routines must be called from the same thread in which ** the SQL function is running. */ SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| ︙ | ︙ | |||
4911 4912 4913 4914 4915 4916 4917 | ** ^If the 4th parameter to the sqlite3_result_text* interfaces or to ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite ** assumes that the text or BLOB result is in constant space and does not ** copy the content of the parameter nor call a destructor on the content ** when it has finished using that result. ** ^If the 4th parameter to the sqlite3_result_text* interfaces ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT | | > > > > > > > > > > > | 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 |
** ^If the 4th parameter to the sqlite3_result_text* interfaces or to
** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
** assumes that the text or BLOB result is in constant space and does not
** copy the content of the parameter nor call a destructor on the content
** when it has finished using that result.
** ^If the 4th parameter to the sqlite3_result_text* interfaces
** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
** then SQLite makes a copy of the result into space obtained
** from [sqlite3_malloc()] before it returns.
**
** ^The sqlite3_result_value() interface sets the result of
** the application-defined function to be a copy of the
** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
** so that the [sqlite3_value] specified in the parameter may change or
** be deallocated after sqlite3_result_value() returns without harm.
** ^A [protected sqlite3_value] object may always be used where an
** [unprotected sqlite3_value] object is required, so either
** kind of [sqlite3_value] object can be used with this interface.
**
** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an
** SQL NULL value, just like [sqlite3_result_null(C)], except that it
** also associates the host-language pointer P or type T with that
** NULL value such that the pointer can be retrieved within an
** [application-defined SQL function] using [sqlite3_value_pointer()].
** ^If the D parameter is not NULL, then it is a pointer to a destructor
** for the P parameter. ^SQLite invokes D with P as its only argument
** when SQLite is finished with P. The T parameter should be a static
** string and preferably a string literal. The sqlite3_result_pointer()
** routine is part of the [pointer passing interface] added for SQLite 3.20.0.
**
** If these routines are called from within the different thread
** than the one containing the application-defined function that received
** the [sqlite3_context] pointer, the results are undefined.
*/
SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
sqlite3_uint64,void(*)(void*));
|
| ︙ | ︙ | |||
4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 |
SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
void(*)(void*), unsigned char encoding);
SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
/*
** CAPI3REF: Setting The Subtype Of An SQL Function
** METHOD: sqlite3_context
| > | 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 |
SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
void(*)(void*), unsigned char encoding);
SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*));
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
/*
** CAPI3REF: Setting The Subtype Of An SQL Function
** METHOD: sqlite3_context
|
| ︙ | ︙ | |||
5606 5607 5608 5609 5610 5611 5612 | ** interface returns SQLITE_OK and fills in the non-NULL pointers in ** the final five arguments with appropriate values if the specified ** column exists. ^The sqlite3_table_column_metadata() interface returns ** SQLITE_ERROR and if the specified column does not exist. ** ^If the column-name parameter to sqlite3_table_column_metadata() is a ** NULL pointer, then this routine simply checks for the existence of the ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it | | > > | 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 | ** interface returns SQLITE_OK and fills in the non-NULL pointers in ** the final five arguments with appropriate values if the specified ** column exists. ^The sqlite3_table_column_metadata() interface returns ** SQLITE_ERROR and if the specified column does not exist. ** ^If the column-name parameter to sqlite3_table_column_metadata() is a ** NULL pointer, then this routine simply checks for the existence of the ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it ** does not. If the table name parameter T in a call to ** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is ** undefined behavior. ** ** ^The column is identified by the second, third and fourth parameters to ** this function. ^(The second parameter is either the name of the database ** (i.e. "main", "temp", or an attached database) containing the specified ** table or NULL.)^ ^If it is NULL, then all attached databases are searched ** for the table using the same algorithm used by the database engine to ** resolve unqualified table references. |
| ︙ | ︙ | |||
6016 6017 6018 6019 6020 6021 6022 | ** CAPI3REF: Virtual Table Constraint Operator Codes ** ** These macros defined the allowed values for the ** [sqlite3_index_info].aConstraint[].op field. Each value represents ** an operator that is part of a constraint term in the wHERE clause of ** a query that uses a [virtual table]. */ | | | | | | | | | | > > > > > | 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 | ** CAPI3REF: Virtual Table Constraint Operator Codes ** ** These macros defined the allowed values for the ** [sqlite3_index_info].aConstraint[].op field. Each value represents ** an operator that is part of a constraint term in the wHERE clause of ** a query that uses a [virtual table]. */ #define SQLITE_INDEX_CONSTRAINT_EQ 2 #define SQLITE_INDEX_CONSTRAINT_GT 4 #define SQLITE_INDEX_CONSTRAINT_LE 8 #define SQLITE_INDEX_CONSTRAINT_LT 16 #define SQLITE_INDEX_CONSTRAINT_GE 32 #define SQLITE_INDEX_CONSTRAINT_MATCH 64 #define SQLITE_INDEX_CONSTRAINT_LIKE 65 #define SQLITE_INDEX_CONSTRAINT_GLOB 66 #define SQLITE_INDEX_CONSTRAINT_REGEXP 67 #define SQLITE_INDEX_CONSTRAINT_NE 68 #define SQLITE_INDEX_CONSTRAINT_ISNOT 69 #define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70 #define SQLITE_INDEX_CONSTRAINT_ISNULL 71 #define SQLITE_INDEX_CONSTRAINT_IS 72 /* ** CAPI3REF: Register A Virtual Table Implementation ** METHOD: sqlite3 ** ** ^These routines are used to register a new [virtual table module] name. ** ^Module names must be registered before |
| ︙ | ︙ | |||
6776 6777 6778 6779 6780 6781 6782 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 #define SQLITE_TESTCTRL_PENDING_BYTE 11 #define SQLITE_TESTCTRL_ASSERT 12 #define SQLITE_TESTCTRL_ALWAYS 13 #define SQLITE_TESTCTRL_RESERVE 14 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 #define SQLITE_TESTCTRL_ISKEYWORD 16 | | | 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 #define SQLITE_TESTCTRL_PENDING_BYTE 11 #define SQLITE_TESTCTRL_ASSERT 12 #define SQLITE_TESTCTRL_ALWAYS 13 #define SQLITE_TESTCTRL_RESERVE 14 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 #define SQLITE_TESTCTRL_ISKEYWORD 16 #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */ #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 #define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */ #define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD 19 #define SQLITE_TESTCTRL_NEVER_CORRUPT 20 #define SQLITE_TESTCTRL_VDBE_COVERAGE 21 #define SQLITE_TESTCTRL_BYTEORDER 22 #define SQLITE_TESTCTRL_ISINIT 23 |
| ︙ | ︙ | |||
6835 6836 6837 6838 6839 6840 6841 | ** that can be returned by [sqlite3_status()]. ** ** <dl> ** [[SQLITE_STATUS_MEMORY_USED]] ^(<dt>SQLITE_STATUS_MEMORY_USED</dt> ** <dd>This parameter is the current amount of memory checked out ** using [sqlite3_malloc()], either directly or indirectly. The ** figure includes calls made to [sqlite3_malloc()] by the application | | < | 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 | ** that can be returned by [sqlite3_status()]. ** ** <dl> ** [[SQLITE_STATUS_MEMORY_USED]] ^(<dt>SQLITE_STATUS_MEMORY_USED</dt> ** <dd>This parameter is the current amount of memory checked out ** using [sqlite3_malloc()], either directly or indirectly. The ** figure includes calls made to [sqlite3_malloc()] by the application ** and internal memory usage by the SQLite library. Auxiliary page-cache ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in ** this parameter. The amount returned is the sum of the allocation ** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^ ** ** [[SQLITE_STATUS_MALLOC_SIZE]] ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt> ** <dd>This parameter records the largest memory allocation request ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their |
| ︙ | ︙ | |||
6874 6875 6876 6877 6878 6879 6880 | ** ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> ** <dd>This parameter records the largest memory allocation request ** handed to [pagecache memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.</dd>)^ ** | | < < < < < | < < < < < < < | | | < < < | | | | 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 | ** ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> ** <dd>This parameter records the largest memory allocation request ** handed to [pagecache memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.</dd>)^ ** ** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt> ** <dd>No longer used.</dd> ** ** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt> ** <dd>No longer used.</dd> ** ** [[SQLITE_STATUS_SCRATCH_SIZE]] <dt>SQLITE_STATUS_SCRATCH_SIZE</dt> ** <dd>No longer used.</dd> ** ** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt> ** <dd>The *pHighwater parameter records the deepest parser stack. ** The *pCurrent value is undefined. The *pHighwater value is only ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^ ** </dl> ** ** New status parameters may be added from time to time. */ #define SQLITE_STATUS_MEMORY_USED 0 #define SQLITE_STATUS_PAGECACHE_USED 1 #define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 #define SQLITE_STATUS_SCRATCH_USED 3 /* NOT USED */ #define SQLITE_STATUS_SCRATCH_OVERFLOW 4 /* NOT USED */ #define SQLITE_STATUS_MALLOC_SIZE 5 #define SQLITE_STATUS_PARSER_STACK 6 #define SQLITE_STATUS_PAGECACHE_SIZE 7 #define SQLITE_STATUS_SCRATCH_SIZE 8 /* NOT USED */ #define SQLITE_STATUS_MALLOC_COUNT 9 /* ** CAPI3REF: Database Connection Status ** METHOD: sqlite3 ** ** ^This interface is used to retrieve runtime status information |
| ︙ | ︙ | |||
7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 | ** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt> ** <dd>^This is the number of virtual machine operations executed ** by the prepared statement if that number is less than or equal ** to 2147483647. The number of virtual machine operations can be ** used as a proxy for the total work done by the prepared statement. ** If the number of virtual machine operations exceeds 2147483647 ** then the value returned by this statement status code is undefined. ** </dd> ** </dl> */ #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 #define SQLITE_STMTSTATUS_SORT 2 #define SQLITE_STMTSTATUS_AUTOINDEX 3 #define SQLITE_STMTSTATUS_VM_STEP 4 /* ** CAPI3REF: Custom Page Cache Object ** ** The sqlite3_pcache type is opaque. It is implemented by ** the pluggable module. The SQLite core has no knowledge of ** its size or internal structure and never deals with the | > > > > > > > > > > > > > > > > > > > > > | 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 | ** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt> ** <dd>^This is the number of virtual machine operations executed ** by the prepared statement if that number is less than or equal ** to 2147483647. The number of virtual machine operations can be ** used as a proxy for the total work done by the prepared statement. ** If the number of virtual machine operations exceeds 2147483647 ** then the value returned by this statement status code is undefined. ** ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt> ** <dd>^This is the number of times that the prepare statement has been ** automatically regenerated due to schema changes or change to ** [bound parameters] that might affect the query plan. ** ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt> ** <dd>^This is the number of times that the prepared statement has ** been run. A single "run" for the purposes of this counter is one ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()]. ** The counter is incremented on the first [sqlite3_step()] call of each ** cycle. ** ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt> ** <dd>^This is the approximate number of bytes of heap memory ** used to store the prepared statement. ^This value is not actually ** a counter, and so the resetFlg parameter to sqlite3_stmt_status() ** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED. ** </dd> ** </dl> */ #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 #define SQLITE_STMTSTATUS_SORT 2 #define SQLITE_STMTSTATUS_AUTOINDEX 3 #define SQLITE_STMTSTATUS_VM_STEP 4 #define SQLITE_STMTSTATUS_REPREPARE 5 #define SQLITE_STMTSTATUS_RUN 6 #define SQLITE_STMTSTATUS_MEMUSED 99 /* ** CAPI3REF: Custom Page Cache Object ** ** The sqlite3_pcache type is opaque. It is implemented by ** the pluggable module. The SQLite core has no knowledge of ** its size or internal structure and never deals with the |
| ︙ | ︙ | |||
9382 9383 9384 9385 9386 9387 9388 | ** Any number of calls to add() and output() may be made between the calls to ** new() and delete(), and in any order. ** ** As well as the regular sqlite3changegroup_add() and ** sqlite3changegroup_output() functions, also available are the streaming ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm(). */ | | | 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 | ** Any number of calls to add() and output() may be made between the calls to ** new() and delete(), and in any order. ** ** As well as the regular sqlite3changegroup_add() and ** sqlite3changegroup_output() functions, also available are the streaming ** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm(). */ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); /* ** CAPI3REF: Add A Changeset To A Changegroup ** ** Add all changes within the changeset (or patchset) in buffer pData (size ** nData bytes) to the changegroup. ** |
| ︙ | ︙ | |||
9459 9460 9461 9462 9463 9464 9465 | ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is ** returned. Or, if an out-of-memory condition occurs during processing, this ** function returns SQLITE_NOMEM. In all cases, if an error occurs the ** final contents of the changegroup is undefined. ** ** If no error occurs, SQLITE_OK is returned. */ | | | 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 | ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is ** returned. Or, if an out-of-memory condition occurs during processing, this ** function returns SQLITE_NOMEM. In all cases, if an error occurs the ** final contents of the changegroup is undefined. ** ** If no error occurs, SQLITE_OK is returned. */ SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); /* ** CAPI3REF: Obtain A Composite Changeset From A Changegroup ** ** Obtain a buffer containing a changeset (or patchset) representing the ** current contents of the changegroup. If the inputs to the changegroup ** were themselves changesets, the output is a changeset. Or, if the |
| ︙ | ︙ | |||
9485 9486 9487 9488 9489 9490 9491 | ** If an error occurs, an SQLite error code is returned and the output ** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK ** is returned and the output variables are set to the size of and a ** pointer to the output buffer, respectively. In this case it is the ** responsibility of the caller to eventually free the buffer using a ** call to sqlite3_free(). */ | | | | 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 | ** If an error occurs, an SQLite error code is returned and the output ** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK ** is returned and the output variables are set to the size of and a ** pointer to the output buffer, respectively. In this case it is the ** responsibility of the caller to eventually free the buffer using a ** call to sqlite3_free(). */ SQLITE_API int sqlite3changegroup_output( sqlite3_changegroup*, int *pnData, /* OUT: Size of output buffer in bytes */ void **ppData /* OUT: Pointer to output buffer */ ); /* ** CAPI3REF: Delete A Changegroup Object */ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*); /* ** CAPI3REF: Apply A Changeset To A Database ** ** Apply a changeset to a database. This function attempts to update the ** "main" database attached to handle db with the changes found in the ** changeset passed via the second and third arguments. |
| ︙ | ︙ | |||
9883 9884 9885 9886 9887 9888 9889 | void *pOut ); SQLITE_API int sqlite3session_patchset_strm( sqlite3_session *pSession, int (*xOutput)(void *pOut, const void *pData, int nData), void *pOut ); | | | | 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 |
void *pOut
);
SQLITE_API int sqlite3session_patchset_strm(
sqlite3_session *pSession,
int (*xOutput)(void *pOut, const void *pData, int nData),
void *pOut
);
SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*,
int (*xInput)(void *pIn, void *pData, int *pnData),
void *pIn
);
SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,
int (*xOutput)(void *pOut, const void *pData, int nData),
void *pOut
);
/*
** Make sure we can call this stuff from C++.
|
| ︙ | ︙ |
Changes to src/stash.c.
| ︙ | ︙ | |||
426 427 428 429 430 431 432 | ** ** List all changes sets currently stashed. Show information about ** individual files in each changeset if -v or --verbose is used. ** ** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS? ** fossil stash gshow|gcat ?STASHID? ?DIFF-OPTIONS? ** | | | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | ** ** List all changes sets currently stashed. Show information about ** individual files in each changeset if -v or --verbose is used. ** ** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS? ** fossil stash gshow|gcat ?STASHID? ?DIFF-OPTIONS? ** ** Show the contents of a stash as a diff against its baseline. ** With gshow and gcat, gdiff-command is used instead of internal ** diff logic. ** ** fossil stash pop ** fossil stash apply ?STASHID? ** ** Apply STASHID or the most recently create stash to the current |
| ︙ | ︙ |
Changes to src/stat.c.
| ︙ | ︙ | |||
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
if( g.perm.Admin ){
style_submenu_element("URLs", "urllist");
style_submenu_element("Schema", "repo_schema");
style_submenu_element("Web-Cache", "cachestat");
}
style_submenu_element("Activity Reports", "reports");
style_submenu_element("Hash Collisions", "hash-collisions");
if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
style_submenu_element("Table Sizes", "repo-tabsize");
}
if( g.perm.Admin || g.perm.Setup || db_get_boolean("test_env_enable",0) ){
style_submenu_element("Environment", "test_env");
}
@ <table class="label-value">
| > | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
if( g.perm.Admin ){
style_submenu_element("URLs", "urllist");
style_submenu_element("Schema", "repo_schema");
style_submenu_element("Web-Cache", "cachestat");
}
style_submenu_element("Activity Reports", "reports");
style_submenu_element("Hash Collisions", "hash-collisions");
style_submenu_element("Artifacts", "bloblist");
if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
style_submenu_element("Table Sizes", "repo-tabsize");
}
if( g.perm.Admin || g.perm.Setup || db_get_boolean("test_env_enable",0) ){
style_submenu_element("Environment", "test_env");
}
@ <table class="label-value">
|
| ︙ | ︙ | |||
110 111 112 113 114 115 116 |
db_finalize(&q);
bigSizeName(sizeof(zBuf), zBuf, t);
@ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) total
@ </td></tr>
@ <tr><th>Compression Ratio:</th><td>
if( t/fsize < 5 ){
b = 10;
| | < | > | < | | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
db_finalize(&q);
bigSizeName(sizeof(zBuf), zBuf, t);
@ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) total
@ </td></tr>
@ <tr><th>Compression Ratio:</th><td>
if( t/fsize < 5 ){
b = 10;
a = t/(fsize/10);
}else{
b = 1;
a = t/fsize;
}
@ %d(a):%d(b)
@ </td></tr>
}
if( db_table_exists("repository","unversioned") ){
Stmt q;
char zStored[100];
db_prepare(&q,
"SELECT count(*), sum(sz), sum(length(content))"
" FROM unversioned"
" WHERE length(hash)>1"
);
if( db_step(&q)==SQLITE_ROW && (n = db_column_int(&q,0))>0 ){
sqlite3_int64 iStored, pct;
iStored = db_column_int64(&q,2);
pct = (iStored*100 + fsize/2)/fsize;
approxSizeName(sizeof(zStored), zStored, iStored);
@ <tr><th>Unversioned Files:</th><td>
@ %z(href("%R/uvlist"))%d(n) files</a>,
@ %s(zStored) compressed, %d(pct)%% of total repository space
@ </td></tr>
}
db_finalize(&q);
}
@ <tr><th>Number Of Check-ins:</th><td>
n = db_int(0, "SELECT count(*) FROM event WHERE type='ci' /*scan*/");
@ %d(n)
|
| ︙ | ︙ | |||
176 177 178 179 180 181 182 |
if( p ){
@ <tr><th>Parent Project ID:</th>
@ <td>%h(p) %h(db_get("parent-project-name",""))</td></tr>
}
/* @ <tr><th>Server ID:</th><td>%h(db_get("server-code",""))</td></tr> */
@ <tr><th>Fossil Version:</th><td>
@ %h(MANIFEST_DATE) %h(MANIFEST_VERSION)
| | | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
if( p ){
@ <tr><th>Parent Project ID:</th>
@ <td>%h(p) %h(db_get("parent-project-name",""))</td></tr>
}
/* @ <tr><th>Server ID:</th><td>%h(db_get("server-code",""))</td></tr> */
@ <tr><th>Fossil Version:</th><td>
@ %h(MANIFEST_DATE) %h(MANIFEST_VERSION)
@ (%h(RELEASE_VERSION)) <a href='version?verbose'>(details)</a>
@ </td></tr>
@ <tr><th>SQLite Version:</th><td>%.19s(sqlite3_sourceid())
@ [%.10s(&sqlite3_sourceid()[20])] (%s(sqlite3_libversion()))
@ <a href='version?verbose'>(details)</a></td></tr>
if( g.eHashPolicy!=HPOLICY_AUTO ){
@ <tr><th>Schema Version:</th><td>%h(g.zAuxSchema),
@ %s(hpolicy_name())</td></tr>
}else{
@ <tr><th>Schema Version:</th><td>%h(g.zAuxSchema)</td></tr>
}
@ <tr><th>Repository Rebuilt:</th><td>
|
| ︙ | ︙ | |||
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
** WEBPAGE: urllist
**
** Show ways in which this repository has been accessed
*/
void urllist_page(void){
Stmt q;
int cnt;
login_check_credentials();
if( !g.perm.Admin ){ login_needed(0); return; }
style_header("URLs and Checkouts");
style_adunit_config(ADUNIT_RIGHT_OK);
style_submenu_element("Stat", "stat");
style_submenu_element("Schema", "repo_schema");
@ <div class="section">URLs</div>
@ <table border="0" width='100%%'>
| > > > > > | | > > > > | | > > > > > | | > > > > > > > > > > > > > | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
** WEBPAGE: urllist
**
** Show ways in which this repository has been accessed
*/
void urllist_page(void){
Stmt q;
int cnt;
int showAll = P("all")!=0;
int nOmitted;
sqlite3_int64 iNow;
char *zRemote;
login_check_credentials();
if( !g.perm.Admin ){ login_needed(0); return; }
style_header("URLs and Checkouts");
style_adunit_config(ADUNIT_RIGHT_OK);
style_submenu_element("Stat", "stat");
style_submenu_element("Schema", "repo_schema");
iNow = db_int64(0, "SELECT strftime('%%s','now')");
@ <div class="section">URLs</div>
@ <table border="0" width='100%%'>
db_prepare(&q, "SELECT substr(name,9), datetime(mtime,'unixepoch'), mtime"
" FROM config WHERE name GLOB 'baseurl:*' ORDER BY 3 DESC");
cnt = 0;
nOmitted = 0;
while( db_step(&q)==SQLITE_ROW ){
if( !showAll && db_column_int64(&q,2)<(iNow - 3600*24*30) && cnt>8 ){
nOmitted++;
}else{
@ <tr><td width='100%%'>%h(db_column_text(&q,0))</td>
@ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
}
cnt++;
}
db_finalize(&q);
if( cnt==0 ){
@ <tr><td>(none)</td>
}else if( nOmitted ){
@ <tr><td><a href="urllist?all"><i>Show %d(nOmitted) more...</i></a>
}
@ </table>
@ <div class="section">Checkouts</div>
@ <table border="0" width='100%%'>
db_prepare(&q, "SELECT substr(name,7), datetime(mtime,'unixepoch')"
" FROM config WHERE name GLOB 'ckout:*' ORDER BY 2 DESC");
cnt = 0;
while( db_step(&q)==SQLITE_ROW ){
const char *zPath = db_column_text(&q,0);
if( vfile_top_of_checkout(zPath) ){
@ <tr><td width='100%%'>%h(zPath)</td>
@ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
}
cnt++;
}
db_finalize(&q);
if( cnt==0 ){
@ <tr><td>(none)</td>
}
@ </table>
zRemote = db_text(0, "SELECT value FROM config WHERE name='last-sync-url'");
if( zRemote ){
@ <div class="section">Last Sync URL</div>
if( sqlite3_strlike("http%", zRemote, 0)==0 ){
UrlData x;
url_parse_local(zRemote, URL_OMIT_USER, &x);
@ <p><a href='%h(x.canonical)'>%h(zRemote)</a>
}else{
@ <p>%h(zRemote)</p>
}
@ </div>
}
style_footer();
}
/*
** WEBPAGE: repo_schema
**
** Show the repository schema
|
| ︙ | ︙ | |||
398 399 400 401 402 403 404 |
style_header("Repository Schema");
style_adunit_config(ADUNIT_RIGHT_OK);
style_submenu_element("Stat", "stat");
style_submenu_element("URLs", "urllist");
if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
style_submenu_element("Table Sizes", "repo-tabsize");
}
| | | 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
style_header("Repository Schema");
style_adunit_config(ADUNIT_RIGHT_OK);
style_submenu_element("Stat", "stat");
style_submenu_element("URLs", "urllist");
if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
style_submenu_element("Table Sizes", "repo-tabsize");
}
blob_init(&sql,
"SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL", -1);
if( zArg ){
style_submenu_element("All", "repo_schema");
blob_appendf(&sql, " AND (tbl_name=%Q OR name=%Q)", zArg, zArg);
}
blob_appendf(&sql, " ORDER BY tbl_name, type<>'table', name");
db_prepare(&q, "%s", blob_str(&sql)/*safe-for-%s*/);
|
| ︙ | ︙ |
Changes to src/statrep.c.
| ︙ | ︙ | |||
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
int nAvg = iterations ? (total/iterations) : 0;
cgi_printf("<br /><div>Total events: %d<br />"
"Average per active week: %d</div>",
total, nAvg);
}
output_table_sorting_javascript("statsTable","tnx",-1);
}
/* Report types
*/
#define RPT_BYFILE 1
#define RPT_BYMONTH 2
#define RPT_BYUSER 3
#define RPT_BYWEEK 4
#define RPT_BYWEEKDAY 5
#define RPT_BYYEAR 6
#define RPT_NONE 0 /* None of the above */
/*
** WEBPAGE: reports
**
** Shows activity reports for the repository.
**
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 |
int nAvg = iterations ? (total/iterations) : 0;
cgi_printf("<br /><div>Total events: %d<br />"
"Average per active week: %d</div>",
total, nAvg);
}
output_table_sorting_javascript("statsTable","tnx",-1);
}
/*
** Generate a report that shows the most recent change for each user.
*/
static void stats_report_last_change(void){
Stmt s;
double rNow;
char *zBaseUrl;
stats_report_init_view();
@ <h1>Event Summary
@ (%s(stats_report_label_for_type())) by User</h1>
@ <table border=1 class='statistics-report-table-events'
@ cellpadding=2 cellspacing=0 id='lastchng'>
@ <thead><tr>
@ <th>User<th>Total Changes<th>Last Change</tr></thead>
@ <tbody>
zBaseUrl = mprintf("%R/timeline?y=%t&u=", PD("type","ci"));
db_prepare(&s,
"SELECT coalesce(euser,user),"
" count(*),"
" max(mtime)"
" FROM v_reports"
" GROUP BY 1"
" ORDER BY 3 DESC"
);
rNow = db_double(0.0, "SELECT julianday('now');");
while( db_step(&s)==SQLITE_ROW ){
const char *zUser = db_column_text(&s, 0);
int cnt = db_column_int(&s, 1);
double rMTime = db_column_double(&s,2);
char *zAge = human_readable_age(rNow - rMTime);
@ <tr>
@ <td><a href='%s(zBaseUrl)%t(zUser)'>%h(zUser)</a>
@ <td>%d(cnt)
@ <td data-sortkey='%f(rMTime)' style='white-space:nowrap'>%s(zAge?zAge:"")
@ </tr>
fossil_free(zAge);
}
@ </tbody></table>
db_finalize(&s);
output_table_sorting_javascript("lastchng","tNK",3);
}
/* Report types
*/
#define RPT_BYFILE 1
#define RPT_BYMONTH 2
#define RPT_BYUSER 3
#define RPT_BYWEEK 4
#define RPT_BYWEEKDAY 5
#define RPT_BYYEAR 6
#define RPT_LASTCHNG 7 /* Last change made for each user */
#define RPT_NONE 0 /* None of the above */
/*
** WEBPAGE: reports
**
** Shows activity reports for the repository.
**
|
| ︙ | ︙ | |||
680 681 682 683 684 685 686 687 688 689 690 |
const char *azView[16]; /* Drop-down menu of view types */
static const struct {
const char *zName; /* Name of view= screen type */
const char *zVal; /* Value of view= query parameter */
int eType; /* Corresponding RPT_* define */
} aViewType[] = {
{ "File Changes","byfile", RPT_BYFILE },
{ "By Month", "bymonth", RPT_BYMONTH },
{ "By User", "byuser", RPT_BYUSER },
{ "By Week", "byweek", RPT_BYWEEK },
{ "By Weekday", "byweekday", RPT_BYWEEKDAY },
| > | | 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
const char *azView[16]; /* Drop-down menu of view types */
static const struct {
const char *zName; /* Name of view= screen type */
const char *zVal; /* Value of view= query parameter */
int eType; /* Corresponding RPT_* define */
} aViewType[] = {
{ "File Changes","byfile", RPT_BYFILE },
{ "Last Change", "lastchng", RPT_LASTCHNG },
{ "By Month", "bymonth", RPT_BYMONTH },
{ "By User", "byuser", RPT_BYUSER },
{ "By Week", "byweek", RPT_BYWEEK },
{ "By Weekday", "byweekday", RPT_BYWEEKDAY },
{ "By Year", "byyear", RPT_BYYEAR },
};
static const char *const azType[] = {
"a", "All Changes",
"ci", "Check-ins",
"g", "Tags",
"e", "Tech Notes",
"t", "Tickets",
|
| ︙ | ︙ | |||
720 721 722 723 724 725 726 |
azView[nView++] = aViewType[i].zVal;
azView[nView++] = aViewType[i].zName;
}
if( eType!=RPT_BYFILE ){
style_submenu_multichoice("type", count(azType)/2, azType, 0);
}
style_submenu_multichoice("view", nView/2, azView, 0);
| | | 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 |
azView[nView++] = aViewType[i].zVal;
azView[nView++] = aViewType[i].zName;
}
if( eType!=RPT_BYFILE ){
style_submenu_multichoice("type", count(azType)/2, azType, 0);
}
style_submenu_multichoice("view", nView/2, azView, 0);
if( eType!=RPT_BYUSER && eType!=RPT_LASTCHNG ){
style_submenu_sql("user","User:",
"SELECT '', 'All Users' UNION ALL "
"SELECT x, x FROM ("
" SELECT DISTINCT trim(coalesce(euser,user)) AS x FROM event %s"
" ORDER BY 1 COLLATE nocase) WHERE x!=''",
eType==RPT_BYFILE ? "WHERE type='ci'" : ""
);
|
| ︙ | ︙ | |||
752 753 754 755 756 757 758 759 760 761 |
break;
case RPT_BYWEEKDAY:
stats_report_day_of_week(zUserName);
break;
case RPT_BYFILE:
stats_report_by_file(zUserName);
break;
}
style_footer();
}
| > > > | 799 800 801 802 803 804 805 806 807 808 809 810 811 |
break;
case RPT_BYWEEKDAY:
stats_report_day_of_week(zUserName);
break;
case RPT_BYFILE:
stats_report_by_file(zUserName);
break;
case RPT_LASTCHNG:
stats_report_last_change();
break;
}
style_footer();
}
|
Changes to src/style.c.
| ︙ | ︙ | |||
42 43 44 45 46 47 48 |
*/
static struct Submenu {
const char *zLabel; /* Button label */
const char *zLink; /* Jump to this link when button is pressed */
} aSubmenu[30];
static int nSubmenu = 0; /* Number of buttons */
static struct SubmenuCtrl {
| | | | | | | | > | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
*/
static struct Submenu {
const char *zLabel; /* Button label */
const char *zLink; /* Jump to this link when button is pressed */
} aSubmenu[30];
static int nSubmenu = 0; /* Number of buttons */
static struct SubmenuCtrl {
const char *zName; /* Form query parameter */
const char *zLabel; /* Label. Might be NULL for FF_MULTI */
unsigned char eType; /* FF_ENTRY, FF_MULTI, FF_BINARY */
unsigned char isDisabled; /* True if this control is grayed out */
short int iSize; /* Width for FF_ENTRY. Count for FF_MULTI */
const char *const *azChoice; /* value/display pairs for FF_MULTI */
const char *zFalse; /* FF_BINARY label when false */
const char *zJS; /* Javascript to run on toggle */
} aSubmenuCtrl[20];
static int nSubmenuCtrl = 0;
#define FF_ENTRY 1
#define FF_MULTI 2
#define FF_BINARY 3
#define FF_CHECKBOX 4
|
| ︙ | ︙ | |||
258 259 260 261 262 263 264 | aSubmenuCtrl[nSubmenuCtrl].isDisabled = isDisabled; aSubmenuCtrl[nSubmenuCtrl].eType = FF_ENTRY; nSubmenuCtrl++; } void style_submenu_checkbox( const char *zName, /* Query parameter name */ const char *zLabel, /* Label to display after the checkbox */ | | > > | 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
aSubmenuCtrl[nSubmenuCtrl].isDisabled = isDisabled;
aSubmenuCtrl[nSubmenuCtrl].eType = FF_ENTRY;
nSubmenuCtrl++;
}
void style_submenu_checkbox(
const char *zName, /* Query parameter name */
const char *zLabel, /* Label to display after the checkbox */
int isDisabled, /* True if disabled */
const char *zJS /* Optional javascript to run on toggle */
){
assert( nSubmenuCtrl < count(aSubmenuCtrl) );
aSubmenuCtrl[nSubmenuCtrl].zName = zName;
aSubmenuCtrl[nSubmenuCtrl].zLabel = zLabel;
aSubmenuCtrl[nSubmenuCtrl].isDisabled = isDisabled;
aSubmenuCtrl[nSubmenuCtrl].zJS = zJS;
aSubmenuCtrl[nSubmenuCtrl].eType = FF_CHECKBOX;
nSubmenuCtrl++;
}
void style_submenu_binary(
const char *zName, /* Query parameter name */
const char *zTrue, /* Label to show when parameter is true */
const char *zFalse, /* Label to show when the parameter is false */
|
| ︙ | ︙ | |||
481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
** The *pAdFlag value might be set to ADUNIT_RIGHT_OK if this is
** a right-hand vertical ad.
*/
static const char *style_adunit_text(unsigned int *pAdFlag){
const char *zAd = 0;
*pAdFlag = 0;
if( adUnitFlags & ADUNIT_OFF ) return 0; /* Disallow ads on this page */
if( g.perm.Admin && db_get_boolean("adunit-omit-if-admin",0) ){
return 0;
}
if( !login_is_nobody()
&& fossil_strcmp(g.zLogin,"anonymous")!=0
&& db_get_boolean("adunit-omit-if-user",0)
){
| > | 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
** The *pAdFlag value might be set to ADUNIT_RIGHT_OK if this is
** a right-hand vertical ad.
*/
static const char *style_adunit_text(unsigned int *pAdFlag){
const char *zAd = 0;
*pAdFlag = 0;
if( adUnitFlags & ADUNIT_OFF ) return 0; /* Disallow ads on this page */
if( db_get_boolean("adunit-disable",0) ) return 0;
if( g.perm.Admin && db_get_boolean("adunit-omit-if-admin",0) ){
return 0;
}
if( !login_is_nobody()
&& fossil_strcmp(g.zLogin,"anonymous")!=0
&& db_get_boolean("adunit-omit-if-user",0)
){
|
| ︙ | ︙ | |||
590 591 592 593 594 595 596 |
if( !isTrue ){
@ selected\
}
@ >%h(aSubmenuCtrl[i].zFalse)</option>
@ </select>
break;
}
| | > > > | > > | 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 |
if( !isTrue ){
@ selected\
}
@ >%h(aSubmenuCtrl[i].zFalse)</option>
@ </select>
break;
}
case FF_CHECKBOX: {
@ <label class='submenuctrl submenuckbox'>\
@ <input type='checkbox' name='%s(zQPN)' \
if( PB(zQPN) ){
@ checked \
}
if( aSubmenuCtrl[i].zJS ){
@ onchange='%s(aSubmenuCtrl[i].zJS)'%s(zDisabled)>\
}else{
@ onchange='gebi("f01").submit();'%s(zDisabled)>\
}
@ %h(aSubmenuCtrl[i].zLabel)</label>
break;
}
}
}
@ </div>
if( nSubmenuCtrl ){
cgi_query_parameters_to_hidden();
cgi_tag_query_parameter(0);
@ </form>
|
| ︙ | ︙ | |||
1568 1569 1570 1571 1572 1573 1574 |
char c;
int i;
int showAll;
char zCap[30];
static const char *const azCgiVars[] = {
"COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE",
"HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
| | > | > | | 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 |
char c;
int i;
int showAll;
char zCap[30];
static const char *const azCgiVars[] = {
"COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE",
"HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
"HTTP_ACCEPT_LANGUAGE", "HTTP_AUTHENICATION",
"HTTP_CONNECTION", "HTTP_HOST",
"HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", "PATH_TRANSLATED",
"QUERY_STRING", "REMOTE_ADDR", "REMOTE_PORT",
"REMOTE_USER", "REQUEST_METHOD",
"REQUEST_URI", "SCRIPT_FILENAME", "SCRIPT_NAME", "SERVER_PROTOCOL",
"HOME", "FOSSIL_HOME", "USERNAME", "USER", "FOSSIL_USER",
"SQLITE_TMPDIR", "TMPDIR",
"TEMP", "TMP", "FOSSIL_VFS",
"FOSSIL_FORCE_TICKET_MODERATION", "FOSSIL_FORCE_WIKI_MODERATION",
"FOSSIL_TCL_PATH", "TH1_DELETE_INTERP", "TH1_ENABLE_DOCS",
"TH1_ENABLE_HOOKS", "TH1_ENABLE_TCL", "REMOTE_HOST"
};
login_check_credentials();
if( !g.perm.Admin && !g.perm.Setup && !db_get_boolean("test_env_enable",0) ){
login_needed(0);
return;
}
for(i=0; i<count(azCgiVars); i++) (void)P(azCgiVars[i]);
style_header("Environment Test");
showAll = PB("showall");
style_submenu_checkbox("showall", "Cookies", 0, 0);
style_submenu_element("Stats", "%R/stat");
#if !defined(_WIN32)
@ uid=%d(getuid()), gid=%d(getgid())<br />
#endif
@ g.zBaseURL = %h(g.zBaseURL)<br />
@ g.zHttpsURL = %h(g.zHttpsURL)<br />
|
| ︙ | ︙ |
Changes to src/tag.c.
| ︙ | ︙ | |||
585 586 587 588 589 590 591 |
tag_cmd_usage:
usage("add|cancel|find|list ...");
}
/*
** COMMAND: reparent*
**
| | | 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
tag_cmd_usage:
usage("add|cancel|find|list ...");
}
/*
** COMMAND: reparent*
**
** Usage: %fossil reparent [OPTIONS] CHECK-IN PARENT ...
**
** Create a "parent" tag that causes CHECK-IN to be interpreted as a
** child of PARENT. If multiple PARENTs are listed, then the first is
** the primary parent and others are merge ancestors.
**
** This is an experts-only command. It is used to patch up a repository
** that has been damaged by a shun or that has been pieced together from
|
| ︙ | ︙ | |||
617 618 619 620 621 622 623 |
char *zUuid;
int dryRun = 0;
if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
db_find_and_open_repository(0, 0);
verify_all_options();
if( g.argc<4 ){
| | | 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
char *zUuid;
int dryRun = 0;
if( find_option("dryrun","n",0)!=0 ) dryRun = TAG_ADD_DRYRUN;
db_find_and_open_repository(0, 0);
verify_all_options();
if( g.argc<4 ){
usage("[OPTIONS] CHECK-IN PARENT ...");
}
rid = name_to_typed_rid(g.argv[2], "ci");
blob_init(&value, 0, 0);
for(i=3; i<g.argc; i++){
int pid = name_to_typed_rid(g.argv[i], "ci");
if( i>3 ) blob_append(&value, " ", 1);
zUuid = rid_to_uuid(pid);
|
| ︙ | ︙ |
Changes to src/tar.c.
| ︙ | ︙ | |||
614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
/* We should be done with options.. */
verify_all_options();
if( g.argc!=4 ){
usage("VERSION OUTPUTFILE");
}
rid = name_to_typed_rid(g.argv[2], "ci");
if( rid==0 ){
fossil_fatal("Check-in not found: %s", g.argv[2]);
return;
}
if( zName==0 ){
| > | 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
/* We should be done with options.. */
verify_all_options();
if( g.argc!=4 ){
usage("VERSION OUTPUTFILE");
}
g.zOpenRevision = g.argv[2];
rid = name_to_typed_rid(g.argv[2], "ci");
if( rid==0 ){
fossil_fatal("Check-in not found: %s", g.argv[2]);
return;
}
if( zName==0 ){
|
| ︙ | ︙ | |||
642 643 644 645 646 647 648 | blob_reset(&tarball); } /* ** WEBPAGE: tarball ** URL: /tarball ** | | | | > > > > > > | > | > | 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 |
blob_reset(&tarball);
}
/*
** WEBPAGE: tarball
** URL: /tarball
**
** Generate a compressed tarball for the check-in specified by the "r"
** query parameter. Return that compressed tarball as the HTTP reply
** content.
**
** Query parameters:
**
** name=NAME[.tar.gz] The base name of the output file. The default
** value is a configuration parameter in the project
** settings. A prefix of the name, omitting the
** extension, is used as the top-most directory name.
**
** r=TAG The check-in that is turned into a compressed tarball.
** Defaults to "trunk". This query parameter used to
** be called "uuid" and "uuid" is still accepted for
** backwards compatibility. If omitted, the default
** check-in name is "trunk".
**
** in=PATTERN Only include files that match the comma-separate
** list of GLOB patterns in PATTERN, as with ex=
**
** ex=PATTERN Omit any file that match PATTERN. PATTERN is a
** comma-separated list of GLOB patterns, where each
** pattern can optionally be quoted using ".." or '..'.
** Any file matching both ex= and in= is excluded.
*/
void tarball_page(void){
int rid;
char *zName, *zRid, *zKey;
int nName, nRid;
const char *zInclude; /* The in= query parameter */
const char *zExclude; /* The ex= query parameter */
Blob cacheKey; /* The key to cache */
Glob *pInclude = 0; /* The compiled in= glob pattern */
Glob *pExclude = 0; /* The compiled ex= glob pattern */
Blob tarball; /* Tarball accumulated here */
const char *z;
login_check_credentials();
if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
load_control();
zName = mprintf("%s", PD("name",""));
nName = strlen(zName);
z = P("r");
if( z==0 ) z = P("uuid");
if( z==0 ) z = "trunk";
g.zOpenRevision = zRid = fossil_strdup(z);
nRid = strlen(zRid);
zInclude = P("in");
if( zInclude ) pInclude = glob_create(zInclude);
zExclude = P("ex");
if( zExclude ) pExclude = glob_create(zExclude);
if( nName>7 && fossil_strcmp(&zName[nName-7], ".tar.gz")==0 ){
/* Special case: Remove the ".tar.gz" suffix. */
nName -= 7;
zName[nName] = 0;
}else{
/* If the file suffix is not ".tar.gz" then just remove the
** suffix up to and including the last "." */
for(nName=strlen(zName)-1; nName>5; nName--){
if( zName[nName]=='.' ){
zName[nName] = 0;
break;
}
}
}
rid = symbolic_name_to_rid(nRid?zRid:zName, "ci");
if( rid==0 ){
cgi_set_status(404, "Not Found");
@ Not found
return;
}
if( nRid==0 && nName>10 ) zName[10] = 0;
/* Compute a unique key for the cache entry based on query parameters */
blob_init(&cacheKey, 0, 0);
|
| ︙ | ︙ |
Changes to src/th.h.
| ︙ | ︙ | |||
100 101 102 103 104 105 106 107 108 109 110 111 112 113 | ** Valid return codes for xProc callbacks. */ #define TH_OK 0 #define TH_ERROR 1 #define TH_BREAK 2 #define TH_RETURN 3 #define TH_CONTINUE 4 /* ** Set and get the interpreter result. */ int Th_SetResult(Th_Interp *, const char *, int); const char *Th_GetResult(Th_Interp *, int *); char *Th_TakeResult(Th_Interp *, int *); | > | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | ** Valid return codes for xProc callbacks. */ #define TH_OK 0 #define TH_ERROR 1 #define TH_BREAK 2 #define TH_RETURN 3 #define TH_CONTINUE 4 #define TH_RETURN2 5 /* ** Set and get the interpreter result. */ int Th_SetResult(Th_Interp *, const char *, int); const char *Th_GetResult(Th_Interp *, int *); char *Th_TakeResult(Th_Interp *, int *); |
| ︙ | ︙ |
Changes to src/th_lang.c.
| ︙ | ︙ | |||
431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
procargs.argv = argv;
procargs.argl = argl;
rc = Th_InFrame(interp, proc_call2, (void *)p, (void *)&procargs);
if( rc==TH_RETURN ){
rc = TH_OK;
}
return rc;
}
/*
** This function is registered as the delete callback for all commands
** created using the built-in [proc] command. It is called automatically
** when a command created using [proc] is deleted.
| > > > | 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
procargs.argv = argv;
procargs.argl = argl;
rc = Th_InFrame(interp, proc_call2, (void *)p, (void *)&procargs);
if( rc==TH_RETURN ){
rc = TH_OK;
}
if( rc==TH_RETURN2 ){
rc = TH_RETURN;
}
return rc;
}
/*
** This function is registered as the delete callback for all commands
** created using the built-in [proc] command. It is called automatically
** when a command created using [proc] is deleted.
|
| ︙ | ︙ | |||
713 714 715 716 717 718 719 720 721 722 723 724 725 726 |
break;
}
}
}
return Th_SetResultInt(interp, iRes);
}
/*
** TH Syntax:
**
** string is CLASS STRING
*/
static int string_is_command(
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 |
break;
}
}
}
return Th_SetResultInt(interp, iRes);
}
/*
** TH Syntax:
**
** string index STRING INDEX
*/
static int string_index_command(
Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
){
int iIndex;
if( argc!=4 ){
return Th_WrongNumArgs(interp, "string index string index");
}
if( argl[3]==3 && 0==memcmp("end", argv[3], 3) ){
iIndex = argl[2]-1;
}else if( Th_ToInt(interp, argv[3], argl[3], &iIndex) ){
Th_ErrorMessage(
interp, "Expected \"end\" or integer, got:", argv[3], argl[3]);
return TH_ERROR;
}
if( iIndex>=0 && iIndex<argl[2] ){
return Th_SetResult(interp, &argv[2][iIndex], 1);
}else{
return Th_SetResult(interp, 0, 0);
}
}
/*
** TH Syntax:
**
** string is CLASS STRING
*/
static int string_is_command(
|
| ︙ | ︙ | |||
1055 1056 1057 1058 1059 1060 1061 | } return TH_ERROR; } /* ** TH Syntax: ** | | | > | | | | | > > > | | > | | | | | | 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 |
}
return TH_ERROR;
}
/*
** TH Syntax:
**
** string compare STR1 STR2
** string first NEEDLE HAYSTACK ?STARTINDEX?
** string index STRING INDEX
** string is CLASS STRING
** string last NEEDLE HAYSTACK ?STARTINDEX?
** string length STRING
** string range STRING FIRST LAST
** string repeat STRING COUNT
** string trim STRING
** string trimleft STRING
** string trimright STRING
*/
static int string_command(
Th_Interp *interp,
void *ctx,
int argc,
const char **argv,
int *argl
){
static const Th_SubCommand aSub[] = {
{ "compare", string_compare_command },
{ "first", string_first_command },
{ "index", string_index_command },
{ "is", string_is_command },
{ "last", string_last_command },
{ "length", string_length_command },
{ "range", string_range_command },
{ "repeat", string_repeat_command },
{ "trim", string_trim_command },
{ "trimleft", string_trim_command },
{ "trimright", string_trim_command },
{ 0, 0 }
};
return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub);
}
|
| ︙ | ︙ |
Changes to src/th_main.c.
| ︙ | ︙ | |||
19 20 21 22 23 24 25 | ** (an independent project) and fossil. */ #include "config.h" #include "th_main.h" #include "sqlite3.h" #if INTERFACE | < < < < < < < < | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ** (an independent project) and fossil. */ #include "config.h" #include "th_main.h" #include "sqlite3.h" #if INTERFACE /* ** Flag parameters to the Th_FossilInit() routine used to control the ** interpreter creation and initialization process. */ #define TH_INIT_NONE ((u32)0x00000000) /* No flags. */ #define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */ #define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */ |
| ︙ | ︙ | |||
65 66 67 68 69 70 71 72 73 74 75 76 77 78 | ** page, respectively. If one of these errors is seen, it will not be sent ** or displayed to the remote user or local interactive user, respectively. */ #define NO_COMMAND_HOOK_ERROR "no such command: command_hook" #define NO_WEBPAGE_HOOK_ERROR "no such command: webpage_hook" #endif /* ** Global variable counting the number of outstanding calls to malloc() ** made by the th1 implementation. This is used to catch memory leaks ** in the interpreter. Obviously, it also means th1 is not threadsafe. */ static int nOutstandingMalloc = 0; | > > > > > > > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
** page, respectively. If one of these errors is seen, it will not be sent
** or displayed to the remote user or local interactive user, respectively.
*/
#define NO_COMMAND_HOOK_ERROR "no such command: command_hook"
#define NO_WEBPAGE_HOOK_ERROR "no such command: webpage_hook"
#endif
/*
** These macros are used within this file to detect if the repository and
** configuration ("user") database are currently open.
*/
#define Th_IsRepositoryOpen() (g.repositoryOpen)
#define Th_IsConfigOpen() (g.zConfigDbName!=0)
/*
** Global variable counting the number of outstanding calls to malloc()
** made by the th1 implementation. This is used to catch memory leaks
** in the interpreter. Obviously, it also means th1 is not threadsafe.
*/
static int nOutstandingMalloc = 0;
|
| ︙ | ︙ | |||
298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
switch( rc ){
case TH_OK: return nullIfOk ? 0 : "TH_OK";
case TH_ERROR: return "TH_ERROR";
case TH_BREAK: return "TH_BREAK";
case TH_RETURN: return "TH_RETURN";
case TH_CONTINUE: return "TH_CONTINUE";
default: {
sqlite3_snprintf(sizeof(zRc), zRc, "TH1 return code %d", rc);
}
}
return zRc;
}
| > | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
switch( rc ){
case TH_OK: return nullIfOk ? 0 : "TH_OK";
case TH_ERROR: return "TH_ERROR";
case TH_BREAK: return "TH_BREAK";
case TH_RETURN: return "TH_RETURN";
case TH_CONTINUE: return "TH_CONTINUE";
case TH_RETURN2: return "TH_RETURN2";
default: {
sqlite3_snprintf(sizeof(zRc), zRc, "TH1 return code %d", rc);
}
}
return zRc;
}
|
| ︙ | ︙ | |||
1586 1587 1588 1589 1590 1591 1592 |
Th_ErrorMessage(interp, "database is not open", 0, 0);
return TH_ERROR;
}
zSql = argv[1];
nSql = argl[1];
while( res==TH_OK && nSql>0 ){
zErr = 0;
| | | | 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 |
Th_ErrorMessage(interp, "database is not open", 0, 0);
return TH_ERROR;
}
zSql = argv[1];
nSql = argl[1];
while( res==TH_OK && nSql>0 ){
zErr = 0;
report_restrict_sql(&zErr);
g.dbIgnoreErrors++;
rc = sqlite3_prepare_v2(g.db, argv[1], argl[1], &pStmt, &zTail);
g.dbIgnoreErrors--;
report_unrestrict_sql();
if( rc!=0 || zErr!=0 ){
if( noComplain ) return TH_OK;
Th_ErrorMessage(interp, "SQL error: ",
zErr ? zErr : sqlite3_errmsg(g.db), -1);
return TH_ERROR;
}
n = (int)(zTail - zSql);
|
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
zBr = P(zNm);
@ <input type="text" size="30" name='%s(zNm)' value='%h(PD(zNm,""))'><br />
}
@ <input type="submit">
@ </form>
style_footer();
}
/*
** Output a timeline in the web format given a query. The query
** should return these columns:
**
** 0. rid
** 1. UUID
| > > > > > > > > | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
zBr = P(zNm);
@ <input type="text" size="30" name='%s(zNm)' value='%h(PD(zNm,""))'><br />
}
@ <input type="submit">
@ </form>
style_footer();
}
/*
** Return a new timelineTable id.
*/
int timeline_tableid(void){
static int id = 0;
return id++;
}
/*
** Output a timeline in the web format given a query. The query
** should return these columns:
**
** 0. rid
** 1. UUID
|
| ︙ | ︙ | |||
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
Stmt fchngQuery; /* Query for file changes on check-ins */
static Stmt qbranch;
int pendingEndTr = 0; /* True if a </td></tr> is needed */
int vid = 0; /* Current checkout version */
int dateFormat = 0; /* 0: HH:MM (default) */
int bCommentGitStyle = 0; /* Only show comments through first blank line */
const char *zDateFmt;
if( fossil_strcmp(g.zIpAddr, "127.0.0.1")==0 && db_open_local(0) ){
vid = db_lget_int("checkout", 0);
}
zPrevDate[0] = 0;
mxWikiLen = db_get_int("timeline-max-comment", 0);
dateFormat = db_get_int("timeline-date-format", 0);
bCommentGitStyle = db_get_int("timeline-truncate-at-blank", 0);
zDateFmt = P("datefmt");
if( zDateFmt ) dateFormat = atoi(zDateFmt);
if( tmFlags & TIMELINE_GRAPH ){
pGraph = graph_init();
}
db_static_prepare(&qbranch,
"SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
TAG_BRANCH
);
| > | | 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
Stmt fchngQuery; /* Query for file changes on check-ins */
static Stmt qbranch;
int pendingEndTr = 0; /* True if a </td></tr> is needed */
int vid = 0; /* Current checkout version */
int dateFormat = 0; /* 0: HH:MM (default) */
int bCommentGitStyle = 0; /* Only show comments through first blank line */
const char *zDateFmt;
int iTableId = timeline_tableid();
if( fossil_strcmp(g.zIpAddr, "127.0.0.1")==0 && db_open_local(0) ){
vid = db_lget_int("checkout", 0);
}
zPrevDate[0] = 0;
mxWikiLen = db_get_int("timeline-max-comment", 0);
dateFormat = db_get_int("timeline-date-format", 0);
bCommentGitStyle = db_get_int("timeline-truncate-at-blank", 0);
zDateFmt = P("datefmt");
if( zDateFmt ) dateFormat = atoi(zDateFmt);
if( tmFlags & TIMELINE_GRAPH ){
pGraph = graph_init();
}
db_static_prepare(&qbranch,
"SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
TAG_BRANCH
);
@ <table id="timelineTable%d(iTableId)" class="timelineTable">
blob_zero(&comment);
while( db_step(pQuery)==SQLITE_ROW ){
int rid = db_column_int(pQuery, 0);
const char *zUuid = db_column_text(pQuery, 1);
int isLeaf = db_column_int(pQuery, 5);
const char *zBgClr = db_column_text(pQuery, 6);
const char *zDate = db_column_text(pQuery, 2);
|
| ︙ | ︙ | |||
436 437 438 439 440 441 442 |
}
}else if( zType[0]=='e' && tagid ){
hyperlink_to_event_tagid(tagid<0?-tagid:tagid);
}else if( (tmFlags & TIMELINE_ARTID)!=0 ){
hyperlink_to_uuid(zUuid);
}
if( tmFlags & TIMELINE_SHOWRID ){
| > > > > | > | 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
}
}else if( zType[0]=='e' && tagid ){
hyperlink_to_event_tagid(tagid<0?-tagid:tagid);
}else if( (tmFlags & TIMELINE_ARTID)!=0 ){
hyperlink_to_uuid(zUuid);
}
if( tmFlags & TIMELINE_SHOWRID ){
int srcId = delta_source_rid(rid);
if( srcId ){
@ (%d(rid)←%d(srcId))
}else{
@ (%d(rid))
}
}
db_column_blob(pQuery, commentColumn, &comment);
if( zType[0]!='c' ){
/* Comments for anything other than a check-in are generated by
** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */
wiki_convert(&comment, 0, WIKI_INLINE);
}else if( bCommentGitStyle ){
|
| ︙ | ︙ | |||
553 554 555 556 557 558 559 |
int fid = db_column_int(&fchngQuery, 1);
int isDel = fid==0;
const char *zOldName = db_column_text(&fchngQuery, 5);
const char *zOld = db_column_text(&fchngQuery, 4);
const char *zNew = db_column_text(&fchngQuery, 3);
const char *zUnpub = "";
char *zA;
| | > > > > | > | 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
int fid = db_column_int(&fchngQuery, 1);
int isDel = fid==0;
const char *zOldName = db_column_text(&fchngQuery, 5);
const char *zOld = db_column_text(&fchngQuery, 4);
const char *zNew = db_column_text(&fchngQuery, 3);
const char *zUnpub = "";
char *zA;
char zId[40];
if( !inUl ){
@ <ul class="filelist">
inUl = 1;
}
if( tmFlags & TIMELINE_SHOWRID ){
int srcId = delta_source_rid(fid);
if( srcId ){
sqlite3_snprintf(sizeof(zId), zId, " (%d←%d) ", fid, srcId);
}else{
sqlite3_snprintf(sizeof(zId), zId, " (%d) ", fid);
}
}else{
zId[0] = 0;
}
if( (tmFlags & TIMELINE_FRENAMES)!=0 ){
if( !isNew && !isDel && zOldName!=0 ){
@ <li> %h(zOldName) → %h(zFilename)%s(zId)
}
|
| ︙ | ︙ | |||
621 622 623 624 625 626 627 |
pGraph = 0;
}else{
@ <tr class="timelineBottom"><td></td><td></td><td></td></tr>
}
}
@ </table>
if( fchngQueryInit ) db_finalize(&fchngQuery);
| | | 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 |
pGraph = 0;
}else{
@ <tr class="timelineBottom"><td></td><td></td><td></td></tr>
}
}
@ </table>
if( fchngQueryInit ) db_finalize(&fchngQuery);
timeline_output_graph_javascript(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0, iTableId, 0);
}
/*
** Change the RGB background color given in the argument in a foreground
** color with the same hue.
*/
static const char *bg_to_fg(const char *zIn){
|
| ︙ | ︙ | |||
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 |
/*
** Generate all of the necessary javascript to generate a timeline
** graph.
*/
void timeline_output_graph_javascript(
GraphContext *pGraph, /* The graph to be displayed */
int omitDescenders, /* True to omit descenders */
int fileDiff /* True for file diff. False for check-in diff */
){
if( pGraph && pGraph->nErr==0 && pGraph->nRow>0 ){
GraphRow *pRow;
int i;
char cSep;
int iRailPitch; /* Pixels between consecutive rails */
int showArrowheads; /* True to draw arrowheads. False to omit. */
int circleNodes; /* True for circle nodes. False for square nodes */
int colorGraph; /* Use colors for graph lines */
iRailPitch = atoi(PD("railpitch","0"));
showArrowheads = skin_detail_boolean("timeline-arrowheads");
circleNodes = skin_detail_boolean("timeline-circle-nodes");
colorGraph = skin_detail_boolean("timeline-color-graph-lines");
@ <script>(function(){
| > > | 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 |
/*
** Generate all of the necessary javascript to generate a timeline
** graph.
*/
void timeline_output_graph_javascript(
GraphContext *pGraph, /* The graph to be displayed */
int omitDescenders, /* True to omit descenders */
int iTableId, /* Identifier for the timelineTable */
int fileDiff /* True for file diff. False for check-in diff */
){
if( pGraph && pGraph->nErr==0 && pGraph->nRow>0 ){
GraphRow *pRow;
int i;
char cSep;
int iRailPitch; /* Pixels between consecutive rails */
int showArrowheads; /* True to draw arrowheads. False to omit. */
int circleNodes; /* True for circle nodes. False for square nodes */
int colorGraph; /* Use colors for graph lines */
int iTopRow; /* Index of the top row of the graph */
iRailPitch = atoi(PD("railpitch","0"));
showArrowheads = skin_detail_boolean("timeline-arrowheads");
circleNodes = skin_detail_boolean("timeline-circle-nodes");
colorGraph = skin_detail_boolean("timeline-color-graph-lines");
@ <script>(function(){
|
| ︙ | ︙ | |||
697 698 699 700 701 702 703 |
@ document.querySelector("head").appendChild(style);
@ }
/* the rowinfo[] array contains all the information needed to generate
** the graph. Each entry contains information for a single row:
**
** id: The id of the <div> element for the row. This is an integer.
** to get an actual id, prepend "m" to the integer. The top node
| | | 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
@ document.querySelector("head").appendChild(style);
@ }
/* the rowinfo[] array contains all the information needed to generate
** the graph. Each entry contains information for a single row:
**
** id: The id of the <div> element for the row. This is an integer.
** to get an actual id, prepend "m" to the integer. The top node
** is iTopRow and numbers increase moving down the timeline.
** bg: The background color for this row
** r: The "rail" that the node for this row sits on. The left-most
** rail is 0 and the number increases to the right.
** d: True if there is a "descender" - an arrow coming from the bottom
** of the page straight up to this node.
** mo: "merge-out". If non-negative, this is the rail position
** for the upward portion of a merge arrow. The merge arrow goes up
|
| ︙ | ︙ | |||
723 724 725 726 727 728 729 730 731 732 733 734 735 736 |
** mi: "merge-in". An array of integer rail positions from which
** merge arrows should be drawn into this node. If the value is
** negative, then the rail position is the absolute value of mi[]
** and a thin merge-arrow descender is drawn to the bottom of
** the screen.
** h: The artifact hash of the object being graphed
*/
cgi_printf("var rowinfo = [\n");
for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:",
pRow->idx, /* id */
pRow->zBgClr, /* bg */
pRow->iRail, /* r */
pRow->bDescender, /* d */
| > | 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 |
** mi: "merge-in". An array of integer rail positions from which
** merge arrows should be drawn into this node. If the value is
** negative, then the rail position is the absolute value of mi[]
** and a thin merge-arrow descender is drawn to the bottom of
** the screen.
** h: The artifact hash of the object being graphed
*/
iTopRow = pGraph->pFirst ? pGraph->pFirst->idx : 0;
cgi_printf("var rowinfo = [\n");
for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:",
pRow->idx, /* id */
pRow->zBgClr, /* bg */
pRow->iRail, /* r */
pRow->bDescender, /* d */
|
| ︙ | ︙ | |||
770 771 772 773 774 775 776 |
cgi_printf("var nrail = %d\n", pGraph->mxRail+1);
graph_free(pGraph);
@ var canvasDiv;
@ var railPitch;
@ var mergeOffset;
@ var node, arrow, arrowSmall, line, mArrow, mLine, wArrow, wLine;
@ function initGraph(){
| | | 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 |
cgi_printf("var nrail = %d\n", pGraph->mxRail+1);
graph_free(pGraph);
@ var canvasDiv;
@ var railPitch;
@ var mergeOffset;
@ var node, arrow, arrowSmall, line, mArrow, mLine, wArrow, wLine;
@ function initGraph(){
@ var parent = gebi("timelineTable%d(iTableId)").rows[0].cells[1];
@ parent.style.verticalAlign = "top";
@ canvasDiv = document.createElement("div");
@ canvasDiv.className = "tl-canvas";
@ canvasDiv.style.position = "absolute";
@ parent.appendChild(canvasDiv);
@
@ var elems = {};
|
| ︙ | ︙ | |||
899 900 901 902 903 904 905 |
@ var y = miLineY(p);
@ drawMergeLine(x0,y,x1,null);
@ var x = p.x + (p.r<rail ? node.w : -mArrow.w);
@ var cls = "arrow merge " + (p.r<rail ? "l" : "r");
@ drawBox(cls,null,x,y+(mLine.w-mArrow.h)/2);
@ }
@ function drawNode(p, btm){
| | | | 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 |
@ var y = miLineY(p);
@ drawMergeLine(x0,y,x1,null);
@ var x = p.x + (p.r<rail ? node.w : -mArrow.w);
@ var cls = "arrow merge " + (p.r<rail ? "l" : "r");
@ drawBox(cls,null,x,y+(mLine.w-mArrow.h)/2);
@ }
@ function drawNode(p, btm){
@ if( p.u>0 ) drawUpArrow(p,rowinfo[p.u-%d(iTopRow)],p.fg);
@ var cls = node.cls;
@ if( p.mi.length ) cls += " merge";
@ if( p.f&1 ) cls += " leaf";
@ var n = drawBox(cls,p.bg,p.x,p.y);
@ n.id = "tln"+p.id;
@ n.onclick = clickOnNode;
@ n.style.zIndex = 10;
if( !omitDescenders ){
@ if( p.u==0 ) drawUpArrow(p,{x: p.x, y: -node.h},p.fg);
@ if( p.d ) drawUpArrow({x: p.x, y: btm-node.h/2},p,p.fg);
}
@ if( p.mo>=0 ){
@ var x0 = p.x + node.w/2;
@ var x1 = p.mo*railPitch + node.w/2;
@ var u = rowinfo[p.mu-%d(iTopRow)];
@ var y1 = miLineY(u);
@ if( p.u<0 || p.mo!=p.r ){
@ x1 += mergeLines[p.mo] = -mLine.w/2;
@ var y0 = p.y+2;
@ if( p.r!=p.mo ) drawMergeLine(x0,y0,x1+(x0<x1 ? mLine.w : 0),null);
@ drawMergeLine(x1,y0+mLine.w,null,y1);
@ }else if( mergeOffset ){
|
| ︙ | ︙ | |||
938 939 940 941 942 943 944 |
@ var x0 = p.x + node.w/2;
@ var x1 = rail*railPitch + (node.w-line.w)/2;
@ if( x0<x1 ){
@ x0 = Math.ceil(x0);
@ x1 += line.w;
@ }
@ var y0 = p.y + (node.h-line.w)/2;
| | | 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 |
@ var x0 = p.x + node.w/2;
@ var x1 = rail*railPitch + (node.w-line.w)/2;
@ if( x0<x1 ){
@ x0 = Math.ceil(x0);
@ x1 += line.w;
@ }
@ var y0 = p.y + (node.h-line.w)/2;
@ var u = rowinfo[p.au[i+1]-%d(iTopRow)];
@ if( u.id<p.id ){
@ drawLine(line,u.fg,x0,y0,x1,null);
@ drawUpArrow(p,u,u.fg);
@ }else{
@ var y1 = u.y + (node.h-line.w)/2;
@ drawLine(wLine,u.fg,x0,y0,x1,null);
@ drawLine(wLine,u.fg,x1-line.w,y0,null,y1+line.w);
|
| ︙ | ︙ | |||
984 985 986 987 988 989 990 |
@ var btm = absoluteY(tlBtm) - canvasY + tlBtm.offsetHeight;
@ for( var i=rowinfo.length-1; i>=0; i-- ){
@ drawNode(rowinfo[i], btm);
@ }
@ }
@ var selRow;
@ function clickOnNode(){
| | | 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 |
@ var btm = absoluteY(tlBtm) - canvasY + tlBtm.offsetHeight;
@ for( var i=rowinfo.length-1; i>=0; i-- ){
@ drawNode(rowinfo[i], btm);
@ }
@ }
@ var selRow;
@ function clickOnNode(){
@ var p = rowinfo[parseInt(this.id.match(/\d+$/)[0], 10)-%d(iTopRow)];
@ if( !selRow ){
@ selRow = p;
@ this.className += " sel";
@ canvasDiv.className += " sel";
@ }else if( selRow==p ){
@ selRow = null;
@ this.className = this.className.replace(" sel", "");
|
| ︙ | ︙ | |||
1592 1593 1594 1595 1596 1597 1598 |
matchStyle = MS_REGEXP;
}else{
/* For exact maching, inhibit links to the selected tag. */
zThisTag = zTagName;
}
/* Display a checkbox to enable/disable display of related check-ins. */
| | | 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 |
matchStyle = MS_REGEXP;
}else{
/* For exact maching, inhibit links to the selected tag. */
zThisTag = zTagName;
}
/* Display a checkbox to enable/disable display of related check-ins. */
style_submenu_checkbox("rel", "Related", 0, 0);
/* Construct the tag match expression. */
zTagSql = tagMatchExpression(matchStyle, zTagName, &zMatchDesc, &zError);
}
if( zMark && zMark[0]==0 ){
if( zAfter ) zMark = zAfter;
|
| ︙ | ︙ | |||
1724 1725 1726 1727 1728 1729 1730 |
p = p->u.pTo;
}
blob_append(&sql, ")", -1);
path_reset();
addFileGlobExclusion(zChng, &sql);
tmFlags |= TIMELINE_DISJOINT;
db_multi_exec("%s", blob_sql_text(&sql));
| | | 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 |
p = p->u.pTo;
}
blob_append(&sql, ")", -1);
path_reset();
addFileGlobExclusion(zChng, &sql);
tmFlags |= TIMELINE_DISJOINT;
db_multi_exec("%s", blob_sql_text(&sql));
style_submenu_checkbox("v", "Files", zType[0]!='a' && zType[0]!='c', 0);
blob_appendf(&desc, "%d check-ins going from ",
db_int(0, "SELECT count(*) FROM timeline"));
blob_appendf(&desc, "%z[%h]</a>", href("%R/info/%h", zFrom), zFrom);
blob_append(&desc, " to ", -1);
blob_appendf(&desc, "%z[%h]</a>", href("%R/info/%h",zTo), zTo);
addFileGlobDescription(zChng, &desc);
}else if( (p_rid || d_rid) && g.perm.Read ){
|
| ︙ | ︙ | |||
1774 1775 1776 1777 1778 1779 1780 |
href("%R/info/%!S", zUuid), zUuid);
if( d_rid ){
if( p_rid ){
/* If both p= and d= are set, we don't have the uuid of d yet. */
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", d_rid);
}
}
| | | | | 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 |
href("%R/info/%!S", zUuid), zUuid);
if( d_rid ){
if( p_rid ){
/* If both p= and d= are set, we don't have the uuid of d yet. */
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", d_rid);
}
}
style_submenu_checkbox("v", "Files", zType[0]!='a' && zType[0]!='c', 0);
style_submenu_entry("n","Max:",4,0);
timeline_y_submenu(1);
}else if( f_rid && g.perm.Read ){
/* If f= is present, ignore all other parameters other than n= */
char *zUuid;
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);"
"INSERT INTO ok VALUES(%d);"
"INSERT OR IGNORE INTO ok SELECT pid FROM plink WHERE cid=%d;"
"INSERT OR IGNORE INTO ok SELECT cid FROM plink WHERE pid=%d;",
f_rid, f_rid, f_rid
);
blob_append_sql(&sql, " AND event.objid IN ok");
db_multi_exec("%s", blob_sql_text(&sql));
if( useDividers ) selectedRid = f_rid;
blob_appendf(&desc, "Parents and children of check-in ");
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", f_rid);
blob_appendf(&desc, "%z[%S]</a>", href("%R/info/%!S", zUuid), zUuid);
tmFlags |= TIMELINE_DISJOINT;
style_submenu_checkbox("unhide", "Unhide", 0, 0);
style_submenu_checkbox("v", "Files", zType[0]!='a' && zType[0]!='c', 0);
}else{
/* Otherwise, a timeline based on a span of time */
int n;
const char *zEType = "timeline item";
char *zDate;
Blob cond;
blob_zero(&cond);
|
| ︙ | ︙ | |||
2079 2080 2081 2082 2083 2084 2085 |
rDate+ONE_SECOND, blob_sql_text(&cond))
){
timeline_submenu(&url, "Newer", "a", zDate, "b");
}
free(zDate);
}
if( zType[0]=='a' || zType[0]=='c' ){
| | | | 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 |
rDate+ONE_SECOND, blob_sql_text(&cond))
){
timeline_submenu(&url, "Newer", "a", zDate, "b");
}
free(zDate);
}
if( zType[0]=='a' || zType[0]=='c' ){
style_submenu_checkbox("unhide", "Unhide", 0, 0);
}
style_submenu_checkbox("v", "Files", zType[0]!='a' && zType[0]!='c', 0);
style_submenu_entry("n","Max:",4,0);
timeline_y_submenu(disableY);
style_submenu_entry("t", "Tag Filter:", -8, 0);
style_submenu_multichoice("ms", count(azMatchStyles)/2, azMatchStyles, 0);
}
blob_zero(&cond);
}
|
| ︙ | ︙ | |||
2445 2446 2447 2448 2449 2450 2451 |
zDate = mprintf("(SELECT datetime('now'))");
}else if( strncmp(zOrigin, "current", k)==0 ){
if( !g.localOpen ){
fossil_fatal("must be within a local checkout to use 'current'");
}
objid = db_lget_int("checkout",0);
zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid);
| < < < > > > | 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 |
zDate = mprintf("(SELECT datetime('now'))");
}else if( strncmp(zOrigin, "current", k)==0 ){
if( !g.localOpen ){
fossil_fatal("must be within a local checkout to use 'current'");
}
objid = db_lget_int("checkout",0);
zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid);
}else if( fossil_is_julianday(zOrigin) ){
const char *zShift = "";
if( mode==TIMELINE_MODE_CHILDREN || mode==TIMELINE_MODE_PARENTS ){
fossil_fatal("cannot compute descendants or ancestors of a date");
}
if( mode==TIMELINE_MODE_NONE ){
if( isIsoDate(zOrigin) ) zShift = ",'+1 day'";
}
zDate = mprintf("(SELECT julianday(%Q%s, fromLocal()))", zOrigin, zShift);
}else if( name_to_uuid(&uuid, 0, "*")==0 ){
objid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &uuid);
zDate = mprintf("(SELECT mtime FROM event WHERE objid=%d)", objid);
}else{
fossil_fatal("unknown check-in or invalid date: %s", zOrigin);
}
if( zFilePattern ){
if( zType==0 ){
/* When zFilePattern is specified and type is not specified, only show
|
| ︙ | ︙ |
Changes to src/tkt.c.
| ︙ | ︙ | |||
747 748 749 750 751 752 753 |
zName = P("name");
if( P("cancel") ){
cgi_redirectf("tktview?name=%T", zName);
}
style_header("Edit Ticket");
if( zName==0 || (nName = strlen(zName))<4 || nName>UUID_SIZE
|| !validate16(zName,nName) ){
| | | | | 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
zName = P("name");
if( P("cancel") ){
cgi_redirectf("tktview?name=%T", zName);
}
style_header("Edit Ticket");
if( zName==0 || (nName = strlen(zName))<4 || nName>UUID_SIZE
|| !validate16(zName,nName) ){
@ <span class="tktError">Not a valid ticket id: "%h(zName)"</span>
style_footer();
return;
}
nRec = db_int(0, "SELECT count(*) FROM ticket WHERE tkt_uuid GLOB '%q*'",
zName);
if( nRec==0 ){
@ <span class="tktError">No such ticket: "%h(zName)"</span>
style_footer();
return;
}
if( nRec>1 ){
@ <span class="tktError">%d(nRec) tickets begin with:
@ "%h(zName)"</span>
style_footer();
return;
}
if( g.thTrace ) Th_Trace("BEGIN_TKTEDIT<br />\n", -1);
ticket_init();
getAllTicketFields();
initializeVariablesFromCGI();
|
| ︙ | ︙ |
Changes to src/unicode.c.
| ︙ | ︙ | |||
50 51 52 53 54 55 56 |
0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F, 0x001B9C07,
0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401, 0x001CC01B,
0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804, 0x00206C09,
0x00209403, 0x0020A405, 0x0020C00F, 0x00216403, 0x00217801,
0x00235030, 0x0024E803, 0x0024F812, 0x00254407, 0x00258804,
0x0025C001, 0x00260403, 0x0026F001, 0x0026F807, 0x00271C02,
0x00272C03, 0x00275C01, 0x00278802, 0x0027C802, 0x0027E802,
| | | | | | | | | | > | | | | | | | | | | | < > | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | > | | | | | | | | | | | | | < | | | | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F, 0x001B9C07,
0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401, 0x001CC01B,
0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804, 0x00206C09,
0x00209403, 0x0020A405, 0x0020C00F, 0x00216403, 0x00217801,
0x00235030, 0x0024E803, 0x0024F812, 0x00254407, 0x00258804,
0x0025C001, 0x00260403, 0x0026F001, 0x0026F807, 0x00271C02,
0x00272C03, 0x00275C01, 0x00278802, 0x0027C802, 0x0027E802,
0x0027F401, 0x00280403, 0x0028F001, 0x0028F805, 0x00291C02,
0x00292C03, 0x00294401, 0x0029C002, 0x0029D401, 0x002A0403,
0x002AF001, 0x002AF808, 0x002B1C03, 0x002B2C03, 0x002B8802,
0x002BC002, 0x002BE806, 0x002C0403, 0x002CF001, 0x002CF807,
0x002D1C02, 0x002D2C03, 0x002D5802, 0x002D8802, 0x002DC001,
0x002E0801, 0x002EF805, 0x002F1803, 0x002F2804, 0x002F5C01,
0x002FCC08, 0x00300004, 0x0030F807, 0x00311803, 0x00312804,
0x00315402, 0x00318802, 0x0031FC01, 0x00320403, 0x0032F001,
0x0032F807, 0x00331803, 0x00332804, 0x00335402, 0x00338802,
0x00340004, 0x0034EC02, 0x0034F807, 0x00351803, 0x00352804,
0x00353C01, 0x00355C01, 0x00358802, 0x0035E401, 0x00360802,
0x00372801, 0x00373C06, 0x00375801, 0x00376008, 0x0037C803,
0x0038C401, 0x0038D007, 0x0038FC01, 0x00391C09, 0x00396802,
0x003AC401, 0x003AD006, 0x003AEC02, 0x003B2006, 0x003C041F,
0x003CD00C, 0x003DC417, 0x003E340B, 0x003E6424, 0x003EF80F,
0x003F380D, 0x0040AC14, 0x00412806, 0x00415804, 0x00417803,
0x00418803, 0x00419C07, 0x0041C404, 0x0042080C, 0x00423C01,
0x00426806, 0x0043EC01, 0x004D740C, 0x004E400A, 0x00500001,
0x0059B402, 0x005A0001, 0x005A6C02, 0x005BAC03, 0x005C4803,
0x005CC805, 0x005D4802, 0x005DC802, 0x005ED023, 0x005F6004,
0x005F7401, 0x0060000F, 0x00621402, 0x0062A401, 0x0064800C,
0x0064C00C, 0x00650001, 0x00651002, 0x00677822, 0x00685C05,
0x00687802, 0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007,
0x006AA006, 0x006AC00F, 0x006C0005, 0x006CD011, 0x006D6823,
0x006E0003, 0x006E840D, 0x006F980E, 0x006FF004, 0x00709014,
0x0070EC05, 0x0071F802, 0x00730008, 0x00734019, 0x0073B401,
0x0073C803, 0x0073DC03, 0x0077003A, 0x0077EC05, 0x007EF401,
0x007EFC03, 0x007F3403, 0x007F7403, 0x007FB403, 0x007FF402,
0x00800065, 0x0081980A, 0x0081E805, 0x00822805, 0x00828020,
0x00834021, 0x00840002, 0x00840C04, 0x00842002, 0x00845001,
0x00845803, 0x00847806, 0x00849401, 0x00849C01, 0x0084A401,
0x0084B801, 0x0084E802, 0x00850005, 0x00852804, 0x00853C01,
0x00862802, 0x00864297, 0x0091000B, 0x0092704E, 0x00940276,
0x009E53E0, 0x00ADD820, 0x00AE6022, 0x00AEF40C, 0x00AF2809,
0x00AFB004, 0x00B39406, 0x00B3BC03, 0x00B3E404, 0x00B3F802,
0x00B5C001, 0x00B5FC01, 0x00B7804F, 0x00B8C01A, 0x00BA001A,
0x00BA6C59, 0x00BC00D6, 0x00BFC00C, 0x00C00005, 0x00C02019,
0x00C0A807, 0x00C0D802, 0x00C0F403, 0x00C26404, 0x00C28001,
0x00C3EC01, 0x00C64002, 0x00C6580A, 0x00C70024, 0x00C8001F,
0x00C8A81E, 0x00C94001, 0x00C98020, 0x00CA2827, 0x00CB003F,
0x00CC0100, 0x01370040, 0x02924037, 0x0293F802, 0x02983403,
0x0299BC10, 0x029A7802, 0x029BC008, 0x029C0017, 0x029C8002,
0x029E2402, 0x02A00801, 0x02A01801, 0x02A02C01, 0x02A08C09,
0x02A0D804, 0x02A1D004, 0x02A20002, 0x02A2D012, 0x02A33802,
0x02A38012, 0x02A3E003, 0x02A3F001, 0x02A4980A, 0x02A51C0D,
0x02A57C01, 0x02A60004, 0x02A6CC1B, 0x02A77802, 0x02A79401,
0x02A8A40E, 0x02A90C01, 0x02A93002, 0x02A97004, 0x02A9DC03,
0x02A9EC03, 0x02AAC001, 0x02AAC803, 0x02AADC02, 0x02AAF802,
0x02AB0401, 0x02AB7802, 0x02ABAC07, 0x02ABD402, 0x02AD6C01,
0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02, 0x037FFC01,
0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802, 0x03F7F002,
0x03F8001A, 0x03F88033, 0x03F95013, 0x03F9A004, 0x03FBFC01,
0x03FC040F, 0x03FC6807, 0x03FCEC06, 0x03FD6C0B, 0x03FF8007,
0x03FFA007, 0x03FFE405, 0x04040003, 0x0404DC09, 0x0405E411,
0x04063003, 0x0406400C, 0x04068001, 0x0407402E, 0x040B8001,
0x040DD805, 0x040E7C01, 0x040F4001, 0x0415BC01, 0x04215C01,
0x0421DC02, 0x04247C01, 0x0424FC01, 0x04280403, 0x04281402,
0x04283004, 0x0428E003, 0x0428FC01, 0x04294009, 0x0429FC01,
0x042B2001, 0x042B9402, 0x042BC007, 0x042CE407, 0x042E6404,
0x04400003, 0x0440E016, 0x0441FC04, 0x0442C012, 0x04440003,
0x04449C0E, 0x04450004, 0x0445CC03, 0x04460003, 0x0446CC0E,
0x04471409, 0x04476C01, 0x04477403, 0x0448B013, 0x044AA401,
0x044B7C0C, 0x044C0004, 0x044CF001, 0x044CF807, 0x044D1C02,
0x044D2C03, 0x044D5C01, 0x044D8802, 0x044D9807, 0x044DC005,
0x0450D412, 0x04512C05, 0x04516C01, 0x04517401, 0x0452C014,
0x04531801, 0x0456BC07, 0x0456E020, 0x04577002, 0x0458C014,
0x0459800D, 0x045AAC0D, 0x045C740F, 0x045CF004, 0x0468040A,
0x0468CC07, 0x0468EC0D, 0x0469440B, 0x046A2813, 0x046A7805,
0x0470BC08, 0x0470E008, 0x04710405, 0x0471C002, 0x04724816,
0x0472A40E, 0x0474C406, 0x0474E801, 0x0474F002, 0x0474FC07,
0x04751C01, 0x0491C005, 0x05A9B802, 0x05ABC006, 0x05ACC010,
0x05AD1002, 0x05BD442E, 0x05BE3C04, 0x06F27008, 0x074000F6,
0x07440027, 0x0744A4C0, 0x07480046, 0x074C0057, 0x075B0401,
0x075B6C01, 0x075BEC01, 0x075C5401, 0x075CD401, 0x075D3C01,
0x075DBC01, 0x075E2401, 0x075EA401, 0x075F0C01, 0x0760028C,
0x076A6C05, 0x076A840F, 0x07800007, 0x07802011, 0x07806C07,
0x07808C02, 0x07809805, 0x07A34007, 0x07A51007, 0x07A57802,
0x07BBC002, 0x07C0002C, 0x07C0C064, 0x07C2800F, 0x07C2C40F,
0x07C3040F, 0x07C34425, 0x07C4401F, 0x07C4C03C, 0x07C5C03D,
0x07C7981D, 0x07C8402C, 0x07C90009, 0x07C94002, 0x07C98006,
0x07CC03D5, 0x07DB800D, 0x07DBC009, 0x07DC0074, 0x07DE0055,
0x07E0000C, 0x07E04038, 0x07E1400A, 0x07E18028, 0x07E2401E,
0x07E4000C, 0x07E4402F, 0x07E5000D, 0x07E5401C, 0x07E60018,
0x07E70001, 0x07E74017, 0x38000401, 0x38008060, 0x380400F0,
};
static const unsigned int aAscii[4] = {
0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001,
};
if( (unsigned int)c<128 ){
return ( (aAscii[c >> 5] & ((unsigned int)1 << (c & 0x001F)))==0 );
}else if( (unsigned int)c<(1<<22) ){
unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;
int iRes = 0;
int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;
int iLo = 0;
while( iHi>=iLo ){
int iTest = (iHi + iLo) / 2;
if( key >= aEntry[iTest] ){
iRes = iTest;
iLo = iTest+1;
}else{
|
| ︙ | ︙ | |||
199 200 201 202 203 204 205 |
'h', 'i', 'k', 'l', 'l', 'm', 'n', 'p', 'r', 'r', 's', 't',
'u', 'v', 'w', 'w', 'x', 'y', 'z', 'h', 't', 'w', 'y', 'a',
'e', 'i', 'o', 'u', 'y',
};
unsigned int key = (((unsigned int)c)<<3) | 0x00000007;
int iRes = 0;
| | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
'h', 'i', 'k', 'l', 'l', 'm', 'n', 'p', 'r', 'r', 's', 't',
'u', 'v', 'w', 'w', 'x', 'y', 'z', 'h', 't', 'w', 'y', 'a',
'e', 'i', 'o', 'u', 'y',
};
unsigned int key = (((unsigned int)c)<<3) | 0x00000007;
int iRes = 0;
int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;
int iLo = 0;
while( iHi>=iLo ){
int iTest = (iHi + iLo) / 2;
if( key >= aDia[iTest] ){
iRes = iTest;
iLo = iTest+1;
}else{
|
| ︙ | ︙ | |||
346 347 348 349 350 351 352 |
assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );
if( c<128 ){
if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');
}else if( c<65536 ){
const struct TableEntry *p;
| | | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );
if( c<128 ){
if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');
}else if( c<65536 ){
const struct TableEntry *p;
int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;
int iLo = 0;
int iRes = -1;
assert( c>aEntry[0].iCode );
while( iHi>=iLo ){
int iTest = (iHi + iLo) / 2;
int cmp = (c - aEntry[iTest].iCode);
|
| ︙ | ︙ |
Changes to src/unversioned.c.
| ︙ | ︙ | |||
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
if( zMtime==0 ){
mtime = time(0);
}else{
mtime = db_int(0, "SELECT strftime('%%s',%Q)", zMtime);
if( mtime<=0 ) fossil_fatal("bad timestamp: %Q", zMtime);
}
if( memcmp(zCmd, "add", nCmd)==0 ){
const char *zIn;
const char *zAs;
Blob file;
int i;
zAs = find_option("as",0,1);
if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE");
verify_all_options();
db_begin_transaction();
content_rcvid_init("#!fossil unversioned add");
for(i=3; i<g.argc; i++){
zIn = zAs ? zAs : g.argv[i];
| > > > > > | < > > > | | | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
if( zMtime==0 ){
mtime = time(0);
}else{
mtime = db_int(0, "SELECT strftime('%%s',%Q)", zMtime);
if( mtime<=0 ) fossil_fatal("bad timestamp: %Q", zMtime);
}
if( memcmp(zCmd, "add", nCmd)==0 ){
const char *zError = 0;
const char *zIn;
const char *zAs;
Blob file;
int i;
zAs = find_option("as",0,1);
if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE");
verify_all_options();
db_begin_transaction();
content_rcvid_init("#!fossil unversioned add");
for(i=3; i<g.argc; i++){
zIn = zAs ? zAs : g.argv[i];
if( zIn[0]==0 ){
zError = "be empty string";
}else if( zIn[0]=='/' ){
zError = "be absolute";
}else if ( !file_is_simple_pathname(zIn,1) ){
zError = "contain complex paths";
}else if( contains_whitespace(zIn) ){
zError = "contain whitespace";
}
if( zError ){
fossil_fatal("unversioned filenames may not %s: %Q", zError, zIn);
}
blob_init(&file,0,0);
blob_read_from_file(&file, g.argv[i]);
unversioned_write(zIn, &file, mtime);
blob_reset(&file);
}
db_end_transaction(0);
|
| ︙ | ︙ | |||
475 476 477 478 479 480 481 |
@ No unversioned files on this server
style_footer();
return;
}
if( PB("byage") ) zOrderBy = "mtime DESC";
if( PB("showdel") ) showDel = 1;
db_prepare(&q,
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > | | | | | | | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
@ No unversioned files on this server
style_footer();
return;
}
if( PB("byage") ) zOrderBy = "mtime DESC";
if( PB("showdel") ) showDel = 1;
db_prepare(&q,
"SELECT"
" name,"
" mtime,"
" hash,"
" sz,"
" (SELECT login FROM rcvfrom, user"
" WHERE user.uid=rcvfrom.uid AND rcvfrom.rcvid=unversioned.rcvid),"
" rcvid"
" FROM unversioned %s ORDER BY %s",
showDel ? "" : "WHERE hash IS NOT NULL" /*safe-for-%s*/,
zOrderBy/*safe-for-%s*/
);
iNow = db_int64(0, "SELECT strftime('%%s','now');");
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
sqlite3_int64 mtime = db_column_int(&q, 1);
const char *zHash = db_column_text(&q, 2);
int isDeleted = zHash==0;
int fullSize = db_column_int(&q, 3);
char *zAge = human_readable_age((iNow - mtime)/86400.0);
const char *zLogin = db_column_text(&q, 4);
int rcvid = db_column_int(&q,5);
if( zLogin==0 ) zLogin = "";
if( (n++)==0 ){
@ <div class="uvlist">
@ <table cellpadding="2" cellspacing="0" border="1" id="uvtab">
@ <thead><tr>
@ <th> Name
@ <th> Age
@ <th> Size
@ <th> User
@ <th> SHA1
if( g.perm.Admin ){
@ <th> rcvid
}
@ </tr></thead>
@ <tbody>
}
@ <tr>
if( isDeleted ){
sqlite3_snprintf(sizeof(zSzName), zSzName, "<i>Deleted</i>");
zHash = "";
fullSize = 0;
@ <td> %h(zName) </td>
}else{
approxSizeName(sizeof(zSzName), zSzName, fullSize);
iTotalSz += fullSize;
cnt++;
@ <td> <a href='%R/uv/%T(zName)'>%h(zName)</a> </td>
}
@ <td data-sortkey='%016llx(-mtime)'> %s(zAge) </td>
@ <td data-sortkey='%08x(fullSize)'> %s(zSzName) </td>
@ <td> %h(zLogin) </td>
@ <td> %h(zHash) </td>
if( g.perm.Admin ){
if( rcvid ){
@ <td> <a href="%R/rcvfrom?rcvid=%d(rcvid)">%d(rcvid)</a>
}else{
@ <td>
}
}
@ </tr>
fossil_free(zAge);
}
db_finalize(&q);
if( n ){
approxSizeName(sizeof(zSzName), zSzName, iTotalSz);
@ </tbody>
@ <tfoot><tr><td><b>Total over %d(cnt) files</b><td><td>%s(zSzName)
@ <td><td>
if( g.perm.Admin ){
@ <td>
}
@ </tfoot>
@ </table></div>
output_table_sorting_javascript("uvtab","tkKttN",1);
}else{
@ No unversioned files on this server.
}
style_footer();
}
/*
** WEBPAGE: juvlist
**
** Return a complete list of unversioned files as JSON. The JSON
** looks like this:
|
| ︙ | ︙ |
Changes to src/update.c.
| ︙ | ︙ | |||
93 94 95 96 97 98 99 | ** unchanged files in addition to those file that actually do change. ** ** Options: ** --case-sensitive <BOOL> override case-sensitive setting ** --debug print debug information on stdout ** --latest acceptable in place of VERSION, update to latest version ** --force-missing force update if missing content after sync | < | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | ** unchanged files in addition to those file that actually do change. ** ** Options: ** --case-sensitive <BOOL> override case-sensitive setting ** --debug print debug information on stdout ** --latest acceptable in place of VERSION, update to latest version ** --force-missing force update if missing content after sync ** -n|--dry-run If given, display instead of run actions ** -v|--verbose print status information about all files ** -W|--width <num> Width of lines (default is to auto-detect). Must be >20 ** or 0 (= no limit, resulting in a single line per entry). ** ** See also: revert */ |
| ︙ | ︙ |
Changes to src/url.c.
| ︙ | ︙ | |||
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
** Flags for url_parse()
*/
#define URL_PROMPT_PW 0x001 /* Prompt for password if needed */
#define URL_REMEMBER 0x002 /* Remember the url for later reuse */
#define URL_ASK_REMEMBER_PW 0x004 /* Ask whether to remember prompted pw */
#define URL_REMEMBER_PW 0x008 /* Should remember pw */
#define URL_PROMPTED 0x010 /* Prompted for PW already */
/*
** The URL related data used with this subsystem.
*/
struct UrlData {
int isFile; /* True if a "file:" url */
int isHttps; /* True if a "https:" url */
| > | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
** Flags for url_parse()
*/
#define URL_PROMPT_PW 0x001 /* Prompt for password if needed */
#define URL_REMEMBER 0x002 /* Remember the url for later reuse */
#define URL_ASK_REMEMBER_PW 0x004 /* Ask whether to remember prompted pw */
#define URL_REMEMBER_PW 0x008 /* Should remember pw */
#define URL_PROMPTED 0x010 /* Prompted for PW already */
#define URL_OMIT_USER 0x020 /* Omit the user name from URL */
/*
** The URL related data used with this subsystem.
*/
struct UrlData {
int isFile; /* True if a "file:" url */
int isHttps; /* True if a "https:" url */
|
| ︙ | ︙ | |||
151 152 153 154 155 156 157 |
}
pUrlData->passwd = mprintf("%.*s", i-j-1, &zUrl[j+1]);
dehttpize(pUrlData->passwd);
}
if( pUrlData->isSsh ){
urlFlags &= ~URL_ASK_REMEMBER_PW;
}
| > > > | > | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
}
pUrlData->passwd = mprintf("%.*s", i-j-1, &zUrl[j+1]);
dehttpize(pUrlData->passwd);
}
if( pUrlData->isSsh ){
urlFlags &= ~URL_ASK_REMEMBER_PW;
}
if( urlFlags & URL_OMIT_USER ){
zLogin = mprintf("");
}else{
zLogin = mprintf("%t@", pUrlData->user);
}
for(j=i+1; (c=zUrl[j])!=0 && c!='/' && c!=':'; j++){}
pUrlData->name = mprintf("%.*s", j-i-1, &zUrl[i+1]);
i = j;
}else{
int inSquare = 0;
int n;
for(i=iStart; (c=zUrl[i])!=0 && c!='/' && (inSquare || c!=':'); i++){
|
| ︙ | ︙ |
Changes to src/user.c.
| ︙ | ︙ | |||
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
static char *zPwdBuffer = 0;
static size_t nPwdBuffer = 0;
static char *getpass(const char *prompt){
char *zPwd;
size_t nPwd;
size_t i;
if( zPwdBuffer==0 ){
zPwdBuffer = fossil_secure_alloc_page(&nPwdBuffer);
assert( zPwdBuffer );
}else{
fossil_secure_zero(zPwdBuffer, nPwdBuffer);
}
zPwd = zPwdBuffer;
nPwd = nPwdBuffer;
fputs(prompt,stderr);
fflush(stderr);
assert( zPwd!=0 );
assert( nPwd>0 );
for(i=0; i<nPwd-1; ++i){
#if defined(_WIN32)
| > > > | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
static char *zPwdBuffer = 0;
static size_t nPwdBuffer = 0;
static char *getpass(const char *prompt){
char *zPwd;
size_t nPwd;
size_t i;
#if defined(_WIN32)
int useGetch = _isatty(_fileno(stderr));
#endif
if( zPwdBuffer==0 ){
zPwdBuffer = fossil_secure_alloc_page(&nPwdBuffer);
assert( zPwdBuffer );
}else{
fossil_secure_zero(zPwdBuffer, nPwdBuffer);
}
zPwd = zPwdBuffer;
nPwd = nPwdBuffer;
fputs(prompt,stderr);
fflush(stderr);
assert( zPwd!=0 );
assert( nPwd>0 );
for(i=0; i<nPwd-1; ++i){
#if defined(_WIN32)
zPwd[i] = useGetch ? _getch() : getc(stdin);
#else
zPwd[i] = getc(stdin);
#endif
if(zPwd[i]=='\r' || zPwd[i]=='\n'){
break;
}
/* BS or DEL */
|
| ︙ | ︙ | |||
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
}
/* ESC */
else if(zPwd[i]==27){
i=0;
break;
}
else{
fputc('*',stderr);
}
}
zPwd[i]='\0';
fputs("\n", stderr);
assert( zPwd==zPwdBuffer );
return zPwd;
| > > > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
}
/* ESC */
else if(zPwd[i]==27){
i=0;
break;
}
else{
#if defined(_WIN32)
if( useGetch )
#endif
fputc('*',stderr);
}
}
zPwd[i]='\0';
fputs("\n", stderr);
assert( zPwd==zPwdBuffer );
return zPwd;
|
| ︙ | ︙ | |||
581 582 583 584 585 586 587 |
** Prompts the user for input and then prints it verbatim (i.e. without
** a trailing line terminator).
*/
void test_prompt_user_cmd(void){
Blob answer;
if( g.argc!=3 ) usage("PROMPT");
prompt_user(g.argv[2], &answer);
| | > > > > > > > > > > > > > > > > > > > > > > > > > > | 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
** Prompts the user for input and then prints it verbatim (i.e. without
** a trailing line terminator).
*/
void test_prompt_user_cmd(void){
Blob answer;
if( g.argc!=3 ) usage("PROMPT");
prompt_user(g.argv[2], &answer);
fossil_print("%s\n", blob_str(&answer));
}
/*
** COMMAND: test-prompt-password
**
** Usage: %fossil test-prompt-password PROMPT VERIFY
**
** Prompts the user for a password and then prints it verbatim.
**
** Behavior is controlled by the VERIFY parameter:
**
** 0 Just ask once.
**
** 1 If the first answer is a non-empty string, ask for
** verification. Repeat if the two strings do not match.
**
** 2 Ask twice, repeat if the strings do not match.
*/
void test_prompt_password_cmd(void){
Blob answer;
int iVerify = 0;
if( g.argc!=4 ) usage("PROMPT VERIFY");
iVerify = atoi(g.argv[3]);
prompt_for_password(g.argv[2], &answer, iVerify);
fossil_print("[%s]\n", blob_str(&answer));
}
/*
** WEBPAGE: access_log
**
** Show login attempts, including timestamp and IP address.
** Requires Admin privileges.
|
| ︙ | ︙ |
Changes to src/util.c.
| ︙ | ︙ | |||
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | ** either via CGI, SCGI, or direct HTTP. The following assert verifies ** this. And the following assert proves that Fossil is not vulnerable ** to the ShellShock or BashDoor bug. */ assert( g.cgiOutput==0 ); /* The regular system() call works to get a shell on unix */ rc = system(zOrigCmd); #endif return rc; } /* ** Like strcmp() except that it accepts NULL pointers. NULL sorts before ** all non-NULL string pointers. Also, this strcmp() is a binary comparison | > > | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | ** either via CGI, SCGI, or direct HTTP. The following assert verifies ** this. And the following assert proves that Fossil is not vulnerable ** to the ShellShock or BashDoor bug. */ assert( g.cgiOutput==0 ); /* The regular system() call works to get a shell on unix */ fossil_limit_memory(0); rc = system(zOrigCmd); fossil_limit_memory(1); #endif return rc; } /* ** Like strcmp() except that it accepts NULL pointers. NULL sorts before ** all non-NULL string pointers. Also, this strcmp() is a binary comparison |
| ︙ | ︙ | |||
445 446 447 448 449 450 451 |
}else{
sqlite3_open("",&db);
}
sqlite3_file_control(db, 0, SQLITE_FCNTL_TEMPFILENAME, (void*)&zTFile);
if( g.db==0 ) sqlite3_close(db);
return zTFile;
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
}else{
sqlite3_open("",&db);
}
sqlite3_file_control(db, 0, SQLITE_FCNTL_TEMPFILENAME, (void*)&zTFile);
if( g.db==0 ) sqlite3_close(db);
return zTFile;
}
/*
** Turn memory limits for stack and heap on and off. The argument
** is true to turn memory limits on and false to turn them off.
**
** Memory limits should be enabled at startup, but then turned off
** before starting subprocesses.
*/
void fossil_limit_memory(int onOff){
#if defined(__unix__)
static sqlite3_int64 origHeap = 10000000000LL; /* 10GB */
static sqlite3_int64 origStack = 8000000 ; /* 8MB */
struct rlimit x;
#if defined(RLIMIT_DATA)
getrlimit(RLIMIT_DATA, &x);
if( onOff ){
origHeap = x.rlim_cur;
if( sizeof(void*)<8 || sizeof(x.rlim_cur)<8 ){
x.rlim_cur = 1000000000 ; /* 1GB on 32-bit systems */
}else{
x.rlim_cur = 10000000000LL; /* 10GB on 64-bit systems */
}
}else{
x.rlim_cur = origHeap;
}
setrlimit(RLIMIT_DATA, &x);
#endif /* defined(RLIMIT_DATA) */
#if defined(RLIMIT_STACK)
getrlimit(RLIMIT_STACK, &x);
if( onOff ){
origStack = x.rlim_cur;
x.rlim_cur = 8000000; /* 8MB */
}else{
x.rlim_cur = origStack;
}
setrlimit(RLIMIT_STACK, &x);
#endif /* defined(RLIMIT_STACK) */
#endif /* defined(__unix__) */
}
|
Changes to src/vfile.c.
| ︙ | ︙ | |||
794 795 796 797 798 799 800 |
}
/*
** Do a file-by-file comparison of the content of the repository and
** the working check-out on disk. Report any errors.
*/
void vfile_compare_repository_to_disk(int vid){
| | | 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 |
}
/*
** Do a file-by-file comparison of the content of the repository and
** the working check-out on disk. Report any errors.
*/
void vfile_compare_repository_to_disk(int vid){
sqlite3_int64 rc;
Stmt q;
Blob disk, repo;
char *zOut;
db_must_be_within_tree();
db_prepare(&q,
"SELECT %Q || pathname, pathname, rid FROM vfile"
|
| ︙ | ︙ |
Changes to src/wiki.c.
| ︙ | ︙ | |||
408 409 410 411 412 413 414 |
/*
** Write a wiki artifact into the repository
*/
static void wiki_put(Blob *pWiki, int parent, int needMod){
int nrid;
if( !needMod ){
nrid = content_put_ex(pWiki, 0, 0, 0, 0);
| | | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
/*
** Write a wiki artifact into the repository
*/
static void wiki_put(Blob *pWiki, int parent, int needMod){
int nrid;
if( !needMod ){
nrid = content_put_ex(pWiki, 0, 0, 0, 0);
if( parent) content_deltify(parent, &nrid, 1, 0);
}else{
nrid = content_put_ex(pWiki, 0, 0, 0, 1);
moderation_table_create();
db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", nrid);
|
| ︙ | ︙ | |||
1423 1424 1425 1426 1427 1428 1429 |
** Usage: %fossil test-markdown-render FILE
**
** Render markdown wiki from FILE to stdout.
**
*/
void test_markdown_render(void){
Blob in, out;
| < | 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 |
** Usage: %fossil test-markdown-render FILE
**
** Render markdown wiki from FILE to stdout.
**
*/
void test_markdown_render(void){
Blob in, out;
verify_all_options();
if( g.argc!=3 ) usage("FILE");
blob_zero(&out);
blob_read_from_file(&in, g.argv[2]);
markdown_to_html(&in, 0, &out);
blob_write_to_file(&out, "-");
}
|
Changes to src/wikiformat.c.
| ︙ | ︙ | |||
1063 1064 1065 1066 1067 1068 1069 | } } /* ** If the input string corresponds to an existing baseline, ** return true. */ | | | | | 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
}
}
/*
** If the input string corresponds to an existing baseline,
** return true.
*/
static int is_valid_hname(const char *z){
int n = strlen(z);
if( n<4 || n>HNAME_MAX ) return 0;
if( !validate16(z, n) ) return 0;
return 1;
}
/*
** Return TRUE if a hash name corresponds to an artifact in this
** repository.
*/
static int in_this_repo(const char *zUuid){
static Stmt q;
int rc;
int n;
char zU2[HNAME_MAX+1];
db_static_prepare(&q,
"SELECT 1 FROM blob WHERE uuid>=:u AND uuid<:u2"
);
db_bind_text(&q, ":u", zUuid);
n = (int)strlen(zUuid);
if( n>=sizeof(zU2) ) n = sizeof(zU2)-1;
memcpy(zU2, zUuid, n);
|
| ︙ | ︙ | |||
1214 1215 1216 1217 1218 1219 1220 |
blob_appendf(p->pOut, "<a href=\"%R%h\">", zTarget);
}else if( zTarget[0]=='.'
&& (zTarget[1]=='/' || (zTarget[1]=='.' && zTarget[2]=='/'))
&& (p->state & WIKI_LINKSONLY)==0 ){
blob_appendf(p->pOut, "<a href=\"%h\">", zTarget);
}else if( zTarget[0]=='#' ){
blob_appendf(p->pOut, "<a href=\"%h\">", zTarget);
| | | | 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 |
blob_appendf(p->pOut, "<a href=\"%R%h\">", zTarget);
}else if( zTarget[0]=='.'
&& (zTarget[1]=='/' || (zTarget[1]=='.' && zTarget[2]=='/'))
&& (p->state & WIKI_LINKSONLY)==0 ){
blob_appendf(p->pOut, "<a href=\"%h\">", zTarget);
}else if( zTarget[0]=='#' ){
blob_appendf(p->pOut, "<a href=\"%h\">", zTarget);
}else if( is_valid_hname(zTarget) ){
int isClosed = 0;
if( strlen(zTarget)<=UUID_SIZE && is_ticket(zTarget, &isClosed) ){
/* Special display processing for tickets. Display the hyperlink
** as crossed out if the ticket is closed.
*/
if( isClosed ){
if( g.perm.Hyperlink ){
blob_appendf(p->pOut,
"%z<span class=\"wikiTagCancelled\">[",
|
| ︙ | ︙ | |||
1736 1737 1738 1739 1740 1741 1742 |
int flags = 0;
if( find_option("buttons",0,0)!=0 ) flags |= WIKI_BUTTONS;
if( find_option("htmlonly",0,0)!=0 ) flags |= WIKI_HTMLONLY;
if( find_option("linksonly",0,0)!=0 ) flags |= WIKI_LINKSONLY;
if( find_option("nobadlinks",0,0)!=0 ) flags |= WIKI_NOBADLINKS;
if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE;
if( find_option("noblock",0,0)!=0 ) flags |= WIKI_NOBLOCK;
| < | 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 |
int flags = 0;
if( find_option("buttons",0,0)!=0 ) flags |= WIKI_BUTTONS;
if( find_option("htmlonly",0,0)!=0 ) flags |= WIKI_HTMLONLY;
if( find_option("linksonly",0,0)!=0 ) flags |= WIKI_LINKSONLY;
if( find_option("nobadlinks",0,0)!=0 ) flags |= WIKI_NOBADLINKS;
if( find_option("inline",0,0)!=0 ) flags |= WIKI_INLINE;
if( find_option("noblock",0,0)!=0 ) flags |= WIKI_NOBLOCK;
verify_all_options();
if( g.argc!=3 ) usage("FILE");
blob_zero(&out);
blob_read_from_file(&in, g.argv[2]);
wiki_convert(&in, &out, flags);
blob_write_to_file(&out, "-");
}
|
| ︙ | ︙ | |||
1837 1838 1839 1840 1841 1842 1843 |
char zLink[42];
zTarget = &z[1];
for(i=0; zTarget[i] && zTarget[i]!='|' && zTarget[i]!=']'; i++){}
while(i>1 && zTarget[i-1]==' '){ i--; }
c = zTarget[i];
zTarget[i] = 0;
| | | 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 |
char zLink[42];
zTarget = &z[1];
for(i=0; zTarget[i] && zTarget[i]!='|' && zTarget[i]!=']'; i++){}
while(i>1 && zTarget[i-1]==' '){ i--; }
c = zTarget[i];
zTarget[i] = 0;
if( is_valid_hname(zTarget) ){
memcpy(zLink, zTarget, i+1);
canonical16(zLink, i);
db_multi_exec(
"REPLACE INTO backlink(target,srctype,srcid,mtime)"
"VALUES(%Q,%d,%d,%g)", zLink, srctype, srcid, mtime
);
}
|
| ︙ | ︙ |
Changes to src/winhttp.c.
| ︙ | ︙ | |||
304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
WSADATA wd;
SOCKET s = INVALID_SOCKET;
SOCKADDR_IN addr;
int idCnt = 0;
int iPort = mnPort;
Blob options;
wchar_t zTmpPath[MAX_PATH];
#if USE_SEE
const char *zSavedKey = 0;
size_t savedKeySize = 0;
#endif
blob_zero(&options);
if( zBaseUrl ){
| > | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
WSADATA wd;
SOCKET s = INVALID_SOCKET;
SOCKADDR_IN addr;
int idCnt = 0;
int iPort = mnPort;
Blob options;
wchar_t zTmpPath[MAX_PATH];
const char *zSkin;
#if USE_SEE
const char *zSavedKey = 0;
size_t savedKeySize = 0;
#endif
blob_zero(&options);
if( zBaseUrl ){
|
| ︙ | ︙ | |||
328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
}
if( g.thTrace ){
blob_appendf(&options, " --th-trace");
}
if( flags & HTTP_SERVER_REPOLIST ){
blob_appendf(&options, " --repolist");
}
#if USE_SEE
zSavedKey = db_get_saved_encryption_key();
savedKeySize = db_get_saved_encryption_key_size();
if( zSavedKey!=0 && savedKeySize>0 ){
blob_appendf(&options, " --usepidkey %lu:%p:%u", GetCurrentProcessId(),
zSavedKey, savedKeySize);
}
| > > > > | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
}
if( g.thTrace ){
blob_appendf(&options, " --th-trace");
}
if( flags & HTTP_SERVER_REPOLIST ){
blob_appendf(&options, " --repolist");
}
zSkin = skin_in_use();
if( zSkin ){
blob_appendf(&options, " --skin %s", zSkin);
}
#if USE_SEE
zSavedKey = db_get_saved_encryption_key();
savedKeySize = db_get_saved_encryption_key_size();
if( zSavedKey!=0 && savedKeySize>0 ){
blob_appendf(&options, " --usepidkey %lu:%p:%u", GetCurrentProcessId(),
zSavedKey, savedKeySize);
}
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
360 361 362 363 364 365 366 |
db_prepare(&q,
"UPDATE unversioned"
" SET rcvid=:rcvid, mtime=:mtime, hash=NULL,"
" sz=0, encoding=0, content=NULL"
" WHERE name=:name"
);
db_bind_int(&q, ":rcvid", g.rcvid);
| | | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
db_prepare(&q,
"UPDATE unversioned"
" SET rcvid=:rcvid, mtime=:mtime, hash=NULL,"
" sz=0, encoding=0, content=NULL"
" WHERE name=:name"
);
db_bind_int(&q, ":rcvid", g.rcvid);
}else if( iStatus==2 ){
db_prepare(&q, "UPDATE unversioned SET mtime=:mtime WHERE name=:name");
}else{
db_prepare(&q,
"REPLACE INTO unversioned(name,rcvid,mtime,hash,sz,encoding,content)"
" VALUES(:name,:rcvid,:mtime,:hash,:sz,:encoding,:content)"
);
db_bind_int(&q, ":rcvid", g.rcvid);
|
| ︙ | ︙ | |||
1004 1005 1006 1007 1008 1009 1010 |
" AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
}
db_finalize(&q);
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 |
" AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
}
db_finalize(&q);
}
/*
** pXfer is a "pragma uv-hash HASH" card.
**
** If HASH is different from the unversioned content hash on this server,
** then send a bunch of uvigot cards, one for each entry unversioned file
** on this server.
|
| ︙ | ︙ | |||
1161 1162 1163 1164 1165 1166 1167 | int isPush = 0; int nErr = 0; Xfer xfer; int deltaFlag = 0; int isClone = 0; int nGimme = 0; int size; | < | 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 | int isPush = 0; int nErr = 0; Xfer xfer; int deltaFlag = 0; int isClone = 0; int nGimme = 0; int size; char *zNow; int rc; const char *zScript = 0; char *zUuidList = 0; int nUuidList = 0; char **pzUuidList = 0; int *pnUuidList = 0; |
| ︙ | ︙ | |||
1264 1265 1266 1267 1268 1269 1270 |
/* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
**
** Accept an unversioned file from the client.
*/
if( blob_eq(&xfer.aToken[0], "uvfile") ){
xfer_accept_unversioned_file(&xfer, g.perm.WrUnver);
if( blob_size(&xfer.err) ){
| | | 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 |
/* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
**
** Accept an unversioned file from the client.
*/
if( blob_eq(&xfer.aToken[0], "uvfile") ){
xfer_accept_unversioned_file(&xfer, g.perm.WrUnver);
if( blob_size(&xfer.err) ){
cgi_reset_content();
@ error %T(blob_str(&xfer.err))
nErr++;
break;
}
}else
/* gimme HASH
|
| ︙ | ︙ | |||
1450 1451 1452 1453 1454 1455 1456 |
char *zName = blob_str(&xfer.aToken[1]);
if( zName[0]=='/' ){
/* New style configuration transfer */
int groupMask = configure_name_to_mask(&zName[1], 0);
if( !g.perm.Admin ) groupMask &= ~CONFIGSET_USER;
if( !g.perm.RdAddr ) groupMask &= ~CONFIGSET_ADDR;
configure_send_group(xfer.pOut, groupMask, 0);
| < < < | 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 |
char *zName = blob_str(&xfer.aToken[1]);
if( zName[0]=='/' ){
/* New style configuration transfer */
int groupMask = configure_name_to_mask(&zName[1], 0);
if( !g.perm.Admin ) groupMask &= ~CONFIGSET_USER;
if( !g.perm.RdAddr ) groupMask &= ~CONFIGSET_ADDR;
configure_send_group(xfer.pOut, groupMask, 0);
}
}
}else
/* config NAME SIZE \n CONTENT
**
** Receive a configuration value from the client. This is only
|
| ︙ | ︙ | |||
1474 1475 1476 1477 1478 1479 1480 |
blob_extract(xfer.pIn, size, &content);
if( !g.perm.Admin ){
cgi_reset_content();
@ error not\sauthorized\sto\spush\sconfiguration
nErr++;
break;
}
| < < < < | 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 |
blob_extract(xfer.pIn, size, &content);
if( !g.perm.Admin ){
cgi_reset_content();
@ error not\sauthorized\sto\spush\sconfiguration
nErr++;
break;
}
configure_receive(zName, &content, CONFIGSET_ALL);
blob_reset(&content);
blob_seek(xfer.pIn, 1, BLOB_SEEK_CUR);
}else
/* cookie TEXT
|
| ︙ | ︙ | |||
1619 1620 1621 1622 1623 1624 1625 |
send_all(&xfer);
if( xfer.syncPrivate ) send_private(&xfer);
}else if( isPull ){
create_cluster();
send_unclustered(&xfer);
if( xfer.syncPrivate ) send_private(&xfer);
}
| < < < | 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 |
send_all(&xfer);
if( xfer.syncPrivate ) send_private(&xfer);
}else if( isPull ){
create_cluster();
send_unclustered(&xfer);
if( xfer.syncPrivate ) send_private(&xfer);
}
db_multi_exec("DROP TABLE onremote");
manifest_crosslink_end(MC_PERMIT_HOOKS);
/* Send the server timestamp last, in case prior processing happened
** to use up a significant fraction of our time window.
*/
zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')");
|
| ︙ | ︙ | |||
1882 1883 1884 1885 1886 1887 1888 |
if( zOpType==0 ) zOpType = "Pull";
zName = configure_first_name(configRcvMask);
while( zName ){
blob_appendf(&send, "reqconfig %s\n", zName);
zName = configure_next_name(configRcvMask);
nCardSent++;
}
| < < < < < < < < < < < < < < < | < | 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 |
if( zOpType==0 ) zOpType = "Pull";
zName = configure_first_name(configRcvMask);
while( zName ){
blob_appendf(&send, "reqconfig %s\n", zName);
zName = configure_next_name(configRcvMask);
nCardSent++;
}
origConfigRcvMask = configRcvMask;
configRcvMask = 0;
}
/* Send a request to sync unversioned files. On a clone, delay sending
** this until the second cycle since the login card might fail on
** the first cycle.
*/
if( (syncFlags & SYNC_UNVERSIONED)!=0
&& ((syncFlags & SYNC_CLONE)==0 || nCycle>0)
&& !uvHashSent
){
blob_appendf(&send, "pragma uv-hash %s\n", unversioned_content_hash(0));
nCardSent++;
uvHashSent = 1;
}
/* Send configuration parameters being pushed */
if( configSendMask ){
if( zOpType==0 ) zOpType = "Push";
nCardSent += configure_send_group(xfer.pOut, configSendMask, 0);
configSendMask = 0;
}
/* Send unversioned files present here on the client but missing or
** obsolete on the server.
**
** Or, if the SYNC_UV_REVERT flag is set, delete the local unversioned
|
| ︙ | ︙ | |||
2078 2079 2080 2081 2082 2083 2084 |
if( blob_eq(&xfer.aToken[0],"cfile") ){
xfer_accept_compressed_file(&xfer, 0, 0);
nArtifactRcvd++;
}else
/* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
**
| | | 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 |
if( blob_eq(&xfer.aToken[0],"cfile") ){
xfer_accept_compressed_file(&xfer, 0, 0);
nArtifactRcvd++;
}else
/* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
**
** Accept an unversioned file from the server.
*/
if( blob_eq(&xfer.aToken[0], "uvfile") ){
xfer_accept_unversioned_file(&xfer, 1);
nArtifactRcvd++;
nUvFileRcvd++;
if( syncFlags & SYNC_VERBOSE ){
fossil_print("\rUnversioned-file received: %s\n",
|
| ︙ | ︙ | |||
2384 2385 2386 2387 2388 2389 2390 |
fossil_warning("%b", &xfer.err);
nErr++;
break;
}
blobarray_reset(xfer.aToken, xfer.nToken);
blob_reset(&xfer.line);
}
| < < < < < | 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 |
fossil_warning("%b", &xfer.err);
nErr++;
break;
}
blobarray_reset(xfer.aToken, xfer.nToken);
blob_reset(&xfer.line);
}
origConfigRcvMask = 0;
if( nCardRcvd>0 && (syncFlags & SYNC_VERBOSE) ){
fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Received:",
blob_size(&recv), nCardRcvd,
xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile);
}else{
fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
|
| ︙ | ︙ |
Changes to src/zip.c.
| ︙ | ︙ | |||
370 371 372 373 374 375 376 |
}
if( (pInclude==0 || glob_match(pInclude, "manifest.tags"))
&& !glob_match(pExclude, "manifest.tags")
&& (flg & MFESTFLG_TAGS) ){
eflg |= MFESTFLG_TAGS;
}
| < | | | | < < | | | < < | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
}
if( (pInclude==0 || glob_match(pInclude, "manifest.tags"))
&& !glob_match(pExclude, "manifest.tags")
&& (flg & MFESTFLG_TAGS) ){
eflg |= MFESTFLG_TAGS;
}
if( eflg & MFESTFLG_RAW ){
blob_append(&filename, "manifest", -1);
zName = blob_str(&filename);
zip_add_folders(zName);
sterilize_manifest(&mfile);
zip_add_file(zName, &mfile, 0);
}
if( eflg & MFESTFLG_UUID ){
blob_append(&hash, "\n", 1);
blob_resize(&filename, nPrefix);
blob_append(&filename, "manifest.uuid", -1);
zName = blob_str(&filename);
zip_add_folders(zName);
zip_add_file(zName, &hash, 0);
|
| ︙ | ︙ | |||
418 419 420 421 422 423 424 |
blob_append(&filename, pFile->zName, -1);
zName = blob_str(&filename);
zip_add_folders(zName);
zip_add_file(zName, &file, manifest_file_mperm(pFile));
blob_reset(&file);
}
}
| < < > | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
blob_append(&filename, pFile->zName, -1);
zName = blob_str(&filename);
zip_add_folders(zName);
zip_add_file(zName, &file, manifest_file_mperm(pFile));
blob_reset(&file);
}
}
}
blob_reset(&mfile);
manifest_destroy(pManifest);
blob_reset(&filename);
blob_reset(&hash);
zip_close(pZip);
}
/*
|
| ︙ | ︙ | |||
470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
/* We should be done with options.. */
verify_all_options();
if( g.argc!=4 ){
usage("VERSION OUTPUTFILE");
}
rid = name_to_typed_rid(g.argv[2], "ci");
if( rid==0 ){
fossil_fatal("Check-in not found: %s", g.argv[2]);
return;
}
if( zName==0 ){
| > | 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
/* We should be done with options.. */
verify_all_options();
if( g.argc!=4 ){
usage("VERSION OUTPUTFILE");
}
g.zOpenRevision = g.argv[2];
rid = name_to_typed_rid(g.argv[2], "ci");
if( rid==0 ){
fossil_fatal("Check-in not found: %s", g.argv[2]);
return;
}
if( zName==0 ){
|
| ︙ | ︙ | |||
498 499 500 501 502 503 504 | blob_reset(&zip); } /* ** WEBPAGE: zip ** URL: /zip ** | | | | > > > > > > > | > | | > | 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
blob_reset(&zip);
}
/*
** WEBPAGE: zip
** URL: /zip
**
** Generate a ZIP archive for the check-in specified by the "r"
** query parameter. Return that ZIP archive as the HTTP reply content.
**
** Query parameters:
**
** name=NAME[.zip] The base name of the output file. The default
** value is a configuration parameter in the project
** settings. A prefix of the name, omitting the
** extension, is used as the top-most directory name.
**
** r=TAG The check-in that is turned into a ZIP archive.
** Defaults to "trunk". This query parameter used to
** be called "uuid" and the older "uuid" name is still
** accepted for backwards compatibility. If this
** query paramater is omitted, the latest "trunk"
** check-in is used.
**
** in=PATTERN Only include files that match the comma-separate
** list of GLOB patterns in PATTERN, as with ex=
**
** ex=PATTERN Omit any file that match PATTERN. PATTERN is a
** comma-separated list of GLOB patterns, where each
** pattern can optionally be quoted using ".." or '..'.
** Any file matching both ex= and in= is excluded.
*/
void baseline_zip_page(void){
int rid;
const char *z;
char *zName, *zRid, *zKey;
int nName, nRid;
const char *zInclude; /* The in= query parameter */
const char *zExclude; /* The ex= query parameter */
Blob cacheKey; /* The key to cache */
Glob *pInclude = 0; /* The compiled in= glob pattern */
Glob *pExclude = 0; /* The compiled ex= glob pattern */
Blob zip; /* ZIP archive accumulated here */
login_check_credentials();
if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
load_control();
zName = mprintf("%s", PD("name",""));
nName = strlen(zName);
z = P("r");
if( z==0 ) z = P("uuid");
if( z==0 ) z = "trunk";
g.zOpenRevision = zRid = fossil_strdup(z);
nRid = strlen(zRid);
zInclude = P("in");
if( zInclude ) pInclude = glob_create(zInclude);
zExclude = P("ex");
if( zExclude ) pExclude = glob_create(zExclude);
if( nName>4 && fossil_strcmp(&zName[nName-4], ".zip")==0 ){
/* Special case: Remove the ".zip" suffix. */
nName -= 4;
zName[nName] = 0;
}else{
/* If the file suffix is not ".zip" then just remove the
** suffix up to and including the last "." */
for(nName=strlen(zName)-1; nName>5; nName--){
if( zName[nName]=='.' ){
zName[nName] = 0;
break;
}
}
}
rid = symbolic_name_to_rid(nRid?zRid:zName, "ci");
if( rid<=0 ){
cgi_set_status(404, "Not Found");
@ Not found
return;
}
if( nRid==0 && nName>10 ) zName[10] = 0;
/* Compute a unique key for the cache entry based on query parameters */
blob_init(&cacheKey, 0, 0);
|
| ︙ | ︙ |
Changes to test/amend.test.
| ︙ | ︙ | |||
14 15 16 17 18 19 20 | # http://www.hwaci.com/drh/ # ############################################################################ # # Tests for the "amend" command. # | < < < < | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# http://www.hwaci.com/drh/
#
############################################################################
#
# Tests for the "amend" command.
#
proc artifact_from_timeline {res var} {
upvar $var artid
regexp {(?x)[0-9]{2}(?::[0-9]{2}){2}\s+\[([0-9a-f]+)]} $res m artid
}
proc manifest_comment {comment} {
string map [list { } {\\s} \n {\\n} \r {\\r}] $comment
}
proc uuid_from_commit {res var} {
upvar $var UUID
regexp {^New_Version: ([0-9a-f]{40})[0-9a-f]*$} $res m UUID
}
proc uuid_from_branch {res var} {
upvar $var UUID
regexp {^New branch: ([0-9a-f]{40})[0-9a-f]*$} $res m UUID
}
proc uuid_from_checkout {var} {
global RESULT
upvar $var UUID
fossil status
regexp {checkout:\s+([0-9a-f]{40})} $RESULT m UUID
|
| ︙ | ︙ | |||
115 116 117 118 119 120 121 |
fossil timeline -n 1
test amend-bgcolor-1.$tc.c {
[string match "*Change*background*color*to*\"$result\"*" $RESULT]
}
if {[artifact_from_timeline $RESULT artid]} {
fossil artifact $artid
test amend-bgcolor-1.$tc.d {
| | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
fossil timeline -n 1
test amend-bgcolor-1.$tc.c {
[string match "*Change*background*color*to*\"$result\"*" $RESULT]
}
if {[artifact_from_timeline $RESULT artid]} {
fossil artifact $artid
test amend-bgcolor-1.$tc.d {
[string match "*T +bgcolor $UUID* $result*" $RESULT]
}
} else {
if {$VERBOSE} { protOut "No artifact found in timeline output" }
test amend-bgcolor-1.$tc.d false
}
}
fossil amend $UUID -bgcolor {}
|
| ︙ | ︙ | |||
159 160 161 162 163 164 165 |
fossil timeline -n 1
test amend-branchcolor-1.3 {
[string match {*Change*branch*background*color*to*"yellow".*} $RESULT]
}
if {[regexp {(?x)[0-9]{2}(?::[0-9]{2}){2}\s+\[([0-9a-f]+)]} $RESULT m artid]} {
fossil artifact $artid
test amend-branchcolor-1.4 {
| | | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
fossil timeline -n 1
test amend-branchcolor-1.3 {
[string match {*Change*branch*background*color*to*"yellow".*} $RESULT]
}
if {[regexp {(?x)[0-9]{2}(?::[0-9]{2}){2}\s+\[([0-9a-f]+)]} $RESULT m artid]} {
fossil artifact $artid
test amend-branchcolor-1.4 {
[string match "*T \*bgcolor $UUID2* yellow*" $RESULT]
}
} else {
if {$VERBOSE} { protOut "No artifact found in timeline output" }
test amend-branchcolor-1.4 false
}
set UUIDN UUIDN
|
| ︙ | ︙ | |||
349 350 351 352 353 354 355 |
test amend-comment-$name.1 {
[string match "*uuid:*$UUID*comment:*$comment*" $RESULT]
}
fossil timeline -n 1
if {[artifact_from_timeline $RESULT artid]} {
fossil artifact $artid
test amend-comment-$name.2 {
| | | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
test amend-comment-$name.1 {
[string match "*uuid:*$UUID*comment:*$comment*" $RESULT]
}
fossil timeline -n 1
if {[artifact_from_timeline $RESULT artid]} {
fossil artifact $artid
test amend-comment-$name.2 {
[string match "*T +comment $UUID* *[manifest_comment $comment]*" $RESULT]
}
} else {
if {$VERBOSE} { protOut "No artifact found in timeline output: $RESULT" }
test amend-comment-$name.2 false
}
fossil timeline -n 1
test amend-comment-$name.3 {
|
| ︙ | ︙ |
Changes to test/commit-warning.test.
| ︙ | ︙ | |||
14 15 16 17 18 19 20 | # http://www.hwaci.com/drh/ # ############################################################################ # # The focus of this file is to test pre-commit warnings. # | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | < < | | | > > > > | > > > | | | | | | | | | | | | | | | | | | < | | < | | < | | < | | | | | | | < < | | | | | | | | | > > | | | | | | | | | > > | > | | | > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# http://www.hwaci.com/drh/
#
############################################################################
#
# The focus of this file is to test pre-commit warnings.
#
test_setup
# binary
write_file binary "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
# text with CRLF lines
write_file crlf.txt [subst -nocommands -novariables \
{ordinary text\r
cariage returns and line feeds\r
on several lines\r\n}]
# text with mixed line endings
write_file cr-only.txt "AAA\rBBB\rCCC\r"
write_file cr-lf-crlf.txt "AAA\rBBB\nCCC\r\n"
# unix plain text includes the empty file by generalization
write_file empty ""
write_file plain.txt {
Lorem ipsum
dolor sic amet
}
# try long lines
set a3 "abcdefgh"
set a4 $a3$a3
set a5 $a4$a4
set a6 $a5$a5
write_file line-0064 "$a6\n"
set a7 $a6$a6
set a8 $a7$a7
set a9 $a8$a8
set a10 $a9$a9
write_file line-1024 "$a10\n"
set a11 $a10$a10
set a12 $a11$a11
write_file line-4096 "$a12\n"
set a13 $a12$a12
write_file line-8192 "$a13\n"
set a14 $a13$a13
set a15 $a14$a14
set a16 $a15$a15
write_file line-64K "$a16\n"
# UTF-8 extends 7-bit ASCII using bytes 80 and above to encode
# larger character codes. Unicode uses U+0 through U+10FFFF only,
# with U+D800 through U+DFFF reserved for surrogate pairs.
# UTF-8 is valid if it is the shortest possible coding, encodes a
# valid Unicode code point. But it's complicated.
write_file utf-mod-c0-80 "11 bit NUL:\xC0\x80 is sometimes ok\n"
write_file utf-bad-e0-80-80 "16 bit NUL:\xE0\x80\x80 is bad\n"
write_file utf-bad-f0-80-80-80 "21 bit NUL:\xF0\x80\x80\x80 is bad\n"
write_file utf-bad-f8-80-80-80-80 "26 bit NUL:\xF8\x80\x80\x80\x80 is bad\n"
write_file utf-bad-fc-80-80-80-80-80 "31 bit NUL:\xFC\x80\x80\x80\x80\x80 is bad\n"
write_file utf-bad-fe-80-80-80-80-80-80 "36 bit NUL:\xFC\x80\x80\x80\x80\x80 is bad\n"
write_file utf-bad-c0-81 "overlong SOH:\xC0\x81 is bad\n"
write_file utf-bad-c0-bf "overlong '?':\xC0\xBF is bad\n"
write_file utf-bad-c1-bf "overlong DEL:\xC1\xBF is bad\n"
write_file utf-bad-f4-90-80-80 "U+110000 not allowed:\xF4\x90\x80 not unicode\n"
write_file utf-bad-f9-80-80-80-80 "U+2000000 not allowed:\xF9\x80\x80\x80\x80 not unicode\n"
write_file utf-bad-ff "no byte FF:\xFF\n"
write_file utf-ill16-lead "lead surrogate U+D800:\xED\xA0\x80 is ill formed\n"
write_file utf-ill16-trail "trail surrogate U+DC00:\xED\xB0\x80 is ill formed\n"
write_file utf-ill16-pair "surrogate pair U+10000:\xED\xA0\x80\xED\xB0\x80 is ill formed\n"
set emoji "micro-smile \xC2\xB5\xE2\x98\xBA\npale facepalm \xF0\x9F\xA4\xA6\xF0\x9F\x8F\xBB\n"
protOut $emoji
write_file utf-8-emoji $emoji
write_file utf-8-bom-emoji "\xef\xbb\xbf$emoji"
# UTF-16 uses 16-bit values to cover all valid unicode code points
# from U+0 to U+10FFFF, using surrogate pairs to escape the BMP.
# Interchange require knowing (and preserving) byte order.
set hello16LE "h\x00e\x00l\x00l\x00o\x00\n\x00"
set hello16BE "\x00h\x00e\x00l\x00l\x00o\x00\n"
write_file utf-16le-hello $hello16LE
write_file utf-16be-hello $hello16BE
set bomLE "\xff\xfe"
set bomBE "\xfe\xff"
write_file utf-16le-bomle-hello "$bomLE$hello16LE"
write_file utf-16be-bombe-hello "$bomBE$hello16BE"
write_file utf-16le-bombe-hello "$bomBE$hello16LE"
write_file utf-16be-bomle-hello "$bomLE$hello16BE"
set le16 [read_file [file join $testdir utf16le.txt]]
set be16 [read_file [file join $testdir utf16be.txt]]
write_file utf-16le.txt $le16
write_file utf-16be.txt $be16
write_file utf-nobom-16le.txt [string range $le16 2 end]
write_file utf-nobom-16be.txt [string range $be16 2 end]
#write_file [file join $::env(TEMP) utf-nobom-16le.txt] [string range $le16 2 end]
#write_file [file join $::env(TEMP) utf-nobom-16be.txt] [string range $be16 2 end]
# make all the test files known to fossil, then test
fossil addremove
fossil test-commit-warning --no-settings -v
test pre-commit-warnings-1 {[normalize_result] eq \
[subst -nocommands -novariables [string trim {
1\tbinary\tbinary data
1\tcr-lf-crlf.txt\tmixed line endings
1\tcr-only.txt\tCR line endings
1\tcrlf.txt\tCR/LF line endings
0\tempty\t
0\tline-0064\t
0\tline-1024\t
0\tline-4096\t
1\tline-64K\tlong lines
1\tline-8192\tlong lines
0\tplain.txt\t
1\tutf-16be-bombe-hello\tUnicode
1\tutf-16be-bomle-hello\tUnicode
1\tutf-16be-hello\tbinary data
1\tutf-16be.txt\tUnicode
1\tutf-16le-bombe-hello\tUnicode
1\tutf-16le-bomle-hello\tUnicode
1\tutf-16le-hello\tbinary data
1\tutf-16le.txt\tUnicode
0\tutf-8-bom-emoji\t
0\tutf-8-emoji\t
1\tutf-bad-c0-81\tinvalid UTF-8
1\tutf-bad-c0-bf\tinvalid UTF-8
1\tutf-bad-c1-bf\tinvalid UTF-8
1\tutf-bad-e0-80-80\tinvalid UTF-8
1\tutf-bad-f0-80-80-80\tinvalid UTF-8
1\tutf-bad-f4-90-80-80\tinvalid UTF-8
1\tutf-bad-f8-80-80-80-80\tinvalid UTF-8
1\tutf-bad-f9-80-80-80-80\tinvalid UTF-8
1\tutf-bad-fc-80-80-80-80-80\tinvalid UTF-8
1\tutf-bad-fe-80-80-80-80-80-80\tinvalid UTF-8
1\tutf-bad-ff\tinvalid UTF-8
0\tutf-ill16-lead\t
0\tutf-ill16-pair\t
0\tutf-ill16-trail\t
0\tutf-mod-c0-80\t
1\tutf-nobom-16be.txt\tbinary data
1\tutf-nobom-16le.txt\tbinary data
1}]]}
###############################################################################
# TODO: Change to a collection of test-case crafted files
# rather than depend on this list of files that will
# be fragile as development progresses.
#
# Unless the real goal of this test is to document a collection
# of source files that MUST NEVER BE TEXT.
#
run_in_checkout {
fossil test-commit-warning --no-settings
}
test pre-commit-warnings-fossil-1 {[normalize_result] eq \
[subst -nocommands -novariables [string trim {
1\tart/branching.odp\tbinary data
1\tart/concept1.dia\tbinary data
1\tart/concept2.dia\tbinary data
1\tcompat/zlib/contrib/blast/test.pk\tbinary data
1\tcompat/zlib/contrib/dotzlib/DotZLib.build\tCR/LF line endings
1\tcompat/zlib/contrib/dotzlib/DotZLib.chm\tbinary data
1\tcompat/zlib/contrib/dotzlib/DotZLib.sln\tCR/LF line endings
1\tcompat/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs\tCR/LF line endings
1\tcompat/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs\tinvalid UTF-8
1\tcompat/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs\tinvalid UTF-8
1\tcompat/zlib/contrib/dotzlib/DotZLib/CodecBase.cs\tinvalid UTF-8
1\tcompat/zlib/contrib/dotzlib/DotZLib/Deflater.cs\tinvalid UTF-8
1\tcompat/zlib/contrib/dotzlib/DotZLib/DotZLib.cs\tinvalid UTF-8
1\tcompat/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj\tCR/LF line endings
1\tcompat/zlib/contrib/dotzlib/DotZLib/GZipStream.cs\tinvalid UTF-8
1\tcompat/zlib/contrib/dotzlib/DotZLib/Inflater.cs\tinvalid UTF-8
1\tcompat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs\tCR/LF line endings
1\tcompat/zlib/contrib/dotzlib/LICENSE_1_0.txt\tCR/LF line endings
1\tcompat/zlib/contrib/dotzlib/readme.txt\tCR/LF line endings
1\tcompat/zlib/contrib/gcc_gvmat64/gvmat64.S\tCR/LF line endings
1\tcompat/zlib/contrib/masmx64/bld_ml64.bat\tCR/LF line endings
1\tcompat/zlib/contrib/masmx64/gvmat64.asm\tCR/LF line endings
1\tcompat/zlib/contrib/masmx64/inffas8664.c\tCR/LF line endings
1\tcompat/zlib/contrib/masmx64/inffasx64.asm\tCR/LF line endings
1\tcompat/zlib/contrib/masmx64/readme.txt\tCR/LF line endings
1\tcompat/zlib/contrib/masmx86/bld_ml32.bat\tCR/LF line endings
1\tcompat/zlib/contrib/masmx86/inffas32.asm\tCR/LF line endings
1\tcompat/zlib/contrib/masmx86/match686.asm\tCR/LF line endings
1\tcompat/zlib/contrib/masmx86/readme.txt\tCR/LF line endings
1\tcompat/zlib/contrib/puff/zeros.raw\tbinary data
1\tcompat/zlib/contrib/testzlib/testzlib.c\tCR/LF line endings
1\tcompat/zlib/contrib/testzlib/testzlib.txt\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/readme.txt\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/miniunz.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/minizip.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/testzlib.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/zlib.rc\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/zlibstat.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/zlibvc.def\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/zlibvc.sln\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/zlibvc.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc11/miniunz.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc11/minizip.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc11/testzlib.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc11/zlib.rc\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc11/zlibstat.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc11/zlibvc.def\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc11/zlibvc.sln\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc11/zlibvc.vcxproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc12/zlibvc.def\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc14/zlibvc.def\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc9/miniunz.vcproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc9/minizip.vcproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc9/testzlib.vcproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc9/testzlibdll.vcproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc9/zlib.rc\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc9/zlibstat.vcproj\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc9/zlibvc.def\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc9/zlibvc.sln\tCR/LF line endings
1\tcompat/zlib/contrib/vstudio/vc9/zlibvc.vcproj\tCR/LF line endings
1\tcompat/zlib/win32/zlib.def\tCR/LF line endings
1\tcompat/zlib/zlib.3.pdf\tbinary data
1\tcompat/zlib/zlib.map\tCR/LF line endings
1\tsetup/fossil.iss\tCR/LF line endings
1\tskins/blitz/arrow_project.png\tbinary data
1\tskins/blitz/dir.png\tbinary data
1\tskins/blitz/file.png\tbinary data
1\tskins/blitz/fossil_100.png\tbinary data
1\tskins/blitz/fossil_80_reversed_darkcyan.png\tbinary data
1\tskins/blitz/fossil_80_reversed_darkcyan_text.png\tbinary data
1\tskins/blitz/rss_20.png\tbinary data
1\tskins/bootstrap/css.txt\tlong lines
1\ttest/th1-docs-input.txt\tCR/LF line endings
1\ttest/th1-hooks-input.txt\tCR/LF line endings
1\ttest/utf16be.txt\tUnicode
1\ttest/utf16le.txt\tUnicode
1\twin/buildmsvc.bat\tCR/LF line endings
1\twin/fossil.ico\tbinary data
1\twin/fossil.rc\tinvalid UTF-8
1\twww/CollRev1.gif\tbinary data
1\twww/CollRev2.gif\tbinary data
1\twww/CollRev3.gif\tbinary data
1\twww/CollRev4.gif\tbinary data
1\twww/apple-touch-icon.png\tbinary data
1\twww/background.jpg\tbinary data
1\twww/branch01.gif\tbinary data
|
| ︙ | ︙ |
Changes to test/diff-test-1.wiki.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<title>Graph Test One</title>
This page contains list of URLs of interesting diffs.
Click on all URLs, one by one, to verify
the correct operation of the diff logic.
* <a href="../../../info/030035345c#chunk73" target="testwindow">
Multiple edits on a single line.</a> This is an SQLite version
update diff. It is a large diff and contains many other interesting
features. Scan the whole diff.
* <a href="../../../fdiff?v1=6da016415dc52d61&v2=af6df3466e3c4a88"
target="testwindow">Tricky alignment and multiple edits per line</a>.
* <a href="../../../fdiff?v1=7108d4748b111d23&v2=2303a98525b39d19#chunk3"
target="testwindow">Add a column to a table</a>
* <a href="../../../fdiff?v1=d1c60722e0b9d775&v2=58d1a8991bacb113"
target="testwindow">Column alignment with multibyte characters.</a>
The edit of a line with multibyte characters is the first chunk.
* <a href="../../../fdiff?v1=57b0d8183cab0e3d&v2=37b3ef49d73cdfe6"
target="testwindow">Large diff of sqlite3.c</a>. This diff was very
slow prior to the performance enhancement change [9e15437e97].
* <a href="../../../info/bda00cbada#chunk49" target="testwindow">
| > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<title>Graph Test One</title>
This page contains list of URLs of interesting diffs.
Click on all URLs, one by one, to verify
the correct operation of the diff logic.
For correct testing, many of these require <tt>show-version-diffs</tt>
to be enabled in the [/setup_timeline|Timeline Display Preferences]
configuration page.
* <a href="../../../info/030035345c#chunk73" target="testwindow">
Multiple edits on a single line.</a> This is an SQLite version
update diff. It is a large diff and contains many other interesting
features. Scan the whole diff.
* <a href="../../../fdiff?v1=6da016415dc52d61&v2=af6df3466e3c4a88"
target="testwindow">Tricky alignment and multiple edits per line</a>.
* <a href="../../../fdiff?v1=7108d4748b111d23&v2=2303a98525b39d19#chunk3"
target="testwindow">Add a column to a table</a>
* <a href="../../../fdiff?v1=d1c60722e0b9d775&v2=58d1a8991bacb113"
target="testwindow">Column alignment with multibyte characters.</a>
The edit of a line with multibyte characters is the first chunk.
* <a href="../../../fdiff?v1=57b0d8183cab0e3d&v2=37b3ef49d73cdfe6"
target="testwindow">Large diff of sqlite3.c</a>. This diff was very
slow prior to the performance enhancement change [9e15437e97].
* <a href="../../../info/bda00cbada#chunk49" target="testwindow">
A difficult indentation change.</a>
* <a href="../../../fdiff?v1=955cc67ace8fb622&v2=e2e1c87b86664b45#chunk13"
target="testwindow">Another tricky indentation.</a> Notice especially
lines 59398 and 59407 on the left.
* <a href="../../../fdiff?v2=955cc67ace8fb622&v1=e2e1c87b86664b45#chunk13"
target="testwindow">Inverse of the previous.</a>
* <a href="../../../fdiff?v1=955cc67ace8fb622&v2=e2e1c87b86664b45#chunk24"
target="testwindow">A complex change</a> that is difficult to align, and
|
| ︙ | ︙ |
Changes to test/fileage-test-1.wiki.
1 2 | This page contains URLs for file-age computations that have given | | | 1 2 3 4 5 6 7 8 9 10 |
This page contains URLs for file-age computations that have given
trouble in the past. Shift-click on on the links, one-by-one, to verify
that the current implementation works correctly:
* [/fileage?name=c9df0dcdaa402] - Verify that the many
execute permission changes that occurred about 24 hours before
check-in c9df0dcdaa402 do not appear as file changes.
* [/tree?ci=c9df0dcdaa40&mtime=0&type=tree] - Verify that all
|
| ︙ | ︙ |
Changes to test/graph-test-1.wiki.
| ︙ | ︙ | |||
40 41 42 43 44 45 46 |
Check-ins tagged "release" and related check-ins</a>
* <a href="../../../timeline?r=release&mionly&n=0" target="testwindow">
Check-ins tagged "release" and merge-ins</a>
* <a href="../../../timeline?t=release&n=0" target="testwindow">
Only check-ins tagged "release"</a>
* <a href="../../../finfo?name=Makefile" target="testwindow">
History of source file "Makefile".</a>
| | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
Check-ins tagged "release" and related check-ins</a>
* <a href="../../../timeline?r=release&mionly&n=0" target="testwindow">
Check-ins tagged "release" and merge-ins</a>
* <a href="../../../timeline?t=release&n=0" target="testwindow">
Only check-ins tagged "release"</a>
* <a href="../../../finfo?name=Makefile" target="testwindow">
History of source file "Makefile".</a>
* <a href="../../../timeline?n=20&a=1970-01-01" target="testwindow">
20 elements after 1970-01-01.</a>
* <a href="../../../timeline?n=100000000&y=ci" target="testwindow">
All check-ins - a huge graph.</a>
* <a href="../../../timeline?f=8dfed953f7530442" target="testwindow">
This malformed commit has a
merge parent which is not a valid checkin.</a>
* <a href="../../../timeline?from=e663bac6f7&to=a298a0e2f9&shortest"
|
| ︙ | ︙ |
Changes to test/json.test.
| ︙ | ︙ | |||
131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
}
return $status
}
# Inspect a dict for keys it must have and keys it must not have
proc test_dict_keys {testname D okfields badfields} {
set i 1
foreach f $okfields {
test "$testname-$i" {[dict exists $D $f]}
incr i
}
foreach f $badfields {
test "$testname-$i" {![dict exists $D $f]}
| > > > > | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
}
return $status
}
# Inspect a dict for keys it must have and keys it must not have
proc test_dict_keys {testname D okfields badfields} {
if {$D eq ""} {
test $testname-validJSON 0
return
}
set i 1
foreach f $okfields {
test "$testname-$i" {[dict exists $D $f]}
incr i
}
foreach f $badfields {
test "$testname-$i" {![dict exists $D $f]}
|
| ︙ | ︙ | |||
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
test_json_payload json-version $HAIfields {}
test json-version-api {[dict get $JR payload jsonApiVersion] >= 20120713}
#### ARTIFACT
# sha1 of 0 bytes and a file to match in a commit
set UUID_empty da39a3ee5e6b4b0d3255bfef95601890afd80709
write_file empty ""
fossil add empty
fossil ci -m "empty file"
# json artifact (checkin)
fossil_json [concat artifact tip]
test_json_envelope_ok json-artifact-checkin-env
test json-artifact-checkin {[dict get $JR payload type] eq "checkin"}
test_json_payload json-artifact \
[concat type uuid isLeaf timestamp user comment parents tags files] {}
# json artifact (file)
| > > | | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
test_json_payload json-version $HAIfields {}
test json-version-api {[dict get $JR payload jsonApiVersion] >= 20120713}
#### ARTIFACT
# sha1 of 0 bytes and a file to match in a commit
set UUID_empty da39a3ee5e6b4b0d3255bfef95601890afd80709
# sha3 of 0 bytes and a file to match in a commit
set UUID_empty_64 a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a
write_file empty ""
fossil add empty
fossil ci -m "empty file"
# json artifact (checkin)
fossil_json [concat artifact tip]
test_json_envelope_ok json-artifact-checkin-env
test json-artifact-checkin {[dict get $JR payload type] eq "checkin"}
test_json_payload json-artifact \
[concat type uuid isLeaf timestamp user comment parents tags files] {}
# json artifact (file)
fossil_json [concat artifact $UUID_empty_64]
test_json_envelope_ok json-artifact-file-env
test json-artifact-file {[dict get $JR payload type] eq "file"}
test_json_payload json-artifact [concat type uuid size checkins] {}
# json artifact (wiki)
fossil wiki create Empty <<"-=BLANK=-"
fossil_json wiki get Empty
|
| ︙ | ︙ | |||
738 739 740 741 742 743 744 |
write_file e1102.json {
{
"command":"no/such/endpoint"
}
}
fossil_json --json-input e1102.json -expectError
| | | | | > > > > > > > > > > | 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 |
write_file e1102.json {
{
"command":"no/such/endpoint"
}
}
fossil_json --json-input e1102.json -expectError
test json-env-RC-1102a-CLI-exit {$CODE != 0}
test_json_envelope json-env-RC-1102a-env {fossil timestamp command procTimeUs \
procTimeMs resultCode resultText} {payload}
test json-env-RC-1102a-code {[dict get $JR resultCode] eq "FOSSIL-1102"}
# FOSSIL-1103 FSL_JSON_E_UNKNOWN
# Unknown error
write_file bad.sql {
CREATE TABLE spam(a integer, b text);
}
exec $::fossilexe sqlite3 --no-repository bad.fossil <bad.sql
fossil_json HAI -R bad.fossil -expectError
test json-env-RC-1103-CLI-exit {$CODE != 0}
if { $JR ne "" } {
test_json_envelope json-env-RC-1103-env {fossil timestamp command procTimeUs \
procTimeMs resultCode resultText} {payload}
test json-env-RC-1103-code {[dict exists $JR resultCode]\
&& [dict get $JR resultCode] eq "FOSSIL-1103"} knownBug
} else {
protOut "Want test case for FOSSIL-1103"
test json-RC-1103 0 knownBug
}
# FOSSIL-1104 FSL_JSON_E_TIMEOUT
# Timeout reached
# FOSSIL-1105 FSL_JSON_E_ASSERT
# Assertion failed
# FOSSIL-1106 FSL_JSON_E_ALLOC
# Resource allocation failed
|
| ︙ | ︙ | |||
834 835 836 837 838 839 840 |
# Fossil repository needs to be rebuilt
# FOSSIL-4102 FSL_JSON_E_DB_NOT_FOUND
# Fossil repository db file could not be found.
fossil close
fossil_json HAI -expectError
test json-RC-4102-CLI-exit {$CODE != 0}
| | | > > > > > > > > > | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |
# Fossil repository needs to be rebuilt
# FOSSIL-4102 FSL_JSON_E_DB_NOT_FOUND
# Fossil repository db file could not be found.
fossil close
fossil_json HAI -expectError
test json-RC-4102-CLI-exit {$CODE != 0}
test_json_envelope json-RC-4102-CLI-exit {fossil timestamp command procTimeUs \
procTimeMs resultCode resultText} {payload}
test json-RC-4102 {[dict get $JR resultCode] eq "FOSSIL-4102"}
fossil open .rep.fossil
# FOSSIL-4103 FSL_JSON_E_DB_NOT_VALID
# Fossil repository db file is not valid.
write_file nope.fossil {
This is not a fossil repo. It ought to be a SQLite db with a well-known schema,
but it is actually just a block of text.
}
fossil_json HAI -R nope.fossil -expectError
test json-RC-4103-CLI-exit {$CODE != 0}
if { $JR ne "" } {
test_json_envelope json-RC-4103-CLI {fossil timestamp command procTimeUs \
procTimeMs resultCode resultText} {payload}
test json-RC-4103 {[dict get $JR resultCode] eq "FOSSIL-4103"}
} else {
test json-RC-4103 0 knownBug
}
###############################################################################
test_cleanup
|
Changes to test/markdown-test1.md.
|
| < | < | 1 2 3 4 5 6 7 8 |
# Markdown Formatter Test Document
This document is designed to test the markdown formatter.
* A bullet item.
* A subitem
* Second bullet
|
| ︙ | ︙ | |||
19 20 21 22 23 24 25 | Other Features -------------- Text can show *emphasis* or _emphasis_ or **strong emphassis**. | > > > > | 17 18 19 20 21 22 23 24 25 26 27 | Other Features -------------- Text can show *emphasis* or _emphasis_ or **strong emphassis**. ``` Fenced code block ``` |
Changes to test/merge5.test.
| ︙ | ︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# drh@hwaci.com
# http://www.hwaci.com/drh/
#
############################################################################
#
# Tests of the "merge" command
#
# Verify the results of a check-out
#
proc checkout-test {testid expected_content} {
set flist {}
foreach {status filename} [exec $::fossilexe ls -l] {
if {$status!="DELETED"} {lappend flist $filename}
| > > > > > > > > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# drh@hwaci.com
# http://www.hwaci.com/drh/
#
############################################################################
#
# Tests of the "merge" command
#
puts "Skipping Merge5 tests"
protOut {
fossil sqlite3 --no-repository reacts badly to SQL dumped from
repositories created from fossil older than version 2.0.
}
test merge5-sqlite3-issue false knownBug
test_cleanup_then_return
# Verify the results of a check-out
#
proc checkout-test {testid expected_content} {
set flist {}
foreach {status filename} [exec $::fossilexe ls -l] {
if {$status!="DELETED"} {lappend flist $filename}
|
| ︙ | ︙ |
Changes to test/set-manifest.test.
| ︙ | ︙ | |||
60 61 62 63 64 65 66 |
foreach f $filelist {
test "set-manifest-2-$v-f-$f" {[file isfile $f]}
}
}
# ... and manifest.uuid is the checkout's hash
fossil info
| | | > | | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
foreach f $filelist {
test "set-manifest-2-$v-f-$f" {[file isfile $f]}
}
}
# ... and manifest.uuid is the checkout's hash
fossil info
regexp {(?m)^checkout:\s+([0-9a-f]{40,64})\s.*$} $RESULT ckoutline ckid
set uuid [string trim [read_file "manifest.uuid"]]
test "set-manifest-2-uuid" {[same_uuid $ckid $uuid]}
# ... which is also the SHA1 of the file "manifest" before it was
# sterilized by appending an extra line when writing the file. The
# extra text begins with # and is a full line, so we'll just strip
# it with a brute-force substitution. This probably has the right
# effect even if the checkin was PGP-signed, but we don't have that
# setting turned on for this manifest in any case.
#regsub {(?m)^#.*\n} [read_file "manifest"] "" manifest
#set muuid [::sha1::sha1 $manifest]
#test "set-manifest-2-manifest" {[same_uuid $muuid $uuid]}
# Classic behavior: FALSE value removes manifest and manifest.uuid
set falses [list false off 0]
foreach v $falses {
fossil settings manifest $v
test "set-manifest-3-$v" {$RESULT eq ""}
|
| ︙ | ︙ |
Changes to test/stash.test.
| ︙ | ︙ | |||
169 170 171 172 173 174 175 |
########
# fossil stash show|cat ?STASHID? ?DIFF-OPTIONS?
# fossil stash [g]diff ?STASHID? ?DIFF-OPTIONS?
fossil stash show
test stash-1-show {[normalize_result] eq $diff_stash_1}
fossil stash diff
| | | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
########
# fossil stash show|cat ?STASHID? ?DIFF-OPTIONS?
# fossil stash [g]diff ?STASHID? ?DIFF-OPTIONS?
fossil stash show
test stash-1-show {[normalize_result] eq $diff_stash_1}
fossil stash diff
test stash-1-diff {[normalize_result] eq $diff_stash_1} knownBug
########
# fossil stash pop
stash-test 2 pop {
DELETE f1
UPDATE f2
|
| ︙ | ︙ |
Added test/subdir/README.html.
> > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <h1>An Example HTML Readme</h1> <p> The test/subdir/ directory and its children exist purely for testing in the self-hosting Fossil repository. This particular file is used to verify that a file name "README.html" is displayed correctly. beneath the directory listing. </p> <center> <table border=1> <tr><td>This</td><td>is</td></tr> <tr><td>a</td><td><table></td></tr> </table> </center> |
Added test/subdir/one/readme.wiki.
> > > > > > > > > | 1 2 3 4 5 6 7 8 9 | <title>Fossil Wiki Readme</title> This is another test README file. The point of this file is to show that lower-case "readme" is recognized, and the Fossil-Wiki formatting is displayed correctly. * First bullet * Second bullet |
Changes to test/tester.tcl.
| ︙ | ︙ | |||
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
if {$::PROT} {
set out [open [file join $::testrundir prot] a]
fconfigure $out -translation platform
puts $out $msg
close $out
}
}
# Run the Fossil program with the specified arguments.
#
# Consults the VERBOSE global variable to determine if
# diagnostics should be emitted when no error is seen.
# Sets the CODE and RESULT global variables for use in
# test expressions.
| > > > > > > > > > > > | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
if {$::PROT} {
set out [open [file join $::testrundir prot] a]
fconfigure $out -translation platform
puts $out $msg
close $out
}
}
# write a dict with just enough formatting
# to make it human readable
#
proc protOutDict {dict {pattern *}} {
set longest [tcl::mathfunc::max 0 {*}[lmap key [dict keys $dict $pattern] {string length $key}]]
dict for {key value} $dict {
protOut [format "%-${longest}s = %s" $key $value]
}
}
# Run the Fossil program with the specified arguments.
#
# Consults the VERBOSE global variable to determine if
# diagnostics should be emitted when no error is seen.
# Sets the CODE and RESULT global variables for use in
# test expressions.
|
| ︙ | ︙ | |||
324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
proc same_file {a b} {
set x [read_file $a]
regsub -all { +\n} $x \n x
set y [read_file $b]
regsub -all { +\n} $y \n y
return [expr {$x==$y}]
}
proc require_no_open_checkout {} {
if {[info exists ::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT)] && \
$::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT) eq "YES_DO_IT"} {
return
}
catch {exec $::fossilexe info} res
| > > > > > > > > > > > > > > > > > > > > > > > | 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
proc same_file {a b} {
set x [read_file $a]
regsub -all { +\n} $x \n x
set y [read_file $b]
regsub -all { +\n} $y \n y
return [expr {$x==$y}]
}
# Return true if two strings refer to the
# same uuid. That is, the shorter is a prefix
# of the longer.
#
proc same_uuid {a b} {
set na [string length $a]
set nb [string length $b]
if {$na == $nb} {
return [expr {$a eq $b}]
}
if {$na < $nb} then {
return [string match "$a*" $b]
}
return [string match "$b*" $a]
}
# Return a prefix of a uuid, defaulting to 10 chars.
#
proc short_uuid {uuid {len 10}} {
string range $uuid 0 $len-1
}
proc require_no_open_checkout {} {
if {[info exists ::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT)] && \
$::env(FOSSIL_TEST_DANGEROUS_IGNORE_OPEN_CHECKOUT) eq "YES_DO_IT"} {
return
}
catch {exec $::fossilexe info} res
|
| ︙ | ︙ | |||
934 935 936 937 938 939 940 941 942 943 944 945 |
if {[catch {
file mkdir $tempHomePath
} error] != 0} {
error "Could not make directory \"$tempHomePath\",\
please set TEMP variable in environment, error: $error"
}
protInit $fossilexe
set ::tempKeepHome 1
foreach testfile $argv {
protOut "***** $testfile ******"
| > | > > > > > > | 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 |
if {[catch {
file mkdir $tempHomePath
} error] != 0} {
error "Could not make directory \"$tempHomePath\",\
please set TEMP variable in environment, error: $error"
}
protInit $fossilexe
set ::tempKeepHome 1
foreach testfile $argv {
protOut "***** $testfile ******"
if { [catch {source $testdir/$testfile.test} testerror testopts] } {
test test-framework-$testfile 0
protOut "!!!!! $testfile: $testerror"
protOutDict $testopts"
} else {
test test-framework-$testfile 1
}
protOut "***** End of $testfile: [llength $bad_test] errors so far ******"
}
unset ::tempKeepHome; delete_temporary_home
set nErr [llength $bad_test]
if {$nErr>0 || !$::QUIET} {
protOut "***** Final results: $nErr errors out of $test_count tests" 1
}
|
| ︙ | ︙ |
Changes to test/th1-docs.test.
| ︙ | ︙ | |||
59 60 61 62 63 64 65 |
run_in_checkout {
set RESULT [test_fossil_http \
$repository $dataFileName /doc/trunk/test/fileStat.th1]
}
test th1-docs-1a {[regexp {<title>Fossil: test/fileStat.th1</title>} $RESULT]}
| | | 59 60 61 62 63 64 65 66 67 68 69 70 71 |
run_in_checkout {
set RESULT [test_fossil_http \
$repository $dataFileName /doc/trunk/test/fileStat.th1]
}
test th1-docs-1a {[regexp {<title>Fossil: test/fileStat.th1</title>} $RESULT]}
test th1-docs-1b {[regexp {>\[[0-9a-f]{40,64}\]<} $RESULT]}
test th1-docs-1c {[regexp { contains \d+ files\.} $RESULT]}
###############################################################################
test_cleanup
|
Changes to test/th1-hooks.test.
| ︙ | ︙ | |||
68 69 70 71 72 73 74 |
} elseif {$::cmd_name eq "test2"} {
error "unsupported command"
} elseif {$::cmd_name eq "test3"} {
emit_hook_log
break "TH_BREAK return code"
} elseif {$::cmd_name eq "test4"} {
emit_hook_log
| | > > > | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
} elseif {$::cmd_name eq "test2"} {
error "unsupported command"
} elseif {$::cmd_name eq "test3"} {
emit_hook_log
break "TH_BREAK return code"
} elseif {$::cmd_name eq "test4"} {
emit_hook_log
return -code 5 "TH_RETURN return code"
} elseif {$::cmd_name eq "timeline"} {
set length [llength $::cmd_args]
set length [expr {$length - 1}]
if {[lindex $::cmd_args $length] eq "custom"} {
append_hook_log "CUSTOM TIMELINE"
emit_hook_log
return "custom timeline"
} elseif {[lindex $::cmd_args $length] eq "custom2"} {
emit_hook_log
puts "+++ some stuff here +++"
continue "custom2 timeline"
} elseif {[lindex $::cmd_args $length] eq "custom3"} {
emit_hook_log
return -code 5 "TH_RETURN return code"
} elseif {[lindex $::cmd_args $length] eq "now"} {
emit_hook_log
return "now timeline"
} else {
emit_hook_log
error "unsupported timeline"
}
|
| ︙ | ︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
test th1-cmd-hooks-1b {[normalize_result] eq \
{<h1><b>command_hook timeline</b></h1>
+++ some stuff here +++
<h1><b>command_hook timeline command_notify timeline</b></h1>}}
###############################################################################
fossil timeline
test th1-cmd-hooks-2a {[first_data_line] eq \
{<h1><b>command_hook timeline</b></h1>}}
test th1-cmd-hooks-2b {[second_data_line] eq {ERROR: unsupported timeline}}
###############################################################################
| > > > > > > > > | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
test th1-cmd-hooks-1b {[normalize_result] eq \
{<h1><b>command_hook timeline</b></h1>
+++ some stuff here +++
<h1><b>command_hook timeline command_notify timeline</b></h1>}}
###############################################################################
fossil timeline custom3; # NOTE: Bad "WHEN" argument.
test th1-cmd-hooks-1c {[normalize_result] eq \
{<h1><b>command_hook timeline</b></h1>
unknown check-in or invalid date: custom3}}
###############################################################################
fossil timeline
test th1-cmd-hooks-2a {[first_data_line] eq \
{<h1><b>command_hook timeline</b></h1>}}
test th1-cmd-hooks-2b {[second_data_line] eq {ERROR: unsupported timeline}}
###############################################################################
|
| ︙ | ︙ | |||
183 184 185 186 187 188 189 |
fossil test3
test th1-custom-cmd-3a {[string trim $RESULT] eq \
{<h1><b>command_hook test3</b></h1>}}
###############################################################################
fossil test4
| > | > > > > > > | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
fossil test3
test th1-custom-cmd-3a {[string trim $RESULT] eq \
{<h1><b>command_hook test3</b></h1>}}
###############################################################################
fossil test4
test th1-custom-cmd-4a {[first_data_line] eq \
{<h1><b>command_hook test4</b></h1>}}
test th1-custom-cmd-4b {[regexp -- \
{: unknown command: test4$} [second_data_line]]}
test th1-custom-cmd-4d {[regexp -- \
{: use "help" for more information$} [third_data_line]]}
###############################################################################
set RESULT [test_fossil_http $repository $dataFileName /timeline]
test th1-web-hooks-1a {[regexp \
{<title>Unnamed Fossil Project: Timeline</title>} $RESULT]}
|
| ︙ | ︙ |
Changes to test/th1.test.
| ︙ | ︙ | |||
850 851 852 853 854 855 856 |
###############################################################################
run_in_checkout {
fossil test-th-eval --open-config "artifact tip"
}
| | | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 |
###############################################################################
run_in_checkout {
fossil test-th-eval --open-config "artifact tip"
}
test th1-artifact-3 {[regexp -- {F test/th1\.test [0-9a-f]{40,64}} $RESULT]}
###############################################################################
fossil test-th-eval "artifact 0000000000"
test th1-artifact-4 {$RESULT eq {TH_ERROR: repository unavailable}}
###############################################################################
|
| ︙ | ︙ | |||
1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 |
###############################################################################
fossil test-th-eval {string is integer 0xC0DEF00Z}
test th1-string-is-31 {$RESULT eq "0"}
###############################################################################
fossil test-th-eval {markdown}
test th1-markdown-1 {$RESULT eq \
{TH_ERROR: wrong # args: should be "markdown STRING"}}
###############################################################################
fossil test-th-eval {markdown one two}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 |
###############################################################################
fossil test-th-eval {string is integer 0xC0DEF00Z}
test th1-string-is-31 {$RESULT eq "0"}
###############################################################################
fossil test-th-eval {string index "" -1}
test th1-string-index-1 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index "" 0}
test th1-string-index-2 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index "" 1}
test th1-string-index-3 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index "" 2}
test th1-string-index-4 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index "" end}
test th1-string-index-5 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index A -1}
test th1-string-index-6 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index A 0}
test th1-string-index-7 {$RESULT eq "A"}
###############################################################################
fossil test-th-eval {string index A 1}
test th1-string-index-8 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index A 2}
test th1-string-index-9 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index A end}
test th1-string-index-10 {$RESULT eq "A"}
###############################################################################
fossil test-th-eval {string index ABC -1}
test th1-string-index-11 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index ABC 0}
test th1-string-index-12 {$RESULT eq "A"}
###############################################################################
fossil test-th-eval {string index ABC 1}
test th1-string-index-13 {$RESULT eq "B"}
###############################################################################
fossil test-th-eval {string index ABC 2}
test th1-string-index-14 {$RESULT eq "C"}
###############################################################################
fossil test-th-eval {string index ABC end}
test th1-string-index-15 {$RESULT eq "C"}
###############################################################################
fossil test-th-eval {markdown}
test th1-markdown-1 {$RESULT eq \
{TH_ERROR: wrong # args: should be "markdown STRING"}}
###############################################################################
fossil test-th-eval {markdown one two}
|
| ︙ | ︙ | |||
1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 |
<p>Text can show <em>emphasis</em> or <em>emphasis</em> or <strong>strong emphassis</strong>.</p>
</div>
}}}
###############################################################################
fossil test-th-eval {encode64 test}
test th1-encode64-1 {$RESULT eq "dGVzdA=="}
###############################################################################
fossil test-th-eval {encode64 test\x00}
test th1-encode64-2 {$RESULT eq "dGVzdAA="}
| > > > > > > > > > > > > > | 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 |
<p>Text can show <em>emphasis</em> or <em>emphasis</em> or <strong>strong emphassis</strong>.</p>
</div>
}}}
###############################################################################
# Verify that quoted delimiters like * and _ don't terminate their
# span. This was fixed by checkin [dd41f85acf].
fossil test-th-eval {markdown "*This is\\*a test.*\n_second\\_test_"}
test th1-markdown-6 {[normalize_result] eq {{} {<div class="markdown">
<p><em>This is*a test.</em>
<em>second_test</em></p>
</div>
}}}
###############################################################################
fossil test-th-eval {encode64 test}
test th1-encode64-1 {$RESULT eq "dGVzdA=="}
###############################################################################
fossil test-th-eval {encode64 test\x00}
test th1-encode64-2 {$RESULT eq "dGVzdAA="}
|
| ︙ | ︙ | |||
1563 1564 1565 1566 1567 1568 1569 |
fossil test-th-source $th1FileName
test th1-source-1 {$RESULT eq {TH_RETURN: 0 1 2 3 4 5 6 7 8 9}}
file delete $th1FileName
###############################################################################
| | | | > > > > | | | < < | < < < < < < < < < < < < < < < < | < | | > | < < | 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 |
fossil test-th-source $th1FileName
test th1-source-1 {$RESULT eq {TH_RETURN: 0 1 2 3 4 5 6 7 8 9}}
file delete $th1FileName
###############################################################################
# Tests for the TH1 unversioned command require at least one
# unversioned file in the repository. All tests run in a freshly
# created checkout of a freshly created repo, so we can just
# create a file or two for the purpose.
write_file ten.txt "0123456789"
fossil unversioned add ten.txt
fossil unversioned list
# unversioned list
fossil test-th-eval --open-config "unversioned list"
test th1-unversioned-1 {[normalize_result] eq {ten.txt}}
# unversioned content
fossil test-th-eval --open-config \
{string length [unversioned content ten.txt]}
test th1-unversioned-2 {$RESULT eq {10}}
###############################################################################
test_cleanup
|
Changes to test/unversioned.test.
| ︙ | ︙ | |||
238 239 240 241 242 243 244 |
test unversioned-34 {[normalize_result] eq {}}
test unversioned-35 {[::sha1::sha1 -hex -filename unversioned2-ex.txt] eq \
{962f96ebd613e4fdd9aa2d20bd9fe21a64e925f2}}
###############################################################################
fossil unversioned hash
| | | | | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
test unversioned-34 {[normalize_result] eq {}}
test unversioned-35 {[::sha1::sha1 -hex -filename unversioned2-ex.txt] eq \
{962f96ebd613e4fdd9aa2d20bd9fe21a64e925f2}}
###############################################################################
fossil unversioned hash
test unversioned-36 {[regexp {^[0-9a-f]{40,64}$} [normalize_result]]}
###############################################################################
fossil unversioned hash --debug
test unversioned-37 {[regexp \
{^unversioned2\.txt 2016-10-01 00:00:00 [0-9a-f]{40,64}
unversioned4\.txt 2016-10-01 00:00:00 [0-9a-f]{40,64}
[0-9a-f]{40,64}$} [normalize_result]]}
###############################################################################
fossil unversioned remove unversioned4.txt --mtime "2016-10-02 13:47:29"
test unversioned-38 {[normalize_result] eq {}}
###############################################################################
|
| ︙ | ︙ |
Changes to test/wiki.test.
| ︙ | ︙ | |||
19 20 21 22 23 24 25 |
#
test_setup
# Return true if two files are similar (i.e. not only compress trailing spaces
# from a line, but remove any final LF from the file as well)
proc similar_file {a b} {
| > > | | | > > > | | | > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#
test_setup
# Return true if two files are similar (i.e. not only compress trailing spaces
# from a line, but remove any final LF from the file as well)
proc similar_file {a b} {
set x ""
if {[file exists $a]} {
set x [read_file $a]
regsub -all { +\n} $x \n x
regsub -all {\n$} $x {} x
}
set y ""
if {[file exists $b]} {
set y [read_file $b]
regsub -all { +\n} $y \n y
regsub -all {\n$} $y {} y
}
return [expr {$x==$y}]
}
# Return the mime type in the manifest for a given wiki page
# Defaults to "error: some text" if the manifest can't be located and
# "text/x-fossil-wiki" (the default mimetype for rendering)
# if the N card is omitted in the manifest.
|
| ︙ | ︙ |
Changes to tools/man_page_command_list.tcl.
1 | #!/usr/bin/env tclsh | | | 1 2 3 4 5 6 7 8 9 |
#!/usr/bin/env tclsh
# man_page_command_list.tcl - generates common command list for fossil.1
# Tunable configuration.
set columns 5
set width 15
# The only supported command-line argument is the optional output filename.
if {[llength $argv] == 1} {
|
| ︙ | ︙ |
Changes to win/Makefile.PellesCGMake.
| ︙ | ︙ | |||
81 82 83 84 85 86 87 | UTILS_OBJ=$(UTILS:.exe=.obj) UTILS_SRC=$(foreach uf,$(UTILS),$(SRCDIR)$(uf:.exe=.c)) # define the SQLite files, which need special flags on compile SQLITESRC=sqlite3.c ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf)) SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj)) | | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | UTILS_OBJ=$(UTILS:.exe=.obj) UTILS_SRC=$(foreach uf,$(UTILS),$(SRCDIR)$(uf:.exe=.c)) # define the SQLite files, which need special flags on compile SQLITESRC=sqlite3.c ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf)) SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj)) SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_WIN32_NO_ANSI # define the SQLite shell files, which need special flags on compile SQLITESHELLSRC=shell.c ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf)) SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj)) SQLITESHELLDEFINES=-Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen |
| ︙ | ︙ |
Changes to win/Makefile.dmc.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 | SSL = CFLAGS = -o BCC = $(DMDIR)\bin\dmc $(CFLAGS) TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL) LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 | | | | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | SSL = CFLAGS = -o BCC = $(DMDIR)\bin\dmc $(CFLAGS) TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL) LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB SHELL_OPTIONS = -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c foci_.c fshell_.c fusefs_.c glob_.c graph_.c gzip_.c hname_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c OBJ = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O RC=$(DMDIR)\bin\rcc RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__ APPNAME = $(OBJDIR)\fossil$(E) all: $(APPNAME) $(APPNAME) : translate$E mkindex$E codecheck1$E headers $(OBJ) $(OBJDIR)\link cd $(OBJDIR) codecheck1$E $(SRC) $(DMDIR)\bin\link @link $(OBJDIR)\fossil.res: $B\win\fossil.rc $(RC) $(RCFLAGS) -o$@ $** $(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res +echo add allrepo attach bag bisect blob branch browse builtin bundle cache captcha cgi checkin checkout clearsign clone comformat configure content db delta deltacmd descendants diff diffcmd dispatch doc encode event export file finfo foci fshell fusefs glob graph gzip hname http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path piechart pivot popen pqueue printf publish purge rebuild regexp report rss schema search security_audit setup sha1 sha1hard sha3 shun sitemap skins sqlcmd stash stat statrep style sync tag tar th_main timeline tkt tktsetup undo unicode unversioned update url user utf8 util verify vfile wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@ +echo fossil >> $@ +echo fossil >> $@ +echo $(LIBS) >> $@ +echo. >> $@ +echo fossil >> $@ translate$E: $(SRCDIR)\translate.c |
| ︙ | ︙ | |||
648 649 650 651 652 653 654 655 656 657 658 659 660 661 | +translate$E $** > $@ $(OBJDIR)\search$O : search_.c search.h $(TCC) -o$@ -c search_.c search_.c : $(SRCDIR)\search.c +translate$E $** > $@ $(OBJDIR)\setup$O : setup_.c setup.h $(TCC) -o$@ -c setup_.c setup_.c : $(SRCDIR)\setup.c +translate$E $** > $@ | > > > > > > | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 | +translate$E $** > $@ $(OBJDIR)\search$O : search_.c search.h $(TCC) -o$@ -c search_.c search_.c : $(SRCDIR)\search.c +translate$E $** > $@ $(OBJDIR)\security_audit$O : security_audit_.c security_audit.h $(TCC) -o$@ -c security_audit_.c security_audit_.c : $(SRCDIR)\security_audit.c +translate$E $** > $@ $(OBJDIR)\setup$O : setup_.c setup.h $(TCC) -o$@ -c setup_.c setup_.c : $(SRCDIR)\setup.c +translate$E $** > $@ |
| ︙ | ︙ | |||
872 873 874 875 876 877 878 | $(OBJDIR)\zip$O : zip_.c zip.h $(TCC) -o$@ -c zip_.c zip_.c : $(SRCDIR)\zip.c +translate$E $** > $@ headers: makeheaders$E page_index.h builtin_data.h VERSION.h | | | 878 879 880 881 882 883 884 885 886 | $(OBJDIR)\zip$O : zip_.c zip.h $(TCC) -o$@ -c zip_.c zip_.c : $(SRCDIR)\zip.c +translate$E $** > $@ headers: makeheaders$E page_index.h builtin_data.h VERSION.h +makeheaders$E add_.c:add.h allrepo_.c:allrepo.h attach_.c:attach.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h dispatch_.c:dispatch.h doc_.c:doc.h encode_.c:encode.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h foci_.c:foci.h fshell_.c:fshell.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h hname_.c:hname.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h piechart_.c:piechart.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h security_audit_.c:security_audit.h setup_.c:setup.h sha1_.c:sha1.h sha1hard_.c:sha1hard.h sha3_.c:sha3.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h unversioned_.c:unversioned.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h @copy /Y nul: headers |
Changes to win/Makefile.mingw.
| ︙ | ︙ | |||
168 169 170 171 172 173 174 | endif #### The directories where the OpenSSL include and library files are located. # The recommended usage here is to use the Sysinternals junction tool # to create a hard link between an "openssl-1.x" sub-directory of the # Fossil source code directory and the target OpenSSL source directory. # | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | endif #### The directories where the OpenSSL include and library files are located. # The recommended usage here is to use the Sysinternals junction tool # to create a hard link between an "openssl-1.x" sub-directory of the # Fossil source code directory and the target OpenSSL source directory. # OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2l OPENSSLINCDIR = $(OPENSSLDIR)/include OPENSSLLIBDIR = $(OPENSSLDIR) #### Either the directory where the Tcl library is installed or the Tcl # source code directory resides (depending on the value of the macro # FOSSIL_TCL_SOURCE). If this points to the Tcl install directory, # this directory must have "include" and "lib" sub-directories. If |
| ︙ | ︙ | |||
223 224 225 226 227 228 229 | #### C compiler and options for use in building executables that will # run on the target platform. This is usually the almost the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | #### C compiler and options for use in building executables that will # run on the target platform. This is usually the almost the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # TCC = $(PREFIX)$(TCCEXE) -Wall -Wdeclaration-after-statement #### Add the necessary command line options to build with debugging # symbols, if enabled. # ifdef FOSSIL_ENABLE_SYMBOLS TCC += -g else |
| ︙ | ︙ | |||
508 509 510 511 512 513 514 515 516 517 518 519 520 521 | $(SRCDIR)/purge.c \ $(SRCDIR)/rebuild.c \ $(SRCDIR)/regexp.c \ $(SRCDIR)/report.c \ $(SRCDIR)/rss.c \ $(SRCDIR)/schema.c \ $(SRCDIR)/search.c \ $(SRCDIR)/setup.c \ $(SRCDIR)/sha1.c \ $(SRCDIR)/sha1hard.c \ $(SRCDIR)/sha3.c \ $(SRCDIR)/shun.c \ $(SRCDIR)/sitemap.c \ $(SRCDIR)/skins.c \ | > | 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | $(SRCDIR)/purge.c \ $(SRCDIR)/rebuild.c \ $(SRCDIR)/regexp.c \ $(SRCDIR)/report.c \ $(SRCDIR)/rss.c \ $(SRCDIR)/schema.c \ $(SRCDIR)/search.c \ $(SRCDIR)/security_audit.c \ $(SRCDIR)/setup.c \ $(SRCDIR)/sha1.c \ $(SRCDIR)/sha1hard.c \ $(SRCDIR)/sha3.c \ $(SRCDIR)/shun.c \ $(SRCDIR)/sitemap.c \ $(SRCDIR)/skins.c \ |
| ︙ | ︙ | |||
562 563 564 565 566 567 568 569 570 571 572 573 574 575 | $(SRCDIR)/../skins/blitz/header.txt \ $(SRCDIR)/../skins/blitz/ticket.txt \ $(SRCDIR)/../skins/blitz_no_logo/css.txt \ $(SRCDIR)/../skins/blitz_no_logo/details.txt \ $(SRCDIR)/../skins/blitz_no_logo/footer.txt \ $(SRCDIR)/../skins/blitz_no_logo/header.txt \ $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \ $(SRCDIR)/../skins/default/css.txt \ $(SRCDIR)/../skins/default/details.txt \ $(SRCDIR)/../skins/default/footer.txt \ $(SRCDIR)/../skins/default/header.txt \ $(SRCDIR)/../skins/eagle/css.txt \ $(SRCDIR)/../skins/eagle/details.txt \ $(SRCDIR)/../skins/eagle/footer.txt \ | > > > > | 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | $(SRCDIR)/../skins/blitz/header.txt \ $(SRCDIR)/../skins/blitz/ticket.txt \ $(SRCDIR)/../skins/blitz_no_logo/css.txt \ $(SRCDIR)/../skins/blitz_no_logo/details.txt \ $(SRCDIR)/../skins/blitz_no_logo/footer.txt \ $(SRCDIR)/../skins/blitz_no_logo/header.txt \ $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \ $(SRCDIR)/../skins/bootstrap/css.txt \ $(SRCDIR)/../skins/bootstrap/details.txt \ $(SRCDIR)/../skins/bootstrap/footer.txt \ $(SRCDIR)/../skins/bootstrap/header.txt \ $(SRCDIR)/../skins/default/css.txt \ $(SRCDIR)/../skins/default/details.txt \ $(SRCDIR)/../skins/default/footer.txt \ $(SRCDIR)/../skins/default/header.txt \ $(SRCDIR)/../skins/eagle/css.txt \ $(SRCDIR)/../skins/eagle/details.txt \ $(SRCDIR)/../skins/eagle/footer.txt \ |
| ︙ | ︙ | |||
686 687 688 689 690 691 692 693 694 695 696 697 698 699 | $(OBJDIR)/purge_.c \ $(OBJDIR)/rebuild_.c \ $(OBJDIR)/regexp_.c \ $(OBJDIR)/report_.c \ $(OBJDIR)/rss_.c \ $(OBJDIR)/schema_.c \ $(OBJDIR)/search_.c \ $(OBJDIR)/setup_.c \ $(OBJDIR)/sha1_.c \ $(OBJDIR)/sha1hard_.c \ $(OBJDIR)/sha3_.c \ $(OBJDIR)/shun_.c \ $(OBJDIR)/sitemap_.c \ $(OBJDIR)/skins_.c \ | > | 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | $(OBJDIR)/purge_.c \ $(OBJDIR)/rebuild_.c \ $(OBJDIR)/regexp_.c \ $(OBJDIR)/report_.c \ $(OBJDIR)/rss_.c \ $(OBJDIR)/schema_.c \ $(OBJDIR)/search_.c \ $(OBJDIR)/security_audit_.c \ $(OBJDIR)/setup_.c \ $(OBJDIR)/sha1_.c \ $(OBJDIR)/sha1hard_.c \ $(OBJDIR)/sha3_.c \ $(OBJDIR)/shun_.c \ $(OBJDIR)/sitemap_.c \ $(OBJDIR)/skins_.c \ |
| ︙ | ︙ | |||
813 814 815 816 817 818 819 820 821 822 823 824 825 826 | $(OBJDIR)/purge.o \ $(OBJDIR)/rebuild.o \ $(OBJDIR)/regexp.o \ $(OBJDIR)/report.o \ $(OBJDIR)/rss.o \ $(OBJDIR)/schema.o \ $(OBJDIR)/search.o \ $(OBJDIR)/setup.o \ $(OBJDIR)/sha1.o \ $(OBJDIR)/sha1hard.o \ $(OBJDIR)/sha3.o \ $(OBJDIR)/shun.o \ $(OBJDIR)/sitemap.o \ $(OBJDIR)/skins.o \ | > | 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | $(OBJDIR)/purge.o \ $(OBJDIR)/rebuild.o \ $(OBJDIR)/regexp.o \ $(OBJDIR)/report.o \ $(OBJDIR)/rss.o \ $(OBJDIR)/schema.o \ $(OBJDIR)/search.o \ $(OBJDIR)/security_audit.o \ $(OBJDIR)/setup.o \ $(OBJDIR)/sha1.o \ $(OBJDIR)/sha1hard.o \ $(OBJDIR)/sha3.o \ $(OBJDIR)/shun.o \ $(OBJDIR)/sitemap.o \ $(OBJDIR)/skins.o \ |
| ︙ | ︙ | |||
978 979 980 981 982 983 984 | SQLITE3_SRC. = sqlite3.c SQLITE3_SRC = $(SRCDIR)/$(SQLITE3_SRC.$(USE_SEE)) SQLITE3_SHELL_SRC.0 = shell.c SQLITE3_SHELL_SRC.1 = shell-see.c SQLITE3_SHELL_SRC. = shell.c SQLITE3_SHELL_SRC = $(SRCDIR)/$(SQLITE3_SHELL_SRC.$(USE_SEE)) SEE_FLAGS.0 = | | | 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 | SQLITE3_SRC. = sqlite3.c SQLITE3_SRC = $(SRCDIR)/$(SQLITE3_SRC.$(USE_SEE)) SQLITE3_SHELL_SRC.0 = shell.c SQLITE3_SHELL_SRC.1 = shell-see.c SQLITE3_SHELL_SRC. = shell.c SQLITE3_SHELL_SRC = $(SRCDIR)/$(SQLITE3_SHELL_SRC.$(USE_SEE)) SEE_FLAGS.0 = SEE_FLAGS.1 = -DSQLITE_HAS_CODEC -DSQLITE_SHELL_DBKEY_PROC=fossil_key SEE_FLAGS. = SEE_FLAGS = $(SEE_FLAGS.$(USE_SEE)) EXTRAOBJ = \ $(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) \ $(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) \ |
| ︙ | ︙ | |||
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 | $(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \ $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \ $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \ $(OBJDIR)/report_.c:$(OBJDIR)/report.h \ $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \ $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \ $(OBJDIR)/search_.c:$(OBJDIR)/search.h \ $(OBJDIR)/setup_.c:$(OBJDIR)/setup.h \ $(OBJDIR)/sha1_.c:$(OBJDIR)/sha1.h \ $(OBJDIR)/sha1hard_.c:$(OBJDIR)/sha1hard.h \ $(OBJDIR)/sha3_.c:$(OBJDIR)/sha3.h \ $(OBJDIR)/shun_.c:$(OBJDIR)/shun.h \ $(OBJDIR)/sitemap_.c:$(OBJDIR)/sitemap.h \ $(OBJDIR)/skins_.c:$(OBJDIR)/skins.h \ | > | 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 | $(OBJDIR)/purge_.c:$(OBJDIR)/purge.h \ $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \ $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \ $(OBJDIR)/report_.c:$(OBJDIR)/report.h \ $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \ $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \ $(OBJDIR)/search_.c:$(OBJDIR)/search.h \ $(OBJDIR)/security_audit_.c:$(OBJDIR)/security_audit.h \ $(OBJDIR)/setup_.c:$(OBJDIR)/setup.h \ $(OBJDIR)/sha1_.c:$(OBJDIR)/sha1.h \ $(OBJDIR)/sha1hard_.c:$(OBJDIR)/sha1hard.h \ $(OBJDIR)/sha3_.c:$(OBJDIR)/sha3.h \ $(OBJDIR)/shun_.c:$(OBJDIR)/shun.h \ $(OBJDIR)/sitemap_.c:$(OBJDIR)/sitemap.h \ $(OBJDIR)/skins_.c:$(OBJDIR)/skins.h \ |
| ︙ | ︙ | |||
1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 | $(OBJDIR)/search_.c: $(SRCDIR)/search.c $(TRANSLATE) $(TRANSLATE) $(SRCDIR)/search.c >$@ $(OBJDIR)/search.o: $(OBJDIR)/search_.c $(OBJDIR)/search.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/search.o -c $(OBJDIR)/search_.c $(OBJDIR)/search.h: $(OBJDIR)/headers $(OBJDIR)/setup_.c: $(SRCDIR)/setup.c $(TRANSLATE) $(TRANSLATE) $(SRCDIR)/setup.c >$@ $(OBJDIR)/setup.o: $(OBJDIR)/setup_.c $(OBJDIR)/setup.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/setup.o -c $(OBJDIR)/setup_.c | > > > > > > > > | 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 | $(OBJDIR)/search_.c: $(SRCDIR)/search.c $(TRANSLATE) $(TRANSLATE) $(SRCDIR)/search.c >$@ $(OBJDIR)/search.o: $(OBJDIR)/search_.c $(OBJDIR)/search.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/search.o -c $(OBJDIR)/search_.c $(OBJDIR)/search.h: $(OBJDIR)/headers $(OBJDIR)/security_audit_.c: $(SRCDIR)/security_audit.c $(TRANSLATE) $(TRANSLATE) $(SRCDIR)/security_audit.c >$@ $(OBJDIR)/security_audit.o: $(OBJDIR)/security_audit_.c $(OBJDIR)/security_audit.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/security_audit.o -c $(OBJDIR)/security_audit_.c $(OBJDIR)/security_audit.h: $(OBJDIR)/headers $(OBJDIR)/setup_.c: $(SRCDIR)/setup.c $(TRANSLATE) $(TRANSLATE) $(SRCDIR)/setup.c >$@ $(OBJDIR)/setup.o: $(OBJDIR)/setup_.c $(OBJDIR)/setup.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/setup.o -c $(OBJDIR)/setup_.c |
| ︙ | ︙ | |||
2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 |
SQLITE_OPTIONS = -DNDEBUG=1 \
-DSQLITE_THREADSAFE=0 \
-DSQLITE_DEFAULT_MEMSTATUS=0 \
-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
-DSQLITE_OMIT_DECLTYPE \
-DSQLITE_OMIT_DEPRECATED \
-DSQLITE_OMIT_PROGRESS_CALLBACK \
-DSQLITE_OMIT_SHARED_CACHE \
-DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_MAX_EXPR_DEPTH=0 \
-DSQLITE_USE_ALLOCA \
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
-DSQLITE_ENABLE_FTS4 \
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
-DSQLITE_ENABLE_DBSTAT_VTAB \
-DSQLITE_ENABLE_JSON1 \
-DSQLITE_ENABLE_FTS5 \
-DSQLITE_WIN32_NO_ANSI \
$(MINGW_OPTIONS) \
-DSQLITE_USE_MALLOC_H \
-DSQLITE_USE_MSIZE
SHELL_OPTIONS = -Dmain=sqlite3_shell \
-DSQLITE_SHELL_IS_UTF8=1 \
| > > | 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 |
SQLITE_OPTIONS = -DNDEBUG=1 \
-DSQLITE_THREADSAFE=0 \
-DSQLITE_DEFAULT_MEMSTATUS=0 \
-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
-DSQLITE_OMIT_DECLTYPE \
-DSQLITE_OMIT_DEPRECATED \
-DSQLITE_OMIT_GET_TABLE \
-DSQLITE_OMIT_PROGRESS_CALLBACK \
-DSQLITE_OMIT_SHARED_CACHE \
-DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_MAX_EXPR_DEPTH=0 \
-DSQLITE_USE_ALLOCA \
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
-DSQLITE_ENABLE_FTS4 \
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
-DSQLITE_ENABLE_DBSTAT_VTAB \
-DSQLITE_ENABLE_JSON1 \
-DSQLITE_ENABLE_FTS5 \
-DSQLITE_ENABLE_STMTVTAB \
-DSQLITE_WIN32_NO_ANSI \
$(MINGW_OPTIONS) \
-DSQLITE_USE_MALLOC_H \
-DSQLITE_USE_MSIZE
SHELL_OPTIONS = -Dmain=sqlite3_shell \
-DSQLITE_SHELL_IS_UTF8=1 \
|
| ︙ | ︙ | |||
2248 2249 2250 2251 2252 2253 2254 | $(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c $(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $@ $(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h $(OBJDIR)/shell.o: $(SQLITE3_SHELL_SRC) $(SRCDIR)/sqlite3.h $(SRCDIR)/../win/Makefile.mingw | | | 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 | $(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c $(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $@ $(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h $(OBJDIR)/shell.o: $(SQLITE3_SHELL_SRC) $(SRCDIR)/sqlite3.h $(SRCDIR)/../win/Makefile.mingw $(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) $(SEE_FLAGS) -c $(SQLITE3_SHELL_SRC) -o $@ $(OBJDIR)/th.o: $(SRCDIR)/th.c $(XTCC) -c $(SRCDIR)/th.c -o $@ $(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c $(XTCC) -c $(SRCDIR)/th_lang.c -o $@ $(OBJDIR)/th_tcl.o: $(SRCDIR)/th_tcl.c $(XTCC) -c $(SRCDIR)/th_tcl.c -o $@ $(OBJDIR)/miniz.o: $(SRCDIR)/miniz.c $(XTCC) $(MINIZ_OPTIONS) -c $(SRCDIR)/miniz.c -o $@ |
Changes to win/Makefile.mingw.mistachkin.
| ︙ | ︙ | |||
168 169 170 171 172 173 174 | endif #### The directories where the OpenSSL include and library files are located. # The recommended usage here is to use the Sysinternals junction tool # to create a hard link between an "openssl-1.x" sub-directory of the # Fossil source code directory and the target OpenSSL source directory. # | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | endif #### The directories where the OpenSSL include and library files are located. # The recommended usage here is to use the Sysinternals junction tool # to create a hard link between an "openssl-1.x" sub-directory of the # Fossil source code directory and the target OpenSSL source directory. # OPENSSLDIR = $(SRCDIR)/../compat/openssl-1.0.2l OPENSSLINCDIR = $(OPENSSLDIR)/include OPENSSLLIBDIR = $(OPENSSLDIR) #### Either the directory where the Tcl library is installed or the Tcl # source code directory resides (depending on the value of the macro # FOSSIL_TCL_SOURCE). If this points to the Tcl install directory, # this directory must have "include" and "lib" sub-directories. If |
| ︙ | ︙ | |||
223 224 225 226 227 228 229 | #### C compiler and options for use in building executables that will # run on the target platform. This is usually the almost the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | #### C compiler and options for use in building executables that will # run on the target platform. This is usually the almost the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # TCC = $(PREFIX)$(TCCEXE) -Wall -Wdeclaration-after-statement #### Add the necessary command line options to build with debugging # symbols, if enabled. # ifdef FOSSIL_ENABLE_SYMBOLS TCC += -g else |
| ︙ | ︙ | |||
978 979 980 981 982 983 984 | SQLITE3_SRC. = sqlite3.c SQLITE3_SRC = $(SRCDIR)/$(SQLITE3_SRC.$(USE_SEE)) SQLITE3_SHELL_SRC.0 = shell.c SQLITE3_SHELL_SRC.1 = shell-see.c SQLITE3_SHELL_SRC. = shell.c SQLITE3_SHELL_SRC = $(SRCDIR)/$(SQLITE3_SHELL_SRC.$(USE_SEE)) SEE_FLAGS.0 = | | | 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 | SQLITE3_SRC. = sqlite3.c SQLITE3_SRC = $(SRCDIR)/$(SQLITE3_SRC.$(USE_SEE)) SQLITE3_SHELL_SRC.0 = shell.c SQLITE3_SHELL_SRC.1 = shell-see.c SQLITE3_SHELL_SRC. = shell.c SQLITE3_SHELL_SRC = $(SRCDIR)/$(SQLITE3_SHELL_SRC.$(USE_SEE)) SEE_FLAGS.0 = SEE_FLAGS.1 = -DSQLITE_HAS_CODEC -DSQLITE_SHELL_DBKEY_PROC=fossil_key SEE_FLAGS. = SEE_FLAGS = $(SEE_FLAGS.$(USE_SEE)) EXTRAOBJ = \ $(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) \ $(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) \ |
| ︙ | ︙ | |||
2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 |
SQLITE_OPTIONS = -DNDEBUG=1 \
-DSQLITE_THREADSAFE=0 \
-DSQLITE_DEFAULT_MEMSTATUS=0 \
-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
-DSQLITE_OMIT_DECLTYPE \
-DSQLITE_OMIT_DEPRECATED \
-DSQLITE_OMIT_PROGRESS_CALLBACK \
-DSQLITE_OMIT_SHARED_CACHE \
-DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_MAX_EXPR_DEPTH=0 \
-DSQLITE_USE_ALLOCA \
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
| > | 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 |
SQLITE_OPTIONS = -DNDEBUG=1 \
-DSQLITE_THREADSAFE=0 \
-DSQLITE_DEFAULT_MEMSTATUS=0 \
-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
-DSQLITE_OMIT_DECLTYPE \
-DSQLITE_OMIT_DEPRECATED \
-DSQLITE_OMIT_GET_TABLE \
-DSQLITE_OMIT_PROGRESS_CALLBACK \
-DSQLITE_OMIT_SHARED_CACHE \
-DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_MAX_EXPR_DEPTH=0 \
-DSQLITE_USE_ALLOCA \
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
|
| ︙ | ︙ | |||
2248 2249 2250 2251 2252 2253 2254 | $(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c $(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $@ $(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h $(OBJDIR)/shell.o: $(SQLITE3_SHELL_SRC) $(SRCDIR)/sqlite3.h $(SRCDIR)/../win/Makefile.mingw.mistachkin | | | 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 | $(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c $(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $@ $(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h $(OBJDIR)/shell.o: $(SQLITE3_SHELL_SRC) $(SRCDIR)/sqlite3.h $(SRCDIR)/../win/Makefile.mingw.mistachkin $(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) $(SEE_FLAGS) -c $(SQLITE3_SHELL_SRC) -o $@ $(OBJDIR)/th.o: $(SRCDIR)/th.c $(XTCC) -c $(SRCDIR)/th.c -o $@ $(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c $(XTCC) -c $(SRCDIR)/th_lang.c -o $@ $(OBJDIR)/th_tcl.o: $(SRCDIR)/th_tcl.c $(XTCC) -c $(SRCDIR)/th_tcl.c -o $@ $(OBJDIR)/miniz.o: $(SRCDIR)/miniz.c $(XTCC) $(MINIZ_OPTIONS) -c $(SRCDIR)/miniz.c -o $@ |
Changes to win/Makefile.msc.
| ︙ | ︙ | |||
96 97 98 99 100 101 102 | # Enable support for the SQLite Encryption Extension? !ifndef USE_SEE USE_SEE = 0 !endif !if $(FOSSIL_ENABLE_SSL)!=0 | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | # Enable support for the SQLite Encryption Extension? !ifndef USE_SEE USE_SEE = 0 !endif !if $(FOSSIL_ENABLE_SSL)!=0 SSLDIR = $(B)\compat\openssl-1.0.2l SSLINCDIR = $(SSLDIR)\inc32 !if $(FOSSIL_DYNAMIC_BUILD)!=0 SSLLIBDIR = $(SSLDIR)\out32dll !else SSLLIBDIR = $(SSLDIR)\out32 !endif SSLLFLAGS = /nologo /opt:ref /debug |
| ︙ | ︙ | |||
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
SQLITE_OPTIONS = /DNDEBUG=1 \
/DSQLITE_THREADSAFE=0 \
/DSQLITE_DEFAULT_MEMSTATUS=0 \
/DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
/DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
/DSQLITE_OMIT_DECLTYPE \
/DSQLITE_OMIT_DEPRECATED \
/DSQLITE_OMIT_PROGRESS_CALLBACK \
/DSQLITE_OMIT_SHARED_CACHE \
/DSQLITE_OMIT_LOAD_EXTENSION \
/DSQLITE_MAX_EXPR_DEPTH=0 \
/DSQLITE_USE_ALLOCA \
/DSQLITE_ENABLE_LOCKING_STYLE=0 \
/DSQLITE_DEFAULT_FILE_FORMAT=4 \
/DSQLITE_ENABLE_EXPLAIN_COMMENTS \
/DSQLITE_ENABLE_FTS4 \
/DSQLITE_ENABLE_FTS3_PARENTHESIS \
/DSQLITE_ENABLE_DBSTAT_VTAB \
/DSQLITE_ENABLE_JSON1 \
/DSQLITE_ENABLE_FTS5 \
/DSQLITE_WIN32_NO_ANSI
SHELL_OPTIONS = /Dmain=sqlite3_shell \
/DSQLITE_SHELL_IS_UTF8=1 \
/DSQLITE_OMIT_LOAD_EXTENSION=1 \
/DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
/DSQLITE_SHELL_DBNAME_PROC=fossil_open \
| > > | 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
SQLITE_OPTIONS = /DNDEBUG=1 \
/DSQLITE_THREADSAFE=0 \
/DSQLITE_DEFAULT_MEMSTATUS=0 \
/DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
/DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
/DSQLITE_OMIT_DECLTYPE \
/DSQLITE_OMIT_DEPRECATED \
/DSQLITE_OMIT_GET_TABLE \
/DSQLITE_OMIT_PROGRESS_CALLBACK \
/DSQLITE_OMIT_SHARED_CACHE \
/DSQLITE_OMIT_LOAD_EXTENSION \
/DSQLITE_MAX_EXPR_DEPTH=0 \
/DSQLITE_USE_ALLOCA \
/DSQLITE_ENABLE_LOCKING_STYLE=0 \
/DSQLITE_DEFAULT_FILE_FORMAT=4 \
/DSQLITE_ENABLE_EXPLAIN_COMMENTS \
/DSQLITE_ENABLE_FTS4 \
/DSQLITE_ENABLE_FTS3_PARENTHESIS \
/DSQLITE_ENABLE_DBSTAT_VTAB \
/DSQLITE_ENABLE_JSON1 \
/DSQLITE_ENABLE_FTS5 \
/DSQLITE_ENABLE_STMTVTAB \
/DSQLITE_WIN32_NO_ANSI
SHELL_OPTIONS = /Dmain=sqlite3_shell \
/DSQLITE_SHELL_IS_UTF8=1 \
/DSQLITE_OMIT_LOAD_EXTENSION=1 \
/DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
/DSQLITE_SHELL_DBNAME_PROC=fossil_open \
|
| ︙ | ︙ | |||
433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
purge_.c \
rebuild_.c \
regexp_.c \
report_.c \
rss_.c \
schema_.c \
search_.c \
setup_.c \
sha1_.c \
sha1hard_.c \
sha3_.c \
shun_.c \
sitemap_.c \
skins_.c \
| > | 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
purge_.c \
rebuild_.c \
regexp_.c \
report_.c \
rss_.c \
schema_.c \
search_.c \
security_audit_.c \
setup_.c \
sha1_.c \
sha1hard_.c \
sha3_.c \
shun_.c \
sitemap_.c \
skins_.c \
|
| ︙ | ︙ | |||
486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
$(SRCDIR)\../skins/blitz/header.txt \
$(SRCDIR)\../skins/blitz/ticket.txt \
$(SRCDIR)\../skins/blitz_no_logo/css.txt \
$(SRCDIR)\../skins/blitz_no_logo/details.txt \
$(SRCDIR)\../skins/blitz_no_logo/footer.txt \
$(SRCDIR)\../skins/blitz_no_logo/header.txt \
$(SRCDIR)\../skins/blitz_no_logo/ticket.txt \
$(SRCDIR)\../skins/default/css.txt \
$(SRCDIR)\../skins/default/details.txt \
$(SRCDIR)\../skins/default/footer.txt \
$(SRCDIR)\../skins/default/header.txt \
$(SRCDIR)\../skins/eagle/css.txt \
$(SRCDIR)\../skins/eagle/details.txt \
$(SRCDIR)\../skins/eagle/footer.txt \
| > > > > | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
$(SRCDIR)\../skins/blitz/header.txt \
$(SRCDIR)\../skins/blitz/ticket.txt \
$(SRCDIR)\../skins/blitz_no_logo/css.txt \
$(SRCDIR)\../skins/blitz_no_logo/details.txt \
$(SRCDIR)\../skins/blitz_no_logo/footer.txt \
$(SRCDIR)\../skins/blitz_no_logo/header.txt \
$(SRCDIR)\../skins/blitz_no_logo/ticket.txt \
$(SRCDIR)\../skins/bootstrap/css.txt \
$(SRCDIR)\../skins/bootstrap/details.txt \
$(SRCDIR)\../skins/bootstrap/footer.txt \
$(SRCDIR)\../skins/bootstrap/header.txt \
$(SRCDIR)\../skins/default/css.txt \
$(SRCDIR)\../skins/default/details.txt \
$(SRCDIR)\../skins/default/footer.txt \
$(SRCDIR)\../skins/default/header.txt \
$(SRCDIR)\../skins/eagle/css.txt \
$(SRCDIR)\../skins/eagle/details.txt \
$(SRCDIR)\../skins/eagle/footer.txt \
|
| ︙ | ︙ | |||
610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
$(OX)\purge$O \
$(OX)\rebuild$O \
$(OX)\regexp$O \
$(OX)\report$O \
$(OX)\rss$O \
$(OX)\schema$O \
$(OX)\search$O \
$(OX)\setup$O \
$(OX)\sha1$O \
$(OX)\sha1hard$O \
$(OX)\sha3$O \
$(OX)\shell$O \
$(OX)\shun$O \
$(OX)\sitemap$O \
| > | 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
$(OX)\purge$O \
$(OX)\rebuild$O \
$(OX)\regexp$O \
$(OX)\report$O \
$(OX)\rss$O \
$(OX)\schema$O \
$(OX)\search$O \
$(OX)\security_audit$O \
$(OX)\setup$O \
$(OX)\sha1$O \
$(OX)\sha1hard$O \
$(OX)\sha3$O \
$(OX)\shell$O \
$(OX)\shun$O \
$(OX)\sitemap$O \
|
| ︙ | ︙ | |||
796 797 798 799 800 801 802 803 804 805 806 807 808 809 | echo $(OX)\purge.obj >> $@ echo $(OX)\rebuild.obj >> $@ echo $(OX)\regexp.obj >> $@ echo $(OX)\report.obj >> $@ echo $(OX)\rss.obj >> $@ echo $(OX)\schema.obj >> $@ echo $(OX)\search.obj >> $@ echo $(OX)\setup.obj >> $@ echo $(OX)\sha1.obj >> $@ echo $(OX)\sha1hard.obj >> $@ echo $(OX)\sha3.obj >> $@ echo $(OX)\shell.obj >> $@ echo $(OX)\shun.obj >> $@ echo $(OX)\sitemap.obj >> $@ | > | 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 | echo $(OX)\purge.obj >> $@ echo $(OX)\rebuild.obj >> $@ echo $(OX)\regexp.obj >> $@ echo $(OX)\report.obj >> $@ echo $(OX)\rss.obj >> $@ echo $(OX)\schema.obj >> $@ echo $(OX)\search.obj >> $@ echo $(OX)\security_audit.obj >> $@ echo $(OX)\setup.obj >> $@ echo $(OX)\sha1.obj >> $@ echo $(OX)\sha1hard.obj >> $@ echo $(OX)\sha3.obj >> $@ echo $(OX)\shell.obj >> $@ echo $(OX)\shun.obj >> $@ echo $(OX)\sitemap.obj >> $@ |
| ︙ | ︙ | |||
865 866 867 868 869 870 871 872 873 874 875 876 877 | mkversion$E: $(SRCDIR)\mkversion.c $(BCC) $** codecheck1$E: $(SRCDIR)\codecheck1.c $(BCC) $** !if $(USE_SEE)!=0 SQLITE3_SHELL_SRC = $(SRCDIR)\shell-see.c !else SQLITE3_SHELL_SRC = $(SRCDIR)\shell.c !endif $(OX)\shell$O : $(SQLITE3_SHELL_SRC) $B\win\Makefile.msc | > > > > | < < < < < < | 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 | mkversion$E: $(SRCDIR)\mkversion.c $(BCC) $** codecheck1$E: $(SRCDIR)\codecheck1.c $(BCC) $** !if $(USE_SEE)!=0 SEE_FLAGS = /DSQLITE_HAS_CODEC=1 /DSQLITE_SHELL_DBKEY_PROC=fossil_key SQLITE3_SHELL_SRC = $(SRCDIR)\shell-see.c SQLITE3_SRC = $(SRCDIR)\sqlite3-see.c !else SEE_FLAGS = SQLITE3_SHELL_SRC = $(SRCDIR)\shell.c SQLITE3_SRC = $(SRCDIR)\sqlite3.c !endif $(OX)\shell$O : $(SQLITE3_SHELL_SRC) $B\win\Makefile.msc $(TCC) /Fo$@ $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) $(SEE_FLAGS) -c $(SQLITE3_SHELL_SRC) $(OX)\sqlite3$O : $(SQLITE3_SRC) $B\win\Makefile.msc $(TCC) /Fo$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $(SEE_FLAGS) $(SQLITE3_SRC) $(OX)\th$O : $(SRCDIR)\th.c $(TCC) /Fo$@ -c $** |
| ︙ | ︙ | |||
1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 | translate$E $** > $@ $(OX)\search$O : search_.c search.h $(TCC) /Fo$@ -c search_.c search_.c : $(SRCDIR)\search.c translate$E $** > $@ $(OX)\setup$O : setup_.c setup.h $(TCC) /Fo$@ -c setup_.c setup_.c : $(SRCDIR)\setup.c translate$E $** > $@ | > > > > > > | 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 | translate$E $** > $@ $(OX)\search$O : search_.c search.h $(TCC) /Fo$@ -c search_.c search_.c : $(SRCDIR)\search.c translate$E $** > $@ $(OX)\security_audit$O : security_audit_.c security_audit.h $(TCC) /Fo$@ -c security_audit_.c security_audit_.c : $(SRCDIR)\security_audit.c translate$E $** > $@ $(OX)\setup$O : setup_.c setup.h $(TCC) /Fo$@ -c setup_.c setup_.c : $(SRCDIR)\setup.c translate$E $** > $@ |
| ︙ | ︙ | |||
1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 | purge_.c:purge.h \ rebuild_.c:rebuild.h \ regexp_.c:regexp.h \ report_.c:report.h \ rss_.c:rss.h \ schema_.c:schema.h \ search_.c:search.h \ setup_.c:setup.h \ sha1_.c:sha1.h \ sha1hard_.c:sha1hard.h \ sha3_.c:sha3.h \ shun_.c:shun.h \ sitemap_.c:sitemap.h \ skins_.c:skins.h \ | > | 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 | purge_.c:purge.h \ rebuild_.c:rebuild.h \ regexp_.c:regexp.h \ report_.c:report.h \ rss_.c:rss.h \ schema_.c:schema.h \ search_.c:search.h \ security_audit_.c:security_audit.h \ setup_.c:setup.h \ sha1_.c:sha1.h \ sha1hard_.c:sha1hard.h \ sha3_.c:sha3.h \ shun_.c:shun.h \ sitemap_.c:sitemap.h \ skins_.c:skins.h \ |
| ︙ | ︙ |
Changes to win/include/dirent.h.
1 2 | /* * Dirent interface for Microsoft Visual Studio | | | 1 2 3 4 5 6 7 8 9 10 | /* * Dirent interface for Microsoft Visual Studio * Version 1.23.1 * * Copyright (C) 2006-2012 Toni Ronkko * This file is part of dirent. Dirent may be freely distributed * under the MIT license. For all details and documentation, see * https://github.com/tronkko/dirent */ #ifndef DIRENT_H |
| ︙ | ︙ | |||
194 195 196 197 198 199 200 | #if !defined(S_ISCHR) # define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) #endif #if !defined(S_ISBLK) # define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) #endif | | | | > > > | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
#if !defined(S_ISCHR)
# define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
#endif
#if !defined(S_ISBLK)
# define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
#endif
/* Return the exact length of the file name without zero terminator */
#define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
/* Return the maximum size of a file name */
#define _D_ALLOC_NAMLEN(p) ((PATH_MAX)+1)
#ifdef __cplusplus
extern "C" {
#endif
/* Wide-character version */
struct _wdirent {
/* Always zero */
long d_ino;
/* File position within stream */
long d_off;
/* Structure size */
unsigned short d_reclen;
/* Length of name without \0 */
size_t d_namlen;
/* File type */
int d_type;
/* File name */
wchar_t d_name[PATH_MAX+1];
};
typedef struct _wdirent _wdirent;
struct _WDIR {
/* Current directory entry */
struct _wdirent ent;
|
| ︙ | ︙ | |||
243 244 245 246 247 248 249 |
HANDLE handle;
/* Initial directory name */
wchar_t *patt;
};
typedef struct _WDIR _WDIR;
| < < < < < < < < < < < < < < < | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
HANDLE handle;
/* Initial directory name */
wchar_t *patt;
};
typedef struct _WDIR _WDIR;
/* Multi-byte character version */
struct dirent {
/* Always zero */
long d_ino;
/* File position within stream */
long d_off;
/* Structure size */
unsigned short d_reclen;
/* Length of name without \0 */
size_t d_namlen;
/* File type */
int d_type;
/* File name */
char d_name[PATH_MAX+1];
};
typedef struct dirent dirent;
struct DIR {
struct dirent ent;
struct _WDIR *wdirp;
};
typedef struct DIR DIR;
/* Dirent functions */
static DIR *opendir (const char *dirname);
static _WDIR *_wopendir (const wchar_t *dirname);
static struct dirent *readdir (DIR *dirp);
static struct _wdirent *_wreaddir (_WDIR *dirp);
static int readdir_r(
DIR *dirp, struct dirent *entry, struct dirent **result);
static int _wreaddir_r(
_WDIR *dirp, struct _wdirent *entry, struct _wdirent **result);
static int closedir (DIR *dirp);
static int _wclosedir (_WDIR *dirp);
static void rewinddir (DIR* dirp);
static void _wrewinddir (_WDIR* dirp);
static int scandir (const char *dirname, struct dirent ***namelist,
int (*filter)(const struct dirent*),
int (*compare)(const void *, const void *));
static int alphasort (const struct dirent **a, const struct dirent **b);
static int versionsort (const struct dirent **a, const struct dirent **b);
/* For compatibility with Symbian */
#define wdirent _wdirent
#define WDIR _WDIR
#define wopendir _wopendir
#define wreaddir _wreaddir
#define wclosedir _wclosedir
#define wrewinddir _wrewinddir
/* Internal utility functions */
static WIN32_FIND_DATAW *dirent_first (_WDIR *dirp);
static WIN32_FIND_DATAW *dirent_next (_WDIR *dirp);
static int dirent_mbstowcs_s(
|
| ︙ | ︙ | |||
308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
size_t *pReturnValue,
char *mbstr,
size_t sizeInBytes,
const wchar_t *wcstr,
size_t count);
static void dirent_set_errno (int error);
/*
* Open directory stream DIRNAME for read and return a pointer to the
* internal working area that is used to retrieve individual directory
* entries.
*/
static _WDIR*
| > | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
size_t *pReturnValue,
char *mbstr,
size_t sizeInBytes,
const wchar_t *wcstr,
size_t count);
static void dirent_set_errno (int error);
/*
* Open directory stream DIRNAME for read and return a pointer to the
* internal working area that is used to retrieve individual directory
* entries.
*/
static _WDIR*
|
| ︙ | ︙ | |||
338 339 340 341 342 343 344 |
/* Reset _WDIR structure */
dirp->handle = INVALID_HANDLE_VALUE;
dirp->patt = NULL;
dirp->cached = 0;
/* Compute the length of full path plus zero terminator
| | | | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
/* Reset _WDIR structure */
dirp->handle = INVALID_HANDLE_VALUE;
dirp->patt = NULL;
dirp->cached = 0;
/* Compute the length of full path plus zero terminator
*
* Note that on WinRT there's no way to convert relative paths
* into absolute paths, so just assume its an absolute path.
*/
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
n = wcslen(dirname);
# else
n = GetFullPathNameW (dirname, 0, NULL, NULL);
# endif
/* Allocate room for absolute directory name and search pattern */
dirp->patt = (wchar_t*) malloc (sizeof (wchar_t) * n + 16);
if (dirp->patt) {
/*
* Convert relative directory name to an absolute one. This
* allows rewinddir() to function correctly even when current
* working directory is changed between opendir() and rewinddir().
*
* Note that on WinRT there's no way to convert relative paths
* into absolute paths, so just assume its an absolute path.
*/
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
wcsncpy_s(dirp->patt, n+1, dirname, n);
# else
n = GetFullPathNameW (dirname, n, dirp->patt, NULL);
|
| ︙ | ︙ | |||
423 424 425 426 427 428 429 |
dirp = NULL;
}
return dirp;
}
/*
| | > | < | > | > > > > > > > > > > > > > > > > > > > | > > > | < < < | | | | | | | | | > | > > > | | | | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
dirp = NULL;
}
return dirp;
}
/*
* Read next directory entry.
*
* Returns pointer to static directory entry which may be overwritted by
* subsequent calls to _wreaddir().
*/
static struct _wdirent*
_wreaddir(
_WDIR *dirp)
{
struct _wdirent *entry;
/*
* Read directory entry to buffer. We can safely ignore the return value
* as entry will be set to NULL in case of error.
*/
(void) _wreaddir_r (dirp, &dirp->ent, &entry);
/* Return pointer to statically allocated directory entry */
return entry;
}
/*
* Read next directory entry.
*
* Returns zero on success. If end of directory stream is reached, then sets
* result to NULL and returns zero.
*/
static int
_wreaddir_r(
_WDIR *dirp,
struct _wdirent *entry,
struct _wdirent **result)
{
WIN32_FIND_DATAW *datap;
/* Read next directory entry */
datap = dirent_next (dirp);
if (datap) {
size_t n;
DWORD attr;
/*
* Copy file name as wide-character string. If the file name is too
* long to fit in to the destination buffer, then truncate file name
* to PATH_MAX characters and zero-terminate the buffer.
*/
n = 0;
while (n < PATH_MAX && datap->cFileName[n] != 0) {
entry->d_name[n] = datap->cFileName[n];
n++;
}
entry->d_name[n] = 0;
/* Length of file name excluding zero terminator */
entry->d_namlen = n;
/* File type */
attr = datap->dwFileAttributes;
if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
entry->d_type = DT_CHR;
} else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
entry->d_type = DT_DIR;
} else {
entry->d_type = DT_REG;
}
/* Reset dummy fields */
entry->d_ino = 0;
entry->d_off = 0;
entry->d_reclen = sizeof (struct _wdirent);
/* Set result address */
*result = entry;
} else {
/* Return NULL to indicate end of directory */
*result = NULL;
}
return /*OK*/0;
}
/*
* Close directory stream opened by opendir() function. This invalidates the
* DIR structure as well as any directory entry read previously by
* _wreaddir().
*/
|
| ︙ | ︙ | |||
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
}
/* Release directory structure */
free (dirp);
ok = /*success*/0;
} else {
/* Invalid directory stream */
dirent_set_errno (EBADF);
ok = /*failure*/-1;
}
return ok;
}
/*
* Rewind directory stream such that _wreaddir() returns the very first
* file name again.
| > > | 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
}
/* Release directory structure */
free (dirp);
ok = /*success*/0;
} else {
/* Invalid directory stream */
dirent_set_errno (EBADF);
ok = /*failure*/-1;
}
return ok;
}
/*
* Rewind directory stream such that _wreaddir() returns the very first
* file name again.
|
| ︙ | ︙ | |||
565 566 567 568 569 570 571 |
dirp->cached = 0;
datap = NULL;
}
return datap;
}
| > | > > > | 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 |
dirp->cached = 0;
datap = NULL;
}
return datap;
}
/*
* Get next directory entry (internal).
*
* Returns
*/
static WIN32_FIND_DATAW*
dirent_next(
_WDIR *dirp)
{
WIN32_FIND_DATAW *p;
/* Get next directory entry */
|
| ︙ | ︙ | |||
602 603 604 605 606 607 608 |
p = NULL;
}
return p;
}
| | | | > | | 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
p = NULL;
}
return p;
}
/*
* Open directory stream using plain old C-string.
*/
static DIR*
opendir(
const char *dirname)
{
struct DIR *dirp;
int error;
/* Must have directory name */
if (dirname == NULL || dirname[0] == '\0') {
dirent_set_errno (ENOENT);
return NULL;
}
/* Allocate memory for DIR structure */
dirp = (DIR*) malloc (sizeof (struct DIR));
if (dirp) {
wchar_t wname[PATH_MAX + 1];
size_t n;
/* Convert directory name to wide-character string */
error = dirent_mbstowcs_s(
&n, wname, PATH_MAX + 1, dirname, PATH_MAX + 1);
if (!error) {
/* Open directory stream using wide-character name */
dirp->wdirp = _wopendir (wname);
if (dirp->wdirp) {
/* Directory stream opened */
error = 0;
} else {
/* Failed to open directory stream */
error = 1;
}
} else {
/*
* Cannot convert file name to wide-character string. This
* occurs if the string contains invalid multi-byte sequences or
* the output buffer is too small to contain the resulting
* string.
*/
error = 1;
}
|
| ︙ | ︙ | |||
664 665 666 667 668 669 670 |
}
return dirp;
}
/*
* Read next directory entry.
| | | | | < > | | > > > > > | > > > | < > > > > > | | | > > < | | | | < < < | | | | | > | > | < | | | | | > | | | > > > > > | | | > | | | 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 |
}
return dirp;
}
/*
* Read next directory entry.
*/
static struct dirent*
readdir(
DIR *dirp)
{
struct dirent *entry;
/*
* Read directory entry to buffer. We can safely ignore the return value
* as entry will be set to NULL in case of error.
*/
(void) readdir_r (dirp, &dirp->ent, &entry);
/* Return pointer to statically allocated directory entry */
return entry;
}
/*
* Read next directory entry into called-allocated buffer.
*
* Returns zero on sucess. If the end of directory stream is reached, then
* sets result to NULL and returns zero.
*/
static int
readdir_r(
DIR *dirp,
struct dirent *entry,
struct dirent **result)
{
WIN32_FIND_DATAW *datap;
/* Read next directory entry */
datap = dirent_next (dirp->wdirp);
if (datap) {
size_t n;
int error;
/* Attempt to convert file name to multi-byte string */
error = dirent_wcstombs_s(
&n, entry->d_name, PATH_MAX + 1, datap->cFileName, PATH_MAX + 1);
/*
* If the file name cannot be represented by a multi-byte string,
* then attempt to use old 8+3 file name. This allows traditional
* Unix-code to access some file names despite of unicode
* characters, although file names may seem unfamiliar to the user.
*
* Be ware that the code below cannot come up with a short file
* name unless the file system provides one. At least
* VirtualBox shared folders fail to do this.
*/
if (error && datap->cAlternateFileName[0] != '\0') {
error = dirent_wcstombs_s(
&n, entry->d_name, PATH_MAX + 1,
datap->cAlternateFileName, PATH_MAX + 1);
}
if (!error) {
DWORD attr;
/* Length of file name excluding zero terminator */
entry->d_namlen = n - 1;
/* File attributes */
attr = datap->dwFileAttributes;
if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
entry->d_type = DT_CHR;
} else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
entry->d_type = DT_DIR;
} else {
entry->d_type = DT_REG;
}
/* Reset dummy fields */
entry->d_ino = 0;
entry->d_off = 0;
entry->d_reclen = sizeof (struct dirent);
} else {
/*
* Cannot convert file name to multi-byte string so construct
* an errornous directory entry and return that. Note that
* we cannot return NULL as that would stop the processing
* of directory entries completely.
*/
entry->d_name[0] = '?';
entry->d_name[1] = '\0';
entry->d_namlen = 1;
entry->d_type = DT_UNKNOWN;
entry->d_ino = 0;
entry->d_off = -1;
entry->d_reclen = 0;
}
/* Return pointer to directory entry */
*result = entry;
} else {
/* No more directory entries */
*result = NULL;
}
return /*OK*/0;
}
/*
* Close directory stream.
*/
static int
closedir(
DIR *dirp)
{
int ok;
if (dirp) {
/* Close wide-character directory stream */
ok = _wclosedir (dirp->wdirp);
dirp->wdirp = NULL;
|
| ︙ | ︙ | |||
787 788 789 790 791 792 793 | } /* * Rewind directory stream to beginning. */ static void rewinddir( | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 |
}
/*
* Rewind directory stream to beginning.
*/
static void
rewinddir(
DIR* dirp)
{
/* Rewind wide-character string directory stream */
_wrewinddir (dirp->wdirp);
}
/*
* Scan directory for entries.
*/
static int
scandir(
const char *dirname,
struct dirent ***namelist,
int (*filter)(const struct dirent*),
int (*compare)(const void*, const void*))
{
struct dirent **files = NULL;
size_t size = 0;
size_t allocated = 0;
const size_t init_size = 1;
DIR *dir = NULL;
struct dirent *entry;
struct dirent *tmp = NULL;
size_t i;
int result = 0;
/* Open directory stream */
dir = opendir (dirname);
if (dir) {
/* Read directory entries to memory */
while (1) {
/* Enlarge pointer table to make room for another pointer */
if (size >= allocated) {
void *p;
size_t num_entries;
/* Compute number of entries in the enlarged pointer table */
if (size < init_size) {
/* Allocate initial pointer table */
num_entries = init_size;
} else {
/* Double the size */
num_entries = size * 2;
}
/* Allocate first pointer table or enlarge existing table */
p = realloc (files, sizeof (void*) * num_entries);
if (p != NULL) {
/* Got the memory */
files = (dirent**) p;
allocated = num_entries;
} else {
/* Out of memory */
result = -1;
break;
}
}
/* Allocate room for temporary directory entry */
if (tmp == NULL) {
tmp = (struct dirent*) malloc (sizeof (struct dirent));
if (tmp == NULL) {
/* Cannot allocate temporary directory entry */
result = -1;
break;
}
}
/* Read directory entry to temporary area */
if (readdir_r (dir, tmp, &entry) == /*OK*/0) {
/* Did we got an entry? */
if (entry != NULL) {
int pass;
/* Determine whether to include the entry in result */
if (filter) {
/* Let the filter function decide */
pass = filter (tmp);
} else {
/* No filter function, include everything */
pass = 1;
}
if (pass) {
/* Store the temporary entry to pointer table */
files[size++] = tmp;
tmp = NULL;
/* Keep up with the number of files */
result++;
}
} else {
/*
* End of directory stream reached => sort entries and
* exit.
*/
qsort (files, size, sizeof (void*), compare);
break;
}
} else {
/* Error reading directory entry */
result = /*Error*/ -1;
break;
}
}
} else {
/* Cannot open directory */
result = /*Error*/ -1;
}
/* Release temporary directory entry */
if (tmp) {
free (tmp);
}
/* Release allocated memory on error */
if (result < 0) {
for (i = 0; i < size; i++) {
free (files[i]);
}
free (files);
files = NULL;
}
/* Close directory stream */
if (dir) {
closedir (dir);
}
/* Pass pointer table to caller */
if (namelist) {
*namelist = files;
}
return result;
}
/* Alphabetical sorting */
static int
alphasort(
const struct dirent **a, const struct dirent **b)
{
return strcoll ((*a)->d_name, (*b)->d_name);
}
/* Sort versions */
static int
versionsort(
const struct dirent **a, const struct dirent **b)
{
/* FIXME: implement strverscmp and use that */
return alphasort (a, b);
}
/* Convert multi-byte string to wide character string */
static int
dirent_mbstowcs_s(
size_t *pReturnValue,
wchar_t *wcstr,
size_t sizeInWords,
|
| ︙ | ︙ |
Changes to win/include/unistd.h.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 | #define F_OK 0 #endif /* not F_OK */ #ifndef X_OK #define X_OK 1 #endif /* not X_OK */ | | | | | | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #define F_OK 0 #endif /* not F_OK */ #ifndef X_OK #define X_OK 1 #endif /* not X_OK */ #ifndef W_OK #define W_OK 2 #endif /* not W_OK */ #ifndef R_OK #define R_OK 4 #endif /* not R_OK */ #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif |
| ︙ | ︙ |
Changes to www/aboutcgi.wiki.
| ︙ | ︙ | |||
139 140 141 142 143 144 145 | In case (B), the PATH_INFO is just "info", but the same "name" query parameter is set explicitly by the URL itself. </blockquote> <h2>Serving Multiple Fossil Repositories From One CGI Script</h2> <blockquote> The previous example showed how to serve a single Fossil repository using a single CGI script. | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | In case (B), the PATH_INFO is just "info", but the same "name" query parameter is set explicitly by the URL itself. </blockquote> <h2>Serving Multiple Fossil Repositories From One CGI Script</h2> <blockquote> The previous example showed how to serve a single Fossil repository using a single CGI script. On a website that wants to serve multiple repositories, one could simply create multiple CGI scripts, one script for each repository. But it is also possible to serve multiple Fossil repositories from a single CGI script. <p> If the CGI script for Fossil contains a "directory:" line instead of a "repository:" line, then the argument to "directory:" is the name of a directory that contains multiple repository files, each ending |
| ︙ | ︙ |
Added www/aboutdownload.wiki.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
<title>How The Fossil Download Page Works</title>
<h1 align="center">How The Download Page Works</h1>
<h2>1.0 Overview</h2>
The [/uv/download.html|Download] page for the Fossil self-hosting
repository is implemented using [./unvers.wiki|unversioned files].
The "download.html" screen itself, and the various build products
are all stored as unversioned content. The download.html page
uses AJAX to retrieve the [/help?cmd=/juvlist|/juvlist] webpage
for a list of all unversioned files. Javascript within the
download.html page then figures out which unversioned files are
build products and paints appropriate icons on the displayed
download page.
When a new version is generated, the developers use the
[/help?cmd=uv|fossil uv edit] command to make minor changes
to the "[/uv/download.html?mimetype=text/plain|download.html]"
file so that it knows about the
new version number. Then the developers run
the [/help?cmd=uv|fossil uv add] command for each
build product. Finally, the
[/help?cmd=uv|fossil uv sync] command is run to push all
the content up to servers. All
[./selfhost.wiki|three self-hosting repositories] for Fossil
are updated automatically.
<h2>2.0 Details</h2>
The current text of the "download.html" file can be seen
[/uv/download.html?mimetype=text/plain|here]. (Mouse-over that
hyperlink to see how the "mimetype=text/plain" query parameter
is added in order to display the file as plain text instead of
the usual HTML.) The default mimetype for "download.html" is
text/html. But because the entire page is enclosed within
<b><div class='fossil-doc' data-title='Download Page'>...</div></b>
Fossil knows to add its standard header and footer information to the
document, making it look just like any other page. See
"[./embeddeddoc.wiki|embedded documentation]" for further details on
how this works.
With each new release, the "releases" variable in the javascript on
the [/uv/download.html?mimetype=text/plain|download.html] page is
edited (using "[/help?cmd=uv|fossil uv edit download.html]") to add
details of the release.
When the javascript on the "download.html" page runs, it requests
a listing of all unversioned content using the /juvlist URL.
([/juvlist|sample /juvlist output]). The content of the download page is
constructed by matching unversioned files against regular expressions
in the "releases" variable.
Build products need to be constructed on different machines. The precompiled
binary for Linux is compiled on Linux, the precompiled binary for Windows
is compiled on Windows10, and so forth. After a new release is tagged,
the release manager goes around to each of the target platforms, checks
out the release and compiles it, then runs
[/help?cmd=uv|fossil uv add] for the build product followed by
[/help?cmd=uv|fossil uv sync] to push the new build product to the
[./selfhost.wiki|various servers]. This process is repeated for
each build product.
When older builds are retired from the download page, the
[/uv/download.html?mimetype=text/plain|download.html] page is again
edited to remove the corresponding entry from the "release" variable
and the edit is synced using
[/help?cmd=uv|fossil uv sync]. This causes the build products to
disappear from the download page immediately. But those build products
are still taking up space in the unversioned content table of the
server repository. To purge the obsolete build products, one or
more [/help?cmd=uv|fossil uv rm] commands are run, followed by
another [/help?cmd=uv|fossil uv sync]. It is important to purge
obsolete build products since they take up a lot of space.
At [/repo-tabsize] you can see that the unversioned table takes up
a substantial fraction of the repository.
<h2>3.0 Security</h2>
Only users with the [/setup_ulist_notes|"y" permission] are allowed
to push unversioned content up to the servers. Having the ability
to push check-ins (the [/setup_ulist_notes|"i" permission]) is not
sufficient.
On the Fossil project there are 67 people (as of 2017-03-24) who have
check-in privileges. But only 3 core developers
can push unversioned content and thus
change the build products on the download page. Minimizing the number
of people who can change the build products helps to ensure that
rogue binaries do not slip onto the download page unnoticed.
|
Changes to www/antibot.wiki.
| ︙ | ︙ | |||
87 88 89 90 91 92 93 | without "href=" attributes. Then, javascript code is added to the end of the page that goes back and fills in the "href=" attributes of the anchor tags with the hyperlink targets, thus enabling the hyperlinks. This extra step of using javascript to enable the hyperlink targets is a security measure against spiders that forge a human-looking UserAgent string. Most spiders do not bother to run javascript and so to the spider the empty anchor tag will be useless. But all modern | | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | without "href=" attributes. Then, javascript code is added to the end of the page that goes back and fills in the "href=" attributes of the anchor tags with the hyperlink targets, thus enabling the hyperlinks. This extra step of using javascript to enable the hyperlink targets is a security measure against spiders that forge a human-looking UserAgent string. Most spiders do not bother to run javascript and so to the spider the empty anchor tag will be useless. But all modern web browsers implement javascript, so hyperlinks will show up normally for human users. <h2>Further defenses</h2> Recently (as of this writing, in the spring of 2013) the Fossil server on the SQLite website ([http://www.sqlite.org/src/]) has been hit repeatedly by Chinese spiders that use forged UserAgent strings to make them look |
| ︙ | ︙ | |||
127 128 129 130 131 132 133 134 135 136 137 138 139 140 | delay is 10 milliseconds. The idea here is that a spider will try to render the page immediately, and will not wait for delayed scripts to be run, thus will never enable the hyperlinks. These two subsettings can be used separately or together. If used together, then the delay timer does not start until after the first mouse movement is detected. <h2>The ongoing struggle</h2> Fossil currently does a very good job of providing easy access to humans while keeping out troublesome robots and spiders. However, spiders and bots continue to grow more sophisticated, requiring ever more advanced defenses. This "arms race" is unlikely to ever end. The developers of | > > > > | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | delay is 10 milliseconds. The idea here is that a spider will try to render the page immediately, and will not wait for delayed scripts to be run, thus will never enable the hyperlinks. These two subsettings can be used separately or together. If used together, then the delay timer does not start until after the first mouse movement is detected. See also [./server.wiki#loadmgmt|Managing Server Load] for a description of how expensive pages can be disabled when the server is under heavy load. <h2>The ongoing struggle</h2> Fossil currently does a very good job of providing easy access to humans while keeping out troublesome robots and spiders. However, spiders and bots continue to grow more sophisticated, requiring ever more advanced defenses. This "arms race" is unlikely to ever end. The developers of |
| ︙ | ︙ |
Changes to www/build.wiki.
1 2 3 4 | <title>Compiling and Installing Fossil</title> <h2>0.0 Using A Pre-compiled Binary</h2> | < | < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <title>Compiling and Installing Fossil</title> <h2>0.0 Using A Pre-compiled Binary</h2> <p>[/uv/download.html|Pre-compiled binaries] are available for recent releases. Just download the appropriate executable for your platform and put it on your $PATH. To uninstall, simply delete the executable. To upgrade from an older release, just overwrite the older binary with the newer one.</p> <h2>0.1 Executive Summary</h2> <p>Building and installing is very simple. Three steps:</p> |
| ︙ | ︙ | |||
27 28 29 30 31 32 33 | <h2>1.0 Obtaining The Source Code</h2> <p>Fossil is self-hosting, so you can obtain a ZIP archive or tarball containing a snapshot of the <em>latest</em> version directly from Fossil's own fossil repository. Additionally, source archives of <em>released</em> versions of | | | < < | < | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <h2>1.0 Obtaining The Source Code</h2> <p>Fossil is self-hosting, so you can obtain a ZIP archive or tarball containing a snapshot of the <em>latest</em> version directly from Fossil's own fossil repository. Additionally, source archives of <em>released</em> versions of fossil are available from the [/uv/download.html|downloads page]. To obtain a development version of fossil, follow these steps:</p> <ol> <li><p>Point your web browser to [https://www.fossil-scm.org/]</li> <li><p>Click on the [/timeline|Timeline] link at the top of the page.</p></li> <li><p>Select a version of of Fossil you want to download. The latest version on the trunk branch is usually a good choice. Click on its link.</p></li> <li><p>Finally, click on one of the |
| ︙ | ︙ | |||
139 140 141 142 143 144 145 | file "<b>win\buildmsvc.bat</b>" may be used and it will attempt to detect and use the latest installed version of MSVC.<br><br>To enable the optional <a href="https://www.openssl.org/">OpenSSL</a> support, first <a href="https://www.openssl.org/source/">download the official source code for OpenSSL</a> and extract it to an appropriately named "<b>openssl-X.Y.ZA</b>" subdirectory within the local [/tree?ci=trunk&name=compat | compat] directory (e.g. | | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | file "<b>win\buildmsvc.bat</b>" may be used and it will attempt to detect and use the latest installed version of MSVC.<br><br>To enable the optional <a href="https://www.openssl.org/">OpenSSL</a> support, first <a href="https://www.openssl.org/source/">download the official source code for OpenSSL</a> and extract it to an appropriately named "<b>openssl-X.Y.ZA</b>" subdirectory within the local [/tree?ci=trunk&name=compat | compat] directory (e.g. "<b>compat/openssl-1.0.2l</b>"), then make sure that some recent <a href="http://www.perl.org/">Perl</a> binaries are installed locally, and finally run one of the following commands: <blockquote><pre> nmake /f Makefile.msc FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin </pre></blockquote> <blockquote><pre> buildmsvc.bat FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin |
| ︙ | ︙ |
Changes to www/changes.wiki.
1 2 3 4 5 6 7 8 9 |
<title>Change Log</title>
<a name='v2_1'></a>
<h2>Changes for Version 2.1 (2017-03-10)</h2>
* Add support for [./hashpolicy.wiki|hash policies] that control which
of the Hardened-SHA1 or SHA3-256 algorithms is used to name new
artifacts.
* Add the "gshow" and "gcat" subcommands to [/help?cmd=stash|fossil stash].
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
<title>Change Log</title>
<a name='v2_4'></a>
<h2>Changes for Version 2.4 (TBD)</h2>
* Add tech-note search capability.
* Add the -r|--revision and -o|--origin options to the
[/help?cmd=annotate|annotate] command.
* Add the origin= query parameter to the [/help?cmd=/annotate|/annotate]
webpage.
* Support for URL Aliases added. URL Aliases allow an administrator
to define their own URLs on the web interface that are rewritten to
built-in URLs with specific parameters.
* Provide separate on-line help screens for each setting.
* Back out support for the --no-dir-symlinks option
* Remove support from the legacy configuration sync protocol. The only
way now to do a configuration push or pull is to use the new protocol that
was added in 2011.
* Add the from= and to= query parameters to [/help?cmd=/fdiff|/fdiff]
in order to get a diff of two files in the same check-in.
* Fix the "ssh://" protocol to prevent an attack whereby the attacker convinces
a victim to run a "clone" with a dodgy URL and thereby gains access to their
system.
* Provide a checkbox that will temporarily disable all ad-units.
* Improvements to the [/help?cmd=/stat|/stat] page
* Various new hyperlinks to the [/help?cmd=/bloblist|/bloblist]
and [/help?cmd=/bigbloblist|/bigbloblist] pages.
* Correct the [/help?cmd=/doc|/doc] page to support read-only repositories.
* Correct [/help?cmd=/zip|/zip], [/help?cmd=/tarball|/tarball],
[/help?cmd=zip|zip], and [/help?cmd=tarball|tarball] pages and commands to
honor the versioned manifest setting when outside of an open checkout
directory.
* The admin-log and access-log settings are now on by default for
new repositories.
* Update the built-in SQLite to version 3.20.1.
<a name='v2_3'></a>
<h2>Changes for Version 2.3 (2017-07-21)</h2>
* Update the built-in SQLite to version 3.20.0 (beta).
* Update internal Unicode character tables, used in regular expression
handling, from version 9.0 to 10.0.
* Show the last-sync-URL on the [/help?cmd=/urllist|/urllist] page.
* Added the "Event Summary" activity report.
[/reports?type=ci&view=lastchng|example]
* Added the "Security Audit" page, available to administrators only
* Added the Last Login time to the user list page, for administrators only
* Added the --numstat option to the [/help?cmd=diff|fossil diff] command
* Limit the size of the heap and stack on unix systems, as a proactive
defense against the
[https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt|Stack Clash]
attack.
* Fix "database locked" warnings caused by "PRAGMA optimize".
* Fix a potential XSS vulnerability on the
[/help?cmd=/help|/help] webpage.
* Documentation updates
<a name='v2_2'></a>
<h2>Changes for Version 2.2 (2017-04-11)</h2>
* GIT comment tags are now handled by Fossil during import/export.
* Show the content of README files on directory listings.
([/file/skins|example])
* Support for Basic Authentication if enabled (default off).
* Show the hash algorithms used on the
[/help?cmd=/rcvfromlist|/rcvfromlist] page.
* The [/help?cmd=/tarball|/tarball] and [/help?cmd=/zip|/zip] pages
now use the the r= query parameter
to select which check-in to deliver. The uuid= query parameter
is still accepted for backwards compatibility.
* Update the built-in SQLite to version 3.18.0.
* Run "[https://www.sqlite.org/pragma.html#pragma_optimize|PRAGMA optimize]"
on the database connection as it is closing.
<a name='v2_1'></a>
<h2>Changes for Version 2.1 (2017-03-10)</h2>
* Add support for [./hashpolicy.wiki|hash policies] that control which
of the Hardened-SHA1 or SHA3-256 algorithms is used to name new
artifacts.
* Add the "gshow" and "gcat" subcommands to [/help?cmd=stash|fossil stash].
|
| ︙ | ︙ | |||
24 25 26 27 28 29 30 |
* Update the built-in SQLite to version 3.17.0.
<a name='v1_37'></a>
<h2>Changes for Version 1.37 (2017-01-16)</h2>
* Add checkbox widgets to various web pages. See [/technote/8d18bf27e9|
this technote] for more information. To get the checkboxes to look as
| | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
* Update the built-in SQLite to version 3.17.0.
<a name='v1_37'></a>
<h2>Changes for Version 1.37 (2017-01-16)</h2>
* Add checkbox widgets to various web pages. See [/technote/8d18bf27e9|
this technote] for more information. To get the checkboxes to look as
intended, you must update the CSS in your repository and all clones.
* Add the [/help/all|fossil all ui] command
* Add the [/help?cmd=/file|/file] webpage
* Enhance the [/help?cmd=/brlist|/brlist] webpage to make use of branch colors.
* Add support for the ms=EXACT|LIKE|GLOB|REGEXP query parameter on the
[/help?cmd=/timeline|/timeline] webpage, with associated form widgets.
* Enhance the [/help/changes|changes] and [/help/status|status] commands
with many new filter options so that specific kinds of changes can be
|
| ︙ | ︙ |
Changes to www/env-opts.md.
| ︙ | ︙ | |||
139 140 141 142 143 144 145 146 147 148 149 150 151 152 | `FOSSIL_HOME`: Location of the `~/.fossil` file. The first environment variable found in the environment from the list `FOSSIL_HOME`, `LOCALAPPDATA` (Windows), `APPDATA` (Windows), `HOMEDRIVE` and `HOMEPATH` (Windows, used together), and `HOME` is used as the location of the `~/.fossil` file. `FOSSIL_USER`: Name of the default user account if the checkout, local or global `default-user` setting is not present. The first environment variable found in the environment from the list `FOSSIL_USER`, `USER`, `LOGNAME`, and `USERNAME` is the user name. If none of those are set, then the default user name is "root". See the discussion of Fossil Username below for a lot more detail. | > > > > > > | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | `FOSSIL_HOME`: Location of the `~/.fossil` file. The first environment variable found in the environment from the list `FOSSIL_HOME`, `LOCALAPPDATA` (Windows), `APPDATA` (Windows), `HOMEDRIVE` and `HOMEPATH` (Windows, used together), and `HOME` is used as the location of the `~/.fossil` file. `FOSSIL_USE_SEE_TEXTKEY`: If set, treat the encryption key string for SEE as text to be hashed into the actaul encryption key. This has no effect if Fossil was not compiled with SEE support enabled. `FOSSIL_USER`: Name of the default user account if the checkout, local or global `default-user` setting is not present. The first environment variable found in the environment from the list `FOSSIL_USER`, `USER`, `LOGNAME`, and `USERNAME` is the user name. If none of those are set, then the default user name is "root". See the discussion of Fossil Username below for a lot more detail. |
| ︙ | ︙ |
Changes to www/fossil-v-git.wiki.
| ︙ | ︙ | |||
116 117 118 119 120 121 122 | small and sometimes haphazard contributions. Fossil promotes a "cathedral" development model in which the project is closely supervised by an highly engaged architect and implemented by a clique of developers. Nota Bene: This is not to say that Git cannot be used for cathedral-style development or that Fossil cannot be used for bazaar-style development. | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | small and sometimes haphazard contributions. Fossil promotes a "cathedral" development model in which the project is closely supervised by an highly engaged architect and implemented by a clique of developers. Nota Bene: This is not to say that Git cannot be used for cathedral-style development or that Fossil cannot be used for bazaar-style development. They can be. But those modes are not their design intent nor their low-friction path. Git encourages a style in which individual developers work in relative isolation, maintaining their own branches and occasionally rebasing and pushing selected changes up to the main repository. Developers using Git often have their own private branches that nobody else ever sees. Work becomes siloed. |
| ︙ | ︙ | |||
143 144 145 146 147 148 149 | Git was specifically designed to support the development of Linux. Fossil was specifically designed to support the development of SQLite. Both SQLite and Linux are important pieces of software. SQLite is found on far more systems than Linux. (Almost every Linux system uses SQLite, but there are many non-Linux systems such as | | | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | Git was specifically designed to support the development of Linux. Fossil was specifically designed to support the development of SQLite. Both SQLite and Linux are important pieces of software. SQLite is found on far more systems than Linux. (Almost every Linux system uses SQLite, but there are many non-Linux systems such as iPhones, PlayStations, and Windows PCs that use SQLite.) On the other hand, for those systems that do use Linux, Linux is a far more important component. Linux uses a bazaar-style development model. There are thousands and thousands of contributors, most of whom do not know each others names. Git is designed for this scenario. |
| ︙ | ︙ |
Added www/globs.md.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
# File Name Glob Patterns
A [glob pattern][glob] is a text expression that matches one or more
file names using wild cards familiar to most users of a command line.
For example, `*` is a glob that matches any name at all and
`Readme.txt` is a glob that matches exactly one file.
Note that although both are notations for describing patterns in text,
glob patterns are not the same thing as a [regular expression or
regexp][regexp].
[glob]: https://en.wikipedia.org/wiki/Glob_(programming) (Wikipedia)
[regexp]: https://en.wikipedia.org/wiki/Regular_expression
A number of fossil setting values hold one or more file glob patterns
that will identify files needing special treatment. Glob patterns are
also accepted in options to certain commands as well as query
parameters to certain pages.
In many cases more than one glob may be specified in a setting,
option, or query parameter by listing multiple globs separated by a
comma or white space.
Of course, many fossil commands also accept lists of files to act on,
and those also may be specified with globs. Although those glob
patterns are similar to what is described here, they are not defined
by fossil, but rather by the conventions of the operating system in
use.
## Syntax
A list of glob patterns is simply one or more glob patterns separated
by white space or commas. If a glob must contain white spaces or
commas, it can be quoted with either single or double quotation marks.
A list is said to match if any one (or more) globs in the list
matches.
A glob pattern is a collection of characters compared to a target
text, usually a file name. The whole glob is said to match if it
successfully consumes and matches the entire target text. Glob
patterns are made up of ordinary characters and special characters.
Ordinary characters consume a single character of the target and must
match it exactly.
Special characters (and special character sequences) consume zero or
more characters from the target and describe what matches. The special
characters (and sequences) are:
:Pattern |:Effect
---------------------------------------------------------------------
`*` | Matches any sequence of zero or more characters
`?` | Matches exactly one character
`[...]` | Matches one character from the enclosed list of characters
`[^...]` | Matches one character not in the enclosed list
Special character sequences have some additional features:
* A range of characters may be specified with `-`, so `[a-d]` matches
exactly the same characters as `[abcd]`. Ranges reflect Unicode
code points without any locale-specific collation sequence.
* Include `-` in a list by placing it last, just before the `]`.
* Include `]` in a list by making the first character after the `[` or
`[^`. At any other place, `]` ends the list.
* Include `^` in a list by placing anywhere except first after the
`[`.
* Beware that ranges in lists may include more than you expect:
`[A-z]` Matches `A` and `Z`, but also matches `a` and some less
obvious characters such as `[`, `\`, and `]` with code point
values between `Z` and `a`.
* Beware that a range must be specified from low value to high
value: `[z-a]` does not match any character at all, preventing the
entire glob from matching.
* Note that unlike typical Unix shell globs, wildcards (`*`, `?`,
and character lists) are allowed to match `/` directory
separators as well as the initial `.` in the name of a hidden
file or directory.
Some examples of character lists:
:Pattern |:Effect
---------------------------------------------------------------------
`[a-d]` | Matches any one of `a`, `b`, `c`, or `d` but not `ä`
`[^a-d]` | Matches exactly one character other than `a`, `b`, `c`, or `d`
`[0-9a-fA-F]` | Matches exactly one hexadecimal digit
`[a-]` | Matches either `a` or `-`
`[][]` | Matches either `]` or `[`
`[^]]` | Matches exactly one character other than `]`
`[]^]` | Matches either `]` or `^`
`[^-]` | Matches exactly one character other than `-`
White space means the specific ASCII characters TAB, LF, VT, FF, CR,
and SPACE. Note that this does not include any of the many additional
spacing characters available in Unicode, and specifically does not
include U+00A0 NO-BREAK SPACE.
Because both LF and CR are white space and leading and trailing spaces
are stripped from each glob in a list, a list of globs may be broken
into lines between globs when the list is stored in a file (as for a
versioned setting).
Similarly 'single quotes' and "double quotes" are the ASCII straight
quote characters, not any of the other quotation marks provided in
Unicode and specifically not the "curly" quotes preferred by
typesetters and word processors.
## File Names to Match
Before it is compared to a glob pattern, each file name is transformed
to a canonical form. The glob must match the entire canonical file
name to be considered a match.
The canonical name of a file has all directory separators changed to
`/`, redundant slashes are removed, all `.` path components are
removed, and all `..` path components are resolved. (There are
additional details we are ignoring here, but they cover rare edge
cases and also follow the principle of least surprise.)
The goal is to have a name that is the simplest possible for each
particular file, and that will be the same on Windows, Unix, and any
other platform where fossil is run.
Beware, however, that all glob matching is case sensitive. This will
not be a surprise on Unix where all file names are also case
sensitive. However, most Windows file systems are case preserving and
case insensitive. That is, on Windows, the names `ReadMe` and `README`
are names of the same file; on Unix they are different files.
Some example cases:
:Pattern |:Effect
--------------------------------------------------------------------------------
`README` | Matches only a file named `README` in the root of the tree. It does not match a file named `src/README` because it does not include any characters that consume (and match) the `src/` part.
`*/README` | Matches `src/README`. Unlike Unix file globs, it also matches `src/library/README`. However it does not match the file `README` in the root of the tree.
`*README` | Matches `src/README` as well as the file `README` in the root of the tree as well as `foo/bar/README` or any other file named `README` in the tree. However, it also matches `A-DIFFERENT-README` and `src/DO-NOT-README`, or any other file whose name ends with `README`.
`src/README` | Matches `src\README` on Windows because all directory separators are rewritten as `/` in the canonical name before the glob is matched. This makes it much easier to write globs that work on both Unix and Windows.
`*.[ch]` | Matches every C source or header file in the tree at the root or at any depth. Again, this is (deliberately) different from Unix file globs and Windows wild cards.
## Where Globs are Used
### Settings that are Globs
These settings are all lists of glob patterns:
:Setting |:Description
--------------------------------------------------------------------------------
`binary-glob` | Files that should be treated as binary files for committing and merging purposes
`clean-glob` | Files that the [`clean`][] command will delete without prompting or allowing undo
`crlf-glob` | Files in which it is okay to have `CR`, `CR`+`LF` or mixed line endings. Set to "`*`" to disable CR+LF checking
`crnl-glob` | Alias for the `crlf-glob` setting
`encoding-glob` | Files that the [`commit`][] command will ignore when issuing warnings about text files that may use another encoding than ASCII or UTF-8. Set to "`*`" to disable encoding checking
`ignore-glob` | Files that the [`add`][], [`addremove`][], [`clean`][], and [`extras`][] commands will ignore
`keep-glob` | Files that the [`clean`][] command will keep
All may be [versioned, local, or global](settings.wiki). Use `fossil
settings` to manage local and global settings, or a file in the
repository's `.fossil-settings/` folder at the root of the tree named
for each for versioned setting.
Using versioned settings for these not only has the advantage that
they are tracked in the repository just like the rest of your project,
but you can more easily keep longer lists of more complicated glob
patterns than would be practical in either local or global settings.
The `ignore-glob` is an example of one setting that frequently grows
to be an elaborate list of files that should be ignored by most
commands. This is especially true when one (or more) IDEs are used in
a project because each IDE has its own ideas of how and where to cache
information that speeds up its browsing and building tasks but which
need not be preserved in your project's history.
### Commands that Refer to Globs
Many of the commands that respect the settings containing globs have
options to override some or all of the settings. These options are
usually named to correspond to the setting they override, such as
`--ignore` to override the `ignore-glob` setting. These commands are:
* [`add`][]
* [`addremove`][]
* [`changes`][]
* [`clean`][]
* [`commit`][]
* [`extras`][]
* [`merge`][]
* [`settings`][]
* [`status`][]
* [`unset`][]
The commands [`tarball`][] and [`zip`][] produce compressed archives of a
specific checkin. They may be further restricted by options that
specify glob patterns that name files to include or exclude rather
than archiving the entire checkin.
The commands [`http`][], [`cgi`][], [`server`][], and [`ui`][] that
implement or support with web servers provide a mechanism to name some
files to serve with static content where a list of glob patterns
specifies what content may be served.
[`add`]: /help?cmd=add
[`addremove`]: /help?cmd=addremove
[`changes`]: /help?cmd=changes
[`clean`]: /help?cmd=clean
[`commit`]: /help?cmd=commit
[`extras`]: /help?cmd=extras
[`merge`]: /help?cmd=merge
[`settings`]: /help?cmd=settings
[`status`]: /help?cmd=status
[`unset`]: /help?cmd=unset
[`tarball`]: /help?cmd=tarball
[`zip`]: /help?cmd=zip
[`http`]: /help?cmd=http
[`cgi`]: /help?cmd=cgi
[`server`]: /help?cmd=server
[`ui`]: /help?cmd=ui
### Web Pages that Refer to Globs
The [`/timeline`][] page supports the query parameter `chng=GLOBLIST` that
names a list of glob patterns defining which files to focus the
timeline on. It also has the query parameters `t=TAG` and `r=TAG` that
names a tag to focus on, which can be configured with `ms=STYLE` to
use a glob pattern to match tag names instead of the default exact
match or a couple of other comparison styles.
The pages [`/tarball`][] and [`/zip`][] generate compressed archives
of a specific checkin. They may be further restricted by query
parameters that specify glob patterns that name files to include or
exclude rather than taking the entire checkin.
[`/timeline`]: /help?cmd=/timeline
[`/tarball`]: /help?cmd=/tarball
[`/zip`]: /help?cmd=/zip
## Platform Quirks
Fossil glob patterns are based on the glob pattern feature of POSIX
shells. Fossil glob patterns also have a quoting mechanism, discussed
above. Because other parts of your operating system may interpret glob
patterns and quotes separately from Fossil, it is often difficult to
give glob patterns correctly to Fossil on the command line. Quotes and
special characters in glob patterns are likely to be interpreted when
given as part of a `fossil` command, causing unexpected behavior.
These problems do not affect [versioned settings files](settings.wiki)
or Admin → Settings in Fossil UI. Consequently, it is better to
set long-term `*-glob` settings via these methods than to use `fossil
settings` commands.
That advice does not help you when you are giving one-off glob patterns
in `fossil` commands. The remainder of this section gives remedies and
workarounds for these problems.
## POSIX Systems
If you are using Fossil on a system with a POSIX-compatible shell
— Linux, macOS, the BSDs, Unix, Cygwin, WSL etc. — the shell
may expand the glob patterns before passing the result to the `fossil`
executable.
Sometimes this is exactly what you want. Consider this command for
example:
$ fossil add RE*
If you give that command in a directory containing `README.txt` and
`RELEASE-NOTES.txt`, the shell will expand the command to:
$ fossil add README.txt RELEASE-NOTES.txt
…which is compatible with the `fossil add` command's argument list,
which allows multiple files.
Now consider what happens instead if you say:
$ fossil add --ignore RE* src/*.c
This *does not* do what you want because the shell will expand both `RE*`
and `src/*.c`, causing one of the two files matching the `RE*` glob
pattern to be ignored and the other to be added to the repository. You
need to say this in that case:
$ fossil add --ignore 'RE*' src/*.c
The single quotes force a POSIX shell to pass the `RE*` glob pattern
through to Fossil untouched, which will do its own glob pattern
matching. There are other methods of quoting a glob pattern or escaping
its special characters; see your shell's manual.
Beware that Fossil's `--ignore` option does not override explicit file
mentions:
$ fossil add --ignore 'REALLY SECRET STUFF.txt' RE*
You might think that would add everything beginning with `RE` *except*
for `REALLY SECRET STUFF.txt`, but when a file is both given
explicitly to Fossil and also matches an ignore rule, Fossil asks what
you want to do with it in the default case; and it does not even ask
if you gave the `-f` or `--force` option along with `--ignore`.
The spaces in the ignored file name above bring us to another point:
such file names must be quoted in Fossil glob patterns, lest Fossil
interpret it as multiple glob patterns, but the shell interprets
quotation marks itself.
One way to fix both this and the previous problem is:
$ fossil add --ignore "'REALLY SECRET STUFF.txt'" READ*
The nested quotation marks cause the inner set to be passed through to
Fossil, and the more specific glob pattern at the end — that is,
`READ*` vs `RE*` — avoids a conflict between explicitly-listed
files and `--ignore` rules in the `fossil add` command.
Another solution would be to use shell escaping instead of nested
quoting:
$ fossil add --ignore "\"REALLY SECRET STUFF.txt\"" READ*
It bears repeating that the two glob patterns here are not interpreted
the same way when running this command from a *subdirectory* of the top
checkout directory as when running it at the top of the checkout tree.
If these files were in a subdirectory of the checkout tree called `doc`
and that was your current working directory, the command would have to
be:
$ fossil add --ignore "'doc/REALLY SECRET STUFF.txt'" READ*
instead. The Fossil glob pattern still needs the `doc/` prefix because
Fossil always interprets glob patterns from the base of the checkout
directory, not from the current working directory as POSIX shells do.
When in doubt, use `fossil status` after running commands like the
above to make sure the right set of files were scheduled for insertion
into the repository before checking the changes in. You never want to
accidentally check something like a password, an API key, or the
private half of a public cryptographic key into Fossil repository that
can be read by people who should not have such secrets.
## Windows
Neither standard Windows command shell — `cmd.exe` or PowerShell
— expands glob patterns the way POSIX shells do. Windows command
shells rely on the command itself to do the glob pattern expansion. The
way this works depends on several factors:
* the version of Windows you are using
* which OS upgrades have been applied to it
* the compiler that built your Fossil executable
* whether you are running the command interactively
* whether the command is built against a runtime system that does this
at all
* whether the Fossil command is being run from a file named `*.BAT` vs
being named `*.CMD`
These factors also affect how a program like `fossil.exe` interprets
quotation marks on its command line.
The fifth item above does not apply to `fossil.exe` when built with
typical tool chains, but we will see an example below where the exception
applies in a way that affects how Fossil interprets the glob pattern.
The most common problem is figuring out how to get a glob pattern passed
on the command line into `fossil.exe` without it being expanded by the C
runtime library that your particular Fossil executable is linked to,
which tries to act like the POSIX systems described above. Windows is
not strongly governed by POSIX, so it has not historically hewed closely
to its strictures.
(This section does not cover the [Microsoft POSIX
subsystem](https://en.wikipedia.org/wiki/Microsoft_POSIX_subsystem),
Windows' obsolete [Services for Unix
3.*x*](https://en.wikipedia.org/wiki/Windows_Services_for_UNIX) feature,
or the [Windows Subsystem for
Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux). (The
latter is sometimes incorrectly called "Bash on Windows" or "Ubuntu on
Windows.") See the POSIX Systems section above for those cases.)
For example, consider how you would set `crlf-glob` to `*` in order to
disable Fossil's "looks like a binary file" checks. The naïve
approach will not work:
C:\...> fossil setting crlf-glob *
The C runtime library will expand that to the list of all files in the
current directory, which will probably cause a Fossil error because
Fossil expects either nothing or option flags after the setting's new
value.
Let's try again:
C:\...> fossil setting crlf-glob '*'
That may or may not work. Either `'*'` or `*` needs to be passed through
to Fossil untouched for this to do what you expect, which may or may not
happen, depending on the factors listed above.
An approach that *will* work reliably is:
C:\...> echo * | fossil setting crlf-glob --args -
This works because the built-in command `echo` does not expand its
arguments, and the `--args -` option makes it read further command
arguments from Fossil's standard input, which is connected to the output
of `echo` by the pipe. (`-` is a common Unix convention meaning
"standard input.")
Another (usually) correct approach is:
C:\...> fossil setting crlf-glob *,
This works because the trailing comma prevents the command shell from
matching any files, unless you happen to have files named with a
trailing comma in the current directory. If the pattern matches no
files, it is passed into Fossil's `main()` function as-is by the C
runtime system. Since Fossil uses commas to separate multiple glob
patterns, this means "all files at the root of the Fossil checkout
directory and nothing else."
## Converting `.gitignore` to `ignore-glob`
Many other version control systems handle the specific case of
ignoring certain files differently from fossil: they have you create
individual "ignore" files in each folder, which specify things ignored
in that folder and below. Usually some form of glob patterns are used
in those files, but the details differ from fossil.
In many simple cases, you can just store a top level "ignore" file in
`.fossil-settings/ignore-glob`. But as usual, there will be lots of
edge cases.
[Git has a rich collection of ignore files][gitignore] which
accumulate rules that affect the current command. There are global
files, per-user files, per workspace unmanaged files, and fully
version controlled files. Some of the files used have no set name, but
are called out in configuration files.
[gitignore]: https://git-scm.com/docs/gitignore
In contrast, fossil has a global setting and a local setting, but the local setting
overrides the global rather than extending it. Similarly, a fossil
command's `--ignore` option replaces the `ignore-glob` setting rather
than extending it.
With that in mind, translating a `.gitignore` file into
`.fossil-settings/ignore-glob` may be possible in many cases. Here are
some of features of `.gitignore` and comments on how they relate to
fossil:
* "A blank line matches no files..." is the same in fossil.
* "A line starting with # serves as a comment...." not in fossil.
* "Trailing spaces are ignored unless they are quoted..." is similar
in fossil. All whitespace before and after a glob is trimmed in
fossil unless quoted with single or double quotes. Git uses
backslash quoting instead, which fossil does not.
* "An optional prefix "!" which negates the pattern..." not in
fossil.
* Git's globs are relative to the location of the `.gitignore` file;
fossil's globs are relative to the root of the workspace.
* Git's globs and fossil's globs treat directory separators
differently. Git includes a notation for zero or more directories
that is not needed in fossil.
### Example
In a project with source and documentation:
work
+-- doc
+-- src
The file `doc/.gitignore` might contain:
# Finished documents by pandoc via LaTeX
*.pdf
# Intermediate files
*.tex
*.toc
*.log
*.out
*.tmp
Entries in `.fossil-settings/ignore-glob` with similar effect, also
limited to the `doc` folder:
doc/*.pdf
doc/*.tex, doc/*.toc, doc/*.log, doc/*.out, doc/*.tmp
## Implementation and References
Most of the implementation of glob pattern handling in fossil is found
`glob.c`, `file.c`, and each individual command and web page that uses
a glob pattern. Find commands and pages in the fossil sources by
looking for comments like `COMMAND: add` or `WEBPAGE: timeline` in
front of the function that implements the command or page in files
`src/*.c`. (Fossil's build system creates the tables used to dispatch
commands at build time by searching the sources for those comments.) A
few starting points:
:File |:Description
--------------------------------------------------------------------------------
[`src/glob.c`][] | Implementation of glob pattern list loading, parsing, and matching.
[`src/file.c`][] | Implementation of various kinds of canonical names of a file.
[`src/glob.c`]: https://www.fossil-scm.org/index.html/file/src/glob.c
[`src/file.c`]: https://www.fossil-scm.org/index.html/file/src/file.c
The actual pattern matching is implemented in SQL, so the
documentation for `GLOB` and the other string matching operators in
[SQLite] (https://sqlite.org/lang_expr.html#like) is useful. Of
course, the SQLite [source code]
(https://www.sqlite.org/src/artifact?name=9d52522cc8ae7f5c&ln=570-768)
and [test harnesses]
(https://www.sqlite.org/src/artifact?name=66a2c9ac34f74f03&ln=586-673)
also make entertaining reading.
|
Changes to www/index.wiki.
| ︙ | ︙ | |||
45 46 47 48 49 50 51 |
When you clone Fossil from one of its
[./selfhost.wiki | self-hosting repositories],
you get more than just source code - you get this entire website.
3. <b>Self-Contained</b> -
Fossil is a single self-contained stand-alone executable.
To install, simply download a
| | | > | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
When you clone Fossil from one of its
[./selfhost.wiki | self-hosting repositories],
you get more than just source code - you get this entire website.
3. <b>Self-Contained</b> -
Fossil is a single self-contained stand-alone executable.
To install, simply download a
[/uv/download.html | precompiled binary]
for Linux, Mac, OpenBSD, or Windows and put it on your $PATH.
[./build.wiki | Easy-to-compile source code] is also available.
4. <b>Simple Networking</b> -
No custom protocols or TCP ports.
Fossil uses ordinary HTTP (or HTTPS or SSH)
for network communications, so it works fine from behind
restrictive firewalls, including [./quickstart.wiki#proxy|proxies].
The protocol is
[./stats.wiki | bandwidth efficient] to the point that Fossil can be
used comfortably over dial-up or over the exceedingly slow Wifi on
airliners.
5. <b>CGI/SCGI Enabled</b> - No server is required, but if you want to
set one up, Fossil supports four easy
[./server.wiki | server configurations].
6. <b>Autosync</b> -
Fossil supports [./concepts.wiki#workflow | "autosync" mode]
|
| ︙ | ︙ | |||
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
* On-line [/help | help].
* Documentation on the
[http://www.sqliteconcepts.org/THManual.pdf | TH1 scripting language],
used to customize [./custom_ticket.wiki | ticketing], and several other
subsystems, including [./customskin.md | theming].
* List of [./th1.md | TH1 commands provided by Fossil itself] that expose
its key functionality to TH1 scripts.
* A free hosting server for Fossil repositories is available at
[http://chiselapp.com/].
* How to [./server.wiki | set up a server] for your repository.
* Customizing the [./custom_ticket.wiki | ticket system].
* Methods to [./checkin_names.wiki | identify a specific check-in].
* [./inout.wiki | Import and export] from and to Git.
* [./fossil-v-git.wiki | Fossil versus Git].
| > > | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
* On-line [/help | help].
* Documentation on the
[http://www.sqliteconcepts.org/THManual.pdf | TH1 scripting language],
used to customize [./custom_ticket.wiki | ticketing], and several other
subsystems, including [./customskin.md | theming].
* List of [./th1.md | TH1 commands provided by Fossil itself] that expose
its key functionality to TH1 scripts.
* List of [./th1-hooks.md | TH1 hooks exposed by Fossil] that enable
customization of commands and web pages.
* A free hosting server for Fossil repositories is available at
[http://chiselapp.com/].
* How to [./server.wiki | set up a server] for your repository.
* Customizing the [./custom_ticket.wiki | ticket system].
* Methods to [./checkin_names.wiki | identify a specific check-in].
* [./inout.wiki | Import and export] from and to Git.
* [./fossil-v-git.wiki | Fossil versus Git].
|
| ︙ | ︙ |
Changes to www/mkindex.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#!/usr/bin/env tclsh
#
# Run this TCL script to generate a WIKI page that contains a
# permuted index of the various documentation files.
#
# tclsh mkindex.tcl
#
set doclist {
aboutcgi.wiki {How CGI Works In Fossil}
adding_code.wiki {Adding New Features To Fossil}
adding_code.wiki {Hacking Fossil}
antibot.wiki {Defense against Spiders and Bots}
blame.wiki {The Annotate/Blame Algorithm Of Fossil}
branching.wiki {Branching, Forking, Merging, and Tagging}
bugtheory.wiki {Bug Tracking In Fossil}
build.wiki {Compiling and Installing Fossil}
| > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#!/usr/bin/env tclsh
#
# Run this TCL script to generate a WIKI page that contains a
# permuted index of the various documentation files.
#
# tclsh mkindex.tcl
#
set doclist {
aboutcgi.wiki {How CGI Works In Fossil}
aboutdownload.wiki {How The Download Page Works}
adding_code.wiki {Adding New Features To Fossil}
adding_code.wiki {Hacking Fossil}
antibot.wiki {Defense against Spiders and Bots}
blame.wiki {The Annotate/Blame Algorithm Of Fossil}
branching.wiki {Branching, Forking, Merging, and Tagging}
bugtheory.wiki {Bug Tracking In Fossil}
build.wiki {Compiling and Installing Fossil}
|
| ︙ | ︙ | |||
29 30 31 32 33 34 35 |
delta_format.wiki {Fossil Delta Format}
embeddeddoc.wiki {Embedded Project Documentation}
encryptedrepos.wiki {How To Use Encrypted Repositories}
env-opts.md {Environment Variables and Global Options}
event.wiki {Events}
faq.wiki {Frequently Asked Questions}
fileformat.wiki {Fossil File Format}
| | > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
delta_format.wiki {Fossil Delta Format}
embeddeddoc.wiki {Embedded Project Documentation}
encryptedrepos.wiki {How To Use Encrypted Repositories}
env-opts.md {Environment Variables and Global Options}
event.wiki {Events}
faq.wiki {Frequently Asked Questions}
fileformat.wiki {Fossil File Format}
fiveminutes.wiki {Up and Running in 5 Minutes as a Single User}
foss-cklist.wiki {Checklist For Successful Open-Source Projects}
fossil-from-msvc.wiki {Integrating Fossil in the Microsoft Express 2010 IDE}
fossil-v-git.wiki {Fossil Versus Git}
globs.md {File Name Glob Patterns}
hacker-howto.wiki {Hacker How-To}
hashpolicy.wiki {Hash Policy: Choosing Between SHA1 and SHA3-256}
/help {Lists of Commands and Webpages}
hints.wiki {Fossil Tips And Usage Hints}
index.wiki {Home Page}
inout.wiki {Import And Export To And From Git}
makefile.wiki {The Fossil Build Process}
|
| ︙ | ︙ | |||
114 115 116 117 118 119 120 | <ul> <li> <a href='quickstart.wiki'>Quick-start Guide</a> <li> <a href='faq.wiki'>FAQ</a> <li> <a href='build.wiki'>Compiling and installing Fossil</a> <li> <a href='../COPYRIGHT-BSD2.txt'>License</a> <li> <a href='http://www.fossil-scm.org/schimpf-book/home'>Jim Schimpf's book</a> | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
<ul>
<li> <a href='quickstart.wiki'>Quick-start Guide</a>
<li> <a href='faq.wiki'>FAQ</a>
<li> <a href='build.wiki'>Compiling and installing Fossil</a>
<li> <a href='../COPYRIGHT-BSD2.txt'>License</a>
<li> <a href='http://www.fossil-scm.org/schimpf-book/home'>Jim Schimpf's
book</a>
<li> <a href='$ROOT/help'>List of commands, web-pages, and settings</a>
</ul>
<a name="pindex"></a>
<h2>Permuted Index:</h2>
<ul>}
foreach entry $permindex {
foreach {title file bold} $entry break
if {$bold} {set title <b>$title</b>}
if {[string match /* $file]} {set file ../../..$file}
puts $out "<li><a href=\"$file\">$title</a></li>"
}
puts $out "</ul></div>"
|
Changes to www/permutedindex.html.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | <ul> <li> <a href='quickstart.wiki'>Quick-start Guide</a> <li> <a href='faq.wiki'>FAQ</a> <li> <a href='build.wiki'>Compiling and installing Fossil</a> <li> <a href='../COPYRIGHT-BSD2.txt'>License</a> <li> <a href='http://www.fossil-scm.org/schimpf-book/home'>Jim Schimpf's book</a> | | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <ul> <li> <a href='quickstart.wiki'>Quick-start Guide</a> <li> <a href='faq.wiki'>FAQ</a> <li> <a href='build.wiki'>Compiling and installing Fossil</a> <li> <a href='../COPYRIGHT-BSD2.txt'>License</a> <li> <a href='http://www.fossil-scm.org/schimpf-book/home'>Jim Schimpf's book</a> <li> <a href='$ROOT/help'>List of commands, web-pages, and settings</a> </ul> <a name="pindex"></a> <h2>Permuted Index:</h2> <ul> <li><a href="fiveminutes.wiki">5 Minutes as a Single User — Up and Running in</a></li> <li><a href="fossil-from-msvc.wiki">2010 IDE — Integrating Fossil in the Microsoft Express</a></li> <li><a href="tech_overview.wiki"><b>A Technical Overview Of The Design And Implementation Of Fossil</b></a></li> <li><a href="adding_code.wiki"><b>Adding New Features To Fossil</b></a></li> <li><a href="copyright-release.html">Agreement — Contributor License</a></li> <li><a href="delta_encoder_algorithm.wiki">Algorithm — Fossil Delta Encoding</a></li> <li><a href="blame.wiki">Algorithm Of Fossil — The Annotate/Blame</a></li> <li><a href="blame.wiki">Annotate/Blame Algorithm Of Fossil — The</a></li> |
| ︙ | ︙ | |||
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | <li><a href="private.wiki">Deleting Private Branches — Creating, Syncing, and</a></li> <li><a href="delta_encoder_algorithm.wiki">Delta Encoding Algorithm — Fossil</a></li> <li><a href="delta_format.wiki">Delta Format — Fossil</a></li> <li><a href="tech_overview.wiki">Design And Implementation Of Fossil — A Technical Overview Of The</a></li> <li><a href="theory1.wiki">Design Of The Fossil DVCS — Thoughts On The</a></li> <li><a href="embeddeddoc.wiki">Documentation — Embedded Project</a></li> <li><a href="contribute.wiki">Documentation To The Fossil Project — Contributing Code or</a></li> <li><a href="theory1.wiki">DVCS — Thoughts On The Design Of The Fossil</a></li> <li><a href="quotes.wiki">DVCSes in General — Quotes: What People Are Saying About Fossil, Git, and</a></li> <li><a href="embeddeddoc.wiki"><b>Embedded Project Documentation</b></a></li> <li><a href="delta_encoder_algorithm.wiki">Encoding Algorithm — Fossil Delta</a></li> <li><a href="encryptedrepos.wiki">Encrypted Repositories — How To Use</a></li> <li><a href="env-opts.md"><b>Environment Variables and Global Options</b></a></li> <li><a href="event.wiki"><b>Events</b></a></li> <li><a href="webpage-ex.md">Examples — Webpage</a></li> <li><a href="inout.wiki">Export To And From Git — Import And</a></li> <li><a href="fossil-from-msvc.wiki">Express 2010 IDE — Integrating Fossil in the Microsoft</a></li> <li><a href="adding_code.wiki">Features To Fossil — Adding New</a></li> <li><a href="fileformat.wiki">File Format — Fossil</a></li> <li><a href="unvers.wiki">Files — Unversioned</a></li> <li><a href="branching.wiki">Forking, Merging, and Tagging — Branching,</a></li> <li><a href="delta_format.wiki">Format — Fossil Delta</a></li> <li><a href="fileformat.wiki">Format — Fossil File</a></li> <li><a href="../../../md_rules">Formatting Rules — Markdown</a></li> <li><a href="../../../wiki_rules">Formatting Rules — Wiki</a></li> <li><a href="changes.wiki"><b>Fossil Changelog</b></a></li> | > > | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | <li><a href="private.wiki">Deleting Private Branches — Creating, Syncing, and</a></li> <li><a href="delta_encoder_algorithm.wiki">Delta Encoding Algorithm — Fossil</a></li> <li><a href="delta_format.wiki">Delta Format — Fossil</a></li> <li><a href="tech_overview.wiki">Design And Implementation Of Fossil — A Technical Overview Of The</a></li> <li><a href="theory1.wiki">Design Of The Fossil DVCS — Thoughts On The</a></li> <li><a href="embeddeddoc.wiki">Documentation — Embedded Project</a></li> <li><a href="contribute.wiki">Documentation To The Fossil Project — Contributing Code or</a></li> <li><a href="aboutdownload.wiki">Download Page Works — How The</a></li> <li><a href="theory1.wiki">DVCS — Thoughts On The Design Of The Fossil</a></li> <li><a href="quotes.wiki">DVCSes in General — Quotes: What People Are Saying About Fossil, Git, and</a></li> <li><a href="embeddeddoc.wiki"><b>Embedded Project Documentation</b></a></li> <li><a href="delta_encoder_algorithm.wiki">Encoding Algorithm — Fossil Delta</a></li> <li><a href="encryptedrepos.wiki">Encrypted Repositories — How To Use</a></li> <li><a href="env-opts.md"><b>Environment Variables and Global Options</b></a></li> <li><a href="event.wiki"><b>Events</b></a></li> <li><a href="webpage-ex.md">Examples — Webpage</a></li> <li><a href="inout.wiki">Export To And From Git — Import And</a></li> <li><a href="fossil-from-msvc.wiki">Express 2010 IDE — Integrating Fossil in the Microsoft</a></li> <li><a href="adding_code.wiki">Features To Fossil — Adding New</a></li> <li><a href="fileformat.wiki">File Format — Fossil</a></li> <li><a href="globs.md"><b>File Name Glob Patterns</b></a></li> <li><a href="unvers.wiki">Files — Unversioned</a></li> <li><a href="branching.wiki">Forking, Merging, and Tagging — Branching,</a></li> <li><a href="delta_format.wiki">Format — Fossil Delta</a></li> <li><a href="fileformat.wiki">Format — Fossil File</a></li> <li><a href="../../../md_rules">Formatting Rules — Markdown</a></li> <li><a href="../../../wiki_rules">Formatting Rules — Wiki</a></li> <li><a href="changes.wiki"><b>Fossil Changelog</b></a></li> |
| ︙ | ︙ | |||
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | <li><a href="fossil-v-git.wiki"><b>Fossil Versus Git</b></a></li> <li><a href="quotes.wiki">Fossil, Git, and DVCSes in General — Quotes: What People Are Saying About</a></li> <li><a href="faq.wiki"><b>Frequently Asked Questions</b></a></li> <li><a href="quotes.wiki">General — Quotes: What People Are Saying About Fossil, Git, and DVCSes in</a></li> <li><a href="fossil-v-git.wiki">Git — Fossil Versus</a></li> <li><a href="inout.wiki">Git — Import And Export To And From</a></li> <li><a href="quotes.wiki">Git, and DVCSes in General — Quotes: What People Are Saying About Fossil,</a></li> <li><a href="env-opts.md">Global Options — Environment Variables and</a></li> <li><a href="customgraph.md">Graph — Theming: Customizing the Timeline</a></li> <li><a href="quickstart.wiki">Guide — Fossil Quick Start</a></li> <li><a href="style.wiki">Guidelines — Source Code Style</a></li> <li><a href="hacker-howto.wiki"><b>Hacker How-To</b></a></li> <li><a href="adding_code.wiki"><b>Hacking Fossil</b></a></li> <li><a href="hashpolicy.wiki"><b>Hash Policy: Choosing Between SHA1 and SHA3-256</b></a></li> <li><a href="hints.wiki">Hints — Fossil Tips And Usage</a></li> <li><a href="index.wiki"><b>Home Page</b></a></li> <li><a href="selfhost.wiki">Hosting Repositories — Fossil Self</a></li> <li><a href="aboutcgi.wiki"><b>How CGI Works In Fossil</b></a></li> <li><a href="server.wiki"><b>How To Configure A Fossil Server</b></a></li> <li><a href="newrepo.wiki"><b>How To Create A New Fossil Repository</b></a></li> <li><a href="encryptedrepos.wiki"><b>How To Use Encrypted Repositories</b></a></li> <li><a href="hacker-howto.wiki">How-To — Hacker</a></li> <li><a href="fossil-from-msvc.wiki">IDE — Integrating Fossil in the Microsoft Express 2010</a></li> <li><a href="tech_overview.wiki">Implementation Of Fossil — A Technical Overview Of The Design And</a></li> <li><a href="inout.wiki"><b>Import And Export To And From Git</b></a></li> <li><a href="build.wiki">Installing Fossil — Compiling and</a></li> <li><a href="fossil-from-msvc.wiki"><b>Integrating Fossil in the Microsoft Express 2010 IDE</b></a></li> <li><a href="selfcheck.wiki">Integrity Self Checks — Fossil Repository</a></li> <li><a href="webui.wiki">Interface — The Fossil Web</a></li> <li><a href="th1.md">Language — The TH1 Scripting</a></li> <li><a href="copyright-release.html">License Agreement — Contributor</a></li> <li><a href="../../../help"><b>Lists of Commands and Webpages</b></a></li> <li><a href="password.wiki">Management And Authentication — Password</a></li> <li><a href="../../../sitemap">Map — Site</a></li> <li><a href="../../../md_rules"><b>Markdown Formatting Rules</b></a></li> <li><a href="branching.wiki">Merging, and Tagging — Branching, Forking,</a></li> <li><a href="fossil-from-msvc.wiki">Microsoft Express 2010 IDE — Integrating Fossil in the</a></li> | > > | > > > | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | <li><a href="fossil-v-git.wiki"><b>Fossil Versus Git</b></a></li> <li><a href="quotes.wiki">Fossil, Git, and DVCSes in General — Quotes: What People Are Saying About</a></li> <li><a href="faq.wiki"><b>Frequently Asked Questions</b></a></li> <li><a href="quotes.wiki">General — Quotes: What People Are Saying About Fossil, Git, and DVCSes in</a></li> <li><a href="fossil-v-git.wiki">Git — Fossil Versus</a></li> <li><a href="inout.wiki">Git — Import And Export To And From</a></li> <li><a href="quotes.wiki">Git, and DVCSes in General — Quotes: What People Are Saying About Fossil,</a></li> <li><a href="globs.md">Glob Patterns — File Name</a></li> <li><a href="env-opts.md">Global Options — Environment Variables and</a></li> <li><a href="customgraph.md">Graph — Theming: Customizing the Timeline</a></li> <li><a href="quickstart.wiki">Guide — Fossil Quick Start</a></li> <li><a href="style.wiki">Guidelines — Source Code Style</a></li> <li><a href="hacker-howto.wiki"><b>Hacker How-To</b></a></li> <li><a href="adding_code.wiki"><b>Hacking Fossil</b></a></li> <li><a href="hashpolicy.wiki"><b>Hash Policy: Choosing Between SHA1 and SHA3-256</b></a></li> <li><a href="hints.wiki">Hints — Fossil Tips And Usage</a></li> <li><a href="index.wiki"><b>Home Page</b></a></li> <li><a href="selfhost.wiki">Hosting Repositories — Fossil Self</a></li> <li><a href="aboutcgi.wiki"><b>How CGI Works In Fossil</b></a></li> <li><a href="aboutdownload.wiki"><b>How The Download Page Works</b></a></li> <li><a href="server.wiki"><b>How To Configure A Fossil Server</b></a></li> <li><a href="newrepo.wiki"><b>How To Create A New Fossil Repository</b></a></li> <li><a href="encryptedrepos.wiki"><b>How To Use Encrypted Repositories</b></a></li> <li><a href="hacker-howto.wiki">How-To — Hacker</a></li> <li><a href="fossil-from-msvc.wiki">IDE — Integrating Fossil in the Microsoft Express 2010</a></li> <li><a href="tech_overview.wiki">Implementation Of Fossil — A Technical Overview Of The Design And</a></li> <li><a href="inout.wiki"><b>Import And Export To And From Git</b></a></li> <li><a href="build.wiki">Installing Fossil — Compiling and</a></li> <li><a href="fossil-from-msvc.wiki"><b>Integrating Fossil in the Microsoft Express 2010 IDE</b></a></li> <li><a href="selfcheck.wiki">Integrity Self Checks — Fossil Repository</a></li> <li><a href="webui.wiki">Interface — The Fossil Web</a></li> <li><a href="th1.md">Language — The TH1 Scripting</a></li> <li><a href="copyright-release.html">License Agreement — Contributor</a></li> <li><a href="../../../help"><b>Lists of Commands and Webpages</b></a></li> <li><a href="password.wiki">Management And Authentication — Password</a></li> <li><a href="../../../sitemap">Map — Site</a></li> <li><a href="../../../md_rules"><b>Markdown Formatting Rules</b></a></li> <li><a href="branching.wiki">Merging, and Tagging — Branching, Forking,</a></li> <li><a href="fossil-from-msvc.wiki">Microsoft Express 2010 IDE — Integrating Fossil in the</a></li> <li><a href="fiveminutes.wiki">Minutes as a Single User — Up and Running in 5</a></li> <li><a href="globs.md">Name Glob Patterns — File</a></li> <li><a href="checkin_names.wiki">Names — Check-in And Version</a></li> <li><a href="adding_code.wiki">New Features To Fossil — Adding</a></li> <li><a href="newrepo.wiki">New Fossil Repository — How To Create A</a></li> <li><a href="foss-cklist.wiki">Open-Source Projects — Checklist For Successful</a></li> <li><a href="pop.wiki">Operation — Principles Of</a></li> <li><a href="env-opts.md">Options — Environment Variables and Global</a></li> <li><a href="tech_overview.wiki">Overview Of The Design And Implementation Of Fossil — A Technical</a></li> <li><a href="index.wiki">Page — Home</a></li> <li><a href="aboutdownload.wiki">Page Works — How The Download</a></li> <li><a href="customskin.md">Pages — Theming: Customizing The Appearance of Web</a></li> <li><a href="password.wiki"><b>Password Management And Authentication</b></a></li> <li><a href="globs.md">Patterns — File Name Glob</a></li> <li><a href="quotes.wiki">People Are Saying About Fossil, Git, and DVCSes in General — Quotes: What</a></li> <li><a href="stats.wiki"><b>Performance Statistics</b></a></li> <li><a href="hashpolicy.wiki">Policy: Choosing Between SHA1 and SHA3-256 — Hash</a></li> <li><a href="../test/release-checklist.wiki"><b>Pre-Release Testing Checklist</b></a></li> <li><a href="pop.wiki"><b>Principles Of Operation</b></a></li> <li><a href="private.wiki">Private Branches — Creating, Syncing, and Deleting</a></li> <li><a href="makefile.wiki">Process — The Fossil Build</a></li> |
| ︙ | ︙ | |||
169 170 171 172 173 174 175 | <li><a href="selfhost.wiki">Repositories — Fossil Self Hosting</a></li> <li><a href="encryptedrepos.wiki">Repositories — How To Use Encrypted</a></li> <li><a href="newrepo.wiki">Repository — How To Create A New Fossil</a></li> <li><a href="selfcheck.wiki">Repository Integrity Self Checks — Fossil</a></li> <li><a href="reviews.wiki"><b>Reviews</b></a></li> <li><a href="../../../md_rules">Rules — Markdown Formatting</a></li> <li><a href="../../../wiki_rules">Rules — Wiki Formatting</a></li> | | | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | <li><a href="selfhost.wiki">Repositories — Fossil Self Hosting</a></li> <li><a href="encryptedrepos.wiki">Repositories — How To Use Encrypted</a></li> <li><a href="newrepo.wiki">Repository — How To Create A New Fossil</a></li> <li><a href="selfcheck.wiki">Repository Integrity Self Checks — Fossil</a></li> <li><a href="reviews.wiki"><b>Reviews</b></a></li> <li><a href="../../../md_rules">Rules — Markdown Formatting</a></li> <li><a href="../../../wiki_rules">Rules — Wiki Formatting</a></li> <li><a href="fiveminutes.wiki">Running in 5 Minutes as a Single User — Up and</a></li> <li><a href="quotes.wiki">Saying About Fossil, Git, and DVCSes in General — Quotes: What People Are</a></li> <li><a href="th1.md">Scripting Language — The TH1</a></li> <li><a href="selfcheck.wiki">Self Checks — Fossil Repository Integrity</a></li> <li><a href="selfhost.wiki">Self Hosting Repositories — Fossil</a></li> <li><a href="server.wiki">Server — How To Configure A Fossil</a></li> <li><a href="settings.wiki">Settings — Fossil</a></li> <li><a href="hashpolicy.wiki">SHA1 and SHA3-256 — Hash Policy: Choosing Between</a></li> <li><a href="hashpolicy.wiki">SHA3-256 — Hash Policy: Choosing Between SHA1 and</a></li> <li><a href="shunning.wiki"><b>Shunning: Deleting Content From Fossil</b></a></li> <li><a href="fiveminutes.wiki">Single User — Up and Running in 5 Minutes as a</a></li> <li><a href="../../../sitemap"><b>Site Map</b></a></li> <li><a href="style.wiki"><b>Source Code Style Guidelines</b></a></li> <li><a href="antibot.wiki">Spiders and Bots — Defense against</a></li> <li><a href="tech_overview.wiki"><b>SQLite Databases Used By Fossil</b></a></li> <li><a href="ssl.wiki">SSL with Fossil — Using</a></li> <li><a href="quickstart.wiki">Start Guide — Fossil Quick</a></li> <li><a href="stats.wiki">Statistics — Performance</a></li> |
| ︙ | ︙ | |||
212 213 214 215 216 217 218 | <li><a href="theory1.wiki"><b>Thoughts On The Design Of The Fossil DVCS</b></a></li> <li><a href="custom_ticket.wiki">Ticket System — Customizing The</a></li> <li><a href="tickets.wiki">Ticket System — The Fossil</a></li> <li><a href="customgraph.md">Timeline Graph — Theming: Customizing the</a></li> <li><a href="hints.wiki">Tips And Usage Hints — Fossil</a></li> <li><a href="bugtheory.wiki">Tracking In Fossil — Bug</a></li> <li><a href="unvers.wiki"><b>Unversioned Files</b></a></li> | | | > | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | <li><a href="theory1.wiki"><b>Thoughts On The Design Of The Fossil DVCS</b></a></li> <li><a href="custom_ticket.wiki">Ticket System — Customizing The</a></li> <li><a href="tickets.wiki">Ticket System — The Fossil</a></li> <li><a href="customgraph.md">Timeline Graph — Theming: Customizing the</a></li> <li><a href="hints.wiki">Tips And Usage Hints — Fossil</a></li> <li><a href="bugtheory.wiki">Tracking In Fossil — Bug</a></li> <li><a href="unvers.wiki"><b>Unversioned Files</b></a></li> <li><a href="fiveminutes.wiki"><b>Up and Running in 5 Minutes as a Single User</b></a></li> <li><a href="hints.wiki">Usage Hints — Fossil Tips And</a></li> <li><a href="fiveminutes.wiki">User — Up and Running in 5 Minutes as a Single</a></li> <li><a href="ssl.wiki"><b>Using SSL with Fossil</b></a></li> <li><a href="env-opts.md">Variables and Global Options — Environment</a></li> <li><a href="whyusefossil.wiki">Version Control — Benefits Of</a></li> <li><a href="checkin_names.wiki">Version Names — Check-in And</a></li> <li><a href="fossil-v-git.wiki">Versus Git — Fossil</a></li> <li><a href="webui.wiki">Web Interface — The Fossil</a></li> <li><a href="customskin.md">Web Pages — Theming: Customizing The Appearance of</a></li> <li><a href="webpage-ex.md"><b>Webpage Examples</b></a></li> <li><a href="../../../help">Webpages — Lists of Commands and</a></li> <li><a href="quotes.wiki">What People Are Saying About Fossil, Git, and DVCSes in General — Quotes:</a></li> <li><a href="whyusefossil.wiki"><b>Why You Should Use Fossil</b></a></li> <li><a href="../../../wiki_rules"><b>Wiki Formatting Rules</b></a></li> <li><a href="wikitheory.wiki"><b>Wiki In Fossil</b></a></li> <li><a href="aboutdownload.wiki">Works — How The Download Page</a></li> <li><a href="aboutcgi.wiki">Works In Fossil — How CGI</a></li> <li><a href="whyusefossil.wiki">You Should Use Fossil — Why</a></li> </ul></div> |
Changes to www/private.wiki.
| ︙ | ︙ | |||
85 86 87 88 89 90 91 | removed, they cannot be retrieved (unless you have synced them to another repository.) So be careful with the command. <h2>Additional Notes</h2> All of the features above apply to <u>all</u> private branches in a single repository at once. There is no mechanism in Fossil (currently) | | | 85 86 87 88 89 90 91 92 93 94 | removed, they cannot be retrieved (unless you have synced them to another repository.) So be careful with the command. <h2>Additional Notes</h2> All of the features above apply to <u>all</u> private branches in a single repository at once. There is no mechanism in Fossil (currently) that allows you to push, pull, clone, sync, or scrub an individual private branch within a repository that contains multiple private branches. |
Changes to www/selfcheck.wiki.
| ︙ | ︙ | |||
76 77 78 79 80 81 82 | the repository checksum is verified after a checkout to make sure that the entire repository was checked out correctly. Note that these added checks use a different hash algorithm (MD5) in order to avoid common-mode failures in the hash algorithm implementation. | | | | | > | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | the repository checksum is verified after a checkout to make sure that the entire repository was checked out correctly. Note that these added checks use a different hash algorithm (MD5) in order to avoid common-mode failures in the hash algorithm implementation. <h2>Checksums On Structural Artifacts And Deltas</h2> Every [./fileformat.wiki | structural artifact] in a fossil repository contains a "Z-card" bearing an MD5 checksum over the rest of the artifact. Any mismatch causes the structural artifact to be ignored. The [./delta_format.wiki | file delta format] includes a 32-bit checksum of the target file. Whenever a file is reconstructed from a delta, that checksum is verified to make sure the reconstruction was done correctly. <h2>Reliability Versus Performance</h2> Some version control systems make a big deal out of being "high performance" or the "fastest version control system". Fossil makes no such claims and has no such ambition. Indeed, profiling indicates that fossil bears a substantial performance cost for doing all of the checksumming and verification outlined above. Fossil takes the philosophy of the <a href="http://en.wikipedia.org/wiki/The_Tortoise_and_the_Hare">tortoise</a>: reliability is more important than raw speed. The developers of fossil see no merit in getting the wrong answer quickly. Fossil may not be the fastest versioning system, but it is "fast enough". Fossil runs quickly enough to stay out of the developers way. Most operations complete in milliseconds, faster that you can press the "Enter" key. |
Changes to www/selfhost.wiki.
1 2 | <title>Fossil Self-Hosting Repositories</title> | | | | | | | | | | > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | <title>Fossil Self-Hosting Repositories</title> Fossil has self-hosted since 2007-07-21. As of 2017-07-25 there are three publicly accessible repositories for the Fossil source code: 1. [https://www.fossil-scm.org/] 2. [https://www2.fossil-scm.org/] 3. [https://www3.fossil-scm.org/site.cgi] The canonical repository is (1). Repositories (2) and (3) automatically stay in synchronization with (1) via a <a href="http://en.wikipedia.org/wiki/Cron">cron job</a> that invokes "fossil sync" at regular intervals. Note that the two secondary repositories are more than just read-only mirrors. All three servers support full read/write capabilities. Changes (such as new tickets or wiki or check-ins) can be implemented on any of the three servers and those changes automatically propagate to the other two servers. Server (1) runs as a CGI script on a <a href="http://www.linode.com/">Linode 8192</a> located in Dallas, TX - on the same virtual machine that hosts <a href="http://www.sqlite.org/">SQLite</a> and over a dozen other smaller projects. This demonstrates that Fossil can run on a low-power host processor. Multiple fossil-based projects can easily be hosted on the same machine, even if that machine is itself one of several dozen virtual machines on single physical box. The CGI script that runs the canonical Fossil self-hosting repository is as follows: <blockquote><pre> #!/usr/bin/fossil repository: /fossil/fossil.fossil </pre></blockquote> Server (3) ran for 10 years as a CGI script on a shared hosting account at <a href="http://www.he.net/">Hurricane Electric</a> in Fremont, CA. This server demonstrated the ability of Fossil to run on an economical shared-host web account with no privileges beyond port 80 HTTP access and CGI. It is not necessary to have a dedicated computer with administrator privileges to run Fossil. As far as we are aware, Fossil is the only full-featured configuration management system that can run in such a restricted environment. The CGI script that ran on the Hurricane Electric server was the same as the CGI script shown above, except that the pathnames are modified to suit the environment: <blockquote><pre> #!/home/hwaci/bin/fossil repository: /home/hwaci/fossil/fossil.fossil </pre></blockquote> In recent years, virtual private servers have become a more flexible and less expensive hosting option compared to shared hosting accounts. So on 2017-07-25, server (3) was moved onto a $5/month "droplet" VPS from [https://www.digitalocean.com|Digital Ocean] located in San Francisco. Server (3) is synchronized with the canonical server (1) by running the following command via cron: <blockquote><pre> /home/hwaci/bin/fossil sync -R /home/hwaci/fossil/fossil.fossil </pre></blockquote> Server (2) is a <a href="http://www.linode.com/">Linode 4096</a> located in Newark, NJ and set up just like the canonical server (1) with the addition of a cron job for synchronization as in server (3). |
Changes to www/server.wiki.
| ︙ | ︙ | |||
174 175 176 177 178 179 180 | It may be necessary to set permissions properly, or to modify an ".htaccess" file or make other server-specific changes. Consult the documentation for your particular web server. In particular, the following permissions are <em>normally</em> required (but, again, may be different for a particular configuration): <ul> | > | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | It may be necessary to set permissions properly, or to modify an ".htaccess" file or make other server-specific changes. Consult the documentation for your particular web server. In particular, the following permissions are <em>normally</em> required (but, again, may be different for a particular configuration): <ul> <li>The Fossil binary (/usr/bin/fossil in the example above) must be readable/executable, and ALL directories leading up to it must be readable by the process which executes the CGI.</li> <li>ALL directories leading to the CGI script must also be readable and the CGI script itself must be executable for the user under which it will run (which often differs from the one running the web server - consult your site's documentation or administrator).</li> <li>The repository file AND the directory containing it must be writable by the same account which executes the Fossil binary (again, this might differ from the WWW user). The directory needs to be writable so that sqlite can write its journal files.</li> |
| ︙ | ︙ | |||
211 212 213 214 215 216 217 218 219 220 221 222 223 224 | notfound: http://url-to-go-to-if-repo-not-found/ </pre></blockquote> </p> <p> Once deployed, a URL like: <b>http://mydomain.org/cgi-bin/repo/XYZ</b> will serve up the repository "/home/fossil/repos/XYZ.fossil" (if it exists). </p> </blockquote> <a name="scgi"></a> <h2>Fossil as SCGI</h2><blockquote> <p> The [/help/server|fossil server] command, described above as a way of | > > > > > | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | notfound: http://url-to-go-to-if-repo-not-found/ </pre></blockquote> </p> <p> Once deployed, a URL like: <b>http://mydomain.org/cgi-bin/repo/XYZ</b> will serve up the repository "/home/fossil/repos/XYZ.fossil" (if it exists). </p> <p> Additional options available to the CGI script are documented in the source code. As of 2017-07-02, the available options are described at [/artifact/9a52a07b?ln=1777-1824|main.c lines 1777 through 1824]. </p> </blockquote> <a name="scgi"></a> <h2>Fossil as SCGI</h2><blockquote> <p> The [/help/server|fossil server] command, described above as a way of |
| ︙ | ︙ | |||
347 348 349 350 351 352 353 | Note that this load-average limiting feature is only available on operating systems that support the "getloadavg()" API. Most modern Unix systems have this interface, but Windows does not, so the feature will not work on Windows. Note also that Linux implements "getloadavg()" by accessing the "/proc/loadavg" file in the "proc" virtual filesystem. If you are running a Fossil instance inside a chroot() jail on Linux, you will need to make the "/proc" file system available inside that jail in order for this feature to work. On | | | | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | Note that this load-average limiting feature is only available on operating systems that support the "getloadavg()" API. Most modern Unix systems have this interface, but Windows does not, so the feature will not work on Windows. Note also that Linux implements "getloadavg()" by accessing the "/proc/loadavg" file in the "proc" virtual filesystem. If you are running a Fossil instance inside a chroot() jail on Linux, you will need to make the "/proc" file system available inside that jail in order for this feature to work. On the [./selfhost.wiki|self-hosting Fossil repositories], this was accomplished by adding a line to the "/etc/fstab" file that looks like: <blockquote><pre> chroot_jail_proc /home/www/proc proc ro 0 0 </pre></blockquote> The /home/www/proc pathname should be adjusted so that the "/proc" component is in the root of the chroot jail, of course. <p> To see if the load-average limiter is functional, visit the [/test_env] page |
| ︙ | ︙ |
Changes to www/sync.wiki.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 | shared to a few hundred.</p> <p>Each repository also has local state. The local state determines the web-page formatting preferences, authorized users, ticket formats, and similar information that varies from one repository to another. The local state is not using transferred during a sync. Except, some local state is transferred during a [/help?cmd=clone|clone] | | > | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | shared to a few hundred.</p> <p>Each repository also has local state. The local state determines the web-page formatting preferences, authorized users, ticket formats, and similar information that varies from one repository to another. The local state is not using transferred during a sync. Except, some local state is transferred during a [/help?cmd=clone|clone] in order to initialize the local state of the new repository. Also, an administrator can sync local state using the [/help?cmd=configuration|config push] and [/help?cmd=configuration|config pull] commands. <h2>2.0 Transport</h2> <p>All communication between client and server is via HTTP requests. The server is listening for incoming HTTP requests. The client issues one or more HTTP requests and receives replies for each |
| ︙ | ︙ |
Changes to www/tech_overview.wiki.
1 2 3 4 5 6 7 8 9 10 | <title>Technical Overview</title> <h2 align="center"> A Technical Overview<br>Of The Design And Implementation<br>Of Fossil </h2> <h2>1.0 Introduction</h2> At its lowest level, a Fossil repository consists of an unordered set of immutable "artifacts". You might think of these artifacts as "files", since in many cases the artifacts are exactly that. | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <title>Technical Overview</title> <h2 align="center"> A Technical Overview<br>Of The Design And Implementation<br>Of Fossil </h2> <h2>1.0 Introduction</h2> At its lowest level, a Fossil repository consists of an unordered set of immutable "artifacts". You might think of these artifacts as "files", since in many cases the artifacts are exactly that. But other "structural artifacts" are also included in the mix. These structural artifacts define the relationships between artifacts - which files go together to form a particular version of the project, who checked in that version and when, what was the check-in comment, what wiki pages are included with the project, what are the edit histories of each wiki page, what bug reports or tickets are included, who contributed to the evolution of each ticket, and so forth. This low-level file format is called the "global state" of the repository, since this is the information that is synced to peer |
| ︙ | ︙ | |||
204 205 206 207 208 209 210 | * Cross-references between tickets, check-ins, and wiki pages. The metadata is held in various SQL tables in the repository database. The metadata is designed to facilitate queries for the various timelines and reports that Fossil generates. As the functionality of Fossil evolves, the schema for the metadata can and does change. | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | * Cross-references between tickets, check-ins, and wiki pages. The metadata is held in various SQL tables in the repository database. The metadata is designed to facilitate queries for the various timelines and reports that Fossil generates. As the functionality of Fossil evolves, the schema for the metadata can and does change. But schema changes do not invalidate the repository. Remember that the metadata contains no new information - only information that has been extracted from the canonical artifacts and saved in a more useful form. Hence, when the metadata schema changes, the prior metadata can be discarded and the entire metadata corpus can be recomputed from the canonical artifacts. That is what the [/help/rebuild | fossil rebuild] command does. |
| ︙ | ︙ |
Added www/th1-hooks.md.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
TH1 Hooks
=========
<big><big><big><font color="red">** DRAFT **</font></big></big></big>
The **TH1 hooks** feature allows <a href="th1.md">TH1</a> scripts to be
configured that can monitor, create, alter, or cancel the execution of
Fossil commands and web pages.
This feature requires the TH1 hooks feature to be enabled at compile-time.
Additionally, the "th1-hooks" repository setting must be enabled at runtime
in order to successfully make use of this feature.
TH1 Hook Related User-Defined Procedures
----------------------------------------
In order to activate TH1 hooks, one or more of the following user-defined
procedures should be defined, generally from within the "th1-setup" script
(setting) for a repository. The following bullets summarize the available
TH1 hooks:
* command\_hook -- _Called before execution of a command._
* command\_notify -- _Called after execution of a command._
* webpage\_hook -- _Called before rendering of a web page._
* webpage\_notify -- _Called after rendering of a web page._
TH1 Hook Related Variables for Commands
---------------------------------------
* cmd\_name -- _Name of command being executed._
* cmd\_args -- _Current command line arguments._
* cmd\_flags -- _Bitmask of CMDFLAG values for the command being executed._
TH1 Hook Related Variables for Web Pages
----------------------------------------
* web\_name -- _Name of web page being rendered._
* web\_args -- _Current command line arguments._
* web\_flags -- _Bitmask of CMDFLAG values for the web page being rendered._
<a name="cmdReturnCodes"></a>TH1 Hook Related Return Codes for Commands
-----------------------------------------------------------------------
* TH\_OK -- _Command will be executed, notification will be executed._
* TH\_ERROR -- _Command will be skipped, notification will be skipped,
error message will be emitted._
* TH\_BREAK -- _Command will be skipped, notification will be skipped._
* TH\_RETURN -- _Command will be executed, notification will be skipped._
* TH\_CONTINUE -- _Command will be skipped, notification will be executed._
For commands that are not included in the Fossil binary, allowing their
execution will cause the standard "unknown command" error message to be
generated, which will typically exit the process. Therefore, adding a
new command generally requires using the TH_CONTINUE return code.
<a name="webReturnCodes"></a>TH1 Hook Related Return Codes for Web Pages
------------------------------------------------------------------------
* TH\_OK -- _Web page will be rendered, notification will be executed._
* TH\_ERROR -- _Web page will be skipped, notification will be skipped,
error message will be emitted._
* TH\_BREAK -- _Web page will be skipped, notification will be skipped._
* TH\_RETURN -- _Web page will be rendered, notification will be skipped._
* TH\_CONTINUE -- _Web page will be skipped, notification will be executed._
For web pages that are not included in the Fossil binary, allowing their
rendering will cause the standard "Not Found" error message to be generated,
which will cause an HTTP 404 status code to be sent. Therefore, adding a
new web page generally requires using the TH_CONTINUE return code.
<a name="triggerReturnCodes"></a>Triggering TH1 Return Codes from a Script
--------------------------------------------------------------------------
* TH\_OK -- _This is the default return code, nothing special needed._
* TH\_ERROR -- _Use the **error** command._
* TH\_BREAK -- _Use the **break** command._
* TH\_RETURN -- _Use the **return -code 5** command._
* TH\_CONTINUE -- _Use the **continue** command._
<a name="command_hook"></a>TH1 command_hook Procedure
-----------------------------------------------------
* command\_hook
This user-defined procedure, if present, is called just before the
execution of a command. The name of the command being executed will
be stored in the "cmd\_name" global variable. The arguments to the
command being executed will be stored in the "cmd\_args" global variable.
The associated CMDFLAG value will be stored in the "cmd\_flags" global
variable. The procedure should cause one of the available return the
<a href="#cmdReturnCodes">code</a> that corresponds to the desired action
to take next.
<a name="command_notify"></a>TH1 command_notify Procedure
---------------------------------------------------------
* command\_notify
This user-defined procedure, if present, is called just after the
execution of a command. The name of the command being executed will
be stored in the "cmd\_name" global variable. The arguments to the
command being executed will be stored in the "cmd\_args" global variable.
The associated CMDFLAG value will be stored in the "cmd\_flags" global
variable. The procedure should cause one of the available return the
<a href="#cmdReturnCodes">code</a> that corresponds to the desired action
to take next.
<a name="webpage_hook"></a>TH1 webpage_hook Procedure
-----------------------------------------------------
* webpage\_hook
This user-defined procedure, if present, is called just before the
rendering of a web page. The name of the web page being rendered will
be stored in the "web\_name" global variable. The arguments to the
web page being rendered will be stored in the "web\_args" global variable.
The associated CMDFLAG value will be stored in the "web\_flags" global
variable. The procedure should cause one of the available return the
<a href="#webReturnCodes">code</a> that corresponds to the desired action
to take next.
<a name="webpage_notify"></a>TH1 webpage_notify Procedure
---------------------------------------------------------
* webpage\_notify
This user-defined procedure, if present, is called just after the
rendering of a web page. The name of the web page being rendered will
be stored in the "web\_name" global variable. The arguments to the
web page being rendered will be stored in the "web\_args" global variable.
The associated CMDFLAG value will be stored in the "web\_flags" global
variable. The procedure should cause one of the available return the
<a href="#webReturnCodes">code</a> that corresponds to the desired action
to take next.
|
Changes to www/th1.md.
| ︙ | ︙ | |||
103 104 105 106 107 108 109 110 111 112 113 114 115 116 | * lsearch LIST STRING * proc NAME ARG-LIST BODY-SCRIPT * rename OLD NEW * return ?-code CODE? ?VALUE? * set VARNAME VALUE * string compare STR1 STR2 * string first NEEDLE HAYSTACK ?START-INDEX? * string is CLASS STRING * string last NEEDLE HAYSTACK ?START-INDEX? * string length STRING * string range STRING FIRST LAST * string repeat STRING COUNT * unset VARNAME * uplevel ?LEVEL? SCRIPT | > | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | * lsearch LIST STRING * proc NAME ARG-LIST BODY-SCRIPT * rename OLD NEW * return ?-code CODE? ?VALUE? * set VARNAME VALUE * string compare STR1 STR2 * string first NEEDLE HAYSTACK ?START-INDEX? * string index STRING INDEX * string is CLASS STRING * string last NEEDLE HAYSTACK ?START-INDEX? * string length STRING * string range STRING FIRST LAST * string repeat STRING COUNT * unset VARNAME * uplevel ?LEVEL? SCRIPT |
| ︙ | ︙ |