Fossil SCM
Merge trunk.
Commit
c57830bec263996efdfc7eaa179d0cac7d65fd49
Parent
9fbc052c88fb4e9…
162 files changed
+38
-16
-28
+1
-26
+3
+9
+1
+2
+35
+1
+31
+63
+30
+314
+307
+1
+9
+144
+2
+130
+21
+3
+59
-59
+224
-255
+224
-255
+11
-5
+4
-3
+113
-318
+77
-21
+77
-21
+75
-29
+7
-3
+1
-1
+85
-33
+192
-120
+192
-120
+9
-18
+9
-18
+2
-2
+35
-17
+6
-6
+11
-15
+482
-91
+81
-25
+301
-117
+301
-117
+7
-13
+70
-20
+102
-24
+79
-43
+79
-43
+41
-11
+6
-6
+2
-2
+165
-43
+248
-40
+248
-40
+53
-21
+53
-21
+45
+140
-45
+59
+19
-16
+70
-1
+18
-12
+146
-34
+146
-34
+268
-107
+53
-2
+604
-95
+275
-93
+275
-93
+57
-8
+30
-4
+93
-74
+170
-57
+2
-2
+62
-48
+62
-48
+132
-22
+1
-6
+5
+32
-24
+3
+6
-2
+48
-1
+271
-56
+21
-15
+47
-24
+47
-24
+1
-1
+204
-29
+55
-14
+55
-14
+174
-12
+15
-1
+327
-22
+59
+11490
-5107
+559
-123
+27
-23
+27
-23
+2
-1
+35
-2
+41
-14
+40
-19
+1
+2
-2
+377
-98
+46
-26
+38
-27
+38
-27
+180
-105
+180
-105
+34
-20
+32
-37
+1
-1
+124
-39
+124
-39
+19
-32
+45
-19
+665
-28
+289
-141
+10
-10
+1
-1
+3
-3
+66
-20
+46
-18
+1
+30
-28
+8
-2
+4
-4
+36
-15
+62
-12
+222
-109
+1
-10
+65
-27
+1
+48
+21
+55
+97
-52
+5
-3
+6
-4
+44
-13
+60
+21
-7
+31
-21
+53
-19
+16
-6
+30
+72
+21
-19
+7
+1
-1
+11
-3
+6
+21
+56
~
BUILD.txt
-
Makefile
~
Makefile.classic
+
Makefile.classic
~
Makefile.in
~
VERSION
~
auto.def
~
autosetup/LICENSE
~
autosetup/README.autosetup
~
autosetup/autosetup
~
autosetup/cc-lib.tcl
~
autosetup/cc-shared.tcl
~
autosetup/cc.tcl
~
autosetup/config.guess
~
autosetup/config.sub
~
autosetup/find-tclsh
~
autosetup/jimsh0.c
~
autosetup/local.tcl
~
autosetup/system.tcl
~
autosetup/test-tclsh
~
configure
~
fossil.nsi
~
src/add.c
~
src/add.c
~
src/allrepo.c
~
src/attach.c
~
src/bisect.c
~
src/blob.c
~
src/blob.c
~
src/branch.c
~
src/browse.c
~
src/captcha.c
~
src/cgi.c
~
src/checkin.c
~
src/checkin.c
~
src/checkout.c
~
src/checkout.c
~
src/clearsign.c
~
src/clone.c
~
src/comformat.c
~
src/config.h
~
src/configure.c
~
src/content.c
~
src/db.c
~
src/db.c
~
src/deltacmd.c
~
src/descendants.c
~
src/diff.c
~
src/diffcmd.c
~
src/diffcmd.c
~
src/doc.c
~
src/encode.c
~
src/event.c
~
src/export.c
~
src/file.c
~
src/file.c
~
src/finfo.c
~
src/finfo.c
~
src/glob.c
~
src/graph.c
~
src/gzip.c
~
src/http.c
~
src/http_ssl.c
~
src/http_transport.c
~
src/import.c
~
src/import.c
~
src/info.c
~
src/leaf.c
~
src/login.c
~
src/main.c
~
src/main.c
~
src/main.mk
~
src/makeheaders.c
~
src/makemake.tcl
~
src/manifest.c
~
src/md5.c
~
src/merge.c
~
src/merge.c
~
src/merge3.c
~
src/mkversion.c
+
src/mkversion.c
~
src/name.c
~
src/path.c
~
src/pqueue.c
~
src/printf.c
~
src/rebuild.c
~
src/report.c
~
src/schema.c
~
src/schema.c
~
src/search.c
~
src/setup.c
~
src/sha1.c
~
src/sha1.c
~
src/shell.c
~
src/shun.c
~
src/skins.c
~
src/sqlcmd.c
~
src/sqlite3.c
~
src/sqlite3.h
~
src/stash.c
~
src/stash.c
~
src/stat.c
~
src/style.c
~
src/sync.c
~
src/tag.c
~
src/tar.c
~
src/th_main.c
~
src/timeline.c
~
src/tkt.c
~
src/undo.c
~
src/undo.c
~
src/update.c
~
src/update.c
~
src/url.c
~
src/user.c
~
src/verify.c
~
src/vfile.c
~
src/vfile.c
~
src/wiki.c
~
src/wikiformat.c
~
src/winhttp.c
~
src/xfer.c
~
src/zip.c
~
test/delta1.test
~
test/file1.test
~
test/graph-test-1.wiki
~
test/merge1.test
~
test/merge2.test
~
test/merge3.test
~
test/release-checklist.wiki
~
win/Makefile.PellesCGMake
~
win/Makefile.dmc
~
win/Makefile.mingw
~
win/Makefile.msc
~
win/icon.rc
-
win/version.c
~
www/build-icons/mac.gif
~
www/build.wiki
~
www/changes.wiki
~
www/checkin.wiki
~
www/checkin_names.wiki
~
www/contribute.wiki
~
www/copyright-release.html
~
www/copyright-release.pdf
~
www/faq.tcl
~
www/faq.wiki
~
www/fileformat.wiki
~
www/foss-cklist.wiki
~
www/fossil_logo_small.gif
~
www/index.wiki
~
www/makefile.wiki
~
www/mkdownload.tcl
~
www/mkindex.tcl
~
www/permutedindex.wiki
~
www/private.wiki
~
www/quickstart.wiki
~
www/reviews.wiki
~
www/selfhost.wiki
~
www/server.wiki
~
www/settings.wiki
~
www/ssl.wiki
~
www/style.wiki
+38
-16
| --- BUILD.txt | ||
| +++ BUILD.txt | ||
| @@ -1,41 +1,60 @@ | ||
| 1 | -All of the source code for fossil is contained in the src/ subdirectory. | |
| 2 | -But there is a lot of generated code, so you will probably want to | |
| 3 | -use the Makefile. To do a complete build on unix, just type: | |
| 1 | +To do a complete build, just type: | |
| 2 | + | |
| 3 | + ./configure; make | |
| 4 | + | |
| 5 | +The ./configure script builds Makefile from Makefile.in based on | |
| 6 | +your system and any options you select (run "./configure --help" | |
| 7 | +for a listing of the available options.) | |
| 8 | + | |
| 9 | +If you wish to use the original Makefile with no configuration, you can | |
| 10 | +instead use: | |
| 4 | 11 | |
| 5 | - make | |
| 12 | + make -f Makefile.classic | |
| 6 | 13 | |
| 7 | 14 | On a windows box, use one of the Makefiles in the win/ subdirectory, |
| 8 | -according to your compiler and environment. For example: | |
| 15 | +according to your compiler and environment. If you have GCC and MSYS | |
| 16 | +installed on your system, then consider: | |
| 17 | + | |
| 18 | + make -f win/Makefile.mingw | |
| 19 | + | |
| 20 | +If you have VC++ installed on your system, then consider: | |
| 9 | 21 | |
| 10 | - make -f win/Makefile.w32 | |
| 22 | + cd win; nmake /f Makefile.msc | |
| 11 | 23 | |
| 12 | 24 | If you have trouble, or you want to do something fancy, just look at |
| 13 | -top level makefile. There are 6 configuration options that are all well | |
| 14 | -commented. Instead of editing the Makefile, consider copying the Makefile | |
| 15 | -to an alternative name such as "GNUMakefile", "BSDMakefile", or "makefile" | |
| 16 | -and editing the copy. | |
| 25 | +Makefile.classic. There are 6 configuration options that are all well | |
| 26 | +commented. Instead of editing the Makefile.classic, consider copying | |
| 27 | +Makefile.classic to an alternative name such as "GNUMakefile", | |
| 28 | +"BSDMakefile", or "makefile" and editing the copy. | |
| 17 | 29 | |
| 18 | 30 | |
| 19 | 31 | BUILDING OUTSIDE THE SOURCE TREE |
| 20 | 32 | |
| 21 | 33 | An out of source build is pretty easy: |
| 22 | 34 | |
| 23 | - 1. Make a new directory to do the builds in. | |
| 24 | - 2. Copy "Makefile" from the source into the build directory and | |
| 25 | - modify the SRCDIR macro along the lines of: | |
| 35 | + 1. Make and change to a new directory to do the builds in. | |
| 36 | + 2. Run the "configure" script from this directory. | |
| 37 | + 3. Type: "make" | |
| 38 | + | |
| 39 | +For example: | |
| 26 | 40 | |
| 27 | - SRCDIR=../src | |
| 28 | - | |
| 29 | - 3. type: "make" | |
| 41 | + mkdir build | |
| 42 | + cd build | |
| 43 | + ../configure | |
| 44 | + make | |
| 30 | 45 | |
| 31 | 46 | This will now keep all generates files seperate from the maintained |
| 32 | 47 | source code. |
| 33 | 48 | |
| 34 | 49 | -------------------------------------------------------------------------- |
| 35 | 50 | |
| 36 | 51 | Here are some notes on what is happening behind the scenes: |
| 52 | + | |
| 53 | +* The configure script (if used) examines the options given | |
| 54 | + and runs various tests with the C compiler to create Makefile | |
| 55 | + from the Makefile.in template as well as autoconfig.h | |
| 37 | 56 | |
| 38 | 57 | * The Makefile just sets up a few macros and then invokes the |
| 39 | 58 | real makefile in src/main.mk. The src/main.mk makefile is |
| 40 | 59 | automatically generated by a TCL script found at src/makemake.tcl. |
| 41 | 60 | Do not edit src/main.mk directly. Update src/makemake.tcl and |
| @@ -51,5 +70,8 @@ | ||
| 51 | 70 | A header comment in src/translate.c explains in detail what it does. |
| 52 | 71 | |
| 53 | 72 | * The src/mkindex.c program generates some C code that implements |
| 54 | 73 | static lookup tables. See the header comment in the source code |
| 55 | 74 | for details on what it does. |
| 75 | + | |
| 76 | +Additional information on the build process is available from | |
| 77 | +http://www.fossil-scm.org/fossil/doc/trunk/www/makefile.wiki | |
| 56 | 78 | |
| 57 | 79 | DELETED Makefile |
| 58 | 80 | ADDED Makefile.classic |
| 59 | 81 | ADDED Makefile.in |
| 60 | 82 | ADDED VERSION |
| 61 | 83 | ADDED auto.def |
| 62 | 84 | ADDED autosetup/LICENSE |
| 63 | 85 | ADDED autosetup/README.autosetup |
| 64 | 86 | ADDED autosetup/autosetup |
| 65 | 87 | ADDED autosetup/cc-lib.tcl |
| 66 | 88 | ADDED autosetup/cc-shared.tcl |
| 67 | 89 | ADDED autosetup/cc.tcl |
| 68 | 90 | ADDED autosetup/config.guess |
| 69 | 91 | ADDED autosetup/config.sub |
| 70 | 92 | ADDED autosetup/find-tclsh |
| 71 | 93 | ADDED autosetup/jimsh0.c |
| 72 | 94 | ADDED autosetup/local.tcl |
| 73 | 95 | ADDED autosetup/system.tcl |
| 74 | 96 | ADDED autosetup/test-tclsh |
| 75 | 97 | ADDED configure |
| --- BUILD.txt | |
| +++ BUILD.txt | |
| @@ -1,41 +1,60 @@ | |
| 1 | All of the source code for fossil is contained in the src/ subdirectory. |
| 2 | But there is a lot of generated code, so you will probably want to |
| 3 | use the Makefile. To do a complete build on unix, just type: |
| 4 | |
| 5 | make |
| 6 | |
| 7 | On a windows box, use one of the Makefiles in the win/ subdirectory, |
| 8 | according to your compiler and environment. For example: |
| 9 | |
| 10 | make -f win/Makefile.w32 |
| 11 | |
| 12 | If you have trouble, or you want to do something fancy, just look at |
| 13 | top level makefile. There are 6 configuration options that are all well |
| 14 | commented. Instead of editing the Makefile, consider copying the Makefile |
| 15 | to an alternative name such as "GNUMakefile", "BSDMakefile", or "makefile" |
| 16 | and editing the copy. |
| 17 | |
| 18 | |
| 19 | BUILDING OUTSIDE THE SOURCE TREE |
| 20 | |
| 21 | An out of source build is pretty easy: |
| 22 | |
| 23 | 1. Make a new directory to do the builds in. |
| 24 | 2. Copy "Makefile" from the source into the build directory and |
| 25 | modify the SRCDIR macro along the lines of: |
| 26 | |
| 27 | SRCDIR=../src |
| 28 | |
| 29 | 3. type: "make" |
| 30 | |
| 31 | This will now keep all generates files seperate from the maintained |
| 32 | source code. |
| 33 | |
| 34 | -------------------------------------------------------------------------- |
| 35 | |
| 36 | Here are some notes on what is happening behind the scenes: |
| 37 | |
| 38 | * The Makefile just sets up a few macros and then invokes the |
| 39 | real makefile in src/main.mk. The src/main.mk makefile is |
| 40 | automatically generated by a TCL script found at src/makemake.tcl. |
| 41 | Do not edit src/main.mk directly. Update src/makemake.tcl and |
| @@ -51,5 +70,8 @@ | |
| 51 | A header comment in src/translate.c explains in detail what it does. |
| 52 | |
| 53 | * The src/mkindex.c program generates some C code that implements |
| 54 | static lookup tables. See the header comment in the source code |
| 55 | for details on what it does. |
| 56 | |
| 57 | ELETED Makefile |
| 58 | DDED Makefile.classic |
| 59 | DDED Makefile.in |
| 60 | DDED VERSION |
| 61 | DDED auto.def |
| 62 | DDED autosetup/LICENSE |
| 63 | DDED autosetup/README.autosetup |
| 64 | DDED autosetup/autosetup |
| 65 | DDED autosetup/cc-lib.tcl |
| 66 | DDED autosetup/cc-shared.tcl |
| 67 | DDED autosetup/cc.tcl |
| 68 | DDED autosetup/config.guess |
| 69 | DDED autosetup/config.sub |
| 70 | DDED autosetup/find-tclsh |
| 71 | DDED autosetup/jimsh0.c |
| 72 | DDED autosetup/local.tcl |
| 73 | DDED autosetup/system.tcl |
| 74 | DDED autosetup/test-tclsh |
| 75 | DDED configure |
| --- BUILD.txt | |
| +++ BUILD.txt | |
| @@ -1,41 +1,60 @@ | |
| 1 | To do a complete build, just type: |
| 2 | |
| 3 | ./configure; make |
| 4 | |
| 5 | The ./configure script builds Makefile from Makefile.in based on |
| 6 | your system and any options you select (run "./configure --help" |
| 7 | for a listing of the available options.) |
| 8 | |
| 9 | If you wish to use the original Makefile with no configuration, you can |
| 10 | instead use: |
| 11 | |
| 12 | make -f Makefile.classic |
| 13 | |
| 14 | On a windows box, use one of the Makefiles in the win/ subdirectory, |
| 15 | according to your compiler and environment. If you have GCC and MSYS |
| 16 | installed on your system, then consider: |
| 17 | |
| 18 | make -f win/Makefile.mingw |
| 19 | |
| 20 | If you have VC++ installed on your system, then consider: |
| 21 | |
| 22 | cd win; nmake /f Makefile.msc |
| 23 | |
| 24 | If you have trouble, or you want to do something fancy, just look at |
| 25 | Makefile.classic. There are 6 configuration options that are all well |
| 26 | commented. Instead of editing the Makefile.classic, consider copying |
| 27 | Makefile.classic to an alternative name such as "GNUMakefile", |
| 28 | "BSDMakefile", or "makefile" and editing the copy. |
| 29 | |
| 30 | |
| 31 | BUILDING OUTSIDE THE SOURCE TREE |
| 32 | |
| 33 | An out of source build is pretty easy: |
| 34 | |
| 35 | 1. Make and change to a new directory to do the builds in. |
| 36 | 2. Run the "configure" script from this directory. |
| 37 | 3. Type: "make" |
| 38 | |
| 39 | For example: |
| 40 | |
| 41 | mkdir build |
| 42 | cd build |
| 43 | ../configure |
| 44 | make |
| 45 | |
| 46 | This will now keep all generates files seperate from the maintained |
| 47 | source code. |
| 48 | |
| 49 | -------------------------------------------------------------------------- |
| 50 | |
| 51 | Here are some notes on what is happening behind the scenes: |
| 52 | |
| 53 | * The configure script (if used) examines the options given |
| 54 | and runs various tests with the C compiler to create Makefile |
| 55 | from the Makefile.in template as well as autoconfig.h |
| 56 | |
| 57 | * The Makefile just sets up a few macros and then invokes the |
| 58 | real makefile in src/main.mk. The src/main.mk makefile is |
| 59 | automatically generated by a TCL script found at src/makemake.tcl. |
| 60 | Do not edit src/main.mk directly. Update src/makemake.tcl and |
| @@ -51,5 +70,8 @@ | |
| 70 | A header comment in src/translate.c explains in detail what it does. |
| 71 | |
| 72 | * The src/mkindex.c program generates some C code that implements |
| 73 | static lookup tables. See the header comment in the source code |
| 74 | for details on what it does. |
| 75 | |
| 76 | Additional information on the build process is available from |
| 77 | http://www.fossil-scm.org/fossil/doc/trunk/www/makefile.wiki |
| 78 | |
| 79 | ELETED Makefile |
| 80 | DDED Makefile.classic |
| 81 | DDED Makefile.in |
| 82 | DDED VERSION |
| 83 | DDED auto.def |
| 84 | DDED autosetup/LICENSE |
| 85 | DDED autosetup/README.autosetup |
| 86 | DDED autosetup/autosetup |
| 87 | DDED autosetup/cc-lib.tcl |
| 88 | DDED autosetup/cc-shared.tcl |
| 89 | DDED autosetup/cc.tcl |
| 90 | DDED autosetup/config.guess |
| 91 | DDED autosetup/config.sub |
| 92 | DDED autosetup/find-tclsh |
| 93 | DDED autosetup/jimsh0.c |
| 94 | DDED autosetup/local.tcl |
| 95 | DDED autosetup/system.tcl |
| 96 | DDED autosetup/test-tclsh |
| 97 | DDED configure |
D
Makefile
-28
| --- a/Makefile | ||
| +++ b/Makefile | ||
| @@ -1,28 +0,0 @@ | ||
| 1 | -#!/usr/bin/make | |
| 2 | -ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX - This works out-of-the-box on mFX@P@1BE,N:fossil:@ | |
| 3 | -#@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:.E_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source | |
| 4 | -# | |
| 5 | -# | |
| 6 | -OBJDIR = ./_STUBS@ | |
| 7 | -FOSSIL_ENABLE_TCL_PRIVATE_STUBS = @FOSSIL_ENABLE_TCL_PRIVATE_STUBSSQLITESQLITELIBS@ @OPENSSL_LDFL -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fosgccE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P | |
| 8 | - | |
| 9 | -#### C CompileIR = ./_STUBS@ | |
| 10 | -FOSSIL_ @FOSSIL_ENABLE_TCL_PRItarget platforl:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source | |
| 11 | -# | |
| 12 | -# | |
| 13 | -OBJDIR = ./_STUBS@ | |
| 14 | -FOSSIL_ENABLE_TCL_PRIVATE_STUBS = @FOSSIL_ENABLE_TCL_PRIVATE_STUBSSQLITESQLITELIBS@ @OPENSSL_LDFL -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzz -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source | |
| 15 | -# files change, where *.in outputs are touched only if they | |
| 16 | -# actually change. If something other than M -D_HAVEas BCC, unless you are cross-compiling. This C compiler builds | |
| 17 | -# the finished binary for fossil. The BCC compiler above is used | |
| 18 | -# for building intermediate code-generator tools. | |
| 19 | -# | |
| 20 | -#TCC = gcc -O6 | |
| 21 | -#TCC = gcc -g -O0 -Wa!profile-arcs -ftest-coverage | |
| 22 | -TCC = gcc -g -Os -Wall | |
| 23 | - | |
| 24 | -# To add support for HTTPS | |
| 25 | -TCC += -DFOSSIL_ENABLE_SSL | |
| 26 | - | |
| 27 | -#### Extra arguments for linking the finished binary. Fossil needs | |
| 28 | -#PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX |
| --- a/Makefile | |
| +++ b/Makefile | |
| @@ -1,28 +0,0 @@ | |
| 1 | #!/usr/bin/make |
| 2 | ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX - This works out-of-the-box on mFX@P@1BE,N:fossil:@ |
| 3 | #@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:.E_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source |
| 4 | # |
| 5 | # |
| 6 | OBJDIR = ./_STUBS@ |
| 7 | FOSSIL_ENABLE_TCL_PRIVATE_STUBS = @FOSSIL_ENABLE_TCL_PRIVATE_STUBSSQLITESQLITELIBS@ @OPENSSL_LDFL -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fosgccE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P |
| 8 | |
| 9 | #### C CompileIR = ./_STUBS@ |
| 10 | FOSSIL_ @FOSSIL_ENABLE_TCL_PRItarget platforl:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source |
| 11 | # |
| 12 | # |
| 13 | OBJDIR = ./_STUBS@ |
| 14 | FOSSIL_ENABLE_TCL_PRIVATE_STUBS = @FOSSIL_ENABLE_TCL_PRIVATE_STUBSSQLITESQLITELIBS@ @OPENSSL_LDFL -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzz -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source |
| 15 | # files change, where *.in outputs are touched only if they |
| 16 | # actually change. If something other than M -D_HAVEas BCC, unless you are cross-compiling. This C compiler builds |
| 17 | # the finished binary for fossil. The BCC compiler above is used |
| 18 | # for building intermediate code-generator tools. |
| 19 | # |
| 20 | #TCC = gcc -O6 |
| 21 | #TCC = gcc -g -O0 -Wa!profile-arcs -ftest-coverage |
| 22 | TCC = gcc -g -Os -Wall |
| 23 | |
| 24 | # To add support for HTTPS |
| 25 | TCC += -DFOSSIL_ENABLE_SSL |
| 26 | |
| 27 | #### Extra arguments for linking the finished binary. Fossil needs |
| 28 | #PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX |
| --- a/Makefile | |
| +++ b/Makefile | |
| @@ -1,28 +0,0 @@ | |
+1
-26
| --- a/Makefile.classic | ||
| +++ b/Makefile.classic | ||
| @@ -1,28 +1,3 @@ | ||
| 1 | 1 | #!/usr/bin/make |
| 2 | -ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX - This works out-of-the-box on mFX@P@1BE,N:fossil:@ | |
| 3 | -#@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:.E_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source | |
| 4 | 2 | # |
| 5 | -# | |
| 6 | -OBJDIR = ./_STUBS@ | |
| 7 | -FOSSIL_ENABLE_TCL_PRIVATE_STUBS = @FOSSIL_ENABLE_TCL_PRIVATE_STUBSSQLITESQLITELIBS@ @OPENSSL_LDFL -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fosgccE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P | |
| 8 | - | |
| 9 | -#### C CompileIR = ./_STUBS@ | |
| 10 | -FOSSIL_ @FOSSIL_ENABLE_TCL_PRItarget platforl:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source | |
| 11 | -# | |
| 12 | -# | |
| 13 | -OBJDIR = ./_STUBS@ | |
| 14 | -FOSSIL_ENABLE_TCL_PRIVATE_STUBS = @FOSSIL_ENABLE_TCL_PRIVATE_STUBSSQLITESQLITELIBS@ @OPENSSL_LDFL -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzz -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source | |
| 15 | -# files change, where *.in outputs are touched only if they | |
| 16 | -# actually change. If something other than M -D_HAVEas BCC, unless you are cross-compiling. This C compiler builds | |
| 17 | -# the finished binary for fossil. The BCC compiler above is used | |
| 18 | -# for building intermediate code-generator tools. | |
| 19 | -# | |
| 20 | -#TCC = gcc -O6 | |
| 21 | -#TCC = gcc -g -O0 -Wa!profile-arcs -ftest-coverage | |
| 22 | -TCC = gcc -g -Os -Wall | |
| 23 | - | |
| 24 | -# To add support for HTTPS | |
| 25 | -TCC += -DFOSSIL_ENABLE_SSL | |
| 26 | - | |
| 27 | -#### Extra arguments for linking the finished binary. Fossil needs | |
| 28 | -#PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX | |
| 3 | +# This is tg the build. This is used |
| --- a/Makefile.classic | |
| +++ b/Makefile.classic | |
| @@ -1,28 +1,3 @@ | |
| 1 | #!/usr/bin/make |
| 2 | ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX - This works out-of-the-box on mFX@P@1BE,N:fossil:@ |
| 3 | #@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:.E_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source |
| 4 | # |
| 5 | # |
| 6 | OBJDIR = ./_STUBS@ |
| 7 | FOSSIL_ENABLE_TCL_PRIVATE_STUBS = @FOSSIL_ENABLE_TCL_PRIVATE_STUBSSQLITESQLITELIBS@ @OPENSSL_LDFL -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fosgccE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P |
| 8 | |
| 9 | #### C CompileIR = ./_STUBS@ |
| 10 | FOSSIL_ @FOSSIL_ENABLE_TCL_PRItarget platforl:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source |
| 11 | # |
| 12 | # |
| 13 | OBJDIR = ./_STUBS@ |
| 14 | FOSSIL_ENABLE_TCL_PRIVATE_STUBS = @FOSSIL_ENABLE_TCL_PRIVATE_STUBSSQLITESQLITELIBS@ @OPENSSL_LDFL -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzz -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source |
| 15 | # files change, where *.in outputs are touched only if they |
| 16 | # actually change. If something other than M -D_HAVEas BCC, unless you are cross-compiling. This C compiler builds |
| 17 | # the finished binary for fossil. The BCC compiler above is used |
| 18 | # for building intermediate code-generator tools. |
| 19 | # |
| 20 | #TCC = gcc -O6 |
| 21 | #TCC = gcc -g -O0 -Wa!profile-arcs -ftest-coverage |
| 22 | TCC = gcc -g -Os -Wall |
| 23 | |
| 24 | # To add support for HTTPS |
| 25 | TCC += -DFOSSIL_ENABLE_SSL |
| 26 | |
| 27 | #### Extra arguments for linking the finished binary. Fossil needs |
| 28 | #PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX |
| --- a/Makefile.classic | |
| +++ b/Makefile.classic | |
| @@ -1,28 +1,3 @@ | |
| 1 | #!/usr/bin/make |
| 2 | # |
| 3 | # This is tg the build. This is used |
+3
| --- a/Makefile.classic | ||
| +++ b/Makefile.classic | ||
| @@ -0,0 +1,3 @@ | ||
| 1 | +#!/usr/bin/make | |
| 2 | +# | |
| 3 | +# This is tg the build. This is used |
| --- a/Makefile.classic | |
| +++ b/Makefile.classic | |
| @@ -0,0 +1,3 @@ | |
| --- a/Makefile.classic | |
| +++ b/Makefile.classic | |
| @@ -0,0 +1,3 @@ | |
| 1 | #!/usr/bin/make |
| 2 | # |
| 3 | # This is tg the build. This is used |
+9
| --- a/Makefile.in | ||
| +++ b/Makefile.in | ||
| @@ -0,0 +1,9 @@ | ||
| 1 | + -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzz -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source | |
| 2 | +# | |
| 3 | +# | |
| 4 | +OBJDIR = ./@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzz -D_HAVE_SQLITE_ssil-@FOSSILendif | |
| 5 | +ifeq ($(findstriSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzz -D_HAVE_SQLITE$(MAKE) reconfig | |
| 6 | +endif | |
| 7 | +@AUTOREMAKE@ && $(MAKE) | |
| 8 | +endif | |
| 9 | +FOSSIL_ENABLE_M + |
| --- a/Makefile.in | |
| +++ b/Makefile.in | |
| @@ -0,0 +1,9 @@ | |
| --- a/Makefile.in | |
| +++ b/Makefile.in | |
| @@ -0,0 +1,9 @@ | |
| 1 | -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzz -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssil-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzzSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX-@FOSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -D_HAVE_SQLITE_ssitclsh -DFOSSIL_ENABLE_LEGACY_MV_RM=1@CFLAGS@@CFLAGS@Rdi make source |
| 2 | # |
| 3 | # |
| 4 | OBJDIR = ./@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzz -D_HAVE_SQLITE_ssil-@FOSSILendif |
| 5 | ifeq ($(findstriSSIL_CI_PFX@P@1BE,N:fossil:@FOSSIL_CI_PFX -fuzz -D_HAVE_SQLITE$(MAKE) reconfig |
| 6 | endif |
| 7 | @AUTOREMAKE@ && $(MAKE) |
| 8 | endif |
| 9 | FOSSIL_ENABLE_M + |
M
VERSION
+1
| --- a/VERSION | ||
| +++ b/VERSION | ||
| @@ -0,0 +1 @@ | ||
| 1 | +1.19 |
| --- a/VERSION | |
| +++ b/VERSION | |
| @@ -0,0 +1 @@ | |
| --- a/VERSION | |
| +++ b/VERSION | |
| @@ -0,0 +1 @@ | |
| 1 | 1.19 |
M
auto.def
+2
| --- a/auto.def | ||
| +++ b/auto.def | ||
| @@ -0,0 +1,2 @@ | ||
| 1 | +D markdown=0 => {Build with markdown enginemarkdown]} { | |
| 2 | +MARKDOWMARKDOWipv6=1 => |
| --- a/auto.def | |
| +++ b/auto.def | |
| @@ -0,0 +1,2 @@ | |
| --- a/auto.def | |
| +++ b/auto.def | |
| @@ -0,0 +1,2 @@ | |
| 1 | D markdown=0 => {Build with markdown enginemarkdown]} { |
| 2 | MARKDOWMARKDOWipv6=1 => |
+35
| --- a/autosetup/LICENSE | ||
| +++ b/autosetup/LICENSE | ||
| @@ -0,0 +1,35 @@ | ||
| 1 | +Unless explicitly stated, all files which form part of autosetup | |
| 2 | +are released under the following license: | |
| 3 | + | |
| 4 | +--------------------------------------------------------------------- | |
| 5 | +autosetup - A build environment "autoconfigurator" | |
| 6 | + | |
| 7 | +Copyright (c) 2010-2011, WorkWare Systems <http://workware.net.au/> | |
| 8 | + | |
| 9 | +Redistribution and use in source and binary forms, with or without | |
| 10 | +modification, are permitted provided that the following conditions | |
| 11 | +are met: | |
| 12 | + | |
| 13 | +1. Redistributions of source code must retain the above copyright | |
| 14 | + notice, this list of conditions and the following disclaimer. | |
| 15 | +2. Redistributions in binary form must reproduce the above | |
| 16 | + copyright notice, this list of conditions and the following | |
| 17 | + disclaimer in the documentation and/or other materials | |
| 18 | + provided with the distribution. | |
| 19 | + | |
| 20 | +THIS SOFTWARE IS PROVIDED BY THE WORKWARE SYSTEMS ``AS IS'' AND ANY | |
| 21 | +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 22 | +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | |
| 23 | +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WORKWARE | |
| 24 | +SYSTEMS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
| 25 | +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 26 | +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
| 27 | +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 28 | +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 29 | +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 30 | +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
| 31 | +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 32 | + | |
| 33 | +The views and conclusions contained in the software and documentation | |
| 34 | +are those of the authors and should not be interpreted as representing | |
| 35 | +official policies, either expressed or implied, of WorkWare Systems. |
| --- a/autosetup/LICENSE | |
| +++ b/autosetup/LICENSE | |
| @@ -0,0 +1,35 @@ | |
| --- a/autosetup/LICENSE | |
| +++ b/autosetup/LICENSE | |
| @@ -0,0 +1,35 @@ | |
| 1 | Unless explicitly stated, all files which form part of autosetup |
| 2 | are released under the following license: |
| 3 | |
| 4 | --------------------------------------------------------------------- |
| 5 | autosetup - A build environment "autoconfigurator" |
| 6 | |
| 7 | Copyright (c) 2010-2011, WorkWare Systems <http://workware.net.au/> |
| 8 | |
| 9 | Redistribution and use in source and binary forms, with or without |
| 10 | modification, are permitted provided that the following conditions |
| 11 | are met: |
| 12 | |
| 13 | 1. Redistributions of source code must retain the above copyright |
| 14 | notice, this list of conditions and the following disclaimer. |
| 15 | 2. Redistributions in binary form must reproduce the above |
| 16 | copyright notice, this list of conditions and the following |
| 17 | disclaimer in the documentation and/or other materials |
| 18 | provided with the distribution. |
| 19 | |
| 20 | THIS SOFTWARE IS PROVIDED BY THE WORKWARE SYSTEMS ``AS IS'' AND ANY |
| 21 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 22 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
| 23 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WORKWARE |
| 24 | SYSTEMS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 27 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 31 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | |
| 33 | The views and conclusions contained in the software and documentation |
| 34 | are those of the authors and should not be interpreted as representing |
| 35 | official policies, either expressed or implied, of WorkWare Systems. |
| --- a/autosetup/README.autosetup | ||
| +++ b/autosetup/README.autosetup | ||
| @@ -0,0 +1 @@ | ||
| 1 | +This is autosetup v0.6.2. S |
| --- a/autosetup/README.autosetup | |
| +++ b/autosetup/README.autosetup | |
| @@ -0,0 +1 @@ | |
| --- a/autosetup/README.autosetup | |
| +++ b/autosetup/README.autosetup | |
| @@ -0,0 +1 @@ | |
| 1 | This is autosetup v0.6.2. S |
+31
| --- a/autosetup/autosetup | ||
| +++ b/autosetup/autosetup | ||
| @@ -0,0 +1,31 @@ | ||
| 1 | +#!/bin/sh | |
| 2 | +4 => "create an initial 'confbool init]$source#!/bin/sh | |
| 3 | +parray define | |
| 4 | + } else { | |
| 5 | + return $alias | |
| 6 | + }[error-location $msg]use cc cc-sharedupleve`"$dir/find-tclsh" || echo false`eduplevel #0#!/bin/sh | |
| 7 | +${m}.tcl | |
| 8 | +uplevel #0 [list source $source]put2put3 "Looking for $source"![string m 2>/dev/null} { | |
| 9 | + set create_configure 1Use --initset cre#!/bin/sh | |
| 10 | +4 => "creat # Jim uses system() for exec under mingw, so | |
| 11 | + # we need to fetch the output ourselves | |
| 12 | + set tmpfile auto[format %04x [rand 10000]].tmp | |
| 13 | + set rc [catch [list exec {*}$readfile $tmpfile] | |
| 14 | + file delete $tmpfile | |
| 15 | + return -code $rc $result breakn/sh | |
| 16 | +4 => "create an in"create an initial 'c[lrange $argv $i end]`"$dir/find-tclsh" || echo false`autoconf-hsh | |
| 17 | +4 => "create an initial 'confbool init]$source#!/bin/sh | |
| 18 | +parray define | |
| 19 | + } else { | |
| 20 | + return $alias | |
| 21 | + }[error-location $msg]use cc cc-shareduplevel #0#!/bin/sh | |
| 22 | +${m}.tcl | |
| 23 | +uplevel #0 [list source $source]put2put3 "Looking for $source"![string m 2>/dev/null} { | |
| 24 | + set create_configure 1Use --initset cre#!/bin/sh | |
| 25 | +4 => "creat # Jim uses system() for exec under mingw, so | |
| 26 | + # we need to fetch the output ourselves | |
| 27 | + set tmpfile auto[format %04x [rand 10000]].tmp | |
| 28 | + set rc [catch [list exec {*}$readfile $tmpfile] | |
| 29 | + file delete $tmpfile | |
| 30 | + return -code $rc $result!/bin/sh | |
| 31 | +4 => "create an |
| --- a/autosetup/autosetup | |
| +++ b/autosetup/autosetup | |
| @@ -0,0 +1,31 @@ | |
| --- a/autosetup/autosetup | |
| +++ b/autosetup/autosetup | |
| @@ -0,0 +1,31 @@ | |
| 1 | #!/bin/sh |
| 2 | 4 => "create an initial 'confbool init]$source#!/bin/sh |
| 3 | parray define |
| 4 | } else { |
| 5 | return $alias |
| 6 | }[error-location $msg]use cc cc-sharedupleve`"$dir/find-tclsh" || echo false`eduplevel #0#!/bin/sh |
| 7 | ${m}.tcl |
| 8 | uplevel #0 [list source $source]put2put3 "Looking for $source"![string m 2>/dev/null} { |
| 9 | set create_configure 1Use --initset cre#!/bin/sh |
| 10 | 4 => "creat # Jim uses system() for exec under mingw, so |
| 11 | # we need to fetch the output ourselves |
| 12 | set tmpfile auto[format %04x [rand 10000]].tmp |
| 13 | set rc [catch [list exec {*}$readfile $tmpfile] |
| 14 | file delete $tmpfile |
| 15 | return -code $rc $result breakn/sh |
| 16 | 4 => "create an in"create an initial 'c[lrange $argv $i end]`"$dir/find-tclsh" || echo false`autoconf-hsh |
| 17 | 4 => "create an initial 'confbool init]$source#!/bin/sh |
| 18 | parray define |
| 19 | } else { |
| 20 | return $alias |
| 21 | }[error-location $msg]use cc cc-shareduplevel #0#!/bin/sh |
| 22 | ${m}.tcl |
| 23 | uplevel #0 [list source $source]put2put3 "Looking for $source"![string m 2>/dev/null} { |
| 24 | set create_configure 1Use --initset cre#!/bin/sh |
| 25 | 4 => "creat # Jim uses system() for exec under mingw, so |
| 26 | # we need to fetch the output ourselves |
| 27 | set tmpfile auto[format %04x [rand 10000]].tmp |
| 28 | set rc [catch [list exec {*}$readfile $tmpfile] |
| 29 | file delete $tmpfile |
| 30 | return -code $rc $result!/bin/sh |
| 31 | 4 => "create an |
+63
| --- a/autosetup/cc-lib.tcl | ||
| +++ b/autosetup/cc-lib.tcl | ||
| @@ -0,0 +1,63 @@ | ||
| 1 | +# Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/ | |
| 2 | +# All rights reserved | |
| 3 | + | |
| 4 | +# @synopsis: | |
| 5 | +# | |
| 6 | +# Provides a library of common tests on top ofmodule-options {}of the 'cc' module. | |
| 7 | + | |
| 8 | +use cc | |
| 9 | + | |
| 10 | +# @cc-check-lfsAC_SYS_LARGEFILE macro | |
| 11 | +# | |
| 12 | +# defines 'HAVE_LFS' if L S is available, | |
| 13 | +# and defines '_FILE_OFFSET_BITS=64' if necessary | |
| 14 | +# | |
| 15 | +# Returns 1 if 'LFS' is available or 0 otherwise | |
| 16 | +# | |
| 17 | +proc cc-check-lfs {} { | |
| 18 | + cc-check-includes sys/types.h | |
| 19 | + msg-checking "Checking if -D_FILE_OFFSET_BITS=64 is needed..." | |
| 20 | + set lfs 1 | |
| 21 | + if {[msg-quiet cc-with {-includes sys/types.h} {cc-check-sizeof off_t}] == 8} { | |
| 22 | + msg-result no | |
| 23 | + } elseif {[msg-quiet cc-with {-includes sys/types.h -cflags -D_FILE_OFFSET_BITS=64} {cc-check-sizeof off_t}] == 8} { | |
| 24 | + define _FILE_OFFSET_BITS 64 | |
| 25 | + msg-result yes | |
| 26 | + } else { | |
| 27 | + set lfs 0 | |
| 28 | + msg-result none | |
| 29 | + } | |
| 30 | + define-feature lfs $lfs | |
| 31 | + return $lfs | |
| 32 | +} | |
| 33 | + | |
| 34 | +# @cc-check-endian | |
| 35 | +# | |
| 36 | +# The equivalent of th eAC_C_BIGENDIAN macroth e 'AC_C_BIGENDIAN' macro. | |
| 37 | +# | |
| 38 | +# defines 'HAVE_BIG_ENDIAN' if endian is known to be big, | |
| 39 | +# or 'HAVE_LITTLE_ENDIAN' if endian is known to be little. | |
| 40 | +# | |
| 41 | +# Returns 1 if determined, or 0 if not. | |
| 42 | +# | |
| 43 | +proc cc-check-endian {} { | |
| 44 | + cc-check-includes sys/types.h sys/param.h | |
| 45 | + set rc 0 | |
| 46 | + msg-checking "Checking endian..." | |
| 47 | + cc-with {-includes {sys/types.h sys/param.h}} { | |
| 48 | + if {[cctest -code { | |
| 49 | + #if! ! defined(LITTLE_ENDIAN) || !defined(BYTE_ORDER) | |
| 50 | + #error unknown | |
| 51 | + #elif BYTE_ORDER != LITTLE_ENDIAN | |
| 52 | + #error big | |
| 53 | + #endif | |
| 54 | + }]} { | |
| 55 | + define-feature little-endian | |
| 56 | + msg-result "little" | |
| 57 | + set rc 1 | |
| 58 | + } else { | |
| 59 | + msg-result "unknown" | |
| 60 | + } | |
| 61 | + } | |
| 62 | + return $rc | |
| 63 | +} |
| --- a/autosetup/cc-lib.tcl | |
| +++ b/autosetup/cc-lib.tcl | |
| @@ -0,0 +1,63 @@ | |
| --- a/autosetup/cc-lib.tcl | |
| +++ b/autosetup/cc-lib.tcl | |
| @@ -0,0 +1,63 @@ | |
| 1 | # Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/ |
| 2 | # All rights reserved |
| 3 | |
| 4 | # @synopsis: |
| 5 | # |
| 6 | # Provides a library of common tests on top ofmodule-options {}of the 'cc' module. |
| 7 | |
| 8 | use cc |
| 9 | |
| 10 | # @cc-check-lfsAC_SYS_LARGEFILE macro |
| 11 | # |
| 12 | # defines 'HAVE_LFS' if L S is available, |
| 13 | # and defines '_FILE_OFFSET_BITS=64' if necessary |
| 14 | # |
| 15 | # Returns 1 if 'LFS' is available or 0 otherwise |
| 16 | # |
| 17 | proc cc-check-lfs {} { |
| 18 | cc-check-includes sys/types.h |
| 19 | msg-checking "Checking if -D_FILE_OFFSET_BITS=64 is needed..." |
| 20 | set lfs 1 |
| 21 | if {[msg-quiet cc-with {-includes sys/types.h} {cc-check-sizeof off_t}] == 8} { |
| 22 | msg-result no |
| 23 | } elseif {[msg-quiet cc-with {-includes sys/types.h -cflags -D_FILE_OFFSET_BITS=64} {cc-check-sizeof off_t}] == 8} { |
| 24 | define _FILE_OFFSET_BITS 64 |
| 25 | msg-result yes |
| 26 | } else { |
| 27 | set lfs 0 |
| 28 | msg-result none |
| 29 | } |
| 30 | define-feature lfs $lfs |
| 31 | return $lfs |
| 32 | } |
| 33 | |
| 34 | # @cc-check-endian |
| 35 | # |
| 36 | # The equivalent of th eAC_C_BIGENDIAN macroth e 'AC_C_BIGENDIAN' macro. |
| 37 | # |
| 38 | # defines 'HAVE_BIG_ENDIAN' if endian is known to be big, |
| 39 | # or 'HAVE_LITTLE_ENDIAN' if endian is known to be little. |
| 40 | # |
| 41 | # Returns 1 if determined, or 0 if not. |
| 42 | # |
| 43 | proc cc-check-endian {} { |
| 44 | cc-check-includes sys/types.h sys/param.h |
| 45 | set rc 0 |
| 46 | msg-checking "Checking endian..." |
| 47 | cc-with {-includes {sys/types.h sys/param.h}} { |
| 48 | if {[cctest -code { |
| 49 | #if! ! defined(LITTLE_ENDIAN) || !defined(BYTE_ORDER) |
| 50 | #error unknown |
| 51 | #elif BYTE_ORDER != LITTLE_ENDIAN |
| 52 | #error big |
| 53 | #endif |
| 54 | }]} { |
| 55 | define-feature little-endian |
| 56 | msg-result "little" |
| 57 | set rc 1 |
| 58 | } else { |
| 59 | msg-result "unknown" |
| 60 | } |
| 61 | } |
| 62 | return $rc |
| 63 | } |
+30
| --- a/autosetup/cc-shared.tcl | ||
| +++ b/autosetup/cc-shared.tcl | ||
| @@ -0,0 +1,30 @@ | ||
| 1 | +# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ | |
| 2 | +# All rights reserved | |
| 3 | + | |
| 4 | +# @synopsis: | |
| 5 | +# | |
| 6 | +# The 'cc-shared' module provides support for shared libraries and shared objects. | |
| 7 | +# It defines the following variables: | |
| 8 | +# | |
| 9 | +## SH_CFLAGS Flags to use compiling sources destined for a shared library | |
| 10 | +## SH_LDFLAGS Flags to use linking t the soname when cread libs - %s = version | |
| 11 | +## SHOBJ_CFLAGS Flags to use compiling sources destined for a shared object | |
| 12 | +## ll symbols table, %s = path | |
| 13 | +## SH_LINKFLAGS Flags to use linking an executable which will load shared objects | |
| 14 | +## LD_LIBRARY_PATH Environment variable which specifie | |
| 15 | +module-options {} | |
| 16 | + | |
| 17 | +foreach i {SH_LINKFLAGS SH_CFLAGS SH_LDFLAGS SHOBJ_CFLAGS SHOBJ_LLD_LIBRARY_PATH define SHOBJ_LDFLAGS_R -bobject | |
| 18 | +## SHOBJ_LDFLAGS Flags to are System# Copyright ( Flags to usDYLD_LIBRARY_PATH | |
| 19 | + } | |
| 20 | + *-*-ming* {sharedOBJ_LDFLAGSshared} | |
| 21 | + *-*-solaris* { | |
| 22 | +# Copyright (c) 20mwed | |
| 23 | +## SHOBJ_LD-Kpic Flags to us-Kpic"-G" | |
| 24 | +define LD_LIBthe toolch-strip-unneeded | |
| 25 | + | |
| 26 | +# Note: Thiain | |
| 27 | +# http://sourceforge sparc* { | |
| 28 | +AGS SHOBJ_LDFLAGS_rdynamicference for identify-fPICshared Flags to us-fPIC} | |
| 29 | + * { | |
| 30 | + # Generic Unix settingsstems http://www.workwa# Copyrigference for identifying PICmicference for idCtify-fPfPICicference for identify-f |
| --- a/autosetup/cc-shared.tcl | |
| +++ b/autosetup/cc-shared.tcl | |
| @@ -0,0 +1,30 @@ | |
| --- a/autosetup/cc-shared.tcl | |
| +++ b/autosetup/cc-shared.tcl | |
| @@ -0,0 +1,30 @@ | |
| 1 | # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ |
| 2 | # All rights reserved |
| 3 | |
| 4 | # @synopsis: |
| 5 | # |
| 6 | # The 'cc-shared' module provides support for shared libraries and shared objects. |
| 7 | # It defines the following variables: |
| 8 | # |
| 9 | ## SH_CFLAGS Flags to use compiling sources destined for a shared library |
| 10 | ## SH_LDFLAGS Flags to use linking t the soname when cread libs - %s = version |
| 11 | ## SHOBJ_CFLAGS Flags to use compiling sources destined for a shared object |
| 12 | ## ll symbols table, %s = path |
| 13 | ## SH_LINKFLAGS Flags to use linking an executable which will load shared objects |
| 14 | ## LD_LIBRARY_PATH Environment variable which specifie |
| 15 | module-options {} |
| 16 | |
| 17 | foreach i {SH_LINKFLAGS SH_CFLAGS SH_LDFLAGS SHOBJ_CFLAGS SHOBJ_LLD_LIBRARY_PATH define SHOBJ_LDFLAGS_R -bobject |
| 18 | ## SHOBJ_LDFLAGS Flags to are System# Copyright ( Flags to usDYLD_LIBRARY_PATH |
| 19 | } |
| 20 | *-*-ming* {sharedOBJ_LDFLAGSshared} |
| 21 | *-*-solaris* { |
| 22 | # Copyright (c) 20mwed |
| 23 | ## SHOBJ_LD-Kpic Flags to us-Kpic"-G" |
| 24 | define LD_LIBthe toolch-strip-unneeded |
| 25 | |
| 26 | # Note: Thiain |
| 27 | # http://sourceforge sparc* { |
| 28 | AGS SHOBJ_LDFLAGS_rdynamicference for identify-fPICshared Flags to us-fPIC} |
| 29 | * { |
| 30 | # Generic Unix settingsstems http://www.workwa# Copyrigference for identifying PICmicference for idCtify-fPfPICicference for identify-f |
+314
| --- a/autosetup/cc.tcl | ||
| +++ b/autosetup/cc.tcl | ||
| @@ -0,0 +1,314 @@ | ||
| 1 | +# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ | |
| 2 | +# All rights reserved | |
| 3 | + | |
| 4 | +# @synopsis: | |
| 5 | +# | |
| 6 | +# The 'cc' module supports checking various 'features' of the C or C++ | |
| 7 | +# compiler/linker environment. Common commands are , | |
| 8 | +# cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-templatement variables are used if set: | |
| 9 | +# | |
| 10 | +## CC - C compiler | |
| 11 | +## CXX - C++ compiler | |
| 12 | +## CPP - C preprocessor | |
| 13 | +##CACHE - Set to "none" to disable automatic use of ccache | |
| 14 | +## Ciler flags | |
| 15 | +## CXXFLAGS - Additional C++ compiler flags | |
| 16 | +## LDFLAGS - Additional compiler flags during linking | |
| 17 | +## LINKFLAGS - ?How is this diffes to use (for all tests) | |
| 18 | +## CROSS - Tool prefix for cross compilation | |
| 19 | +# | |
| 20 | +# The following variables are defined from the corresponding | |
| 21 | +# environment variables if set. | |
| 22 | +# | |
| 23 | +## CC_FOR_BUILD | |
| 24 | +## LD | |
| 25 | + | |
| 26 | +use systPPFLAGS | |
| 27 | +## LINKFLAGSmodule-options {} | |
| 28 | + | |
| 29 | +# Checks for the existence of the giveNote that the return code is not meaningful | |
| 30 | +proc cc-check-something {name code} { | |
| 31 | + uplevel 1 $codee given type/strunction {function} { | |
| 32 | + cctest -link 1 -declare "extern void $function\(void);" -code "$function\();" | |
| 33 | +} | |
| 34 | + | |
| 35 | +# Checks for the existence of the given type by compiling | |
| 36 | +proc cctest_type {type} { | |
| 37 | + cctest -code "$type _x;" | |
| 38 | +} | |
| 39 | + | |
| 40 | +# Checks for the existence of the given type/structure member. | |
| 41 | +# e.g. "struct stat.st_mtime" | |
| 42 | +proc cctest_member {struct_member} { | |
| 43 | + # split at the first dot | |
| 44 | + regexp {^([^.]+)[.](.*)$} $lassign me;\n#endif" | |
| 45 | +} | |
| 46 | + | |
| 47 | +# @cc-ch | |
| 48 | +# e.g. "struct stypeses a variable with the 4 8 1 2 16 32} { | |
| 49 | + if {[cctest -code "static int _x\[sizeof($type) == $i ? 1 : -1\] = { 1 };"]} { | |
| 50 | + set size $i | |
| 51 | + break | |
| 52 | + } | |
| 53 | + } | |
| 54 | + msg-result $size | |
| 55 | + set define [feature-define-name $type SIZEOF_] | |
| 56 | + define $define $size | |
| 57 | + } | |
| 58 | + # Return the last result | |
| 59 | + get-define $define | |
| 60 | +} | |
| 61 | + | |
| 62 | +# Checks for each feature in $list by using the given script. | |
| 63 | +# | |
| 64 | +# When the script is evaluated, $each is set to the feature | |
| 65 | +# being checked, and $extra is set to any additional cctest args. | |
| 66 | +# | |
| 67 | +# Returns 1 if all features were found, or 0 otherwise. | |
| 68 | +proc cc-check-some-feature {list script} { | |
| 69 | + set ret 1 | |
| 70 | + foreach each $list { | |
| 71 | + if {![check-feature $each $script]} { | |
| 72 | + set ret 0 | |
| 73 | + } | |
| 74 | + } | |
| 75 | + return $ret | |
| 76 | +} | |
| 77 | + | |
| 78 | +# @cc-check-includes includes ... | |
| 79 | +# | |
| 80 | +# Checks that the given include files can be used. | |
| 81 | +proc cc-check-includes {args} { | |
| 82 | + c | |
| 83 | +procproc cctest_define {cc-check-some-xp {^([^.]+)[.](.*)$} $struct_member -> struct member | |
| 84 | + cctest -code "static $struct _s; return sizeof(_s.$member);" | |
| 85 | +} | |
| 86 | + | |
| 87 | +# Checks for the existence of the given define by compiling | |
| 88 | +# | |
| 89 | +proc cctest_define {name} { | |
| 90 | + cctest -code "#ifndef $name\n#error not defined\n#endif" | |
| 91 | +} | |
| 92 | + | |
| 93 | +# Checks forcks that the given include files can be used. | |
| 94 | +proc cc-check-includes {args} { | |
| 95 | + cc-check-some-feature $args { | |
| 96 | + set with {} | |
| 97 | + if {[dict exists $::autosetup(cc-include-deps) $each]} { | |
| 98 | + set deps! cc-check-include$exeecks tha]} { | |
| 99 | + cc-with [list -includes $w } | |
| 100 | + define $TOOL $exeed if set: | |
| 101 | +# | |
| 102 | +## CC | |
| 103 | +# @synopsis: | |
| 104 | +# | |
| 105 | +# The 'cc' module supports checking various 'features' of the C or C++ | |
| 106 | +# compiler/linker environment. Common commands are , | |
| 107 | +# cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-templatement variables are used if set: | |
| 108 | +# | |
| 109 | +## CC - C compiler | |
| 110 | +## CXX - C++ compiler | |
| 111 | +## CPP - C preprocessor | |
| 112 | +##CACHE - Set to "none" to disable automatic use of ccache | |
| 113 | +## Ciler flags | |
| 114 | +## CXXFLAGS - Additional C++ compiler flags | |
| 115 | +## LDFLAGS - Additional compiler flags during linking | |
| 116 | +## LINKFLAGS - ?How is this diffes to use (for all tests) | |
| 117 | +## CROSS - Tool prefix for cross compilation | |
| 118 | +# | |
| 119 | +# The following variables are defined from the corresponding | |
| 120 | +# environment variables if set. | |
| 121 | +# | |
| 122 | +## CC_FOR_BUILD | |
| 123 | +## LD | |
| 124 | + | |
| 125 | +use systPPFLAGS | |
| 126 | +## LINKFLAGSmodule-options {} | |
| 127 | + | |
| 128 | +# Checks for the existence of the giveNote that the return code is not meaningful | |
| 129 | +proc cc-check-something {name code} { | |
| 130 | + uplevel 1 $codee given type/strunction {function} { | |
| 131 | + cctest -link 1 -declare "extern void $function\(void);" -code "$function\();" | |
| 132 | +} | |
| 133 | + | |
| 134 | +# Checks for the existence of the given type by compiling | |
| 135 | +proc cctest_type {type} { | |
| 136 | + cctest -code "$type _x;" | |
| 137 | +} | |
| 138 | + | |
| 139 | +# Checks for the existence of the given type/structure member. | |
| 140 | +# e.g. "struct stat.st_mtime" | |
| 141 | +proc cctest_member {struct_member} { | |
| 142 | + # split at the first dot | |
| 143 | + regexp {^([^.]+)[.](.*)$} $lassign [split $struct_member .]rn sizeof(_s.$member);" | |
| 144 | +} | |
| 145 | + | |
| 146 | +# Checks for the existence of the given define by compiling | |
| 147 | +# | |
| 148 | +proc cctest_define {name} { | |
| 149 | + cctest -code "#ifndef $name\n#error not defined\n#endif" | |
| 150 | +} | |
| 151 | + | |
| 152 | +# Checks for the existence of the given name either as | |
| 153 | +# a macro (#define) or an rvalue (such as an enum) | |
| 154 | +# | |
| 155 | +proc cctest_decl {name} { | |
| 156 | + cctest -code "#ifndef $name\n(void)$name;\n#endif" | |
| 157 | +} | |
| 158 | + | |
| 159 | +# @cc-check-sizeof type ... | |
| 160 | +# | |
| 161 | +# Checks the size of the given types (between 1 and 32, inclusive). | |
| 162 | +# Defines a variable with the size determined, or 'unknown'"unknown"ng', defines 'SIZEOF_LSIZEOF_LONG_LONGe. | |
| 163 | +# | |
| 164 | +proc cc-check-sizeof {args} { | |
| 165 | + foreach type $args { | |
| 166 | + msg-checking "Checking for sizeof $type..." | |
| 167 | + set size unknown | |
| 168 | + # Try the most common sizes first | |
| 169 | + foreach i {4 8 1 2 16 32} { | |
| 170 | + if {[cctest -code "static int _x\[sizeof($type) == $i ? 1 : -1\] = { 1 };"]} { | |
| 171 | + set size $i | |
| 172 | + break | |
| 173 | + } | |
| 174 | + } | |
| 175 | + msg-result $size | |
| 176 | + set define [feature-define-name $type SIZEOF_] | |
| 177 | + define $define $size | |
| 178 | + } | |
| 179 | + # Return the last result | |
| 180 | + get-define $define | |
| 181 | +} | |
| 182 | + | |
| 183 | +# Checks for each feature in $list by using the given script. | |
| 184 | +# | |
| 185 | +# When the script is evaluated, $each is set to the feature | |
| 186 | +# being checked, and $extra is set to any additional cctest args. | |
| 187 | +# | |
| 188 | +# Returns 1 if all features were found, or 0 otherwise. | |
| 189 | +proc cc-check-some-feature {list script} { | |
| 190 | + set ret 1 | |
| 191 | + foreach each $list { | |
| 192 | + if {![check-feature $each $script]} { | |
| 193 | + set ret 0 | |
| 194 | + } | |
| 195 | + } | |
| 196 | + return $ret | |
| 197 | +} | |
| 198 | + | |
| 199 | +# @cc-check-includes includes ... | |
| 200 | +# | |
| 201 | +# Checks that the given include files can be used. | |
| 202 | +proc cc-check-includes {args} { | |
| 203 | + c | |
| 204 | +procproc cctest_define {cc-check-some-xp {^([^.]+)[.](.*)$} $struct_member -> struct member | |
| 205 | + cctest -code "static $struct _s; return sizeof(_s.$member);" | |
| 206 | +} | |
| 207 | + | |
| 208 | +# Checks for the existence of the given define by compiling | |
| 209 | +# | |
| 210 | +proc cctest_define {name} { | |
| 211 | + cctest -code "#ifndef $name\n#error not defined\n#endif" | |
| 212 | +} | |
| 213 | + | |
| 214 | +# Checks for the existence of the given name either as | |
| 215 | +# a macro (#define) or an rvalue (such as an enum) | |
| 216 | +# | |
| 217 | +proc cctest_decl {name} { | |
| 218 | + cctest -code "#ifndef $name\n(void)$name;\n#endif" | |
| 219 | +} | |
| 220 | + given types (bet#includeddetermined, or 'unknown' otherwise. | |
| 221 | +# e.g. for type 'long long', defines 'SIZEOF_LONG_LONG'. | |
| 222 | +# Returns the size of the last type. | |
| 223 | +# | |
| 224 | +proc cc-check-sizeof {args} { | |
| 225 | + foreach type $adfirst dot | |
| 226 | + regexp {^([^.]+)[.](.*)$} $struct_member -> struct member | |
| 227 | + cctest -code "static $struct _s; return sizeof(_s.$member);" | |
| 228 | +} | |
| 229 | + | |
| 230 | +# Checks for the existence of the given define by compiling | |
| 231 | +# | |
| 232 | +proc cctest_define FLAGS - ?How is this di# @synopsis: | |
| 233 | +# | |
| 234 | +# The 'cc' module supports checking various 'features' of the C or C++ | |
| 235 | +# compiler/linker environment. Common commands are , | |
| 236 | +# cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-templatement variables are used if set: | |
| 237 | +# | |
| 238 | +## CC - C compiler | |
| 239 | +## CXX - C++ compiler | |
| 240 | +## CPP - C preprocessor | |
| 241 | +##CACHE - Set to "none" to disfor a declsable automatic use of ccache | |
| 242 | +## Ciler flags | |
| 243 | +## C# Copyright (c) 2010 Work foreach type $args { | |
| 244 | + msg-checking "Checking for sizeof $type..." | |
| 245 | + set size unknown | |
| 246 | + # Try the most common sizes first | |
| 247 | + foreach i {4 8 1 2 16 32} { | |
| 248 | + if {[cctest -code "static int _x\[sizeof($type) == $i ? 1 : -1\] = { 1 };"]} { | |
| 249 | + set size $i | |
| 250 | + break | |
| 251 | + } | |
| 252 | + } | |
| 253 | + msg-result $size | |
| 254 | + set define [feature-define-name $type SIZEOF_] | |
| 255 | + define $define $size | |
| 256 | + } | |
| 257 | + # Return the last result | |
| 258 | + get-define $define | |
| 259 | +} | |
| 260 | + | |
| 261 | +# Checks for each feature in $list by using the given script. | |
| 262 | +# | |
| 263 | +# When the script is evaluated, $each is set to the feature | |
| 264 | +# being checked, and $extra is set to any additional cctest args. | |
| 265 | +# | |
| 266 | +# Returns 1 if all features were found, or 0 otherwise. | |
| 267 | +proc cc-check-some-feature {list script} { | |
| 268 | + set ret 1ch $script]} { | |
| 269 | + set ret 0 | |
| 270 | + } | |
| 271 | + } | |
| 272 | + return $ret | |
| 273 | +} | |
| 274 | + | |
| 275 | +# @cc-check-includes includes ... | |
| 276 | +# | |
| 277 | +# Checks that the given include files can be used. | |
| 278 | +proc cc-check-includes {args} { | |
| 279 | + cc-check-some-feature $args { | |
| 280 | + set with {} | |
| 281 | + if {[dict exists $::autosetup(cc-include-deps) $each]} { | |
| 282 | + set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]] | |
| 283 | + msg-quiet cc-check-includes {*}$deps | |
| 284 | + foreach i $deps { | |
| 285 | + if {[have-feature $i]} { | |
| 286 | + lappend with $i | |
| 287 | +ure $each $scriptargs { | |
| 288 | + set new($name) $value | |
| 289 | + } $i]} { | |
| 290 | + lappend$newme\n(void)$name;\n#th]} { | |
| 291 | + cc-with [list -includes $with] { | |
| 292 | + cctest -includes $each | |
| 293 | + } | |
| 294 | + } else { | |
| 295 | + cctest -includes $each | |
| 296 | + } | |
| 297 | + } | |
| 298 | +} | |
| 299 | + | |
| 300 | +# @cc-include-needs include required ... | |
| 301 | +# | |
| 302 | +# Ensures that when checking for '$include', a check is first | |
| 303 | +# made for eachtk is first | |
| 304 | +# made for each '$required' file, and if found, it is included with '#include'. | |
| 305 | +proc cc-include-needs {file args} { | |
| 306 | + foreach depfile $args { | |
| 307 | + dict set ::autosetup(cc-include-deps) $file $depfile 1 | |
| 308 | + } | |
| 309 | +} | |
| 310 | + | |
| 311 | +# C *-*-darwin* { | |
| 312 | + # Don't-gstabs | |
| 313 | + } | |
| 314 | + }$value$valuecc-check-tools ld.o |
| --- a/autosetup/cc.tcl | |
| +++ b/autosetup/cc.tcl | |
| @@ -0,0 +1,314 @@ | |
| --- a/autosetup/cc.tcl | |
| +++ b/autosetup/cc.tcl | |
| @@ -0,0 +1,314 @@ | |
| 1 | # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ |
| 2 | # All rights reserved |
| 3 | |
| 4 | # @synopsis: |
| 5 | # |
| 6 | # The 'cc' module supports checking various 'features' of the C or C++ |
| 7 | # compiler/linker environment. Common commands are , |
| 8 | # cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-templatement variables are used if set: |
| 9 | # |
| 10 | ## CC - C compiler |
| 11 | ## CXX - C++ compiler |
| 12 | ## CPP - C preprocessor |
| 13 | ##CACHE - Set to "none" to disable automatic use of ccache |
| 14 | ## Ciler flags |
| 15 | ## CXXFLAGS - Additional C++ compiler flags |
| 16 | ## LDFLAGS - Additional compiler flags during linking |
| 17 | ## LINKFLAGS - ?How is this diffes to use (for all tests) |
| 18 | ## CROSS - Tool prefix for cross compilation |
| 19 | # |
| 20 | # The following variables are defined from the corresponding |
| 21 | # environment variables if set. |
| 22 | # |
| 23 | ## CC_FOR_BUILD |
| 24 | ## LD |
| 25 | |
| 26 | use systPPFLAGS |
| 27 | ## LINKFLAGSmodule-options {} |
| 28 | |
| 29 | # Checks for the existence of the giveNote that the return code is not meaningful |
| 30 | proc cc-check-something {name code} { |
| 31 | uplevel 1 $codee given type/strunction {function} { |
| 32 | cctest -link 1 -declare "extern void $function\(void);" -code "$function\();" |
| 33 | } |
| 34 | |
| 35 | # Checks for the existence of the given type by compiling |
| 36 | proc cctest_type {type} { |
| 37 | cctest -code "$type _x;" |
| 38 | } |
| 39 | |
| 40 | # Checks for the existence of the given type/structure member. |
| 41 | # e.g. "struct stat.st_mtime" |
| 42 | proc cctest_member {struct_member} { |
| 43 | # split at the first dot |
| 44 | regexp {^([^.]+)[.](.*)$} $lassign me;\n#endif" |
| 45 | } |
| 46 | |
| 47 | # @cc-ch |
| 48 | # e.g. "struct stypeses a variable with the 4 8 1 2 16 32} { |
| 49 | if {[cctest -code "static int _x\[sizeof($type) == $i ? 1 : -1\] = { 1 };"]} { |
| 50 | set size $i |
| 51 | break |
| 52 | } |
| 53 | } |
| 54 | msg-result $size |
| 55 | set define [feature-define-name $type SIZEOF_] |
| 56 | define $define $size |
| 57 | } |
| 58 | # Return the last result |
| 59 | get-define $define |
| 60 | } |
| 61 | |
| 62 | # Checks for each feature in $list by using the given script. |
| 63 | # |
| 64 | # When the script is evaluated, $each is set to the feature |
| 65 | # being checked, and $extra is set to any additional cctest args. |
| 66 | # |
| 67 | # Returns 1 if all features were found, or 0 otherwise. |
| 68 | proc cc-check-some-feature {list script} { |
| 69 | set ret 1 |
| 70 | foreach each $list { |
| 71 | if {![check-feature $each $script]} { |
| 72 | set ret 0 |
| 73 | } |
| 74 | } |
| 75 | return $ret |
| 76 | } |
| 77 | |
| 78 | # @cc-check-includes includes ... |
| 79 | # |
| 80 | # Checks that the given include files can be used. |
| 81 | proc cc-check-includes {args} { |
| 82 | c |
| 83 | procproc cctest_define {cc-check-some-xp {^([^.]+)[.](.*)$} $struct_member -> struct member |
| 84 | cctest -code "static $struct _s; return sizeof(_s.$member);" |
| 85 | } |
| 86 | |
| 87 | # Checks for the existence of the given define by compiling |
| 88 | # |
| 89 | proc cctest_define {name} { |
| 90 | cctest -code "#ifndef $name\n#error not defined\n#endif" |
| 91 | } |
| 92 | |
| 93 | # Checks forcks that the given include files can be used. |
| 94 | proc cc-check-includes {args} { |
| 95 | cc-check-some-feature $args { |
| 96 | set with {} |
| 97 | if {[dict exists $::autosetup(cc-include-deps) $each]} { |
| 98 | set deps! cc-check-include$exeecks tha]} { |
| 99 | cc-with [list -includes $w } |
| 100 | define $TOOL $exeed if set: |
| 101 | # |
| 102 | ## CC |
| 103 | # @synopsis: |
| 104 | # |
| 105 | # The 'cc' module supports checking various 'features' of the C or C++ |
| 106 | # compiler/linker environment. Common commands are , |
| 107 | # cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-templatement variables are used if set: |
| 108 | # |
| 109 | ## CC - C compiler |
| 110 | ## CXX - C++ compiler |
| 111 | ## CPP - C preprocessor |
| 112 | ##CACHE - Set to "none" to disable automatic use of ccache |
| 113 | ## Ciler flags |
| 114 | ## CXXFLAGS - Additional C++ compiler flags |
| 115 | ## LDFLAGS - Additional compiler flags during linking |
| 116 | ## LINKFLAGS - ?How is this diffes to use (for all tests) |
| 117 | ## CROSS - Tool prefix for cross compilation |
| 118 | # |
| 119 | # The following variables are defined from the corresponding |
| 120 | # environment variables if set. |
| 121 | # |
| 122 | ## CC_FOR_BUILD |
| 123 | ## LD |
| 124 | |
| 125 | use systPPFLAGS |
| 126 | ## LINKFLAGSmodule-options {} |
| 127 | |
| 128 | # Checks for the existence of the giveNote that the return code is not meaningful |
| 129 | proc cc-check-something {name code} { |
| 130 | uplevel 1 $codee given type/strunction {function} { |
| 131 | cctest -link 1 -declare "extern void $function\(void);" -code "$function\();" |
| 132 | } |
| 133 | |
| 134 | # Checks for the existence of the given type by compiling |
| 135 | proc cctest_type {type} { |
| 136 | cctest -code "$type _x;" |
| 137 | } |
| 138 | |
| 139 | # Checks for the existence of the given type/structure member. |
| 140 | # e.g. "struct stat.st_mtime" |
| 141 | proc cctest_member {struct_member} { |
| 142 | # split at the first dot |
| 143 | regexp {^([^.]+)[.](.*)$} $lassign [split $struct_member .]rn sizeof(_s.$member);" |
| 144 | } |
| 145 | |
| 146 | # Checks for the existence of the given define by compiling |
| 147 | # |
| 148 | proc cctest_define {name} { |
| 149 | cctest -code "#ifndef $name\n#error not defined\n#endif" |
| 150 | } |
| 151 | |
| 152 | # Checks for the existence of the given name either as |
| 153 | # a macro (#define) or an rvalue (such as an enum) |
| 154 | # |
| 155 | proc cctest_decl {name} { |
| 156 | cctest -code "#ifndef $name\n(void)$name;\n#endif" |
| 157 | } |
| 158 | |
| 159 | # @cc-check-sizeof type ... |
| 160 | # |
| 161 | # Checks the size of the given types (between 1 and 32, inclusive). |
| 162 | # Defines a variable with the size determined, or 'unknown'"unknown"ng', defines 'SIZEOF_LSIZEOF_LONG_LONGe. |
| 163 | # |
| 164 | proc cc-check-sizeof {args} { |
| 165 | foreach type $args { |
| 166 | msg-checking "Checking for sizeof $type..." |
| 167 | set size unknown |
| 168 | # Try the most common sizes first |
| 169 | foreach i {4 8 1 2 16 32} { |
| 170 | if {[cctest -code "static int _x\[sizeof($type) == $i ? 1 : -1\] = { 1 };"]} { |
| 171 | set size $i |
| 172 | break |
| 173 | } |
| 174 | } |
| 175 | msg-result $size |
| 176 | set define [feature-define-name $type SIZEOF_] |
| 177 | define $define $size |
| 178 | } |
| 179 | # Return the last result |
| 180 | get-define $define |
| 181 | } |
| 182 | |
| 183 | # Checks for each feature in $list by using the given script. |
| 184 | # |
| 185 | # When the script is evaluated, $each is set to the feature |
| 186 | # being checked, and $extra is set to any additional cctest args. |
| 187 | # |
| 188 | # Returns 1 if all features were found, or 0 otherwise. |
| 189 | proc cc-check-some-feature {list script} { |
| 190 | set ret 1 |
| 191 | foreach each $list { |
| 192 | if {![check-feature $each $script]} { |
| 193 | set ret 0 |
| 194 | } |
| 195 | } |
| 196 | return $ret |
| 197 | } |
| 198 | |
| 199 | # @cc-check-includes includes ... |
| 200 | # |
| 201 | # Checks that the given include files can be used. |
| 202 | proc cc-check-includes {args} { |
| 203 | c |
| 204 | procproc cctest_define {cc-check-some-xp {^([^.]+)[.](.*)$} $struct_member -> struct member |
| 205 | cctest -code "static $struct _s; return sizeof(_s.$member);" |
| 206 | } |
| 207 | |
| 208 | # Checks for the existence of the given define by compiling |
| 209 | # |
| 210 | proc cctest_define {name} { |
| 211 | cctest -code "#ifndef $name\n#error not defined\n#endif" |
| 212 | } |
| 213 | |
| 214 | # Checks for the existence of the given name either as |
| 215 | # a macro (#define) or an rvalue (such as an enum) |
| 216 | # |
| 217 | proc cctest_decl {name} { |
| 218 | cctest -code "#ifndef $name\n(void)$name;\n#endif" |
| 219 | } |
| 220 | given types (bet#includeddetermined, or 'unknown' otherwise. |
| 221 | # e.g. for type 'long long', defines 'SIZEOF_LONG_LONG'. |
| 222 | # Returns the size of the last type. |
| 223 | # |
| 224 | proc cc-check-sizeof {args} { |
| 225 | foreach type $adfirst dot |
| 226 | regexp {^([^.]+)[.](.*)$} $struct_member -> struct member |
| 227 | cctest -code "static $struct _s; return sizeof(_s.$member);" |
| 228 | } |
| 229 | |
| 230 | # Checks for the existence of the given define by compiling |
| 231 | # |
| 232 | proc cctest_define FLAGS - ?How is this di# @synopsis: |
| 233 | # |
| 234 | # The 'cc' module supports checking various 'features' of the C or C++ |
| 235 | # compiler/linker environment. Common commands are , |
| 236 | # cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-templatement variables are used if set: |
| 237 | # |
| 238 | ## CC - C compiler |
| 239 | ## CXX - C++ compiler |
| 240 | ## CPP - C preprocessor |
| 241 | ##CACHE - Set to "none" to disfor a declsable automatic use of ccache |
| 242 | ## Ciler flags |
| 243 | ## C# Copyright (c) 2010 Work foreach type $args { |
| 244 | msg-checking "Checking for sizeof $type..." |
| 245 | set size unknown |
| 246 | # Try the most common sizes first |
| 247 | foreach i {4 8 1 2 16 32} { |
| 248 | if {[cctest -code "static int _x\[sizeof($type) == $i ? 1 : -1\] = { 1 };"]} { |
| 249 | set size $i |
| 250 | break |
| 251 | } |
| 252 | } |
| 253 | msg-result $size |
| 254 | set define [feature-define-name $type SIZEOF_] |
| 255 | define $define $size |
| 256 | } |
| 257 | # Return the last result |
| 258 | get-define $define |
| 259 | } |
| 260 | |
| 261 | # Checks for each feature in $list by using the given script. |
| 262 | # |
| 263 | # When the script is evaluated, $each is set to the feature |
| 264 | # being checked, and $extra is set to any additional cctest args. |
| 265 | # |
| 266 | # Returns 1 if all features were found, or 0 otherwise. |
| 267 | proc cc-check-some-feature {list script} { |
| 268 | set ret 1ch $script]} { |
| 269 | set ret 0 |
| 270 | } |
| 271 | } |
| 272 | return $ret |
| 273 | } |
| 274 | |
| 275 | # @cc-check-includes includes ... |
| 276 | # |
| 277 | # Checks that the given include files can be used. |
| 278 | proc cc-check-includes {args} { |
| 279 | cc-check-some-feature $args { |
| 280 | set with {} |
| 281 | if {[dict exists $::autosetup(cc-include-deps) $each]} { |
| 282 | set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]] |
| 283 | msg-quiet cc-check-includes {*}$deps |
| 284 | foreach i $deps { |
| 285 | if {[have-feature $i]} { |
| 286 | lappend with $i |
| 287 | ure $each $scriptargs { |
| 288 | set new($name) $value |
| 289 | } $i]} { |
| 290 | lappend$newme\n(void)$name;\n#th]} { |
| 291 | cc-with [list -includes $with] { |
| 292 | cctest -includes $each |
| 293 | } |
| 294 | } else { |
| 295 | cctest -includes $each |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | # @cc-include-needs include required ... |
| 301 | # |
| 302 | # Ensures that when checking for '$include', a check is first |
| 303 | # made for eachtk is first |
| 304 | # made for each '$required' file, and if found, it is included with '#include'. |
| 305 | proc cc-include-needs {file args} { |
| 306 | foreach depfile $args { |
| 307 | dict set ::autosetup(cc-include-deps) $file $depfile 1 |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | # C *-*-darwin* { |
| 312 | # Don't-gstabs |
| 313 | } |
| 314 | }$value$valuecc-check-tools ld.o |
+307
| --- a/autosetup/config.guess | ||
| +++ b/autosetup/config.guess | ||
| @@ -0,0 +1,307 @@ | ||
| 1 | +03-23 the terms of the GNU General Public License as published by | |
| 2 | +# t(C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, | |
| 3 | +# 2000, 2001, 2002, 2003, 2004, 2005, 2006,oftware Foundation, 0-09-24r | |
| 4 | +# (at your option) any later version. | |
| 5 | +# | |
| 6 | +# This program is distributed in the hope that it will be useful, but | |
| 7 | +# WITHOUT ANY WARRANTY; without even the implied w2 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 8 | +# General Public License for more details. | |
| 9 | +# | |
| 10 | +# You should have received a copy of the GNU General Public License | |
| 11 | +# along with this program; if not, see <https://www.gnu.org/licenses/>. | |
| 12 | +# | |
| 13 | +# As a special exceptionto the GNU General Public License, if you | |
| 14 | +# distribute this file as part of a program that contains a | |
| 15 | +# configuration script generated by Autoconwrite to the Free Software | |
| 16 | +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Bmay include it under | |
| 17 | +# the same distribution terms that you use for the rest of that | |
| 18 | +# program. This Exception is an additional permission under section 7 | |
| 19 | +# of the GNU General Public License, version 3 ("GPLv3"). | |
| 20 | +# | |
| 21 | +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. | |
| 22 | +# | |
| 23 | +# You can ggnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. | |
| 24 | + | |
| 25 | +$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} | |
| 26 | + cat <<-EOF > $dummy.c`$CC_FOR_BUILwith a ChangeLog entry to to guess a canonical s#! /bin/sh | |
| 27 | +# Attempt to guess a canonical system name. | |
| 28 | +# Copyright 1992-2014 Free Software Found4-11-04it and/or modify it | |
| 29 | +# under the terms of the GNU General Public License as published by | |
| 30 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 31 | +# (at your option) any later version. | |
| 32 | +# | |
| 33 | +# This program is distributed in the hope that it will be useful, but | |
| 34 | +# WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 35 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 36 | +# General Public License for more details. | |
| 37 | +# | |
| 38 | +# You should have received a copy of the GNU General Public License | |
| 39 | +# along with this program; if not, see <https://www.gnu.org/licenses/>. | |
| 40 | +# | |
| 41 | +# As a special exceptionto the GNU General Public License, if you | |
| 42 | +# distribute this file as part of a program that contains a | |
| 43 | +# configuration script generated by Autoconf, you may include it under | |
| 44 | +# the same distribution terms that you use for the rest of that | |
| 45 | +# program. This Exception is an additional permission under section 7 | |
| 46 | +# of the GNU General Public License, version 3 ("GPLv3"). | |
| 47 | +# | |
| 48 | +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. | |
| 49 | +# | |
| 50 | +# You can get the latest version of this script from: | |
| 51 | +# https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. | |
| 52 | + | |
| 53 | +$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} | |
| 54 | + cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl | |
| 55 | +# Attempt to guess a canoniAttempt to g! /bin/sh | |
| 56 | +# Attemp#*) machine=${! /bin/sh | |
| 57 | +# Attemp#! /bin/sh | |
| 58 | +# Attempt to guess a canonical system name. | |
| 59 | +# Copyright 1992-2018canonical system name. | |
| 60 | +# Copyrig! /bin/sh | |
| 61 | +# Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh | |
| 62 | +# Attemp#! /bin/sh | |
| 63 | +# Attempt to guess a ${! /bin/sh | |
| 64 | +# Attemp#! /bin/sh | |
| 65 | +# Attempt to guess a cekkoBSD:*:*) | |
| 66 | + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*) | |
| 67 | + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh | |
| 68 | +# Attempt to guess a canonical system name. | |
| 69 | +# Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name. | |
| 70 | +# Copyright 1992-2018 Free Software Foundation, Inc. | |
| 71 | + | |
| 72 | +timestamp='2018-03-08it and/or modify it | |
| 73 | +# under the terms of the GNU General Public License as published by | |
| 74 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 75 | +# (at your o program. | |
| 76 | + | |
| 77 | + | |
| 78 | +# neral Public License | |
| 79 | +# along with he GNU General Public03-23 the terms of the and include a ChangeLog | |
| 80 | +# entrhe GNU General Public License as published by | |
| 81 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 82 | +# (at your option) any later version. | |
| 83 | +# | |
| 84 | +# This program is distributed in the hope that it will be useful, but | |
| 85 | +# WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 86 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 87 | +# General Public License for more details. | |
| 88 | +# | |
| 89 | +# You should have received a copy of the GNU General Public License | |
| 90 | +# along with this program; if not, see <https://www.gnu.org/licenses/>. | |
| 91 | +# | |
| 92 | +# As a special exceptionto the GNU General Public License, if you | |
| 93 | +# distribute this file as part of a program that contains a | |
| 94 | +# configuration script generated by Autoconf, you may include it under | |
| 95 | +# the same distribution terms that you use for the rest of that | |
| 96 | +# program. This Exception is an additional permission under section 7 | |
| 97 | +# of the GNU General Public License, version 3 ("GPLv3"). | |
| 98 | +# | |
| 99 | +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. | |
| 100 | +# | |
| 101 | +# You can ggnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. | |
| 102 | + | |
| 103 | +$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} | |
| 104 | + cat <<-EOF > $dummy.c`$CC_FOR_BUILwith a ChangeLog entry to to guess a canonical s#! /bin/sh | |
| 105 | +# Attempt to guess a canonical system name. | |
| 106 | +# Copyright 1992-2014 Free Software Found4-11-04it and/or modify it | |
| 107 | +# under the terms of the GNU General Public License as published by | |
| 108 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 109 | +# (at your option) any later version. | |
| 110 | +# | |
| 111 | +# This program is distributed in the hope that it will be useful, but | |
| 112 | +# WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 113 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 114 | +# General Public License for more details. | |
| 115 | +# | |
| 116 | +# You should have received a copy of the GNU General Public License | |
| 117 | +# along with this program; if not, see <https://www.gnu.org/licenses/>. | |
| 118 | +# | |
| 119 | +# As a special exceptionto the GNU General Public License, if you | |
| 120 | +# distribute this file as part of a program that contains a | |
| 121 | +# configuration script generated by Autoconf, you may include it under | |
| 122 | +# the same distribution terms that you use for the rest of that | |
| 123 | +# program. This Exception is an additional permission under section 7 | |
| 124 | +# of the GNU General Public License, version 3 ("GPLv3"). | |
| 125 | +# | |
| 126 | +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. | |
| 127 | +# | |
| 128 | +# You can get the latest version of this script from: | |
| 129 | +# https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. | |
| 130 | + | |
| 131 | +$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} | |
| 132 | + cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl | |
| 133 | +# Attempt to guess a canoniAttempt to g! /bin/sh | |
| 134 | +# Attemp#*) machine=${! /bin/sh | |
| 135 | +# Attemp#! /bin/sh | |
| 136 | +# Attempt to guess a canonical system name. | |
| 137 | +# Copyright 1992-2018canonical system name. | |
| 138 | +# Copyrig! /bin/sh | |
| 139 | +# Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh | |
| 140 | +# Attemp#! /bin/sh | |
| 141 | +# Attempt to guess a ${! /bin/sh | |
| 142 | +# Attemp#! /bin/sh | |
| 143 | +# Attempt to guess a cekkoBSD:*:*) | |
| 144 | + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*) | |
| 145 | + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh | |
| 146 | +# Attempt to guess a canonical system name. | |
| 147 | +# Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name. | |
| 148 | +# Copyright 1992-2018 Free Software Foundation, Inc. | |
| 149 | + | |
| 150 | +timestamp='2018-03-08it and/or modify it | |
| 151 | +# under the terms of the GNU General Public License as published by | |
| 152 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 153 | +# (at your o.c`$CC_FOR_BUILwith a ChangeLog entry to to guess a canonical s#! /bin/sh | |
| 154 | +# Attempt to guess a canonical system name. | |
| 155 | +# Copyright 1992-2014 Free Software Found4-11-04it and/or modify it | |
| 156 | +# under the terms of the GNU General Public License as published by | |
| 157 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 158 | +# (at your option) any later version. | |
| 159 | +# | |
| 160 | +# This program is distributed in the hope that it will be useful, but | |
| 161 | +# WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 162 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 163 | +# General Public License for more details. | |
| 164 | +# | |
| 165 | +# You should have received a copy of the GNU General Public License | |
| 166 | +# along with this program; if not, see <https://www.gnu.org/licenses/>. | |
| 167 | +# | |
| 168 | +# As a special exceptionto the GNU General Public License, if you | |
| 169 | +# distribute this file as part of a program that contains a | |
| 170 | +# configuration script generated by Autoconf, you may include it under | |
| 171 | +# the same distribution terms that you use for the rest of that | |
| 172 | +# program. This Exception is an additional permission under section 7 | |
| 173 | +# of the GNU General Public License, version 3 ("GPLv3"). | |
| 174 | +# | |
| 175 | +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. | |
| 176 | +# | |
| 177 | +# You can get the latest version of this script from: | |
| 178 | +# https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. | |
| 179 | + | |
| 180 | +$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} | |
| 181 | + cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl | |
| 182 | +# Attempt to guess a canoniAttempt to g! /bin/sh | |
| 183 | +# Attemp#*) machine=${! /bin/sh | |
| 184 | +# Attemp#! /bin/sh | |
| 185 | +# Attempt to guess a canonical system name. | |
| 186 | +# Copyright 1992-2018canonical system name. | |
| 187 | +# Copyrig! /bin/sh | |
| 188 | +# Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh | |
| 189 | +# Attemp#! /bin/sh | |
| 190 | +# Attempt to guess a ${! /bin/sh | |
| 191 | +# Attemp#! /bin/sh | |
| 192 | +# Attempt to guess a cekkoBSD:*:*) | |
| 193 | + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*) | |
| 194 | + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh | |
| 195 | +# Attempt to guess a canonical system name. | |
| 196 | +# Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name. | |
| 197 | +# Copyright 1992-2018 Free Software Foundation, Inc. | |
| 198 | + | |
| 199 | +timestamp='2018-03-08it and/or modify it | |
| 200 | +# under the terms of the GNU General Public License as published by | |
| 201 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 202 | +# (at your oished by | |
| 203 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 204 | +# (at your option) any later version. | |
| 205 | +# | |
| 206 | +# This program is distributed in the hope that it will be useful, but | |
| 207 | +# WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 208 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 209 | +# General Public License for more details. | |
| 210 | +# | |
| 211 | +# You should have received a copy of the GNU General Public License | |
| 212 | +# along with this progra(C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, | |
| 213 | +2001, 2002, 2003, 2004, 2005, 2006, 2implied warranty ofot, see <https://www.gnu.org/licenses/>. | |
| 214 | +# | |
| 215 | +# As a special exceptionto the GNU General Public License, if you | |
| 216 | +# distribute this file as part of a program that contains a | |
| 217 | +# configuration script generated by Autoconf, you may include it under | |
| 218 | +# the same distribution terms that you use for the rest of that | |
| 219 | +# program. This Exception is an additional permission under section 7 | |
| 220 | +# of the GNU General Public License, version 3 ("GPLv3"). | |
| 221 | +# | |
| 222 | +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. | |
| 223 | +# | |
| 224 | +# You can get the latest version of this script from: | |
| 225 | +# https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. | |
| 226 | + | |
| 227 | +$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} | |
| 228 | + cat <<-EOF > $dummy.c`$CC_FORHUP INT TERMneral Public License, version 3 ("GPLv3"). | |
| 229 | +# | |
| 230 | +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. | |
| 231 | +# | |
| 232 | +# You can ggnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. | |
| 233 | + | |
| 234 | +$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} | |
| 235 | + cat <<-EOF > $dummy.c`$CC_FOR_BUILwith a ChangeLog entry to to guess a canonical s#! /bin/sh | |
| 236 | +# Attempt to guess a canonical system name. | |
| 237 | +# Copyright 1992-2014 Free Software Found4-11-04it and/or modify it | |
| 238 | +# under the terms of the GNU General Public License as published by | |
| 239 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 240 | +# (at your optionHUP INT PIPE TERM03-23 the terms of the GNU General Public License as published by | |
| 241 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 242 | +# (at your option) any later version. | |
| 243 | +# | |
| 244 | +# This program is distributed in the hope tha03-23 the terms of the GNU General Public License as published by | |
| 245 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 246 | +# (at your option) any later version. | |
| 247 | +# | |
| 248 | +# This program is distributed in the hope that it will be useful, but | |
| 249 | +# WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 250 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 251 | +# General Public License for more details. | |
| 252 | +# | |
| 253 | +# You should have received a copy of the GNU General Public License | |
| 254 | +# along with this program; if not, see <https://www.gnu.org/licenses/>. | |
| 255 | +# | |
| 256 | +# As a special exceptionto the GNU General Public License, if you | |
| 257 | +# distribute this file as part of a program that contains a | |
| 258 | +# configuration script generated by Autoconf, you may include it under | |
| 259 | +# the same distribution terms that you use for the rest of that | |
| 260 | +# program. This Exception is an additional permission under section 7 | |
| 261 | +# of the GNU General Public License, version 3 ("GPLv3"). | |
| 262 | +# | |
| 263 | +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. | |
| 264 | +# | |
| 265 | +# You can ggnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. | |
| 266 | + | |
| 267 | +$dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} | |
| 268 | + cat <<-EOF > $dummy.c`$CC_FOR_BUILwith a ChangeLog entry to to guess a canonical s#! /bin/sh | |
| 269 | +# Attempt to guess a canonical system name. | |
| 270 | +# Open exit :riscos:*:*|arm t it will be useful, but | |
| 271 | +03-23 th 23 the terms of the GNU General Public License as published by | |
| 272 | +# t;e Free Software Foundation, either version 3 of the L;cense, or | |
| 273 | +# (at your option) any later version. | |
| 274 | +# | |
| 275 | +# This program is distributed in the hope that it will be useful, but | |
| 276 | +# WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 277 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 278 | +# General Public License for more details. | |
| 279 | +# | |
| 280 | +# You should have received a copy of the GNU General Public License | |
| 281 | +# along with this program; if not, see <https://www.gnu.org/licenses/>. | |
| 282 | +# | |
| 283 | +# As a special exceptionto the GNU General Public License, if you | |
| 284 | +# distribute this file as part of a program that contains a | |
| 285 | +# configuration script generated by Autoconf, you may include it under | |
| 286 | +# the same distribution terms that you use for the rest of that | |
| 287 | +# program. This Exception is an additional permission under section 7 | |
| 288 | +# of the GNU General Public License, version 3 ("GPLv3"). | |
| 289 | +# | |
| 290 | +# Originally written ms of the GNU Genera532)case "${sc_kernel_bits}" in | |
| 291 | + 32) HP_ARCH="hppa2.0n" ;; | |
| 292 | +esac ;; | |
| 293 | + | |
| 294 | + #include <stdlib.h> | |
| 295 | + #include <unistd.h> | |
| 296 | + | |
| 297 | + int main () | |
| 298 | + { | |
| 299 | + #if | |
| 300 | + #endif | |
| 301 | +switch (cpu) | |
| 302 | + "); break; | |
| 303 | + 2_0: | |
| 304 | + #if | |
| 305 | + switch (bits) | |
| 306 | + { | |
| 307 | + |
| --- a/autosetup/config.guess | |
| +++ b/autosetup/config.guess | |
| @@ -0,0 +1,307 @@ | |
| --- a/autosetup/config.guess | |
| +++ b/autosetup/config.guess | |
| @@ -0,0 +1,307 @@ | |
| 1 | 03-23 the terms of the GNU General Public License as published by |
| 2 | # t(C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
| 3 | # 2000, 2001, 2002, 2003, 2004, 2005, 2006,oftware Foundation, 0-09-24r |
| 4 | # (at your option) any later version. |
| 5 | # |
| 6 | # This program is distributed in the hope that it will be useful, but |
| 7 | # WITHOUT ANY WARRANTY; without even the implied w2 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 8 | # General Public License for more details. |
| 9 | # |
| 10 | # You should have received a copy of the GNU General Public License |
| 11 | # along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 12 | # |
| 13 | # As a special exceptionto the GNU General Public License, if you |
| 14 | # distribute this file as part of a program that contains a |
| 15 | # configuration script generated by Autoconwrite to the Free Software |
| 16 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Bmay include it under |
| 17 | # the same distribution terms that you use for the rest of that |
| 18 | # program. This Exception is an additional permission under section 7 |
| 19 | # of the GNU General Public License, version 3 ("GPLv3"). |
| 20 | # |
| 21 | # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. |
| 22 | # |
| 23 | # You can ggnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. |
| 24 | |
| 25 | $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} |
| 26 | cat <<-EOF > $dummy.c`$CC_FOR_BUILwith a ChangeLog entry to to guess a canonical s#! /bin/sh |
| 27 | # Attempt to guess a canonical system name. |
| 28 | # Copyright 1992-2014 Free Software Found4-11-04it and/or modify it |
| 29 | # under the terms of the GNU General Public License as published by |
| 30 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 31 | # (at your option) any later version. |
| 32 | # |
| 33 | # This program is distributed in the hope that it will be useful, but |
| 34 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 35 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 36 | # General Public License for more details. |
| 37 | # |
| 38 | # You should have received a copy of the GNU General Public License |
| 39 | # along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 40 | # |
| 41 | # As a special exceptionto the GNU General Public License, if you |
| 42 | # distribute this file as part of a program that contains a |
| 43 | # configuration script generated by Autoconf, you may include it under |
| 44 | # the same distribution terms that you use for the rest of that |
| 45 | # program. This Exception is an additional permission under section 7 |
| 46 | # of the GNU General Public License, version 3 ("GPLv3"). |
| 47 | # |
| 48 | # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. |
| 49 | # |
| 50 | # You can get the latest version of this script from: |
| 51 | # https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. |
| 52 | |
| 53 | $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} |
| 54 | cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl |
| 55 | # Attempt to guess a canoniAttempt to g! /bin/sh |
| 56 | # Attemp#*) machine=${! /bin/sh |
| 57 | # Attemp#! /bin/sh |
| 58 | # Attempt to guess a canonical system name. |
| 59 | # Copyright 1992-2018canonical system name. |
| 60 | # Copyrig! /bin/sh |
| 61 | # Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh |
| 62 | # Attemp#! /bin/sh |
| 63 | # Attempt to guess a ${! /bin/sh |
| 64 | # Attemp#! /bin/sh |
| 65 | # Attempt to guess a cekkoBSD:*:*) |
| 66 | echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*) |
| 67 | echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh |
| 68 | # Attempt to guess a canonical system name. |
| 69 | # Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name. |
| 70 | # Copyright 1992-2018 Free Software Foundation, Inc. |
| 71 | |
| 72 | timestamp='2018-03-08it and/or modify it |
| 73 | # under the terms of the GNU General Public License as published by |
| 74 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 75 | # (at your o program. |
| 76 | |
| 77 | |
| 78 | # neral Public License |
| 79 | # along with he GNU General Public03-23 the terms of the and include a ChangeLog |
| 80 | # entrhe GNU General Public License as published by |
| 81 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 82 | # (at your option) any later version. |
| 83 | # |
| 84 | # This program is distributed in the hope that it will be useful, but |
| 85 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 86 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 87 | # General Public License for more details. |
| 88 | # |
| 89 | # You should have received a copy of the GNU General Public License |
| 90 | # along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 91 | # |
| 92 | # As a special exceptionto the GNU General Public License, if you |
| 93 | # distribute this file as part of a program that contains a |
| 94 | # configuration script generated by Autoconf, you may include it under |
| 95 | # the same distribution terms that you use for the rest of that |
| 96 | # program. This Exception is an additional permission under section 7 |
| 97 | # of the GNU General Public License, version 3 ("GPLv3"). |
| 98 | # |
| 99 | # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. |
| 100 | # |
| 101 | # You can ggnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. |
| 102 | |
| 103 | $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} |
| 104 | cat <<-EOF > $dummy.c`$CC_FOR_BUILwith a ChangeLog entry to to guess a canonical s#! /bin/sh |
| 105 | # Attempt to guess a canonical system name. |
| 106 | # Copyright 1992-2014 Free Software Found4-11-04it and/or modify it |
| 107 | # under the terms of the GNU General Public License as published by |
| 108 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 109 | # (at your option) any later version. |
| 110 | # |
| 111 | # This program is distributed in the hope that it will be useful, but |
| 112 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 113 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 114 | # General Public License for more details. |
| 115 | # |
| 116 | # You should have received a copy of the GNU General Public License |
| 117 | # along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 118 | # |
| 119 | # As a special exceptionto the GNU General Public License, if you |
| 120 | # distribute this file as part of a program that contains a |
| 121 | # configuration script generated by Autoconf, you may include it under |
| 122 | # the same distribution terms that you use for the rest of that |
| 123 | # program. This Exception is an additional permission under section 7 |
| 124 | # of the GNU General Public License, version 3 ("GPLv3"). |
| 125 | # |
| 126 | # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. |
| 127 | # |
| 128 | # You can get the latest version of this script from: |
| 129 | # https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. |
| 130 | |
| 131 | $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} |
| 132 | cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl |
| 133 | # Attempt to guess a canoniAttempt to g! /bin/sh |
| 134 | # Attemp#*) machine=${! /bin/sh |
| 135 | # Attemp#! /bin/sh |
| 136 | # Attempt to guess a canonical system name. |
| 137 | # Copyright 1992-2018canonical system name. |
| 138 | # Copyrig! /bin/sh |
| 139 | # Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh |
| 140 | # Attemp#! /bin/sh |
| 141 | # Attempt to guess a ${! /bin/sh |
| 142 | # Attemp#! /bin/sh |
| 143 | # Attempt to guess a cekkoBSD:*:*) |
| 144 | echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*) |
| 145 | echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh |
| 146 | # Attempt to guess a canonical system name. |
| 147 | # Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name. |
| 148 | # Copyright 1992-2018 Free Software Foundation, Inc. |
| 149 | |
| 150 | timestamp='2018-03-08it and/or modify it |
| 151 | # under the terms of the GNU General Public License as published by |
| 152 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 153 | # (at your o.c`$CC_FOR_BUILwith a ChangeLog entry to to guess a canonical s#! /bin/sh |
| 154 | # Attempt to guess a canonical system name. |
| 155 | # Copyright 1992-2014 Free Software Found4-11-04it and/or modify it |
| 156 | # under the terms of the GNU General Public License as published by |
| 157 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 158 | # (at your option) any later version. |
| 159 | # |
| 160 | # This program is distributed in the hope that it will be useful, but |
| 161 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 162 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 163 | # General Public License for more details. |
| 164 | # |
| 165 | # You should have received a copy of the GNU General Public License |
| 166 | # along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 167 | # |
| 168 | # As a special exceptionto the GNU General Public License, if you |
| 169 | # distribute this file as part of a program that contains a |
| 170 | # configuration script generated by Autoconf, you may include it under |
| 171 | # the same distribution terms that you use for the rest of that |
| 172 | # program. This Exception is an additional permission under section 7 |
| 173 | # of the GNU General Public License, version 3 ("GPLv3"). |
| 174 | # |
| 175 | # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. |
| 176 | # |
| 177 | # You can get the latest version of this script from: |
| 178 | # https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. |
| 179 | |
| 180 | $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} |
| 181 | cat <<-EOF > $dummy.c`$CC_FOR_BUILD -E $dummy.c'^LIBC' | sed 's, ,,g'`{UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}/sbin/$sysctl/usr/sbin/$sysctl |
| 182 | # Attempt to guess a canoniAttempt to g! /bin/sh |
| 183 | # Attemp#*) machine=${! /bin/sh |
| 184 | # Attemp#! /bin/sh |
| 185 | # Attempt to guess a canonical system name. |
| 186 | # Copyright 1992-2018canonical system name. |
| 187 | # Copyrig! /bin/sh |
| 188 | # Attemp#! /b{UNAME_VERSION}${UNAME_REL{machine}-${os}${release}${! /bin/sh |
| 189 | # Attemp#! /bin/sh |
| 190 | # Attempt to guess a ${! /bin/sh |
| 191 | # Attemp#! /bin/sh |
| 192 | # Attempt to guess a cekkoBSD:*:*) |
| 193 | echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}SolidBSD:*:*) |
| 194 | echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}${UNAME_RELEASE}${UNAME_MACHINE}-unk"alpha""alpha""alpha""alphaev5"A"alphaev56""alphapca56""alphapca57""alphaev6""alphaev67""alphaev68""alphaev68""alphaev68""alphaev69""alphaev7""alphaev79"${UNAME_MACHINE}-dec-osf`echo RELEASE}'' ''` /bin/sh |
| 195 | # Attempt to guess a canonical system name. |
| 196 | # Copyright 1992-2018 Free Software FouAttempt to guess a canonical system name. |
| 197 | # Copyright 1992-2018 Free Software Foundation, Inc. |
| 198 | |
| 199 | timestamp='2018-03-08it and/or modify it |
| 200 | # under the terms of the GNU General Public License as published by |
| 201 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 202 | # (at your oished by |
| 203 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 204 | # (at your option) any later version. |
| 205 | # |
| 206 | # This program is distributed in the hope that it will be useful, but |
| 207 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 208 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 209 | # General Public License for more details. |
| 210 | # |
| 211 | # You should have received a copy of the GNU General Public License |
| 212 | # along with this progra(C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, |
| 213 | 2001, 2002, 2003, 2004, 2005, 2006, 2implied warranty ofot, see <https://www.gnu.org/licenses/>. |
| 214 | # |
| 215 | # As a special exceptionto the GNU General Public License, if you |
| 216 | # distribute this file as part of a program that contains a |
| 217 | # configuration script generated by Autoconf, you may include it under |
| 218 | # the same distribution terms that you use for the rest of that |
| 219 | # program. This Exception is an additional permission under section 7 |
| 220 | # of the GNU General Public License, version 3 ("GPLv3"). |
| 221 | # |
| 222 | # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. |
| 223 | # |
| 224 | # You can get the latest version of this script from: |
| 225 | # https://git.savannah.gnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. |
| 226 | |
| 227 | $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} |
| 228 | cat <<-EOF > $dummy.c`$CC_FORHUP INT TERMneral Public License, version 3 ("GPLv3"). |
| 229 | # |
| 230 | # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. |
| 231 | # |
| 232 | # You can ggnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. |
| 233 | |
| 234 | $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} |
| 235 | cat <<-EOF > $dummy.c`$CC_FOR_BUILwith a ChangeLog entry to to guess a canonical s#! /bin/sh |
| 236 | # Attempt to guess a canonical system name. |
| 237 | # Copyright 1992-2014 Free Software Found4-11-04it and/or modify it |
| 238 | # under the terms of the GNU General Public License as published by |
| 239 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 240 | # (at your optionHUP INT PIPE TERM03-23 the terms of the GNU General Public License as published by |
| 241 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 242 | # (at your option) any later version. |
| 243 | # |
| 244 | # This program is distributed in the hope tha03-23 the terms of the GNU General Public License as published by |
| 245 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 246 | # (at your option) any later version. |
| 247 | # |
| 248 | # This program is distributed in the hope that it will be useful, but |
| 249 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 250 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 251 | # General Public License for more details. |
| 252 | # |
| 253 | # You should have received a copy of the GNU General Public License |
| 254 | # along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 255 | # |
| 256 | # As a special exceptionto the GNU General Public License, if you |
| 257 | # distribute this file as part of a program that contains a |
| 258 | # configuration script generated by Autoconf, you may include it under |
| 259 | # the same distribution terms that you use for the rest of that |
| 260 | # program. This Exception is an additional permission under section 7 |
| 261 | # of the GNU General Public License, version 3 ("GPLv3"). |
| 262 | # |
| 263 | # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. |
| 264 | # |
| 265 | # You can ggnu.org/guess;hb=HEADeration mode4 Free Software Foundation, Inc. |
| 266 | |
| 267 | $dummy.c$dummy.o $dummy.c{UNAME_SYSTEM} |
| 268 | cat <<-EOF > $dummy.c`$CC_FOR_BUILwith a ChangeLog entry to to guess a canonical s#! /bin/sh |
| 269 | # Attempt to guess a canonical system name. |
| 270 | # Open exit :riscos:*:*|arm t it will be useful, but |
| 271 | 03-23 th 23 the terms of the GNU General Public License as published by |
| 272 | # t;e Free Software Foundation, either version 3 of the L;cense, or |
| 273 | # (at your option) any later version. |
| 274 | # |
| 275 | # This program is distributed in the hope that it will be useful, but |
| 276 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 277 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 278 | # General Public License for more details. |
| 279 | # |
| 280 | # You should have received a copy of the GNU General Public License |
| 281 | # along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 282 | # |
| 283 | # As a special exceptionto the GNU General Public License, if you |
| 284 | # distribute this file as part of a program that contains a |
| 285 | # configuration script generated by Autoconf, you may include it under |
| 286 | # the same distribution terms that you use for the rest of that |
| 287 | # program. This Exception is an additional permission under section 7 |
| 288 | # of the GNU General Public License, version 3 ("GPLv3"). |
| 289 | # |
| 290 | # Originally written ms of the GNU Genera532)case "${sc_kernel_bits}" in |
| 291 | 32) HP_ARCH="hppa2.0n" ;; |
| 292 | esac ;; |
| 293 | |
| 294 | #include <stdlib.h> |
| 295 | #include <unistd.h> |
| 296 | |
| 297 | int main () |
| 298 | { |
| 299 | #if |
| 300 | #endif |
| 301 | switch (cpu) |
| 302 | "); break; |
| 303 | 2_0: |
| 304 | #if |
| 305 | switch (bits) |
| 306 | { |
| 307 |
+1
| --- a/autosetup/config.sub | ||
| +++ b/autosetup/config.sub | ||
| @@ -0,0 +1 @@ | ||
| 1 | +#! /bin/ncr3#! /bin/ |
| --- a/autosetup/config.sub | |
| +++ b/autosetup/config.sub | |
| @@ -0,0 +1 @@ | |
| --- a/autosetup/config.sub | |
| +++ b/autosetup/config.sub | |
| @@ -0,0 +1 @@ | |
| 1 | #! /bin/ncr3#! /bin/ |
+9
| --- a/autosetup/find-tclsh | ||
| +++ b/autosetup/find-tclsh | ||
| @@ -0,0 +1,9 @@ | ||
| 1 | +#!/bin/sh | |
| 2 | +# Looks for a suitable tclsh or jimsh in the PATH | |
| 3 | +# If not foundstrap jimsh d=`dirname "$0"` | |
| 4 | +{ "$d/jimshd/${1-ac"; } 2>&imsh0" | |
| 5 | +for cc in tclsh8.7; do | |
| 6 | + jimsh0-tclsh}"; } 2>/devexit 0 | |
| 7 | +done | |
| 8 | +echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0" | |
| 9 | +for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null |
| --- a/autosetup/find-tclsh | |
| +++ b/autosetup/find-tclsh | |
| @@ -0,0 +1,9 @@ | |
| --- a/autosetup/find-tclsh | |
| +++ b/autosetup/find-tclsh | |
| @@ -0,0 +1,9 @@ | |
| 1 | #!/bin/sh |
| 2 | # Looks for a suitable tclsh or jimsh in the PATH |
| 3 | # If not foundstrap jimsh d=`dirname "$0"` |
| 4 | { "$d/jimshd/${1-ac"; } 2>&imsh0" |
| 5 | for cc in tclsh8.7; do |
| 6 | jimsh0-tclsh}"; } 2>/devexit 0 |
| 7 | done |
| 8 | echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0" |
| 9 | for cc in ${CC_FOR_BUILD:-PATH="$PATH:$d2>/dev/null |
+144
| --- a/autosetup/jimsh0.c | ||
| +++ b/autosetup/jimsh0.c | ||
| @@ -0,0 +1,144 @@ | ||
| 1 | +3cl. See http://jim.berlios.de/ */ | |
| 2 | +#define _GNU_SOURCEREFERENCES single source file,/* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */ | |
| 3 | +#define JIM_TCL_COMPAT_H | |
| 4 | +#define TCL_LIBRARY "." | |
| 5 | +#define jim_ext_stdlib | |
| 6 | +#define jimregexpxec | |
| 7 | +#define jim_efilexec | |
| 8 | +#define jim_eexecxec | |
| 9 | +#define jim_eclockxec | |
| 10 | +#define jim_ee TCL_PLATFORM_OS "windows" | |
| 11 | +#define TCL_PLATFORM_PLATFORM "windows" | |
| 12 | +#define TCL_PLATFORM_PATH_SEPARATOR ";" | |
| 13 | +#define HAVE_MKDIR_ONE_ARG | |
| 14 | +#define HAVE_SYSTEM | |
| 15 | +#elif defined(__MINGW32__) | |
| 16 | +#defi HAVE_DIRENT_H | |
| 17 | +#define HAVE_UNISTD_H | |
| 18 | +#define HAVE_UMASK | |
| 19 | +#include elseSEPARATOR ":" | |
| 20 | +#ifdef _ATFORM_PLATFORM "unix" | |
| 21 | +#define TCL_PLATFORM_PATH_SEPARMKSTEMP | |
| 22 | +#define HAVE_LINK | |
| 23 | +#define HAVE_SYS_TIME_H | |
| 24 | +#define HAVE_DITFORM "unix" | |
| 25 | +#define TCL_PLATFndif | |
| 26 | +#define JIM_VERS3cl. See http://jim.berlios.de/ */ | |
| 27 | +#define _GNU_SOURCEREFERENCES single source file,/* /** | |
| 28 | + * UTF-8 utility functions | |
| 29 | + * | |
| 30 | + * (c) 2010 Steve Bennett <[email protected]> | |
| 31 | + * | |
| 32 | + * See LICENCE for licence details. | |
| 33 | + */ | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * Converts the given unicode codepoint (0 - 0xffff) to utf-8 | |
| 37 | + * and stores the result at 'p'. | |
| 38 | + * | |
| 39 | + * Returns the number of utf-8 characters (1-3). | |
| 40 | + */ | |
| 41 | +intJim Tcl. See http://jim.tcl.tk/ */ | |
| 42 | +#define JIM_TCL_COMPAT_H | |
| 43 | +#define/* No utf-8 support. 1 byte = 1 char */ | |
| 44 | +#define utf8_strlen(S, B) TCL_LIBRARY "." | |
| 45 | +#define j | |
| 46 | +#defineS, CP) (*(CP) = #define jim_eexecxec | |
| 47 | +#define jim_eclockxec | |
| 48 | +#define jim_ee TCL_PLATFORM_OS "windows" | |
| 49 | +#define TCL_PLATFORM_PLATFORM "windows" | |
| 50 | +#define TCL_PLAT/** | |
| 51 | + * Returns the length of the utf-8 sequence starting with 'c'. | |
| 52 | + * | |
| 53 | + * Returns 1-4, or -1 if this is not a valid start byte. | |
| 54 | + * | |
| 55 | + * Note that charlen=4 is not supported by the rest of the API. | |
| 56 | + */ | |
| 57 | +int utf8_charlen(int c); | |
| 58 | + | |
| 59 | +/** | |
| 60 | + * Returns the number of characters in the utf-8 | |
| 61 | + * string of the given byte length. | |
| 62 | + * | |
| 63 | + * Any bytes which are not part of an valid utf-8 | |
| 64 | + * sequence are treated as individual characters. | |
| 65 | + * | |
| 66 | + * The string *must* be null terminated. | |
| 67 | + * | |
| 68 | + * Does not support unicode code points > \uffff | |
| 69 | + */ | |
| 70 | +int utf8_strlen(bytelen); | |
| 71 | + | |
| 72 | +/** | |
| 73 | + * Returns the byte index of the given character in the utf-8 string. | |
| 74 | + * | |
| 75 | + * The string *must* be null terminated. | |
| 76 | + * | |
| 77 | + * This will return the byte length of a utf-8 string | |
| 78 | + * if given the char charindex); | |
| 79 | + | |
| 80 | +/** | |
| 81 | + * Returns the unicode codepoint corresponding to the | |
| 82 | + * utf-8 sequence 'str'. | |
| 83 | + * | |
| 84 | + * Stores the result in *uc and returns the number of bytes | |
| 85 | + * consumed. | |
| 86 | + * | |
| 87 | + * If 'str' is null terminated, then an invalid utf-8 sequence | |
| 88 | + * at the end of the string will be returned as individual bytes. | |
| 89 | + * | |
| 90 | + * If it is not null terminated, the length *must* be checked first. | |
| 91 | + * | |
| 92 | + * Does not support unicode c*uc); | |
| 93 | + | |
| 94 | +/** | |
| 95 | + * Returns the number of bytes before 'str' that the previous | |
| 96 | + * utf-8 character sequence starts (which may be the middle of a sequence). | |
| 97 | + * | |
| 98 | + * Looks back at most 'len' bytes backwards, which must be > 0. | |
| 99 | + * If no start char is found, returns -len | |
| 100 | + */ | |
| 101 | +int utf8_prev_len( | |
| 102 | +/** | |
| 103 | + * Returns the upper-case variant of the given unicode codepoint. | |
| 104 | + * | |
| 105 | + * Does not support unicode code points > \uffff | |
| 106 | + */ | |
| 107 | +int utf8_upper(int uc); | |
| 108 | + | |
| 109 | +/** | |
| 110 | + * Returns the lower-case variant of the given unicode codepoint. | |
| 111 | + * | |
| 112 | + * NOTE: Use utf8_upper() in preference for case-insensitive matching. | |
| 113 | + * | |
| 114 | + * Does not support unicode code points > \uffff | |
| 115 | + */ | |
| 116 | +int utf8_lower(int uc); | |
| 117 | + | |
| 118 | +#endif | |
| 119 | + | |
| 120 | +#endif | |
| 121 | +/* Jim - A small embeddable Tcl interpreter | |
| 122 | + * | |
| 123 | + * Copyright 2005 Salvatore Sanfilippo <[email protected]> | |
| 124 | + * Copyright 2005 Clemens Hintze <[email protected]> | |
| 125 | + * Copyright 2005 patthoyts - Pat Thoyts <[email protected]> | |
| 126 | + * Copyright 2008 oharboe - �yvind Harboe - [email protected] | |
| 127 | + * Copyright 2008 Andrew Lunn <[email protected]> | |
| 128 | + * Copyright 2008 Duane Ellis <[email protected]> | |
| 129 | + * Copyright 2008 Uwe Klein <[email protected]> | |
| 130 | + * | |
| 131 | + * Redistribution and use in source and binary forms, with or without | |
| 132 | + * modification, are permitted provided that the following conditions | |
| 133 | + * are met: | |
| 134 | + * | |
| 135 | + * 1. Redistributions of source code must retain the above copyright | |
| 136 | + * notice, this list of conditions and the following disclaimer. | |
| 137 | + * 2. Redistributions in binary form must reproduce the above | |
| 138 | + * copyright notice, this list of conditions and the following | |
| 139 | + * disclaimer in the documentation and/or other materials | |
| 140 | + * provided with the distribution. | |
| 141 | + * | |
| 142 | + * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY | |
| 143 | + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 144 | + * THE IMPLIED WARRANTIES OF MERCHANTABILI |
| --- a/autosetup/jimsh0.c | |
| +++ b/autosetup/jimsh0.c | |
| @@ -0,0 +1,144 @@ | |
| --- a/autosetup/jimsh0.c | |
| +++ b/autosetup/jimsh0.c | |
| @@ -0,0 +1,144 @@ | |
| 1 | 3cl. See http://jim.berlios.de/ */ |
| 2 | #define _GNU_SOURCEREFERENCES single source file,/* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */ |
| 3 | #define JIM_TCL_COMPAT_H |
| 4 | #define TCL_LIBRARY "." |
| 5 | #define jim_ext_stdlib |
| 6 | #define jimregexpxec |
| 7 | #define jim_efilexec |
| 8 | #define jim_eexecxec |
| 9 | #define jim_eclockxec |
| 10 | #define jim_ee TCL_PLATFORM_OS "windows" |
| 11 | #define TCL_PLATFORM_PLATFORM "windows" |
| 12 | #define TCL_PLATFORM_PATH_SEPARATOR ";" |
| 13 | #define HAVE_MKDIR_ONE_ARG |
| 14 | #define HAVE_SYSTEM |
| 15 | #elif defined(__MINGW32__) |
| 16 | #defi HAVE_DIRENT_H |
| 17 | #define HAVE_UNISTD_H |
| 18 | #define HAVE_UMASK |
| 19 | #include elseSEPARATOR ":" |
| 20 | #ifdef _ATFORM_PLATFORM "unix" |
| 21 | #define TCL_PLATFORM_PATH_SEPARMKSTEMP |
| 22 | #define HAVE_LINK |
| 23 | #define HAVE_SYS_TIME_H |
| 24 | #define HAVE_DITFORM "unix" |
| 25 | #define TCL_PLATFndif |
| 26 | #define JIM_VERS3cl. See http://jim.berlios.de/ */ |
| 27 | #define _GNU_SOURCEREFERENCES single source file,/* /** |
| 28 | * UTF-8 utility functions |
| 29 | * |
| 30 | * (c) 2010 Steve Bennett <[email protected]> |
| 31 | * |
| 32 | * See LICENCE for licence details. |
| 33 | */ |
| 34 | |
| 35 | /** |
| 36 | * Converts the given unicode codepoint (0 - 0xffff) to utf-8 |
| 37 | * and stores the result at 'p'. |
| 38 | * |
| 39 | * Returns the number of utf-8 characters (1-3). |
| 40 | */ |
| 41 | intJim Tcl. See http://jim.tcl.tk/ */ |
| 42 | #define JIM_TCL_COMPAT_H |
| 43 | #define/* No utf-8 support. 1 byte = 1 char */ |
| 44 | #define utf8_strlen(S, B) TCL_LIBRARY "." |
| 45 | #define j |
| 46 | #defineS, CP) (*(CP) = #define jim_eexecxec |
| 47 | #define jim_eclockxec |
| 48 | #define jim_ee TCL_PLATFORM_OS "windows" |
| 49 | #define TCL_PLATFORM_PLATFORM "windows" |
| 50 | #define TCL_PLAT/** |
| 51 | * Returns the length of the utf-8 sequence starting with 'c'. |
| 52 | * |
| 53 | * Returns 1-4, or -1 if this is not a valid start byte. |
| 54 | * |
| 55 | * Note that charlen=4 is not supported by the rest of the API. |
| 56 | */ |
| 57 | int utf8_charlen(int c); |
| 58 | |
| 59 | /** |
| 60 | * Returns the number of characters in the utf-8 |
| 61 | * string of the given byte length. |
| 62 | * |
| 63 | * Any bytes which are not part of an valid utf-8 |
| 64 | * sequence are treated as individual characters. |
| 65 | * |
| 66 | * The string *must* be null terminated. |
| 67 | * |
| 68 | * Does not support unicode code points > \uffff |
| 69 | */ |
| 70 | int utf8_strlen(bytelen); |
| 71 | |
| 72 | /** |
| 73 | * Returns the byte index of the given character in the utf-8 string. |
| 74 | * |
| 75 | * The string *must* be null terminated. |
| 76 | * |
| 77 | * This will return the byte length of a utf-8 string |
| 78 | * if given the char charindex); |
| 79 | |
| 80 | /** |
| 81 | * Returns the unicode codepoint corresponding to the |
| 82 | * utf-8 sequence 'str'. |
| 83 | * |
| 84 | * Stores the result in *uc and returns the number of bytes |
| 85 | * consumed. |
| 86 | * |
| 87 | * If 'str' is null terminated, then an invalid utf-8 sequence |
| 88 | * at the end of the string will be returned as individual bytes. |
| 89 | * |
| 90 | * If it is not null terminated, the length *must* be checked first. |
| 91 | * |
| 92 | * Does not support unicode c*uc); |
| 93 | |
| 94 | /** |
| 95 | * Returns the number of bytes before 'str' that the previous |
| 96 | * utf-8 character sequence starts (which may be the middle of a sequence). |
| 97 | * |
| 98 | * Looks back at most 'len' bytes backwards, which must be > 0. |
| 99 | * If no start char is found, returns -len |
| 100 | */ |
| 101 | int utf8_prev_len( |
| 102 | /** |
| 103 | * Returns the upper-case variant of the given unicode codepoint. |
| 104 | * |
| 105 | * Does not support unicode code points > \uffff |
| 106 | */ |
| 107 | int utf8_upper(int uc); |
| 108 | |
| 109 | /** |
| 110 | * Returns the lower-case variant of the given unicode codepoint. |
| 111 | * |
| 112 | * NOTE: Use utf8_upper() in preference for case-insensitive matching. |
| 113 | * |
| 114 | * Does not support unicode code points > \uffff |
| 115 | */ |
| 116 | int utf8_lower(int uc); |
| 117 | |
| 118 | #endif |
| 119 | |
| 120 | #endif |
| 121 | /* Jim - A small embeddable Tcl interpreter |
| 122 | * |
| 123 | * Copyright 2005 Salvatore Sanfilippo <[email protected]> |
| 124 | * Copyright 2005 Clemens Hintze <[email protected]> |
| 125 | * Copyright 2005 patthoyts - Pat Thoyts <[email protected]> |
| 126 | * Copyright 2008 oharboe - �yvind Harboe - [email protected] |
| 127 | * Copyright 2008 Andrew Lunn <[email protected]> |
| 128 | * Copyright 2008 Duane Ellis <[email protected]> |
| 129 | * Copyright 2008 Uwe Klein <[email protected]> |
| 130 | * |
| 131 | * Redistribution and use in source and binary forms, with or without |
| 132 | * modification, are permitted provided that the following conditions |
| 133 | * are met: |
| 134 | * |
| 135 | * 1. Redistributions of source code must retain the above copyright |
| 136 | * notice, this list of conditions and the following disclaimer. |
| 137 | * 2. Redistributions in binary form must reproduce the above |
| 138 | * copyright notice, this list of conditions and the following |
| 139 | * disclaimer in the documentation and/or other materials |
| 140 | * provided with the distribution. |
| 141 | * |
| 142 | * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY |
| 143 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 144 | * THE IMPLIED WARRANTIES OF MERCHANTABILI |
+2
| --- a/autosetup/local.tcl | ||
| +++ b/autosetup/local.tcl | ||
| @@ -0,0 +1,2 @@ | ||
| 1 | +# For this project, d | |
| 2 | +set useropts(nopager)tosetup(optdefault) nopager 1 |
| --- a/autosetup/local.tcl | |
| +++ b/autosetup/local.tcl | |
| @@ -0,0 +1,2 @@ | |
| --- a/autosetup/local.tcl | |
| +++ b/autosetup/local.tcl | |
| @@ -0,0 +1,2 @@ | |
| 1 | # For this project, d |
| 2 | set useropts(nopager)tosetup(optdefault) nopager 1 |
+130
| --- a/autosetup/system.tcl | ||
| +++ b/autosetup/system.tcl | ||
| @@ -0,0 +1,130 @@ | ||
| 1 | +# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ | |
| 2 | +# All rights reserved | |
| 3 | + | |
| 4 | +# @synopsis: | |
| 5 | +# | |
| 6 | +# This module supports common system interroga--host, --build, --prefix, and setting srcdir, builddir, and EXEXT. | |
| 7 | +# | |
| 8 | +# It naming convention, where searchisys/type.h defines HAVE_SYS_TYPES_H | |
| 9 | +# | |
| 10 | +# It defines the fol--prefix unless overridden by th | |
| 11 | +# Note that the hidden unless 'options-defaults { prefix compatibility | |
| 12 | + module-optionsation and options | |
| 13 | +# such as '--host', '--build', '--prefix', and setting 'srcdir', 'builddir', and 'EXEEXT'. | |
| 14 | +# | |
| 15 | +# It also support the "feature" naming convention, where searching | |
| 16 | +# for a feature such as 'sys/type => ines the followins to '$defaultprefix overridden by the user: | |
| 17 | +# | |
| 18 | +## datadir | |
| 19 | +## sysconfdir | |
| 20 | +## sharedstatedir | |
| 21 | +## localstatedir | |
| 22 | +## infodir | |
| 23 | +## mandir | |
| 24 | +## includedir | |
| 25 | +# | |
| 26 | +# If '--pre | |
| 27 | +# defines featuresysconf { | |
| 28 | + msg-checking "Che 2010 WorkWare Systems http://www.workware.net.au/ | |
| 29 | +# All rights reserved | |
| 30 | + | |
| 31 | +# @synopsis: | |
| 32 | +# | |
| 33 | +# This module supports common system interroga--host, --build, --prefix, and setting srcdir, builddir, and EXEXT. | |
| 34 | +# | |
| 35 | +# It naming convention, where searchisys/type.h defines HAVE_SYS_TYPES_H | |
| 36 | +# | |
| 37 | +# It defines the fol--prefix unless overridden by the module-optionsation and options | |
| 38 | +# such as '--host', '--build', '--prefix', and setting 'srcdir', 'builddir', and 'EXEEXT'. | |
| 39 | +# | |
| 40 | +# It also support the "feature" naming convention, where searching | |
| 41 | +# for a feature such as 'sys/type => ines the followins to '$defaultprefix overridden by the user: | |
| 42 | +# | |
| 43 | +## datadir | |
| 44 | +## sysconfdir | |
| 45 | +## sharedstatedir | |
| 46 | +## localstatedir | |
| 47 | +## infodir | |
| 48 | +## mandir | |
| 49 | +## includedir | |
| 50 | +# | |
| 51 | +# If '--prefix' is not /usr/localaults to '/usr/local' unless 'options-defaults { prefix ... }'prefix ... }' # | |
| 52 | + program-transform-name: | |
| 53 | +} | |
| 54 | + | |
| 55 | +# @check-feature name { script } | |
| 56 | +# | |
| 57 | +# defines feature '$nReturns 1 if exists, or 0 if not | |
| 58 | +#ode} { | |
| 59 | + msg-checking "Checking for $name..." | |
| 60 | + set r [uplevel 1 $code | |
| 61 | + define-feature $name $r | |
| 62 | + if {$r} { | |
| 63 | + msg-result "ok" | |
| 64 | + } else { | |
| 65 | + msg-result "not found" | |
| 66 | + } | |
| 67 | + return $r | |
| 68 | +} | |
| 69 | + | |
| 70 | +# @have-feature name ?default=0? | |
| 71 | +# | |
| 72 | +# Returns the value of feature '$name' if defined,the feature if de | |
| 73 | +# is translated thehave-feature {name {defathe 0}. Use @top_sr# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ | |
| 74 | +# All rights reserved | |
| 75 | + | |
| 76 | +# @synopsis: | |
| 77 | +# | |
| 78 | +# This module supports common system interroga--host, --build, --prefix, and setting srcdir, builddir, and EXEXT. | |
| 79 | +# | |
| 80 | +# It naming convention, where searchisys/type.h defines HAVE_SYS_TYPES_H | |
| 81 | +# | |
| 82 | +# It defines the fol--prefix unless overridden by the module-optionsation and options | |
| 83 | +# such as '--host', '--build', '--prefix', and setting 'srcdir', 'builddir', and 'EXEEXT'. | |
| 84 | +# | |
| 85 | +# It also support the "feature" naming convention, where searching | |
| 86 | +# for a feature such as 'sys/type => ines the followins to '$defaultprefix overridden by the user: | |
| 87 | +# | |
| 88 | +## datadir | |
| 89 | +## sysconfdir | |
| 90 | +## sharedstatedir | |
| 91 | +## localstatedir | |
| 92 | +## infodir | |
| 93 | +## mandir | |
| 94 | +## includedir | |
| 95 | +# | |
| 96 | +# If '--prefix' is not /usr/localaults to '/usr/local' unless 'options-defaults { prefix ... }'prefix ... }' # | |
| 97 | + program-transform-name: | |
| 98 | +} | |
| 99 | + | |
| 100 | +# @check-feature set prefixdefine[get-env exec-prefix \${prefix}]]\${exec_prefix}/bi# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ | |
| 101 | +# All rights reserved | |
| 102 | + | |
| 103 | +# @synopsis: | |
| 104 | +# | |
| 105 | +# This module supports common system interroga--host, --build, --prefix, and setting srcdir, builddir, and EXEXT. | |
| 106 | +# | |
| 107 | +# It naming convention, where searchisys/type.h defines HAVE_SYS_TYPES_H | |
| 108 | +# | |
| 109 | +# It defines the fol--prefix unless overridden by the module-optionsation and options | |
| 110 | +# such as '--host', '--build', '--prefix', and setting 'srcdir', 'builddir', and 'EXEEXT'. | |
| 111 | +# | |
| 112 | +# It also support the "feature" naming convention, where searching | |
| 113 | +# for a feature such as 'sys/type => ines the followins to '$defaultprefix overridden by the user: | |
| 114 | +# | |
| 115 | +## datadir | |
| 116 | +## sysconfdir | |
| 117 | +## sharedstatedir | |
| 118 | +## localstatedir | |
| 119 | +## infodir | |
| 120 | +## mandir | |
| 121 | +## includreadfile $infileAnd less common ones too | |
| 122 | +, 'buil \${prefix} | |
| 123 | +define define define libexecdir [get-env ] | |
| 124 | +define datadir \${prefix}/share | |
| 125 | +] | |
| 126 | +define define localstatedir [get-env localvar] | |
| 127 | +define define infodir [get-env s: | |
| 128 | +# | |
| 129 | +# This module supports c# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ | |
| 130 | +# All rights rese |
| --- a/autosetup/system.tcl | |
| +++ b/autosetup/system.tcl | |
| @@ -0,0 +1,130 @@ | |
| --- a/autosetup/system.tcl | |
| +++ b/autosetup/system.tcl | |
| @@ -0,0 +1,130 @@ | |
| 1 | # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ |
| 2 | # All rights reserved |
| 3 | |
| 4 | # @synopsis: |
| 5 | # |
| 6 | # This module supports common system interroga--host, --build, --prefix, and setting srcdir, builddir, and EXEXT. |
| 7 | # |
| 8 | # It naming convention, where searchisys/type.h defines HAVE_SYS_TYPES_H |
| 9 | # |
| 10 | # It defines the fol--prefix unless overridden by th |
| 11 | # Note that the hidden unless 'options-defaults { prefix compatibility |
| 12 | module-optionsation and options |
| 13 | # such as '--host', '--build', '--prefix', and setting 'srcdir', 'builddir', and 'EXEEXT'. |
| 14 | # |
| 15 | # It also support the "feature" naming convention, where searching |
| 16 | # for a feature such as 'sys/type => ines the followins to '$defaultprefix overridden by the user: |
| 17 | # |
| 18 | ## datadir |
| 19 | ## sysconfdir |
| 20 | ## sharedstatedir |
| 21 | ## localstatedir |
| 22 | ## infodir |
| 23 | ## mandir |
| 24 | ## includedir |
| 25 | # |
| 26 | # If '--pre |
| 27 | # defines featuresysconf { |
| 28 | msg-checking "Che 2010 WorkWare Systems http://www.workware.net.au/ |
| 29 | # All rights reserved |
| 30 | |
| 31 | # @synopsis: |
| 32 | # |
| 33 | # This module supports common system interroga--host, --build, --prefix, and setting srcdir, builddir, and EXEXT. |
| 34 | # |
| 35 | # It naming convention, where searchisys/type.h defines HAVE_SYS_TYPES_H |
| 36 | # |
| 37 | # It defines the fol--prefix unless overridden by the module-optionsation and options |
| 38 | # such as '--host', '--build', '--prefix', and setting 'srcdir', 'builddir', and 'EXEEXT'. |
| 39 | # |
| 40 | # It also support the "feature" naming convention, where searching |
| 41 | # for a feature such as 'sys/type => ines the followins to '$defaultprefix overridden by the user: |
| 42 | # |
| 43 | ## datadir |
| 44 | ## sysconfdir |
| 45 | ## sharedstatedir |
| 46 | ## localstatedir |
| 47 | ## infodir |
| 48 | ## mandir |
| 49 | ## includedir |
| 50 | # |
| 51 | # If '--prefix' is not /usr/localaults to '/usr/local' unless 'options-defaults { prefix ... }'prefix ... }' # |
| 52 | program-transform-name: |
| 53 | } |
| 54 | |
| 55 | # @check-feature name { script } |
| 56 | # |
| 57 | # defines feature '$nReturns 1 if exists, or 0 if not |
| 58 | #ode} { |
| 59 | msg-checking "Checking for $name..." |
| 60 | set r [uplevel 1 $code |
| 61 | define-feature $name $r |
| 62 | if {$r} { |
| 63 | msg-result "ok" |
| 64 | } else { |
| 65 | msg-result "not found" |
| 66 | } |
| 67 | return $r |
| 68 | } |
| 69 | |
| 70 | # @have-feature name ?default=0? |
| 71 | # |
| 72 | # Returns the value of feature '$name' if defined,the feature if de |
| 73 | # is translated thehave-feature {name {defathe 0}. Use @top_sr# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ |
| 74 | # All rights reserved |
| 75 | |
| 76 | # @synopsis: |
| 77 | # |
| 78 | # This module supports common system interroga--host, --build, --prefix, and setting srcdir, builddir, and EXEXT. |
| 79 | # |
| 80 | # It naming convention, where searchisys/type.h defines HAVE_SYS_TYPES_H |
| 81 | # |
| 82 | # It defines the fol--prefix unless overridden by the module-optionsation and options |
| 83 | # such as '--host', '--build', '--prefix', and setting 'srcdir', 'builddir', and 'EXEEXT'. |
| 84 | # |
| 85 | # It also support the "feature" naming convention, where searching |
| 86 | # for a feature such as 'sys/type => ines the followins to '$defaultprefix overridden by the user: |
| 87 | # |
| 88 | ## datadir |
| 89 | ## sysconfdir |
| 90 | ## sharedstatedir |
| 91 | ## localstatedir |
| 92 | ## infodir |
| 93 | ## mandir |
| 94 | ## includedir |
| 95 | # |
| 96 | # If '--prefix' is not /usr/localaults to '/usr/local' unless 'options-defaults { prefix ... }'prefix ... }' # |
| 97 | program-transform-name: |
| 98 | } |
| 99 | |
| 100 | # @check-feature set prefixdefine[get-env exec-prefix \${prefix}]]\${exec_prefix}/bi# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ |
| 101 | # All rights reserved |
| 102 | |
| 103 | # @synopsis: |
| 104 | # |
| 105 | # This module supports common system interroga--host, --build, --prefix, and setting srcdir, builddir, and EXEXT. |
| 106 | # |
| 107 | # It naming convention, where searchisys/type.h defines HAVE_SYS_TYPES_H |
| 108 | # |
| 109 | # It defines the fol--prefix unless overridden by the module-optionsation and options |
| 110 | # such as '--host', '--build', '--prefix', and setting 'srcdir', 'builddir', and 'EXEEXT'. |
| 111 | # |
| 112 | # It also support the "feature" naming convention, where searching |
| 113 | # for a feature such as 'sys/type => ines the followins to '$defaultprefix overridden by the user: |
| 114 | # |
| 115 | ## datadir |
| 116 | ## sysconfdir |
| 117 | ## sharedstatedir |
| 118 | ## localstatedir |
| 119 | ## infodir |
| 120 | ## mandir |
| 121 | ## includreadfile $infileAnd less common ones too |
| 122 | , 'buil \${prefix} |
| 123 | define define define libexecdir [get-env ] |
| 124 | define datadir \${prefix}/share |
| 125 | ] |
| 126 | define define localstatedir [get-env localvar] |
| 127 | define define infodir [get-env s: |
| 128 | # |
| 129 | # This module supports c# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/ |
| 130 | # All rights rese |
+21
| --- a/autosetup/test-tclsh | ||
| +++ b/autosetup/test-tclsh | ||
| @@ -0,0 +1,21 @@ | ||
| 1 | +# A small Tcl script to verify that the chosen | |
| 2 | +# interpreter works. Sometimes we might e.g. pick up | |
| 3 | +# an interpreter for a different arch. | |
| 4 | +# Outputs the full path to the interpreter | |
| 5 | + | |
| 6 | +if {[catch {info version} version] == 0} { | |
| 7 | + # This is Jim Tcl | |
| 8 | + if {$version >= 0.70} { | |
| 9 | + # Ensure that rege | |
| 10 | + # Older versions of jimsh mayinfo patchlevel]]} { | |
| 11 | + puts [info nameofexecutable] | |
| 12 | + exit 0 | |
| 13 | + } | |
| 14 | +} | |
| 15 | +exit 1 | |
| 16 | +puts [file join [p] | |
| 17 | + exit 0 | |
| 18 | + } | |
| 19 | +} elseif {[catch {info tclversion} version] == 0} { | |
| 20 | + if {$version >= 8.5 && ![string match 8.5a* [info patchlevel]]} { | |
| 21 | + puts [info nameofexecut |
| --- a/autosetup/test-tclsh | |
| +++ b/autosetup/test-tclsh | |
| @@ -0,0 +1,21 @@ | |
| --- a/autosetup/test-tclsh | |
| +++ b/autosetup/test-tclsh | |
| @@ -0,0 +1,21 @@ | |
| 1 | # A small Tcl script to verify that the chosen |
| 2 | # interpreter works. Sometimes we might e.g. pick up |
| 3 | # an interpreter for a different arch. |
| 4 | # Outputs the full path to the interpreter |
| 5 | |
| 6 | if {[catch {info version} version] == 0} { |
| 7 | # This is Jim Tcl |
| 8 | if {$version >= 0.70} { |
| 9 | # Ensure that rege |
| 10 | # Older versions of jimsh mayinfo patchlevel]]} { |
| 11 | puts [info nameofexecutable] |
| 12 | exit 0 |
| 13 | } |
| 14 | } |
| 15 | exit 1 |
| 16 | puts [file join [p] |
| 17 | exit 0 |
| 18 | } |
| 19 | } elseif {[catch {info tclversion} version] == 0} { |
| 20 | if {$version >= 8.5 && ![string match 8.5a* [info patchlevel]]} { |
| 21 | puts [info nameofexecut |
+3
| --- a/configure | ||
| +++ b/configure | ||
| @@ -0,0 +1,3 @@ | ||
| 1 | +#!/bin/sh | |
| 2 | +dir=autosetup" | |
| 3 | +#st -f `"ir/auhen exec" || echo false` |
| --- a/configure | |
| +++ b/configure | |
| @@ -0,0 +1,3 @@ | |
| --- a/configure | |
| +++ b/configure | |
| @@ -0,0 +1,3 @@ | |
| 1 | #!/bin/sh |
| 2 | dir=autosetup" |
| 3 | #st -f `"ir/auhen exec" || echo false` |
+59
-59
| --- fossil.nsi | ||
| +++ fossil.nsi | ||
| @@ -1,59 +1,59 @@ | ||
| 1 | -; example2.nsi | |
| 2 | -; | |
| 3 | -; This script is based on example1.nsi, but adds uninstall support | |
| 4 | -; and (optionally) start menu shortcuts. | |
| 5 | -; | |
| 6 | -; It will install notepad.exe into a directory that the user selects, | |
| 7 | -; | |
| 8 | - | |
| 9 | -; The name of the installer | |
| 10 | -Name "Fossil" | |
| 11 | - | |
| 12 | -; The file to write | |
| 13 | -OutFile "fossil-setup-7c0bd3ee08.exe" | |
| 14 | - | |
| 15 | -; The default installation directory | |
| 16 | -InstallDir $PROGRAMFILES\Fossil | |
| 17 | -; Registry key to check for directory (so if you install again, it will | |
| 18 | -; overwrite the old one automatically) | |
| 19 | -InstallDirRegKey HKLM SOFTWARE\Fossil "Install_Dir" | |
| 20 | - | |
| 21 | -; The text to prompt the user to enter a directory | |
| 22 | -ComponentText "This will install fossil on your computer." | |
| 23 | -; The text to prompt the user to enter a directory | |
| 24 | -DirText "Choose a directory to install in to:" | |
| 25 | - | |
| 26 | -; The stuff to install | |
| 27 | -Section "Fossil (required)" | |
| 28 | - ; Set output path to the installation directory. | |
| 29 | - SetOutPath $INSTDIR | |
| 30 | - ; Put file there | |
| 31 | - File ".\build\fossil.exe" | |
| 32 | - ; Write the installation path into the registry | |
| 33 | - WriteRegStr HKLM SOFTWARE\Fossil "Install_Dir" "$INSTDIR" | |
| 34 | - ; Write the uninstall keys for Windows | |
| 35 | - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" "DisplayName" "Fossil (remove only)" | |
| 36 | - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" "UninstallString" '"$INSTDIR\uninstall.exe"' | |
| 37 | - WriteUninstaller "uninstall.exe" | |
| 38 | -SectionEnd | |
| 39 | - | |
| 40 | - | |
| 41 | -; uninstall stuff | |
| 42 | - | |
| 43 | -UninstallText "This will uninstall fossil. Hit next to continue." | |
| 44 | - | |
| 45 | -; special uninstall section. | |
| 46 | -Section "Uninstall" | |
| 47 | - ; remove registry keys | |
| 48 | - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" | |
| 49 | - DeleteRegKey HKLM SOFTWARE\Fossil | |
| 50 | - ; remove files | |
| 51 | - Delete $INSTDIR\fossil.exe | |
| 52 | - ; MUST REMOVE UNINSTALLER, too | |
| 53 | - Delete $INSTDIR\uninstall.exe | |
| 54 | - ; remove shortcuts, if any. | |
| 55 | - RMDir "$SMPROGRAMS\Fossil" | |
| 56 | - RMDir "$INSTDIR" | |
| 57 | -SectionEnd | |
| 58 | - | |
| 59 | -; eof | |
| 1 | +; example2.nsi | |
| 2 | +; | |
| 3 | +; This script is based on example1.nsi, but adds uninstall support | |
| 4 | +; and (optionally) start menu shortcuts. | |
| 5 | +; | |
| 6 | +; It will install notepad.exe into a directory that the user selects, | |
| 7 | +; | |
| 8 | + | |
| 9 | +; The name of the installer | |
| 10 | +Name "Fossil" | |
| 11 | + | |
| 12 | +; The file to write | |
| 13 | +OutFile "fossil-setup.exe" | |
| 14 | + | |
| 15 | +; The default installation directory | |
| 16 | +InstallDir $PROGRAMFILES\Fossil | |
| 17 | +; Registry key to check for directory (so if you install again, it will | |
| 18 | +; overwrite the old one automatically) | |
| 19 | +InstallDirRegKey HKLM SOFTWARE\Fossil "Install_Dir" | |
| 20 | + | |
| 21 | +; The text to prompt the user to enter a directory | |
| 22 | +ComponentText "This will install fossil on your computer." | |
| 23 | +; The text to prompt the user to enter a directory | |
| 24 | +DirText "Choose a directory to install in to:" | |
| 25 | + | |
| 26 | +; The stuff to install | |
| 27 | +Section "Fossil (required)" | |
| 28 | + ; Set output path to the installation directory. | |
| 29 | + SetOutPath $INSTDIR | |
| 30 | + ; Put file there | |
| 31 | + File ".\fossil.exe" | |
| 32 | + ; Write the installation path into the registry | |
| 33 | + WriteRegStr HKLM SOFTWARE\Fossil "Install_Dir" "$INSTDIR" | |
| 34 | + ; Write the uninstall keys for Windows | |
| 35 | + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" "DisplayName" "Fossil (remove only)" | |
| 36 | + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" "UninstallString" '"$INSTDIR\uninstall.exe"' | |
| 37 | + WriteUninstaller "uninstall.exe" | |
| 38 | +SectionEnd | |
| 39 | + | |
| 40 | + | |
| 41 | +; uninstall stuff | |
| 42 | + | |
| 43 | +UninstallText "This will uninstall fossil. Hit next to continue." | |
| 44 | + | |
| 45 | +; special uninstall section. | |
| 46 | +Section "Uninstall" | |
| 47 | + ; remove registry keys | |
| 48 | + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" | |
| 49 | + DeleteRegKey HKLM SOFTWARE\Fossil | |
| 50 | + ; remove files | |
| 51 | + Delete $INSTDIR\fossil.exe | |
| 52 | + ; MUST REMOVE UNINSTALLER, too | |
| 53 | + Delete $INSTDIR\uninstall.exe | |
| 54 | + ; remove shortcuts, if any. | |
| 55 | + RMDir "$SMPROGRAMS\Fossil" | |
| 56 | + RMDir "$INSTDIR" | |
| 57 | +SectionEnd | |
| 58 | + | |
| 59 | +; eof | |
| 60 | 60 |
| --- fossil.nsi | |
| +++ fossil.nsi | |
| @@ -1,59 +1,59 @@ | |
| 1 | ; example2.nsi |
| 2 | ; |
| 3 | ; This script is based on example1.nsi, but adds uninstall support |
| 4 | ; and (optionally) start menu shortcuts. |
| 5 | ; |
| 6 | ; It will install notepad.exe into a directory that the user selects, |
| 7 | ; |
| 8 | |
| 9 | ; The name of the installer |
| 10 | Name "Fossil" |
| 11 | |
| 12 | ; The file to write |
| 13 | OutFile "fossil-setup-7c0bd3ee08.exe" |
| 14 | |
| 15 | ; The default installation directory |
| 16 | InstallDir $PROGRAMFILES\Fossil |
| 17 | ; Registry key to check for directory (so if you install again, it will |
| 18 | ; overwrite the old one automatically) |
| 19 | InstallDirRegKey HKLM SOFTWARE\Fossil "Install_Dir" |
| 20 | |
| 21 | ; The text to prompt the user to enter a directory |
| 22 | ComponentText "This will install fossil on your computer." |
| 23 | ; The text to prompt the user to enter a directory |
| 24 | DirText "Choose a directory to install in to:" |
| 25 | |
| 26 | ; The stuff to install |
| 27 | Section "Fossil (required)" |
| 28 | ; Set output path to the installation directory. |
| 29 | SetOutPath $INSTDIR |
| 30 | ; Put file there |
| 31 | File ".\build\fossil.exe" |
| 32 | ; Write the installation path into the registry |
| 33 | WriteRegStr HKLM SOFTWARE\Fossil "Install_Dir" "$INSTDIR" |
| 34 | ; Write the uninstall keys for Windows |
| 35 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" "DisplayName" "Fossil (remove only)" |
| 36 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" "UninstallString" '"$INSTDIR\uninstall.exe"' |
| 37 | WriteUninstaller "uninstall.exe" |
| 38 | SectionEnd |
| 39 | |
| 40 | |
| 41 | ; uninstall stuff |
| 42 | |
| 43 | UninstallText "This will uninstall fossil. Hit next to continue." |
| 44 | |
| 45 | ; special uninstall section. |
| 46 | Section "Uninstall" |
| 47 | ; remove registry keys |
| 48 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" |
| 49 | DeleteRegKey HKLM SOFTWARE\Fossil |
| 50 | ; remove files |
| 51 | Delete $INSTDIR\fossil.exe |
| 52 | ; MUST REMOVE UNINSTALLER, too |
| 53 | Delete $INSTDIR\uninstall.exe |
| 54 | ; remove shortcuts, if any. |
| 55 | RMDir "$SMPROGRAMS\Fossil" |
| 56 | RMDir "$INSTDIR" |
| 57 | SectionEnd |
| 58 | |
| 59 | ; eof |
| 60 |
| --- fossil.nsi | |
| +++ fossil.nsi | |
| @@ -1,59 +1,59 @@ | |
| 1 | ; example2.nsi |
| 2 | ; |
| 3 | ; This script is based on example1.nsi, but adds uninstall support |
| 4 | ; and (optionally) start menu shortcuts. |
| 5 | ; |
| 6 | ; It will install notepad.exe into a directory that the user selects, |
| 7 | ; |
| 8 | |
| 9 | ; The name of the installer |
| 10 | Name "Fossil" |
| 11 | |
| 12 | ; The file to write |
| 13 | OutFile "fossil-setup.exe" |
| 14 | |
| 15 | ; The default installation directory |
| 16 | InstallDir $PROGRAMFILES\Fossil |
| 17 | ; Registry key to check for directory (so if you install again, it will |
| 18 | ; overwrite the old one automatically) |
| 19 | InstallDirRegKey HKLM SOFTWARE\Fossil "Install_Dir" |
| 20 | |
| 21 | ; The text to prompt the user to enter a directory |
| 22 | ComponentText "This will install fossil on your computer." |
| 23 | ; The text to prompt the user to enter a directory |
| 24 | DirText "Choose a directory to install in to:" |
| 25 | |
| 26 | ; The stuff to install |
| 27 | Section "Fossil (required)" |
| 28 | ; Set output path to the installation directory. |
| 29 | SetOutPath $INSTDIR |
| 30 | ; Put file there |
| 31 | File ".\fossil.exe" |
| 32 | ; Write the installation path into the registry |
| 33 | WriteRegStr HKLM SOFTWARE\Fossil "Install_Dir" "$INSTDIR" |
| 34 | ; Write the uninstall keys for Windows |
| 35 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" "DisplayName" "Fossil (remove only)" |
| 36 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" "UninstallString" '"$INSTDIR\uninstall.exe"' |
| 37 | WriteUninstaller "uninstall.exe" |
| 38 | SectionEnd |
| 39 | |
| 40 | |
| 41 | ; uninstall stuff |
| 42 | |
| 43 | UninstallText "This will uninstall fossil. Hit next to continue." |
| 44 | |
| 45 | ; special uninstall section. |
| 46 | Section "Uninstall" |
| 47 | ; remove registry keys |
| 48 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fossil" |
| 49 | DeleteRegKey HKLM SOFTWARE\Fossil |
| 50 | ; remove files |
| 51 | Delete $INSTDIR\fossil.exe |
| 52 | ; MUST REMOVE UNINSTALLER, too |
| 53 | Delete $INSTDIR\uninstall.exe |
| 54 | ; remove shortcuts, if any. |
| 55 | RMDir "$SMPROGRAMS\Fossil" |
| 56 | RMDir "$INSTDIR" |
| 57 | SectionEnd |
| 58 | |
| 59 | ; eof |
| 60 |
+224
-255
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -85,307 +85,273 @@ | ||
| 85 | 85 | zAll = blob_str(&x); |
| 86 | 86 | } |
| 87 | 87 | return zAll; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - | |
| 91 | -/* | |
| 92 | -** The pIgnore statement is query of the form: | |
| 93 | -** | |
| 94 | -** SELECT (:x GLOB ... OR :x GLOB ... OR ...) | |
| 95 | -** | |
| 96 | -** In other words, it is a query that returns true if the :x value | |
| 97 | -** should be ignored. Evaluate the query and return true to ignore | |
| 98 | -** and false to not ignore. | |
| 99 | -** | |
| 100 | -** If pIgnore is NULL, then do not ignore. | |
| 101 | -*/ | |
| 102 | -static int shouldBeIgnored(Stmt *pIgnore, const char *zName){ | |
| 103 | - int rc = 0; | |
| 104 | - if( pIgnore ){ | |
| 105 | - db_bind_text(pIgnore, ":x", zName); | |
| 106 | - db_step(pIgnore); | |
| 107 | - rc = db_column_int(pIgnore, 0); | |
| 108 | - db_reset(pIgnore); | |
| 109 | - } | |
| 110 | - return rc; | |
| 111 | -} | |
| 112 | - | |
| 113 | - | |
| 114 | 90 | /* |
| 115 | 91 | ** Add a single file named zName to the VFILE table with vid. |
| 116 | 92 | ** |
| 117 | 93 | ** Omit any file whose name is pOmit. |
| 118 | 94 | */ |
| 119 | -static void add_one_file( | |
| 120 | - const char *zName, /* Name of file to add */ | |
| 95 | +static int add_one_file( | |
| 96 | + const char *zPath, /* Tree-name of file to add. */ | |
| 121 | 97 | int vid, /* Add to this VFILE */ |
| 122 | - Blob *pOmit | |
| 98 | + int caseSensitive /* True if filenames are case sensitive */ | |
| 123 | 99 | ){ |
| 124 | - Blob pathname; | |
| 125 | - const char *zPath; | |
| 126 | - int i; | |
| 127 | - const char *zReserved; | |
| 128 | - | |
| 129 | - file_tree_name(zName, &pathname, 1); | |
| 130 | - zPath = blob_str(&pathname); | |
| 131 | - for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ | |
| 132 | - if( fossil_strcmp(zPath, zReserved)==0 ) break; | |
| 133 | - } | |
| 134 | - if( zReserved || (pOmit && blob_compare(&pathname, pOmit)==0) ){ | |
| 135 | - fossil_warning("cannot add %s", zPath); | |
| 100 | + const char *zCollate = caseSensitive ? "binary" : "nocase"; | |
| 101 | + if( !file_is_simple_pathname(zPath) ){ | |
| 102 | + fossil_fatal("filename contains illegal characters: %s", zPath); | |
| 103 | + } | |
| 104 | + if( db_exists("SELECT 1 FROM vfile" | |
| 105 | + " WHERE pathname=%Q COLLATE %s", zPath, zCollate) ){ | |
| 106 | + db_multi_exec("UPDATE vfile SET deleted=0" | |
| 107 | + " WHERE pathname=%Q COLLATE %s", zPath, zCollate); | |
| 108 | + }else{ | |
| 109 | + char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath); | |
| 110 | + db_multi_exec( | |
| 111 | + "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)" | |
| 112 | + "VALUES(%d,0,0,0,%Q,%d)", | |
| 113 | + vid, zPath, file_isexe(zFullname)); | |
| 114 | + fossil_free(zFullname); | |
| 115 | + } | |
| 116 | + if( db_changes() ){ | |
| 117 | + fossil_print("ADDED %s\n", zPath); | |
| 118 | + return 1; | |
| 119 | + }else{ | |
| 120 | + fossil_print("SKIP %s\n", zPath); | |
| 121 | + return 0; | |
| 122 | + } | |
| 123 | +} | |
| 124 | + | |
| 125 | +/* | |
| 126 | +** Add all files in the sfile temp table. | |
| 127 | +** | |
| 128 | +** Automatically exclude the repository file. | |
| 129 | +*/ | |
| 130 | +static int add_files_in_sfile(int vid, int caseSensitive){ | |
| 131 | + const char *zRepo; /* Name of the repository database file */ | |
| 132 | + int nAdd = 0; /* Number of files added */ | |
| 133 | + int i; /* Loop counter */ | |
| 134 | + const char *zReserved; /* Name of a reserved file */ | |
| 135 | + Blob repoName; /* Treename of the repository */ | |
| 136 | + Stmt loop; /* SQL to loop over all files to add */ | |
| 137 | + int (*xCmp)(const char*,const char*); | |
| 138 | + | |
| 139 | + if( !file_tree_name(g.zRepositoryName, &repoName, 0) ){ | |
| 140 | + blob_zero(&repoName); | |
| 141 | + zRepo = ""; | |
| 142 | + }else{ | |
| 143 | + zRepo = blob_str(&repoName); | |
| 144 | + } | |
| 145 | + if( caseSensitive ){ | |
| 146 | + xCmp = fossil_strcmp; | |
| 136 | 147 | }else{ |
| 137 | - if( !file_is_simple_pathname(zPath) ){ | |
| 138 | - fossil_fatal("filename contains illegal characters: %s", zPath); | |
| 139 | - } | |
| 140 | -#if defined(_WIN32) | |
| 141 | - if( db_exists("SELECT 1 FROM vfile" | |
| 142 | - " WHERE pathname=%Q COLLATE nocase", zPath) ){ | |
| 143 | - db_multi_exec("UPDATE vfile SET deleted=0" | |
| 144 | - " WHERE pathname=%Q COLLATE nocase", zPath); | |
| 145 | - } | |
| 146 | -#else | |
| 147 | - if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){ | |
| 148 | - db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath); | |
| 149 | - } | |
| 150 | -#endif | |
| 151 | - else{ | |
| 152 | - db_multi_exec( | |
| 153 | - "INSERT INTO vfile(vid,deleted,rid,mrid,pathname)" | |
| 154 | - "VALUES(%d,0,0,0,%Q)", vid, zPath); | |
| 155 | - } | |
| 156 | - printf("ADDED %s\n", zPath); | |
| 157 | - } | |
| 158 | - blob_reset(&pathname); | |
| 159 | -} | |
| 160 | - | |
| 161 | -/* | |
| 162 | -** All content of the zDir directory to the SFILE table. | |
| 163 | -*/ | |
| 164 | -void add_directory_content(const char *zDir, Stmt *pIgnore){ | |
| 165 | - DIR *d; | |
| 166 | - int origSize; | |
| 167 | - struct dirent *pEntry; | |
| 168 | - Blob path; | |
| 169 | - | |
| 170 | - blob_zero(&path); | |
| 171 | - blob_append(&path, zDir, -1); | |
| 172 | - origSize = blob_size(&path); | |
| 173 | - d = opendir(zDir); | |
| 174 | - if( d ){ | |
| 175 | - while( (pEntry=readdir(d))!=0 ){ | |
| 176 | - char *zPath; | |
| 177 | - if( pEntry->d_name[0]=='.' ){ | |
| 178 | - if( !includeDotFiles ) continue; | |
| 179 | - if( pEntry->d_name[1]==0 ) continue; | |
| 180 | - if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; | |
| 181 | - } | |
| 182 | - blob_appendf(&path, "/%s", pEntry->d_name); | |
| 183 | - zPath = blob_str(&path); | |
| 184 | - if( shouldBeIgnored(pIgnore, zPath) ){ | |
| 185 | - /* Noop */ | |
| 186 | - }else if( file_isdir(zPath)==1 ){ | |
| 187 | - add_directory_content(zPath, pIgnore); | |
| 188 | - }else if( file_isfile_or_link(zPath) ){ | |
| 189 | - db_multi_exec("INSERT INTO sfile VALUES(%Q)", zPath); | |
| 190 | - } | |
| 191 | - blob_resize(&path, origSize); | |
| 192 | - } | |
| 193 | - } | |
| 194 | - closedir(d); | |
| 195 | - blob_reset(&path); | |
| 196 | -} | |
| 197 | - | |
| 198 | -/* | |
| 199 | -** Add all content of a directory. | |
| 200 | -*/ | |
| 201 | -void add_directory(const char *zDir, int vid, Blob *pOmit, Stmt *pIgnore){ | |
| 202 | - Stmt q; | |
| 203 | - add_directory_content(zDir, pIgnore); | |
| 204 | - db_prepare(&q, "SELECT x FROM sfile ORDER BY x"); | |
| 205 | - while( db_step(&q)==SQLITE_ROW ){ | |
| 206 | - const char *zName = db_column_text(&q, 0); | |
| 207 | - add_one_file(zName, vid, pOmit); | |
| 208 | - } | |
| 209 | - db_finalize(&q); | |
| 210 | - db_multi_exec("DELETE FROM sfile"); | |
| 148 | + xCmp = fossil_stricmp; | |
| 149 | + db_multi_exec( | |
| 150 | + "CREATE INDEX IF NOT EXISTS vfile_nocase" | |
| 151 | + " ON vfile(pathname COLLATE nocase)" | |
| 152 | + ); | |
| 153 | + } | |
| 154 | + db_prepare(&loop, "SELECT x FROM sfile ORDER BY x"); | |
| 155 | + while( db_step(&loop)==SQLITE_ROW ){ | |
| 156 | + const char *zToAdd = db_column_text(&loop, 0); | |
| 157 | + if( fossil_strcmp(zToAdd, zRepo)==0 ) continue; | |
| 158 | + for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ | |
| 159 | + if( xCmp(zToAdd, zReserved)==0 ) break; | |
| 160 | + } | |
| 161 | + if( zReserved ) continue; | |
| 162 | + nAdd += add_one_file(zToAdd, vid, caseSensitive); | |
| 163 | + } | |
| 164 | + db_finalize(&loop); | |
| 165 | + blob_reset(&repoName); | |
| 166 | + return nAdd; | |
| 211 | 167 | } |
| 212 | 168 | |
| 213 | 169 | /* |
| 214 | 170 | ** COMMAND: add |
| 215 | 171 | ** |
| 216 | -** Usage: %fossil add FILE... | |
| 217 | -** | |
| 218 | -** Make arrangements to add one or more files to the current checkout | |
| 219 | -** at the next commit. | |
| 220 | -** | |
| 221 | -** When adding files recursively, filenames that begin with "." are | |
| 222 | -** excluded by default. To include such files, add the "--dotfiles" | |
| 223 | -** option to the command-line. | |
| 224 | -** | |
| 225 | -** The --ignore option overrides the "ignore-glob" setting. See | |
| 226 | -** documentation on the "setting" command for further information. | |
| 172 | +** Usage: %fossil add ?OPTIONS? FILE1 ?FILE2 ...? | |
| 173 | +** | |
| 174 | +** Make arrangements to add one or more files or directories to the | |
| 175 | +** current checkout at the next commit. | |
| 176 | +** | |
| 177 | +** When adding files or directories recursively, filenames that begin | |
| 178 | +** with "." are excluded by default. To include such files, add | |
| 179 | +** the "--dotfiles" option to the command-line. | |
| 180 | +** | |
| 181 | +** The --ignore option is a comma-separate list of glob patterns for files | |
| 182 | +** to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore option | |
| 183 | +** does not appear on the command line then the "ignore-glob" setting is | |
| 184 | +** used. | |
| 185 | +** | |
| 186 | +** SUMMARY: fossil add ?OPTIONS? FILE1 ?FILE2 ...? | |
| 187 | +** Options: --dotfiles, --ignore | |
| 227 | 188 | */ |
| 228 | 189 | void add_cmd(void){ |
| 229 | - int i; | |
| 230 | - int vid; | |
| 231 | - const char *zIgnoreFlag; | |
| 232 | - Blob repo; | |
| 233 | - Stmt ignoreTest; /* Test to see if a name should be ignored */ | |
| 234 | - Stmt *pIgnore; /* Pointer to ignoreTest or to NULL */ | |
| 190 | + int i; /* Loop counter */ | |
| 191 | + int vid; /* Currently checked out version */ | |
| 192 | + int nRoot; /* Full path characters in g.zLocalRoot */ | |
| 193 | + const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ | |
| 194 | + Glob *pIgnore; /* Ignore everything matching this glob pattern */ | |
| 195 | + int caseSensitive; /* True if filenames are case sensitive */ | |
| 235 | 196 | |
| 236 | 197 | zIgnoreFlag = find_option("ignore",0,1); |
| 237 | 198 | includeDotFiles = find_option("dotfiles",0,0)!=0; |
| 199 | + capture_case_sensitive_option(); | |
| 238 | 200 | db_must_be_within_tree(); |
| 201 | + caseSensitive = filenames_are_case_sensitive(); | |
| 239 | 202 | if( zIgnoreFlag==0 ){ |
| 240 | 203 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 241 | 204 | } |
| 242 | 205 | vid = db_lget_int("checkout",0); |
| 243 | 206 | if( vid==0 ){ |
| 244 | 207 | fossil_panic("no checkout to add to"); |
| 245 | 208 | } |
| 246 | 209 | db_begin_transaction(); |
| 247 | - if( !file_tree_name(g.zRepositoryName, &repo, 0) ){ | |
| 248 | - blob_zero(&repo); | |
| 249 | - } | |
| 250 | 210 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 251 | 211 | #if defined(_WIN32) |
| 252 | 212 | db_multi_exec( |
| 253 | 213 | "CREATE INDEX IF NOT EXISTS vfile_pathname " |
| 254 | 214 | " ON vfile(pathname COLLATE nocase)" |
| 255 | 215 | ); |
| 256 | 216 | #endif |
| 257 | - if( zIgnoreFlag && zIgnoreFlag[0] ){ | |
| 258 | - db_prepare(&ignoreTest, "SELECT %s", glob_expr(":x", zIgnoreFlag)); | |
| 259 | - pIgnore = &ignoreTest; | |
| 260 | - }else{ | |
| 261 | - pIgnore = 0; | |
| 262 | - } | |
| 217 | + pIgnore = glob_create(zIgnoreFlag); | |
| 218 | + nRoot = strlen(g.zLocalRoot); | |
| 219 | + | |
| 220 | + /* Load the names of all files that are to be added into sfile temp table */ | |
| 263 | 221 | for(i=2; i<g.argc; i++){ |
| 264 | 222 | char *zName; |
| 265 | 223 | int isDir; |
| 224 | + Blob fullName; | |
| 266 | 225 | |
| 267 | - zName = mprintf("%/", g.argv[i]); | |
| 226 | + file_canonical_name(g.argv[i], &fullName); | |
| 227 | + zName = blob_str(&fullName); | |
| 268 | 228 | isDir = file_isdir(zName); |
| 269 | 229 | if( isDir==1 ){ |
| 270 | - add_directory(zName, vid, &repo, pIgnore); | |
| 230 | + vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore); | |
| 271 | 231 | }else if( isDir==0 ){ |
| 272 | 232 | fossil_fatal("not found: %s", zName); |
| 273 | - }else if( access(zName, R_OK) ){ | |
| 233 | + }else if( file_access(zName, R_OK) ){ | |
| 274 | 234 | fossil_fatal("cannot open %s", zName); |
| 275 | 235 | }else{ |
| 276 | - add_one_file(zName, vid, &repo); | |
| 277 | - } | |
| 278 | - free(zName); | |
| 279 | - } | |
| 280 | - if( pIgnore ) db_finalize(pIgnore); | |
| 281 | - db_end_transaction(0); | |
| 282 | -} | |
| 283 | - | |
| 284 | -/* | |
| 285 | -** Remove all contents of zDir | |
| 286 | -*/ | |
| 287 | -void del_directory_content(const char *zDir){ | |
| 288 | - DIR *d; | |
| 289 | - int origSize; | |
| 290 | - struct dirent *pEntry; | |
| 291 | - Blob path; | |
| 292 | - | |
| 293 | - blob_zero(&path); | |
| 294 | - blob_append(&path, zDir, -1); | |
| 295 | - origSize = blob_size(&path); | |
| 296 | - d = opendir(zDir); | |
| 297 | - if( d ){ | |
| 298 | - while( (pEntry=readdir(d))!=0 ){ | |
| 299 | - char *zPath; | |
| 300 | - if( pEntry->d_name[0]=='.'){ | |
| 301 | - if( !includeDotFiles ) continue; | |
| 302 | - if( pEntry->d_name[1]==0 ) continue; | |
| 303 | - if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; | |
| 304 | - } | |
| 305 | - blob_appendf(&path, "/%s", pEntry->d_name); | |
| 306 | - zPath = blob_str(&path); | |
| 307 | - if( file_isdir(zPath)==1 ){ | |
| 308 | - del_directory_content(zPath); | |
| 309 | - }else if( file_isfile_or_link(zPath) ){ | |
| 310 | - char *zFilePath; | |
| 311 | - Blob pathname; | |
| 312 | - file_tree_name(zPath, &pathname, 1); | |
| 313 | - zFilePath = blob_str(&pathname); | |
| 314 | - if( !db_exists( | |
| 315 | - "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zFilePath) | |
| 316 | - ){ | |
| 317 | - printf("SKIPPED %s\n", zPath); | |
| 318 | - }else{ | |
| 319 | - db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath); | |
| 320 | - printf("DELETED %s\n", zPath); | |
| 321 | - } | |
| 322 | - blob_reset(&pathname); | |
| 323 | - } | |
| 324 | - blob_resize(&path, origSize); | |
| 325 | - } | |
| 326 | - } | |
| 327 | - closedir(d); | |
| 328 | - blob_reset(&path); | |
| 236 | + char *zTreeName = &zName[nRoot]; | |
| 237 | + db_multi_exec( | |
| 238 | + "INSERT OR IGNORE INTO sfile(x)" | |
| 239 | + " SELECT %Q WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE pathname=%Q)", | |
| 240 | + zTreeName, zTreeName | |
| 241 | + ); | |
| 242 | + } | |
| 243 | + blob_reset(&fullName); | |
| 244 | + } | |
| 245 | + glob_free(pIgnore); | |
| 246 | + | |
| 247 | + add_files_in_sfile(vid, caseSensitive); | |
| 248 | + db_end_transaction(0); | |
| 329 | 249 | } |
| 330 | 250 | |
| 331 | 251 | /* |
| 332 | 252 | ** COMMAND: rm |
| 333 | 253 | ** COMMAND: delete |
| 334 | 254 | ** |
| 335 | -** Usage: %fossil rm FILE... | |
| 336 | -** or: %fossil delete FILE... | |
| 255 | +** Usage: %fossil rm FILE1 ?FILE2 ...? | |
| 256 | +** or: %fossil delete FILE1 ?FILE2 ...? | |
| 337 | 257 | ** |
| 338 | -** Remove one or more files from the tree. | |
| 258 | +** Remove one or more files or directories from the repository. | |
| 339 | 259 | ** |
| 340 | -** This command does not remove the files from disk. It just marks the | |
| 260 | +** This command does NOT remove the files from disk. It just marks the | |
| 341 | 261 | ** files as no longer being part of the project. In other words, future |
| 342 | 262 | ** changes to the named files will not be versioned. |
| 263 | +** | |
| 264 | +** SUMMARY: fossil rm FILE1 ?FILE2 ...? | |
| 265 | +** or: fossil delete FILE1 ?FILE2 ...? | |
| 343 | 266 | */ |
| 344 | 267 | void delete_cmd(void){ |
| 345 | 268 | int i; |
| 346 | 269 | int vid; |
| 270 | + Stmt loop; | |
| 347 | 271 | |
| 348 | 272 | db_must_be_within_tree(); |
| 349 | 273 | vid = db_lget_int("checkout", 0); |
| 350 | 274 | if( vid==0 ){ |
| 351 | 275 | fossil_panic("no checkout to remove from"); |
| 352 | 276 | } |
| 353 | 277 | db_begin_transaction(); |
| 278 | + db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); | |
| 354 | 279 | for(i=2; i<g.argc; i++){ |
| 355 | - char *zName; | |
| 356 | - | |
| 357 | - zName = mprintf("%/", g.argv[i]); | |
| 358 | - if( file_isdir(zName) == 1 ){ | |
| 359 | - del_directory_content(zName); | |
| 360 | - } else { | |
| 361 | - char *zPath; | |
| 362 | - Blob pathname; | |
| 363 | - file_tree_name(zName, &pathname, 1); | |
| 364 | - zPath = blob_str(&pathname); | |
| 365 | - if( !db_exists( | |
| 366 | - "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){ | |
| 367 | - fossil_fatal("not in the repository: %s", zName); | |
| 368 | - }else{ | |
| 369 | - db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath); | |
| 370 | - printf("DELETED %s\n", zPath); | |
| 371 | - } | |
| 372 | - blob_reset(&pathname); | |
| 373 | - } | |
| 374 | - free(zName); | |
| 375 | - } | |
| 376 | - db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0"); | |
| 280 | + Blob treeName; | |
| 281 | + char *zTreeName; | |
| 282 | + | |
| 283 | + file_tree_name(g.argv[i], &treeName, 1); | |
| 284 | + zTreeName = blob_str(&treeName); | |
| 285 | + db_multi_exec( | |
| 286 | + "INSERT OR IGNORE INTO sfile" | |
| 287 | + " SELECT pathname FROM vfile" | |
| 288 | + " WHERE (pathname=%Q" | |
| 289 | + " OR (pathname>'%q/' AND pathname<'%q0'))" | |
| 290 | + " AND NOT deleted", | |
| 291 | + zTreeName, zTreeName, zTreeName | |
| 292 | + ); | |
| 293 | + blob_reset(&treeName); | |
| 294 | + } | |
| 295 | + | |
| 296 | + db_prepare(&loop, "SELECT x FROM sfile"); | |
| 297 | + while( db_step(&loop)==SQLITE_ROW ){ | |
| 298 | + fossil_print("DELETED %s\n", db_column_text(&loop, 0)); | |
| 299 | + } | |
| 300 | + db_finalize(&loop); | |
| 301 | + db_multi_exec( | |
| 302 | + "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;" | |
| 303 | + "DELETE FROM vfile WHERE rid=0 AND deleted;" | |
| 304 | + ); | |
| 377 | 305 | db_end_transaction(0); |
| 378 | 306 | } |
| 307 | + | |
| 308 | +/* | |
| 309 | +** Capture the command-line --case-sensitive option. | |
| 310 | +*/ | |
| 311 | +static const char *zCaseSensitive = 0; | |
| 312 | +void capture_case_sensitive_option(void){ | |
| 313 | + if( zCaseSensitive==0 ){ | |
| 314 | + zCaseSensitive = find_option("case-sensitive",0,1); | |
| 315 | + } | |
| 316 | +} | |
| 317 | + | |
| 318 | +/* | |
| 319 | +** This routine determines if files should be case-sensitive or not. | |
| 320 | +** In other words, this routine determines if two filenames that | |
| 321 | +** differ only in case should be considered the same name or not. | |
| 322 | +** | |
| 323 | +** The case-sensitive setting determines the default value. If | |
| 324 | +** the case-sensitive setting is undefined, then case sensitivity | |
| 325 | +** defaults on for Mac and Windows and off for all other unix. | |
| 326 | +** | |
| 327 | +** The --case-sensitive BOOLEAN command-line option overrides any | |
| 328 | +** setting. | |
| 329 | +*/ | |
| 330 | +int filenames_are_case_sensitive(void){ | |
| 331 | + int caseSensitive; | |
| 332 | + | |
| 333 | + if( zCaseSensitive ){ | |
| 334 | + caseSensitive = is_truth(zCaseSensitive); | |
| 335 | + }else{ | |
| 336 | +#if !defined(_WIN32) && !defined(__DARWIN__) && !defined(__APPLE__) | |
| 337 | + caseSensitive = 1; | |
| 338 | +#else | |
| 339 | + caseSensitive = 0; | |
| 340 | +#endif | |
| 341 | + caseSensitive = db_get_boolean("case-sensitive",caseSensitive); | |
| 342 | + } | |
| 343 | + return caseSensitive; | |
| 344 | +} | |
| 379 | 345 | |
| 380 | 346 | /* |
| 381 | 347 | ** COMMAND: addremove |
| 382 | 348 | ** |
| 383 | 349 | ** Usage: %fossil addremove ?--dotfiles? ?--ignore GLOBPATTERN? ?--test? |
| 384 | 350 | ** |
| 385 | 351 | ** Do all necessary "add" and "rm" commands to synchronize the repository |
| 386 | -** with the content of the working checkout | |
| 352 | +** with the content of the working checkout: | |
| 387 | 353 | ** |
| 388 | 354 | ** * All files in the checkout but not in the repository (that is, |
| 389 | 355 | ** all files displayed using the "extra" command) are added as |
| 390 | 356 | ** if by the "add" command. |
| 391 | 357 | ** |
| @@ -398,65 +364,63 @@ | ||
| 398 | 364 | ** |
| 399 | 365 | ** Files and directories whose names begin with "." are ignored unless |
| 400 | 366 | ** the --dotfiles option is used. |
| 401 | 367 | ** |
| 402 | 368 | ** The --ignore option overrides the "ignore-glob" setting. See |
| 403 | -** documentation on the "setting" command for further information. | |
| 369 | +** documentation on the "settings" command for further information. | |
| 404 | 370 | ** |
| 405 | 371 | ** The --test option shows what would happen without actually doing anything. |
| 406 | 372 | ** |
| 407 | 373 | ** This command can be used to track third party software. |
| 374 | +** | |
| 375 | +** SUMMARY: fossil addremove | |
| 376 | +** Options: ?--dotfiles? ?--ignore GLOB? ?--test? ?--case-sensitive BOOL? | |
| 408 | 377 | */ |
| 409 | -void import_cmd(void){ | |
| 378 | +void addremove_cmd(void){ | |
| 410 | 379 | Blob path; |
| 411 | 380 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 412 | 381 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 413 | 382 | int isTest = find_option("test",0,0)!=0; |
| 383 | + int caseSensitive; | |
| 414 | 384 | int n; |
| 415 | 385 | Stmt q; |
| 416 | 386 | int vid; |
| 417 | - Blob repo; | |
| 418 | 387 | int nAdd = 0; |
| 419 | 388 | int nDelete = 0; |
| 389 | + Glob *pIgnore; | |
| 420 | 390 | |
| 391 | + capture_case_sensitive_option(); | |
| 421 | 392 | db_must_be_within_tree(); |
| 393 | + caseSensitive = filenames_are_case_sensitive(); | |
| 422 | 394 | if( zIgnoreFlag==0 ){ |
| 423 | 395 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 424 | 396 | } |
| 425 | 397 | vid = db_lget_int("checkout",0); |
| 426 | 398 | if( vid==0 ){ |
| 427 | 399 | fossil_panic("no checkout to add to"); |
| 428 | 400 | } |
| 429 | 401 | db_begin_transaction(); |
| 402 | + | |
| 403 | + /* step 1: | |
| 404 | + ** Populate the temp table "sfile" with the names of all unmanged | |
| 405 | + ** files currently in the check-out, except for files that match the | |
| 406 | + ** --ignore or ignore-glob patterns and dot-files. Then add all of | |
| 407 | + ** the files in the sfile temp table to the set of managed files. | |
| 408 | + */ | |
| 430 | 409 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 431 | 410 | n = strlen(g.zLocalRoot); |
| 432 | 411 | blob_init(&path, g.zLocalRoot, n-1); |
| 433 | 412 | /* now we read the complete file structure into a temp table */ |
| 434 | - vfile_scan(0, &path, blob_size(&path), allFlag); | |
| 435 | - if( file_tree_name(g.zRepositoryName, &repo, 0) ){ | |
| 436 | - db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); | |
| 437 | - } | |
| 438 | - | |
| 439 | - /* step 1: search for extra files */ | |
| 440 | - db_prepare(&q, | |
| 441 | - "SELECT x, %Q || x FROM sfile" | |
| 442 | - " WHERE x NOT IN (%s)" | |
| 443 | - " AND NOT %s" | |
| 444 | - " ORDER BY 1", | |
| 445 | - g.zLocalRoot, | |
| 446 | - fossil_all_reserved_names(), | |
| 447 | - glob_expr("x", zIgnoreFlag) | |
| 448 | - ); | |
| 449 | - while( db_step(&q)==SQLITE_ROW ){ | |
| 450 | - add_one_file(db_column_text(&q, 1), vid, 0); | |
| 451 | - nAdd++; | |
| 452 | - } | |
| 453 | - db_finalize(&q); | |
| 413 | + pIgnore = glob_create(zIgnoreFlag); | |
| 414 | + vfile_scan(&path, blob_size(&path), allFlag, pIgnore); | |
| 415 | + glob_free(pIgnore); | |
| 416 | + nAdd = add_files_in_sfile(vid, caseSensitive); | |
| 417 | + | |
| 454 | 418 | /* step 2: search for missing files */ |
| 455 | - db_prepare(&q, | |
| 456 | - "SELECT pathname,%Q || pathname,deleted FROM vfile" | |
| 457 | - " WHERE deleted!=1" | |
| 419 | + db_prepare(&q, | |
| 420 | + "SELECT pathname, %Q || pathname, deleted FROM vfile" | |
| 421 | + " WHERE NOT deleted" | |
| 458 | 422 | " ORDER BY 1", |
| 459 | 423 | g.zLocalRoot |
| 460 | 424 | ); |
| 461 | 425 | while( db_step(&q)==SQLITE_ROW ){ |
| 462 | 426 | const char * zFile; |
| @@ -466,17 +430,17 @@ | ||
| 466 | 430 | zPath = db_column_text(&q, 1); |
| 467 | 431 | if( !file_isfile_or_link(zPath) ){ |
| 468 | 432 | if( !isTest ){ |
| 469 | 433 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 470 | 434 | } |
| 471 | - printf("DELETED %s\n", zFile); | |
| 435 | + fossil_print("DELETED %s\n", zFile); | |
| 472 | 436 | nDelete++; |
| 473 | 437 | } |
| 474 | 438 | } |
| 475 | 439 | db_finalize(&q); |
| 476 | 440 | /* show cmmand summary */ |
| 477 | - printf("added %d files, deleted %d files\n", nAdd, nDelete); | |
| 441 | + fossil_print("added %d files, deleted %d files\n", nAdd, nDelete); | |
| 478 | 442 | |
| 479 | 443 | db_end_transaction(isTest); |
| 480 | 444 | } |
| 481 | 445 | |
| 482 | 446 | |
| @@ -484,11 +448,11 @@ | ||
| 484 | 448 | ** Rename a single file. |
| 485 | 449 | ** |
| 486 | 450 | ** The original name of the file is zOrig. The new filename is zNew. |
| 487 | 451 | */ |
| 488 | 452 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 489 | - printf("RENAME %s %s\n", zOrig, zNew); | |
| 453 | + fossil_print("RENAME %s %s\n", zOrig, zNew); | |
| 490 | 454 | db_multi_exec( |
| 491 | 455 | "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d", |
| 492 | 456 | zNew, zOrig, vid |
| 493 | 457 | ); |
| 494 | 458 | } |
| @@ -498,15 +462,20 @@ | ||
| 498 | 462 | ** COMMAND: rename |
| 499 | 463 | ** |
| 500 | 464 | ** Usage: %fossil mv|rename OLDNAME NEWNAME |
| 501 | 465 | ** or: %fossil mv|rename OLDNAME... DIR |
| 502 | 466 | ** |
| 503 | -** Move or rename one or more files within the tree | |
| 467 | +** Move or rename one or more files or directories within the repository tree. | |
| 468 | +** You can either rename a file or directory or move it to another subdirectory. | |
| 504 | 469 | ** |
| 505 | -** This command does not rename the files on disk. This command merely | |
| 470 | +** This command does NOT rename or move the files on disk. This command merely | |
| 506 | 471 | ** records the fact that filenames have changed so that appropriate notations |
| 507 | 472 | ** can be made at the next commit/checkin. |
| 473 | +** | |
| 474 | +** | |
| 475 | +** SUMMARY: fossil mv|rename OLDNAME NEWNAME | |
| 476 | +** or: fossil mv|rename OLDNAME... DIR | |
| 508 | 477 | */ |
| 509 | 478 | void mv_cmd(void){ |
| 510 | 479 | int i; |
| 511 | 480 | int vid; |
| 512 | 481 | char *zDest; |
| @@ -553,13 +522,13 @@ | ||
| 553 | 522 | zOrig = blob_str(&orig); |
| 554 | 523 | nOrig = blob_size(&orig); |
| 555 | 524 | db_prepare(&q, |
| 556 | 525 | "SELECT pathname FROM vfile" |
| 557 | 526 | " WHERE vid=%d" |
| 558 | - " AND (pathname='%s' OR pathname GLOB '%s/*')" | |
| 527 | + " AND (pathname='%q' OR (pathname>'%q/' AND pathname<'%q0'))" | |
| 559 | 528 | " ORDER BY 1", |
| 560 | - vid, zOrig, zOrig | |
| 529 | + vid, zOrig, zOrig, zOrig | |
| 561 | 530 | ); |
| 562 | 531 | while( db_step(&q)==SQLITE_ROW ){ |
| 563 | 532 | const char *zPath = db_column_text(&q, 0); |
| 564 | 533 | int nPath = db_column_bytes(&q, 0); |
| 565 | 534 | const char *zTail; |
| 566 | 535 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -85,307 +85,273 @@ | |
| 85 | zAll = blob_str(&x); |
| 86 | } |
| 87 | return zAll; |
| 88 | } |
| 89 | |
| 90 | |
| 91 | /* |
| 92 | ** The pIgnore statement is query of the form: |
| 93 | ** |
| 94 | ** SELECT (:x GLOB ... OR :x GLOB ... OR ...) |
| 95 | ** |
| 96 | ** In other words, it is a query that returns true if the :x value |
| 97 | ** should be ignored. Evaluate the query and return true to ignore |
| 98 | ** and false to not ignore. |
| 99 | ** |
| 100 | ** If pIgnore is NULL, then do not ignore. |
| 101 | */ |
| 102 | static int shouldBeIgnored(Stmt *pIgnore, const char *zName){ |
| 103 | int rc = 0; |
| 104 | if( pIgnore ){ |
| 105 | db_bind_text(pIgnore, ":x", zName); |
| 106 | db_step(pIgnore); |
| 107 | rc = db_column_int(pIgnore, 0); |
| 108 | db_reset(pIgnore); |
| 109 | } |
| 110 | return rc; |
| 111 | } |
| 112 | |
| 113 | |
| 114 | /* |
| 115 | ** Add a single file named zName to the VFILE table with vid. |
| 116 | ** |
| 117 | ** Omit any file whose name is pOmit. |
| 118 | */ |
| 119 | static void add_one_file( |
| 120 | const char *zName, /* Name of file to add */ |
| 121 | int vid, /* Add to this VFILE */ |
| 122 | Blob *pOmit |
| 123 | ){ |
| 124 | Blob pathname; |
| 125 | const char *zPath; |
| 126 | int i; |
| 127 | const char *zReserved; |
| 128 | |
| 129 | file_tree_name(zName, &pathname, 1); |
| 130 | zPath = blob_str(&pathname); |
| 131 | for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ |
| 132 | if( fossil_strcmp(zPath, zReserved)==0 ) break; |
| 133 | } |
| 134 | if( zReserved || (pOmit && blob_compare(&pathname, pOmit)==0) ){ |
| 135 | fossil_warning("cannot add %s", zPath); |
| 136 | }else{ |
| 137 | if( !file_is_simple_pathname(zPath) ){ |
| 138 | fossil_fatal("filename contains illegal characters: %s", zPath); |
| 139 | } |
| 140 | #if defined(_WIN32) |
| 141 | if( db_exists("SELECT 1 FROM vfile" |
| 142 | " WHERE pathname=%Q COLLATE nocase", zPath) ){ |
| 143 | db_multi_exec("UPDATE vfile SET deleted=0" |
| 144 | " WHERE pathname=%Q COLLATE nocase", zPath); |
| 145 | } |
| 146 | #else |
| 147 | if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){ |
| 148 | db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath); |
| 149 | } |
| 150 | #endif |
| 151 | else{ |
| 152 | db_multi_exec( |
| 153 | "INSERT INTO vfile(vid,deleted,rid,mrid,pathname)" |
| 154 | "VALUES(%d,0,0,0,%Q)", vid, zPath); |
| 155 | } |
| 156 | printf("ADDED %s\n", zPath); |
| 157 | } |
| 158 | blob_reset(&pathname); |
| 159 | } |
| 160 | |
| 161 | /* |
| 162 | ** All content of the zDir directory to the SFILE table. |
| 163 | */ |
| 164 | void add_directory_content(const char *zDir, Stmt *pIgnore){ |
| 165 | DIR *d; |
| 166 | int origSize; |
| 167 | struct dirent *pEntry; |
| 168 | Blob path; |
| 169 | |
| 170 | blob_zero(&path); |
| 171 | blob_append(&path, zDir, -1); |
| 172 | origSize = blob_size(&path); |
| 173 | d = opendir(zDir); |
| 174 | if( d ){ |
| 175 | while( (pEntry=readdir(d))!=0 ){ |
| 176 | char *zPath; |
| 177 | if( pEntry->d_name[0]=='.' ){ |
| 178 | if( !includeDotFiles ) continue; |
| 179 | if( pEntry->d_name[1]==0 ) continue; |
| 180 | if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; |
| 181 | } |
| 182 | blob_appendf(&path, "/%s", pEntry->d_name); |
| 183 | zPath = blob_str(&path); |
| 184 | if( shouldBeIgnored(pIgnore, zPath) ){ |
| 185 | /* Noop */ |
| 186 | }else if( file_isdir(zPath)==1 ){ |
| 187 | add_directory_content(zPath, pIgnore); |
| 188 | }else if( file_isfile_or_link(zPath) ){ |
| 189 | db_multi_exec("INSERT INTO sfile VALUES(%Q)", zPath); |
| 190 | } |
| 191 | blob_resize(&path, origSize); |
| 192 | } |
| 193 | } |
| 194 | closedir(d); |
| 195 | blob_reset(&path); |
| 196 | } |
| 197 | |
| 198 | /* |
| 199 | ** Add all content of a directory. |
| 200 | */ |
| 201 | void add_directory(const char *zDir, int vid, Blob *pOmit, Stmt *pIgnore){ |
| 202 | Stmt q; |
| 203 | add_directory_content(zDir, pIgnore); |
| 204 | db_prepare(&q, "SELECT x FROM sfile ORDER BY x"); |
| 205 | while( db_step(&q)==SQLITE_ROW ){ |
| 206 | const char *zName = db_column_text(&q, 0); |
| 207 | add_one_file(zName, vid, pOmit); |
| 208 | } |
| 209 | db_finalize(&q); |
| 210 | db_multi_exec("DELETE FROM sfile"); |
| 211 | } |
| 212 | |
| 213 | /* |
| 214 | ** COMMAND: add |
| 215 | ** |
| 216 | ** Usage: %fossil add FILE... |
| 217 | ** |
| 218 | ** Make arrangements to add one or more files to the current checkout |
| 219 | ** at the next commit. |
| 220 | ** |
| 221 | ** When adding files recursively, filenames that begin with "." are |
| 222 | ** excluded by default. To include such files, add the "--dotfiles" |
| 223 | ** option to the command-line. |
| 224 | ** |
| 225 | ** The --ignore option overrides the "ignore-glob" setting. See |
| 226 | ** documentation on the "setting" command for further information. |
| 227 | */ |
| 228 | void add_cmd(void){ |
| 229 | int i; |
| 230 | int vid; |
| 231 | const char *zIgnoreFlag; |
| 232 | Blob repo; |
| 233 | Stmt ignoreTest; /* Test to see if a name should be ignored */ |
| 234 | Stmt *pIgnore; /* Pointer to ignoreTest or to NULL */ |
| 235 | |
| 236 | zIgnoreFlag = find_option("ignore",0,1); |
| 237 | includeDotFiles = find_option("dotfiles",0,0)!=0; |
| 238 | db_must_be_within_tree(); |
| 239 | if( zIgnoreFlag==0 ){ |
| 240 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 241 | } |
| 242 | vid = db_lget_int("checkout",0); |
| 243 | if( vid==0 ){ |
| 244 | fossil_panic("no checkout to add to"); |
| 245 | } |
| 246 | db_begin_transaction(); |
| 247 | if( !file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 248 | blob_zero(&repo); |
| 249 | } |
| 250 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 251 | #if defined(_WIN32) |
| 252 | db_multi_exec( |
| 253 | "CREATE INDEX IF NOT EXISTS vfile_pathname " |
| 254 | " ON vfile(pathname COLLATE nocase)" |
| 255 | ); |
| 256 | #endif |
| 257 | if( zIgnoreFlag && zIgnoreFlag[0] ){ |
| 258 | db_prepare(&ignoreTest, "SELECT %s", glob_expr(":x", zIgnoreFlag)); |
| 259 | pIgnore = &ignoreTest; |
| 260 | }else{ |
| 261 | pIgnore = 0; |
| 262 | } |
| 263 | for(i=2; i<g.argc; i++){ |
| 264 | char *zName; |
| 265 | int isDir; |
| 266 | |
| 267 | zName = mprintf("%/", g.argv[i]); |
| 268 | isDir = file_isdir(zName); |
| 269 | if( isDir==1 ){ |
| 270 | add_directory(zName, vid, &repo, pIgnore); |
| 271 | }else if( isDir==0 ){ |
| 272 | fossil_fatal("not found: %s", zName); |
| 273 | }else if( access(zName, R_OK) ){ |
| 274 | fossil_fatal("cannot open %s", zName); |
| 275 | }else{ |
| 276 | add_one_file(zName, vid, &repo); |
| 277 | } |
| 278 | free(zName); |
| 279 | } |
| 280 | if( pIgnore ) db_finalize(pIgnore); |
| 281 | db_end_transaction(0); |
| 282 | } |
| 283 | |
| 284 | /* |
| 285 | ** Remove all contents of zDir |
| 286 | */ |
| 287 | void del_directory_content(const char *zDir){ |
| 288 | DIR *d; |
| 289 | int origSize; |
| 290 | struct dirent *pEntry; |
| 291 | Blob path; |
| 292 | |
| 293 | blob_zero(&path); |
| 294 | blob_append(&path, zDir, -1); |
| 295 | origSize = blob_size(&path); |
| 296 | d = opendir(zDir); |
| 297 | if( d ){ |
| 298 | while( (pEntry=readdir(d))!=0 ){ |
| 299 | char *zPath; |
| 300 | if( pEntry->d_name[0]=='.'){ |
| 301 | if( !includeDotFiles ) continue; |
| 302 | if( pEntry->d_name[1]==0 ) continue; |
| 303 | if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; |
| 304 | } |
| 305 | blob_appendf(&path, "/%s", pEntry->d_name); |
| 306 | zPath = blob_str(&path); |
| 307 | if( file_isdir(zPath)==1 ){ |
| 308 | del_directory_content(zPath); |
| 309 | }else if( file_isfile_or_link(zPath) ){ |
| 310 | char *zFilePath; |
| 311 | Blob pathname; |
| 312 | file_tree_name(zPath, &pathname, 1); |
| 313 | zFilePath = blob_str(&pathname); |
| 314 | if( !db_exists( |
| 315 | "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zFilePath) |
| 316 | ){ |
| 317 | printf("SKIPPED %s\n", zPath); |
| 318 | }else{ |
| 319 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath); |
| 320 | printf("DELETED %s\n", zPath); |
| 321 | } |
| 322 | blob_reset(&pathname); |
| 323 | } |
| 324 | blob_resize(&path, origSize); |
| 325 | } |
| 326 | } |
| 327 | closedir(d); |
| 328 | blob_reset(&path); |
| 329 | } |
| 330 | |
| 331 | /* |
| 332 | ** COMMAND: rm |
| 333 | ** COMMAND: delete |
| 334 | ** |
| 335 | ** Usage: %fossil rm FILE... |
| 336 | ** or: %fossil delete FILE... |
| 337 | ** |
| 338 | ** Remove one or more files from the tree. |
| 339 | ** |
| 340 | ** This command does not remove the files from disk. It just marks the |
| 341 | ** files as no longer being part of the project. In other words, future |
| 342 | ** changes to the named files will not be versioned. |
| 343 | */ |
| 344 | void delete_cmd(void){ |
| 345 | int i; |
| 346 | int vid; |
| 347 | |
| 348 | db_must_be_within_tree(); |
| 349 | vid = db_lget_int("checkout", 0); |
| 350 | if( vid==0 ){ |
| 351 | fossil_panic("no checkout to remove from"); |
| 352 | } |
| 353 | db_begin_transaction(); |
| 354 | for(i=2; i<g.argc; i++){ |
| 355 | char *zName; |
| 356 | |
| 357 | zName = mprintf("%/", g.argv[i]); |
| 358 | if( file_isdir(zName) == 1 ){ |
| 359 | del_directory_content(zName); |
| 360 | } else { |
| 361 | char *zPath; |
| 362 | Blob pathname; |
| 363 | file_tree_name(zName, &pathname, 1); |
| 364 | zPath = blob_str(&pathname); |
| 365 | if( !db_exists( |
| 366 | "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){ |
| 367 | fossil_fatal("not in the repository: %s", zName); |
| 368 | }else{ |
| 369 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath); |
| 370 | printf("DELETED %s\n", zPath); |
| 371 | } |
| 372 | blob_reset(&pathname); |
| 373 | } |
| 374 | free(zName); |
| 375 | } |
| 376 | db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0"); |
| 377 | db_end_transaction(0); |
| 378 | } |
| 379 | |
| 380 | /* |
| 381 | ** COMMAND: addremove |
| 382 | ** |
| 383 | ** Usage: %fossil addremove ?--dotfiles? ?--ignore GLOBPATTERN? ?--test? |
| 384 | ** |
| 385 | ** Do all necessary "add" and "rm" commands to synchronize the repository |
| 386 | ** with the content of the working checkout |
| 387 | ** |
| 388 | ** * All files in the checkout but not in the repository (that is, |
| 389 | ** all files displayed using the "extra" command) are added as |
| 390 | ** if by the "add" command. |
| 391 | ** |
| @@ -398,65 +364,63 @@ | |
| 398 | ** |
| 399 | ** Files and directories whose names begin with "." are ignored unless |
| 400 | ** the --dotfiles option is used. |
| 401 | ** |
| 402 | ** The --ignore option overrides the "ignore-glob" setting. See |
| 403 | ** documentation on the "setting" command for further information. |
| 404 | ** |
| 405 | ** The --test option shows what would happen without actually doing anything. |
| 406 | ** |
| 407 | ** This command can be used to track third party software. |
| 408 | */ |
| 409 | void import_cmd(void){ |
| 410 | Blob path; |
| 411 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 412 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 413 | int isTest = find_option("test",0,0)!=0; |
| 414 | int n; |
| 415 | Stmt q; |
| 416 | int vid; |
| 417 | Blob repo; |
| 418 | int nAdd = 0; |
| 419 | int nDelete = 0; |
| 420 | |
| 421 | db_must_be_within_tree(); |
| 422 | if( zIgnoreFlag==0 ){ |
| 423 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 424 | } |
| 425 | vid = db_lget_int("checkout",0); |
| 426 | if( vid==0 ){ |
| 427 | fossil_panic("no checkout to add to"); |
| 428 | } |
| 429 | db_begin_transaction(); |
| 430 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 431 | n = strlen(g.zLocalRoot); |
| 432 | blob_init(&path, g.zLocalRoot, n-1); |
| 433 | /* now we read the complete file structure into a temp table */ |
| 434 | vfile_scan(0, &path, blob_size(&path), allFlag); |
| 435 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 436 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 437 | } |
| 438 | |
| 439 | /* step 1: search for extra files */ |
| 440 | db_prepare(&q, |
| 441 | "SELECT x, %Q || x FROM sfile" |
| 442 | " WHERE x NOT IN (%s)" |
| 443 | " AND NOT %s" |
| 444 | " ORDER BY 1", |
| 445 | g.zLocalRoot, |
| 446 | fossil_all_reserved_names(), |
| 447 | glob_expr("x", zIgnoreFlag) |
| 448 | ); |
| 449 | while( db_step(&q)==SQLITE_ROW ){ |
| 450 | add_one_file(db_column_text(&q, 1), vid, 0); |
| 451 | nAdd++; |
| 452 | } |
| 453 | db_finalize(&q); |
| 454 | /* step 2: search for missing files */ |
| 455 | db_prepare(&q, |
| 456 | "SELECT pathname,%Q || pathname,deleted FROM vfile" |
| 457 | " WHERE deleted!=1" |
| 458 | " ORDER BY 1", |
| 459 | g.zLocalRoot |
| 460 | ); |
| 461 | while( db_step(&q)==SQLITE_ROW ){ |
| 462 | const char * zFile; |
| @@ -466,17 +430,17 @@ | |
| 466 | zPath = db_column_text(&q, 1); |
| 467 | if( !file_isfile_or_link(zPath) ){ |
| 468 | if( !isTest ){ |
| 469 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 470 | } |
| 471 | printf("DELETED %s\n", zFile); |
| 472 | nDelete++; |
| 473 | } |
| 474 | } |
| 475 | db_finalize(&q); |
| 476 | /* show cmmand summary */ |
| 477 | printf("added %d files, deleted %d files\n", nAdd, nDelete); |
| 478 | |
| 479 | db_end_transaction(isTest); |
| 480 | } |
| 481 | |
| 482 | |
| @@ -484,11 +448,11 @@ | |
| 484 | ** Rename a single file. |
| 485 | ** |
| 486 | ** The original name of the file is zOrig. The new filename is zNew. |
| 487 | */ |
| 488 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 489 | printf("RENAME %s %s\n", zOrig, zNew); |
| 490 | db_multi_exec( |
| 491 | "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d", |
| 492 | zNew, zOrig, vid |
| 493 | ); |
| 494 | } |
| @@ -498,15 +462,20 @@ | |
| 498 | ** COMMAND: rename |
| 499 | ** |
| 500 | ** Usage: %fossil mv|rename OLDNAME NEWNAME |
| 501 | ** or: %fossil mv|rename OLDNAME... DIR |
| 502 | ** |
| 503 | ** Move or rename one or more files within the tree |
| 504 | ** |
| 505 | ** This command does not rename the files on disk. This command merely |
| 506 | ** records the fact that filenames have changed so that appropriate notations |
| 507 | ** can be made at the next commit/checkin. |
| 508 | */ |
| 509 | void mv_cmd(void){ |
| 510 | int i; |
| 511 | int vid; |
| 512 | char *zDest; |
| @@ -553,13 +522,13 @@ | |
| 553 | zOrig = blob_str(&orig); |
| 554 | nOrig = blob_size(&orig); |
| 555 | db_prepare(&q, |
| 556 | "SELECT pathname FROM vfile" |
| 557 | " WHERE vid=%d" |
| 558 | " AND (pathname='%s' OR pathname GLOB '%s/*')" |
| 559 | " ORDER BY 1", |
| 560 | vid, zOrig, zOrig |
| 561 | ); |
| 562 | while( db_step(&q)==SQLITE_ROW ){ |
| 563 | const char *zPath = db_column_text(&q, 0); |
| 564 | int nPath = db_column_bytes(&q, 0); |
| 565 | const char *zTail; |
| 566 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -85,307 +85,273 @@ | |
| 85 | zAll = blob_str(&x); |
| 86 | } |
| 87 | return zAll; |
| 88 | } |
| 89 | |
| 90 | /* |
| 91 | ** Add a single file named zName to the VFILE table with vid. |
| 92 | ** |
| 93 | ** Omit any file whose name is pOmit. |
| 94 | */ |
| 95 | static int add_one_file( |
| 96 | const char *zPath, /* Tree-name of file to add. */ |
| 97 | int vid, /* Add to this VFILE */ |
| 98 | int caseSensitive /* True if filenames are case sensitive */ |
| 99 | ){ |
| 100 | const char *zCollate = caseSensitive ? "binary" : "nocase"; |
| 101 | if( !file_is_simple_pathname(zPath) ){ |
| 102 | fossil_fatal("filename contains illegal characters: %s", zPath); |
| 103 | } |
| 104 | if( db_exists("SELECT 1 FROM vfile" |
| 105 | " WHERE pathname=%Q COLLATE %s", zPath, zCollate) ){ |
| 106 | db_multi_exec("UPDATE vfile SET deleted=0" |
| 107 | " WHERE pathname=%Q COLLATE %s", zPath, zCollate); |
| 108 | }else{ |
| 109 | char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath); |
| 110 | db_multi_exec( |
| 111 | "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)" |
| 112 | "VALUES(%d,0,0,0,%Q,%d)", |
| 113 | vid, zPath, file_isexe(zFullname)); |
| 114 | fossil_free(zFullname); |
| 115 | } |
| 116 | if( db_changes() ){ |
| 117 | fossil_print("ADDED %s\n", zPath); |
| 118 | return 1; |
| 119 | }else{ |
| 120 | fossil_print("SKIP %s\n", zPath); |
| 121 | return 0; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /* |
| 126 | ** Add all files in the sfile temp table. |
| 127 | ** |
| 128 | ** Automatically exclude the repository file. |
| 129 | */ |
| 130 | static int add_files_in_sfile(int vid, int caseSensitive){ |
| 131 | const char *zRepo; /* Name of the repository database file */ |
| 132 | int nAdd = 0; /* Number of files added */ |
| 133 | int i; /* Loop counter */ |
| 134 | const char *zReserved; /* Name of a reserved file */ |
| 135 | Blob repoName; /* Treename of the repository */ |
| 136 | Stmt loop; /* SQL to loop over all files to add */ |
| 137 | int (*xCmp)(const char*,const char*); |
| 138 | |
| 139 | if( !file_tree_name(g.zRepositoryName, &repoName, 0) ){ |
| 140 | blob_zero(&repoName); |
| 141 | zRepo = ""; |
| 142 | }else{ |
| 143 | zRepo = blob_str(&repoName); |
| 144 | } |
| 145 | if( caseSensitive ){ |
| 146 | xCmp = fossil_strcmp; |
| 147 | }else{ |
| 148 | xCmp = fossil_stricmp; |
| 149 | db_multi_exec( |
| 150 | "CREATE INDEX IF NOT EXISTS vfile_nocase" |
| 151 | " ON vfile(pathname COLLATE nocase)" |
| 152 | ); |
| 153 | } |
| 154 | db_prepare(&loop, "SELECT x FROM sfile ORDER BY x"); |
| 155 | while( db_step(&loop)==SQLITE_ROW ){ |
| 156 | const char *zToAdd = db_column_text(&loop, 0); |
| 157 | if( fossil_strcmp(zToAdd, zRepo)==0 ) continue; |
| 158 | for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ |
| 159 | if( xCmp(zToAdd, zReserved)==0 ) break; |
| 160 | } |
| 161 | if( zReserved ) continue; |
| 162 | nAdd += add_one_file(zToAdd, vid, caseSensitive); |
| 163 | } |
| 164 | db_finalize(&loop); |
| 165 | blob_reset(&repoName); |
| 166 | return nAdd; |
| 167 | } |
| 168 | |
| 169 | /* |
| 170 | ** COMMAND: add |
| 171 | ** |
| 172 | ** Usage: %fossil add ?OPTIONS? FILE1 ?FILE2 ...? |
| 173 | ** |
| 174 | ** Make arrangements to add one or more files or directories to the |
| 175 | ** current checkout at the next commit. |
| 176 | ** |
| 177 | ** When adding files or directories recursively, filenames that begin |
| 178 | ** with "." are excluded by default. To include such files, add |
| 179 | ** the "--dotfiles" option to the command-line. |
| 180 | ** |
| 181 | ** The --ignore option is a comma-separate list of glob patterns for files |
| 182 | ** to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore option |
| 183 | ** does not appear on the command line then the "ignore-glob" setting is |
| 184 | ** used. |
| 185 | ** |
| 186 | ** SUMMARY: fossil add ?OPTIONS? FILE1 ?FILE2 ...? |
| 187 | ** Options: --dotfiles, --ignore |
| 188 | */ |
| 189 | void add_cmd(void){ |
| 190 | int i; /* Loop counter */ |
| 191 | int vid; /* Currently checked out version */ |
| 192 | int nRoot; /* Full path characters in g.zLocalRoot */ |
| 193 | const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ |
| 194 | Glob *pIgnore; /* Ignore everything matching this glob pattern */ |
| 195 | int caseSensitive; /* True if filenames are case sensitive */ |
| 196 | |
| 197 | zIgnoreFlag = find_option("ignore",0,1); |
| 198 | includeDotFiles = find_option("dotfiles",0,0)!=0; |
| 199 | capture_case_sensitive_option(); |
| 200 | db_must_be_within_tree(); |
| 201 | caseSensitive = filenames_are_case_sensitive(); |
| 202 | if( zIgnoreFlag==0 ){ |
| 203 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 204 | } |
| 205 | vid = db_lget_int("checkout",0); |
| 206 | if( vid==0 ){ |
| 207 | fossil_panic("no checkout to add to"); |
| 208 | } |
| 209 | db_begin_transaction(); |
| 210 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 211 | #if defined(_WIN32) |
| 212 | db_multi_exec( |
| 213 | "CREATE INDEX IF NOT EXISTS vfile_pathname " |
| 214 | " ON vfile(pathname COLLATE nocase)" |
| 215 | ); |
| 216 | #endif |
| 217 | pIgnore = glob_create(zIgnoreFlag); |
| 218 | nRoot = strlen(g.zLocalRoot); |
| 219 | |
| 220 | /* Load the names of all files that are to be added into sfile temp table */ |
| 221 | for(i=2; i<g.argc; i++){ |
| 222 | char *zName; |
| 223 | int isDir; |
| 224 | Blob fullName; |
| 225 | |
| 226 | file_canonical_name(g.argv[i], &fullName); |
| 227 | zName = blob_str(&fullName); |
| 228 | isDir = file_isdir(zName); |
| 229 | if( isDir==1 ){ |
| 230 | vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore); |
| 231 | }else if( isDir==0 ){ |
| 232 | fossil_fatal("not found: %s", zName); |
| 233 | }else if( file_access(zName, R_OK) ){ |
| 234 | fossil_fatal("cannot open %s", zName); |
| 235 | }else{ |
| 236 | char *zTreeName = &zName[nRoot]; |
| 237 | db_multi_exec( |
| 238 | "INSERT OR IGNORE INTO sfile(x)" |
| 239 | " SELECT %Q WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE pathname=%Q)", |
| 240 | zTreeName, zTreeName |
| 241 | ); |
| 242 | } |
| 243 | blob_reset(&fullName); |
| 244 | } |
| 245 | glob_free(pIgnore); |
| 246 | |
| 247 | add_files_in_sfile(vid, caseSensitive); |
| 248 | db_end_transaction(0); |
| 249 | } |
| 250 | |
| 251 | /* |
| 252 | ** COMMAND: rm |
| 253 | ** COMMAND: delete |
| 254 | ** |
| 255 | ** Usage: %fossil rm FILE1 ?FILE2 ...? |
| 256 | ** or: %fossil delete FILE1 ?FILE2 ...? |
| 257 | ** |
| 258 | ** Remove one or more files or directories from the repository. |
| 259 | ** |
| 260 | ** This command does NOT remove the files from disk. It just marks the |
| 261 | ** files as no longer being part of the project. In other words, future |
| 262 | ** changes to the named files will not be versioned. |
| 263 | ** |
| 264 | ** SUMMARY: fossil rm FILE1 ?FILE2 ...? |
| 265 | ** or: fossil delete FILE1 ?FILE2 ...? |
| 266 | */ |
| 267 | void delete_cmd(void){ |
| 268 | int i; |
| 269 | int vid; |
| 270 | Stmt loop; |
| 271 | |
| 272 | db_must_be_within_tree(); |
| 273 | vid = db_lget_int("checkout", 0); |
| 274 | if( vid==0 ){ |
| 275 | fossil_panic("no checkout to remove from"); |
| 276 | } |
| 277 | db_begin_transaction(); |
| 278 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 279 | for(i=2; i<g.argc; i++){ |
| 280 | Blob treeName; |
| 281 | char *zTreeName; |
| 282 | |
| 283 | file_tree_name(g.argv[i], &treeName, 1); |
| 284 | zTreeName = blob_str(&treeName); |
| 285 | db_multi_exec( |
| 286 | "INSERT OR IGNORE INTO sfile" |
| 287 | " SELECT pathname FROM vfile" |
| 288 | " WHERE (pathname=%Q" |
| 289 | " OR (pathname>'%q/' AND pathname<'%q0'))" |
| 290 | " AND NOT deleted", |
| 291 | zTreeName, zTreeName, zTreeName |
| 292 | ); |
| 293 | blob_reset(&treeName); |
| 294 | } |
| 295 | |
| 296 | db_prepare(&loop, "SELECT x FROM sfile"); |
| 297 | while( db_step(&loop)==SQLITE_ROW ){ |
| 298 | fossil_print("DELETED %s\n", db_column_text(&loop, 0)); |
| 299 | } |
| 300 | db_finalize(&loop); |
| 301 | db_multi_exec( |
| 302 | "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;" |
| 303 | "DELETE FROM vfile WHERE rid=0 AND deleted;" |
| 304 | ); |
| 305 | db_end_transaction(0); |
| 306 | } |
| 307 | |
| 308 | /* |
| 309 | ** Capture the command-line --case-sensitive option. |
| 310 | */ |
| 311 | static const char *zCaseSensitive = 0; |
| 312 | void capture_case_sensitive_option(void){ |
| 313 | if( zCaseSensitive==0 ){ |
| 314 | zCaseSensitive = find_option("case-sensitive",0,1); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | /* |
| 319 | ** This routine determines if files should be case-sensitive or not. |
| 320 | ** In other words, this routine determines if two filenames that |
| 321 | ** differ only in case should be considered the same name or not. |
| 322 | ** |
| 323 | ** The case-sensitive setting determines the default value. If |
| 324 | ** the case-sensitive setting is undefined, then case sensitivity |
| 325 | ** defaults on for Mac and Windows and off for all other unix. |
| 326 | ** |
| 327 | ** The --case-sensitive BOOLEAN command-line option overrides any |
| 328 | ** setting. |
| 329 | */ |
| 330 | int filenames_are_case_sensitive(void){ |
| 331 | int caseSensitive; |
| 332 | |
| 333 | if( zCaseSensitive ){ |
| 334 | caseSensitive = is_truth(zCaseSensitive); |
| 335 | }else{ |
| 336 | #if !defined(_WIN32) && !defined(__DARWIN__) && !defined(__APPLE__) |
| 337 | caseSensitive = 1; |
| 338 | #else |
| 339 | caseSensitive = 0; |
| 340 | #endif |
| 341 | caseSensitive = db_get_boolean("case-sensitive",caseSensitive); |
| 342 | } |
| 343 | return caseSensitive; |
| 344 | } |
| 345 | |
| 346 | /* |
| 347 | ** COMMAND: addremove |
| 348 | ** |
| 349 | ** Usage: %fossil addremove ?--dotfiles? ?--ignore GLOBPATTERN? ?--test? |
| 350 | ** |
| 351 | ** Do all necessary "add" and "rm" commands to synchronize the repository |
| 352 | ** with the content of the working checkout: |
| 353 | ** |
| 354 | ** * All files in the checkout but not in the repository (that is, |
| 355 | ** all files displayed using the "extra" command) are added as |
| 356 | ** if by the "add" command. |
| 357 | ** |
| @@ -398,65 +364,63 @@ | |
| 364 | ** |
| 365 | ** Files and directories whose names begin with "." are ignored unless |
| 366 | ** the --dotfiles option is used. |
| 367 | ** |
| 368 | ** The --ignore option overrides the "ignore-glob" setting. See |
| 369 | ** documentation on the "settings" command for further information. |
| 370 | ** |
| 371 | ** The --test option shows what would happen without actually doing anything. |
| 372 | ** |
| 373 | ** This command can be used to track third party software. |
| 374 | ** |
| 375 | ** SUMMARY: fossil addremove |
| 376 | ** Options: ?--dotfiles? ?--ignore GLOB? ?--test? ?--case-sensitive BOOL? |
| 377 | */ |
| 378 | void addremove_cmd(void){ |
| 379 | Blob path; |
| 380 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 381 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 382 | int isTest = find_option("test",0,0)!=0; |
| 383 | int caseSensitive; |
| 384 | int n; |
| 385 | Stmt q; |
| 386 | int vid; |
| 387 | int nAdd = 0; |
| 388 | int nDelete = 0; |
| 389 | Glob *pIgnore; |
| 390 | |
| 391 | capture_case_sensitive_option(); |
| 392 | db_must_be_within_tree(); |
| 393 | caseSensitive = filenames_are_case_sensitive(); |
| 394 | if( zIgnoreFlag==0 ){ |
| 395 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 396 | } |
| 397 | vid = db_lget_int("checkout",0); |
| 398 | if( vid==0 ){ |
| 399 | fossil_panic("no checkout to add to"); |
| 400 | } |
| 401 | db_begin_transaction(); |
| 402 | |
| 403 | /* step 1: |
| 404 | ** Populate the temp table "sfile" with the names of all unmanged |
| 405 | ** files currently in the check-out, except for files that match the |
| 406 | ** --ignore or ignore-glob patterns and dot-files. Then add all of |
| 407 | ** the files in the sfile temp table to the set of managed files. |
| 408 | */ |
| 409 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 410 | n = strlen(g.zLocalRoot); |
| 411 | blob_init(&path, g.zLocalRoot, n-1); |
| 412 | /* now we read the complete file structure into a temp table */ |
| 413 | pIgnore = glob_create(zIgnoreFlag); |
| 414 | vfile_scan(&path, blob_size(&path), allFlag, pIgnore); |
| 415 | glob_free(pIgnore); |
| 416 | nAdd = add_files_in_sfile(vid, caseSensitive); |
| 417 | |
| 418 | /* step 2: search for missing files */ |
| 419 | db_prepare(&q, |
| 420 | "SELECT pathname, %Q || pathname, deleted FROM vfile" |
| 421 | " WHERE NOT deleted" |
| 422 | " ORDER BY 1", |
| 423 | g.zLocalRoot |
| 424 | ); |
| 425 | while( db_step(&q)==SQLITE_ROW ){ |
| 426 | const char * zFile; |
| @@ -466,17 +430,17 @@ | |
| 430 | zPath = db_column_text(&q, 1); |
| 431 | if( !file_isfile_or_link(zPath) ){ |
| 432 | if( !isTest ){ |
| 433 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 434 | } |
| 435 | fossil_print("DELETED %s\n", zFile); |
| 436 | nDelete++; |
| 437 | } |
| 438 | } |
| 439 | db_finalize(&q); |
| 440 | /* show cmmand summary */ |
| 441 | fossil_print("added %d files, deleted %d files\n", nAdd, nDelete); |
| 442 | |
| 443 | db_end_transaction(isTest); |
| 444 | } |
| 445 | |
| 446 | |
| @@ -484,11 +448,11 @@ | |
| 448 | ** Rename a single file. |
| 449 | ** |
| 450 | ** The original name of the file is zOrig. The new filename is zNew. |
| 451 | */ |
| 452 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 453 | fossil_print("RENAME %s %s\n", zOrig, zNew); |
| 454 | db_multi_exec( |
| 455 | "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d", |
| 456 | zNew, zOrig, vid |
| 457 | ); |
| 458 | } |
| @@ -498,15 +462,20 @@ | |
| 462 | ** COMMAND: rename |
| 463 | ** |
| 464 | ** Usage: %fossil mv|rename OLDNAME NEWNAME |
| 465 | ** or: %fossil mv|rename OLDNAME... DIR |
| 466 | ** |
| 467 | ** Move or rename one or more files or directories within the repository tree. |
| 468 | ** You can either rename a file or directory or move it to another subdirectory. |
| 469 | ** |
| 470 | ** This command does NOT rename or move the files on disk. This command merely |
| 471 | ** records the fact that filenames have changed so that appropriate notations |
| 472 | ** can be made at the next commit/checkin. |
| 473 | ** |
| 474 | ** |
| 475 | ** SUMMARY: fossil mv|rename OLDNAME NEWNAME |
| 476 | ** or: fossil mv|rename OLDNAME... DIR |
| 477 | */ |
| 478 | void mv_cmd(void){ |
| 479 | int i; |
| 480 | int vid; |
| 481 | char *zDest; |
| @@ -553,13 +522,13 @@ | |
| 522 | zOrig = blob_str(&orig); |
| 523 | nOrig = blob_size(&orig); |
| 524 | db_prepare(&q, |
| 525 | "SELECT pathname FROM vfile" |
| 526 | " WHERE vid=%d" |
| 527 | " AND (pathname='%q' OR (pathname>'%q/' AND pathname<'%q0'))" |
| 528 | " ORDER BY 1", |
| 529 | vid, zOrig, zOrig, zOrig |
| 530 | ); |
| 531 | while( db_step(&q)==SQLITE_ROW ){ |
| 532 | const char *zPath = db_column_text(&q, 0); |
| 533 | int nPath = db_column_bytes(&q, 0); |
| 534 | const char *zTail; |
| 535 |
+224
-255
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -85,307 +85,273 @@ | ||
| 85 | 85 | zAll = blob_str(&x); |
| 86 | 86 | } |
| 87 | 87 | return zAll; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - | |
| 91 | -/* | |
| 92 | -** The pIgnore statement is query of the form: | |
| 93 | -** | |
| 94 | -** SELECT (:x GLOB ... OR :x GLOB ... OR ...) | |
| 95 | -** | |
| 96 | -** In other words, it is a query that returns true if the :x value | |
| 97 | -** should be ignored. Evaluate the query and return true to ignore | |
| 98 | -** and false to not ignore. | |
| 99 | -** | |
| 100 | -** If pIgnore is NULL, then do not ignore. | |
| 101 | -*/ | |
| 102 | -static int shouldBeIgnored(Stmt *pIgnore, const char *zName){ | |
| 103 | - int rc = 0; | |
| 104 | - if( pIgnore ){ | |
| 105 | - db_bind_text(pIgnore, ":x", zName); | |
| 106 | - db_step(pIgnore); | |
| 107 | - rc = db_column_int(pIgnore, 0); | |
| 108 | - db_reset(pIgnore); | |
| 109 | - } | |
| 110 | - return rc; | |
| 111 | -} | |
| 112 | - | |
| 113 | - | |
| 114 | 90 | /* |
| 115 | 91 | ** Add a single file named zName to the VFILE table with vid. |
| 116 | 92 | ** |
| 117 | 93 | ** Omit any file whose name is pOmit. |
| 118 | 94 | */ |
| 119 | -static void add_one_file( | |
| 120 | - const char *zName, /* Name of file to add */ | |
| 95 | +static int add_one_file( | |
| 96 | + const char *zPath, /* Tree-name of file to add. */ | |
| 121 | 97 | int vid, /* Add to this VFILE */ |
| 122 | - Blob *pOmit | |
| 98 | + int caseSensitive /* True if filenames are case sensitive */ | |
| 123 | 99 | ){ |
| 124 | - Blob pathname; | |
| 125 | - const char *zPath; | |
| 126 | - int i; | |
| 127 | - const char *zReserved; | |
| 128 | - | |
| 129 | - file_tree_name(zName, &pathname, 1); | |
| 130 | - zPath = blob_str(&pathname); | |
| 131 | - for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ | |
| 132 | - if( fossil_strcmp(zPath, zReserved)==0 ) break; | |
| 133 | - } | |
| 134 | - if( zReserved || (pOmit && blob_compare(&pathname, pOmit)==0) ){ | |
| 135 | - fossil_warning("cannot add %s", zPath); | |
| 100 | + const char *zCollate = caseSensitive ? "binary" : "nocase"; | |
| 101 | + if( !file_is_simple_pathname(zPath) ){ | |
| 102 | + fossil_fatal("filename contains illegal characters: %s", zPath); | |
| 103 | + } | |
| 104 | + if( db_exists("SELECT 1 FROM vfile" | |
| 105 | + " WHERE pathname=%Q COLLATE %s", zPath, zCollate) ){ | |
| 106 | + db_multi_exec("UPDATE vfile SET deleted=0" | |
| 107 | + " WHERE pathname=%Q COLLATE %s", zPath, zCollate); | |
| 108 | + }else{ | |
| 109 | + char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath); | |
| 110 | + db_multi_exec( | |
| 111 | + "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)" | |
| 112 | + "VALUES(%d,0,0,0,%Q,%d)", | |
| 113 | + vid, zPath, file_isexe(zFullname)); | |
| 114 | + fossil_free(zFullname); | |
| 115 | + } | |
| 116 | + if( db_changes() ){ | |
| 117 | + fossil_print("ADDED %s\n", zPath); | |
| 118 | + return 1; | |
| 119 | + }else{ | |
| 120 | + fossil_print("SKIP %s\n", zPath); | |
| 121 | + return 0; | |
| 122 | + } | |
| 123 | +} | |
| 124 | + | |
| 125 | +/* | |
| 126 | +** Add all files in the sfile temp table. | |
| 127 | +** | |
| 128 | +** Automatically exclude the repository file. | |
| 129 | +*/ | |
| 130 | +static int add_files_in_sfile(int vid, int caseSensitive){ | |
| 131 | + const char *zRepo; /* Name of the repository database file */ | |
| 132 | + int nAdd = 0; /* Number of files added */ | |
| 133 | + int i; /* Loop counter */ | |
| 134 | + const char *zReserved; /* Name of a reserved file */ | |
| 135 | + Blob repoName; /* Treename of the repository */ | |
| 136 | + Stmt loop; /* SQL to loop over all files to add */ | |
| 137 | + int (*xCmp)(const char*,const char*); | |
| 138 | + | |
| 139 | + if( !file_tree_name(g.zRepositoryName, &repoName, 0) ){ | |
| 140 | + blob_zero(&repoName); | |
| 141 | + zRepo = ""; | |
| 142 | + }else{ | |
| 143 | + zRepo = blob_str(&repoName); | |
| 144 | + } | |
| 145 | + if( caseSensitive ){ | |
| 146 | + xCmp = fossil_strcmp; | |
| 136 | 147 | }else{ |
| 137 | - if( !file_is_simple_pathname(zPath) ){ | |
| 138 | - fossil_fatal("filename contains illegal characters: %s", zPath); | |
| 139 | - } | |
| 140 | -#if defined(_WIN32) | |
| 141 | - if( db_exists("SELECT 1 FROM vfile" | |
| 142 | - " WHERE pathname=%Q COLLATE nocase", zPath) ){ | |
| 143 | - db_multi_exec("UPDATE vfile SET deleted=0" | |
| 144 | - " WHERE pathname=%Q COLLATE nocase", zPath); | |
| 145 | - } | |
| 146 | -#else | |
| 147 | - if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){ | |
| 148 | - db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath); | |
| 149 | - } | |
| 150 | -#endif | |
| 151 | - else{ | |
| 152 | - db_multi_exec( | |
| 153 | - "INSERT INTO vfile(vid,deleted,rid,mrid,pathname)" | |
| 154 | - "VALUES(%d,0,0,0,%Q)", vid, zPath); | |
| 155 | - } | |
| 156 | - printf("ADDED %s\n", zPath); | |
| 157 | - } | |
| 158 | - blob_reset(&pathname); | |
| 159 | -} | |
| 160 | - | |
| 161 | -/* | |
| 162 | -** All content of the zDir directory to the SFILE table. | |
| 163 | -*/ | |
| 164 | -void add_directory_content(const char *zDir, Stmt *pIgnore){ | |
| 165 | - DIR *d; | |
| 166 | - int origSize; | |
| 167 | - struct dirent *pEntry; | |
| 168 | - Blob path; | |
| 169 | - | |
| 170 | - blob_zero(&path); | |
| 171 | - blob_append(&path, zDir, -1); | |
| 172 | - origSize = blob_size(&path); | |
| 173 | - d = opendir(zDir); | |
| 174 | - if( d ){ | |
| 175 | - while( (pEntry=readdir(d))!=0 ){ | |
| 176 | - char *zPath; | |
| 177 | - if( pEntry->d_name[0]=='.' ){ | |
| 178 | - if( !includeDotFiles ) continue; | |
| 179 | - if( pEntry->d_name[1]==0 ) continue; | |
| 180 | - if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; | |
| 181 | - } | |
| 182 | - blob_appendf(&path, "/%s", pEntry->d_name); | |
| 183 | - zPath = blob_str(&path); | |
| 184 | - if( shouldBeIgnored(pIgnore, zPath) ){ | |
| 185 | - /* Noop */ | |
| 186 | - }else if( file_isdir(zPath)==1 ){ | |
| 187 | - add_directory_content(zPath, pIgnore); | |
| 188 | - }else if( file_isfile_or_link(zPath) ){ | |
| 189 | - db_multi_exec("INSERT INTO sfile VALUES(%Q)", zPath); | |
| 190 | - } | |
| 191 | - blob_resize(&path, origSize); | |
| 192 | - } | |
| 193 | - } | |
| 194 | - closedir(d); | |
| 195 | - blob_reset(&path); | |
| 196 | -} | |
| 197 | - | |
| 198 | -/* | |
| 199 | -** Add all content of a directory. | |
| 200 | -*/ | |
| 201 | -void add_directory(const char *zDir, int vid, Blob *pOmit, Stmt *pIgnore){ | |
| 202 | - Stmt q; | |
| 203 | - add_directory_content(zDir, pIgnore); | |
| 204 | - db_prepare(&q, "SELECT x FROM sfile ORDER BY x"); | |
| 205 | - while( db_step(&q)==SQLITE_ROW ){ | |
| 206 | - const char *zName = db_column_text(&q, 0); | |
| 207 | - add_one_file(zName, vid, pOmit); | |
| 208 | - } | |
| 209 | - db_finalize(&q); | |
| 210 | - db_multi_exec("DELETE FROM sfile"); | |
| 148 | + xCmp = fossil_stricmp; | |
| 149 | + db_multi_exec( | |
| 150 | + "CREATE INDEX IF NOT EXISTS vfile_nocase" | |
| 151 | + " ON vfile(pathname COLLATE nocase)" | |
| 152 | + ); | |
| 153 | + } | |
| 154 | + db_prepare(&loop, "SELECT x FROM sfile ORDER BY x"); | |
| 155 | + while( db_step(&loop)==SQLITE_ROW ){ | |
| 156 | + const char *zToAdd = db_column_text(&loop, 0); | |
| 157 | + if( fossil_strcmp(zToAdd, zRepo)==0 ) continue; | |
| 158 | + for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ | |
| 159 | + if( xCmp(zToAdd, zReserved)==0 ) break; | |
| 160 | + } | |
| 161 | + if( zReserved ) continue; | |
| 162 | + nAdd += add_one_file(zToAdd, vid, caseSensitive); | |
| 163 | + } | |
| 164 | + db_finalize(&loop); | |
| 165 | + blob_reset(&repoName); | |
| 166 | + return nAdd; | |
| 211 | 167 | } |
| 212 | 168 | |
| 213 | 169 | /* |
| 214 | 170 | ** COMMAND: add |
| 215 | 171 | ** |
| 216 | -** Usage: %fossil add FILE... | |
| 217 | -** | |
| 218 | -** Make arrangements to add one or more files to the current checkout | |
| 219 | -** at the next commit. | |
| 220 | -** | |
| 221 | -** When adding files recursively, filenames that begin with "." are | |
| 222 | -** excluded by default. To include such files, add the "--dotfiles" | |
| 223 | -** option to the command-line. | |
| 224 | -** | |
| 225 | -** The --ignore option overrides the "ignore-glob" setting. See | |
| 226 | -** documentation on the "setting" command for further information. | |
| 172 | +** Usage: %fossil add ?OPTIONS? FILE1 ?FILE2 ...? | |
| 173 | +** | |
| 174 | +** Make arrangements to add one or more files or directories to the | |
| 175 | +** current checkout at the next commit. | |
| 176 | +** | |
| 177 | +** When adding files or directories recursively, filenames that begin | |
| 178 | +** with "." are excluded by default. To include such files, add | |
| 179 | +** the "--dotfiles" option to the command-line. | |
| 180 | +** | |
| 181 | +** The --ignore option is a comma-separate list of glob patterns for files | |
| 182 | +** to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore option | |
| 183 | +** does not appear on the command line then the "ignore-glob" setting is | |
| 184 | +** used. | |
| 185 | +** | |
| 186 | +** SUMMARY: fossil add ?OPTIONS? FILE1 ?FILE2 ...? | |
| 187 | +** Options: --dotfiles, --ignore | |
| 227 | 188 | */ |
| 228 | 189 | void add_cmd(void){ |
| 229 | - int i; | |
| 230 | - int vid; | |
| 231 | - const char *zIgnoreFlag; | |
| 232 | - Blob repo; | |
| 233 | - Stmt ignoreTest; /* Test to see if a name should be ignored */ | |
| 234 | - Stmt *pIgnore; /* Pointer to ignoreTest or to NULL */ | |
| 190 | + int i; /* Loop counter */ | |
| 191 | + int vid; /* Currently checked out version */ | |
| 192 | + int nRoot; /* Full path characters in g.zLocalRoot */ | |
| 193 | + const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ | |
| 194 | + Glob *pIgnore; /* Ignore everything matching this glob pattern */ | |
| 195 | + int caseSensitive; /* True if filenames are case sensitive */ | |
| 235 | 196 | |
| 236 | 197 | zIgnoreFlag = find_option("ignore",0,1); |
| 237 | 198 | includeDotFiles = find_option("dotfiles",0,0)!=0; |
| 199 | + capture_case_sensitive_option(); | |
| 238 | 200 | db_must_be_within_tree(); |
| 201 | + caseSensitive = filenames_are_case_sensitive(); | |
| 239 | 202 | if( zIgnoreFlag==0 ){ |
| 240 | 203 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 241 | 204 | } |
| 242 | 205 | vid = db_lget_int("checkout",0); |
| 243 | 206 | if( vid==0 ){ |
| 244 | 207 | fossil_panic("no checkout to add to"); |
| 245 | 208 | } |
| 246 | 209 | db_begin_transaction(); |
| 247 | - if( !file_tree_name(g.zRepositoryName, &repo, 0) ){ | |
| 248 | - blob_zero(&repo); | |
| 249 | - } | |
| 250 | 210 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 251 | 211 | #if defined(_WIN32) |
| 252 | 212 | db_multi_exec( |
| 253 | 213 | "CREATE INDEX IF NOT EXISTS vfile_pathname " |
| 254 | 214 | " ON vfile(pathname COLLATE nocase)" |
| 255 | 215 | ); |
| 256 | 216 | #endif |
| 257 | - if( zIgnoreFlag && zIgnoreFlag[0] ){ | |
| 258 | - db_prepare(&ignoreTest, "SELECT %s", glob_expr(":x", zIgnoreFlag)); | |
| 259 | - pIgnore = &ignoreTest; | |
| 260 | - }else{ | |
| 261 | - pIgnore = 0; | |
| 262 | - } | |
| 217 | + pIgnore = glob_create(zIgnoreFlag); | |
| 218 | + nRoot = strlen(g.zLocalRoot); | |
| 219 | + | |
| 220 | + /* Load the names of all files that are to be added into sfile temp table */ | |
| 263 | 221 | for(i=2; i<g.argc; i++){ |
| 264 | 222 | char *zName; |
| 265 | 223 | int isDir; |
| 224 | + Blob fullName; | |
| 266 | 225 | |
| 267 | - zName = mprintf("%/", g.argv[i]); | |
| 226 | + file_canonical_name(g.argv[i], &fullName); | |
| 227 | + zName = blob_str(&fullName); | |
| 268 | 228 | isDir = file_isdir(zName); |
| 269 | 229 | if( isDir==1 ){ |
| 270 | - add_directory(zName, vid, &repo, pIgnore); | |
| 230 | + vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore); | |
| 271 | 231 | }else if( isDir==0 ){ |
| 272 | 232 | fossil_fatal("not found: %s", zName); |
| 273 | - }else if( access(zName, R_OK) ){ | |
| 233 | + }else if( file_access(zName, R_OK) ){ | |
| 274 | 234 | fossil_fatal("cannot open %s", zName); |
| 275 | 235 | }else{ |
| 276 | - add_one_file(zName, vid, &repo); | |
| 277 | - } | |
| 278 | - free(zName); | |
| 279 | - } | |
| 280 | - if( pIgnore ) db_finalize(pIgnore); | |
| 281 | - db_end_transaction(0); | |
| 282 | -} | |
| 283 | - | |
| 284 | -/* | |
| 285 | -** Remove all contents of zDir | |
| 286 | -*/ | |
| 287 | -void del_directory_content(const char *zDir){ | |
| 288 | - DIR *d; | |
| 289 | - int origSize; | |
| 290 | - struct dirent *pEntry; | |
| 291 | - Blob path; | |
| 292 | - | |
| 293 | - blob_zero(&path); | |
| 294 | - blob_append(&path, zDir, -1); | |
| 295 | - origSize = blob_size(&path); | |
| 296 | - d = opendir(zDir); | |
| 297 | - if( d ){ | |
| 298 | - while( (pEntry=readdir(d))!=0 ){ | |
| 299 | - char *zPath; | |
| 300 | - if( pEntry->d_name[0]=='.'){ | |
| 301 | - if( !includeDotFiles ) continue; | |
| 302 | - if( pEntry->d_name[1]==0 ) continue; | |
| 303 | - if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; | |
| 304 | - } | |
| 305 | - blob_appendf(&path, "/%s", pEntry->d_name); | |
| 306 | - zPath = blob_str(&path); | |
| 307 | - if( file_isdir(zPath)==1 ){ | |
| 308 | - del_directory_content(zPath); | |
| 309 | - }else if( file_isfile_or_link(zPath) ){ | |
| 310 | - char *zFilePath; | |
| 311 | - Blob pathname; | |
| 312 | - file_tree_name(zPath, &pathname, 1); | |
| 313 | - zFilePath = blob_str(&pathname); | |
| 314 | - if( !db_exists( | |
| 315 | - "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zFilePath) | |
| 316 | - ){ | |
| 317 | - printf("SKIPPED %s\n", zPath); | |
| 318 | - }else{ | |
| 319 | - db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath); | |
| 320 | - printf("DELETED %s\n", zPath); | |
| 321 | - } | |
| 322 | - blob_reset(&pathname); | |
| 323 | - } | |
| 324 | - blob_resize(&path, origSize); | |
| 325 | - } | |
| 326 | - } | |
| 327 | - closedir(d); | |
| 328 | - blob_reset(&path); | |
| 236 | + char *zTreeName = &zName[nRoot]; | |
| 237 | + db_multi_exec( | |
| 238 | + "INSERT OR IGNORE INTO sfile(x)" | |
| 239 | + " SELECT %Q WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE pathname=%Q)", | |
| 240 | + zTreeName, zTreeName | |
| 241 | + ); | |
| 242 | + } | |
| 243 | + blob_reset(&fullName); | |
| 244 | + } | |
| 245 | + glob_free(pIgnore); | |
| 246 | + | |
| 247 | + add_files_in_sfile(vid, caseSensitive); | |
| 248 | + db_end_transaction(0); | |
| 329 | 249 | } |
| 330 | 250 | |
| 331 | 251 | /* |
| 332 | 252 | ** COMMAND: rm |
| 333 | 253 | ** COMMAND: delete |
| 334 | 254 | ** |
| 335 | -** Usage: %fossil rm FILE... | |
| 336 | -** or: %fossil delete FILE... | |
| 255 | +** Usage: %fossil rm FILE1 ?FILE2 ...? | |
| 256 | +** or: %fossil delete FILE1 ?FILE2 ...? | |
| 337 | 257 | ** |
| 338 | -** Remove one or more files from the tree. | |
| 258 | +** Remove one or more files or directories from the repository. | |
| 339 | 259 | ** |
| 340 | -** This command does not remove the files from disk. It just marks the | |
| 260 | +** This command does NOT remove the files from disk. It just marks the | |
| 341 | 261 | ** files as no longer being part of the project. In other words, future |
| 342 | 262 | ** changes to the named files will not be versioned. |
| 263 | +** | |
| 264 | +** SUMMARY: fossil rm FILE1 ?FILE2 ...? | |
| 265 | +** or: fossil delete FILE1 ?FILE2 ...? | |
| 343 | 266 | */ |
| 344 | 267 | void delete_cmd(void){ |
| 345 | 268 | int i; |
| 346 | 269 | int vid; |
| 270 | + Stmt loop; | |
| 347 | 271 | |
| 348 | 272 | db_must_be_within_tree(); |
| 349 | 273 | vid = db_lget_int("checkout", 0); |
| 350 | 274 | if( vid==0 ){ |
| 351 | 275 | fossil_panic("no checkout to remove from"); |
| 352 | 276 | } |
| 353 | 277 | db_begin_transaction(); |
| 278 | + db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); | |
| 354 | 279 | for(i=2; i<g.argc; i++){ |
| 355 | - char *zName; | |
| 356 | - | |
| 357 | - zName = mprintf("%/", g.argv[i]); | |
| 358 | - if( file_isdir(zName) == 1 ){ | |
| 359 | - del_directory_content(zName); | |
| 360 | - } else { | |
| 361 | - char *zPath; | |
| 362 | - Blob pathname; | |
| 363 | - file_tree_name(zName, &pathname, 1); | |
| 364 | - zPath = blob_str(&pathname); | |
| 365 | - if( !db_exists( | |
| 366 | - "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){ | |
| 367 | - fossil_fatal("not in the repository: %s", zName); | |
| 368 | - }else{ | |
| 369 | - db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath); | |
| 370 | - printf("DELETED %s\n", zPath); | |
| 371 | - } | |
| 372 | - blob_reset(&pathname); | |
| 373 | - } | |
| 374 | - free(zName); | |
| 375 | - } | |
| 376 | - db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0"); | |
| 280 | + Blob treeName; | |
| 281 | + char *zTreeName; | |
| 282 | + | |
| 283 | + file_tree_name(g.argv[i], &treeName, 1); | |
| 284 | + zTreeName = blob_str(&treeName); | |
| 285 | + db_multi_exec( | |
| 286 | + "INSERT OR IGNORE INTO sfile" | |
| 287 | + " SELECT pathname FROM vfile" | |
| 288 | + " WHERE (pathname=%Q" | |
| 289 | + " OR (pathname>'%q/' AND pathname<'%q0'))" | |
| 290 | + " AND NOT deleted", | |
| 291 | + zTreeName, zTreeName, zTreeName | |
| 292 | + ); | |
| 293 | + blob_reset(&treeName); | |
| 294 | + } | |
| 295 | + | |
| 296 | + db_prepare(&loop, "SELECT x FROM sfile"); | |
| 297 | + while( db_step(&loop)==SQLITE_ROW ){ | |
| 298 | + fossil_print("DELETED %s\n", db_column_text(&loop, 0)); | |
| 299 | + } | |
| 300 | + db_finalize(&loop); | |
| 301 | + db_multi_exec( | |
| 302 | + "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;" | |
| 303 | + "DELETE FROM vfile WHERE rid=0 AND deleted;" | |
| 304 | + ); | |
| 377 | 305 | db_end_transaction(0); |
| 378 | 306 | } |
| 307 | + | |
| 308 | +/* | |
| 309 | +** Capture the command-line --case-sensitive option. | |
| 310 | +*/ | |
| 311 | +static const char *zCaseSensitive = 0; | |
| 312 | +void capture_case_sensitive_option(void){ | |
| 313 | + if( zCaseSensitive==0 ){ | |
| 314 | + zCaseSensitive = find_option("case-sensitive",0,1); | |
| 315 | + } | |
| 316 | +} | |
| 317 | + | |
| 318 | +/* | |
| 319 | +** This routine determines if files should be case-sensitive or not. | |
| 320 | +** In other words, this routine determines if two filenames that | |
| 321 | +** differ only in case should be considered the same name or not. | |
| 322 | +** | |
| 323 | +** The case-sensitive setting determines the default value. If | |
| 324 | +** the case-sensitive setting is undefined, then case sensitivity | |
| 325 | +** defaults on for Mac and Windows and off for all other unix. | |
| 326 | +** | |
| 327 | +** The --case-sensitive BOOLEAN command-line option overrides any | |
| 328 | +** setting. | |
| 329 | +*/ | |
| 330 | +int filenames_are_case_sensitive(void){ | |
| 331 | + int caseSensitive; | |
| 332 | + | |
| 333 | + if( zCaseSensitive ){ | |
| 334 | + caseSensitive = is_truth(zCaseSensitive); | |
| 335 | + }else{ | |
| 336 | +#if !defined(_WIN32) && !defined(__DARWIN__) && !defined(__APPLE__) | |
| 337 | + caseSensitive = 1; | |
| 338 | +#else | |
| 339 | + caseSensitive = 0; | |
| 340 | +#endif | |
| 341 | + caseSensitive = db_get_boolean("case-sensitive",caseSensitive); | |
| 342 | + } | |
| 343 | + return caseSensitive; | |
| 344 | +} | |
| 379 | 345 | |
| 380 | 346 | /* |
| 381 | 347 | ** COMMAND: addremove |
| 382 | 348 | ** |
| 383 | 349 | ** Usage: %fossil addremove ?--dotfiles? ?--ignore GLOBPATTERN? ?--test? |
| 384 | 350 | ** |
| 385 | 351 | ** Do all necessary "add" and "rm" commands to synchronize the repository |
| 386 | -** with the content of the working checkout | |
| 352 | +** with the content of the working checkout: | |
| 387 | 353 | ** |
| 388 | 354 | ** * All files in the checkout but not in the repository (that is, |
| 389 | 355 | ** all files displayed using the "extra" command) are added as |
| 390 | 356 | ** if by the "add" command. |
| 391 | 357 | ** |
| @@ -398,65 +364,63 @@ | ||
| 398 | 364 | ** |
| 399 | 365 | ** Files and directories whose names begin with "." are ignored unless |
| 400 | 366 | ** the --dotfiles option is used. |
| 401 | 367 | ** |
| 402 | 368 | ** The --ignore option overrides the "ignore-glob" setting. See |
| 403 | -** documentation on the "setting" command for further information. | |
| 369 | +** documentation on the "settings" command for further information. | |
| 404 | 370 | ** |
| 405 | 371 | ** The --test option shows what would happen without actually doing anything. |
| 406 | 372 | ** |
| 407 | 373 | ** This command can be used to track third party software. |
| 374 | +** | |
| 375 | +** SUMMARY: fossil addremove | |
| 376 | +** Options: ?--dotfiles? ?--ignore GLOB? ?--test? ?--case-sensitive BOOL? | |
| 408 | 377 | */ |
| 409 | -void import_cmd(void){ | |
| 378 | +void addremove_cmd(void){ | |
| 410 | 379 | Blob path; |
| 411 | 380 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 412 | 381 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 413 | 382 | int isTest = find_option("test",0,0)!=0; |
| 383 | + int caseSensitive; | |
| 414 | 384 | int n; |
| 415 | 385 | Stmt q; |
| 416 | 386 | int vid; |
| 417 | - Blob repo; | |
| 418 | 387 | int nAdd = 0; |
| 419 | 388 | int nDelete = 0; |
| 389 | + Glob *pIgnore; | |
| 420 | 390 | |
| 391 | + capture_case_sensitive_option(); | |
| 421 | 392 | db_must_be_within_tree(); |
| 393 | + caseSensitive = filenames_are_case_sensitive(); | |
| 422 | 394 | if( zIgnoreFlag==0 ){ |
| 423 | 395 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 424 | 396 | } |
| 425 | 397 | vid = db_lget_int("checkout",0); |
| 426 | 398 | if( vid==0 ){ |
| 427 | 399 | fossil_panic("no checkout to add to"); |
| 428 | 400 | } |
| 429 | 401 | db_begin_transaction(); |
| 402 | + | |
| 403 | + /* step 1: | |
| 404 | + ** Populate the temp table "sfile" with the names of all unmanged | |
| 405 | + ** files currently in the check-out, except for files that match the | |
| 406 | + ** --ignore or ignore-glob patterns and dot-files. Then add all of | |
| 407 | + ** the files in the sfile temp table to the set of managed files. | |
| 408 | + */ | |
| 430 | 409 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 431 | 410 | n = strlen(g.zLocalRoot); |
| 432 | 411 | blob_init(&path, g.zLocalRoot, n-1); |
| 433 | 412 | /* now we read the complete file structure into a temp table */ |
| 434 | - vfile_scan(0, &path, blob_size(&path), allFlag); | |
| 435 | - if( file_tree_name(g.zRepositoryName, &repo, 0) ){ | |
| 436 | - db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); | |
| 437 | - } | |
| 438 | - | |
| 439 | - /* step 1: search for extra files */ | |
| 440 | - db_prepare(&q, | |
| 441 | - "SELECT x, %Q || x FROM sfile" | |
| 442 | - " WHERE x NOT IN (%s)" | |
| 443 | - " AND NOT %s" | |
| 444 | - " ORDER BY 1", | |
| 445 | - g.zLocalRoot, | |
| 446 | - fossil_all_reserved_names(), | |
| 447 | - glob_expr("x", zIgnoreFlag) | |
| 448 | - ); | |
| 449 | - while( db_step(&q)==SQLITE_ROW ){ | |
| 450 | - add_one_file(db_column_text(&q, 1), vid, 0); | |
| 451 | - nAdd++; | |
| 452 | - } | |
| 453 | - db_finalize(&q); | |
| 413 | + pIgnore = glob_create(zIgnoreFlag); | |
| 414 | + vfile_scan(&path, blob_size(&path), allFlag, pIgnore); | |
| 415 | + glob_free(pIgnore); | |
| 416 | + nAdd = add_files_in_sfile(vid, caseSensitive); | |
| 417 | + | |
| 454 | 418 | /* step 2: search for missing files */ |
| 455 | - db_prepare(&q, | |
| 456 | - "SELECT pathname,%Q || pathname,deleted FROM vfile" | |
| 457 | - " WHERE deleted!=1" | |
| 419 | + db_prepare(&q, | |
| 420 | + "SELECT pathname, %Q || pathname, deleted FROM vfile" | |
| 421 | + " WHERE NOT deleted" | |
| 458 | 422 | " ORDER BY 1", |
| 459 | 423 | g.zLocalRoot |
| 460 | 424 | ); |
| 461 | 425 | while( db_step(&q)==SQLITE_ROW ){ |
| 462 | 426 | const char * zFile; |
| @@ -466,17 +430,17 @@ | ||
| 466 | 430 | zPath = db_column_text(&q, 1); |
| 467 | 431 | if( !file_isfile_or_link(zPath) ){ |
| 468 | 432 | if( !isTest ){ |
| 469 | 433 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 470 | 434 | } |
| 471 | - printf("DELETED %s\n", zFile); | |
| 435 | + fossil_print("DELETED %s\n", zFile); | |
| 472 | 436 | nDelete++; |
| 473 | 437 | } |
| 474 | 438 | } |
| 475 | 439 | db_finalize(&q); |
| 476 | 440 | /* show cmmand summary */ |
| 477 | - printf("added %d files, deleted %d files\n", nAdd, nDelete); | |
| 441 | + fossil_print("added %d files, deleted %d files\n", nAdd, nDelete); | |
| 478 | 442 | |
| 479 | 443 | db_end_transaction(isTest); |
| 480 | 444 | } |
| 481 | 445 | |
| 482 | 446 | |
| @@ -484,11 +448,11 @@ | ||
| 484 | 448 | ** Rename a single file. |
| 485 | 449 | ** |
| 486 | 450 | ** The original name of the file is zOrig. The new filename is zNew. |
| 487 | 451 | */ |
| 488 | 452 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 489 | - printf("RENAME %s %s\n", zOrig, zNew); | |
| 453 | + fossil_print("RENAME %s %s\n", zOrig, zNew); | |
| 490 | 454 | db_multi_exec( |
| 491 | 455 | "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d", |
| 492 | 456 | zNew, zOrig, vid |
| 493 | 457 | ); |
| 494 | 458 | } |
| @@ -498,15 +462,20 @@ | ||
| 498 | 462 | ** COMMAND: rename |
| 499 | 463 | ** |
| 500 | 464 | ** Usage: %fossil mv|rename OLDNAME NEWNAME |
| 501 | 465 | ** or: %fossil mv|rename OLDNAME... DIR |
| 502 | 466 | ** |
| 503 | -** Move or rename one or more files within the tree | |
| 467 | +** Move or rename one or more files or directories within the repository tree. | |
| 468 | +** You can either rename a file or directory or move it to another subdirectory. | |
| 504 | 469 | ** |
| 505 | -** This command does not rename the files on disk. This command merely | |
| 470 | +** This command does NOT rename or move the files on disk. This command merely | |
| 506 | 471 | ** records the fact that filenames have changed so that appropriate notations |
| 507 | 472 | ** can be made at the next commit/checkin. |
| 473 | +** | |
| 474 | +** | |
| 475 | +** SUMMARY: fossil mv|rename OLDNAME NEWNAME | |
| 476 | +** or: fossil mv|rename OLDNAME... DIR | |
| 508 | 477 | */ |
| 509 | 478 | void mv_cmd(void){ |
| 510 | 479 | int i; |
| 511 | 480 | int vid; |
| 512 | 481 | char *zDest; |
| @@ -553,13 +522,13 @@ | ||
| 553 | 522 | zOrig = blob_str(&orig); |
| 554 | 523 | nOrig = blob_size(&orig); |
| 555 | 524 | db_prepare(&q, |
| 556 | 525 | "SELECT pathname FROM vfile" |
| 557 | 526 | " WHERE vid=%d" |
| 558 | - " AND (pathname='%s' OR pathname GLOB '%s/*')" | |
| 527 | + " AND (pathname='%q' OR (pathname>'%q/' AND pathname<'%q0'))" | |
| 559 | 528 | " ORDER BY 1", |
| 560 | - vid, zOrig, zOrig | |
| 529 | + vid, zOrig, zOrig, zOrig | |
| 561 | 530 | ); |
| 562 | 531 | while( db_step(&q)==SQLITE_ROW ){ |
| 563 | 532 | const char *zPath = db_column_text(&q, 0); |
| 564 | 533 | int nPath = db_column_bytes(&q, 0); |
| 565 | 534 | const char *zTail; |
| 566 | 535 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -85,307 +85,273 @@ | |
| 85 | zAll = blob_str(&x); |
| 86 | } |
| 87 | return zAll; |
| 88 | } |
| 89 | |
| 90 | |
| 91 | /* |
| 92 | ** The pIgnore statement is query of the form: |
| 93 | ** |
| 94 | ** SELECT (:x GLOB ... OR :x GLOB ... OR ...) |
| 95 | ** |
| 96 | ** In other words, it is a query that returns true if the :x value |
| 97 | ** should be ignored. Evaluate the query and return true to ignore |
| 98 | ** and false to not ignore. |
| 99 | ** |
| 100 | ** If pIgnore is NULL, then do not ignore. |
| 101 | */ |
| 102 | static int shouldBeIgnored(Stmt *pIgnore, const char *zName){ |
| 103 | int rc = 0; |
| 104 | if( pIgnore ){ |
| 105 | db_bind_text(pIgnore, ":x", zName); |
| 106 | db_step(pIgnore); |
| 107 | rc = db_column_int(pIgnore, 0); |
| 108 | db_reset(pIgnore); |
| 109 | } |
| 110 | return rc; |
| 111 | } |
| 112 | |
| 113 | |
| 114 | /* |
| 115 | ** Add a single file named zName to the VFILE table with vid. |
| 116 | ** |
| 117 | ** Omit any file whose name is pOmit. |
| 118 | */ |
| 119 | static void add_one_file( |
| 120 | const char *zName, /* Name of file to add */ |
| 121 | int vid, /* Add to this VFILE */ |
| 122 | Blob *pOmit |
| 123 | ){ |
| 124 | Blob pathname; |
| 125 | const char *zPath; |
| 126 | int i; |
| 127 | const char *zReserved; |
| 128 | |
| 129 | file_tree_name(zName, &pathname, 1); |
| 130 | zPath = blob_str(&pathname); |
| 131 | for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ |
| 132 | if( fossil_strcmp(zPath, zReserved)==0 ) break; |
| 133 | } |
| 134 | if( zReserved || (pOmit && blob_compare(&pathname, pOmit)==0) ){ |
| 135 | fossil_warning("cannot add %s", zPath); |
| 136 | }else{ |
| 137 | if( !file_is_simple_pathname(zPath) ){ |
| 138 | fossil_fatal("filename contains illegal characters: %s", zPath); |
| 139 | } |
| 140 | #if defined(_WIN32) |
| 141 | if( db_exists("SELECT 1 FROM vfile" |
| 142 | " WHERE pathname=%Q COLLATE nocase", zPath) ){ |
| 143 | db_multi_exec("UPDATE vfile SET deleted=0" |
| 144 | " WHERE pathname=%Q COLLATE nocase", zPath); |
| 145 | } |
| 146 | #else |
| 147 | if( db_exists("SELECT 1 FROM vfile WHERE pathname=%Q", zPath) ){ |
| 148 | db_multi_exec("UPDATE vfile SET deleted=0 WHERE pathname=%Q", zPath); |
| 149 | } |
| 150 | #endif |
| 151 | else{ |
| 152 | db_multi_exec( |
| 153 | "INSERT INTO vfile(vid,deleted,rid,mrid,pathname)" |
| 154 | "VALUES(%d,0,0,0,%Q)", vid, zPath); |
| 155 | } |
| 156 | printf("ADDED %s\n", zPath); |
| 157 | } |
| 158 | blob_reset(&pathname); |
| 159 | } |
| 160 | |
| 161 | /* |
| 162 | ** All content of the zDir directory to the SFILE table. |
| 163 | */ |
| 164 | void add_directory_content(const char *zDir, Stmt *pIgnore){ |
| 165 | DIR *d; |
| 166 | int origSize; |
| 167 | struct dirent *pEntry; |
| 168 | Blob path; |
| 169 | |
| 170 | blob_zero(&path); |
| 171 | blob_append(&path, zDir, -1); |
| 172 | origSize = blob_size(&path); |
| 173 | d = opendir(zDir); |
| 174 | if( d ){ |
| 175 | while( (pEntry=readdir(d))!=0 ){ |
| 176 | char *zPath; |
| 177 | if( pEntry->d_name[0]=='.' ){ |
| 178 | if( !includeDotFiles ) continue; |
| 179 | if( pEntry->d_name[1]==0 ) continue; |
| 180 | if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; |
| 181 | } |
| 182 | blob_appendf(&path, "/%s", pEntry->d_name); |
| 183 | zPath = blob_str(&path); |
| 184 | if( shouldBeIgnored(pIgnore, zPath) ){ |
| 185 | /* Noop */ |
| 186 | }else if( file_isdir(zPath)==1 ){ |
| 187 | add_directory_content(zPath, pIgnore); |
| 188 | }else if( file_isfile_or_link(zPath) ){ |
| 189 | db_multi_exec("INSERT INTO sfile VALUES(%Q)", zPath); |
| 190 | } |
| 191 | blob_resize(&path, origSize); |
| 192 | } |
| 193 | } |
| 194 | closedir(d); |
| 195 | blob_reset(&path); |
| 196 | } |
| 197 | |
| 198 | /* |
| 199 | ** Add all content of a directory. |
| 200 | */ |
| 201 | void add_directory(const char *zDir, int vid, Blob *pOmit, Stmt *pIgnore){ |
| 202 | Stmt q; |
| 203 | add_directory_content(zDir, pIgnore); |
| 204 | db_prepare(&q, "SELECT x FROM sfile ORDER BY x"); |
| 205 | while( db_step(&q)==SQLITE_ROW ){ |
| 206 | const char *zName = db_column_text(&q, 0); |
| 207 | add_one_file(zName, vid, pOmit); |
| 208 | } |
| 209 | db_finalize(&q); |
| 210 | db_multi_exec("DELETE FROM sfile"); |
| 211 | } |
| 212 | |
| 213 | /* |
| 214 | ** COMMAND: add |
| 215 | ** |
| 216 | ** Usage: %fossil add FILE... |
| 217 | ** |
| 218 | ** Make arrangements to add one or more files to the current checkout |
| 219 | ** at the next commit. |
| 220 | ** |
| 221 | ** When adding files recursively, filenames that begin with "." are |
| 222 | ** excluded by default. To include such files, add the "--dotfiles" |
| 223 | ** option to the command-line. |
| 224 | ** |
| 225 | ** The --ignore option overrides the "ignore-glob" setting. See |
| 226 | ** documentation on the "setting" command for further information. |
| 227 | */ |
| 228 | void add_cmd(void){ |
| 229 | int i; |
| 230 | int vid; |
| 231 | const char *zIgnoreFlag; |
| 232 | Blob repo; |
| 233 | Stmt ignoreTest; /* Test to see if a name should be ignored */ |
| 234 | Stmt *pIgnore; /* Pointer to ignoreTest or to NULL */ |
| 235 | |
| 236 | zIgnoreFlag = find_option("ignore",0,1); |
| 237 | includeDotFiles = find_option("dotfiles",0,0)!=0; |
| 238 | db_must_be_within_tree(); |
| 239 | if( zIgnoreFlag==0 ){ |
| 240 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 241 | } |
| 242 | vid = db_lget_int("checkout",0); |
| 243 | if( vid==0 ){ |
| 244 | fossil_panic("no checkout to add to"); |
| 245 | } |
| 246 | db_begin_transaction(); |
| 247 | if( !file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 248 | blob_zero(&repo); |
| 249 | } |
| 250 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 251 | #if defined(_WIN32) |
| 252 | db_multi_exec( |
| 253 | "CREATE INDEX IF NOT EXISTS vfile_pathname " |
| 254 | " ON vfile(pathname COLLATE nocase)" |
| 255 | ); |
| 256 | #endif |
| 257 | if( zIgnoreFlag && zIgnoreFlag[0] ){ |
| 258 | db_prepare(&ignoreTest, "SELECT %s", glob_expr(":x", zIgnoreFlag)); |
| 259 | pIgnore = &ignoreTest; |
| 260 | }else{ |
| 261 | pIgnore = 0; |
| 262 | } |
| 263 | for(i=2; i<g.argc; i++){ |
| 264 | char *zName; |
| 265 | int isDir; |
| 266 | |
| 267 | zName = mprintf("%/", g.argv[i]); |
| 268 | isDir = file_isdir(zName); |
| 269 | if( isDir==1 ){ |
| 270 | add_directory(zName, vid, &repo, pIgnore); |
| 271 | }else if( isDir==0 ){ |
| 272 | fossil_fatal("not found: %s", zName); |
| 273 | }else if( access(zName, R_OK) ){ |
| 274 | fossil_fatal("cannot open %s", zName); |
| 275 | }else{ |
| 276 | add_one_file(zName, vid, &repo); |
| 277 | } |
| 278 | free(zName); |
| 279 | } |
| 280 | if( pIgnore ) db_finalize(pIgnore); |
| 281 | db_end_transaction(0); |
| 282 | } |
| 283 | |
| 284 | /* |
| 285 | ** Remove all contents of zDir |
| 286 | */ |
| 287 | void del_directory_content(const char *zDir){ |
| 288 | DIR *d; |
| 289 | int origSize; |
| 290 | struct dirent *pEntry; |
| 291 | Blob path; |
| 292 | |
| 293 | blob_zero(&path); |
| 294 | blob_append(&path, zDir, -1); |
| 295 | origSize = blob_size(&path); |
| 296 | d = opendir(zDir); |
| 297 | if( d ){ |
| 298 | while( (pEntry=readdir(d))!=0 ){ |
| 299 | char *zPath; |
| 300 | if( pEntry->d_name[0]=='.'){ |
| 301 | if( !includeDotFiles ) continue; |
| 302 | if( pEntry->d_name[1]==0 ) continue; |
| 303 | if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; |
| 304 | } |
| 305 | blob_appendf(&path, "/%s", pEntry->d_name); |
| 306 | zPath = blob_str(&path); |
| 307 | if( file_isdir(zPath)==1 ){ |
| 308 | del_directory_content(zPath); |
| 309 | }else if( file_isfile_or_link(zPath) ){ |
| 310 | char *zFilePath; |
| 311 | Blob pathname; |
| 312 | file_tree_name(zPath, &pathname, 1); |
| 313 | zFilePath = blob_str(&pathname); |
| 314 | if( !db_exists( |
| 315 | "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zFilePath) |
| 316 | ){ |
| 317 | printf("SKIPPED %s\n", zPath); |
| 318 | }else{ |
| 319 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath); |
| 320 | printf("DELETED %s\n", zPath); |
| 321 | } |
| 322 | blob_reset(&pathname); |
| 323 | } |
| 324 | blob_resize(&path, origSize); |
| 325 | } |
| 326 | } |
| 327 | closedir(d); |
| 328 | blob_reset(&path); |
| 329 | } |
| 330 | |
| 331 | /* |
| 332 | ** COMMAND: rm |
| 333 | ** COMMAND: delete |
| 334 | ** |
| 335 | ** Usage: %fossil rm FILE... |
| 336 | ** or: %fossil delete FILE... |
| 337 | ** |
| 338 | ** Remove one or more files from the tree. |
| 339 | ** |
| 340 | ** This command does not remove the files from disk. It just marks the |
| 341 | ** files as no longer being part of the project. In other words, future |
| 342 | ** changes to the named files will not be versioned. |
| 343 | */ |
| 344 | void delete_cmd(void){ |
| 345 | int i; |
| 346 | int vid; |
| 347 | |
| 348 | db_must_be_within_tree(); |
| 349 | vid = db_lget_int("checkout", 0); |
| 350 | if( vid==0 ){ |
| 351 | fossil_panic("no checkout to remove from"); |
| 352 | } |
| 353 | db_begin_transaction(); |
| 354 | for(i=2; i<g.argc; i++){ |
| 355 | char *zName; |
| 356 | |
| 357 | zName = mprintf("%/", g.argv[i]); |
| 358 | if( file_isdir(zName) == 1 ){ |
| 359 | del_directory_content(zName); |
| 360 | } else { |
| 361 | char *zPath; |
| 362 | Blob pathname; |
| 363 | file_tree_name(zName, &pathname, 1); |
| 364 | zPath = blob_str(&pathname); |
| 365 | if( !db_exists( |
| 366 | "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){ |
| 367 | fossil_fatal("not in the repository: %s", zName); |
| 368 | }else{ |
| 369 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath); |
| 370 | printf("DELETED %s\n", zPath); |
| 371 | } |
| 372 | blob_reset(&pathname); |
| 373 | } |
| 374 | free(zName); |
| 375 | } |
| 376 | db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0"); |
| 377 | db_end_transaction(0); |
| 378 | } |
| 379 | |
| 380 | /* |
| 381 | ** COMMAND: addremove |
| 382 | ** |
| 383 | ** Usage: %fossil addremove ?--dotfiles? ?--ignore GLOBPATTERN? ?--test? |
| 384 | ** |
| 385 | ** Do all necessary "add" and "rm" commands to synchronize the repository |
| 386 | ** with the content of the working checkout |
| 387 | ** |
| 388 | ** * All files in the checkout but not in the repository (that is, |
| 389 | ** all files displayed using the "extra" command) are added as |
| 390 | ** if by the "add" command. |
| 391 | ** |
| @@ -398,65 +364,63 @@ | |
| 398 | ** |
| 399 | ** Files and directories whose names begin with "." are ignored unless |
| 400 | ** the --dotfiles option is used. |
| 401 | ** |
| 402 | ** The --ignore option overrides the "ignore-glob" setting. See |
| 403 | ** documentation on the "setting" command for further information. |
| 404 | ** |
| 405 | ** The --test option shows what would happen without actually doing anything. |
| 406 | ** |
| 407 | ** This command can be used to track third party software. |
| 408 | */ |
| 409 | void import_cmd(void){ |
| 410 | Blob path; |
| 411 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 412 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 413 | int isTest = find_option("test",0,0)!=0; |
| 414 | int n; |
| 415 | Stmt q; |
| 416 | int vid; |
| 417 | Blob repo; |
| 418 | int nAdd = 0; |
| 419 | int nDelete = 0; |
| 420 | |
| 421 | db_must_be_within_tree(); |
| 422 | if( zIgnoreFlag==0 ){ |
| 423 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 424 | } |
| 425 | vid = db_lget_int("checkout",0); |
| 426 | if( vid==0 ){ |
| 427 | fossil_panic("no checkout to add to"); |
| 428 | } |
| 429 | db_begin_transaction(); |
| 430 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 431 | n = strlen(g.zLocalRoot); |
| 432 | blob_init(&path, g.zLocalRoot, n-1); |
| 433 | /* now we read the complete file structure into a temp table */ |
| 434 | vfile_scan(0, &path, blob_size(&path), allFlag); |
| 435 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 436 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 437 | } |
| 438 | |
| 439 | /* step 1: search for extra files */ |
| 440 | db_prepare(&q, |
| 441 | "SELECT x, %Q || x FROM sfile" |
| 442 | " WHERE x NOT IN (%s)" |
| 443 | " AND NOT %s" |
| 444 | " ORDER BY 1", |
| 445 | g.zLocalRoot, |
| 446 | fossil_all_reserved_names(), |
| 447 | glob_expr("x", zIgnoreFlag) |
| 448 | ); |
| 449 | while( db_step(&q)==SQLITE_ROW ){ |
| 450 | add_one_file(db_column_text(&q, 1), vid, 0); |
| 451 | nAdd++; |
| 452 | } |
| 453 | db_finalize(&q); |
| 454 | /* step 2: search for missing files */ |
| 455 | db_prepare(&q, |
| 456 | "SELECT pathname,%Q || pathname,deleted FROM vfile" |
| 457 | " WHERE deleted!=1" |
| 458 | " ORDER BY 1", |
| 459 | g.zLocalRoot |
| 460 | ); |
| 461 | while( db_step(&q)==SQLITE_ROW ){ |
| 462 | const char * zFile; |
| @@ -466,17 +430,17 @@ | |
| 466 | zPath = db_column_text(&q, 1); |
| 467 | if( !file_isfile_or_link(zPath) ){ |
| 468 | if( !isTest ){ |
| 469 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 470 | } |
| 471 | printf("DELETED %s\n", zFile); |
| 472 | nDelete++; |
| 473 | } |
| 474 | } |
| 475 | db_finalize(&q); |
| 476 | /* show cmmand summary */ |
| 477 | printf("added %d files, deleted %d files\n", nAdd, nDelete); |
| 478 | |
| 479 | db_end_transaction(isTest); |
| 480 | } |
| 481 | |
| 482 | |
| @@ -484,11 +448,11 @@ | |
| 484 | ** Rename a single file. |
| 485 | ** |
| 486 | ** The original name of the file is zOrig. The new filename is zNew. |
| 487 | */ |
| 488 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 489 | printf("RENAME %s %s\n", zOrig, zNew); |
| 490 | db_multi_exec( |
| 491 | "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d", |
| 492 | zNew, zOrig, vid |
| 493 | ); |
| 494 | } |
| @@ -498,15 +462,20 @@ | |
| 498 | ** COMMAND: rename |
| 499 | ** |
| 500 | ** Usage: %fossil mv|rename OLDNAME NEWNAME |
| 501 | ** or: %fossil mv|rename OLDNAME... DIR |
| 502 | ** |
| 503 | ** Move or rename one or more files within the tree |
| 504 | ** |
| 505 | ** This command does not rename the files on disk. This command merely |
| 506 | ** records the fact that filenames have changed so that appropriate notations |
| 507 | ** can be made at the next commit/checkin. |
| 508 | */ |
| 509 | void mv_cmd(void){ |
| 510 | int i; |
| 511 | int vid; |
| 512 | char *zDest; |
| @@ -553,13 +522,13 @@ | |
| 553 | zOrig = blob_str(&orig); |
| 554 | nOrig = blob_size(&orig); |
| 555 | db_prepare(&q, |
| 556 | "SELECT pathname FROM vfile" |
| 557 | " WHERE vid=%d" |
| 558 | " AND (pathname='%s' OR pathname GLOB '%s/*')" |
| 559 | " ORDER BY 1", |
| 560 | vid, zOrig, zOrig |
| 561 | ); |
| 562 | while( db_step(&q)==SQLITE_ROW ){ |
| 563 | const char *zPath = db_column_text(&q, 0); |
| 564 | int nPath = db_column_bytes(&q, 0); |
| 565 | const char *zTail; |
| 566 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -85,307 +85,273 @@ | |
| 85 | zAll = blob_str(&x); |
| 86 | } |
| 87 | return zAll; |
| 88 | } |
| 89 | |
| 90 | /* |
| 91 | ** Add a single file named zName to the VFILE table with vid. |
| 92 | ** |
| 93 | ** Omit any file whose name is pOmit. |
| 94 | */ |
| 95 | static int add_one_file( |
| 96 | const char *zPath, /* Tree-name of file to add. */ |
| 97 | int vid, /* Add to this VFILE */ |
| 98 | int caseSensitive /* True if filenames are case sensitive */ |
| 99 | ){ |
| 100 | const char *zCollate = caseSensitive ? "binary" : "nocase"; |
| 101 | if( !file_is_simple_pathname(zPath) ){ |
| 102 | fossil_fatal("filename contains illegal characters: %s", zPath); |
| 103 | } |
| 104 | if( db_exists("SELECT 1 FROM vfile" |
| 105 | " WHERE pathname=%Q COLLATE %s", zPath, zCollate) ){ |
| 106 | db_multi_exec("UPDATE vfile SET deleted=0" |
| 107 | " WHERE pathname=%Q COLLATE %s", zPath, zCollate); |
| 108 | }else{ |
| 109 | char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath); |
| 110 | db_multi_exec( |
| 111 | "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe)" |
| 112 | "VALUES(%d,0,0,0,%Q,%d)", |
| 113 | vid, zPath, file_isexe(zFullname)); |
| 114 | fossil_free(zFullname); |
| 115 | } |
| 116 | if( db_changes() ){ |
| 117 | fossil_print("ADDED %s\n", zPath); |
| 118 | return 1; |
| 119 | }else{ |
| 120 | fossil_print("SKIP %s\n", zPath); |
| 121 | return 0; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /* |
| 126 | ** Add all files in the sfile temp table. |
| 127 | ** |
| 128 | ** Automatically exclude the repository file. |
| 129 | */ |
| 130 | static int add_files_in_sfile(int vid, int caseSensitive){ |
| 131 | const char *zRepo; /* Name of the repository database file */ |
| 132 | int nAdd = 0; /* Number of files added */ |
| 133 | int i; /* Loop counter */ |
| 134 | const char *zReserved; /* Name of a reserved file */ |
| 135 | Blob repoName; /* Treename of the repository */ |
| 136 | Stmt loop; /* SQL to loop over all files to add */ |
| 137 | int (*xCmp)(const char*,const char*); |
| 138 | |
| 139 | if( !file_tree_name(g.zRepositoryName, &repoName, 0) ){ |
| 140 | blob_zero(&repoName); |
| 141 | zRepo = ""; |
| 142 | }else{ |
| 143 | zRepo = blob_str(&repoName); |
| 144 | } |
| 145 | if( caseSensitive ){ |
| 146 | xCmp = fossil_strcmp; |
| 147 | }else{ |
| 148 | xCmp = fossil_stricmp; |
| 149 | db_multi_exec( |
| 150 | "CREATE INDEX IF NOT EXISTS vfile_nocase" |
| 151 | " ON vfile(pathname COLLATE nocase)" |
| 152 | ); |
| 153 | } |
| 154 | db_prepare(&loop, "SELECT x FROM sfile ORDER BY x"); |
| 155 | while( db_step(&loop)==SQLITE_ROW ){ |
| 156 | const char *zToAdd = db_column_text(&loop, 0); |
| 157 | if( fossil_strcmp(zToAdd, zRepo)==0 ) continue; |
| 158 | for(i=0; (zReserved = fossil_reserved_name(i))!=0; i++){ |
| 159 | if( xCmp(zToAdd, zReserved)==0 ) break; |
| 160 | } |
| 161 | if( zReserved ) continue; |
| 162 | nAdd += add_one_file(zToAdd, vid, caseSensitive); |
| 163 | } |
| 164 | db_finalize(&loop); |
| 165 | blob_reset(&repoName); |
| 166 | return nAdd; |
| 167 | } |
| 168 | |
| 169 | /* |
| 170 | ** COMMAND: add |
| 171 | ** |
| 172 | ** Usage: %fossil add ?OPTIONS? FILE1 ?FILE2 ...? |
| 173 | ** |
| 174 | ** Make arrangements to add one or more files or directories to the |
| 175 | ** current checkout at the next commit. |
| 176 | ** |
| 177 | ** When adding files or directories recursively, filenames that begin |
| 178 | ** with "." are excluded by default. To include such files, add |
| 179 | ** the "--dotfiles" option to the command-line. |
| 180 | ** |
| 181 | ** The --ignore option is a comma-separate list of glob patterns for files |
| 182 | ** to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore option |
| 183 | ** does not appear on the command line then the "ignore-glob" setting is |
| 184 | ** used. |
| 185 | ** |
| 186 | ** SUMMARY: fossil add ?OPTIONS? FILE1 ?FILE2 ...? |
| 187 | ** Options: --dotfiles, --ignore |
| 188 | */ |
| 189 | void add_cmd(void){ |
| 190 | int i; /* Loop counter */ |
| 191 | int vid; /* Currently checked out version */ |
| 192 | int nRoot; /* Full path characters in g.zLocalRoot */ |
| 193 | const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ |
| 194 | Glob *pIgnore; /* Ignore everything matching this glob pattern */ |
| 195 | int caseSensitive; /* True if filenames are case sensitive */ |
| 196 | |
| 197 | zIgnoreFlag = find_option("ignore",0,1); |
| 198 | includeDotFiles = find_option("dotfiles",0,0)!=0; |
| 199 | capture_case_sensitive_option(); |
| 200 | db_must_be_within_tree(); |
| 201 | caseSensitive = filenames_are_case_sensitive(); |
| 202 | if( zIgnoreFlag==0 ){ |
| 203 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 204 | } |
| 205 | vid = db_lget_int("checkout",0); |
| 206 | if( vid==0 ){ |
| 207 | fossil_panic("no checkout to add to"); |
| 208 | } |
| 209 | db_begin_transaction(); |
| 210 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 211 | #if defined(_WIN32) |
| 212 | db_multi_exec( |
| 213 | "CREATE INDEX IF NOT EXISTS vfile_pathname " |
| 214 | " ON vfile(pathname COLLATE nocase)" |
| 215 | ); |
| 216 | #endif |
| 217 | pIgnore = glob_create(zIgnoreFlag); |
| 218 | nRoot = strlen(g.zLocalRoot); |
| 219 | |
| 220 | /* Load the names of all files that are to be added into sfile temp table */ |
| 221 | for(i=2; i<g.argc; i++){ |
| 222 | char *zName; |
| 223 | int isDir; |
| 224 | Blob fullName; |
| 225 | |
| 226 | file_canonical_name(g.argv[i], &fullName); |
| 227 | zName = blob_str(&fullName); |
| 228 | isDir = file_isdir(zName); |
| 229 | if( isDir==1 ){ |
| 230 | vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore); |
| 231 | }else if( isDir==0 ){ |
| 232 | fossil_fatal("not found: %s", zName); |
| 233 | }else if( file_access(zName, R_OK) ){ |
| 234 | fossil_fatal("cannot open %s", zName); |
| 235 | }else{ |
| 236 | char *zTreeName = &zName[nRoot]; |
| 237 | db_multi_exec( |
| 238 | "INSERT OR IGNORE INTO sfile(x)" |
| 239 | " SELECT %Q WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE pathname=%Q)", |
| 240 | zTreeName, zTreeName |
| 241 | ); |
| 242 | } |
| 243 | blob_reset(&fullName); |
| 244 | } |
| 245 | glob_free(pIgnore); |
| 246 | |
| 247 | add_files_in_sfile(vid, caseSensitive); |
| 248 | db_end_transaction(0); |
| 249 | } |
| 250 | |
| 251 | /* |
| 252 | ** COMMAND: rm |
| 253 | ** COMMAND: delete |
| 254 | ** |
| 255 | ** Usage: %fossil rm FILE1 ?FILE2 ...? |
| 256 | ** or: %fossil delete FILE1 ?FILE2 ...? |
| 257 | ** |
| 258 | ** Remove one or more files or directories from the repository. |
| 259 | ** |
| 260 | ** This command does NOT remove the files from disk. It just marks the |
| 261 | ** files as no longer being part of the project. In other words, future |
| 262 | ** changes to the named files will not be versioned. |
| 263 | ** |
| 264 | ** SUMMARY: fossil rm FILE1 ?FILE2 ...? |
| 265 | ** or: fossil delete FILE1 ?FILE2 ...? |
| 266 | */ |
| 267 | void delete_cmd(void){ |
| 268 | int i; |
| 269 | int vid; |
| 270 | Stmt loop; |
| 271 | |
| 272 | db_must_be_within_tree(); |
| 273 | vid = db_lget_int("checkout", 0); |
| 274 | if( vid==0 ){ |
| 275 | fossil_panic("no checkout to remove from"); |
| 276 | } |
| 277 | db_begin_transaction(); |
| 278 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 279 | for(i=2; i<g.argc; i++){ |
| 280 | Blob treeName; |
| 281 | char *zTreeName; |
| 282 | |
| 283 | file_tree_name(g.argv[i], &treeName, 1); |
| 284 | zTreeName = blob_str(&treeName); |
| 285 | db_multi_exec( |
| 286 | "INSERT OR IGNORE INTO sfile" |
| 287 | " SELECT pathname FROM vfile" |
| 288 | " WHERE (pathname=%Q" |
| 289 | " OR (pathname>'%q/' AND pathname<'%q0'))" |
| 290 | " AND NOT deleted", |
| 291 | zTreeName, zTreeName, zTreeName |
| 292 | ); |
| 293 | blob_reset(&treeName); |
| 294 | } |
| 295 | |
| 296 | db_prepare(&loop, "SELECT x FROM sfile"); |
| 297 | while( db_step(&loop)==SQLITE_ROW ){ |
| 298 | fossil_print("DELETED %s\n", db_column_text(&loop, 0)); |
| 299 | } |
| 300 | db_finalize(&loop); |
| 301 | db_multi_exec( |
| 302 | "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;" |
| 303 | "DELETE FROM vfile WHERE rid=0 AND deleted;" |
| 304 | ); |
| 305 | db_end_transaction(0); |
| 306 | } |
| 307 | |
| 308 | /* |
| 309 | ** Capture the command-line --case-sensitive option. |
| 310 | */ |
| 311 | static const char *zCaseSensitive = 0; |
| 312 | void capture_case_sensitive_option(void){ |
| 313 | if( zCaseSensitive==0 ){ |
| 314 | zCaseSensitive = find_option("case-sensitive",0,1); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | /* |
| 319 | ** This routine determines if files should be case-sensitive or not. |
| 320 | ** In other words, this routine determines if two filenames that |
| 321 | ** differ only in case should be considered the same name or not. |
| 322 | ** |
| 323 | ** The case-sensitive setting determines the default value. If |
| 324 | ** the case-sensitive setting is undefined, then case sensitivity |
| 325 | ** defaults on for Mac and Windows and off for all other unix. |
| 326 | ** |
| 327 | ** The --case-sensitive BOOLEAN command-line option overrides any |
| 328 | ** setting. |
| 329 | */ |
| 330 | int filenames_are_case_sensitive(void){ |
| 331 | int caseSensitive; |
| 332 | |
| 333 | if( zCaseSensitive ){ |
| 334 | caseSensitive = is_truth(zCaseSensitive); |
| 335 | }else{ |
| 336 | #if !defined(_WIN32) && !defined(__DARWIN__) && !defined(__APPLE__) |
| 337 | caseSensitive = 1; |
| 338 | #else |
| 339 | caseSensitive = 0; |
| 340 | #endif |
| 341 | caseSensitive = db_get_boolean("case-sensitive",caseSensitive); |
| 342 | } |
| 343 | return caseSensitive; |
| 344 | } |
| 345 | |
| 346 | /* |
| 347 | ** COMMAND: addremove |
| 348 | ** |
| 349 | ** Usage: %fossil addremove ?--dotfiles? ?--ignore GLOBPATTERN? ?--test? |
| 350 | ** |
| 351 | ** Do all necessary "add" and "rm" commands to synchronize the repository |
| 352 | ** with the content of the working checkout: |
| 353 | ** |
| 354 | ** * All files in the checkout but not in the repository (that is, |
| 355 | ** all files displayed using the "extra" command) are added as |
| 356 | ** if by the "add" command. |
| 357 | ** |
| @@ -398,65 +364,63 @@ | |
| 364 | ** |
| 365 | ** Files and directories whose names begin with "." are ignored unless |
| 366 | ** the --dotfiles option is used. |
| 367 | ** |
| 368 | ** The --ignore option overrides the "ignore-glob" setting. See |
| 369 | ** documentation on the "settings" command for further information. |
| 370 | ** |
| 371 | ** The --test option shows what would happen without actually doing anything. |
| 372 | ** |
| 373 | ** This command can be used to track third party software. |
| 374 | ** |
| 375 | ** SUMMARY: fossil addremove |
| 376 | ** Options: ?--dotfiles? ?--ignore GLOB? ?--test? ?--case-sensitive BOOL? |
| 377 | */ |
| 378 | void addremove_cmd(void){ |
| 379 | Blob path; |
| 380 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 381 | int allFlag = find_option("dotfiles",0,0)!=0; |
| 382 | int isTest = find_option("test",0,0)!=0; |
| 383 | int caseSensitive; |
| 384 | int n; |
| 385 | Stmt q; |
| 386 | int vid; |
| 387 | int nAdd = 0; |
| 388 | int nDelete = 0; |
| 389 | Glob *pIgnore; |
| 390 | |
| 391 | capture_case_sensitive_option(); |
| 392 | db_must_be_within_tree(); |
| 393 | caseSensitive = filenames_are_case_sensitive(); |
| 394 | if( zIgnoreFlag==0 ){ |
| 395 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 396 | } |
| 397 | vid = db_lget_int("checkout",0); |
| 398 | if( vid==0 ){ |
| 399 | fossil_panic("no checkout to add to"); |
| 400 | } |
| 401 | db_begin_transaction(); |
| 402 | |
| 403 | /* step 1: |
| 404 | ** Populate the temp table "sfile" with the names of all unmanged |
| 405 | ** files currently in the check-out, except for files that match the |
| 406 | ** --ignore or ignore-glob patterns and dot-files. Then add all of |
| 407 | ** the files in the sfile temp table to the set of managed files. |
| 408 | */ |
| 409 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 410 | n = strlen(g.zLocalRoot); |
| 411 | blob_init(&path, g.zLocalRoot, n-1); |
| 412 | /* now we read the complete file structure into a temp table */ |
| 413 | pIgnore = glob_create(zIgnoreFlag); |
| 414 | vfile_scan(&path, blob_size(&path), allFlag, pIgnore); |
| 415 | glob_free(pIgnore); |
| 416 | nAdd = add_files_in_sfile(vid, caseSensitive); |
| 417 | |
| 418 | /* step 2: search for missing files */ |
| 419 | db_prepare(&q, |
| 420 | "SELECT pathname, %Q || pathname, deleted FROM vfile" |
| 421 | " WHERE NOT deleted" |
| 422 | " ORDER BY 1", |
| 423 | g.zLocalRoot |
| 424 | ); |
| 425 | while( db_step(&q)==SQLITE_ROW ){ |
| 426 | const char * zFile; |
| @@ -466,17 +430,17 @@ | |
| 430 | zPath = db_column_text(&q, 1); |
| 431 | if( !file_isfile_or_link(zPath) ){ |
| 432 | if( !isTest ){ |
| 433 | db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile); |
| 434 | } |
| 435 | fossil_print("DELETED %s\n", zFile); |
| 436 | nDelete++; |
| 437 | } |
| 438 | } |
| 439 | db_finalize(&q); |
| 440 | /* show cmmand summary */ |
| 441 | fossil_print("added %d files, deleted %d files\n", nAdd, nDelete); |
| 442 | |
| 443 | db_end_transaction(isTest); |
| 444 | } |
| 445 | |
| 446 | |
| @@ -484,11 +448,11 @@ | |
| 448 | ** Rename a single file. |
| 449 | ** |
| 450 | ** The original name of the file is zOrig. The new filename is zNew. |
| 451 | */ |
| 452 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 453 | fossil_print("RENAME %s %s\n", zOrig, zNew); |
| 454 | db_multi_exec( |
| 455 | "UPDATE vfile SET pathname='%s' WHERE pathname='%s' AND vid=%d", |
| 456 | zNew, zOrig, vid |
| 457 | ); |
| 458 | } |
| @@ -498,15 +462,20 @@ | |
| 462 | ** COMMAND: rename |
| 463 | ** |
| 464 | ** Usage: %fossil mv|rename OLDNAME NEWNAME |
| 465 | ** or: %fossil mv|rename OLDNAME... DIR |
| 466 | ** |
| 467 | ** Move or rename one or more files or directories within the repository tree. |
| 468 | ** You can either rename a file or directory or move it to another subdirectory. |
| 469 | ** |
| 470 | ** This command does NOT rename or move the files on disk. This command merely |
| 471 | ** records the fact that filenames have changed so that appropriate notations |
| 472 | ** can be made at the next commit/checkin. |
| 473 | ** |
| 474 | ** |
| 475 | ** SUMMARY: fossil mv|rename OLDNAME NEWNAME |
| 476 | ** or: fossil mv|rename OLDNAME... DIR |
| 477 | */ |
| 478 | void mv_cmd(void){ |
| 479 | int i; |
| 480 | int vid; |
| 481 | char *zDest; |
| @@ -553,13 +522,13 @@ | |
| 522 | zOrig = blob_str(&orig); |
| 523 | nOrig = blob_size(&orig); |
| 524 | db_prepare(&q, |
| 525 | "SELECT pathname FROM vfile" |
| 526 | " WHERE vid=%d" |
| 527 | " AND (pathname='%q' OR (pathname>'%q/' AND pathname<'%q0'))" |
| 528 | " ORDER BY 1", |
| 529 | vid, zOrig, zOrig, zOrig |
| 530 | ); |
| 531 | while( db_step(&q)==SQLITE_ROW ){ |
| 532 | const char *zPath = db_column_text(&q, 0); |
| 533 | int nPath = db_column_bytes(&q, 0); |
| 534 | const char *zTail; |
| 535 |
+11
-5
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -86,10 +86,12 @@ | ||
| 86 | 86 | const char *zCmd; |
| 87 | 87 | char *zSyscmd; |
| 88 | 88 | char *zFossil; |
| 89 | 89 | char *zQFilename; |
| 90 | 90 | int nMissing; |
| 91 | + int stopOnError = find_option("dontstop",0,0)==0; | |
| 92 | + int rc; | |
| 91 | 93 | |
| 92 | 94 | if( g.argc<3 ){ |
| 93 | 95 | usage("list|ls|pull|push|rebuild|sync"); |
| 94 | 96 | } |
| 95 | 97 | n = strlen(g.argv[2]); |
| @@ -127,26 +129,30 @@ | ||
| 127 | 129 | " FROM global_config" |
| 128 | 130 | " WHERE substr(name, 1, 5)=='repo:' ORDER BY 1" |
| 129 | 131 | ); |
| 130 | 132 | while( db_step(&q)==SQLITE_ROW ){ |
| 131 | 133 | const char *zFilename = db_column_text(&q, 0); |
| 132 | - if( access(zFilename, 0) ){ | |
| 134 | + if( file_access(zFilename, 0) ){ | |
| 133 | 135 | nMissing++; |
| 134 | 136 | continue; |
| 135 | 137 | } |
| 136 | 138 | if( !file_is_canonical(zFilename) ) nMissing++; |
| 137 | 139 | if( zCmd[0]=='l' ){ |
| 138 | - printf("%s\n", zFilename); | |
| 140 | + fossil_print("%s\n", zFilename); | |
| 139 | 141 | continue; |
| 140 | 142 | } |
| 141 | 143 | zQFilename = quoteFilename(zFilename); |
| 142 | 144 | zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename); |
| 143 | - printf("%s\n", zSyscmd); | |
| 145 | + fossil_print("%s\n", zSyscmd); | |
| 144 | 146 | fflush(stdout); |
| 145 | - fossil_system(zSyscmd); | |
| 147 | + rc = fossil_system(zSyscmd); | |
| 146 | 148 | free(zSyscmd); |
| 147 | 149 | free(zQFilename); |
| 150 | + if( stopOnError && rc ){ | |
| 151 | + nMissing = 0; | |
| 152 | + break; | |
| 153 | + } | |
| 148 | 154 | } |
| 149 | 155 | |
| 150 | 156 | /* If any repositories whose names appear in the ~/.fossil file could not |
| 151 | 157 | ** be found, remove those names from the ~/.fossil file. |
| 152 | 158 | */ |
| @@ -153,11 +159,11 @@ | ||
| 153 | 159 | if( nMissing ){ |
| 154 | 160 | db_begin_transaction(); |
| 155 | 161 | db_reset(&q); |
| 156 | 162 | while( db_step(&q)==SQLITE_ROW ){ |
| 157 | 163 | const char *zFilename = db_column_text(&q, 0); |
| 158 | - if( access(zFilename, 0) ){ | |
| 164 | + if( file_access(zFilename, 0) ){ | |
| 159 | 165 | char *zRepo = mprintf("repo:%s", zFilename); |
| 160 | 166 | db_unset(zRepo, 1); |
| 161 | 167 | free(zRepo); |
| 162 | 168 | }else if( !file_is_canonical(zFilename) ){ |
| 163 | 169 | Blob cname; |
| 164 | 170 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -86,10 +86,12 @@ | |
| 86 | const char *zCmd; |
| 87 | char *zSyscmd; |
| 88 | char *zFossil; |
| 89 | char *zQFilename; |
| 90 | int nMissing; |
| 91 | |
| 92 | if( g.argc<3 ){ |
| 93 | usage("list|ls|pull|push|rebuild|sync"); |
| 94 | } |
| 95 | n = strlen(g.argv[2]); |
| @@ -127,26 +129,30 @@ | |
| 127 | " FROM global_config" |
| 128 | " WHERE substr(name, 1, 5)=='repo:' ORDER BY 1" |
| 129 | ); |
| 130 | while( db_step(&q)==SQLITE_ROW ){ |
| 131 | const char *zFilename = db_column_text(&q, 0); |
| 132 | if( access(zFilename, 0) ){ |
| 133 | nMissing++; |
| 134 | continue; |
| 135 | } |
| 136 | if( !file_is_canonical(zFilename) ) nMissing++; |
| 137 | if( zCmd[0]=='l' ){ |
| 138 | printf("%s\n", zFilename); |
| 139 | continue; |
| 140 | } |
| 141 | zQFilename = quoteFilename(zFilename); |
| 142 | zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename); |
| 143 | printf("%s\n", zSyscmd); |
| 144 | fflush(stdout); |
| 145 | fossil_system(zSyscmd); |
| 146 | free(zSyscmd); |
| 147 | free(zQFilename); |
| 148 | } |
| 149 | |
| 150 | /* If any repositories whose names appear in the ~/.fossil file could not |
| 151 | ** be found, remove those names from the ~/.fossil file. |
| 152 | */ |
| @@ -153,11 +159,11 @@ | |
| 153 | if( nMissing ){ |
| 154 | db_begin_transaction(); |
| 155 | db_reset(&q); |
| 156 | while( db_step(&q)==SQLITE_ROW ){ |
| 157 | const char *zFilename = db_column_text(&q, 0); |
| 158 | if( access(zFilename, 0) ){ |
| 159 | char *zRepo = mprintf("repo:%s", zFilename); |
| 160 | db_unset(zRepo, 1); |
| 161 | free(zRepo); |
| 162 | }else if( !file_is_canonical(zFilename) ){ |
| 163 | Blob cname; |
| 164 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -86,10 +86,12 @@ | |
| 86 | const char *zCmd; |
| 87 | char *zSyscmd; |
| 88 | char *zFossil; |
| 89 | char *zQFilename; |
| 90 | int nMissing; |
| 91 | int stopOnError = find_option("dontstop",0,0)==0; |
| 92 | int rc; |
| 93 | |
| 94 | if( g.argc<3 ){ |
| 95 | usage("list|ls|pull|push|rebuild|sync"); |
| 96 | } |
| 97 | n = strlen(g.argv[2]); |
| @@ -127,26 +129,30 @@ | |
| 129 | " FROM global_config" |
| 130 | " WHERE substr(name, 1, 5)=='repo:' ORDER BY 1" |
| 131 | ); |
| 132 | while( db_step(&q)==SQLITE_ROW ){ |
| 133 | const char *zFilename = db_column_text(&q, 0); |
| 134 | if( file_access(zFilename, 0) ){ |
| 135 | nMissing++; |
| 136 | continue; |
| 137 | } |
| 138 | if( !file_is_canonical(zFilename) ) nMissing++; |
| 139 | if( zCmd[0]=='l' ){ |
| 140 | fossil_print("%s\n", zFilename); |
| 141 | continue; |
| 142 | } |
| 143 | zQFilename = quoteFilename(zFilename); |
| 144 | zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename); |
| 145 | fossil_print("%s\n", zSyscmd); |
| 146 | fflush(stdout); |
| 147 | rc = fossil_system(zSyscmd); |
| 148 | free(zSyscmd); |
| 149 | free(zQFilename); |
| 150 | if( stopOnError && rc ){ |
| 151 | nMissing = 0; |
| 152 | break; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | /* If any repositories whose names appear in the ~/.fossil file could not |
| 157 | ** be found, remove those names from the ~/.fossil file. |
| 158 | */ |
| @@ -153,11 +159,11 @@ | |
| 159 | if( nMissing ){ |
| 160 | db_begin_transaction(); |
| 161 | db_reset(&q); |
| 162 | while( db_step(&q)==SQLITE_ROW ){ |
| 163 | const char *zFilename = db_column_text(&q, 0); |
| 164 | if( file_access(zFilename, 0) ){ |
| 165 | char *zRepo = mprintf("repo:%s", zFilename); |
| 166 | db_unset(zRepo, 1); |
| 167 | free(zRepo); |
| 168 | }else if( !file_is_canonical(zFilename) ){ |
| 169 | Blob cname; |
| 170 |
+4
-3
| --- src/attach.c | ||
| +++ src/attach.c | ||
| @@ -241,11 +241,11 @@ | ||
| 241 | 241 | int rid; |
| 242 | 242 | int i, n; |
| 243 | 243 | |
| 244 | 244 | db_begin_transaction(); |
| 245 | 245 | blob_init(&content, aContent, szContent); |
| 246 | - rid = content_put(&content, 0, 0, 0); | |
| 246 | + rid = content_put(&content); | |
| 247 | 247 | zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 248 | 248 | blob_zero(&manifest); |
| 249 | 249 | for(i=n=0; zName[i]; i++){ |
| 250 | 250 | if( zName[i]=='/' || zName[i]=='\\' ) n = i; |
| 251 | 251 | } |
| @@ -262,12 +262,13 @@ | ||
| 262 | 262 | zDate = date_in_standard_format("now"); |
| 263 | 263 | blob_appendf(&manifest, "D %s\n", zDate); |
| 264 | 264 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 265 | 265 | md5sum_blob(&manifest, &cksum); |
| 266 | 266 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 267 | - rid = content_put(&manifest, 0, 0, 0); | |
| 267 | + rid = content_put(&manifest); | |
| 268 | 268 | manifest_crosslink(rid, &manifest); |
| 269 | + assert( blob_is_reset(&manifest) ); | |
| 269 | 270 | db_end_transaction(0); |
| 270 | 271 | cgi_redirect(zFrom); |
| 271 | 272 | } |
| 272 | 273 | style_header("Add Attachment"); |
| 273 | 274 | @ <h2>Add Attachment To %s(zTargetType)</h2> |
| @@ -341,11 +342,11 @@ | ||
| 341 | 342 | zDate = date_in_standard_format("now"); |
| 342 | 343 | blob_appendf(&manifest, "D %s\n", zDate); |
| 343 | 344 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 344 | 345 | md5sum_blob(&manifest, &cksum); |
| 345 | 346 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 346 | - rid = content_put(&manifest, 0, 0, 0); | |
| 347 | + rid = content_put(&manifest); | |
| 347 | 348 | manifest_crosslink(rid, &manifest); |
| 348 | 349 | db_end_transaction(0); |
| 349 | 350 | cgi_redirect(zFrom); |
| 350 | 351 | } |
| 351 | 352 | style_header("Delete Attachment"); |
| 352 | 353 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -241,11 +241,11 @@ | |
| 241 | int rid; |
| 242 | int i, n; |
| 243 | |
| 244 | db_begin_transaction(); |
| 245 | blob_init(&content, aContent, szContent); |
| 246 | rid = content_put(&content, 0, 0, 0); |
| 247 | zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 248 | blob_zero(&manifest); |
| 249 | for(i=n=0; zName[i]; i++){ |
| 250 | if( zName[i]=='/' || zName[i]=='\\' ) n = i; |
| 251 | } |
| @@ -262,12 +262,13 @@ | |
| 262 | zDate = date_in_standard_format("now"); |
| 263 | blob_appendf(&manifest, "D %s\n", zDate); |
| 264 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 265 | md5sum_blob(&manifest, &cksum); |
| 266 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 267 | rid = content_put(&manifest, 0, 0, 0); |
| 268 | manifest_crosslink(rid, &manifest); |
| 269 | db_end_transaction(0); |
| 270 | cgi_redirect(zFrom); |
| 271 | } |
| 272 | style_header("Add Attachment"); |
| 273 | @ <h2>Add Attachment To %s(zTargetType)</h2> |
| @@ -341,11 +342,11 @@ | |
| 341 | zDate = date_in_standard_format("now"); |
| 342 | blob_appendf(&manifest, "D %s\n", zDate); |
| 343 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 344 | md5sum_blob(&manifest, &cksum); |
| 345 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 346 | rid = content_put(&manifest, 0, 0, 0); |
| 347 | manifest_crosslink(rid, &manifest); |
| 348 | db_end_transaction(0); |
| 349 | cgi_redirect(zFrom); |
| 350 | } |
| 351 | style_header("Delete Attachment"); |
| 352 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -241,11 +241,11 @@ | |
| 241 | int rid; |
| 242 | int i, n; |
| 243 | |
| 244 | db_begin_transaction(); |
| 245 | blob_init(&content, aContent, szContent); |
| 246 | rid = content_put(&content); |
| 247 | zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 248 | blob_zero(&manifest); |
| 249 | for(i=n=0; zName[i]; i++){ |
| 250 | if( zName[i]=='/' || zName[i]=='\\' ) n = i; |
| 251 | } |
| @@ -262,12 +262,13 @@ | |
| 262 | zDate = date_in_standard_format("now"); |
| 263 | blob_appendf(&manifest, "D %s\n", zDate); |
| 264 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 265 | md5sum_blob(&manifest, &cksum); |
| 266 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 267 | rid = content_put(&manifest); |
| 268 | manifest_crosslink(rid, &manifest); |
| 269 | assert( blob_is_reset(&manifest) ); |
| 270 | db_end_transaction(0); |
| 271 | cgi_redirect(zFrom); |
| 272 | } |
| 273 | style_header("Add Attachment"); |
| 274 | @ <h2>Add Attachment To %s(zTargetType)</h2> |
| @@ -341,11 +342,11 @@ | |
| 342 | zDate = date_in_standard_format("now"); |
| 343 | blob_appendf(&manifest, "D %s\n", zDate); |
| 344 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 345 | md5sum_blob(&manifest, &cksum); |
| 346 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 347 | rid = content_put(&manifest); |
| 348 | manifest_crosslink(rid, &manifest); |
| 349 | db_end_transaction(0); |
| 350 | cgi_redirect(zFrom); |
| 351 | } |
| 352 | style_header("Delete Attachment"); |
| 353 |
+113
-318
| --- src/bisect.c | ||
| +++ src/bisect.c | ||
| @@ -21,205 +21,74 @@ | ||
| 21 | 21 | */ |
| 22 | 22 | #include "config.h" |
| 23 | 23 | #include "bisect.h" |
| 24 | 24 | #include <assert.h> |
| 25 | 25 | |
| 26 | -/* Nodes for the shortest path algorithm. | |
| 27 | -*/ | |
| 28 | -typedef struct BisectNode BisectNode; | |
| 29 | -struct BisectNode { | |
| 30 | - int rid; /* ID for this node */ | |
| 31 | - int fromIsParent; /* True if pFrom is the parent of rid */ | |
| 32 | - BisectNode *pFrom; /* Node we came from */ | |
| 33 | - union { | |
| 34 | - BisectNode *pPeer; /* List of nodes of the same generation */ | |
| 35 | - BisectNode *pTo; /* Next on path from beginning to end */ | |
| 36 | - } u; | |
| 37 | - BisectNode *pAll; /* List of all nodes */ | |
| 38 | -}; | |
| 39 | - | |
| 40 | 26 | /* |
| 41 | 27 | ** Local variables for this module |
| 42 | 28 | */ |
| 43 | 29 | static struct { |
| 44 | - BisectNode *pCurrent; /* Current generation of nodes */ | |
| 45 | - BisectNode *pAll; /* All nodes */ | |
| 46 | - Bag seen; /* Nodes seen before */ | |
| 47 | 30 | int bad; /* The bad version */ |
| 48 | 31 | int good; /* The good version */ |
| 49 | - int nStep; /* Number of steps from good to bad */ | |
| 50 | - BisectNode *pStart; /* Earliest node (bad) */ | |
| 51 | - BisectNode *pEnd; /* Most recent (good) */ | |
| 52 | 32 | } bisect; |
| 53 | 33 | |
| 54 | -/* | |
| 55 | -** Create a new node | |
| 56 | -*/ | |
| 57 | -static BisectNode *bisect_new_node(int rid, BisectNode *pFrom, int isParent){ | |
| 58 | - BisectNode *p; | |
| 59 | - | |
| 60 | - p = fossil_malloc( sizeof(*p) ); | |
| 61 | - p->rid = rid; | |
| 62 | - p->fromIsParent = isParent; | |
| 63 | - p->pFrom = pFrom; | |
| 64 | - p->u.pPeer = bisect.pCurrent; | |
| 65 | - bisect.pCurrent = p; | |
| 66 | - p->pAll = bisect.pAll; | |
| 67 | - bisect.pAll = p; | |
| 68 | - bisect.pEnd = p; | |
| 69 | - bag_insert(&bisect.seen, rid); | |
| 70 | - return p; | |
| 71 | -} | |
| 72 | - | |
| 73 | -/* | |
| 74 | -** Reset memory used by the shortest path algorithm. | |
| 75 | -*/ | |
| 76 | -static void bisect_reset(void){ | |
| 77 | - BisectNode *p; | |
| 78 | - while( bisect.pAll ){ | |
| 79 | - p = bisect.pAll; | |
| 80 | - bisect.pAll = p->pAll; | |
| 81 | - fossil_free(p); | |
| 82 | - } | |
| 83 | - bag_clear(&bisect.seen); | |
| 84 | - bisect.pCurrent = 0; | |
| 85 | - bisect.pAll = 0; | |
| 86 | - bisect.pEnd = 0; | |
| 87 | - bisect.nStep = 0; | |
| 88 | -} | |
| 89 | - | |
| 90 | -/* | |
| 91 | -** Compute the shortest path from iFrom to iTo | |
| 92 | -** | |
| 93 | -** If directOnly is true, then use only the "primary" links from parent to | |
| 94 | -** child. In other words, ignore merges. | |
| 95 | -*/ | |
| 96 | -static BisectNode *bisect_shortest_path(int iFrom, int iTo, int directOnly){ | |
| 97 | - Stmt s; | |
| 98 | - BisectNode *pPrev; | |
| 99 | - BisectNode *p; | |
| 100 | - | |
| 101 | - bisect_reset(); | |
| 102 | - bisect.pStart = bisect_new_node(iFrom, 0, 0); | |
| 103 | - if( iTo==iFrom ) return bisect.pStart; | |
| 104 | - if( directOnly ){ | |
| 105 | - db_prepare(&s, | |
| 106 | - "SELECT cid, 1 FROM plink WHERE pid=:pid AND isprim " | |
| 107 | - "UNION ALL " | |
| 108 | - "SELECT pid, 0 FROM plink WHERE cid=:pid AND isprim" | |
| 109 | - ); | |
| 110 | - }else{ | |
| 111 | - db_prepare(&s, | |
| 112 | - "SELECT cid, 1 FROM plink WHERE pid=:pid " | |
| 113 | - "UNION ALL " | |
| 114 | - "SELECT pid, 0 FROM plink WHERE cid=:pid" | |
| 115 | - ); | |
| 116 | - } | |
| 117 | - while( bisect.pCurrent ){ | |
| 118 | - bisect.nStep++; | |
| 119 | - pPrev = bisect.pCurrent; | |
| 120 | - bisect.pCurrent = 0; | |
| 121 | - while( pPrev ){ | |
| 122 | - db_bind_int(&s, ":pid", pPrev->rid); | |
| 123 | - while( db_step(&s)==SQLITE_ROW ){ | |
| 124 | - int cid = db_column_int(&s, 0); | |
| 125 | - int isParent = db_column_int(&s, 1); | |
| 126 | - if( bag_find(&bisect.seen, cid) ) continue; | |
| 127 | - p = bisect_new_node(cid, pPrev, isParent); | |
| 128 | - if( cid==iTo ){ | |
| 129 | - db_finalize(&s); | |
| 130 | - return p; | |
| 131 | - } | |
| 132 | - } | |
| 133 | - db_reset(&s); | |
| 134 | - pPrev = pPrev->u.pPeer; | |
| 135 | - } | |
| 136 | - } | |
| 137 | - bisect_reset(); | |
| 138 | - return 0; | |
| 139 | -} | |
| 140 | - | |
| 141 | -/* | |
| 142 | -** Construct the path from bisect.pStart to bisect.pEnd in the u.pTo fields. | |
| 143 | -*/ | |
| 144 | -static void bisect_reverse_path(void){ | |
| 145 | - BisectNode *p; | |
| 146 | - for(p=bisect.pEnd; p && p->pFrom; p = p->pFrom){ | |
| 147 | - p->pFrom->u.pTo = p; | |
| 148 | - } | |
| 149 | - bisect.pEnd->u.pTo = 0; | |
| 150 | - assert( p==bisect.pStart ); | |
| 151 | -} | |
| 152 | - | |
| 153 | -/* | |
| 154 | -** COMMAND: test-shortest-path | |
| 155 | -** | |
| 156 | -** Usage: %fossil test-shortest-path ?--no-merge? VERSION1 VERSION2 | |
| 157 | -** | |
| 158 | -** Report the shortest path between two checkins. If the --no-merge flag | |
| 159 | -** is used, follow only direct parent-child paths and omit merge links. | |
| 160 | -*/ | |
| 161 | -void shortest_path_test_cmd(void){ | |
| 162 | - int iFrom; | |
| 163 | - int iTo; | |
| 164 | - BisectNode *p; | |
| 165 | - int n; | |
| 166 | - int directOnly; | |
| 167 | - | |
| 168 | - db_find_and_open_repository(0,0); | |
| 169 | - directOnly = find_option("no-merge",0,0)!=0; | |
| 170 | - if( g.argc!=4 ) usage("VERSION1 VERSION2"); | |
| 171 | - iFrom = name_to_rid(g.argv[2]); | |
| 172 | - iTo = name_to_rid(g.argv[3]); | |
| 173 | - p = bisect_shortest_path(iFrom, iTo, directOnly); | |
| 174 | - if( p==0 ){ | |
| 175 | - fossil_fatal("no path from %s to %s", g.argv[1], g.argv[2]); | |
| 176 | - } | |
| 177 | - bisect_reverse_path(); | |
| 178 | - for(n=1, p=bisect.pStart; p; p=p->u.pTo, n++){ | |
| 179 | - char *z; | |
| 180 | - z = db_text(0, | |
| 181 | - "SELECT substr(uuid,1,12) || ' ' || datetime(mtime)" | |
| 182 | - " FROM blob, event" | |
| 183 | - " WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'", | |
| 184 | - p->rid, p->rid); | |
| 185 | - printf("%4d: %s", n, z); | |
| 186 | - fossil_free(z); | |
| 187 | - if( p->u.pTo ){ | |
| 188 | - printf(" is a %s of\n", p->u.pTo->fromIsParent ? "parent" : "child"); | |
| 189 | - }else{ | |
| 190 | - printf("\n"); | |
| 191 | - } | |
| 192 | - } | |
| 193 | -} | |
| 194 | - | |
| 195 | 34 | /* |
| 196 | 35 | ** Find the shortest path between bad and good. |
| 197 | 36 | */ |
| 198 | -static BisectNode *bisect_path(void){ | |
| 199 | - BisectNode *p; | |
| 37 | +void bisect_path(void){ | |
| 38 | + PathNode *p; | |
| 200 | 39 | bisect.bad = db_lget_int("bisect-bad", 0); |
| 201 | 40 | if( bisect.bad==0 ){ |
| 202 | - bisect.bad = db_int(0, "SELECT cid FROM plink ORDER BY mtime DESC LIMIT 1"); | |
| 203 | - db_lset_int("bisect-bad", bisect.bad); | |
| 41 | + fossil_fatal("no \"bad\" version has been identified"); | |
| 204 | 42 | } |
| 205 | 43 | bisect.good = db_lget_int("bisect-good", 0); |
| 206 | 44 | if( bisect.good==0 ){ |
| 207 | - bisect.good = db_int(0,"SELECT pid FROM plink ORDER BY mtime LIMIT 1"); | |
| 208 | - db_lset_int("bisect-good", bisect.good); | |
| 45 | + fossil_fatal("no \"good\" version has been identified"); | |
| 209 | 46 | } |
| 210 | - p = bisect_shortest_path(bisect.good, bisect.bad, 0); | |
| 47 | + p = path_shortest(bisect.good, bisect.bad, bisect_option("direct-only")); | |
| 211 | 48 | if( p==0 ){ |
| 212 | 49 | char *zBad = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", bisect.bad); |
| 213 | 50 | char *zGood = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", bisect.good); |
| 214 | 51 | fossil_fatal("no path from good ([%S]) to bad ([%S]) or back", |
| 215 | 52 | zGood, zBad); |
| 216 | 53 | } |
| 217 | - return p; | |
| 218 | 54 | } |
| 219 | 55 | |
| 56 | +/* | |
| 57 | +** The set of all bisect options. | |
| 58 | +*/ | |
| 59 | +static const struct { | |
| 60 | + const char *zName; | |
| 61 | + const char *zDefault; | |
| 62 | + const char *zDesc; | |
| 63 | +} aBisectOption[] = { | |
| 64 | + { "auto-next", "on", "Automatically run \"bisect next\" after each " | |
| 65 | + "\"bisect good\" or \"bisect bad\"" }, | |
| 66 | + { "direct-only", "on", "Follow only primary parent-child links, not " | |
| 67 | + "merges\n" }, | |
| 68 | +}; | |
| 220 | 69 | |
| 70 | +/* | |
| 71 | +** Return the value of a boolean bisect option. | |
| 72 | +*/ | |
| 73 | +int bisect_option(const char *zName){ | |
| 74 | + unsigned int i; | |
| 75 | + int r = -1; | |
| 76 | + for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ | |
| 77 | + if( fossil_strcmp(zName, aBisectOption[i].zName)==0 ){ | |
| 78 | + char *zLabel = mprintf("bisect-%s", zName); | |
| 79 | + char *z = db_lget(zLabel, (char*)aBisectOption[i].zDefault); | |
| 80 | + if( is_truth(z) ) r = 1; | |
| 81 | + if( is_false(z) ) r = 0; | |
| 82 | + if( r<0 ) r = is_truth(aBisectOption[i].zDefault); | |
| 83 | + free(zLabel); | |
| 84 | + break; | |
| 85 | + } | |
| 86 | + } | |
| 87 | + assert( r>=0 ); | |
| 88 | + return r; | |
| 89 | +} | |
| 221 | 90 | |
| 222 | 91 | /* |
| 223 | 92 | ** COMMAND: bisect |
| 224 | 93 | ** |
| 225 | 94 | ** Usage: %fossil bisect SUBCOMMAND ... |
| @@ -239,10 +108,15 @@ | ||
| 239 | 108 | ** fossil bisect next |
| 240 | 109 | ** |
| 241 | 110 | ** Update to the next version that is halfway between the working and |
| 242 | 111 | ** non-working versions. |
| 243 | 112 | ** |
| 113 | +** fossil bisect options ?NAME? ?VALUE? | |
| 114 | +** | |
| 115 | +** List all bisect options, or the value of a single option, or set the | |
| 116 | +** value of a bisect option. | |
| 117 | +** | |
| 244 | 118 | ** fossil bisect reset |
| 245 | 119 | ** |
| 246 | 120 | ** Reinitialize a bisect session. This cancels prior bisect history |
| 247 | 121 | ** and allows a bisect session to start over from the beginning. |
| 248 | 122 | ** |
| @@ -252,202 +126,123 @@ | ||
| 252 | 126 | */ |
| 253 | 127 | void bisect_cmd(void){ |
| 254 | 128 | int n; |
| 255 | 129 | const char *zCmd; |
| 256 | 130 | db_must_be_within_tree(); |
| 131 | + if( g.argc<3 ){ | |
| 132 | + usage("bisect SUBCOMMAND ARGS..."); | |
| 133 | + } | |
| 257 | 134 | zCmd = g.argv[2]; |
| 258 | 135 | n = strlen(zCmd); |
| 259 | 136 | if( n==0 ) zCmd = "-"; |
| 260 | 137 | if( memcmp(zCmd, "bad", n)==0 ){ |
| 261 | 138 | int ridBad; |
| 262 | 139 | if( g.argc==3 ){ |
| 263 | 140 | ridBad = db_lget_int("checkout",0); |
| 264 | 141 | }else{ |
| 265 | - ridBad = name_to_rid(g.argv[3]); | |
| 142 | + ridBad = name_to_typed_rid(g.argv[3], "ci"); | |
| 266 | 143 | } |
| 267 | 144 | db_lset_int("bisect-bad", ridBad); |
| 145 | + if( ridBad>0 | |
| 146 | + && bisect_option("auto-next") | |
| 147 | + && db_lget_int("bisect-good",0)>0 | |
| 148 | + ){ | |
| 149 | + zCmd = "next"; | |
| 150 | + n = 4; | |
| 151 | + }else{ | |
| 152 | + return; | |
| 153 | + } | |
| 268 | 154 | }else if( memcmp(zCmd, "good", n)==0 ){ |
| 269 | 155 | int ridGood; |
| 270 | 156 | if( g.argc==3 ){ |
| 271 | 157 | ridGood = db_lget_int("checkout",0); |
| 272 | 158 | }else{ |
| 273 | - ridGood = name_to_rid(g.argv[3]); | |
| 159 | + ridGood = name_to_typed_rid(g.argv[3], "ci"); | |
| 274 | 160 | } |
| 275 | 161 | db_lset_int("bisect-good", ridGood); |
| 276 | - }else if( memcmp(zCmd, "next", n)==0 ){ | |
| 277 | - BisectNode *p; | |
| 278 | - int n; | |
| 162 | + if( ridGood>0 | |
| 163 | + && bisect_option("auto-next") | |
| 164 | + && db_lget_int("bisect-bad",0)>0 | |
| 165 | + ){ | |
| 166 | + zCmd = "next"; | |
| 167 | + n = 4; | |
| 168 | + }else{ | |
| 169 | + return; | |
| 170 | + } | |
| 171 | + } | |
| 172 | + if( memcmp(zCmd, "next", n)==0 ){ | |
| 173 | + PathNode *pMid; | |
| 279 | 174 | bisect_path(); |
| 280 | - if( bisect.nStep<2 ){ | |
| 175 | + pMid = path_midpoint(); | |
| 176 | + if( pMid==0 ){ | |
| 281 | 177 | fossil_fatal("bisect is done - there are no more intermediate versions"); |
| 282 | 178 | } |
| 283 | - for(p=bisect.pEnd, n=0; p && n<bisect.nStep/2; p=p->pFrom, n++){} | |
| 284 | 179 | g.argv[1] = "update"; |
| 285 | - g.argv[2] = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", p->rid); | |
| 180 | + g.argv[2] = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pMid->rid); | |
| 286 | 181 | g.argc = 3; |
| 287 | 182 | g.fNoSync = 1; |
| 288 | 183 | update_cmd(); |
| 184 | + }else if( memcmp(zCmd, "options", n)==0 ){ | |
| 185 | + if( g.argc==3 ){ | |
| 186 | + unsigned int i; | |
| 187 | + for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ | |
| 188 | + char *z = mprintf("bisect-%s", aBisectOption[i].zName); | |
| 189 | + fossil_print(" %-15s %-6s ", aBisectOption[i].zName, | |
| 190 | + db_lget(z, (char*)aBisectOption[i].zDefault)); | |
| 191 | + fossil_free(z); | |
| 192 | + comment_print(aBisectOption[i].zDesc, 27, 79); | |
| 193 | + } | |
| 194 | + }else if( g.argc==4 || g.argc==5 ){ | |
| 195 | + unsigned int i; | |
| 196 | + n = strlen(g.argv[3]); | |
| 197 | + for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ | |
| 198 | + if( memcmp(g.argv[3], aBisectOption[i].zName, n)==0 ){ | |
| 199 | + char *z = mprintf("bisect-%s", aBisectOption[i].zName); | |
| 200 | + if( g.argc==5 ){ | |
| 201 | + db_lset(z, g.argv[4]); | |
| 202 | + } | |
| 203 | + fossil_print("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault)); | |
| 204 | + fossil_free(z); | |
| 205 | + break; | |
| 206 | + } | |
| 207 | + } | |
| 208 | + if( i>=sizeof(aBisectOption)/sizeof(aBisectOption[0]) ){ | |
| 209 | + fossil_fatal("no such bisect option: %s", g.argv[3]); | |
| 210 | + } | |
| 211 | + }else{ | |
| 212 | + usage("bisect option ?NAME? ?VALUE?"); | |
| 213 | + } | |
| 289 | 214 | }else if( memcmp(zCmd, "reset", n)==0 ){ |
| 290 | 215 | db_multi_exec( |
| 291 | - "REPLACE INTO vvar(name, value) " | |
| 292 | - " SELECT 'bisect-good', pid FROM plink ORDER BY mtime LIMIT 1;" | |
| 293 | - "REPLACE INTO vvar(name, value) " | |
| 294 | - " SELECT 'bisect-bad', cid FROM plink ORDER BY mtime DESC LIMIT 1;" | |
| 216 | + "DELETE FROM vvar WHERE name IN ('bisect-good', 'bisect-bad');" | |
| 295 | 217 | ); |
| 296 | 218 | }else if( memcmp(zCmd, "vlist", n)==0 ){ |
| 297 | - BisectNode *p; | |
| 219 | + PathNode *p; | |
| 298 | 220 | int vid = db_lget_int("checkout", 0); |
| 299 | 221 | int n; |
| 300 | 222 | Stmt s; |
| 223 | + int nStep; | |
| 301 | 224 | bisect_path(); |
| 302 | 225 | db_prepare(&s, "SELECT substr(blob.uuid,1,20) || ' ' || " |
| 303 | 226 | " datetime(event.mtime) FROM blob, event" |
| 304 | 227 | " WHERE blob.rid=:rid AND event.objid=:rid" |
| 305 | 228 | " AND event.type='ci'"); |
| 306 | - for(p=bisect.pEnd, n=0; p; p=p->pFrom, n++){ | |
| 229 | + nStep = path_length(); | |
| 230 | + for(p=path_last(), n=0; p; p=p->pFrom, n++){ | |
| 307 | 231 | const char *z; |
| 308 | 232 | db_bind_int(&s, ":rid", p->rid); |
| 309 | 233 | if( db_step(&s)==SQLITE_ROW ){ |
| 310 | 234 | z = db_column_text(&s, 0); |
| 311 | - printf("%s", z); | |
| 312 | - if( p->rid==bisect.good ) printf(" GOOD"); | |
| 313 | - if( p->rid==bisect.bad ) printf(" BAD"); | |
| 314 | - if( p->rid==vid ) printf(" CURRENT"); | |
| 315 | - if( bisect.nStep>1 && n==bisect.nStep/2 ) printf(" NEXT"); | |
| 316 | - printf("\n"); | |
| 235 | + fossil_print("%s", z); | |
| 236 | + if( p->rid==bisect.good ) fossil_print(" GOOD"); | |
| 237 | + if( p->rid==bisect.bad ) fossil_print(" BAD"); | |
| 238 | + if( p->rid==vid ) fossil_print(" CURRENT"); | |
| 239 | + if( nStep>1 && n==nStep/2 ) fossil_print(" NEXT"); | |
| 240 | + fossil_print("\n"); | |
| 317 | 241 | } |
| 318 | 242 | db_reset(&s); |
| 319 | 243 | } |
| 320 | 244 | db_finalize(&s); |
| 321 | 245 | }else{ |
| 322 | 246 | usage("bad|good|next|reset|vlist ..."); |
| 323 | 247 | } |
| 324 | 248 | } |
| 325 | - | |
| 326 | -/* | |
| 327 | -** A record of a file rename operation. | |
| 328 | -*/ | |
| 329 | -typedef struct NameChange NameChange; | |
| 330 | -struct NameChange { | |
| 331 | - int origName; /* Original name of file */ | |
| 332 | - int curName; /* Current name of the file */ | |
| 333 | - int newName; /* Name of file in next version */ | |
| 334 | - NameChange *pNext; /* List of all name changes */ | |
| 335 | -}; | |
| 336 | - | |
| 337 | -/* | |
| 338 | -** Compute all file name changes that occur going from checkin iFrom | |
| 339 | -** to checkin iTo. | |
| 340 | -** | |
| 341 | -** The number of name changes is written into *pnChng. For each name | |
| 342 | -** change, two integers are allocated for *piChng. The first is the | |
| 343 | -** filename.fnid for the original name and the second is for new name. | |
| 344 | -** Space to hold *piChng is obtained from fossil_malloc() and should | |
| 345 | -** be released by the caller. | |
| 346 | -** | |
| 347 | -** This routine really has nothing to do with bisection. It is located | |
| 348 | -** in this bisect.c module in order to leverage some of the bisect | |
| 349 | -** infrastructure. | |
| 350 | -*/ | |
| 351 | -void find_filename_changes( | |
| 352 | - int iFrom, | |
| 353 | - int iTo, | |
| 354 | - int *pnChng, | |
| 355 | - int **aiChng | |
| 356 | -){ | |
| 357 | - BisectNode *p; /* For looping over path from iFrom to iTo */ | |
| 358 | - NameChange *pAll = 0; /* List of all name changes seen so far */ | |
| 359 | - NameChange *pChng; /* For looping through the name change list */ | |
| 360 | - int nChng = 0; /* Number of files whose names have changed */ | |
| 361 | - int *aChng; /* Two integers per name change */ | |
| 362 | - int i; /* Loop counter */ | |
| 363 | - Stmt q1; /* Query of name changes */ | |
| 364 | - | |
| 365 | - *pnChng = 0; | |
| 366 | - *aiChng = 0; | |
| 367 | - bisect_reset(); | |
| 368 | - p = bisect_shortest_path(iFrom, iTo, 0); | |
| 369 | - if( p==0 ) return; | |
| 370 | - bisect_reverse_path(); | |
| 371 | - db_prepare(&q1, | |
| 372 | - "SELECT pfnid, fnid FROM mlink WHERE mid=:mid AND pfnid>0" | |
| 373 | - ); | |
| 374 | - for(p=bisect.pStart; p; p=p->u.pTo){ | |
| 375 | - int fnid, pfnid; | |
| 376 | - if( !p->fromIsParent && (p->u.pTo==0 || p->u.pTo->fromIsParent) ){ | |
| 377 | - /* Skip nodes where the parent is not on the path */ | |
| 378 | - continue; | |
| 379 | - } | |
| 380 | - db_bind_int(&q1, ":mid", p->rid); | |
| 381 | - while( db_step(&q1)==SQLITE_ROW ){ | |
| 382 | - if( p->fromIsParent ){ | |
| 383 | - fnid = db_column_int(&q1, 1); | |
| 384 | - pfnid = db_column_int(&q1, 0); | |
| 385 | - }else{ | |
| 386 | - fnid = db_column_int(&q1, 0); | |
| 387 | - pfnid = db_column_int(&q1, 1); | |
| 388 | - } | |
| 389 | - for(pChng=pAll; pChng; pChng=pChng->pNext){ | |
| 390 | - if( pChng->curName==pfnid ){ | |
| 391 | - pChng->newName = fnid; | |
| 392 | - break; | |
| 393 | - } | |
| 394 | - } | |
| 395 | - if( pChng==0 ){ | |
| 396 | - pChng = fossil_malloc( sizeof(*pChng) ); | |
| 397 | - pChng->pNext = pAll; | |
| 398 | - pAll = pChng; | |
| 399 | - pChng->origName = pfnid; | |
| 400 | - pChng->curName = pfnid; | |
| 401 | - pChng->newName = fnid; | |
| 402 | - nChng++; | |
| 403 | - } | |
| 404 | - } | |
| 405 | - for(pChng=pAll; pChng; pChng=pChng->pNext) pChng->curName = pChng->newName; | |
| 406 | - db_reset(&q1); | |
| 407 | - } | |
| 408 | - db_finalize(&q1); | |
| 409 | - if( nChng ){ | |
| 410 | - *pnChng = nChng; | |
| 411 | - aChng = *aiChng = fossil_malloc( nChng*2*sizeof(int) ); | |
| 412 | - for(pChng=pAll, i=0; pChng; pChng=pChng->pNext, i+=2){ | |
| 413 | - aChng[i] = pChng->origName; | |
| 414 | - aChng[i+1] = pChng->newName; | |
| 415 | - } | |
| 416 | - while( pAll ){ | |
| 417 | - pChng = pAll; | |
| 418 | - pAll = pAll->pNext; | |
| 419 | - fossil_free(pChng); | |
| 420 | - } | |
| 421 | - } | |
| 422 | -} | |
| 423 | - | |
| 424 | -/* | |
| 425 | -** COMMAND: test-name-changes | |
| 426 | -** | |
| 427 | -** Usage: %fossil test-name-changes VERSION1 VERSION2 | |
| 428 | -** | |
| 429 | -** Show all filename changes that occur going from VERSION1 to VERSION2 | |
| 430 | -*/ | |
| 431 | -void test_name_change(void){ | |
| 432 | - int iFrom; | |
| 433 | - int iTo; | |
| 434 | - int *aChng; | |
| 435 | - int nChng; | |
| 436 | - int i; | |
| 437 | - | |
| 438 | - db_find_and_open_repository(0,0); | |
| 439 | - if( g.argc!=4 ) usage("VERSION1 VERSION2"); | |
| 440 | - iFrom = name_to_rid(g.argv[2]); | |
| 441 | - iTo = name_to_rid(g.argv[3]); | |
| 442 | - find_filename_changes(iFrom, iTo, &nChng, &aChng); | |
| 443 | - for(i=0; i<nChng; i++){ | |
| 444 | - char *zFrom, *zTo; | |
| 445 | - | |
| 446 | - zFrom = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2]); | |
| 447 | - zTo = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2+1]); | |
| 448 | - printf("[%s] -> [%s]\n", zFrom, zTo); | |
| 449 | - fossil_free(zFrom); | |
| 450 | - fossil_free(zTo); | |
| 451 | - } | |
| 452 | - fossil_free(aChng); | |
| 453 | -} | |
| 454 | 249 |
| --- src/bisect.c | |
| +++ src/bisect.c | |
| @@ -21,205 +21,74 @@ | |
| 21 | */ |
| 22 | #include "config.h" |
| 23 | #include "bisect.h" |
| 24 | #include <assert.h> |
| 25 | |
| 26 | /* Nodes for the shortest path algorithm. |
| 27 | */ |
| 28 | typedef struct BisectNode BisectNode; |
| 29 | struct BisectNode { |
| 30 | int rid; /* ID for this node */ |
| 31 | int fromIsParent; /* True if pFrom is the parent of rid */ |
| 32 | BisectNode *pFrom; /* Node we came from */ |
| 33 | union { |
| 34 | BisectNode *pPeer; /* List of nodes of the same generation */ |
| 35 | BisectNode *pTo; /* Next on path from beginning to end */ |
| 36 | } u; |
| 37 | BisectNode *pAll; /* List of all nodes */ |
| 38 | }; |
| 39 | |
| 40 | /* |
| 41 | ** Local variables for this module |
| 42 | */ |
| 43 | static struct { |
| 44 | BisectNode *pCurrent; /* Current generation of nodes */ |
| 45 | BisectNode *pAll; /* All nodes */ |
| 46 | Bag seen; /* Nodes seen before */ |
| 47 | int bad; /* The bad version */ |
| 48 | int good; /* The good version */ |
| 49 | int nStep; /* Number of steps from good to bad */ |
| 50 | BisectNode *pStart; /* Earliest node (bad) */ |
| 51 | BisectNode *pEnd; /* Most recent (good) */ |
| 52 | } bisect; |
| 53 | |
| 54 | /* |
| 55 | ** Create a new node |
| 56 | */ |
| 57 | static BisectNode *bisect_new_node(int rid, BisectNode *pFrom, int isParent){ |
| 58 | BisectNode *p; |
| 59 | |
| 60 | p = fossil_malloc( sizeof(*p) ); |
| 61 | p->rid = rid; |
| 62 | p->fromIsParent = isParent; |
| 63 | p->pFrom = pFrom; |
| 64 | p->u.pPeer = bisect.pCurrent; |
| 65 | bisect.pCurrent = p; |
| 66 | p->pAll = bisect.pAll; |
| 67 | bisect.pAll = p; |
| 68 | bisect.pEnd = p; |
| 69 | bag_insert(&bisect.seen, rid); |
| 70 | return p; |
| 71 | } |
| 72 | |
| 73 | /* |
| 74 | ** Reset memory used by the shortest path algorithm. |
| 75 | */ |
| 76 | static void bisect_reset(void){ |
| 77 | BisectNode *p; |
| 78 | while( bisect.pAll ){ |
| 79 | p = bisect.pAll; |
| 80 | bisect.pAll = p->pAll; |
| 81 | fossil_free(p); |
| 82 | } |
| 83 | bag_clear(&bisect.seen); |
| 84 | bisect.pCurrent = 0; |
| 85 | bisect.pAll = 0; |
| 86 | bisect.pEnd = 0; |
| 87 | bisect.nStep = 0; |
| 88 | } |
| 89 | |
| 90 | /* |
| 91 | ** Compute the shortest path from iFrom to iTo |
| 92 | ** |
| 93 | ** If directOnly is true, then use only the "primary" links from parent to |
| 94 | ** child. In other words, ignore merges. |
| 95 | */ |
| 96 | static BisectNode *bisect_shortest_path(int iFrom, int iTo, int directOnly){ |
| 97 | Stmt s; |
| 98 | BisectNode *pPrev; |
| 99 | BisectNode *p; |
| 100 | |
| 101 | bisect_reset(); |
| 102 | bisect.pStart = bisect_new_node(iFrom, 0, 0); |
| 103 | if( iTo==iFrom ) return bisect.pStart; |
| 104 | if( directOnly ){ |
| 105 | db_prepare(&s, |
| 106 | "SELECT cid, 1 FROM plink WHERE pid=:pid AND isprim " |
| 107 | "UNION ALL " |
| 108 | "SELECT pid, 0 FROM plink WHERE cid=:pid AND isprim" |
| 109 | ); |
| 110 | }else{ |
| 111 | db_prepare(&s, |
| 112 | "SELECT cid, 1 FROM plink WHERE pid=:pid " |
| 113 | "UNION ALL " |
| 114 | "SELECT pid, 0 FROM plink WHERE cid=:pid" |
| 115 | ); |
| 116 | } |
| 117 | while( bisect.pCurrent ){ |
| 118 | bisect.nStep++; |
| 119 | pPrev = bisect.pCurrent; |
| 120 | bisect.pCurrent = 0; |
| 121 | while( pPrev ){ |
| 122 | db_bind_int(&s, ":pid", pPrev->rid); |
| 123 | while( db_step(&s)==SQLITE_ROW ){ |
| 124 | int cid = db_column_int(&s, 0); |
| 125 | int isParent = db_column_int(&s, 1); |
| 126 | if( bag_find(&bisect.seen, cid) ) continue; |
| 127 | p = bisect_new_node(cid, pPrev, isParent); |
| 128 | if( cid==iTo ){ |
| 129 | db_finalize(&s); |
| 130 | return p; |
| 131 | } |
| 132 | } |
| 133 | db_reset(&s); |
| 134 | pPrev = pPrev->u.pPeer; |
| 135 | } |
| 136 | } |
| 137 | bisect_reset(); |
| 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | /* |
| 142 | ** Construct the path from bisect.pStart to bisect.pEnd in the u.pTo fields. |
| 143 | */ |
| 144 | static void bisect_reverse_path(void){ |
| 145 | BisectNode *p; |
| 146 | for(p=bisect.pEnd; p && p->pFrom; p = p->pFrom){ |
| 147 | p->pFrom->u.pTo = p; |
| 148 | } |
| 149 | bisect.pEnd->u.pTo = 0; |
| 150 | assert( p==bisect.pStart ); |
| 151 | } |
| 152 | |
| 153 | /* |
| 154 | ** COMMAND: test-shortest-path |
| 155 | ** |
| 156 | ** Usage: %fossil test-shortest-path ?--no-merge? VERSION1 VERSION2 |
| 157 | ** |
| 158 | ** Report the shortest path between two checkins. If the --no-merge flag |
| 159 | ** is used, follow only direct parent-child paths and omit merge links. |
| 160 | */ |
| 161 | void shortest_path_test_cmd(void){ |
| 162 | int iFrom; |
| 163 | int iTo; |
| 164 | BisectNode *p; |
| 165 | int n; |
| 166 | int directOnly; |
| 167 | |
| 168 | db_find_and_open_repository(0,0); |
| 169 | directOnly = find_option("no-merge",0,0)!=0; |
| 170 | if( g.argc!=4 ) usage("VERSION1 VERSION2"); |
| 171 | iFrom = name_to_rid(g.argv[2]); |
| 172 | iTo = name_to_rid(g.argv[3]); |
| 173 | p = bisect_shortest_path(iFrom, iTo, directOnly); |
| 174 | if( p==0 ){ |
| 175 | fossil_fatal("no path from %s to %s", g.argv[1], g.argv[2]); |
| 176 | } |
| 177 | bisect_reverse_path(); |
| 178 | for(n=1, p=bisect.pStart; p; p=p->u.pTo, n++){ |
| 179 | char *z; |
| 180 | z = db_text(0, |
| 181 | "SELECT substr(uuid,1,12) || ' ' || datetime(mtime)" |
| 182 | " FROM blob, event" |
| 183 | " WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'", |
| 184 | p->rid, p->rid); |
| 185 | printf("%4d: %s", n, z); |
| 186 | fossil_free(z); |
| 187 | if( p->u.pTo ){ |
| 188 | printf(" is a %s of\n", p->u.pTo->fromIsParent ? "parent" : "child"); |
| 189 | }else{ |
| 190 | printf("\n"); |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | /* |
| 196 | ** Find the shortest path between bad and good. |
| 197 | */ |
| 198 | static BisectNode *bisect_path(void){ |
| 199 | BisectNode *p; |
| 200 | bisect.bad = db_lget_int("bisect-bad", 0); |
| 201 | if( bisect.bad==0 ){ |
| 202 | bisect.bad = db_int(0, "SELECT cid FROM plink ORDER BY mtime DESC LIMIT 1"); |
| 203 | db_lset_int("bisect-bad", bisect.bad); |
| 204 | } |
| 205 | bisect.good = db_lget_int("bisect-good", 0); |
| 206 | if( bisect.good==0 ){ |
| 207 | bisect.good = db_int(0,"SELECT pid FROM plink ORDER BY mtime LIMIT 1"); |
| 208 | db_lset_int("bisect-good", bisect.good); |
| 209 | } |
| 210 | p = bisect_shortest_path(bisect.good, bisect.bad, 0); |
| 211 | if( p==0 ){ |
| 212 | char *zBad = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", bisect.bad); |
| 213 | char *zGood = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", bisect.good); |
| 214 | fossil_fatal("no path from good ([%S]) to bad ([%S]) or back", |
| 215 | zGood, zBad); |
| 216 | } |
| 217 | return p; |
| 218 | } |
| 219 | |
| 220 | |
| 221 | |
| 222 | /* |
| 223 | ** COMMAND: bisect |
| 224 | ** |
| 225 | ** Usage: %fossil bisect SUBCOMMAND ... |
| @@ -239,10 +108,15 @@ | |
| 239 | ** fossil bisect next |
| 240 | ** |
| 241 | ** Update to the next version that is halfway between the working and |
| 242 | ** non-working versions. |
| 243 | ** |
| 244 | ** fossil bisect reset |
| 245 | ** |
| 246 | ** Reinitialize a bisect session. This cancels prior bisect history |
| 247 | ** and allows a bisect session to start over from the beginning. |
| 248 | ** |
| @@ -252,202 +126,123 @@ | |
| 252 | */ |
| 253 | void bisect_cmd(void){ |
| 254 | int n; |
| 255 | const char *zCmd; |
| 256 | db_must_be_within_tree(); |
| 257 | zCmd = g.argv[2]; |
| 258 | n = strlen(zCmd); |
| 259 | if( n==0 ) zCmd = "-"; |
| 260 | if( memcmp(zCmd, "bad", n)==0 ){ |
| 261 | int ridBad; |
| 262 | if( g.argc==3 ){ |
| 263 | ridBad = db_lget_int("checkout",0); |
| 264 | }else{ |
| 265 | ridBad = name_to_rid(g.argv[3]); |
| 266 | } |
| 267 | db_lset_int("bisect-bad", ridBad); |
| 268 | }else if( memcmp(zCmd, "good", n)==0 ){ |
| 269 | int ridGood; |
| 270 | if( g.argc==3 ){ |
| 271 | ridGood = db_lget_int("checkout",0); |
| 272 | }else{ |
| 273 | ridGood = name_to_rid(g.argv[3]); |
| 274 | } |
| 275 | db_lset_int("bisect-good", ridGood); |
| 276 | }else if( memcmp(zCmd, "next", n)==0 ){ |
| 277 | BisectNode *p; |
| 278 | int n; |
| 279 | bisect_path(); |
| 280 | if( bisect.nStep<2 ){ |
| 281 | fossil_fatal("bisect is done - there are no more intermediate versions"); |
| 282 | } |
| 283 | for(p=bisect.pEnd, n=0; p && n<bisect.nStep/2; p=p->pFrom, n++){} |
| 284 | g.argv[1] = "update"; |
| 285 | g.argv[2] = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", p->rid); |
| 286 | g.argc = 3; |
| 287 | g.fNoSync = 1; |
| 288 | update_cmd(); |
| 289 | }else if( memcmp(zCmd, "reset", n)==0 ){ |
| 290 | db_multi_exec( |
| 291 | "REPLACE INTO vvar(name, value) " |
| 292 | " SELECT 'bisect-good', pid FROM plink ORDER BY mtime LIMIT 1;" |
| 293 | "REPLACE INTO vvar(name, value) " |
| 294 | " SELECT 'bisect-bad', cid FROM plink ORDER BY mtime DESC LIMIT 1;" |
| 295 | ); |
| 296 | }else if( memcmp(zCmd, "vlist", n)==0 ){ |
| 297 | BisectNode *p; |
| 298 | int vid = db_lget_int("checkout", 0); |
| 299 | int n; |
| 300 | Stmt s; |
| 301 | bisect_path(); |
| 302 | db_prepare(&s, "SELECT substr(blob.uuid,1,20) || ' ' || " |
| 303 | " datetime(event.mtime) FROM blob, event" |
| 304 | " WHERE blob.rid=:rid AND event.objid=:rid" |
| 305 | " AND event.type='ci'"); |
| 306 | for(p=bisect.pEnd, n=0; p; p=p->pFrom, n++){ |
| 307 | const char *z; |
| 308 | db_bind_int(&s, ":rid", p->rid); |
| 309 | if( db_step(&s)==SQLITE_ROW ){ |
| 310 | z = db_column_text(&s, 0); |
| 311 | printf("%s", z); |
| 312 | if( p->rid==bisect.good ) printf(" GOOD"); |
| 313 | if( p->rid==bisect.bad ) printf(" BAD"); |
| 314 | if( p->rid==vid ) printf(" CURRENT"); |
| 315 | if( bisect.nStep>1 && n==bisect.nStep/2 ) printf(" NEXT"); |
| 316 | printf("\n"); |
| 317 | } |
| 318 | db_reset(&s); |
| 319 | } |
| 320 | db_finalize(&s); |
| 321 | }else{ |
| 322 | usage("bad|good|next|reset|vlist ..."); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | /* |
| 327 | ** A record of a file rename operation. |
| 328 | */ |
| 329 | typedef struct NameChange NameChange; |
| 330 | struct NameChange { |
| 331 | int origName; /* Original name of file */ |
| 332 | int curName; /* Current name of the file */ |
| 333 | int newName; /* Name of file in next version */ |
| 334 | NameChange *pNext; /* List of all name changes */ |
| 335 | }; |
| 336 | |
| 337 | /* |
| 338 | ** Compute all file name changes that occur going from checkin iFrom |
| 339 | ** to checkin iTo. |
| 340 | ** |
| 341 | ** The number of name changes is written into *pnChng. For each name |
| 342 | ** change, two integers are allocated for *piChng. The first is the |
| 343 | ** filename.fnid for the original name and the second is for new name. |
| 344 | ** Space to hold *piChng is obtained from fossil_malloc() and should |
| 345 | ** be released by the caller. |
| 346 | ** |
| 347 | ** This routine really has nothing to do with bisection. It is located |
| 348 | ** in this bisect.c module in order to leverage some of the bisect |
| 349 | ** infrastructure. |
| 350 | */ |
| 351 | void find_filename_changes( |
| 352 | int iFrom, |
| 353 | int iTo, |
| 354 | int *pnChng, |
| 355 | int **aiChng |
| 356 | ){ |
| 357 | BisectNode *p; /* For looping over path from iFrom to iTo */ |
| 358 | NameChange *pAll = 0; /* List of all name changes seen so far */ |
| 359 | NameChange *pChng; /* For looping through the name change list */ |
| 360 | int nChng = 0; /* Number of files whose names have changed */ |
| 361 | int *aChng; /* Two integers per name change */ |
| 362 | int i; /* Loop counter */ |
| 363 | Stmt q1; /* Query of name changes */ |
| 364 | |
| 365 | *pnChng = 0; |
| 366 | *aiChng = 0; |
| 367 | bisect_reset(); |
| 368 | p = bisect_shortest_path(iFrom, iTo, 0); |
| 369 | if( p==0 ) return; |
| 370 | bisect_reverse_path(); |
| 371 | db_prepare(&q1, |
| 372 | "SELECT pfnid, fnid FROM mlink WHERE mid=:mid AND pfnid>0" |
| 373 | ); |
| 374 | for(p=bisect.pStart; p; p=p->u.pTo){ |
| 375 | int fnid, pfnid; |
| 376 | if( !p->fromIsParent && (p->u.pTo==0 || p->u.pTo->fromIsParent) ){ |
| 377 | /* Skip nodes where the parent is not on the path */ |
| 378 | continue; |
| 379 | } |
| 380 | db_bind_int(&q1, ":mid", p->rid); |
| 381 | while( db_step(&q1)==SQLITE_ROW ){ |
| 382 | if( p->fromIsParent ){ |
| 383 | fnid = db_column_int(&q1, 1); |
| 384 | pfnid = db_column_int(&q1, 0); |
| 385 | }else{ |
| 386 | fnid = db_column_int(&q1, 0); |
| 387 | pfnid = db_column_int(&q1, 1); |
| 388 | } |
| 389 | for(pChng=pAll; pChng; pChng=pChng->pNext){ |
| 390 | if( pChng->curName==pfnid ){ |
| 391 | pChng->newName = fnid; |
| 392 | break; |
| 393 | } |
| 394 | } |
| 395 | if( pChng==0 ){ |
| 396 | pChng = fossil_malloc( sizeof(*pChng) ); |
| 397 | pChng->pNext = pAll; |
| 398 | pAll = pChng; |
| 399 | pChng->origName = pfnid; |
| 400 | pChng->curName = pfnid; |
| 401 | pChng->newName = fnid; |
| 402 | nChng++; |
| 403 | } |
| 404 | } |
| 405 | for(pChng=pAll; pChng; pChng=pChng->pNext) pChng->curName = pChng->newName; |
| 406 | db_reset(&q1); |
| 407 | } |
| 408 | db_finalize(&q1); |
| 409 | if( nChng ){ |
| 410 | *pnChng = nChng; |
| 411 | aChng = *aiChng = fossil_malloc( nChng*2*sizeof(int) ); |
| 412 | for(pChng=pAll, i=0; pChng; pChng=pChng->pNext, i+=2){ |
| 413 | aChng[i] = pChng->origName; |
| 414 | aChng[i+1] = pChng->newName; |
| 415 | } |
| 416 | while( pAll ){ |
| 417 | pChng = pAll; |
| 418 | pAll = pAll->pNext; |
| 419 | fossil_free(pChng); |
| 420 | } |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | /* |
| 425 | ** COMMAND: test-name-changes |
| 426 | ** |
| 427 | ** Usage: %fossil test-name-changes VERSION1 VERSION2 |
| 428 | ** |
| 429 | ** Show all filename changes that occur going from VERSION1 to VERSION2 |
| 430 | */ |
| 431 | void test_name_change(void){ |
| 432 | int iFrom; |
| 433 | int iTo; |
| 434 | int *aChng; |
| 435 | int nChng; |
| 436 | int i; |
| 437 | |
| 438 | db_find_and_open_repository(0,0); |
| 439 | if( g.argc!=4 ) usage("VERSION1 VERSION2"); |
| 440 | iFrom = name_to_rid(g.argv[2]); |
| 441 | iTo = name_to_rid(g.argv[3]); |
| 442 | find_filename_changes(iFrom, iTo, &nChng, &aChng); |
| 443 | for(i=0; i<nChng; i++){ |
| 444 | char *zFrom, *zTo; |
| 445 | |
| 446 | zFrom = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2]); |
| 447 | zTo = db_text(0, "SELECT name FROM filename WHERE fnid=%d", aChng[i*2+1]); |
| 448 | printf("[%s] -> [%s]\n", zFrom, zTo); |
| 449 | fossil_free(zFrom); |
| 450 | fossil_free(zTo); |
| 451 | } |
| 452 | fossil_free(aChng); |
| 453 | } |
| 454 |
| --- src/bisect.c | |
| +++ src/bisect.c | |
| @@ -21,205 +21,74 @@ | |
| 21 | */ |
| 22 | #include "config.h" |
| 23 | #include "bisect.h" |
| 24 | #include <assert.h> |
| 25 | |
| 26 | /* |
| 27 | ** Local variables for this module |
| 28 | */ |
| 29 | static struct { |
| 30 | int bad; /* The bad version */ |
| 31 | int good; /* The good version */ |
| 32 | } bisect; |
| 33 | |
| 34 | /* |
| 35 | ** Find the shortest path between bad and good. |
| 36 | */ |
| 37 | void bisect_path(void){ |
| 38 | PathNode *p; |
| 39 | bisect.bad = db_lget_int("bisect-bad", 0); |
| 40 | if( bisect.bad==0 ){ |
| 41 | fossil_fatal("no \"bad\" version has been identified"); |
| 42 | } |
| 43 | bisect.good = db_lget_int("bisect-good", 0); |
| 44 | if( bisect.good==0 ){ |
| 45 | fossil_fatal("no \"good\" version has been identified"); |
| 46 | } |
| 47 | p = path_shortest(bisect.good, bisect.bad, bisect_option("direct-only")); |
| 48 | if( p==0 ){ |
| 49 | char *zBad = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", bisect.bad); |
| 50 | char *zGood = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", bisect.good); |
| 51 | fossil_fatal("no path from good ([%S]) to bad ([%S]) or back", |
| 52 | zGood, zBad); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /* |
| 57 | ** The set of all bisect options. |
| 58 | */ |
| 59 | static const struct { |
| 60 | const char *zName; |
| 61 | const char *zDefault; |
| 62 | const char *zDesc; |
| 63 | } aBisectOption[] = { |
| 64 | { "auto-next", "on", "Automatically run \"bisect next\" after each " |
| 65 | "\"bisect good\" or \"bisect bad\"" }, |
| 66 | { "direct-only", "on", "Follow only primary parent-child links, not " |
| 67 | "merges\n" }, |
| 68 | }; |
| 69 | |
| 70 | /* |
| 71 | ** Return the value of a boolean bisect option. |
| 72 | */ |
| 73 | int bisect_option(const char *zName){ |
| 74 | unsigned int i; |
| 75 | int r = -1; |
| 76 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 77 | if( fossil_strcmp(zName, aBisectOption[i].zName)==0 ){ |
| 78 | char *zLabel = mprintf("bisect-%s", zName); |
| 79 | char *z = db_lget(zLabel, (char*)aBisectOption[i].zDefault); |
| 80 | if( is_truth(z) ) r = 1; |
| 81 | if( is_false(z) ) r = 0; |
| 82 | if( r<0 ) r = is_truth(aBisectOption[i].zDefault); |
| 83 | free(zLabel); |
| 84 | break; |
| 85 | } |
| 86 | } |
| 87 | assert( r>=0 ); |
| 88 | return r; |
| 89 | } |
| 90 | |
| 91 | /* |
| 92 | ** COMMAND: bisect |
| 93 | ** |
| 94 | ** Usage: %fossil bisect SUBCOMMAND ... |
| @@ -239,10 +108,15 @@ | |
| 108 | ** fossil bisect next |
| 109 | ** |
| 110 | ** Update to the next version that is halfway between the working and |
| 111 | ** non-working versions. |
| 112 | ** |
| 113 | ** fossil bisect options ?NAME? ?VALUE? |
| 114 | ** |
| 115 | ** List all bisect options, or the value of a single option, or set the |
| 116 | ** value of a bisect option. |
| 117 | ** |
| 118 | ** fossil bisect reset |
| 119 | ** |
| 120 | ** Reinitialize a bisect session. This cancels prior bisect history |
| 121 | ** and allows a bisect session to start over from the beginning. |
| 122 | ** |
| @@ -252,202 +126,123 @@ | |
| 126 | */ |
| 127 | void bisect_cmd(void){ |
| 128 | int n; |
| 129 | const char *zCmd; |
| 130 | db_must_be_within_tree(); |
| 131 | if( g.argc<3 ){ |
| 132 | usage("bisect SUBCOMMAND ARGS..."); |
| 133 | } |
| 134 | zCmd = g.argv[2]; |
| 135 | n = strlen(zCmd); |
| 136 | if( n==0 ) zCmd = "-"; |
| 137 | if( memcmp(zCmd, "bad", n)==0 ){ |
| 138 | int ridBad; |
| 139 | if( g.argc==3 ){ |
| 140 | ridBad = db_lget_int("checkout",0); |
| 141 | }else{ |
| 142 | ridBad = name_to_typed_rid(g.argv[3], "ci"); |
| 143 | } |
| 144 | db_lset_int("bisect-bad", ridBad); |
| 145 | if( ridBad>0 |
| 146 | && bisect_option("auto-next") |
| 147 | && db_lget_int("bisect-good",0)>0 |
| 148 | ){ |
| 149 | zCmd = "next"; |
| 150 | n = 4; |
| 151 | }else{ |
| 152 | return; |
| 153 | } |
| 154 | }else if( memcmp(zCmd, "good", n)==0 ){ |
| 155 | int ridGood; |
| 156 | if( g.argc==3 ){ |
| 157 | ridGood = db_lget_int("checkout",0); |
| 158 | }else{ |
| 159 | ridGood = name_to_typed_rid(g.argv[3], "ci"); |
| 160 | } |
| 161 | db_lset_int("bisect-good", ridGood); |
| 162 | if( ridGood>0 |
| 163 | && bisect_option("auto-next") |
| 164 | && db_lget_int("bisect-bad",0)>0 |
| 165 | ){ |
| 166 | zCmd = "next"; |
| 167 | n = 4; |
| 168 | }else{ |
| 169 | return; |
| 170 | } |
| 171 | } |
| 172 | if( memcmp(zCmd, "next", n)==0 ){ |
| 173 | PathNode *pMid; |
| 174 | bisect_path(); |
| 175 | pMid = path_midpoint(); |
| 176 | if( pMid==0 ){ |
| 177 | fossil_fatal("bisect is done - there are no more intermediate versions"); |
| 178 | } |
| 179 | g.argv[1] = "update"; |
| 180 | g.argv[2] = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pMid->rid); |
| 181 | g.argc = 3; |
| 182 | g.fNoSync = 1; |
| 183 | update_cmd(); |
| 184 | }else if( memcmp(zCmd, "options", n)==0 ){ |
| 185 | if( g.argc==3 ){ |
| 186 | unsigned int i; |
| 187 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 188 | char *z = mprintf("bisect-%s", aBisectOption[i].zName); |
| 189 | fossil_print(" %-15s %-6s ", aBisectOption[i].zName, |
| 190 | db_lget(z, (char*)aBisectOption[i].zDefault)); |
| 191 | fossil_free(z); |
| 192 | comment_print(aBisectOption[i].zDesc, 27, 79); |
| 193 | } |
| 194 | }else if( g.argc==4 || g.argc==5 ){ |
| 195 | unsigned int i; |
| 196 | n = strlen(g.argv[3]); |
| 197 | for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){ |
| 198 | if( memcmp(g.argv[3], aBisectOption[i].zName, n)==0 ){ |
| 199 | char *z = mprintf("bisect-%s", aBisectOption[i].zName); |
| 200 | if( g.argc==5 ){ |
| 201 | db_lset(z, g.argv[4]); |
| 202 | } |
| 203 | fossil_print("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault)); |
| 204 | fossil_free(z); |
| 205 | break; |
| 206 | } |
| 207 | } |
| 208 | if( i>=sizeof(aBisectOption)/sizeof(aBisectOption[0]) ){ |
| 209 | fossil_fatal("no such bisect option: %s", g.argv[3]); |
| 210 | } |
| 211 | }else{ |
| 212 | usage("bisect option ?NAME? ?VALUE?"); |
| 213 | } |
| 214 | }else if( memcmp(zCmd, "reset", n)==0 ){ |
| 215 | db_multi_exec( |
| 216 | "DELETE FROM vvar WHERE name IN ('bisect-good', 'bisect-bad');" |
| 217 | ); |
| 218 | }else if( memcmp(zCmd, "vlist", n)==0 ){ |
| 219 | PathNode *p; |
| 220 | int vid = db_lget_int("checkout", 0); |
| 221 | int n; |
| 222 | Stmt s; |
| 223 | int nStep; |
| 224 | bisect_path(); |
| 225 | db_prepare(&s, "SELECT substr(blob.uuid,1,20) || ' ' || " |
| 226 | " datetime(event.mtime) FROM blob, event" |
| 227 | " WHERE blob.rid=:rid AND event.objid=:rid" |
| 228 | " AND event.type='ci'"); |
| 229 | nStep = path_length(); |
| 230 | for(p=path_last(), n=0; p; p=p->pFrom, n++){ |
| 231 | const char *z; |
| 232 | db_bind_int(&s, ":rid", p->rid); |
| 233 | if( db_step(&s)==SQLITE_ROW ){ |
| 234 | z = db_column_text(&s, 0); |
| 235 | fossil_print("%s", z); |
| 236 | if( p->rid==bisect.good ) fossil_print(" GOOD"); |
| 237 | if( p->rid==bisect.bad ) fossil_print(" BAD"); |
| 238 | if( p->rid==vid ) fossil_print(" CURRENT"); |
| 239 | if( nStep>1 && n==nStep/2 ) fossil_print(" NEXT"); |
| 240 | fossil_print("\n"); |
| 241 | } |
| 242 | db_reset(&s); |
| 243 | } |
| 244 | db_finalize(&s); |
| 245 | }else{ |
| 246 | usage("bad|good|next|reset|vlist ..."); |
| 247 | } |
| 248 | } |
| 249 |
+77
-21
| --- src/blob.c | ||
| +++ src/blob.c | ||
| @@ -60,17 +60,22 @@ | ||
| 60 | 60 | #define blob_is_init(x) \ |
| 61 | 61 | assert((x)->xRealloc==blobReallocMalloc || (x)->xRealloc==blobReallocStatic) |
| 62 | 62 | |
| 63 | 63 | /* |
| 64 | 64 | ** Make sure a blob does not contain malloced memory. |
| 65 | +** | |
| 66 | +** This might fail if we are unlucky and x is uninitialized. For that | |
| 67 | +** reason it should only be used locally for debugging. Leave it turned | |
| 68 | +** off for production. | |
| 65 | 69 | */ |
| 66 | 70 | #if 0 /* Enable for debugging only */ |
| 67 | -#define blob_is_reset(x) \ | |
| 68 | - assert((x)->xRealloc!=blobReallocMalloc || (x)->nAlloc==0) | |
| 71 | +#define assert_blob_is_reset(x) assert(blob_is_reset(x)) | |
| 69 | 72 | #else |
| 70 | -#define blob_is_reset(x) | |
| 73 | +#define assert_blob_is_reset(x) | |
| 71 | 74 | #endif |
| 75 | + | |
| 76 | + | |
| 72 | 77 | |
| 73 | 78 | /* |
| 74 | 79 | ** We find that the built-in isspace() function does not work for |
| 75 | 80 | ** some international character sets. So here is a substitute. |
| 76 | 81 | */ |
| @@ -106,11 +111,11 @@ | ||
| 106 | 111 | assert( fossil_isspace((char)i) ); |
| 107 | 112 | }else{ |
| 108 | 113 | assert( !fossil_isspace((char)i) ); |
| 109 | 114 | } |
| 110 | 115 | } |
| 111 | - printf("All 256 characters OK\n"); | |
| 116 | + fossil_print("All 256 characters OK\n"); | |
| 112 | 117 | } |
| 113 | 118 | |
| 114 | 119 | /* |
| 115 | 120 | ** This routine is called if a blob operation fails because we |
| 116 | 121 | ** have run out of memory. |
| @@ -178,16 +183,29 @@ | ||
| 178 | 183 | void blob_reset(Blob *pBlob){ |
| 179 | 184 | blob_is_init(pBlob); |
| 180 | 185 | pBlob->xRealloc(pBlob, 0); |
| 181 | 186 | } |
| 182 | 187 | |
| 188 | + | |
| 189 | +/* | |
| 190 | +** Return true if the blob has been zeroed - in other words if it contains | |
| 191 | +** no malloced memory. This only works reliably if the blob has been | |
| 192 | +** initialized - it can return a false negative on an uninitialized blob. | |
| 193 | +*/ | |
| 194 | +int blob_is_reset(Blob *pBlob){ | |
| 195 | + if( pBlob==0 ) return 1; | |
| 196 | + if( pBlob->nUsed ) return 0; | |
| 197 | + if( pBlob->xRealloc==blobReallocMalloc && pBlob->nAlloc ) return 0; | |
| 198 | + return 1; | |
| 199 | +} | |
| 200 | + | |
| 183 | 201 | /* |
| 184 | 202 | ** Initialize a blob to a string or byte-array constant of a specified length. |
| 185 | 203 | ** Any prior data in the blob is discarded. |
| 186 | 204 | */ |
| 187 | 205 | void blob_init(Blob *pBlob, const char *zData, int size){ |
| 188 | - blob_is_reset(pBlob); | |
| 206 | + assert_blob_is_reset(pBlob); | |
| 189 | 207 | if( zData==0 ){ |
| 190 | 208 | *pBlob = empty_blob; |
| 191 | 209 | }else{ |
| 192 | 210 | if( size<=0 ) size = strlen(zData); |
| 193 | 211 | pBlob->nUsed = pBlob->nAlloc = size; |
| @@ -208,11 +226,11 @@ | ||
| 208 | 226 | /* |
| 209 | 227 | ** Initialize a blob to an empty string. |
| 210 | 228 | */ |
| 211 | 229 | void blob_zero(Blob *pBlob){ |
| 212 | 230 | static const char zEmpty[] = ""; |
| 213 | - blob_is_reset(pBlob); | |
| 231 | + assert_blob_is_reset(pBlob); | |
| 214 | 232 | pBlob->nUsed = 0; |
| 215 | 233 | pBlob->nAlloc = 1; |
| 216 | 234 | pBlob->aData = (char*)zEmpty; |
| 217 | 235 | pBlob->iCursor = 0; |
| 218 | 236 | pBlob->xRealloc = blobReallocStatic; |
| @@ -357,11 +375,11 @@ | ||
| 357 | 375 | ** |
| 358 | 376 | ** After this call completes, pTo will be an ephemeral blob. |
| 359 | 377 | */ |
| 360 | 378 | int blob_extract(Blob *pFrom, int N, Blob *pTo){ |
| 361 | 379 | blob_is_init(pFrom); |
| 362 | - blob_is_reset(pTo); | |
| 380 | + assert_blob_is_reset(pTo); | |
| 363 | 381 | if( pFrom->iCursor + N > pFrom->nUsed ){ |
| 364 | 382 | N = pFrom->nUsed - pFrom->iCursor; |
| 365 | 383 | if( N<=0 ){ |
| 366 | 384 | blob_zero(pTo); |
| 367 | 385 | return 0; |
| @@ -471,10 +489,48 @@ | ||
| 471 | 489 | int n = pFrom->nUsed; |
| 472 | 490 | int i = pFrom->iCursor; |
| 473 | 491 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 474 | 492 | pFrom->iCursor = i; |
| 475 | 493 | while( i<n && !fossil_isspace(aData[i]) ){ i++; } |
| 494 | + blob_extract(pFrom, i-pFrom->iCursor, pTo); | |
| 495 | + while( i<n && fossil_isspace(aData[i]) ){ i++; } | |
| 496 | + pFrom->iCursor = i; | |
| 497 | + return pTo->nUsed; | |
| 498 | +} | |
| 499 | + | |
| 500 | +/* | |
| 501 | +** Extract a single SQL token from pFrom and use it to initialize pTo. | |
| 502 | +** Return the number of bytes in the token. If no token is found, | |
| 503 | +** return 0. | |
| 504 | +** | |
| 505 | +** An SQL token consists of one or more non-space characters. If the | |
| 506 | +** first character is ' then the token is terminated by a matching ' | |
| 507 | +** (ignoring double '') or by the end of the string | |
| 508 | +** | |
| 509 | +** The cursor of pFrom is left pointing at the first character past | |
| 510 | +** the end of the token. | |
| 511 | +** | |
| 512 | +** pTo will be an ephermeral blob. If pFrom changes, it might alter | |
| 513 | +** pTo as well. | |
| 514 | +*/ | |
| 515 | +int blob_sqltoken(Blob *pFrom, Blob *pTo){ | |
| 516 | + char *aData = pFrom->aData; | |
| 517 | + int n = pFrom->nUsed; | |
| 518 | + int i = pFrom->iCursor; | |
| 519 | + while( i<n && fossil_isspace(aData[i]) ){ i++; } | |
| 520 | + pFrom->iCursor = i; | |
| 521 | + if( aData[i]=='\'' ){ | |
| 522 | + i++; | |
| 523 | + while( i<n ){ | |
| 524 | + if( aData[i]=='\'' ){ | |
| 525 | + if( aData[++i]!='\'' ) break; | |
| 526 | + } | |
| 527 | + i++; | |
| 528 | + } | |
| 529 | + }else{ | |
| 530 | + while( i<n && !fossil_isspace(aData[i]) ){ i++; } | |
| 531 | + } | |
| 476 | 532 | blob_extract(pFrom, i-pFrom->iCursor, pTo); |
| 477 | 533 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 478 | 534 | pFrom->iCursor = i; |
| 479 | 535 | return pTo->nUsed; |
| 480 | 536 | } |
| @@ -634,11 +690,11 @@ | ||
| 634 | 690 | } |
| 635 | 691 | if( size==0 ){ |
| 636 | 692 | return 0; |
| 637 | 693 | } |
| 638 | 694 | blob_resize(pBlob, size); |
| 639 | - in = fopen(zFilename, "rb"); | |
| 695 | + in = fossil_fopen(zFilename, "rb"); | |
| 640 | 696 | if( in==0 ){ |
| 641 | 697 | fossil_panic("cannot open %s for reading", zFilename); |
| 642 | 698 | } |
| 643 | 699 | got = fread(blob_buffer(pBlob), 1, size, in); |
| 644 | 700 | fclose(in); |
| @@ -658,13 +714,15 @@ | ||
| 658 | 714 | */ |
| 659 | 715 | int blob_read_link(Blob *pBlob, const char *zFilename){ |
| 660 | 716 | #if !defined(_WIN32) |
| 661 | 717 | char zBuf[1024]; |
| 662 | 718 | ssize_t len = readlink(zFilename, zBuf, 1023); |
| 663 | - zBuf[len] = 0; | |
| 664 | 719 | blob_zero(pBlob); |
| 665 | - blob_appendf(pBlob, "%s", zBuf); | |
| 720 | + if (len > 0) { | |
| 721 | + zBuf[len] = 0; | |
| 722 | + blob_appendf(pBlob, "%s", zBuf); | |
| 723 | + } | |
| 666 | 724 | return len; |
| 667 | 725 | #else |
| 668 | 726 | blob_zero(pBlob); |
| 669 | 727 | return 0; |
| 670 | 728 | #endif |
| @@ -678,16 +736,15 @@ | ||
| 678 | 736 | ** |
| 679 | 737 | ** Return the number of bytes written. |
| 680 | 738 | */ |
| 681 | 739 | int blob_write_to_file(Blob *pBlob, const char *zFilename){ |
| 682 | 740 | FILE *out; |
| 683 | - int needToClose; | |
| 684 | 741 | int wrote; |
| 685 | 742 | |
| 686 | 743 | if( zFilename[0]==0 || (zFilename[0]=='-' && zFilename[1]==0) ){ |
| 687 | - out = stdout; | |
| 688 | - needToClose = 0; | |
| 744 | + fossil_puts(blob_str(pBlob), 0); | |
| 745 | + return blob_size(pBlob); | |
| 689 | 746 | }else{ |
| 690 | 747 | int i, nName; |
| 691 | 748 | char *zName, zBuf[1000]; |
| 692 | 749 | |
| 693 | 750 | nName = strlen(zFilename); |
| @@ -717,22 +774,21 @@ | ||
| 717 | 774 | } |
| 718 | 775 | #endif |
| 719 | 776 | zName[i] = '/'; |
| 720 | 777 | } |
| 721 | 778 | } |
| 722 | - out = fopen(zName, "wb"); | |
| 779 | + out = fossil_fopen(zName, "wb"); | |
| 723 | 780 | if( out==0 ){ |
| 724 | 781 | fossil_fatal_recursive("unable to open file \"%s\" for writing", zName); |
| 725 | 782 | return 0; |
| 726 | 783 | } |
| 727 | - needToClose = 1; | |
| 728 | 784 | if( zName!=zBuf ) free(zName); |
| 729 | 785 | } |
| 730 | 786 | blob_is_init(pBlob); |
| 731 | 787 | wrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out); |
| 732 | - if( needToClose ) fclose(out); | |
| 733 | - if( wrote!=blob_size(pBlob) ){ | |
| 788 | + fclose(out); | |
| 789 | + if( wrote!=blob_size(pBlob) && out!=stdout ){ | |
| 734 | 790 | fossil_fatal_recursive("short write: %d of %d bytes to %s", wrote, |
| 735 | 791 | blob_size(pBlob), zFilename); |
| 736 | 792 | } |
| 737 | 793 | return wrote; |
| 738 | 794 | } |
| @@ -758,11 +814,11 @@ | ||
| 758 | 814 | outBuf[3] = nIn & 0xff; |
| 759 | 815 | nOut2 = (long int)nOut; |
| 760 | 816 | compress(&outBuf[4], &nOut2, |
| 761 | 817 | (unsigned char*)blob_buffer(pIn), blob_size(pIn)); |
| 762 | 818 | if( pOut==pIn ) blob_reset(pOut); |
| 763 | - blob_is_reset(pOut); | |
| 819 | + assert_blob_is_reset(pOut); | |
| 764 | 820 | *pOut = temp; |
| 765 | 821 | blob_resize(pOut, nOut2+4); |
| 766 | 822 | } |
| 767 | 823 | |
| 768 | 824 | /* |
| @@ -811,11 +867,11 @@ | ||
| 811 | 867 | deflate(&stream, Z_FINISH); |
| 812 | 868 | blob_resize(&temp, stream.total_out + 4); |
| 813 | 869 | deflateEnd(&stream); |
| 814 | 870 | if( pOut==pIn1 ) blob_reset(pOut); |
| 815 | 871 | if( pOut==pIn2 ) blob_reset(pOut); |
| 816 | - blob_is_reset(pOut); | |
| 872 | + assert_blob_is_reset(pOut); | |
| 817 | 873 | *pOut = temp; |
| 818 | 874 | } |
| 819 | 875 | |
| 820 | 876 | /* |
| 821 | 877 | ** COMMAND: test-compress-2 |
| @@ -856,11 +912,11 @@ | ||
| 856 | 912 | blob_reset(&temp); |
| 857 | 913 | return 1; |
| 858 | 914 | } |
| 859 | 915 | blob_resize(&temp, nOut2); |
| 860 | 916 | if( pOut==pIn ) blob_reset(pOut); |
| 861 | - blob_is_reset(pOut); | |
| 917 | + assert_blob_is_reset(pOut); | |
| 862 | 918 | *pOut = temp; |
| 863 | 919 | return 0; |
| 864 | 920 | } |
| 865 | 921 | |
| 866 | 922 | /* |
| @@ -892,11 +948,11 @@ | ||
| 892 | 948 | } |
| 893 | 949 | blob_reset(&b1); |
| 894 | 950 | blob_reset(&b2); |
| 895 | 951 | blob_reset(&b3); |
| 896 | 952 | } |
| 897 | - printf("ok\n"); | |
| 953 | + fossil_print("ok\n"); | |
| 898 | 954 | } |
| 899 | 955 | |
| 900 | 956 | #if defined(_WIN32) |
| 901 | 957 | /* |
| 902 | 958 | ** Convert every \n character in the given blob into \r\n. |
| 903 | 959 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -60,17 +60,22 @@ | |
| 60 | #define blob_is_init(x) \ |
| 61 | assert((x)->xRealloc==blobReallocMalloc || (x)->xRealloc==blobReallocStatic) |
| 62 | |
| 63 | /* |
| 64 | ** Make sure a blob does not contain malloced memory. |
| 65 | */ |
| 66 | #if 0 /* Enable for debugging only */ |
| 67 | #define blob_is_reset(x) \ |
| 68 | assert((x)->xRealloc!=blobReallocMalloc || (x)->nAlloc==0) |
| 69 | #else |
| 70 | #define blob_is_reset(x) |
| 71 | #endif |
| 72 | |
| 73 | /* |
| 74 | ** We find that the built-in isspace() function does not work for |
| 75 | ** some international character sets. So here is a substitute. |
| 76 | */ |
| @@ -106,11 +111,11 @@ | |
| 106 | assert( fossil_isspace((char)i) ); |
| 107 | }else{ |
| 108 | assert( !fossil_isspace((char)i) ); |
| 109 | } |
| 110 | } |
| 111 | printf("All 256 characters OK\n"); |
| 112 | } |
| 113 | |
| 114 | /* |
| 115 | ** This routine is called if a blob operation fails because we |
| 116 | ** have run out of memory. |
| @@ -178,16 +183,29 @@ | |
| 178 | void blob_reset(Blob *pBlob){ |
| 179 | blob_is_init(pBlob); |
| 180 | pBlob->xRealloc(pBlob, 0); |
| 181 | } |
| 182 | |
| 183 | /* |
| 184 | ** Initialize a blob to a string or byte-array constant of a specified length. |
| 185 | ** Any prior data in the blob is discarded. |
| 186 | */ |
| 187 | void blob_init(Blob *pBlob, const char *zData, int size){ |
| 188 | blob_is_reset(pBlob); |
| 189 | if( zData==0 ){ |
| 190 | *pBlob = empty_blob; |
| 191 | }else{ |
| 192 | if( size<=0 ) size = strlen(zData); |
| 193 | pBlob->nUsed = pBlob->nAlloc = size; |
| @@ -208,11 +226,11 @@ | |
| 208 | /* |
| 209 | ** Initialize a blob to an empty string. |
| 210 | */ |
| 211 | void blob_zero(Blob *pBlob){ |
| 212 | static const char zEmpty[] = ""; |
| 213 | blob_is_reset(pBlob); |
| 214 | pBlob->nUsed = 0; |
| 215 | pBlob->nAlloc = 1; |
| 216 | pBlob->aData = (char*)zEmpty; |
| 217 | pBlob->iCursor = 0; |
| 218 | pBlob->xRealloc = blobReallocStatic; |
| @@ -357,11 +375,11 @@ | |
| 357 | ** |
| 358 | ** After this call completes, pTo will be an ephemeral blob. |
| 359 | */ |
| 360 | int blob_extract(Blob *pFrom, int N, Blob *pTo){ |
| 361 | blob_is_init(pFrom); |
| 362 | blob_is_reset(pTo); |
| 363 | if( pFrom->iCursor + N > pFrom->nUsed ){ |
| 364 | N = pFrom->nUsed - pFrom->iCursor; |
| 365 | if( N<=0 ){ |
| 366 | blob_zero(pTo); |
| 367 | return 0; |
| @@ -471,10 +489,48 @@ | |
| 471 | int n = pFrom->nUsed; |
| 472 | int i = pFrom->iCursor; |
| 473 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 474 | pFrom->iCursor = i; |
| 475 | while( i<n && !fossil_isspace(aData[i]) ){ i++; } |
| 476 | blob_extract(pFrom, i-pFrom->iCursor, pTo); |
| 477 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 478 | pFrom->iCursor = i; |
| 479 | return pTo->nUsed; |
| 480 | } |
| @@ -634,11 +690,11 @@ | |
| 634 | } |
| 635 | if( size==0 ){ |
| 636 | return 0; |
| 637 | } |
| 638 | blob_resize(pBlob, size); |
| 639 | in = fopen(zFilename, "rb"); |
| 640 | if( in==0 ){ |
| 641 | fossil_panic("cannot open %s for reading", zFilename); |
| 642 | } |
| 643 | got = fread(blob_buffer(pBlob), 1, size, in); |
| 644 | fclose(in); |
| @@ -658,13 +714,15 @@ | |
| 658 | */ |
| 659 | int blob_read_link(Blob *pBlob, const char *zFilename){ |
| 660 | #if !defined(_WIN32) |
| 661 | char zBuf[1024]; |
| 662 | ssize_t len = readlink(zFilename, zBuf, 1023); |
| 663 | zBuf[len] = 0; |
| 664 | blob_zero(pBlob); |
| 665 | blob_appendf(pBlob, "%s", zBuf); |
| 666 | return len; |
| 667 | #else |
| 668 | blob_zero(pBlob); |
| 669 | return 0; |
| 670 | #endif |
| @@ -678,16 +736,15 @@ | |
| 678 | ** |
| 679 | ** Return the number of bytes written. |
| 680 | */ |
| 681 | int blob_write_to_file(Blob *pBlob, const char *zFilename){ |
| 682 | FILE *out; |
| 683 | int needToClose; |
| 684 | int wrote; |
| 685 | |
| 686 | if( zFilename[0]==0 || (zFilename[0]=='-' && zFilename[1]==0) ){ |
| 687 | out = stdout; |
| 688 | needToClose = 0; |
| 689 | }else{ |
| 690 | int i, nName; |
| 691 | char *zName, zBuf[1000]; |
| 692 | |
| 693 | nName = strlen(zFilename); |
| @@ -717,22 +774,21 @@ | |
| 717 | } |
| 718 | #endif |
| 719 | zName[i] = '/'; |
| 720 | } |
| 721 | } |
| 722 | out = fopen(zName, "wb"); |
| 723 | if( out==0 ){ |
| 724 | fossil_fatal_recursive("unable to open file \"%s\" for writing", zName); |
| 725 | return 0; |
| 726 | } |
| 727 | needToClose = 1; |
| 728 | if( zName!=zBuf ) free(zName); |
| 729 | } |
| 730 | blob_is_init(pBlob); |
| 731 | wrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out); |
| 732 | if( needToClose ) fclose(out); |
| 733 | if( wrote!=blob_size(pBlob) ){ |
| 734 | fossil_fatal_recursive("short write: %d of %d bytes to %s", wrote, |
| 735 | blob_size(pBlob), zFilename); |
| 736 | } |
| 737 | return wrote; |
| 738 | } |
| @@ -758,11 +814,11 @@ | |
| 758 | outBuf[3] = nIn & 0xff; |
| 759 | nOut2 = (long int)nOut; |
| 760 | compress(&outBuf[4], &nOut2, |
| 761 | (unsigned char*)blob_buffer(pIn), blob_size(pIn)); |
| 762 | if( pOut==pIn ) blob_reset(pOut); |
| 763 | blob_is_reset(pOut); |
| 764 | *pOut = temp; |
| 765 | blob_resize(pOut, nOut2+4); |
| 766 | } |
| 767 | |
| 768 | /* |
| @@ -811,11 +867,11 @@ | |
| 811 | deflate(&stream, Z_FINISH); |
| 812 | blob_resize(&temp, stream.total_out + 4); |
| 813 | deflateEnd(&stream); |
| 814 | if( pOut==pIn1 ) blob_reset(pOut); |
| 815 | if( pOut==pIn2 ) blob_reset(pOut); |
| 816 | blob_is_reset(pOut); |
| 817 | *pOut = temp; |
| 818 | } |
| 819 | |
| 820 | /* |
| 821 | ** COMMAND: test-compress-2 |
| @@ -856,11 +912,11 @@ | |
| 856 | blob_reset(&temp); |
| 857 | return 1; |
| 858 | } |
| 859 | blob_resize(&temp, nOut2); |
| 860 | if( pOut==pIn ) blob_reset(pOut); |
| 861 | blob_is_reset(pOut); |
| 862 | *pOut = temp; |
| 863 | return 0; |
| 864 | } |
| 865 | |
| 866 | /* |
| @@ -892,11 +948,11 @@ | |
| 892 | } |
| 893 | blob_reset(&b1); |
| 894 | blob_reset(&b2); |
| 895 | blob_reset(&b3); |
| 896 | } |
| 897 | printf("ok\n"); |
| 898 | } |
| 899 | |
| 900 | #if defined(_WIN32) |
| 901 | /* |
| 902 | ** Convert every \n character in the given blob into \r\n. |
| 903 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -60,17 +60,22 @@ | |
| 60 | #define blob_is_init(x) \ |
| 61 | assert((x)->xRealloc==blobReallocMalloc || (x)->xRealloc==blobReallocStatic) |
| 62 | |
| 63 | /* |
| 64 | ** Make sure a blob does not contain malloced memory. |
| 65 | ** |
| 66 | ** This might fail if we are unlucky and x is uninitialized. For that |
| 67 | ** reason it should only be used locally for debugging. Leave it turned |
| 68 | ** off for production. |
| 69 | */ |
| 70 | #if 0 /* Enable for debugging only */ |
| 71 | #define assert_blob_is_reset(x) assert(blob_is_reset(x)) |
| 72 | #else |
| 73 | #define assert_blob_is_reset(x) |
| 74 | #endif |
| 75 | |
| 76 | |
| 77 | |
| 78 | /* |
| 79 | ** We find that the built-in isspace() function does not work for |
| 80 | ** some international character sets. So here is a substitute. |
| 81 | */ |
| @@ -106,11 +111,11 @@ | |
| 111 | assert( fossil_isspace((char)i) ); |
| 112 | }else{ |
| 113 | assert( !fossil_isspace((char)i) ); |
| 114 | } |
| 115 | } |
| 116 | fossil_print("All 256 characters OK\n"); |
| 117 | } |
| 118 | |
| 119 | /* |
| 120 | ** This routine is called if a blob operation fails because we |
| 121 | ** have run out of memory. |
| @@ -178,16 +183,29 @@ | |
| 183 | void blob_reset(Blob *pBlob){ |
| 184 | blob_is_init(pBlob); |
| 185 | pBlob->xRealloc(pBlob, 0); |
| 186 | } |
| 187 | |
| 188 | |
| 189 | /* |
| 190 | ** Return true if the blob has been zeroed - in other words if it contains |
| 191 | ** no malloced memory. This only works reliably if the blob has been |
| 192 | ** initialized - it can return a false negative on an uninitialized blob. |
| 193 | */ |
| 194 | int blob_is_reset(Blob *pBlob){ |
| 195 | if( pBlob==0 ) return 1; |
| 196 | if( pBlob->nUsed ) return 0; |
| 197 | if( pBlob->xRealloc==blobReallocMalloc && pBlob->nAlloc ) return 0; |
| 198 | return 1; |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | ** Initialize a blob to a string or byte-array constant of a specified length. |
| 203 | ** Any prior data in the blob is discarded. |
| 204 | */ |
| 205 | void blob_init(Blob *pBlob, const char *zData, int size){ |
| 206 | assert_blob_is_reset(pBlob); |
| 207 | if( zData==0 ){ |
| 208 | *pBlob = empty_blob; |
| 209 | }else{ |
| 210 | if( size<=0 ) size = strlen(zData); |
| 211 | pBlob->nUsed = pBlob->nAlloc = size; |
| @@ -208,11 +226,11 @@ | |
| 226 | /* |
| 227 | ** Initialize a blob to an empty string. |
| 228 | */ |
| 229 | void blob_zero(Blob *pBlob){ |
| 230 | static const char zEmpty[] = ""; |
| 231 | assert_blob_is_reset(pBlob); |
| 232 | pBlob->nUsed = 0; |
| 233 | pBlob->nAlloc = 1; |
| 234 | pBlob->aData = (char*)zEmpty; |
| 235 | pBlob->iCursor = 0; |
| 236 | pBlob->xRealloc = blobReallocStatic; |
| @@ -357,11 +375,11 @@ | |
| 375 | ** |
| 376 | ** After this call completes, pTo will be an ephemeral blob. |
| 377 | */ |
| 378 | int blob_extract(Blob *pFrom, int N, Blob *pTo){ |
| 379 | blob_is_init(pFrom); |
| 380 | assert_blob_is_reset(pTo); |
| 381 | if( pFrom->iCursor + N > pFrom->nUsed ){ |
| 382 | N = pFrom->nUsed - pFrom->iCursor; |
| 383 | if( N<=0 ){ |
| 384 | blob_zero(pTo); |
| 385 | return 0; |
| @@ -471,10 +489,48 @@ | |
| 489 | int n = pFrom->nUsed; |
| 490 | int i = pFrom->iCursor; |
| 491 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 492 | pFrom->iCursor = i; |
| 493 | while( i<n && !fossil_isspace(aData[i]) ){ i++; } |
| 494 | blob_extract(pFrom, i-pFrom->iCursor, pTo); |
| 495 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 496 | pFrom->iCursor = i; |
| 497 | return pTo->nUsed; |
| 498 | } |
| 499 | |
| 500 | /* |
| 501 | ** Extract a single SQL token from pFrom and use it to initialize pTo. |
| 502 | ** Return the number of bytes in the token. If no token is found, |
| 503 | ** return 0. |
| 504 | ** |
| 505 | ** An SQL token consists of one or more non-space characters. If the |
| 506 | ** first character is ' then the token is terminated by a matching ' |
| 507 | ** (ignoring double '') or by the end of the string |
| 508 | ** |
| 509 | ** The cursor of pFrom is left pointing at the first character past |
| 510 | ** the end of the token. |
| 511 | ** |
| 512 | ** pTo will be an ephermeral blob. If pFrom changes, it might alter |
| 513 | ** pTo as well. |
| 514 | */ |
| 515 | int blob_sqltoken(Blob *pFrom, Blob *pTo){ |
| 516 | char *aData = pFrom->aData; |
| 517 | int n = pFrom->nUsed; |
| 518 | int i = pFrom->iCursor; |
| 519 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 520 | pFrom->iCursor = i; |
| 521 | if( aData[i]=='\'' ){ |
| 522 | i++; |
| 523 | while( i<n ){ |
| 524 | if( aData[i]=='\'' ){ |
| 525 | if( aData[++i]!='\'' ) break; |
| 526 | } |
| 527 | i++; |
| 528 | } |
| 529 | }else{ |
| 530 | while( i<n && !fossil_isspace(aData[i]) ){ i++; } |
| 531 | } |
| 532 | blob_extract(pFrom, i-pFrom->iCursor, pTo); |
| 533 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 534 | pFrom->iCursor = i; |
| 535 | return pTo->nUsed; |
| 536 | } |
| @@ -634,11 +690,11 @@ | |
| 690 | } |
| 691 | if( size==0 ){ |
| 692 | return 0; |
| 693 | } |
| 694 | blob_resize(pBlob, size); |
| 695 | in = fossil_fopen(zFilename, "rb"); |
| 696 | if( in==0 ){ |
| 697 | fossil_panic("cannot open %s for reading", zFilename); |
| 698 | } |
| 699 | got = fread(blob_buffer(pBlob), 1, size, in); |
| 700 | fclose(in); |
| @@ -658,13 +714,15 @@ | |
| 714 | */ |
| 715 | int blob_read_link(Blob *pBlob, const char *zFilename){ |
| 716 | #if !defined(_WIN32) |
| 717 | char zBuf[1024]; |
| 718 | ssize_t len = readlink(zFilename, zBuf, 1023); |
| 719 | blob_zero(pBlob); |
| 720 | if (len > 0) { |
| 721 | zBuf[len] = 0; |
| 722 | blob_appendf(pBlob, "%s", zBuf); |
| 723 | } |
| 724 | return len; |
| 725 | #else |
| 726 | blob_zero(pBlob); |
| 727 | return 0; |
| 728 | #endif |
| @@ -678,16 +736,15 @@ | |
| 736 | ** |
| 737 | ** Return the number of bytes written. |
| 738 | */ |
| 739 | int blob_write_to_file(Blob *pBlob, const char *zFilename){ |
| 740 | FILE *out; |
| 741 | int wrote; |
| 742 | |
| 743 | if( zFilename[0]==0 || (zFilename[0]=='-' && zFilename[1]==0) ){ |
| 744 | fossil_puts(blob_str(pBlob), 0); |
| 745 | return blob_size(pBlob); |
| 746 | }else{ |
| 747 | int i, nName; |
| 748 | char *zName, zBuf[1000]; |
| 749 | |
| 750 | nName = strlen(zFilename); |
| @@ -717,22 +774,21 @@ | |
| 774 | } |
| 775 | #endif |
| 776 | zName[i] = '/'; |
| 777 | } |
| 778 | } |
| 779 | out = fossil_fopen(zName, "wb"); |
| 780 | if( out==0 ){ |
| 781 | fossil_fatal_recursive("unable to open file \"%s\" for writing", zName); |
| 782 | return 0; |
| 783 | } |
| 784 | if( zName!=zBuf ) free(zName); |
| 785 | } |
| 786 | blob_is_init(pBlob); |
| 787 | wrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out); |
| 788 | fclose(out); |
| 789 | if( wrote!=blob_size(pBlob) && out!=stdout ){ |
| 790 | fossil_fatal_recursive("short write: %d of %d bytes to %s", wrote, |
| 791 | blob_size(pBlob), zFilename); |
| 792 | } |
| 793 | return wrote; |
| 794 | } |
| @@ -758,11 +814,11 @@ | |
| 814 | outBuf[3] = nIn & 0xff; |
| 815 | nOut2 = (long int)nOut; |
| 816 | compress(&outBuf[4], &nOut2, |
| 817 | (unsigned char*)blob_buffer(pIn), blob_size(pIn)); |
| 818 | if( pOut==pIn ) blob_reset(pOut); |
| 819 | assert_blob_is_reset(pOut); |
| 820 | *pOut = temp; |
| 821 | blob_resize(pOut, nOut2+4); |
| 822 | } |
| 823 | |
| 824 | /* |
| @@ -811,11 +867,11 @@ | |
| 867 | deflate(&stream, Z_FINISH); |
| 868 | blob_resize(&temp, stream.total_out + 4); |
| 869 | deflateEnd(&stream); |
| 870 | if( pOut==pIn1 ) blob_reset(pOut); |
| 871 | if( pOut==pIn2 ) blob_reset(pOut); |
| 872 | assert_blob_is_reset(pOut); |
| 873 | *pOut = temp; |
| 874 | } |
| 875 | |
| 876 | /* |
| 877 | ** COMMAND: test-compress-2 |
| @@ -856,11 +912,11 @@ | |
| 912 | blob_reset(&temp); |
| 913 | return 1; |
| 914 | } |
| 915 | blob_resize(&temp, nOut2); |
| 916 | if( pOut==pIn ) blob_reset(pOut); |
| 917 | assert_blob_is_reset(pOut); |
| 918 | *pOut = temp; |
| 919 | return 0; |
| 920 | } |
| 921 | |
| 922 | /* |
| @@ -892,11 +948,11 @@ | |
| 948 | } |
| 949 | blob_reset(&b1); |
| 950 | blob_reset(&b2); |
| 951 | blob_reset(&b3); |
| 952 | } |
| 953 | fossil_print("ok\n"); |
| 954 | } |
| 955 | |
| 956 | #if defined(_WIN32) |
| 957 | /* |
| 958 | ** Convert every \n character in the given blob into \r\n. |
| 959 |
+77
-21
| --- src/blob.c | ||
| +++ src/blob.c | ||
| @@ -60,17 +60,22 @@ | ||
| 60 | 60 | #define blob_is_init(x) \ |
| 61 | 61 | assert((x)->xRealloc==blobReallocMalloc || (x)->xRealloc==blobReallocStatic) |
| 62 | 62 | |
| 63 | 63 | /* |
| 64 | 64 | ** Make sure a blob does not contain malloced memory. |
| 65 | +** | |
| 66 | +** This might fail if we are unlucky and x is uninitialized. For that | |
| 67 | +** reason it should only be used locally for debugging. Leave it turned | |
| 68 | +** off for production. | |
| 65 | 69 | */ |
| 66 | 70 | #if 0 /* Enable for debugging only */ |
| 67 | -#define blob_is_reset(x) \ | |
| 68 | - assert((x)->xRealloc!=blobReallocMalloc || (x)->nAlloc==0) | |
| 71 | +#define assert_blob_is_reset(x) assert(blob_is_reset(x)) | |
| 69 | 72 | #else |
| 70 | -#define blob_is_reset(x) | |
| 73 | +#define assert_blob_is_reset(x) | |
| 71 | 74 | #endif |
| 75 | + | |
| 76 | + | |
| 72 | 77 | |
| 73 | 78 | /* |
| 74 | 79 | ** We find that the built-in isspace() function does not work for |
| 75 | 80 | ** some international character sets. So here is a substitute. |
| 76 | 81 | */ |
| @@ -106,11 +111,11 @@ | ||
| 106 | 111 | assert( fossil_isspace((char)i) ); |
| 107 | 112 | }else{ |
| 108 | 113 | assert( !fossil_isspace((char)i) ); |
| 109 | 114 | } |
| 110 | 115 | } |
| 111 | - printf("All 256 characters OK\n"); | |
| 116 | + fossil_print("All 256 characters OK\n"); | |
| 112 | 117 | } |
| 113 | 118 | |
| 114 | 119 | /* |
| 115 | 120 | ** This routine is called if a blob operation fails because we |
| 116 | 121 | ** have run out of memory. |
| @@ -178,16 +183,29 @@ | ||
| 178 | 183 | void blob_reset(Blob *pBlob){ |
| 179 | 184 | blob_is_init(pBlob); |
| 180 | 185 | pBlob->xRealloc(pBlob, 0); |
| 181 | 186 | } |
| 182 | 187 | |
| 188 | + | |
| 189 | +/* | |
| 190 | +** Return true if the blob has been zeroed - in other words if it contains | |
| 191 | +** no malloced memory. This only works reliably if the blob has been | |
| 192 | +** initialized - it can return a false negative on an uninitialized blob. | |
| 193 | +*/ | |
| 194 | +int blob_is_reset(Blob *pBlob){ | |
| 195 | + if( pBlob==0 ) return 1; | |
| 196 | + if( pBlob->nUsed ) return 0; | |
| 197 | + if( pBlob->xRealloc==blobReallocMalloc && pBlob->nAlloc ) return 0; | |
| 198 | + return 1; | |
| 199 | +} | |
| 200 | + | |
| 183 | 201 | /* |
| 184 | 202 | ** Initialize a blob to a string or byte-array constant of a specified length. |
| 185 | 203 | ** Any prior data in the blob is discarded. |
| 186 | 204 | */ |
| 187 | 205 | void blob_init(Blob *pBlob, const char *zData, int size){ |
| 188 | - blob_is_reset(pBlob); | |
| 206 | + assert_blob_is_reset(pBlob); | |
| 189 | 207 | if( zData==0 ){ |
| 190 | 208 | *pBlob = empty_blob; |
| 191 | 209 | }else{ |
| 192 | 210 | if( size<=0 ) size = strlen(zData); |
| 193 | 211 | pBlob->nUsed = pBlob->nAlloc = size; |
| @@ -208,11 +226,11 @@ | ||
| 208 | 226 | /* |
| 209 | 227 | ** Initialize a blob to an empty string. |
| 210 | 228 | */ |
| 211 | 229 | void blob_zero(Blob *pBlob){ |
| 212 | 230 | static const char zEmpty[] = ""; |
| 213 | - blob_is_reset(pBlob); | |
| 231 | + assert_blob_is_reset(pBlob); | |
| 214 | 232 | pBlob->nUsed = 0; |
| 215 | 233 | pBlob->nAlloc = 1; |
| 216 | 234 | pBlob->aData = (char*)zEmpty; |
| 217 | 235 | pBlob->iCursor = 0; |
| 218 | 236 | pBlob->xRealloc = blobReallocStatic; |
| @@ -357,11 +375,11 @@ | ||
| 357 | 375 | ** |
| 358 | 376 | ** After this call completes, pTo will be an ephemeral blob. |
| 359 | 377 | */ |
| 360 | 378 | int blob_extract(Blob *pFrom, int N, Blob *pTo){ |
| 361 | 379 | blob_is_init(pFrom); |
| 362 | - blob_is_reset(pTo); | |
| 380 | + assert_blob_is_reset(pTo); | |
| 363 | 381 | if( pFrom->iCursor + N > pFrom->nUsed ){ |
| 364 | 382 | N = pFrom->nUsed - pFrom->iCursor; |
| 365 | 383 | if( N<=0 ){ |
| 366 | 384 | blob_zero(pTo); |
| 367 | 385 | return 0; |
| @@ -471,10 +489,48 @@ | ||
| 471 | 489 | int n = pFrom->nUsed; |
| 472 | 490 | int i = pFrom->iCursor; |
| 473 | 491 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 474 | 492 | pFrom->iCursor = i; |
| 475 | 493 | while( i<n && !fossil_isspace(aData[i]) ){ i++; } |
| 494 | + blob_extract(pFrom, i-pFrom->iCursor, pTo); | |
| 495 | + while( i<n && fossil_isspace(aData[i]) ){ i++; } | |
| 496 | + pFrom->iCursor = i; | |
| 497 | + return pTo->nUsed; | |
| 498 | +} | |
| 499 | + | |
| 500 | +/* | |
| 501 | +** Extract a single SQL token from pFrom and use it to initialize pTo. | |
| 502 | +** Return the number of bytes in the token. If no token is found, | |
| 503 | +** return 0. | |
| 504 | +** | |
| 505 | +** An SQL token consists of one or more non-space characters. If the | |
| 506 | +** first character is ' then the token is terminated by a matching ' | |
| 507 | +** (ignoring double '') or by the end of the string | |
| 508 | +** | |
| 509 | +** The cursor of pFrom is left pointing at the first character past | |
| 510 | +** the end of the token. | |
| 511 | +** | |
| 512 | +** pTo will be an ephermeral blob. If pFrom changes, it might alter | |
| 513 | +** pTo as well. | |
| 514 | +*/ | |
| 515 | +int blob_sqltoken(Blob *pFrom, Blob *pTo){ | |
| 516 | + char *aData = pFrom->aData; | |
| 517 | + int n = pFrom->nUsed; | |
| 518 | + int i = pFrom->iCursor; | |
| 519 | + while( i<n && fossil_isspace(aData[i]) ){ i++; } | |
| 520 | + pFrom->iCursor = i; | |
| 521 | + if( aData[i]=='\'' ){ | |
| 522 | + i++; | |
| 523 | + while( i<n ){ | |
| 524 | + if( aData[i]=='\'' ){ | |
| 525 | + if( aData[++i]!='\'' ) break; | |
| 526 | + } | |
| 527 | + i++; | |
| 528 | + } | |
| 529 | + }else{ | |
| 530 | + while( i<n && !fossil_isspace(aData[i]) ){ i++; } | |
| 531 | + } | |
| 476 | 532 | blob_extract(pFrom, i-pFrom->iCursor, pTo); |
| 477 | 533 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 478 | 534 | pFrom->iCursor = i; |
| 479 | 535 | return pTo->nUsed; |
| 480 | 536 | } |
| @@ -634,11 +690,11 @@ | ||
| 634 | 690 | } |
| 635 | 691 | if( size==0 ){ |
| 636 | 692 | return 0; |
| 637 | 693 | } |
| 638 | 694 | blob_resize(pBlob, size); |
| 639 | - in = fopen(zFilename, "rb"); | |
| 695 | + in = fossil_fopen(zFilename, "rb"); | |
| 640 | 696 | if( in==0 ){ |
| 641 | 697 | fossil_panic("cannot open %s for reading", zFilename); |
| 642 | 698 | } |
| 643 | 699 | got = fread(blob_buffer(pBlob), 1, size, in); |
| 644 | 700 | fclose(in); |
| @@ -658,13 +714,15 @@ | ||
| 658 | 714 | */ |
| 659 | 715 | int blob_read_link(Blob *pBlob, const char *zFilename){ |
| 660 | 716 | #if !defined(_WIN32) |
| 661 | 717 | char zBuf[1024]; |
| 662 | 718 | ssize_t len = readlink(zFilename, zBuf, 1023); |
| 663 | - zBuf[len] = 0; | |
| 664 | 719 | blob_zero(pBlob); |
| 665 | - blob_appendf(pBlob, "%s", zBuf); | |
| 720 | + if (len > 0) { | |
| 721 | + zBuf[len] = 0; | |
| 722 | + blob_appendf(pBlob, "%s", zBuf); | |
| 723 | + } | |
| 666 | 724 | return len; |
| 667 | 725 | #else |
| 668 | 726 | blob_zero(pBlob); |
| 669 | 727 | return 0; |
| 670 | 728 | #endif |
| @@ -678,16 +736,15 @@ | ||
| 678 | 736 | ** |
| 679 | 737 | ** Return the number of bytes written. |
| 680 | 738 | */ |
| 681 | 739 | int blob_write_to_file(Blob *pBlob, const char *zFilename){ |
| 682 | 740 | FILE *out; |
| 683 | - int needToClose; | |
| 684 | 741 | int wrote; |
| 685 | 742 | |
| 686 | 743 | if( zFilename[0]==0 || (zFilename[0]=='-' && zFilename[1]==0) ){ |
| 687 | - out = stdout; | |
| 688 | - needToClose = 0; | |
| 744 | + fossil_puts(blob_str(pBlob), 0); | |
| 745 | + return blob_size(pBlob); | |
| 689 | 746 | }else{ |
| 690 | 747 | int i, nName; |
| 691 | 748 | char *zName, zBuf[1000]; |
| 692 | 749 | |
| 693 | 750 | nName = strlen(zFilename); |
| @@ -717,22 +774,21 @@ | ||
| 717 | 774 | } |
| 718 | 775 | #endif |
| 719 | 776 | zName[i] = '/'; |
| 720 | 777 | } |
| 721 | 778 | } |
| 722 | - out = fopen(zName, "wb"); | |
| 779 | + out = fossil_fopen(zName, "wb"); | |
| 723 | 780 | if( out==0 ){ |
| 724 | 781 | fossil_fatal_recursive("unable to open file \"%s\" for writing", zName); |
| 725 | 782 | return 0; |
| 726 | 783 | } |
| 727 | - needToClose = 1; | |
| 728 | 784 | if( zName!=zBuf ) free(zName); |
| 729 | 785 | } |
| 730 | 786 | blob_is_init(pBlob); |
| 731 | 787 | wrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out); |
| 732 | - if( needToClose ) fclose(out); | |
| 733 | - if( wrote!=blob_size(pBlob) ){ | |
| 788 | + fclose(out); | |
| 789 | + if( wrote!=blob_size(pBlob) && out!=stdout ){ | |
| 734 | 790 | fossil_fatal_recursive("short write: %d of %d bytes to %s", wrote, |
| 735 | 791 | blob_size(pBlob), zFilename); |
| 736 | 792 | } |
| 737 | 793 | return wrote; |
| 738 | 794 | } |
| @@ -758,11 +814,11 @@ | ||
| 758 | 814 | outBuf[3] = nIn & 0xff; |
| 759 | 815 | nOut2 = (long int)nOut; |
| 760 | 816 | compress(&outBuf[4], &nOut2, |
| 761 | 817 | (unsigned char*)blob_buffer(pIn), blob_size(pIn)); |
| 762 | 818 | if( pOut==pIn ) blob_reset(pOut); |
| 763 | - blob_is_reset(pOut); | |
| 819 | + assert_blob_is_reset(pOut); | |
| 764 | 820 | *pOut = temp; |
| 765 | 821 | blob_resize(pOut, nOut2+4); |
| 766 | 822 | } |
| 767 | 823 | |
| 768 | 824 | /* |
| @@ -811,11 +867,11 @@ | ||
| 811 | 867 | deflate(&stream, Z_FINISH); |
| 812 | 868 | blob_resize(&temp, stream.total_out + 4); |
| 813 | 869 | deflateEnd(&stream); |
| 814 | 870 | if( pOut==pIn1 ) blob_reset(pOut); |
| 815 | 871 | if( pOut==pIn2 ) blob_reset(pOut); |
| 816 | - blob_is_reset(pOut); | |
| 872 | + assert_blob_is_reset(pOut); | |
| 817 | 873 | *pOut = temp; |
| 818 | 874 | } |
| 819 | 875 | |
| 820 | 876 | /* |
| 821 | 877 | ** COMMAND: test-compress-2 |
| @@ -856,11 +912,11 @@ | ||
| 856 | 912 | blob_reset(&temp); |
| 857 | 913 | return 1; |
| 858 | 914 | } |
| 859 | 915 | blob_resize(&temp, nOut2); |
| 860 | 916 | if( pOut==pIn ) blob_reset(pOut); |
| 861 | - blob_is_reset(pOut); | |
| 917 | + assert_blob_is_reset(pOut); | |
| 862 | 918 | *pOut = temp; |
| 863 | 919 | return 0; |
| 864 | 920 | } |
| 865 | 921 | |
| 866 | 922 | /* |
| @@ -892,11 +948,11 @@ | ||
| 892 | 948 | } |
| 893 | 949 | blob_reset(&b1); |
| 894 | 950 | blob_reset(&b2); |
| 895 | 951 | blob_reset(&b3); |
| 896 | 952 | } |
| 897 | - printf("ok\n"); | |
| 953 | + fossil_print("ok\n"); | |
| 898 | 954 | } |
| 899 | 955 | |
| 900 | 956 | #if defined(_WIN32) |
| 901 | 957 | /* |
| 902 | 958 | ** Convert every \n character in the given blob into \r\n. |
| 903 | 959 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -60,17 +60,22 @@ | |
| 60 | #define blob_is_init(x) \ |
| 61 | assert((x)->xRealloc==blobReallocMalloc || (x)->xRealloc==blobReallocStatic) |
| 62 | |
| 63 | /* |
| 64 | ** Make sure a blob does not contain malloced memory. |
| 65 | */ |
| 66 | #if 0 /* Enable for debugging only */ |
| 67 | #define blob_is_reset(x) \ |
| 68 | assert((x)->xRealloc!=blobReallocMalloc || (x)->nAlloc==0) |
| 69 | #else |
| 70 | #define blob_is_reset(x) |
| 71 | #endif |
| 72 | |
| 73 | /* |
| 74 | ** We find that the built-in isspace() function does not work for |
| 75 | ** some international character sets. So here is a substitute. |
| 76 | */ |
| @@ -106,11 +111,11 @@ | |
| 106 | assert( fossil_isspace((char)i) ); |
| 107 | }else{ |
| 108 | assert( !fossil_isspace((char)i) ); |
| 109 | } |
| 110 | } |
| 111 | printf("All 256 characters OK\n"); |
| 112 | } |
| 113 | |
| 114 | /* |
| 115 | ** This routine is called if a blob operation fails because we |
| 116 | ** have run out of memory. |
| @@ -178,16 +183,29 @@ | |
| 178 | void blob_reset(Blob *pBlob){ |
| 179 | blob_is_init(pBlob); |
| 180 | pBlob->xRealloc(pBlob, 0); |
| 181 | } |
| 182 | |
| 183 | /* |
| 184 | ** Initialize a blob to a string or byte-array constant of a specified length. |
| 185 | ** Any prior data in the blob is discarded. |
| 186 | */ |
| 187 | void blob_init(Blob *pBlob, const char *zData, int size){ |
| 188 | blob_is_reset(pBlob); |
| 189 | if( zData==0 ){ |
| 190 | *pBlob = empty_blob; |
| 191 | }else{ |
| 192 | if( size<=0 ) size = strlen(zData); |
| 193 | pBlob->nUsed = pBlob->nAlloc = size; |
| @@ -208,11 +226,11 @@ | |
| 208 | /* |
| 209 | ** Initialize a blob to an empty string. |
| 210 | */ |
| 211 | void blob_zero(Blob *pBlob){ |
| 212 | static const char zEmpty[] = ""; |
| 213 | blob_is_reset(pBlob); |
| 214 | pBlob->nUsed = 0; |
| 215 | pBlob->nAlloc = 1; |
| 216 | pBlob->aData = (char*)zEmpty; |
| 217 | pBlob->iCursor = 0; |
| 218 | pBlob->xRealloc = blobReallocStatic; |
| @@ -357,11 +375,11 @@ | |
| 357 | ** |
| 358 | ** After this call completes, pTo will be an ephemeral blob. |
| 359 | */ |
| 360 | int blob_extract(Blob *pFrom, int N, Blob *pTo){ |
| 361 | blob_is_init(pFrom); |
| 362 | blob_is_reset(pTo); |
| 363 | if( pFrom->iCursor + N > pFrom->nUsed ){ |
| 364 | N = pFrom->nUsed - pFrom->iCursor; |
| 365 | if( N<=0 ){ |
| 366 | blob_zero(pTo); |
| 367 | return 0; |
| @@ -471,10 +489,48 @@ | |
| 471 | int n = pFrom->nUsed; |
| 472 | int i = pFrom->iCursor; |
| 473 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 474 | pFrom->iCursor = i; |
| 475 | while( i<n && !fossil_isspace(aData[i]) ){ i++; } |
| 476 | blob_extract(pFrom, i-pFrom->iCursor, pTo); |
| 477 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 478 | pFrom->iCursor = i; |
| 479 | return pTo->nUsed; |
| 480 | } |
| @@ -634,11 +690,11 @@ | |
| 634 | } |
| 635 | if( size==0 ){ |
| 636 | return 0; |
| 637 | } |
| 638 | blob_resize(pBlob, size); |
| 639 | in = fopen(zFilename, "rb"); |
| 640 | if( in==0 ){ |
| 641 | fossil_panic("cannot open %s for reading", zFilename); |
| 642 | } |
| 643 | got = fread(blob_buffer(pBlob), 1, size, in); |
| 644 | fclose(in); |
| @@ -658,13 +714,15 @@ | |
| 658 | */ |
| 659 | int blob_read_link(Blob *pBlob, const char *zFilename){ |
| 660 | #if !defined(_WIN32) |
| 661 | char zBuf[1024]; |
| 662 | ssize_t len = readlink(zFilename, zBuf, 1023); |
| 663 | zBuf[len] = 0; |
| 664 | blob_zero(pBlob); |
| 665 | blob_appendf(pBlob, "%s", zBuf); |
| 666 | return len; |
| 667 | #else |
| 668 | blob_zero(pBlob); |
| 669 | return 0; |
| 670 | #endif |
| @@ -678,16 +736,15 @@ | |
| 678 | ** |
| 679 | ** Return the number of bytes written. |
| 680 | */ |
| 681 | int blob_write_to_file(Blob *pBlob, const char *zFilename){ |
| 682 | FILE *out; |
| 683 | int needToClose; |
| 684 | int wrote; |
| 685 | |
| 686 | if( zFilename[0]==0 || (zFilename[0]=='-' && zFilename[1]==0) ){ |
| 687 | out = stdout; |
| 688 | needToClose = 0; |
| 689 | }else{ |
| 690 | int i, nName; |
| 691 | char *zName, zBuf[1000]; |
| 692 | |
| 693 | nName = strlen(zFilename); |
| @@ -717,22 +774,21 @@ | |
| 717 | } |
| 718 | #endif |
| 719 | zName[i] = '/'; |
| 720 | } |
| 721 | } |
| 722 | out = fopen(zName, "wb"); |
| 723 | if( out==0 ){ |
| 724 | fossil_fatal_recursive("unable to open file \"%s\" for writing", zName); |
| 725 | return 0; |
| 726 | } |
| 727 | needToClose = 1; |
| 728 | if( zName!=zBuf ) free(zName); |
| 729 | } |
| 730 | blob_is_init(pBlob); |
| 731 | wrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out); |
| 732 | if( needToClose ) fclose(out); |
| 733 | if( wrote!=blob_size(pBlob) ){ |
| 734 | fossil_fatal_recursive("short write: %d of %d bytes to %s", wrote, |
| 735 | blob_size(pBlob), zFilename); |
| 736 | } |
| 737 | return wrote; |
| 738 | } |
| @@ -758,11 +814,11 @@ | |
| 758 | outBuf[3] = nIn & 0xff; |
| 759 | nOut2 = (long int)nOut; |
| 760 | compress(&outBuf[4], &nOut2, |
| 761 | (unsigned char*)blob_buffer(pIn), blob_size(pIn)); |
| 762 | if( pOut==pIn ) blob_reset(pOut); |
| 763 | blob_is_reset(pOut); |
| 764 | *pOut = temp; |
| 765 | blob_resize(pOut, nOut2+4); |
| 766 | } |
| 767 | |
| 768 | /* |
| @@ -811,11 +867,11 @@ | |
| 811 | deflate(&stream, Z_FINISH); |
| 812 | blob_resize(&temp, stream.total_out + 4); |
| 813 | deflateEnd(&stream); |
| 814 | if( pOut==pIn1 ) blob_reset(pOut); |
| 815 | if( pOut==pIn2 ) blob_reset(pOut); |
| 816 | blob_is_reset(pOut); |
| 817 | *pOut = temp; |
| 818 | } |
| 819 | |
| 820 | /* |
| 821 | ** COMMAND: test-compress-2 |
| @@ -856,11 +912,11 @@ | |
| 856 | blob_reset(&temp); |
| 857 | return 1; |
| 858 | } |
| 859 | blob_resize(&temp, nOut2); |
| 860 | if( pOut==pIn ) blob_reset(pOut); |
| 861 | blob_is_reset(pOut); |
| 862 | *pOut = temp; |
| 863 | return 0; |
| 864 | } |
| 865 | |
| 866 | /* |
| @@ -892,11 +948,11 @@ | |
| 892 | } |
| 893 | blob_reset(&b1); |
| 894 | blob_reset(&b2); |
| 895 | blob_reset(&b3); |
| 896 | } |
| 897 | printf("ok\n"); |
| 898 | } |
| 899 | |
| 900 | #if defined(_WIN32) |
| 901 | /* |
| 902 | ** Convert every \n character in the given blob into \r\n. |
| 903 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -60,17 +60,22 @@ | |
| 60 | #define blob_is_init(x) \ |
| 61 | assert((x)->xRealloc==blobReallocMalloc || (x)->xRealloc==blobReallocStatic) |
| 62 | |
| 63 | /* |
| 64 | ** Make sure a blob does not contain malloced memory. |
| 65 | ** |
| 66 | ** This might fail if we are unlucky and x is uninitialized. For that |
| 67 | ** reason it should only be used locally for debugging. Leave it turned |
| 68 | ** off for production. |
| 69 | */ |
| 70 | #if 0 /* Enable for debugging only */ |
| 71 | #define assert_blob_is_reset(x) assert(blob_is_reset(x)) |
| 72 | #else |
| 73 | #define assert_blob_is_reset(x) |
| 74 | #endif |
| 75 | |
| 76 | |
| 77 | |
| 78 | /* |
| 79 | ** We find that the built-in isspace() function does not work for |
| 80 | ** some international character sets. So here is a substitute. |
| 81 | */ |
| @@ -106,11 +111,11 @@ | |
| 111 | assert( fossil_isspace((char)i) ); |
| 112 | }else{ |
| 113 | assert( !fossil_isspace((char)i) ); |
| 114 | } |
| 115 | } |
| 116 | fossil_print("All 256 characters OK\n"); |
| 117 | } |
| 118 | |
| 119 | /* |
| 120 | ** This routine is called if a blob operation fails because we |
| 121 | ** have run out of memory. |
| @@ -178,16 +183,29 @@ | |
| 183 | void blob_reset(Blob *pBlob){ |
| 184 | blob_is_init(pBlob); |
| 185 | pBlob->xRealloc(pBlob, 0); |
| 186 | } |
| 187 | |
| 188 | |
| 189 | /* |
| 190 | ** Return true if the blob has been zeroed - in other words if it contains |
| 191 | ** no malloced memory. This only works reliably if the blob has been |
| 192 | ** initialized - it can return a false negative on an uninitialized blob. |
| 193 | */ |
| 194 | int blob_is_reset(Blob *pBlob){ |
| 195 | if( pBlob==0 ) return 1; |
| 196 | if( pBlob->nUsed ) return 0; |
| 197 | if( pBlob->xRealloc==blobReallocMalloc && pBlob->nAlloc ) return 0; |
| 198 | return 1; |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | ** Initialize a blob to a string or byte-array constant of a specified length. |
| 203 | ** Any prior data in the blob is discarded. |
| 204 | */ |
| 205 | void blob_init(Blob *pBlob, const char *zData, int size){ |
| 206 | assert_blob_is_reset(pBlob); |
| 207 | if( zData==0 ){ |
| 208 | *pBlob = empty_blob; |
| 209 | }else{ |
| 210 | if( size<=0 ) size = strlen(zData); |
| 211 | pBlob->nUsed = pBlob->nAlloc = size; |
| @@ -208,11 +226,11 @@ | |
| 226 | /* |
| 227 | ** Initialize a blob to an empty string. |
| 228 | */ |
| 229 | void blob_zero(Blob *pBlob){ |
| 230 | static const char zEmpty[] = ""; |
| 231 | assert_blob_is_reset(pBlob); |
| 232 | pBlob->nUsed = 0; |
| 233 | pBlob->nAlloc = 1; |
| 234 | pBlob->aData = (char*)zEmpty; |
| 235 | pBlob->iCursor = 0; |
| 236 | pBlob->xRealloc = blobReallocStatic; |
| @@ -357,11 +375,11 @@ | |
| 375 | ** |
| 376 | ** After this call completes, pTo will be an ephemeral blob. |
| 377 | */ |
| 378 | int blob_extract(Blob *pFrom, int N, Blob *pTo){ |
| 379 | blob_is_init(pFrom); |
| 380 | assert_blob_is_reset(pTo); |
| 381 | if( pFrom->iCursor + N > pFrom->nUsed ){ |
| 382 | N = pFrom->nUsed - pFrom->iCursor; |
| 383 | if( N<=0 ){ |
| 384 | blob_zero(pTo); |
| 385 | return 0; |
| @@ -471,10 +489,48 @@ | |
| 489 | int n = pFrom->nUsed; |
| 490 | int i = pFrom->iCursor; |
| 491 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 492 | pFrom->iCursor = i; |
| 493 | while( i<n && !fossil_isspace(aData[i]) ){ i++; } |
| 494 | blob_extract(pFrom, i-pFrom->iCursor, pTo); |
| 495 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 496 | pFrom->iCursor = i; |
| 497 | return pTo->nUsed; |
| 498 | } |
| 499 | |
| 500 | /* |
| 501 | ** Extract a single SQL token from pFrom and use it to initialize pTo. |
| 502 | ** Return the number of bytes in the token. If no token is found, |
| 503 | ** return 0. |
| 504 | ** |
| 505 | ** An SQL token consists of one or more non-space characters. If the |
| 506 | ** first character is ' then the token is terminated by a matching ' |
| 507 | ** (ignoring double '') or by the end of the string |
| 508 | ** |
| 509 | ** The cursor of pFrom is left pointing at the first character past |
| 510 | ** the end of the token. |
| 511 | ** |
| 512 | ** pTo will be an ephermeral blob. If pFrom changes, it might alter |
| 513 | ** pTo as well. |
| 514 | */ |
| 515 | int blob_sqltoken(Blob *pFrom, Blob *pTo){ |
| 516 | char *aData = pFrom->aData; |
| 517 | int n = pFrom->nUsed; |
| 518 | int i = pFrom->iCursor; |
| 519 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 520 | pFrom->iCursor = i; |
| 521 | if( aData[i]=='\'' ){ |
| 522 | i++; |
| 523 | while( i<n ){ |
| 524 | if( aData[i]=='\'' ){ |
| 525 | if( aData[++i]!='\'' ) break; |
| 526 | } |
| 527 | i++; |
| 528 | } |
| 529 | }else{ |
| 530 | while( i<n && !fossil_isspace(aData[i]) ){ i++; } |
| 531 | } |
| 532 | blob_extract(pFrom, i-pFrom->iCursor, pTo); |
| 533 | while( i<n && fossil_isspace(aData[i]) ){ i++; } |
| 534 | pFrom->iCursor = i; |
| 535 | return pTo->nUsed; |
| 536 | } |
| @@ -634,11 +690,11 @@ | |
| 690 | } |
| 691 | if( size==0 ){ |
| 692 | return 0; |
| 693 | } |
| 694 | blob_resize(pBlob, size); |
| 695 | in = fossil_fopen(zFilename, "rb"); |
| 696 | if( in==0 ){ |
| 697 | fossil_panic("cannot open %s for reading", zFilename); |
| 698 | } |
| 699 | got = fread(blob_buffer(pBlob), 1, size, in); |
| 700 | fclose(in); |
| @@ -658,13 +714,15 @@ | |
| 714 | */ |
| 715 | int blob_read_link(Blob *pBlob, const char *zFilename){ |
| 716 | #if !defined(_WIN32) |
| 717 | char zBuf[1024]; |
| 718 | ssize_t len = readlink(zFilename, zBuf, 1023); |
| 719 | blob_zero(pBlob); |
| 720 | if (len > 0) { |
| 721 | zBuf[len] = 0; |
| 722 | blob_appendf(pBlob, "%s", zBuf); |
| 723 | } |
| 724 | return len; |
| 725 | #else |
| 726 | blob_zero(pBlob); |
| 727 | return 0; |
| 728 | #endif |
| @@ -678,16 +736,15 @@ | |
| 736 | ** |
| 737 | ** Return the number of bytes written. |
| 738 | */ |
| 739 | int blob_write_to_file(Blob *pBlob, const char *zFilename){ |
| 740 | FILE *out; |
| 741 | int wrote; |
| 742 | |
| 743 | if( zFilename[0]==0 || (zFilename[0]=='-' && zFilename[1]==0) ){ |
| 744 | fossil_puts(blob_str(pBlob), 0); |
| 745 | return blob_size(pBlob); |
| 746 | }else{ |
| 747 | int i, nName; |
| 748 | char *zName, zBuf[1000]; |
| 749 | |
| 750 | nName = strlen(zFilename); |
| @@ -717,22 +774,21 @@ | |
| 774 | } |
| 775 | #endif |
| 776 | zName[i] = '/'; |
| 777 | } |
| 778 | } |
| 779 | out = fossil_fopen(zName, "wb"); |
| 780 | if( out==0 ){ |
| 781 | fossil_fatal_recursive("unable to open file \"%s\" for writing", zName); |
| 782 | return 0; |
| 783 | } |
| 784 | if( zName!=zBuf ) free(zName); |
| 785 | } |
| 786 | blob_is_init(pBlob); |
| 787 | wrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out); |
| 788 | fclose(out); |
| 789 | if( wrote!=blob_size(pBlob) && out!=stdout ){ |
| 790 | fossil_fatal_recursive("short write: %d of %d bytes to %s", wrote, |
| 791 | blob_size(pBlob), zFilename); |
| 792 | } |
| 793 | return wrote; |
| 794 | } |
| @@ -758,11 +814,11 @@ | |
| 814 | outBuf[3] = nIn & 0xff; |
| 815 | nOut2 = (long int)nOut; |
| 816 | compress(&outBuf[4], &nOut2, |
| 817 | (unsigned char*)blob_buffer(pIn), blob_size(pIn)); |
| 818 | if( pOut==pIn ) blob_reset(pOut); |
| 819 | assert_blob_is_reset(pOut); |
| 820 | *pOut = temp; |
| 821 | blob_resize(pOut, nOut2+4); |
| 822 | } |
| 823 | |
| 824 | /* |
| @@ -811,11 +867,11 @@ | |
| 867 | deflate(&stream, Z_FINISH); |
| 868 | blob_resize(&temp, stream.total_out + 4); |
| 869 | deflateEnd(&stream); |
| 870 | if( pOut==pIn1 ) blob_reset(pOut); |
| 871 | if( pOut==pIn2 ) blob_reset(pOut); |
| 872 | assert_blob_is_reset(pOut); |
| 873 | *pOut = temp; |
| 874 | } |
| 875 | |
| 876 | /* |
| 877 | ** COMMAND: test-compress-2 |
| @@ -856,11 +912,11 @@ | |
| 912 | blob_reset(&temp); |
| 913 | return 1; |
| 914 | } |
| 915 | blob_resize(&temp, nOut2); |
| 916 | if( pOut==pIn ) blob_reset(pOut); |
| 917 | assert_blob_is_reset(pOut); |
| 918 | *pOut = temp; |
| 919 | return 0; |
| 920 | } |
| 921 | |
| 922 | /* |
| @@ -892,11 +948,11 @@ | |
| 948 | } |
| 949 | blob_reset(&b1); |
| 950 | blob_reset(&b2); |
| 951 | blob_reset(&b3); |
| 952 | } |
| 953 | fossil_print("ok\n"); |
| 954 | } |
| 955 | |
| 956 | #if defined(_WIN32) |
| 957 | /* |
| 958 | ** Convert every \n character in the given blob into \r\n. |
| 959 |
+75
-29
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -39,13 +39,15 @@ | ||
| 39 | 39 | Blob branch; /* manifest for the new branch */ |
| 40 | 40 | Manifest *pParent; /* Parsed parent manifest */ |
| 41 | 41 | Blob mcksum; /* Self-checksum on the manifest */ |
| 42 | 42 | const char *zDateOvrd; /* Override date string */ |
| 43 | 43 | const char *zUserOvrd; /* Override user name */ |
| 44 | + int isPrivate = 0; /* True if the branch should be private */ | |
| 44 | 45 | |
| 45 | 46 | noSign = find_option("nosign","",0)!=0; |
| 46 | 47 | zColor = find_option("bgcolor","c",1); |
| 48 | + isPrivate = find_option("private",0,0)!=0; | |
| 47 | 49 | zDateOvrd = find_option("date-override",0,1); |
| 48 | 50 | zUserOvrd = find_option("user-override",0,1); |
| 49 | 51 | verify_all_options(); |
| 50 | 52 | if( g.argc<5 ){ |
| 51 | 53 | usage("new BRANCH-NAME CHECK-IN ?-bgcolor COLOR?"); |
| @@ -66,11 +68,11 @@ | ||
| 66 | 68 | fossil_fatal("branch \"%s\" already exists", zBranch); |
| 67 | 69 | } |
| 68 | 70 | |
| 69 | 71 | user_select(); |
| 70 | 72 | db_begin_transaction(); |
| 71 | - rootid = name_to_rid(g.argv[4]); | |
| 73 | + rootid = name_to_typed_rid(g.argv[4], "ci"); | |
| 72 | 74 | if( rootid==0 ){ |
| 73 | 75 | fossil_fatal("unable to locate check-in off of which to branch"); |
| 74 | 76 | } |
| 75 | 77 | |
| 76 | 78 | pParent = manifest_get(rootid, CFTYPE_MANIFEST); |
| @@ -99,20 +101,28 @@ | ||
| 99 | 101 | } |
| 100 | 102 | blob_append(&branch, "\n", 1); |
| 101 | 103 | } |
| 102 | 104 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rootid); |
| 103 | 105 | blob_appendf(&branch, "P %s\n", zUuid); |
| 104 | - blob_appendf(&branch, "R %s\n", pParent->zRepoCksum); | |
| 106 | + if( pParent->zRepoCksum ){ | |
| 107 | + blob_appendf(&branch, "R %s\n", pParent->zRepoCksum); | |
| 108 | + } | |
| 105 | 109 | manifest_destroy(pParent); |
| 106 | 110 | |
| 107 | 111 | /* Add the symbolic branch name and the "branch" tag to identify |
| 108 | 112 | ** this as a new branch */ |
| 113 | + if( content_is_private(rootid) ) isPrivate = 1; | |
| 114 | + if( isPrivate && zColor==0 ) zColor = "#fec084"; | |
| 109 | 115 | if( zColor!=0 ){ |
| 110 | 116 | blob_appendf(&branch, "T *bgcolor * %F\n", zColor); |
| 111 | 117 | } |
| 112 | 118 | blob_appendf(&branch, "T *branch * %F\n", zBranch); |
| 113 | 119 | blob_appendf(&branch, "T *sym-%F *\n", zBranch); |
| 120 | + if( isPrivate ){ | |
| 121 | + blob_appendf(&branch, "T +private *\n"); | |
| 122 | + noSign = 1; | |
| 123 | + } | |
| 114 | 124 | |
| 115 | 125 | /* Cancel all other symbolic tags */ |
| 116 | 126 | db_prepare(&q, |
| 117 | 127 | "SELECT tagname FROM tagxref, tag" |
| 118 | 128 | " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid" |
| @@ -136,23 +146,24 @@ | ||
| 136 | 146 | db_end_transaction(1); |
| 137 | 147 | fossil_exit(1); |
| 138 | 148 | } |
| 139 | 149 | } |
| 140 | 150 | |
| 141 | - brid = content_put(&branch, 0, 0, 0); | |
| 151 | + brid = content_put(&branch); | |
| 142 | 152 | if( brid==0 ){ |
| 143 | 153 | fossil_panic("trouble committing manifest: %s", g.zErrMsg); |
| 144 | 154 | } |
| 145 | 155 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid); |
| 146 | 156 | if( manifest_crosslink(brid, &branch)==0 ){ |
| 147 | 157 | fossil_panic("unable to install new manifest"); |
| 148 | 158 | } |
| 159 | + assert( blob_is_reset(&branch) ); | |
| 149 | 160 | content_deltify(rootid, brid, 0); |
| 150 | 161 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid); |
| 151 | - printf("New branch: %s\n", zUuid); | |
| 162 | + fossil_print("New branch: %s\n", zUuid); | |
| 152 | 163 | if( g.argc==3 ){ |
| 153 | - printf( | |
| 164 | + fossil_print( | |
| 154 | 165 | "\n" |
| 155 | 166 | "Note: the local check-out has not been updated to the new\n" |
| 156 | 167 | " branch. To begin working on the new branch, do this:\n" |
| 157 | 168 | "\n" |
| 158 | 169 | " %s update %s\n", |
| @@ -165,67 +176,102 @@ | ||
| 165 | 176 | db_end_transaction(0); |
| 166 | 177 | |
| 167 | 178 | /* Do an autosync push, if requested */ |
| 168 | 179 | autosync(AUTOSYNC_PUSH); |
| 169 | 180 | } |
| 181 | + | |
| 182 | +/* | |
| 183 | +** Prepare a query that will list all branches. | |
| 184 | +*/ | |
| 185 | +static void prepareBranchQuery(Stmt *pQuery, int showAll, int showClosed){ | |
| 186 | + if( showClosed ){ | |
| 187 | + db_prepare(pQuery, | |
| 188 | + "SELECT value FROM tagxref" | |
| 189 | + " WHERE tagid=%d AND value NOT NULL " | |
| 190 | + "EXCEPT " | |
| 191 | + "SELECT value FROM tagxref" | |
| 192 | + " WHERE tagid=%d" | |
| 193 | + " AND rid IN leaf" | |
| 194 | + " AND NOT %z" | |
| 195 | + " ORDER BY value COLLATE nocase /*sort*/", | |
| 196 | + TAG_BRANCH, TAG_BRANCH, leaf_is_closed_sql("tagxref.rid") | |
| 197 | + ); | |
| 198 | + }else if( showAll ){ | |
| 199 | + db_prepare(pQuery, | |
| 200 | + "SELECT DISTINCT value FROM tagxref" | |
| 201 | + " WHERE tagid=%d AND value NOT NULL" | |
| 202 | + " AND rid IN leaf" | |
| 203 | + " ORDER BY value COLLATE nocase /*sort*/", | |
| 204 | + TAG_BRANCH | |
| 205 | + ); | |
| 206 | + }else{ | |
| 207 | + db_prepare(pQuery, | |
| 208 | + "SELECT DISTINCT value FROM tagxref" | |
| 209 | + " WHERE tagid=%d AND value NOT NULL" | |
| 210 | + " AND rid IN leaf" | |
| 211 | + " AND NOT %z" | |
| 212 | + " ORDER BY value COLLATE nocase /*sort*/", | |
| 213 | + TAG_BRANCH, leaf_is_closed_sql("tagxref.rid") | |
| 214 | + ); | |
| 215 | + } | |
| 216 | +} | |
| 217 | + | |
| 170 | 218 | |
| 171 | 219 | /* |
| 172 | 220 | ** COMMAND: branch |
| 173 | 221 | ** |
| 174 | 222 | ** Usage: %fossil branch SUBCOMMAND ... ?-R|--repository FILE? |
| 175 | 223 | ** |
| 176 | 224 | ** Run various subcommands to manage branches of the open repository or |
| 177 | 225 | ** of the repository identified by the -R or --repository option. |
| 178 | 226 | ** |
| 179 | -** %fossil branch new BRANCH-NAME BASIS ?-bgcolor COLOR? | |
| 227 | +** %fossil branch new BRANCH-NAME BASIS ?--bgcolor COLOR? ?--private? | |
| 180 | 228 | ** |
| 181 | 229 | ** Create a new branch BRANCH-NAME off of check-in BASIS. |
| 182 | -** You can optionally give the branch a default color. | |
| 230 | +** You can optionally give the branch a default color. The | |
| 231 | +** --private option makes the branch private. | |
| 183 | 232 | ** |
| 184 | 233 | ** %fossil branch list |
| 234 | +** %fossil branch ls | |
| 185 | 235 | ** |
| 186 | -** List all branches | |
| 236 | +** List all branches. Use --all or --closed to list all branches | |
| 237 | +** or closed branches. The default is to show only open branches. | |
| 187 | 238 | ** |
| 188 | 239 | */ |
| 189 | 240 | void branch_cmd(void){ |
| 190 | 241 | int n; |
| 191 | 242 | const char *zCmd = "list"; |
| 192 | 243 | db_find_and_open_repository(0, 0); |
| 193 | 244 | if( g.argc<2 ){ |
| 194 | - usage("new|list ..."); | |
| 245 | + usage("new|list|ls ..."); | |
| 195 | 246 | } |
| 196 | 247 | if( g.argc>=3 ) zCmd = g.argv[2]; |
| 197 | 248 | n = strlen(zCmd); |
| 198 | 249 | if( strncmp(zCmd,"new",n)==0 ){ |
| 199 | 250 | branch_new(); |
| 200 | - }else if( strncmp(zCmd,"list",n)==0 ){ | |
| 251 | + }else if( (strncmp(zCmd,"list",n)==0)||(strncmp(zCmd, "ls", n)==0) ){ | |
| 201 | 252 | Stmt q; |
| 202 | 253 | int vid; |
| 203 | 254 | char *zCurrent = 0; |
| 255 | + int showAll = find_option("all",0,0)!=0; | |
| 256 | + int showClosed = find_option("closed",0,0)!=0; | |
| 204 | 257 | |
| 205 | 258 | if( g.localOpen ){ |
| 206 | 259 | vid = db_lget_int("checkout", 0); |
| 207 | 260 | zCurrent = db_text(0, "SELECT value FROM tagxref" |
| 208 | 261 | " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH); |
| 209 | 262 | } |
| 210 | - db_prepare(&q, | |
| 211 | - "SELECT DISTINCT value FROM tagxref" | |
| 212 | - " WHERE tagid=%d AND value NOT NULL" | |
| 213 | - " AND rid IN leaf" | |
| 214 | - " AND NOT %z" | |
| 215 | - " ORDER BY value /*sort*/", | |
| 216 | - TAG_BRANCH, leaf_is_closed_sql("tagxref.rid") | |
| 217 | - ); | |
| 263 | + prepareBranchQuery(&q, showAll, showClosed); | |
| 218 | 264 | while( db_step(&q)==SQLITE_ROW ){ |
| 219 | 265 | const char *zBr = db_column_text(&q, 0); |
| 220 | 266 | int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; |
| 221 | - printf("%s%s\n", (isCur ? "* " : " "), zBr); | |
| 267 | + fossil_print("%s%s\n", (isCur ? "* " : " "), zBr); | |
| 222 | 268 | } |
| 223 | 269 | db_finalize(&q); |
| 224 | 270 | }else{ |
| 225 | 271 | fossil_panic("branch subcommand should be one of: " |
| 226 | - "new list"); | |
| 272 | + "new list ls"); | |
| 227 | 273 | } |
| 228 | 274 | } |
| 229 | 275 | |
| 230 | 276 | /* |
| 231 | 277 | ** WEBPAGE: brlist |
| @@ -234,19 +280,26 @@ | ||
| 234 | 280 | */ |
| 235 | 281 | void brlist_page(void){ |
| 236 | 282 | Stmt q; |
| 237 | 283 | int cnt; |
| 238 | 284 | int showClosed = P("closed")!=0; |
| 285 | + int showAll = P("all")!=0; | |
| 239 | 286 | |
| 240 | 287 | login_check_credentials(); |
| 241 | 288 | if( !g.okRead ){ login_needed(); return; } |
| 242 | 289 | |
| 243 | - style_header(showClosed ? "Closed Branches" : "Open Branches"); | |
| 290 | + style_header(showClosed ? "Closed Branches" : | |
| 291 | + showAll ? "All Branches" : "Open Branches"); | |
| 244 | 292 | style_submenu_element("Timeline", "Timeline", "brtimeline"); |
| 245 | 293 | if( showClosed ){ |
| 294 | + style_submenu_element("All", "All", "brlist?all"); | |
| 295 | + style_submenu_element("Open","Open","brlist"); | |
| 296 | + }else if( showAll ){ | |
| 297 | + style_submenu_element("Closed", "Closed", "brlist?closed"); | |
| 246 | 298 | style_submenu_element("Open","Open","brlist"); |
| 247 | 299 | }else{ |
| 300 | + style_submenu_element("All", "All", "brlist?all"); | |
| 248 | 301 | style_submenu_element("Closed","Closed","brlist?closed"); |
| 249 | 302 | } |
| 250 | 303 | login_anonymous_available(); |
| 251 | 304 | style_sidebox_begin("Nomenclature:", "33%"); |
| 252 | 305 | @ <ol> |
| @@ -262,19 +315,12 @@ | ||
| 262 | 315 | @ Closed branches are fixed and do not change (unless they are first |
| 263 | 316 | @ reopened)</li> |
| 264 | 317 | @ </ol> |
| 265 | 318 | style_sidebox_end(); |
| 266 | 319 | |
| 320 | + prepareBranchQuery(&q, showAll, showClosed); | |
| 267 | 321 | cnt = 0; |
| 268 | - db_prepare(&q, | |
| 269 | - "SELECT DISTINCT value FROM tagxref" | |
| 270 | - " WHERE tagid=%d AND value NOT NULL" | |
| 271 | - " AND rid IN leaf" | |
| 272 | - " AND %s %z" | |
| 273 | - " ORDER BY value /*sort*/", | |
| 274 | - TAG_BRANCH, showClosed ? "" : "NOT", leaf_is_closed_sql("tagxref.rid") | |
| 275 | - ); | |
| 276 | 322 | while( db_step(&q)==SQLITE_ROW ){ |
| 277 | 323 | const char *zBr = db_column_text(&q, 0); |
| 278 | 324 | if( cnt==0 ){ |
| 279 | 325 | if( showClosed ){ |
| 280 | 326 | @ <h2>Closed Branches:</h2> |
| 281 | 327 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -39,13 +39,15 @@ | |
| 39 | Blob branch; /* manifest for the new branch */ |
| 40 | Manifest *pParent; /* Parsed parent manifest */ |
| 41 | Blob mcksum; /* Self-checksum on the manifest */ |
| 42 | const char *zDateOvrd; /* Override date string */ |
| 43 | const char *zUserOvrd; /* Override user name */ |
| 44 | |
| 45 | noSign = find_option("nosign","",0)!=0; |
| 46 | zColor = find_option("bgcolor","c",1); |
| 47 | zDateOvrd = find_option("date-override",0,1); |
| 48 | zUserOvrd = find_option("user-override",0,1); |
| 49 | verify_all_options(); |
| 50 | if( g.argc<5 ){ |
| 51 | usage("new BRANCH-NAME CHECK-IN ?-bgcolor COLOR?"); |
| @@ -66,11 +68,11 @@ | |
| 66 | fossil_fatal("branch \"%s\" already exists", zBranch); |
| 67 | } |
| 68 | |
| 69 | user_select(); |
| 70 | db_begin_transaction(); |
| 71 | rootid = name_to_rid(g.argv[4]); |
| 72 | if( rootid==0 ){ |
| 73 | fossil_fatal("unable to locate check-in off of which to branch"); |
| 74 | } |
| 75 | |
| 76 | pParent = manifest_get(rootid, CFTYPE_MANIFEST); |
| @@ -99,20 +101,28 @@ | |
| 99 | } |
| 100 | blob_append(&branch, "\n", 1); |
| 101 | } |
| 102 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rootid); |
| 103 | blob_appendf(&branch, "P %s\n", zUuid); |
| 104 | blob_appendf(&branch, "R %s\n", pParent->zRepoCksum); |
| 105 | manifest_destroy(pParent); |
| 106 | |
| 107 | /* Add the symbolic branch name and the "branch" tag to identify |
| 108 | ** this as a new branch */ |
| 109 | if( zColor!=0 ){ |
| 110 | blob_appendf(&branch, "T *bgcolor * %F\n", zColor); |
| 111 | } |
| 112 | blob_appendf(&branch, "T *branch * %F\n", zBranch); |
| 113 | blob_appendf(&branch, "T *sym-%F *\n", zBranch); |
| 114 | |
| 115 | /* Cancel all other symbolic tags */ |
| 116 | db_prepare(&q, |
| 117 | "SELECT tagname FROM tagxref, tag" |
| 118 | " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid" |
| @@ -136,23 +146,24 @@ | |
| 136 | db_end_transaction(1); |
| 137 | fossil_exit(1); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | brid = content_put(&branch, 0, 0, 0); |
| 142 | if( brid==0 ){ |
| 143 | fossil_panic("trouble committing manifest: %s", g.zErrMsg); |
| 144 | } |
| 145 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid); |
| 146 | if( manifest_crosslink(brid, &branch)==0 ){ |
| 147 | fossil_panic("unable to install new manifest"); |
| 148 | } |
| 149 | content_deltify(rootid, brid, 0); |
| 150 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid); |
| 151 | printf("New branch: %s\n", zUuid); |
| 152 | if( g.argc==3 ){ |
| 153 | printf( |
| 154 | "\n" |
| 155 | "Note: the local check-out has not been updated to the new\n" |
| 156 | " branch. To begin working on the new branch, do this:\n" |
| 157 | "\n" |
| 158 | " %s update %s\n", |
| @@ -165,67 +176,102 @@ | |
| 165 | db_end_transaction(0); |
| 166 | |
| 167 | /* Do an autosync push, if requested */ |
| 168 | autosync(AUTOSYNC_PUSH); |
| 169 | } |
| 170 | |
| 171 | /* |
| 172 | ** COMMAND: branch |
| 173 | ** |
| 174 | ** Usage: %fossil branch SUBCOMMAND ... ?-R|--repository FILE? |
| 175 | ** |
| 176 | ** Run various subcommands to manage branches of the open repository or |
| 177 | ** of the repository identified by the -R or --repository option. |
| 178 | ** |
| 179 | ** %fossil branch new BRANCH-NAME BASIS ?-bgcolor COLOR? |
| 180 | ** |
| 181 | ** Create a new branch BRANCH-NAME off of check-in BASIS. |
| 182 | ** You can optionally give the branch a default color. |
| 183 | ** |
| 184 | ** %fossil branch list |
| 185 | ** |
| 186 | ** List all branches |
| 187 | ** |
| 188 | */ |
| 189 | void branch_cmd(void){ |
| 190 | int n; |
| 191 | const char *zCmd = "list"; |
| 192 | db_find_and_open_repository(0, 0); |
| 193 | if( g.argc<2 ){ |
| 194 | usage("new|list ..."); |
| 195 | } |
| 196 | if( g.argc>=3 ) zCmd = g.argv[2]; |
| 197 | n = strlen(zCmd); |
| 198 | if( strncmp(zCmd,"new",n)==0 ){ |
| 199 | branch_new(); |
| 200 | }else if( strncmp(zCmd,"list",n)==0 ){ |
| 201 | Stmt q; |
| 202 | int vid; |
| 203 | char *zCurrent = 0; |
| 204 | |
| 205 | if( g.localOpen ){ |
| 206 | vid = db_lget_int("checkout", 0); |
| 207 | zCurrent = db_text(0, "SELECT value FROM tagxref" |
| 208 | " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH); |
| 209 | } |
| 210 | db_prepare(&q, |
| 211 | "SELECT DISTINCT value FROM tagxref" |
| 212 | " WHERE tagid=%d AND value NOT NULL" |
| 213 | " AND rid IN leaf" |
| 214 | " AND NOT %z" |
| 215 | " ORDER BY value /*sort*/", |
| 216 | TAG_BRANCH, leaf_is_closed_sql("tagxref.rid") |
| 217 | ); |
| 218 | while( db_step(&q)==SQLITE_ROW ){ |
| 219 | const char *zBr = db_column_text(&q, 0); |
| 220 | int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; |
| 221 | printf("%s%s\n", (isCur ? "* " : " "), zBr); |
| 222 | } |
| 223 | db_finalize(&q); |
| 224 | }else{ |
| 225 | fossil_panic("branch subcommand should be one of: " |
| 226 | "new list"); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | /* |
| 231 | ** WEBPAGE: brlist |
| @@ -234,19 +280,26 @@ | |
| 234 | */ |
| 235 | void brlist_page(void){ |
| 236 | Stmt q; |
| 237 | int cnt; |
| 238 | int showClosed = P("closed")!=0; |
| 239 | |
| 240 | login_check_credentials(); |
| 241 | if( !g.okRead ){ login_needed(); return; } |
| 242 | |
| 243 | style_header(showClosed ? "Closed Branches" : "Open Branches"); |
| 244 | style_submenu_element("Timeline", "Timeline", "brtimeline"); |
| 245 | if( showClosed ){ |
| 246 | style_submenu_element("Open","Open","brlist"); |
| 247 | }else{ |
| 248 | style_submenu_element("Closed","Closed","brlist?closed"); |
| 249 | } |
| 250 | login_anonymous_available(); |
| 251 | style_sidebox_begin("Nomenclature:", "33%"); |
| 252 | @ <ol> |
| @@ -262,19 +315,12 @@ | |
| 262 | @ Closed branches are fixed and do not change (unless they are first |
| 263 | @ reopened)</li> |
| 264 | @ </ol> |
| 265 | style_sidebox_end(); |
| 266 | |
| 267 | cnt = 0; |
| 268 | db_prepare(&q, |
| 269 | "SELECT DISTINCT value FROM tagxref" |
| 270 | " WHERE tagid=%d AND value NOT NULL" |
| 271 | " AND rid IN leaf" |
| 272 | " AND %s %z" |
| 273 | " ORDER BY value /*sort*/", |
| 274 | TAG_BRANCH, showClosed ? "" : "NOT", leaf_is_closed_sql("tagxref.rid") |
| 275 | ); |
| 276 | while( db_step(&q)==SQLITE_ROW ){ |
| 277 | const char *zBr = db_column_text(&q, 0); |
| 278 | if( cnt==0 ){ |
| 279 | if( showClosed ){ |
| 280 | @ <h2>Closed Branches:</h2> |
| 281 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -39,13 +39,15 @@ | |
| 39 | Blob branch; /* manifest for the new branch */ |
| 40 | Manifest *pParent; /* Parsed parent manifest */ |
| 41 | Blob mcksum; /* Self-checksum on the manifest */ |
| 42 | const char *zDateOvrd; /* Override date string */ |
| 43 | const char *zUserOvrd; /* Override user name */ |
| 44 | int isPrivate = 0; /* True if the branch should be private */ |
| 45 | |
| 46 | noSign = find_option("nosign","",0)!=0; |
| 47 | zColor = find_option("bgcolor","c",1); |
| 48 | isPrivate = find_option("private",0,0)!=0; |
| 49 | zDateOvrd = find_option("date-override",0,1); |
| 50 | zUserOvrd = find_option("user-override",0,1); |
| 51 | verify_all_options(); |
| 52 | if( g.argc<5 ){ |
| 53 | usage("new BRANCH-NAME CHECK-IN ?-bgcolor COLOR?"); |
| @@ -66,11 +68,11 @@ | |
| 68 | fossil_fatal("branch \"%s\" already exists", zBranch); |
| 69 | } |
| 70 | |
| 71 | user_select(); |
| 72 | db_begin_transaction(); |
| 73 | rootid = name_to_typed_rid(g.argv[4], "ci"); |
| 74 | if( rootid==0 ){ |
| 75 | fossil_fatal("unable to locate check-in off of which to branch"); |
| 76 | } |
| 77 | |
| 78 | pParent = manifest_get(rootid, CFTYPE_MANIFEST); |
| @@ -99,20 +101,28 @@ | |
| 101 | } |
| 102 | blob_append(&branch, "\n", 1); |
| 103 | } |
| 104 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rootid); |
| 105 | blob_appendf(&branch, "P %s\n", zUuid); |
| 106 | if( pParent->zRepoCksum ){ |
| 107 | blob_appendf(&branch, "R %s\n", pParent->zRepoCksum); |
| 108 | } |
| 109 | manifest_destroy(pParent); |
| 110 | |
| 111 | /* Add the symbolic branch name and the "branch" tag to identify |
| 112 | ** this as a new branch */ |
| 113 | if( content_is_private(rootid) ) isPrivate = 1; |
| 114 | if( isPrivate && zColor==0 ) zColor = "#fec084"; |
| 115 | if( zColor!=0 ){ |
| 116 | blob_appendf(&branch, "T *bgcolor * %F\n", zColor); |
| 117 | } |
| 118 | blob_appendf(&branch, "T *branch * %F\n", zBranch); |
| 119 | blob_appendf(&branch, "T *sym-%F *\n", zBranch); |
| 120 | if( isPrivate ){ |
| 121 | blob_appendf(&branch, "T +private *\n"); |
| 122 | noSign = 1; |
| 123 | } |
| 124 | |
| 125 | /* Cancel all other symbolic tags */ |
| 126 | db_prepare(&q, |
| 127 | "SELECT tagname FROM tagxref, tag" |
| 128 | " WHERE tagxref.rid=%d AND tagxref.tagid=tag.tagid" |
| @@ -136,23 +146,24 @@ | |
| 146 | db_end_transaction(1); |
| 147 | fossil_exit(1); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | brid = content_put(&branch); |
| 152 | if( brid==0 ){ |
| 153 | fossil_panic("trouble committing manifest: %s", g.zErrMsg); |
| 154 | } |
| 155 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid); |
| 156 | if( manifest_crosslink(brid, &branch)==0 ){ |
| 157 | fossil_panic("unable to install new manifest"); |
| 158 | } |
| 159 | assert( blob_is_reset(&branch) ); |
| 160 | content_deltify(rootid, brid, 0); |
| 161 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid); |
| 162 | fossil_print("New branch: %s\n", zUuid); |
| 163 | if( g.argc==3 ){ |
| 164 | fossil_print( |
| 165 | "\n" |
| 166 | "Note: the local check-out has not been updated to the new\n" |
| 167 | " branch. To begin working on the new branch, do this:\n" |
| 168 | "\n" |
| 169 | " %s update %s\n", |
| @@ -165,67 +176,102 @@ | |
| 176 | db_end_transaction(0); |
| 177 | |
| 178 | /* Do an autosync push, if requested */ |
| 179 | autosync(AUTOSYNC_PUSH); |
| 180 | } |
| 181 | |
| 182 | /* |
| 183 | ** Prepare a query that will list all branches. |
| 184 | */ |
| 185 | static void prepareBranchQuery(Stmt *pQuery, int showAll, int showClosed){ |
| 186 | if( showClosed ){ |
| 187 | db_prepare(pQuery, |
| 188 | "SELECT value FROM tagxref" |
| 189 | " WHERE tagid=%d AND value NOT NULL " |
| 190 | "EXCEPT " |
| 191 | "SELECT value FROM tagxref" |
| 192 | " WHERE tagid=%d" |
| 193 | " AND rid IN leaf" |
| 194 | " AND NOT %z" |
| 195 | " ORDER BY value COLLATE nocase /*sort*/", |
| 196 | TAG_BRANCH, TAG_BRANCH, leaf_is_closed_sql("tagxref.rid") |
| 197 | ); |
| 198 | }else if( showAll ){ |
| 199 | db_prepare(pQuery, |
| 200 | "SELECT DISTINCT value FROM tagxref" |
| 201 | " WHERE tagid=%d AND value NOT NULL" |
| 202 | " AND rid IN leaf" |
| 203 | " ORDER BY value COLLATE nocase /*sort*/", |
| 204 | TAG_BRANCH |
| 205 | ); |
| 206 | }else{ |
| 207 | db_prepare(pQuery, |
| 208 | "SELECT DISTINCT value FROM tagxref" |
| 209 | " WHERE tagid=%d AND value NOT NULL" |
| 210 | " AND rid IN leaf" |
| 211 | " AND NOT %z" |
| 212 | " ORDER BY value COLLATE nocase /*sort*/", |
| 213 | TAG_BRANCH, leaf_is_closed_sql("tagxref.rid") |
| 214 | ); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | |
| 219 | /* |
| 220 | ** COMMAND: branch |
| 221 | ** |
| 222 | ** Usage: %fossil branch SUBCOMMAND ... ?-R|--repository FILE? |
| 223 | ** |
| 224 | ** Run various subcommands to manage branches of the open repository or |
| 225 | ** of the repository identified by the -R or --repository option. |
| 226 | ** |
| 227 | ** %fossil branch new BRANCH-NAME BASIS ?--bgcolor COLOR? ?--private? |
| 228 | ** |
| 229 | ** Create a new branch BRANCH-NAME off of check-in BASIS. |
| 230 | ** You can optionally give the branch a default color. The |
| 231 | ** --private option makes the branch private. |
| 232 | ** |
| 233 | ** %fossil branch list |
| 234 | ** %fossil branch ls |
| 235 | ** |
| 236 | ** List all branches. Use --all or --closed to list all branches |
| 237 | ** or closed branches. The default is to show only open branches. |
| 238 | ** |
| 239 | */ |
| 240 | void branch_cmd(void){ |
| 241 | int n; |
| 242 | const char *zCmd = "list"; |
| 243 | db_find_and_open_repository(0, 0); |
| 244 | if( g.argc<2 ){ |
| 245 | usage("new|list|ls ..."); |
| 246 | } |
| 247 | if( g.argc>=3 ) zCmd = g.argv[2]; |
| 248 | n = strlen(zCmd); |
| 249 | if( strncmp(zCmd,"new",n)==0 ){ |
| 250 | branch_new(); |
| 251 | }else if( (strncmp(zCmd,"list",n)==0)||(strncmp(zCmd, "ls", n)==0) ){ |
| 252 | Stmt q; |
| 253 | int vid; |
| 254 | char *zCurrent = 0; |
| 255 | int showAll = find_option("all",0,0)!=0; |
| 256 | int showClosed = find_option("closed",0,0)!=0; |
| 257 | |
| 258 | if( g.localOpen ){ |
| 259 | vid = db_lget_int("checkout", 0); |
| 260 | zCurrent = db_text(0, "SELECT value FROM tagxref" |
| 261 | " WHERE rid=%d AND tagid=%d", vid, TAG_BRANCH); |
| 262 | } |
| 263 | prepareBranchQuery(&q, showAll, showClosed); |
| 264 | while( db_step(&q)==SQLITE_ROW ){ |
| 265 | const char *zBr = db_column_text(&q, 0); |
| 266 | int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0; |
| 267 | fossil_print("%s%s\n", (isCur ? "* " : " "), zBr); |
| 268 | } |
| 269 | db_finalize(&q); |
| 270 | }else{ |
| 271 | fossil_panic("branch subcommand should be one of: " |
| 272 | "new list ls"); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | /* |
| 277 | ** WEBPAGE: brlist |
| @@ -234,19 +280,26 @@ | |
| 280 | */ |
| 281 | void brlist_page(void){ |
| 282 | Stmt q; |
| 283 | int cnt; |
| 284 | int showClosed = P("closed")!=0; |
| 285 | int showAll = P("all")!=0; |
| 286 | |
| 287 | login_check_credentials(); |
| 288 | if( !g.okRead ){ login_needed(); return; } |
| 289 | |
| 290 | style_header(showClosed ? "Closed Branches" : |
| 291 | showAll ? "All Branches" : "Open Branches"); |
| 292 | style_submenu_element("Timeline", "Timeline", "brtimeline"); |
| 293 | if( showClosed ){ |
| 294 | style_submenu_element("All", "All", "brlist?all"); |
| 295 | style_submenu_element("Open","Open","brlist"); |
| 296 | }else if( showAll ){ |
| 297 | style_submenu_element("Closed", "Closed", "brlist?closed"); |
| 298 | style_submenu_element("Open","Open","brlist"); |
| 299 | }else{ |
| 300 | style_submenu_element("All", "All", "brlist?all"); |
| 301 | style_submenu_element("Closed","Closed","brlist?closed"); |
| 302 | } |
| 303 | login_anonymous_available(); |
| 304 | style_sidebox_begin("Nomenclature:", "33%"); |
| 305 | @ <ol> |
| @@ -262,19 +315,12 @@ | |
| 315 | @ Closed branches are fixed and do not change (unless they are first |
| 316 | @ reopened)</li> |
| 317 | @ </ol> |
| 318 | style_sidebox_end(); |
| 319 | |
| 320 | prepareBranchQuery(&q, showAll, showClosed); |
| 321 | cnt = 0; |
| 322 | while( db_step(&q)==SQLITE_ROW ){ |
| 323 | const char *zBr = db_column_text(&q, 0); |
| 324 | if( cnt==0 ){ |
| 325 | if( showClosed ){ |
| 326 | @ <h2>Closed Branches:</h2> |
| 327 |
+7
-3
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -146,11 +146,11 @@ | ||
| 146 | 146 | /* Compute the title of the page */ |
| 147 | 147 | blob_zero(&dirname); |
| 148 | 148 | if( zD ){ |
| 149 | 149 | blob_append(&dirname, "in directory ", -1); |
| 150 | 150 | hyperlinked_path(zD, &dirname, zCI); |
| 151 | - zPrefix = mprintf("%h/", zD); | |
| 151 | + zPrefix = mprintf("%s/", zD); | |
| 152 | 152 | }else{ |
| 153 | 153 | blob_append(&dirname, "in the top-level directory", -1); |
| 154 | 154 | zPrefix = ""; |
| 155 | 155 | } |
| 156 | 156 | if( zCI ){ |
| @@ -210,11 +210,15 @@ | ||
| 210 | 210 | db_prepare(&ins, |
| 211 | 211 | "INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,0), :u)" |
| 212 | 212 | ); |
| 213 | 213 | manifest_file_rewind(pM); |
| 214 | 214 | while( (pFile = manifest_file_next(pM,0))!=0 ){ |
| 215 | - if( nD>0 && memcmp(pFile->zName, zD, nD-1)!=0 ) continue; | |
| 215 | + if( nD>0 | |
| 216 | + && (memcmp(pFile->zName, zD, nD-1)!=0 || pFile->zName[nD-1]!='/') | |
| 217 | + ){ | |
| 218 | + continue; | |
| 219 | + } | |
| 216 | 220 | if( pPrev |
| 217 | 221 | && memcmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0 |
| 218 | 222 | && (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/') |
| 219 | 223 | ){ |
| 220 | 224 | continue; |
| @@ -263,11 +267,11 @@ | ||
| 263 | 267 | if( zFN[0]=='/' ){ |
| 264 | 268 | zFN++; |
| 265 | 269 | @ <li><a href="%s(zSubdirLink)%T(zFN)">%h(zFN)/</a></li> |
| 266 | 270 | }else if( zCI ){ |
| 267 | 271 | const char *zUuid = db_column_text(&q, 1); |
| 268 | - @ <li><a href="%s(g.zTop)/artifact?name=%s(zUuid)">%h(zFN)</a></li> | |
| 272 | + @ <li><a href="%s(g.zTop)/artifact/%s(zUuid)">%h(zFN)</a></li> | |
| 269 | 273 | }else{ |
| 270 | 274 | @ <li><a href="%s(g.zTop)/finfo?name=%T(zPrefix)%T(zFN)">%h(zFN) |
| 271 | 275 | @ </a></li> |
| 272 | 276 | } |
| 273 | 277 | } |
| 274 | 278 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -146,11 +146,11 @@ | |
| 146 | /* Compute the title of the page */ |
| 147 | blob_zero(&dirname); |
| 148 | if( zD ){ |
| 149 | blob_append(&dirname, "in directory ", -1); |
| 150 | hyperlinked_path(zD, &dirname, zCI); |
| 151 | zPrefix = mprintf("%h/", zD); |
| 152 | }else{ |
| 153 | blob_append(&dirname, "in the top-level directory", -1); |
| 154 | zPrefix = ""; |
| 155 | } |
| 156 | if( zCI ){ |
| @@ -210,11 +210,15 @@ | |
| 210 | db_prepare(&ins, |
| 211 | "INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,0), :u)" |
| 212 | ); |
| 213 | manifest_file_rewind(pM); |
| 214 | while( (pFile = manifest_file_next(pM,0))!=0 ){ |
| 215 | if( nD>0 && memcmp(pFile->zName, zD, nD-1)!=0 ) continue; |
| 216 | if( pPrev |
| 217 | && memcmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0 |
| 218 | && (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/') |
| 219 | ){ |
| 220 | continue; |
| @@ -263,11 +267,11 @@ | |
| 263 | if( zFN[0]=='/' ){ |
| 264 | zFN++; |
| 265 | @ <li><a href="%s(zSubdirLink)%T(zFN)">%h(zFN)/</a></li> |
| 266 | }else if( zCI ){ |
| 267 | const char *zUuid = db_column_text(&q, 1); |
| 268 | @ <li><a href="%s(g.zTop)/artifact?name=%s(zUuid)">%h(zFN)</a></li> |
| 269 | }else{ |
| 270 | @ <li><a href="%s(g.zTop)/finfo?name=%T(zPrefix)%T(zFN)">%h(zFN) |
| 271 | @ </a></li> |
| 272 | } |
| 273 | } |
| 274 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -146,11 +146,11 @@ | |
| 146 | /* Compute the title of the page */ |
| 147 | blob_zero(&dirname); |
| 148 | if( zD ){ |
| 149 | blob_append(&dirname, "in directory ", -1); |
| 150 | hyperlinked_path(zD, &dirname, zCI); |
| 151 | zPrefix = mprintf("%s/", zD); |
| 152 | }else{ |
| 153 | blob_append(&dirname, "in the top-level directory", -1); |
| 154 | zPrefix = ""; |
| 155 | } |
| 156 | if( zCI ){ |
| @@ -210,11 +210,15 @@ | |
| 210 | db_prepare(&ins, |
| 211 | "INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,0), :u)" |
| 212 | ); |
| 213 | manifest_file_rewind(pM); |
| 214 | while( (pFile = manifest_file_next(pM,0))!=0 ){ |
| 215 | if( nD>0 |
| 216 | && (memcmp(pFile->zName, zD, nD-1)!=0 || pFile->zName[nD-1]!='/') |
| 217 | ){ |
| 218 | continue; |
| 219 | } |
| 220 | if( pPrev |
| 221 | && memcmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0 |
| 222 | && (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/') |
| 223 | ){ |
| 224 | continue; |
| @@ -263,11 +267,11 @@ | |
| 267 | if( zFN[0]=='/' ){ |
| 268 | zFN++; |
| 269 | @ <li><a href="%s(zSubdirLink)%T(zFN)">%h(zFN)/</a></li> |
| 270 | }else if( zCI ){ |
| 271 | const char *zUuid = db_column_text(&q, 1); |
| 272 | @ <li><a href="%s(g.zTop)/artifact/%s(zUuid)">%h(zFN)</a></li> |
| 273 | }else{ |
| 274 | @ <li><a href="%s(g.zTop)/finfo?name=%T(zPrefix)%T(zFN)">%h(zFN) |
| 275 | @ </a></li> |
| 276 | } |
| 277 | } |
| 278 |
+1
-1
| --- src/captcha.c | ||
| +++ src/captcha.c | ||
| @@ -392,11 +392,11 @@ | ||
| 392 | 392 | for(i=2; i<g.argc; i++){ |
| 393 | 393 | char zHex[30]; |
| 394 | 394 | v = (unsigned int)atoi(g.argv[i]); |
| 395 | 395 | sqlite3_snprintf(sizeof(zHex), zHex, "%x", v); |
| 396 | 396 | z = captcha_render(zHex); |
| 397 | - printf("%s:\n%s", zHex, z); | |
| 397 | + fossil_print("%s:\n%s", zHex, z); | |
| 398 | 398 | free(z); |
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /* |
| 403 | 403 |
| --- src/captcha.c | |
| +++ src/captcha.c | |
| @@ -392,11 +392,11 @@ | |
| 392 | for(i=2; i<g.argc; i++){ |
| 393 | char zHex[30]; |
| 394 | v = (unsigned int)atoi(g.argv[i]); |
| 395 | sqlite3_snprintf(sizeof(zHex), zHex, "%x", v); |
| 396 | z = captcha_render(zHex); |
| 397 | printf("%s:\n%s", zHex, z); |
| 398 | free(z); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | /* |
| 403 |
| --- src/captcha.c | |
| +++ src/captcha.c | |
| @@ -392,11 +392,11 @@ | |
| 392 | for(i=2; i<g.argc; i++){ |
| 393 | char zHex[30]; |
| 394 | v = (unsigned int)atoi(g.argv[i]); |
| 395 | sqlite3_snprintf(sizeof(zHex), zHex, "%x", v); |
| 396 | z = captcha_render(zHex); |
| 397 | fossil_print("%s:\n%s", zHex, z); |
| 398 | free(z); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | /* |
| 403 |
+85
-33
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -2,11 +2,11 @@ | ||
| 2 | 2 | ** Copyright (c) 2006 D. Richard Hipp |
| 3 | 3 | ** |
| 4 | 4 | ** This program is free software; you can redistribute it and/or |
| 5 | 5 | ** modify it under the terms of the Simplified BSD License (also |
| 6 | 6 | ** known as the "2-Clause License" or "FreeBSD License".) |
| 7 | - | |
| 7 | +** | |
| 8 | 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | 9 | ** but without any warranty; without even the implied warranty of |
| 10 | 10 | ** merchantability or fitness for a particular purpose. |
| 11 | 11 | ** |
| 12 | 12 | ** Author contact information: |
| @@ -55,12 +55,12 @@ | ||
| 55 | 55 | ** or cookie "x", or NULL if there is no such parameter or cookie. PD("x","y") |
| 56 | 56 | ** does the same except "y" is returned in place of NULL if there is not match. |
| 57 | 57 | */ |
| 58 | 58 | #define P(x) cgi_parameter((x),0) |
| 59 | 59 | #define PD(x,y) cgi_parameter((x),(y)) |
| 60 | -#define QP(x) quotable_string(cgi_parameter((x),0)) | |
| 61 | -#define QPD(x,y) quotable_string(cgi_parameter((x),(y))) | |
| 60 | +#define PT(x) cgi_parameter_trimmed((x),0) | |
| 61 | +#define PDT(x,y) cgi_parameter_trimmed((x),(y)) | |
| 62 | 62 | |
| 63 | 63 | |
| 64 | 64 | /* |
| 65 | 65 | ** Destinations for output text. |
| 66 | 66 | */ |
| @@ -191,20 +191,24 @@ | ||
| 191 | 191 | const char *zName, /* Name of the cookie */ |
| 192 | 192 | const char *zValue, /* Value of the cookie. Automatically escaped */ |
| 193 | 193 | const char *zPath, /* Path cookie applies to. NULL means "/" */ |
| 194 | 194 | int lifetime /* Expiration of the cookie in seconds from now */ |
| 195 | 195 | ){ |
| 196 | + char *zSecure = ""; | |
| 196 | 197 | if( zPath==0 ) zPath = g.zTop; |
| 198 | + if( g.zBaseURL!=0 && strncmp(g.zBaseURL, "https:", 6)==0 ){ | |
| 199 | + zSecure = " secure;"; | |
| 200 | + } | |
| 197 | 201 | if( lifetime>0 ){ |
| 198 | 202 | lifetime += (int)time(0); |
| 199 | 203 | blob_appendf(&extraHeader, |
| 200 | - "Set-Cookie: %s=%t; Path=%s; expires=%z; Version=1\r\n", | |
| 201 | - zName, zValue, zPath, cgi_rfc822_datestamp(lifetime)); | |
| 204 | + "Set-Cookie: %s=%t; Path=%s; expires=%z; HttpOnly;%s Version=1\r\n", | |
| 205 | + zName, zValue, zPath, cgi_rfc822_datestamp(lifetime), zSecure); | |
| 202 | 206 | }else{ |
| 203 | 207 | blob_appendf(&extraHeader, |
| 204 | - "Set-Cookie: %s=%t; Path=%s; Version=1\r\n", | |
| 205 | - zName, zValue, zPath); | |
| 208 | + "Set-Cookie: %s=%t; Path=%s; HttpOnly;%s Version=1\r\n", | |
| 209 | + zName, zValue, zPath, zSecure); | |
| 206 | 210 | } |
| 207 | 211 | } |
| 208 | 212 | |
| 209 | 213 | #if 0 |
| 210 | 214 | /* |
| @@ -289,10 +293,28 @@ | ||
| 289 | 293 | } |
| 290 | 294 | |
| 291 | 295 | if( blob_size(&extraHeader)>0 ){ |
| 292 | 296 | fprintf(g.httpOut, "%s", blob_buffer(&extraHeader)); |
| 293 | 297 | } |
| 298 | + | |
| 299 | + /* Add headers to turn on useful security options in browsers. */ | |
| 300 | + fprintf(g.httpOut, "X-Frame-Options: SAMEORIGIN\r\n"); | |
| 301 | + /* This stops fossil pages appearing in frames or iframes, preventing | |
| 302 | + ** click-jacking attacks on supporting browsers. | |
| 303 | + ** | |
| 304 | + ** Other good headers would be | |
| 305 | + ** Strict-Transport-Security: max-age=62208000 | |
| 306 | + ** if we're using https. However, this would break sites which serve different | |
| 307 | + ** content on http and https protocols. Also, | |
| 308 | + ** X-Content-Security-Policy: allow 'self' | |
| 309 | + ** would help mitigate some XSS and data injection attacks, but will break | |
| 310 | + ** deliberate inclusion of external resources, such as JavaScript syntax | |
| 311 | + ** highlighter scripts. | |
| 312 | + ** | |
| 313 | + ** These headers are probably best added by the web server hosting fossil as | |
| 314 | + ** a CGI script. | |
| 315 | + */ | |
| 294 | 316 | |
| 295 | 317 | if( g.isConst ){ |
| 296 | 318 | /* constant means that the input URL will _never_ generate anything |
| 297 | 319 | ** else. In the case of attachments, the contents won't change because |
| 298 | 320 | ** an attempt to change them generates a new attachment number. In the |
| @@ -310,11 +332,11 @@ | ||
| 310 | 332 | |
| 311 | 333 | /* Content intended for logged in users should only be cached in |
| 312 | 334 | ** the browser, not some shared location. |
| 313 | 335 | */ |
| 314 | 336 | fprintf(g.httpOut, "Content-Type: %s; charset=utf-8\r\n", zContentType); |
| 315 | - if( strcmp(zContentType,"application/x-fossil")==0 ){ | |
| 337 | + if( fossil_strcmp(zContentType,"application/x-fossil")==0 ){ | |
| 316 | 338 | cgi_combine_header_and_body(); |
| 317 | 339 | blob_compress(&cgiContent[0], &cgiContent[0]); |
| 318 | 340 | } |
| 319 | 341 | |
| 320 | 342 | if( iReplyStatus != 304 ) { |
| @@ -331,10 +353,11 @@ | ||
| 331 | 353 | if( size>0 ){ |
| 332 | 354 | fwrite(blob_buffer(&cgiContent[i]), 1, size, g.httpOut); |
| 333 | 355 | } |
| 334 | 356 | } |
| 335 | 357 | } |
| 358 | + fflush(g.httpOut); | |
| 336 | 359 | CGIDEBUG(("DONE\n")); |
| 337 | 360 | } |
| 338 | 361 | |
| 339 | 362 | /* |
| 340 | 363 | ** Do a redirect request to the URL given in the argument. |
| @@ -342,18 +365,21 @@ | ||
| 342 | 365 | ** The URL must be relative to the base of the fossil server. |
| 343 | 366 | */ |
| 344 | 367 | void cgi_redirect(const char *zURL){ |
| 345 | 368 | char *zLocation; |
| 346 | 369 | CGIDEBUG(("redirect to %s\n", zURL)); |
| 347 | - if( strncmp(zURL,"http:",5)==0 || strncmp(zURL,"https:",6)==0 || *zURL=='/' ){ | |
| 370 | + if( strncmp(zURL,"http:",5)==0 || strncmp(zURL,"https:",6)==0 ){ | |
| 348 | 371 | zLocation = mprintf("Location: %s\r\n", zURL); |
| 372 | + }else if( *zURL=='/' ){ | |
| 373 | + zLocation = mprintf("Location: %.*s%s\r\n", | |
| 374 | + strlen(g.zBaseURL)-strlen(g.zTop), g.zBaseURL, zURL); | |
| 349 | 375 | }else{ |
| 350 | - zLocation = mprintf("Location: %s/%s\r\n", g.zTop, zURL); | |
| 376 | + zLocation = mprintf("Location: %s/%s\r\n", g.zBaseURL, zURL); | |
| 351 | 377 | } |
| 352 | 378 | cgi_append_header(zLocation); |
| 353 | 379 | cgi_reset_content(); |
| 354 | - cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL); | |
| 380 | + cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zLocation); | |
| 355 | 381 | cgi_set_status(302, "Moved Temporarily"); |
| 356 | 382 | free(zLocation); |
| 357 | 383 | cgi_reply(); |
| 358 | 384 | fossil_exit(0); |
| 359 | 385 | } |
| @@ -416,11 +442,11 @@ | ||
| 416 | 442 | ** Replace a parameter with a new value. |
| 417 | 443 | */ |
| 418 | 444 | void cgi_replace_parameter(const char *zName, const char *zValue){ |
| 419 | 445 | int i; |
| 420 | 446 | for(i=0; i<nUsedQP; i++){ |
| 421 | - if( strcmp(aParamQP[i].zName,zName)==0 ){ | |
| 447 | + if( fossil_strcmp(aParamQP[i].zName,zName)==0 ){ | |
| 422 | 448 | aParamQP[i].zValue = zValue; |
| 423 | 449 | return; |
| 424 | 450 | } |
| 425 | 451 | } |
| 426 | 452 | cgi_set_parameter_nocopy(zName, zValue); |
| @@ -678,26 +704,26 @@ | ||
| 678 | 704 | |
| 679 | 705 | len = atoi(PD("CONTENT_LENGTH", "0")); |
| 680 | 706 | g.zContentType = zType = P("CONTENT_TYPE"); |
| 681 | 707 | if( len>0 && zType ){ |
| 682 | 708 | blob_zero(&g.cgiIn); |
| 683 | - if( strcmp(zType,"application/x-www-form-urlencoded")==0 | |
| 709 | + if( fossil_strcmp(zType,"application/x-www-form-urlencoded")==0 | |
| 684 | 710 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 685 | 711 | z = fossil_malloc( len+1 ); |
| 686 | 712 | len = fread(z, 1, len, g.httpIn); |
| 687 | 713 | z[len] = 0; |
| 688 | 714 | if( zType[0]=='a' ){ |
| 689 | 715 | add_param_list(z, '&'); |
| 690 | 716 | }else{ |
| 691 | 717 | process_multipart_form_data(z, len); |
| 692 | 718 | } |
| 693 | - }else if( strcmp(zType, "application/x-fossil")==0 ){ | |
| 719 | + }else if( fossil_strcmp(zType, "application/x-fossil")==0 ){ | |
| 694 | 720 | blob_read_from_channel(&g.cgiIn, g.httpIn, len); |
| 695 | 721 | blob_uncompress(&g.cgiIn, &g.cgiIn); |
| 696 | - }else if( strcmp(zType, "application/x-fossil-debug")==0 ){ | |
| 722 | + }else if( fossil_strcmp(zType, "application/x-fossil-debug")==0 ){ | |
| 697 | 723 | blob_read_from_channel(&g.cgiIn, g.httpIn, len); |
| 698 | - }else if( strcmp(zType, "application/x-fossil-uncompressed")==0 ){ | |
| 724 | + }else if( fossil_strcmp(zType, "application/x-fossil-uncompressed")==0 ){ | |
| 699 | 725 | blob_read_from_channel(&g.cgiIn, g.httpIn, len); |
| 700 | 726 | } |
| 701 | 727 | } |
| 702 | 728 | |
| 703 | 729 | z = (char*)P("HTTP_COOKIE"); |
| @@ -713,11 +739,11 @@ | ||
| 713 | 739 | */ |
| 714 | 740 | static int qparam_compare(const void *a, const void *b){ |
| 715 | 741 | struct QParam *pA = (struct QParam*)a; |
| 716 | 742 | struct QParam *pB = (struct QParam*)b; |
| 717 | 743 | int c; |
| 718 | - c = strcmp(pA->zName, pB->zName); | |
| 744 | + c = fossil_strcmp(pA->zName, pB->zName); | |
| 719 | 745 | if( c==0 ){ |
| 720 | 746 | c = pA->seq - pB->seq; |
| 721 | 747 | } |
| 722 | 748 | return c; |
| 723 | 749 | } |
| @@ -742,11 +768,11 @@ | ||
| 742 | 768 | /* After sorting, remove duplicate parameters. The secondary sort |
| 743 | 769 | ** key is aParamQP[].seq and we keep the first entry. That means |
| 744 | 770 | ** with duplicate calls to cgi_set_parameter() the second and |
| 745 | 771 | ** subsequent calls are effectively no-ops. */ |
| 746 | 772 | for(i=j=1; i<nUsedQP; i++){ |
| 747 | - if( strcmp(aParamQP[i].zName,aParamQP[i-1].zName)==0 ){ | |
| 773 | + if( fossil_strcmp(aParamQP[i].zName,aParamQP[i-1].zName)==0 ){ | |
| 748 | 774 | continue; |
| 749 | 775 | } |
| 750 | 776 | if( j<i ){ |
| 751 | 777 | memcpy(&aParamQP[j], &aParamQP[i], sizeof(aParamQP[j])); |
| 752 | 778 | } |
| @@ -758,11 +784,11 @@ | ||
| 758 | 784 | /* Do a binary search for a matching query parameter */ |
| 759 | 785 | lo = 0; |
| 760 | 786 | hi = nUsedQP-1; |
| 761 | 787 | while( lo<=hi ){ |
| 762 | 788 | mid = (lo+hi)/2; |
| 763 | - c = strcmp(aParamQP[mid].zName, zName); | |
| 789 | + c = fossil_strcmp(aParamQP[mid].zName, zName); | |
| 764 | 790 | if( c==0 ){ |
| 765 | 791 | CGIDEBUG(("mem-match [%s] = [%s]\n", zName, aParamQP[mid].zValue)); |
| 766 | 792 | return aParamQP[mid].zValue; |
| 767 | 793 | }else if( c>0 ){ |
| 768 | 794 | hi = mid-1; |
| @@ -784,10 +810,27 @@ | ||
| 784 | 810 | } |
| 785 | 811 | } |
| 786 | 812 | CGIDEBUG(("no-match [%s]\n", zName)); |
| 787 | 813 | return zDefault; |
| 788 | 814 | } |
| 815 | + | |
| 816 | +/* | |
| 817 | +** Return the value of a CGI parameter with leading and trailing | |
| 818 | +** spaces removed. | |
| 819 | +*/ | |
| 820 | +char *cgi_parameter_trimmed(const char *zName, const char *zDefault){ | |
| 821 | + const char *zIn; | |
| 822 | + char *zOut; | |
| 823 | + int i; | |
| 824 | + zIn = cgi_parameter(zName, 0); | |
| 825 | + if( zIn==0 ) zIn = zDefault; | |
| 826 | + while( fossil_isspace(zIn[0]) ) zIn++; | |
| 827 | + zOut = fossil_strdup(zIn); | |
| 828 | + for(i=0; zOut[i]; i++){} | |
| 829 | + while( i>0 && fossil_isspace(zOut[i-1]) ) zOut[--i] = 0; | |
| 830 | + return zOut; | |
| 831 | +} | |
| 789 | 832 | |
| 790 | 833 | /* |
| 791 | 834 | ** Return the name of the i-th CGI parameter. Return NULL if there |
| 792 | 835 | ** are fewer than i registered CGI parmaeters. |
| 793 | 836 | */ |
| @@ -845,17 +888,26 @@ | ||
| 845 | 888 | } |
| 846 | 889 | |
| 847 | 890 | /* |
| 848 | 891 | ** Print all query parameters on standard output. Format the |
| 849 | 892 | ** parameters as HTML. This is used for testing and debugging. |
| 893 | +** Release builds omit the values of the cookies to avoid defeating | |
| 894 | +** the purpose of setting HttpOnly cookies. | |
| 850 | 895 | */ |
| 851 | 896 | void cgi_print_all(void){ |
| 852 | 897 | int i; |
| 898 | + int showAll = 0; | |
| 899 | +#ifdef FOSSIL_DEBUG | |
| 900 | + /* Show the values of cookies in debug mode. */ | |
| 901 | + showAll = 1; | |
| 902 | +#endif | |
| 853 | 903 | cgi_parameter("",""); /* Force the parameters into sorted order */ |
| 854 | 904 | for(i=0; i<nUsedQP; i++){ |
| 855 | - cgi_printf("%s = %s <br />\n", | |
| 856 | - htmlize(aParamQP[i].zName, -1), htmlize(aParamQP[i].zValue, -1)); | |
| 905 | + if( showAll || (fossil_stricmp("HTTP_COOKIE",aParamQP[i].zName)!=0 && fossil_strnicmp("fossil-",aParamQP[i].zName,7)!=0) ){ | |
| 906 | + cgi_printf("%s = %s <br />\n", | |
| 907 | + htmlize(aParamQP[i].zName, -1), htmlize(aParamQP[i].zValue, -1)); | |
| 908 | + } | |
| 857 | 909 | } |
| 858 | 910 | } |
| 859 | 911 | |
| 860 | 912 | /* |
| 861 | 913 | ** This routine works like "printf" except that it has the |
| @@ -952,12 +1004,12 @@ | ||
| 952 | 1004 | } |
| 953 | 1005 | zToken = extract_token(zLine, &z); |
| 954 | 1006 | if( zToken==0 ){ |
| 955 | 1007 | malformed_request(); |
| 956 | 1008 | } |
| 957 | - if( strcmp(zToken,"GET")!=0 && strcmp(zToken,"POST")!=0 | |
| 958 | - && strcmp(zToken,"HEAD")!=0 ){ | |
| 1009 | + if( fossil_strcmp(zToken,"GET")!=0 && fossil_strcmp(zToken,"POST")!=0 | |
| 1010 | + && fossil_strcmp(zToken,"HEAD")!=0 ){ | |
| 959 | 1011 | malformed_request(); |
| 960 | 1012 | } |
| 961 | 1013 | cgi_setenv("GATEWAY_INTERFACE","CGI/1.0"); |
| 962 | 1014 | cgi_setenv("REQUEST_METHOD",zToken); |
| 963 | 1015 | zToken = extract_token(z, &z); |
| @@ -993,29 +1045,29 @@ | ||
| 993 | 1045 | while( i>0 && fossil_isspace(zVal[i-1]) ){ i--; } |
| 994 | 1046 | zVal[i] = 0; |
| 995 | 1047 | for(i=0; zFieldName[i]; i++){ |
| 996 | 1048 | zFieldName[i] = fossil_tolower(zFieldName[i]); |
| 997 | 1049 | } |
| 998 | - if( strcmp(zFieldName,"content-length:")==0 ){ | |
| 1050 | + if( fossil_strcmp(zFieldName,"content-length:")==0 ){ | |
| 999 | 1051 | cgi_setenv("CONTENT_LENGTH", zVal); |
| 1000 | - }else if( strcmp(zFieldName,"content-type:")==0 ){ | |
| 1052 | + }else if( fossil_strcmp(zFieldName,"content-type:")==0 ){ | |
| 1001 | 1053 | cgi_setenv("CONTENT_TYPE", zVal); |
| 1002 | - }else if( strcmp(zFieldName,"cookie:")==0 ){ | |
| 1054 | + }else if( fossil_strcmp(zFieldName,"cookie:")==0 ){ | |
| 1003 | 1055 | cgi_setenv("HTTP_COOKIE", zVal); |
| 1004 | - }else if( strcmp(zFieldName,"https:")==0 ){ | |
| 1056 | + }else if( fossil_strcmp(zFieldName,"https:")==0 ){ | |
| 1005 | 1057 | cgi_setenv("HTTPS", zVal); |
| 1006 | - }else if( strcmp(zFieldName,"host:")==0 ){ | |
| 1058 | + }else if( fossil_strcmp(zFieldName,"host:")==0 ){ | |
| 1007 | 1059 | cgi_setenv("HTTP_HOST", zVal); |
| 1008 | - }else if( strcmp(zFieldName,"if-none-match:")==0 ){ | |
| 1060 | + }else if( fossil_strcmp(zFieldName,"if-none-match:")==0 ){ | |
| 1009 | 1061 | cgi_setenv("HTTP_IF_NONE_MATCH", zVal); |
| 1010 | - }else if( strcmp(zFieldName,"if-modified-since:")==0 ){ | |
| 1062 | + }else if( fossil_strcmp(zFieldName,"if-modified-since:")==0 ){ | |
| 1011 | 1063 | cgi_setenv("HTTP_IF_MODIFIED_SINCE", zVal); |
| 1012 | 1064 | } |
| 1013 | 1065 | #if 0 |
| 1014 | - else if( strcmp(zFieldName,"referer:")==0 ){ | |
| 1066 | + else if( fossil_strcmp(zFieldName,"referer:")==0 ){ | |
| 1015 | 1067 | cgi_setenv("HTTP_REFERER", zVal); |
| 1016 | - }else if( strcmp(zFieldName,"user-agent:")==0 ){ | |
| 1068 | + }else if( fossil_strcmp(zFieldName,"user-agent:")==0 ){ | |
| 1017 | 1069 | cgi_setenv("HTTP_USER_AGENT", zVal); |
| 1018 | 1070 | } |
| 1019 | 1071 | #endif |
| 1020 | 1072 | } |
| 1021 | 1073 | |
| @@ -1096,11 +1148,11 @@ | ||
| 1096 | 1148 | } |
| 1097 | 1149 | } |
| 1098 | 1150 | if( iPort>mxPort ) return 1; |
| 1099 | 1151 | listen(listener,10); |
| 1100 | 1152 | if( iPort>mnPort ){ |
| 1101 | - printf("Listening for HTTP requests on TCP port %d\n", iPort); | |
| 1153 | + fossil_print("Listening for HTTP requests on TCP port %d\n", iPort); | |
| 1102 | 1154 | fflush(stdout); |
| 1103 | 1155 | } |
| 1104 | 1156 | if( zBrowser ){ |
| 1105 | 1157 | zBrowser = mprintf(zBrowser, iPort); |
| 1106 | 1158 | system(zBrowser); |
| 1107 | 1159 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -2,11 +2,11 @@ | |
| 2 | ** Copyright (c) 2006 D. Richard Hipp |
| 3 | ** |
| 4 | ** This program is free software; you can redistribute it and/or |
| 5 | ** modify it under the terms of the Simplified BSD License (also |
| 6 | ** known as the "2-Clause License" or "FreeBSD License".) |
| 7 | |
| 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | ** but without any warranty; without even the implied warranty of |
| 10 | ** merchantability or fitness for a particular purpose. |
| 11 | ** |
| 12 | ** Author contact information: |
| @@ -55,12 +55,12 @@ | |
| 55 | ** or cookie "x", or NULL if there is no such parameter or cookie. PD("x","y") |
| 56 | ** does the same except "y" is returned in place of NULL if there is not match. |
| 57 | */ |
| 58 | #define P(x) cgi_parameter((x),0) |
| 59 | #define PD(x,y) cgi_parameter((x),(y)) |
| 60 | #define QP(x) quotable_string(cgi_parameter((x),0)) |
| 61 | #define QPD(x,y) quotable_string(cgi_parameter((x),(y))) |
| 62 | |
| 63 | |
| 64 | /* |
| 65 | ** Destinations for output text. |
| 66 | */ |
| @@ -191,20 +191,24 @@ | |
| 191 | const char *zName, /* Name of the cookie */ |
| 192 | const char *zValue, /* Value of the cookie. Automatically escaped */ |
| 193 | const char *zPath, /* Path cookie applies to. NULL means "/" */ |
| 194 | int lifetime /* Expiration of the cookie in seconds from now */ |
| 195 | ){ |
| 196 | if( zPath==0 ) zPath = g.zTop; |
| 197 | if( lifetime>0 ){ |
| 198 | lifetime += (int)time(0); |
| 199 | blob_appendf(&extraHeader, |
| 200 | "Set-Cookie: %s=%t; Path=%s; expires=%z; Version=1\r\n", |
| 201 | zName, zValue, zPath, cgi_rfc822_datestamp(lifetime)); |
| 202 | }else{ |
| 203 | blob_appendf(&extraHeader, |
| 204 | "Set-Cookie: %s=%t; Path=%s; Version=1\r\n", |
| 205 | zName, zValue, zPath); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | #if 0 |
| 210 | /* |
| @@ -289,10 +293,28 @@ | |
| 289 | } |
| 290 | |
| 291 | if( blob_size(&extraHeader)>0 ){ |
| 292 | fprintf(g.httpOut, "%s", blob_buffer(&extraHeader)); |
| 293 | } |
| 294 | |
| 295 | if( g.isConst ){ |
| 296 | /* constant means that the input URL will _never_ generate anything |
| 297 | ** else. In the case of attachments, the contents won't change because |
| 298 | ** an attempt to change them generates a new attachment number. In the |
| @@ -310,11 +332,11 @@ | |
| 310 | |
| 311 | /* Content intended for logged in users should only be cached in |
| 312 | ** the browser, not some shared location. |
| 313 | */ |
| 314 | fprintf(g.httpOut, "Content-Type: %s; charset=utf-8\r\n", zContentType); |
| 315 | if( strcmp(zContentType,"application/x-fossil")==0 ){ |
| 316 | cgi_combine_header_and_body(); |
| 317 | blob_compress(&cgiContent[0], &cgiContent[0]); |
| 318 | } |
| 319 | |
| 320 | if( iReplyStatus != 304 ) { |
| @@ -331,10 +353,11 @@ | |
| 331 | if( size>0 ){ |
| 332 | fwrite(blob_buffer(&cgiContent[i]), 1, size, g.httpOut); |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | CGIDEBUG(("DONE\n")); |
| 337 | } |
| 338 | |
| 339 | /* |
| 340 | ** Do a redirect request to the URL given in the argument. |
| @@ -342,18 +365,21 @@ | |
| 342 | ** The URL must be relative to the base of the fossil server. |
| 343 | */ |
| 344 | void cgi_redirect(const char *zURL){ |
| 345 | char *zLocation; |
| 346 | CGIDEBUG(("redirect to %s\n", zURL)); |
| 347 | if( strncmp(zURL,"http:",5)==0 || strncmp(zURL,"https:",6)==0 || *zURL=='/' ){ |
| 348 | zLocation = mprintf("Location: %s\r\n", zURL); |
| 349 | }else{ |
| 350 | zLocation = mprintf("Location: %s/%s\r\n", g.zTop, zURL); |
| 351 | } |
| 352 | cgi_append_header(zLocation); |
| 353 | cgi_reset_content(); |
| 354 | cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL); |
| 355 | cgi_set_status(302, "Moved Temporarily"); |
| 356 | free(zLocation); |
| 357 | cgi_reply(); |
| 358 | fossil_exit(0); |
| 359 | } |
| @@ -416,11 +442,11 @@ | |
| 416 | ** Replace a parameter with a new value. |
| 417 | */ |
| 418 | void cgi_replace_parameter(const char *zName, const char *zValue){ |
| 419 | int i; |
| 420 | for(i=0; i<nUsedQP; i++){ |
| 421 | if( strcmp(aParamQP[i].zName,zName)==0 ){ |
| 422 | aParamQP[i].zValue = zValue; |
| 423 | return; |
| 424 | } |
| 425 | } |
| 426 | cgi_set_parameter_nocopy(zName, zValue); |
| @@ -678,26 +704,26 @@ | |
| 678 | |
| 679 | len = atoi(PD("CONTENT_LENGTH", "0")); |
| 680 | g.zContentType = zType = P("CONTENT_TYPE"); |
| 681 | if( len>0 && zType ){ |
| 682 | blob_zero(&g.cgiIn); |
| 683 | if( strcmp(zType,"application/x-www-form-urlencoded")==0 |
| 684 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 685 | z = fossil_malloc( len+1 ); |
| 686 | len = fread(z, 1, len, g.httpIn); |
| 687 | z[len] = 0; |
| 688 | if( zType[0]=='a' ){ |
| 689 | add_param_list(z, '&'); |
| 690 | }else{ |
| 691 | process_multipart_form_data(z, len); |
| 692 | } |
| 693 | }else if( strcmp(zType, "application/x-fossil")==0 ){ |
| 694 | blob_read_from_channel(&g.cgiIn, g.httpIn, len); |
| 695 | blob_uncompress(&g.cgiIn, &g.cgiIn); |
| 696 | }else if( strcmp(zType, "application/x-fossil-debug")==0 ){ |
| 697 | blob_read_from_channel(&g.cgiIn, g.httpIn, len); |
| 698 | }else if( strcmp(zType, "application/x-fossil-uncompressed")==0 ){ |
| 699 | blob_read_from_channel(&g.cgiIn, g.httpIn, len); |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | z = (char*)P("HTTP_COOKIE"); |
| @@ -713,11 +739,11 @@ | |
| 713 | */ |
| 714 | static int qparam_compare(const void *a, const void *b){ |
| 715 | struct QParam *pA = (struct QParam*)a; |
| 716 | struct QParam *pB = (struct QParam*)b; |
| 717 | int c; |
| 718 | c = strcmp(pA->zName, pB->zName); |
| 719 | if( c==0 ){ |
| 720 | c = pA->seq - pB->seq; |
| 721 | } |
| 722 | return c; |
| 723 | } |
| @@ -742,11 +768,11 @@ | |
| 742 | /* After sorting, remove duplicate parameters. The secondary sort |
| 743 | ** key is aParamQP[].seq and we keep the first entry. That means |
| 744 | ** with duplicate calls to cgi_set_parameter() the second and |
| 745 | ** subsequent calls are effectively no-ops. */ |
| 746 | for(i=j=1; i<nUsedQP; i++){ |
| 747 | if( strcmp(aParamQP[i].zName,aParamQP[i-1].zName)==0 ){ |
| 748 | continue; |
| 749 | } |
| 750 | if( j<i ){ |
| 751 | memcpy(&aParamQP[j], &aParamQP[i], sizeof(aParamQP[j])); |
| 752 | } |
| @@ -758,11 +784,11 @@ | |
| 758 | /* Do a binary search for a matching query parameter */ |
| 759 | lo = 0; |
| 760 | hi = nUsedQP-1; |
| 761 | while( lo<=hi ){ |
| 762 | mid = (lo+hi)/2; |
| 763 | c = strcmp(aParamQP[mid].zName, zName); |
| 764 | if( c==0 ){ |
| 765 | CGIDEBUG(("mem-match [%s] = [%s]\n", zName, aParamQP[mid].zValue)); |
| 766 | return aParamQP[mid].zValue; |
| 767 | }else if( c>0 ){ |
| 768 | hi = mid-1; |
| @@ -784,10 +810,27 @@ | |
| 784 | } |
| 785 | } |
| 786 | CGIDEBUG(("no-match [%s]\n", zName)); |
| 787 | return zDefault; |
| 788 | } |
| 789 | |
| 790 | /* |
| 791 | ** Return the name of the i-th CGI parameter. Return NULL if there |
| 792 | ** are fewer than i registered CGI parmaeters. |
| 793 | */ |
| @@ -845,17 +888,26 @@ | |
| 845 | } |
| 846 | |
| 847 | /* |
| 848 | ** Print all query parameters on standard output. Format the |
| 849 | ** parameters as HTML. This is used for testing and debugging. |
| 850 | */ |
| 851 | void cgi_print_all(void){ |
| 852 | int i; |
| 853 | cgi_parameter("",""); /* Force the parameters into sorted order */ |
| 854 | for(i=0; i<nUsedQP; i++){ |
| 855 | cgi_printf("%s = %s <br />\n", |
| 856 | htmlize(aParamQP[i].zName, -1), htmlize(aParamQP[i].zValue, -1)); |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | /* |
| 861 | ** This routine works like "printf" except that it has the |
| @@ -952,12 +1004,12 @@ | |
| 952 | } |
| 953 | zToken = extract_token(zLine, &z); |
| 954 | if( zToken==0 ){ |
| 955 | malformed_request(); |
| 956 | } |
| 957 | if( strcmp(zToken,"GET")!=0 && strcmp(zToken,"POST")!=0 |
| 958 | && strcmp(zToken,"HEAD")!=0 ){ |
| 959 | malformed_request(); |
| 960 | } |
| 961 | cgi_setenv("GATEWAY_INTERFACE","CGI/1.0"); |
| 962 | cgi_setenv("REQUEST_METHOD",zToken); |
| 963 | zToken = extract_token(z, &z); |
| @@ -993,29 +1045,29 @@ | |
| 993 | while( i>0 && fossil_isspace(zVal[i-1]) ){ i--; } |
| 994 | zVal[i] = 0; |
| 995 | for(i=0; zFieldName[i]; i++){ |
| 996 | zFieldName[i] = fossil_tolower(zFieldName[i]); |
| 997 | } |
| 998 | if( strcmp(zFieldName,"content-length:")==0 ){ |
| 999 | cgi_setenv("CONTENT_LENGTH", zVal); |
| 1000 | }else if( strcmp(zFieldName,"content-type:")==0 ){ |
| 1001 | cgi_setenv("CONTENT_TYPE", zVal); |
| 1002 | }else if( strcmp(zFieldName,"cookie:")==0 ){ |
| 1003 | cgi_setenv("HTTP_COOKIE", zVal); |
| 1004 | }else if( strcmp(zFieldName,"https:")==0 ){ |
| 1005 | cgi_setenv("HTTPS", zVal); |
| 1006 | }else if( strcmp(zFieldName,"host:")==0 ){ |
| 1007 | cgi_setenv("HTTP_HOST", zVal); |
| 1008 | }else if( strcmp(zFieldName,"if-none-match:")==0 ){ |
| 1009 | cgi_setenv("HTTP_IF_NONE_MATCH", zVal); |
| 1010 | }else if( strcmp(zFieldName,"if-modified-since:")==0 ){ |
| 1011 | cgi_setenv("HTTP_IF_MODIFIED_SINCE", zVal); |
| 1012 | } |
| 1013 | #if 0 |
| 1014 | else if( strcmp(zFieldName,"referer:")==0 ){ |
| 1015 | cgi_setenv("HTTP_REFERER", zVal); |
| 1016 | }else if( strcmp(zFieldName,"user-agent:")==0 ){ |
| 1017 | cgi_setenv("HTTP_USER_AGENT", zVal); |
| 1018 | } |
| 1019 | #endif |
| 1020 | } |
| 1021 | |
| @@ -1096,11 +1148,11 @@ | |
| 1096 | } |
| 1097 | } |
| 1098 | if( iPort>mxPort ) return 1; |
| 1099 | listen(listener,10); |
| 1100 | if( iPort>mnPort ){ |
| 1101 | printf("Listening for HTTP requests on TCP port %d\n", iPort); |
| 1102 | fflush(stdout); |
| 1103 | } |
| 1104 | if( zBrowser ){ |
| 1105 | zBrowser = mprintf(zBrowser, iPort); |
| 1106 | system(zBrowser); |
| 1107 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -2,11 +2,11 @@ | |
| 2 | ** Copyright (c) 2006 D. Richard Hipp |
| 3 | ** |
| 4 | ** This program is free software; you can redistribute it and/or |
| 5 | ** modify it under the terms of the Simplified BSD License (also |
| 6 | ** known as the "2-Clause License" or "FreeBSD License".) |
| 7 | ** |
| 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | ** but without any warranty; without even the implied warranty of |
| 10 | ** merchantability or fitness for a particular purpose. |
| 11 | ** |
| 12 | ** Author contact information: |
| @@ -55,12 +55,12 @@ | |
| 55 | ** or cookie "x", or NULL if there is no such parameter or cookie. PD("x","y") |
| 56 | ** does the same except "y" is returned in place of NULL if there is not match. |
| 57 | */ |
| 58 | #define P(x) cgi_parameter((x),0) |
| 59 | #define PD(x,y) cgi_parameter((x),(y)) |
| 60 | #define PT(x) cgi_parameter_trimmed((x),0) |
| 61 | #define PDT(x,y) cgi_parameter_trimmed((x),(y)) |
| 62 | |
| 63 | |
| 64 | /* |
| 65 | ** Destinations for output text. |
| 66 | */ |
| @@ -191,20 +191,24 @@ | |
| 191 | const char *zName, /* Name of the cookie */ |
| 192 | const char *zValue, /* Value of the cookie. Automatically escaped */ |
| 193 | const char *zPath, /* Path cookie applies to. NULL means "/" */ |
| 194 | int lifetime /* Expiration of the cookie in seconds from now */ |
| 195 | ){ |
| 196 | char *zSecure = ""; |
| 197 | if( zPath==0 ) zPath = g.zTop; |
| 198 | if( g.zBaseURL!=0 && strncmp(g.zBaseURL, "https:", 6)==0 ){ |
| 199 | zSecure = " secure;"; |
| 200 | } |
| 201 | if( lifetime>0 ){ |
| 202 | lifetime += (int)time(0); |
| 203 | blob_appendf(&extraHeader, |
| 204 | "Set-Cookie: %s=%t; Path=%s; expires=%z; HttpOnly;%s Version=1\r\n", |
| 205 | zName, zValue, zPath, cgi_rfc822_datestamp(lifetime), zSecure); |
| 206 | }else{ |
| 207 | blob_appendf(&extraHeader, |
| 208 | "Set-Cookie: %s=%t; Path=%s; HttpOnly;%s Version=1\r\n", |
| 209 | zName, zValue, zPath, zSecure); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | #if 0 |
| 214 | /* |
| @@ -289,10 +293,28 @@ | |
| 293 | } |
| 294 | |
| 295 | if( blob_size(&extraHeader)>0 ){ |
| 296 | fprintf(g.httpOut, "%s", blob_buffer(&extraHeader)); |
| 297 | } |
| 298 | |
| 299 | /* Add headers to turn on useful security options in browsers. */ |
| 300 | fprintf(g.httpOut, "X-Frame-Options: SAMEORIGIN\r\n"); |
| 301 | /* This stops fossil pages appearing in frames or iframes, preventing |
| 302 | ** click-jacking attacks on supporting browsers. |
| 303 | ** |
| 304 | ** Other good headers would be |
| 305 | ** Strict-Transport-Security: max-age=62208000 |
| 306 | ** if we're using https. However, this would break sites which serve different |
| 307 | ** content on http and https protocols. Also, |
| 308 | ** X-Content-Security-Policy: allow 'self' |
| 309 | ** would help mitigate some XSS and data injection attacks, but will break |
| 310 | ** deliberate inclusion of external resources, such as JavaScript syntax |
| 311 | ** highlighter scripts. |
| 312 | ** |
| 313 | ** These headers are probably best added by the web server hosting fossil as |
| 314 | ** a CGI script. |
| 315 | */ |
| 316 | |
| 317 | if( g.isConst ){ |
| 318 | /* constant means that the input URL will _never_ generate anything |
| 319 | ** else. In the case of attachments, the contents won't change because |
| 320 | ** an attempt to change them generates a new attachment number. In the |
| @@ -310,11 +332,11 @@ | |
| 332 | |
| 333 | /* Content intended for logged in users should only be cached in |
| 334 | ** the browser, not some shared location. |
| 335 | */ |
| 336 | fprintf(g.httpOut, "Content-Type: %s; charset=utf-8\r\n", zContentType); |
| 337 | if( fossil_strcmp(zContentType,"application/x-fossil")==0 ){ |
| 338 | cgi_combine_header_and_body(); |
| 339 | blob_compress(&cgiContent[0], &cgiContent[0]); |
| 340 | } |
| 341 | |
| 342 | if( iReplyStatus != 304 ) { |
| @@ -331,10 +353,11 @@ | |
| 353 | if( size>0 ){ |
| 354 | fwrite(blob_buffer(&cgiContent[i]), 1, size, g.httpOut); |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | fflush(g.httpOut); |
| 359 | CGIDEBUG(("DONE\n")); |
| 360 | } |
| 361 | |
| 362 | /* |
| 363 | ** Do a redirect request to the URL given in the argument. |
| @@ -342,18 +365,21 @@ | |
| 365 | ** The URL must be relative to the base of the fossil server. |
| 366 | */ |
| 367 | void cgi_redirect(const char *zURL){ |
| 368 | char *zLocation; |
| 369 | CGIDEBUG(("redirect to %s\n", zURL)); |
| 370 | if( strncmp(zURL,"http:",5)==0 || strncmp(zURL,"https:",6)==0 ){ |
| 371 | zLocation = mprintf("Location: %s\r\n", zURL); |
| 372 | }else if( *zURL=='/' ){ |
| 373 | zLocation = mprintf("Location: %.*s%s\r\n", |
| 374 | strlen(g.zBaseURL)-strlen(g.zTop), g.zBaseURL, zURL); |
| 375 | }else{ |
| 376 | zLocation = mprintf("Location: %s/%s\r\n", g.zBaseURL, zURL); |
| 377 | } |
| 378 | cgi_append_header(zLocation); |
| 379 | cgi_reset_content(); |
| 380 | cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zLocation); |
| 381 | cgi_set_status(302, "Moved Temporarily"); |
| 382 | free(zLocation); |
| 383 | cgi_reply(); |
| 384 | fossil_exit(0); |
| 385 | } |
| @@ -416,11 +442,11 @@ | |
| 442 | ** Replace a parameter with a new value. |
| 443 | */ |
| 444 | void cgi_replace_parameter(const char *zName, const char *zValue){ |
| 445 | int i; |
| 446 | for(i=0; i<nUsedQP; i++){ |
| 447 | if( fossil_strcmp(aParamQP[i].zName,zName)==0 ){ |
| 448 | aParamQP[i].zValue = zValue; |
| 449 | return; |
| 450 | } |
| 451 | } |
| 452 | cgi_set_parameter_nocopy(zName, zValue); |
| @@ -678,26 +704,26 @@ | |
| 704 | |
| 705 | len = atoi(PD("CONTENT_LENGTH", "0")); |
| 706 | g.zContentType = zType = P("CONTENT_TYPE"); |
| 707 | if( len>0 && zType ){ |
| 708 | blob_zero(&g.cgiIn); |
| 709 | if( fossil_strcmp(zType,"application/x-www-form-urlencoded")==0 |
| 710 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 711 | z = fossil_malloc( len+1 ); |
| 712 | len = fread(z, 1, len, g.httpIn); |
| 713 | z[len] = 0; |
| 714 | if( zType[0]=='a' ){ |
| 715 | add_param_list(z, '&'); |
| 716 | }else{ |
| 717 | process_multipart_form_data(z, len); |
| 718 | } |
| 719 | }else if( fossil_strcmp(zType, "application/x-fossil")==0 ){ |
| 720 | blob_read_from_channel(&g.cgiIn, g.httpIn, len); |
| 721 | blob_uncompress(&g.cgiIn, &g.cgiIn); |
| 722 | }else if( fossil_strcmp(zType, "application/x-fossil-debug")==0 ){ |
| 723 | blob_read_from_channel(&g.cgiIn, g.httpIn, len); |
| 724 | }else if( fossil_strcmp(zType, "application/x-fossil-uncompressed")==0 ){ |
| 725 | blob_read_from_channel(&g.cgiIn, g.httpIn, len); |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | z = (char*)P("HTTP_COOKIE"); |
| @@ -713,11 +739,11 @@ | |
| 739 | */ |
| 740 | static int qparam_compare(const void *a, const void *b){ |
| 741 | struct QParam *pA = (struct QParam*)a; |
| 742 | struct QParam *pB = (struct QParam*)b; |
| 743 | int c; |
| 744 | c = fossil_strcmp(pA->zName, pB->zName); |
| 745 | if( c==0 ){ |
| 746 | c = pA->seq - pB->seq; |
| 747 | } |
| 748 | return c; |
| 749 | } |
| @@ -742,11 +768,11 @@ | |
| 768 | /* After sorting, remove duplicate parameters. The secondary sort |
| 769 | ** key is aParamQP[].seq and we keep the first entry. That means |
| 770 | ** with duplicate calls to cgi_set_parameter() the second and |
| 771 | ** subsequent calls are effectively no-ops. */ |
| 772 | for(i=j=1; i<nUsedQP; i++){ |
| 773 | if( fossil_strcmp(aParamQP[i].zName,aParamQP[i-1].zName)==0 ){ |
| 774 | continue; |
| 775 | } |
| 776 | if( j<i ){ |
| 777 | memcpy(&aParamQP[j], &aParamQP[i], sizeof(aParamQP[j])); |
| 778 | } |
| @@ -758,11 +784,11 @@ | |
| 784 | /* Do a binary search for a matching query parameter */ |
| 785 | lo = 0; |
| 786 | hi = nUsedQP-1; |
| 787 | while( lo<=hi ){ |
| 788 | mid = (lo+hi)/2; |
| 789 | c = fossil_strcmp(aParamQP[mid].zName, zName); |
| 790 | if( c==0 ){ |
| 791 | CGIDEBUG(("mem-match [%s] = [%s]\n", zName, aParamQP[mid].zValue)); |
| 792 | return aParamQP[mid].zValue; |
| 793 | }else if( c>0 ){ |
| 794 | hi = mid-1; |
| @@ -784,10 +810,27 @@ | |
| 810 | } |
| 811 | } |
| 812 | CGIDEBUG(("no-match [%s]\n", zName)); |
| 813 | return zDefault; |
| 814 | } |
| 815 | |
| 816 | /* |
| 817 | ** Return the value of a CGI parameter with leading and trailing |
| 818 | ** spaces removed. |
| 819 | */ |
| 820 | char *cgi_parameter_trimmed(const char *zName, const char *zDefault){ |
| 821 | const char *zIn; |
| 822 | char *zOut; |
| 823 | int i; |
| 824 | zIn = cgi_parameter(zName, 0); |
| 825 | if( zIn==0 ) zIn = zDefault; |
| 826 | while( fossil_isspace(zIn[0]) ) zIn++; |
| 827 | zOut = fossil_strdup(zIn); |
| 828 | for(i=0; zOut[i]; i++){} |
| 829 | while( i>0 && fossil_isspace(zOut[i-1]) ) zOut[--i] = 0; |
| 830 | return zOut; |
| 831 | } |
| 832 | |
| 833 | /* |
| 834 | ** Return the name of the i-th CGI parameter. Return NULL if there |
| 835 | ** are fewer than i registered CGI parmaeters. |
| 836 | */ |
| @@ -845,17 +888,26 @@ | |
| 888 | } |
| 889 | |
| 890 | /* |
| 891 | ** Print all query parameters on standard output. Format the |
| 892 | ** parameters as HTML. This is used for testing and debugging. |
| 893 | ** Release builds omit the values of the cookies to avoid defeating |
| 894 | ** the purpose of setting HttpOnly cookies. |
| 895 | */ |
| 896 | void cgi_print_all(void){ |
| 897 | int i; |
| 898 | int showAll = 0; |
| 899 | #ifdef FOSSIL_DEBUG |
| 900 | /* Show the values of cookies in debug mode. */ |
| 901 | showAll = 1; |
| 902 | #endif |
| 903 | cgi_parameter("",""); /* Force the parameters into sorted order */ |
| 904 | for(i=0; i<nUsedQP; i++){ |
| 905 | if( showAll || (fossil_stricmp("HTTP_COOKIE",aParamQP[i].zName)!=0 && fossil_strnicmp("fossil-",aParamQP[i].zName,7)!=0) ){ |
| 906 | cgi_printf("%s = %s <br />\n", |
| 907 | htmlize(aParamQP[i].zName, -1), htmlize(aParamQP[i].zValue, -1)); |
| 908 | } |
| 909 | } |
| 910 | } |
| 911 | |
| 912 | /* |
| 913 | ** This routine works like "printf" except that it has the |
| @@ -952,12 +1004,12 @@ | |
| 1004 | } |
| 1005 | zToken = extract_token(zLine, &z); |
| 1006 | if( zToken==0 ){ |
| 1007 | malformed_request(); |
| 1008 | } |
| 1009 | if( fossil_strcmp(zToken,"GET")!=0 && fossil_strcmp(zToken,"POST")!=0 |
| 1010 | && fossil_strcmp(zToken,"HEAD")!=0 ){ |
| 1011 | malformed_request(); |
| 1012 | } |
| 1013 | cgi_setenv("GATEWAY_INTERFACE","CGI/1.0"); |
| 1014 | cgi_setenv("REQUEST_METHOD",zToken); |
| 1015 | zToken = extract_token(z, &z); |
| @@ -993,29 +1045,29 @@ | |
| 1045 | while( i>0 && fossil_isspace(zVal[i-1]) ){ i--; } |
| 1046 | zVal[i] = 0; |
| 1047 | for(i=0; zFieldName[i]; i++){ |
| 1048 | zFieldName[i] = fossil_tolower(zFieldName[i]); |
| 1049 | } |
| 1050 | if( fossil_strcmp(zFieldName,"content-length:")==0 ){ |
| 1051 | cgi_setenv("CONTENT_LENGTH", zVal); |
| 1052 | }else if( fossil_strcmp(zFieldName,"content-type:")==0 ){ |
| 1053 | cgi_setenv("CONTENT_TYPE", zVal); |
| 1054 | }else if( fossil_strcmp(zFieldName,"cookie:")==0 ){ |
| 1055 | cgi_setenv("HTTP_COOKIE", zVal); |
| 1056 | }else if( fossil_strcmp(zFieldName,"https:")==0 ){ |
| 1057 | cgi_setenv("HTTPS", zVal); |
| 1058 | }else if( fossil_strcmp(zFieldName,"host:")==0 ){ |
| 1059 | cgi_setenv("HTTP_HOST", zVal); |
| 1060 | }else if( fossil_strcmp(zFieldName,"if-none-match:")==0 ){ |
| 1061 | cgi_setenv("HTTP_IF_NONE_MATCH", zVal); |
| 1062 | }else if( fossil_strcmp(zFieldName,"if-modified-since:")==0 ){ |
| 1063 | cgi_setenv("HTTP_IF_MODIFIED_SINCE", zVal); |
| 1064 | } |
| 1065 | #if 0 |
| 1066 | else if( fossil_strcmp(zFieldName,"referer:")==0 ){ |
| 1067 | cgi_setenv("HTTP_REFERER", zVal); |
| 1068 | }else if( fossil_strcmp(zFieldName,"user-agent:")==0 ){ |
| 1069 | cgi_setenv("HTTP_USER_AGENT", zVal); |
| 1070 | } |
| 1071 | #endif |
| 1072 | } |
| 1073 | |
| @@ -1096,11 +1148,11 @@ | |
| 1148 | } |
| 1149 | } |
| 1150 | if( iPort>mxPort ) return 1; |
| 1151 | listen(listener,10); |
| 1152 | if( iPort>mnPort ){ |
| 1153 | fossil_print("Listening for HTTP requests on TCP port %d\n", iPort); |
| 1154 | fflush(stdout); |
| 1155 | } |
| 1156 | if( zBrowser ){ |
| 1157 | zBrowser = mprintf(zBrowser, iPort); |
| 1158 | system(zBrowser); |
| 1159 |
+192
-120
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -32,60 +32,72 @@ | ||
| 32 | 32 | ** are not true files results in a fatal error. |
| 33 | 33 | */ |
| 34 | 34 | static void status_report( |
| 35 | 35 | Blob *report, /* Append the status report here */ |
| 36 | 36 | const char *zPrefix, /* Prefix on each line of the report */ |
| 37 | - int missingIsFatal /* MISSING and NOT_A_FILE are fatal errors */ | |
| 37 | + int missingIsFatal, /* MISSING and NOT_A_FILE are fatal errors */ | |
| 38 | + int cwdRelative /* Report relative to the current working dir */ | |
| 38 | 39 | ){ |
| 39 | 40 | Stmt q; |
| 40 | 41 | int nPrefix = strlen(zPrefix); |
| 41 | 42 | int nErr = 0; |
| 43 | + Blob rewrittenPathname; | |
| 42 | 44 | db_prepare(&q, |
| 43 | 45 | "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)" |
| 44 | 46 | " FROM vfile " |
| 45 | 47 | " WHERE file_is_selected(id)" |
| 46 | 48 | " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1" |
| 47 | 49 | ); |
| 50 | + blob_zero(&rewrittenPathname); | |
| 48 | 51 | while( db_step(&q)==SQLITE_ROW ){ |
| 49 | 52 | const char *zPathname = db_column_text(&q,0); |
| 53 | + const char *zDisplayName = zPathname; | |
| 50 | 54 | int isDeleted = db_column_int(&q, 1); |
| 51 | 55 | int isChnged = db_column_int(&q,2); |
| 52 | 56 | int isNew = db_column_int(&q,3)==0; |
| 53 | 57 | int isRenamed = db_column_int(&q,4); |
| 54 | 58 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 59 | + if( cwdRelative ){ | |
| 60 | + file_relative_name(zFullName, &rewrittenPathname); | |
| 61 | + zDisplayName = blob_str(&rewrittenPathname); | |
| 62 | + if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){ | |
| 63 | + zDisplayName += 2; /* no unnecessary ./ prefix */ | |
| 64 | + } | |
| 65 | + } | |
| 55 | 66 | blob_append(report, zPrefix, nPrefix); |
| 56 | 67 | if( isDeleted ){ |
| 57 | - blob_appendf(report, "DELETED %s\n", zPathname); | |
| 68 | + blob_appendf(report, "DELETED %s\n", zDisplayName); | |
| 58 | 69 | }else if( !file_isfile_or_link(zFullName) ){ |
| 59 | - if( access(zFullName, 0)==0 ){ | |
| 60 | - blob_appendf(report, "NOT_A_FILE %s\n", zPathname); | |
| 70 | + if( file_access(zFullName, 0)==0 ){ | |
| 71 | + blob_appendf(report, "NOT_A_FILE %s\n", zDisplayName); | |
| 61 | 72 | if( missingIsFatal ){ |
| 62 | - fossil_warning("not a file: %s", zPathname); | |
| 73 | + fossil_warning("not a file: %s", zDisplayName); | |
| 63 | 74 | nErr++; |
| 64 | 75 | } |
| 65 | 76 | }else{ |
| 66 | - blob_appendf(report, "MISSING %s\n", zPathname); | |
| 77 | + blob_appendf(report, "MISSING %s\n", zDisplayName); | |
| 67 | 78 | if( missingIsFatal ){ |
| 68 | - fossil_warning("missing file: %s", zPathname); | |
| 79 | + fossil_warning("missing file: %s", zDisplayName); | |
| 69 | 80 | nErr++; |
| 70 | 81 | } |
| 71 | 82 | } |
| 72 | 83 | }else if( isNew ){ |
| 73 | - blob_appendf(report, "ADDED %s\n", zPathname); | |
| 84 | + blob_appendf(report, "ADDED %s\n", zDisplayName); | |
| 74 | 85 | }else if( isDeleted ){ |
| 75 | - blob_appendf(report, "DELETED %s\n", zPathname); | |
| 86 | + blob_appendf(report, "DELETED %s\n", zDisplayName); | |
| 76 | 87 | }else if( isChnged==2 ){ |
| 77 | - blob_appendf(report, "UPDATED_BY_MERGE %s\n", zPathname); | |
| 88 | + blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName); | |
| 78 | 89 | }else if( isChnged==3 ){ |
| 79 | - blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname); | |
| 90 | + blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName); | |
| 80 | 91 | }else if( isChnged==1 ){ |
| 81 | - blob_appendf(report, "EDITED %s\n", zPathname); | |
| 92 | + blob_appendf(report, "EDITED %s\n", zDisplayName); | |
| 82 | 93 | }else if( isRenamed ){ |
| 83 | - blob_appendf(report, "RENAMED %s\n", zPathname); | |
| 94 | + blob_appendf(report, "RENAMED %s\n", zDisplayName); | |
| 84 | 95 | } |
| 85 | 96 | free(zFullName); |
| 86 | 97 | } |
| 98 | + blob_reset(&rewrittenPathname); | |
| 87 | 99 | db_finalize(&q); |
| 88 | 100 | db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid" |
| 89 | 101 | " WHERE id=0"); |
| 90 | 102 | while( db_step(&q)==SQLITE_ROW ){ |
| 91 | 103 | blob_append(report, zPrefix, nPrefix); |
| @@ -94,33 +106,59 @@ | ||
| 94 | 106 | db_finalize(&q); |
| 95 | 107 | if( nErr ){ |
| 96 | 108 | fossil_fatal("aborting due to prior errors"); |
| 97 | 109 | } |
| 98 | 110 | } |
| 111 | + | |
| 112 | +/* | |
| 113 | +** Use the "relative-paths" setting and the --abs-paths and | |
| 114 | +** --rel-paths command line options to determine whether the | |
| 115 | +** status report should be shown relative to the current | |
| 116 | +** working directory. | |
| 117 | +*/ | |
| 118 | +static int determine_cwd_relative_option() | |
| 119 | +{ | |
| 120 | + int relativePaths = db_get_boolean("relative-paths", 1); | |
| 121 | + int absPathOption = find_option("abs-paths", 0, 0)!=0; | |
| 122 | + int relPathOption = find_option("rel-paths", 0, 0)!=0; | |
| 123 | + if( absPathOption ){ relativePaths = 0; } | |
| 124 | + if( relPathOption ){ relativePaths = 1; } | |
| 125 | + return relativePaths; | |
| 126 | +} | |
| 99 | 127 | |
| 100 | 128 | /* |
| 101 | 129 | ** COMMAND: changes |
| 102 | 130 | ** |
| 103 | 131 | ** Usage: %fossil changes |
| 104 | 132 | ** |
| 105 | 133 | ** Report on the edit status of all files in the current checkout. |
| 106 | 134 | ** See also the "status" and "extra" commands. |
| 107 | 135 | ** |
| 136 | +** Pathnames are displayed according to the "relative-paths" setting, | |
| 137 | +** unless overridden by the --abs-paths or --rel-paths options. | |
| 138 | +** | |
| 108 | 139 | ** Options: |
| 109 | 140 | ** |
| 110 | 141 | ** --sha1sum Verify file status using SHA1 hashing rather |
| 111 | 142 | ** than relying on file mtimes. |
| 143 | +** | |
| 144 | +** --abs-paths Display absolute pathnames. | |
| 145 | +** | |
| 146 | +** --rel-paths Display pathnames relative to the current working | |
| 147 | +** directory. | |
| 112 | 148 | */ |
| 113 | 149 | void changes_cmd(void){ |
| 114 | 150 | Blob report; |
| 115 | 151 | int vid; |
| 116 | 152 | int useSha1sum = find_option("sha1sum", 0, 0)!=0; |
| 153 | + int cwdRelative = 0; | |
| 117 | 154 | db_must_be_within_tree(); |
| 155 | + cwdRelative = determine_cwd_relative_option(); | |
| 118 | 156 | blob_zero(&report); |
| 119 | 157 | vid = db_lget_int("checkout", 0); |
| 120 | 158 | vfile_check_signature(vid, 0, useSha1sum); |
| 121 | - status_report(&report, "", 0); | |
| 159 | + status_report(&report, "", 0, cwdRelative); | |
| 122 | 160 | blob_write_to_file(&report, "-"); |
| 123 | 161 | } |
| 124 | 162 | |
| 125 | 163 | /* |
| 126 | 164 | ** COMMAND: status |
| @@ -127,22 +165,30 @@ | ||
| 127 | 165 | ** |
| 128 | 166 | ** Usage: %fossil status |
| 129 | 167 | ** |
| 130 | 168 | ** Report on the status of the current checkout. |
| 131 | 169 |