Fossil SCM

Build-in the linenoise command-line editing library on unix.

drh 2015-06-11 15:28 trunk merge
Commit 851485657643dc2c18c4b555159a981591e42609
-15
--- auto.def
+++ auto.def
@@ -14,11 +14,10 @@
1414
with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
1515
with-tcl-private-stubs=0
1616
=> {Enable Tcl integration via private stubs mechanism}
1717
internal-sqlite=1 => {Don't use the internal SQLite, use the system one}
1818
static=0 => {Link a static executable}
19
- lineedit=1 => {Disable line editing}
2019
fusefs=1 => {Disable the Fuse Filesystem}
2120
fossil-debug=0 => {Build with fossil debugging enabled}
2221
json=0 => {Build with fossil JSON API enabled}
2322
}
2423
@@ -260,24 +259,10 @@
260259
if {![cc-check-includes zlib.h] || ![cc-check-function-in-lib inflateEnd z]} {
261260
user-error "zlib not found please install it or specify the location with --with-zlib"
262261
}
263262
}
264263
265
-if {[opt-bool lineedit]} {
266
- # Need readline-compatible line editing
267
- cc-with {-includes stdio.h} {
268
- if {[cc-check-includes readline/readline.h] && [cc-check-function-in-lib readline readline]} {
269
- define-append EXTRA_CFLAGS -DHAVE_READLINE
270
- msg-result "Using readline for line editing"
271
- } elseif {[cc-check-includes editline/readline.h] && [cc-check-function-in-lib readline edit]} {
272
- define-feature editline
273
- define-append EXTRA_CFLAGS -DHAVE_EDITLINE
274
- msg-result "Using editline for line editing"
275
- }
276
- }
277
-}
278
-
279264
# Network functions require libraries on some systems
280265
cc-check-function-in-lib gethostbyname nsl
281266
if {![cc-check-function-in-lib socket {socket network}]} {
282267
# Last resort, may be Windows
283268
if {[string match *mingw* [get-define host]]} {
284269
285270
ADDED src/linenoise.c
286271
ADDED src/linenoise.h
--- auto.def
+++ auto.def
@@ -14,11 +14,10 @@
14 with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
15 with-tcl-private-stubs=0
16 => {Enable Tcl integration via private stubs mechanism}
17 internal-sqlite=1 => {Don't use the internal SQLite, use the system one}
18 static=0 => {Link a static executable}
19 lineedit=1 => {Disable line editing}
20 fusefs=1 => {Disable the Fuse Filesystem}
21 fossil-debug=0 => {Build with fossil debugging enabled}
22 json=0 => {Build with fossil JSON API enabled}
23 }
24
@@ -260,24 +259,10 @@
260 if {![cc-check-includes zlib.h] || ![cc-check-function-in-lib inflateEnd z]} {
261 user-error "zlib not found please install it or specify the location with --with-zlib"
262 }
263 }
264
265 if {[opt-bool lineedit]} {
266 # Need readline-compatible line editing
267 cc-with {-includes stdio.h} {
268 if {[cc-check-includes readline/readline.h] && [cc-check-function-in-lib readline readline]} {
269 define-append EXTRA_CFLAGS -DHAVE_READLINE
270 msg-result "Using readline for line editing"
271 } elseif {[cc-check-includes editline/readline.h] && [cc-check-function-in-lib readline edit]} {
272 define-feature editline
273 define-append EXTRA_CFLAGS -DHAVE_EDITLINE
274 msg-result "Using editline for line editing"
275 }
276 }
277 }
278
279 # Network functions require libraries on some systems
280 cc-check-function-in-lib gethostbyname nsl
281 if {![cc-check-function-in-lib socket {socket network}]} {
282 # Last resort, may be Windows
283 if {[string match *mingw* [get-define host]]} {
284
285 DDED src/linenoise.c
286 DDED src/linenoise.h
--- auto.def
+++ auto.def
@@ -14,11 +14,10 @@
14 with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
15 with-tcl-private-stubs=0
16 => {Enable Tcl integration via private stubs mechanism}
17 internal-sqlite=1 => {Don't use the internal SQLite, use the system one}
18 static=0 => {Link a static executable}
 
19 fusefs=1 => {Disable the Fuse Filesystem}
20 fossil-debug=0 => {Build with fossil debugging enabled}
21 json=0 => {Build with fossil JSON API enabled}
22 }
23
@@ -260,24 +259,10 @@
259 if {![cc-check-includes zlib.h] || ![cc-check-function-in-lib inflateEnd z]} {
260 user-error "zlib not found please install it or specify the location with --with-zlib"
261 }
262 }
263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264 # Network functions require libraries on some systems
265 cc-check-function-in-lib gethostbyname nsl
266 if {![cc-check-function-in-lib socket {socket network}]} {
267 # Last resort, may be Windows
268 if {[string match *mingw* [get-define host]]} {
269
270 DDED src/linenoise.c
271 DDED src/linenoise.h
--- a/src/linenoise.c
+++ b/src/linenoise.c
@@ -0,0 +1,40 @@
1
+t->buf, oVERSION 1.0
2
+ *
3
+ * G line editing lib
4
+ *4argtypest->buf, o#include "sqlite3onst char *fmt, arg1fmt, arg1arg1==== C89 compatibility====== */
5
+
6
+/* snprintf() is not C89, but sqlite3_vsnprintf() can be adaptedSnprintf(char *str, size_t size, const char *format, ...) {
7
+ va_list ap;
8
+ int result;
9
+
10
+ va_start(ap,format);
11
+ result = (int)strlen(sqlite3_vsnprintf((int)size,str,format,ap));
12
+ va_end(ap);
13
+
14
+ return result;
15
+}
16
+#undef snprintf
17
+#define snprintf linenoiseSnprintf
18
+
19
+/* strdup() is technically not standard C89 despite being in POSIXStrdup(const char *s) {
20
+ size_t size = strlen(s)+1;
21
+ char *result = malloc(size);
22
+
23
+ if (result) memcpy(result,s,size);
24
+
25
+ return result;
26
+}
27
+#undef strdup
28
+#define strdup linenoiseStrdup
29
+
30
+/* strcasecmp() is not standard C89. SQLite offers a direct replacement. */
31
+#undef strcasecmp
32
+#define strcasecmp sqlite3_stricmp#if !defined(__sun__)#endift->buf, o, 0);, 0);
33
+t->buf, o, 0"\n",1);", 0) /* || mlmode */(int){
34
+*/ buflen, stdin)countif (count && buf[count-1]countt->bu}/* Interactive editingen printf("\n");
35
+ }FILE *int->buf, oVERSION ne editing lib
36
+ *4argtypest->buf, o#include "sqlite3onst char *fmt, arg1fmt, arg1arg1==== C89 compatibility====== */
37
+
38
+/* snprintf() is not C89, but s...__VA_ARGS__...););
39
+");
40
+: 1960 magic shit.
--- a/src/linenoise.c
+++ b/src/linenoise.c
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/src/linenoise.c
+++ b/src/linenoise.c
@@ -0,0 +1,40 @@
1 t->buf, oVERSION 1.0
2 *
3 * G line editing lib
4 *4argtypest->buf, o#include "sqlite3onst char *fmt, arg1fmt, arg1arg1==== C89 compatibility====== */
5
6 /* snprintf() is not C89, but sqlite3_vsnprintf() can be adaptedSnprintf(char *str, size_t size, const char *format, ...) {
7 va_list ap;
8 int result;
9
10 va_start(ap,format);
11 result = (int)strlen(sqlite3_vsnprintf((int)size,str,format,ap));
12 va_end(ap);
13
14 return result;
15 }
16 #undef snprintf
17 #define snprintf linenoiseSnprintf
18
19 /* strdup() is technically not standard C89 despite being in POSIXStrdup(const char *s) {
20 size_t size = strlen(s)+1;
21 char *result = malloc(size);
22
23 if (result) memcpy(result,s,size);
24
25 return result;
26 }
27 #undef strdup
28 #define strdup linenoiseStrdup
29
30 /* strcasecmp() is not standard C89. SQLite offers a direct replacement. */
31 #undef strcasecmp
32 #define strcasecmp sqlite3_stricmp#if !defined(__sun__)#endift->buf, o, 0);, 0);
33 t->buf, o, 0"\n",1);", 0) /* || mlmode */(int){
34 */ buflen, stdin)countif (count && buf[count-1]countt->bu}/* Interactive editingen printf("\n");
35 }FILE *int->buf, oVERSION ne editing lib
36 *4argtypest->buf, o#include "sqlite3onst char *fmt, arg1fmt, arg1arg1==== C89 compatibility====== */
37
38 /* snprintf() is not C89, but s...__VA_ARGS__...););
39 ");
40 : 1960 magic shit.
--- a/src/linenoise.h
+++ b/src/linenoise.h
@@ -0,0 +1,21 @@
1
+/* linenoise.h -- VERSION 1.0
2
+ *
3
+ * Guerrilla line editing libr line editing lib
4
+ * needs to be 20,000 lines of C code.
5
+ *
6
+ * See linenoise.c for more information.
7
+ *
8
+ * -----------------------------------------------------------------------2014, Salvatore Sanfilippo <antirez at gmail dot com>
9
+ * Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
10
+ *
11
+ * All rights reserved.
12
+ *
13
+ * Redistribution and use in source and binary forms, with or without
14
+ * modification, are permitted provided that the following conditions are
15
+ * met:
16
+ *
17
+ * * Redistributions of source code must retain the above copyright
18
+ * notice, this list of conditions and the following disclaimer.
19
+ *
20
+ * * Redistributions in binary form must reproduce the above copyright
21
+ * notice, thi
--- a/src/linenoise.h
+++ b/src/linenoise.h
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/src/linenoise.h
+++ b/src/linenoise.h
@@ -0,0 +1,21 @@
1 /* linenoise.h -- VERSION 1.0
2 *
3 * Guerrilla line editing libr line editing lib
4 * needs to be 20,000 lines of C code.
5 *
6 * See linenoise.c for more information.
7 *
8 * -----------------------------------------------------------------------2014, Salvatore Sanfilippo <antirez at gmail dot com>
9 * Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
10 *
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are
15 * met:
16 *
17 * * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * * Redistributions in binary form must reproduce the above copyright
21 * notice, thi
+5 -1
--- src/main.mk
+++ src/main.mk
@@ -510,10 +510,11 @@
510510
511511
512512
EXTRAOBJ = \
513513
$(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) \
514514
$(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) \
515
+ $(OBJDIR)/linenoise.o \
515516
$(OBJDIR)/shell.o \
516517
$(OBJDIR)/th.o \
517518
$(OBJDIR)/th_lang.o \
518519
$(OBJDIR)/th_tcl.o \
519520
$(OBJDIR)/cson_amalgamation.o
@@ -1620,11 +1621,14 @@
16201621
16211622
$(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
16221623
$(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) -c $(SRCDIR)/sqlite3.c -o $@
16231624
16241625
$(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h
1625
- $(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)/shell.c -o $@
1626
+ $(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -DHAVE_LINENOISE -c $(SRCDIR)/shell.c -o $@
1627
+
1628
+$(OBJDIR)/linenoise.o: $(SRCDIR)/linenoise.c $(SRCDIR)/linenoise.h
1629
+ $(XTCC) -c $(SRCDIR)/linenoise.c -o $@
16261630
16271631
$(OBJDIR)/th.o: $(SRCDIR)/th.c
16281632
$(XTCC) -c $(SRCDIR)/th.c -o $@
16291633
16301634
$(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
16311635
--- src/main.mk
+++ src/main.mk
@@ -510,10 +510,11 @@
510
511
512 EXTRAOBJ = \
513 $(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) \
514 $(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) \
 
515 $(OBJDIR)/shell.o \
516 $(OBJDIR)/th.o \
517 $(OBJDIR)/th_lang.o \
518 $(OBJDIR)/th_tcl.o \
519 $(OBJDIR)/cson_amalgamation.o
@@ -1620,11 +1621,14 @@
1620
1621 $(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
1622 $(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) -c $(SRCDIR)/sqlite3.c -o $@
1623
1624 $(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h
1625 $(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)/shell.c -o $@
 
 
 
1626
1627 $(OBJDIR)/th.o: $(SRCDIR)/th.c
1628 $(XTCC) -c $(SRCDIR)/th.c -o $@
1629
1630 $(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
1631
--- src/main.mk
+++ src/main.mk
@@ -510,10 +510,11 @@
510
511
512 EXTRAOBJ = \
513 $(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) \
514 $(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) \
515 $(OBJDIR)/linenoise.o \
516 $(OBJDIR)/shell.o \
517 $(OBJDIR)/th.o \
518 $(OBJDIR)/th_lang.o \
519 $(OBJDIR)/th_tcl.o \
520 $(OBJDIR)/cson_amalgamation.o
@@ -1620,11 +1621,14 @@
1621
1622 $(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
1623 $(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) -c $(SRCDIR)/sqlite3.c -o $@
1624
1625 $(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h
1626 $(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -DHAVE_LINENOISE -c $(SRCDIR)/shell.c -o $@
1627
1628 $(OBJDIR)/linenoise.o: $(SRCDIR)/linenoise.c $(SRCDIR)/linenoise.h
1629 $(XTCC) -c $(SRCDIR)/linenoise.c -o $@
1630
1631 $(OBJDIR)/th.o: $(SRCDIR)/th.c
1632 $(XTCC) -c $(SRCDIR)/th.c -o $@
1633
1634 $(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
1635
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -341,10 +341,11 @@
341341
342342
writeln [string map [list <<<NEXT_LINE>>> \\] {
343343
EXTRAOBJ = <<<NEXT_LINE>>>
344344
$(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) <<<NEXT_LINE>>>
345345
$(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) <<<NEXT_LINE>>>
346
+ $(OBJDIR)/linenoise.o <<<NEXT_LINE>>>
346347
$(OBJDIR)/shell.o <<<NEXT_LINE>>>
347348
$(OBJDIR)/th.o <<<NEXT_LINE>>>
348349
$(OBJDIR)/th_lang.o <<<NEXT_LINE>>>
349350
$(OBJDIR)/th_tcl.o <<<NEXT_LINE>>>
350351
$(OBJDIR)/cson_amalgamation.o
@@ -401,11 +402,14 @@
401402
402403
writeln "\$(OBJDIR)/sqlite3.o:\t\$(SRCDIR)/sqlite3.c"
403404
writeln "\t\$(XTCC) \$(SQLITE_OPTIONS) \$(SQLITE_CFLAGS) -c \$(SRCDIR)/sqlite3.c -o \$@\n"
404405
405406
writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c \$(SRCDIR)/sqlite3.h"
406
-writeln "\t\$(XTCC) \$(SHELL_OPTIONS) \$(SHELL_CFLAGS) -c \$(SRCDIR)/shell.c -o \$@\n"
407
+writeln "\t\$(XTCC) \$(SHELL_OPTIONS) \$(SHELL_CFLAGS) -DHAVE_LINENOISE -c \$(SRCDIR)/shell.c -o \$@\n"
408
+
409
+writeln "\$(OBJDIR)/linenoise.o:\t\$(SRCDIR)/linenoise.c \$(SRCDIR)/linenoise.h"
410
+writeln "\t\$(XTCC) -c \$(SRCDIR)/linenoise.c -o \$@\n"
407411
408412
writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
409413
writeln "\t\$(XTCC) -c \$(SRCDIR)/th.c -o \$@\n"
410414
411415
writeln "\$(OBJDIR)/th_lang.o:\t\$(SRCDIR)/th_lang.c"
412416
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -341,10 +341,11 @@
341
342 writeln [string map [list <<<NEXT_LINE>>> \\] {
343 EXTRAOBJ = <<<NEXT_LINE>>>
344 $(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) <<<NEXT_LINE>>>
345 $(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) <<<NEXT_LINE>>>
 
346 $(OBJDIR)/shell.o <<<NEXT_LINE>>>
347 $(OBJDIR)/th.o <<<NEXT_LINE>>>
348 $(OBJDIR)/th_lang.o <<<NEXT_LINE>>>
349 $(OBJDIR)/th_tcl.o <<<NEXT_LINE>>>
350 $(OBJDIR)/cson_amalgamation.o
@@ -401,11 +402,14 @@
401
402 writeln "\$(OBJDIR)/sqlite3.o:\t\$(SRCDIR)/sqlite3.c"
403 writeln "\t\$(XTCC) \$(SQLITE_OPTIONS) \$(SQLITE_CFLAGS) -c \$(SRCDIR)/sqlite3.c -o \$@\n"
404
405 writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c \$(SRCDIR)/sqlite3.h"
406 writeln "\t\$(XTCC) \$(SHELL_OPTIONS) \$(SHELL_CFLAGS) -c \$(SRCDIR)/shell.c -o \$@\n"
 
 
 
407
408 writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
409 writeln "\t\$(XTCC) -c \$(SRCDIR)/th.c -o \$@\n"
410
411 writeln "\$(OBJDIR)/th_lang.o:\t\$(SRCDIR)/th_lang.c"
412
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -341,10 +341,11 @@
341
342 writeln [string map [list <<<NEXT_LINE>>> \\] {
343 EXTRAOBJ = <<<NEXT_LINE>>>
344 $(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) <<<NEXT_LINE>>>
345 $(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) <<<NEXT_LINE>>>
346 $(OBJDIR)/linenoise.o <<<NEXT_LINE>>>
347 $(OBJDIR)/shell.o <<<NEXT_LINE>>>
348 $(OBJDIR)/th.o <<<NEXT_LINE>>>
349 $(OBJDIR)/th_lang.o <<<NEXT_LINE>>>
350 $(OBJDIR)/th_tcl.o <<<NEXT_LINE>>>
351 $(OBJDIR)/cson_amalgamation.o
@@ -401,11 +402,14 @@
402
403 writeln "\$(OBJDIR)/sqlite3.o:\t\$(SRCDIR)/sqlite3.c"
404 writeln "\t\$(XTCC) \$(SQLITE_OPTIONS) \$(SQLITE_CFLAGS) -c \$(SRCDIR)/sqlite3.c -o \$@\n"
405
406 writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c \$(SRCDIR)/sqlite3.h"
407 writeln "\t\$(XTCC) \$(SHELL_OPTIONS) \$(SHELL_CFLAGS) -DHAVE_LINENOISE -c \$(SRCDIR)/shell.c -o \$@\n"
408
409 writeln "\$(OBJDIR)/linenoise.o:\t\$(SRCDIR)/linenoise.c \$(SRCDIR)/linenoise.h"
410 writeln "\t\$(XTCC) -c \$(SRCDIR)/linenoise.c -o \$@\n"
411
412 writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
413 writeln "\t\$(XTCC) -c \$(SRCDIR)/th.c -o \$@\n"
414
415 writeln "\$(OBJDIR)/th_lang.o:\t\$(SRCDIR)/th_lang.c"
416

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button