Fossil SCM

Minor cleanups. Made Th_Ob_Man opaque. Renamed TH_USE_xxx to TH_ENABLE_xxx.

stephan 2012-07-15 13:14 th1-query-api
Commit 3d243a5681fb177e124adbdc5e729248b1cff76c
4 files changed +25 -7 +25 -27 -19 +13 -10
+25 -7
--- src/th.c
+++ src/th.c
@@ -6,11 +6,23 @@
66
77
#include "th.h"
88
#include <string.h>
99
#include <assert.h>
1010
#include <stdio.h> /* FILE class */
11
-#ifdef TH_USE_OUTBUF
11
+
12
+#ifdef TH_ENABLE_OUTBUF
13
+struct Th_Ob_Man {
14
+ Blob ** aBuf; /* Stack of Blobs */
15
+ int nBuf; /* Number of blobs */
16
+ int cursor; /* Current level (-1=not active) */
17
+ Th_Interp * interp; /* The associated interpreter */
18
+ Th_Vtab_Output * aOutput
19
+ /* Stack of output routines corresponding
20
+ to the current buffering level.
21
+ Has nBuf entries.
22
+ */;
23
+};
1224
#endif
1325
1426
extern void *fossil_realloc(void *p, size_t n);
1527
static void * th_fossil_realloc(void *p, unsigned int n){
1628
return fossil_realloc( p, n );
@@ -2747,11 +2759,11 @@
27472759
return e ? ((Th_GcEntry*)e->pData)->pData : NULL;
27482760
}
27492761
27502762
27512763
2752
-#ifdef TH_USE_OUTBUF
2764
+#ifdef TH_ENABLE_OUTBUF
27532765
/* Reminder: the ob code "really" belongs in th_lang.c,
27542766
but we need access to Th_Interp internals in order to
27552767
swap out Th_Vtab parts for purposes of stacking layers
27562768
of buffers.
27572769
*/
@@ -2881,18 +2893,24 @@
28812893
/*printf( "post-pop: pMan->nBuf=%d, pMan->cursor=%d\n", pMan->nBuf, pMan->cursor);*/
28822894
return rc;
28832895
}
28842896
}
28852897
2886
-void Th_ob_cleanup( Th_Ob_Man * man ){
2887
- Blob * b;
2888
- while( (b = Th_ob_pop(man)) ){
2898
+int Th_ob_pop_free( Th_Ob_Man * pMan ){
2899
+ Blob * b = Th_ob_pop( pMan );
2900
+ if(!b) return 1;
2901
+ else {
28892902
blob_reset(b);
2890
- Th_Free( man->interp, b );
2903
+ Th_Free( pMan->interp, b );
28912904
}
28922905
}
28932906
2907
+
2908
+void Th_ob_cleanup( Th_Ob_Man * man ){
2909
+ while( 0 == Th_ob_pop_free(man) ){}
2910
+}
2911
+
28942912
28952913
/*
28962914
** TH Syntax:
28972915
**
28982916
** ob clean
@@ -3143,7 +3161,7 @@
31433161
}
31443162
31453163
#undef Th_Ob_Man_empty_m
31463164
#undef Th_Ob_Man_KEY
31473165
#endif
3148
-/* end TH_USE_OUTBUF */
3166
+/* end TH_ENABLE_OUTBUF */
31493167
31503168
--- src/th.c
+++ src/th.c
@@ -6,11 +6,23 @@
6
7 #include "th.h"
8 #include <string.h>
9 #include <assert.h>
10 #include <stdio.h> /* FILE class */
11 #ifdef TH_USE_OUTBUF
 
 
 
 
 
 
 
 
 
 
 
 
12 #endif
13
14 extern void *fossil_realloc(void *p, size_t n);
15 static void * th_fossil_realloc(void *p, unsigned int n){
16 return fossil_realloc( p, n );
@@ -2747,11 +2759,11 @@
2747 return e ? ((Th_GcEntry*)e->pData)->pData : NULL;
2748 }
2749
2750
2751
2752 #ifdef TH_USE_OUTBUF
2753 /* Reminder: the ob code "really" belongs in th_lang.c,
2754 but we need access to Th_Interp internals in order to
2755 swap out Th_Vtab parts for purposes of stacking layers
2756 of buffers.
2757 */
@@ -2881,18 +2893,24 @@
2881 /*printf( "post-pop: pMan->nBuf=%d, pMan->cursor=%d\n", pMan->nBuf, pMan->cursor);*/
2882 return rc;
2883 }
2884 }
2885
2886 void Th_ob_cleanup( Th_Ob_Man * man ){
2887 Blob * b;
2888 while( (b = Th_ob_pop(man)) ){
 
2889 blob_reset(b);
2890 Th_Free( man->interp, b );
2891 }
2892 }
2893
 
 
 
 
 
2894
2895 /*
2896 ** TH Syntax:
2897 **
2898 ** ob clean
@@ -3143,7 +3161,7 @@
3143 }
3144
3145 #undef Th_Ob_Man_empty_m
3146 #undef Th_Ob_Man_KEY
3147 #endif
3148 /* end TH_USE_OUTBUF */
3149
3150
--- src/th.c
+++ src/th.c
@@ -6,11 +6,23 @@
6
7 #include "th.h"
8 #include <string.h>
9 #include <assert.h>
10 #include <stdio.h> /* FILE class */
11
12 #ifdef TH_ENABLE_OUTBUF
13 struct Th_Ob_Man {
14 Blob ** aBuf; /* Stack of Blobs */
15 int nBuf; /* Number of blobs */
16 int cursor; /* Current level (-1=not active) */
17 Th_Interp * interp; /* The associated interpreter */
18 Th_Vtab_Output * aOutput
19 /* Stack of output routines corresponding
20 to the current buffering level.
21 Has nBuf entries.
22 */;
23 };
24 #endif
25
26 extern void *fossil_realloc(void *p, size_t n);
27 static void * th_fossil_realloc(void *p, unsigned int n){
28 return fossil_realloc( p, n );
@@ -2747,11 +2759,11 @@
2759 return e ? ((Th_GcEntry*)e->pData)->pData : NULL;
2760 }
2761
2762
2763
2764 #ifdef TH_ENABLE_OUTBUF
2765 /* Reminder: the ob code "really" belongs in th_lang.c,
2766 but we need access to Th_Interp internals in order to
2767 swap out Th_Vtab parts for purposes of stacking layers
2768 of buffers.
2769 */
@@ -2881,18 +2893,24 @@
2893 /*printf( "post-pop: pMan->nBuf=%d, pMan->cursor=%d\n", pMan->nBuf, pMan->cursor);*/
2894 return rc;
2895 }
2896 }
2897
2898 int Th_ob_pop_free( Th_Ob_Man * pMan ){
2899 Blob * b = Th_ob_pop( pMan );
2900 if(!b) return 1;
2901 else {
2902 blob_reset(b);
2903 Th_Free( pMan->interp, b );
2904 }
2905 }
2906
2907
2908 void Th_ob_cleanup( Th_Ob_Man * man ){
2909 while( 0 == Th_ob_pop_free(man) ){}
2910 }
2911
2912
2913 /*
2914 ** TH Syntax:
2915 **
2916 ** ob clean
@@ -3143,7 +3161,7 @@
3161 }
3162
3163 #undef Th_Ob_Man_empty_m
3164 #undef Th_Ob_Man_KEY
3165 #endif
3166 /* end TH_ENABLE_OUTBUF */
3167
3168
+25 -27
--- src/th.h
+++ src/th.h
@@ -1,28 +1,28 @@
11
#include "config.h"
22
33
/*
4
-** TH_USE_SQLITE, if defined, enables the "query" family of functions.
4
+** TH_ENABLE_SQLITE, if defined, enables the "query" family of functions.
55
** They provide SELECT-only access to the repository db.
66
*/
7
-#define TH_USE_SQLITE
7
+#define TH_ENABLE_SQLITE
88
99
/*
10
-** TH_USE_OUTBUF, if defined, enables the "ob" family of functions.
10
+** TH_ENABLE_OUTBUF, if defined, enables the "ob" family of functions.
1111
** They are functionally similar to PHP's ob_start(), ob_end(), etc.
1212
** family of functions, providing output capturing/buffering.
1313
*/
14
-#define TH_USE_OUTBUF
14
+#define TH_ENABLE_OUTBUF
1515
1616
/*
17
-** TH_USE_ARGV, if defined, enables the "argv" family of functions.
17
+** TH_ENABLE_ARGV, if defined, enables the "argv" family of functions.
1818
** They provide access to CLI arguments as well as GET/POST arguments.
1919
** They do not provide access to POST data submitted in JSON mode.
2020
*/
21
-#define TH_USE_ARGV
21
+#define TH_ENABLE_ARGV
2222
23
-#ifdef TH_USE_OUTBUF
23
+#ifdef TH_ENABLE_OUTBUF
2424
#ifndef INTERFACE
2525
#include "blob.h"
2626
#endif
2727
#endif
2828
@@ -200,11 +200,11 @@
200200
201201
/*
202202
** Interfaces to register the language extensions.
203203
*/
204204
int th_register_language(Th_Interp *interp); /* th_lang.c */
205
-int th_register_sqlite(Th_Interp *interp); /* th_main.c */
205
+int th_register_query(Th_Interp *interp); /* th_main.c */
206206
int th_register_argv(Th_Interp *interp); /* th_main.c */
207207
int th_register_vfs(Th_Interp *interp); /* th_vfs.c */
208208
int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */
209209
int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */
210210
int th_register_ob(Th_Interp * interp); /* th.c */
@@ -313,30 +313,21 @@
313313
** Returns TH_OK on success, "something else" on error.
314314
*/
315315
int Th_register_commands( Th_Interp * interp, Th_Command_Reg const * pList );
316316
317317
318
-#ifdef TH_USE_OUTBUF
318
+#ifdef TH_ENABLE_OUTBUF
319319
/*
320320
** Manager of a stack of Blob objects for output buffering.
321
+** See Th_ob_manager().
321322
*/
322
-struct Th_Ob_Man {
323
- Blob ** aBuf; /* Stack of Blobs */
324
- int nBuf; /* Number of blobs */
325
- int cursor; /* Current level (-1=not active) */
326
- Th_Interp * interp; /* The associated interpreter */
327
- Th_Vtab_Output * aOutput
328
- /* Stack of output routines corresponding
329
- to the current buffering level.
330
- Has nBuf entries.
331
- */;
332
-};
333
-
334323
typedef struct Th_Ob_Man Th_Ob_Man;
335324
336325
/*
337
-** Returns the ob manager for the given interpreter.
326
+** Returns the ob manager for the given interpreter. The manager gets
327
+** installed by the th_register_ob(). In Fossil ob support is
328
+** installed automatically if it is available at built time.
338329
*/
339330
Th_Ob_Man * Th_ob_manager(Th_Interp *ignored);
340331
341332
/*
342333
** Returns the top-most Blob in pMan's stack, or NULL
@@ -352,15 +343,22 @@
352343
*/
353344
int Th_ob_push( Th_Ob_Man * pMan, Blob ** pOut );
354345
355346
/*
356347
** Pops the top-most output buffer off the stack and returns
357
-** it. Returns NULL if there is no current buffer. When the last
358
-** buffer is popped, pMan's internals are cleaned up.
348
+** it. Returns NULL if there is no current buffer. When the last
349
+** buffer is popped, pMan's internals are cleaned up (but pMan is not
350
+** freed).
359351
**
360
-** The caller owns the returned object and must eventually call
361
-** blob_reset() on it and Th_Free() it.
352
+** The caller owns the returned object and must eventually clean it up
353
+** by first passing it to blob_reset() and then Th_Free() it.
362354
*/
363355
Blob * Th_ob_pop( Th_Ob_Man * pMan );
356
+/*
357
+** Convenience form of Th_ob_pop() which pops and frees the
358
+** top-most buffer. Returns 0 on success, non-0 if there is no
359
+** stack to pop.
360
+*/
361
+int Th_ob_pop_free( Th_Ob_Man * pMan );
364362
365363
#endif
366
-/* TH_USE_OUTBUF */
364
+/* TH_ENABLE_OUTBUF */
367365
--- src/th.h
+++ src/th.h
@@ -1,28 +1,28 @@
1 #include "config.h"
2
3 /*
4 ** TH_USE_SQLITE, if defined, enables the "query" family of functions.
5 ** They provide SELECT-only access to the repository db.
6 */
7 #define TH_USE_SQLITE
8
9 /*
10 ** TH_USE_OUTBUF, if defined, enables the "ob" family of functions.
11 ** They are functionally similar to PHP's ob_start(), ob_end(), etc.
12 ** family of functions, providing output capturing/buffering.
13 */
14 #define TH_USE_OUTBUF
15
16 /*
17 ** TH_USE_ARGV, if defined, enables the "argv" family of functions.
18 ** They provide access to CLI arguments as well as GET/POST arguments.
19 ** They do not provide access to POST data submitted in JSON mode.
20 */
21 #define TH_USE_ARGV
22
23 #ifdef TH_USE_OUTBUF
24 #ifndef INTERFACE
25 #include "blob.h"
26 #endif
27 #endif
28
@@ -200,11 +200,11 @@
200
201 /*
202 ** Interfaces to register the language extensions.
203 */
204 int th_register_language(Th_Interp *interp); /* th_lang.c */
205 int th_register_sqlite(Th_Interp *interp); /* th_main.c */
206 int th_register_argv(Th_Interp *interp); /* th_main.c */
207 int th_register_vfs(Th_Interp *interp); /* th_vfs.c */
208 int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */
209 int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */
210 int th_register_ob(Th_Interp * interp); /* th.c */
@@ -313,30 +313,21 @@
313 ** Returns TH_OK on success, "something else" on error.
314 */
315 int Th_register_commands( Th_Interp * interp, Th_Command_Reg const * pList );
316
317
318 #ifdef TH_USE_OUTBUF
319 /*
320 ** Manager of a stack of Blob objects for output buffering.
 
321 */
322 struct Th_Ob_Man {
323 Blob ** aBuf; /* Stack of Blobs */
324 int nBuf; /* Number of blobs */
325 int cursor; /* Current level (-1=not active) */
326 Th_Interp * interp; /* The associated interpreter */
327 Th_Vtab_Output * aOutput
328 /* Stack of output routines corresponding
329 to the current buffering level.
330 Has nBuf entries.
331 */;
332 };
333
334 typedef struct Th_Ob_Man Th_Ob_Man;
335
336 /*
337 ** Returns the ob manager for the given interpreter.
 
 
338 */
339 Th_Ob_Man * Th_ob_manager(Th_Interp *ignored);
340
341 /*
342 ** Returns the top-most Blob in pMan's stack, or NULL
@@ -352,15 +343,22 @@
352 */
353 int Th_ob_push( Th_Ob_Man * pMan, Blob ** pOut );
354
355 /*
356 ** Pops the top-most output buffer off the stack and returns
357 ** it. Returns NULL if there is no current buffer. When the last
358 ** buffer is popped, pMan's internals are cleaned up.
 
359 **
360 ** The caller owns the returned object and must eventually call
361 ** blob_reset() on it and Th_Free() it.
362 */
363 Blob * Th_ob_pop( Th_Ob_Man * pMan );
 
 
 
 
 
 
364
365 #endif
366 /* TH_USE_OUTBUF */
367
--- src/th.h
+++ src/th.h
@@ -1,28 +1,28 @@
1 #include "config.h"
2
3 /*
4 ** TH_ENABLE_SQLITE, if defined, enables the "query" family of functions.
5 ** They provide SELECT-only access to the repository db.
6 */
7 #define TH_ENABLE_SQLITE
8
9 /*
10 ** TH_ENABLE_OUTBUF, if defined, enables the "ob" family of functions.
11 ** They are functionally similar to PHP's ob_start(), ob_end(), etc.
12 ** family of functions, providing output capturing/buffering.
13 */
14 #define TH_ENABLE_OUTBUF
15
16 /*
17 ** TH_ENABLE_ARGV, if defined, enables the "argv" family of functions.
18 ** They provide access to CLI arguments as well as GET/POST arguments.
19 ** They do not provide access to POST data submitted in JSON mode.
20 */
21 #define TH_ENABLE_ARGV
22
23 #ifdef TH_ENABLE_OUTBUF
24 #ifndef INTERFACE
25 #include "blob.h"
26 #endif
27 #endif
28
@@ -200,11 +200,11 @@
200
201 /*
202 ** Interfaces to register the language extensions.
203 */
204 int th_register_language(Th_Interp *interp); /* th_lang.c */
205 int th_register_query(Th_Interp *interp); /* th_main.c */
206 int th_register_argv(Th_Interp *interp); /* th_main.c */
207 int th_register_vfs(Th_Interp *interp); /* th_vfs.c */
208 int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */
209 int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */
210 int th_register_ob(Th_Interp * interp); /* th.c */
@@ -313,30 +313,21 @@
313 ** Returns TH_OK on success, "something else" on error.
314 */
315 int Th_register_commands( Th_Interp * interp, Th_Command_Reg const * pList );
316
317
318 #ifdef TH_ENABLE_OUTBUF
319 /*
320 ** Manager of a stack of Blob objects for output buffering.
321 ** See Th_ob_manager().
322 */
 
 
 
 
 
 
 
 
 
 
 
 
323 typedef struct Th_Ob_Man Th_Ob_Man;
324
325 /*
326 ** Returns the ob manager for the given interpreter. The manager gets
327 ** installed by the th_register_ob(). In Fossil ob support is
328 ** installed automatically if it is available at built time.
329 */
330 Th_Ob_Man * Th_ob_manager(Th_Interp *ignored);
331
332 /*
333 ** Returns the top-most Blob in pMan's stack, or NULL
@@ -352,15 +343,22 @@
343 */
344 int Th_ob_push( Th_Ob_Man * pMan, Blob ** pOut );
345
346 /*
347 ** Pops the top-most output buffer off the stack and returns
348 ** it. Returns NULL if there is no current buffer. When the last
349 ** buffer is popped, pMan's internals are cleaned up (but pMan is not
350 ** freed).
351 **
352 ** The caller owns the returned object and must eventually clean it up
353 ** by first passing it to blob_reset() and then Th_Free() it.
354 */
355 Blob * Th_ob_pop( Th_Ob_Man * pMan );
356 /*
357 ** Convenience form of Th_ob_pop() which pops and frees the
358 ** top-most buffer. Returns 0 on success, non-0 if there is no
359 ** stack to pop.
360 */
361 int Th_ob_pop_free( Th_Ob_Man * pMan );
362
363 #endif
364 /* TH_ENABLE_OUTBUF */
365
--- src/th_lang.c
+++ src/th_lang.c
@@ -1055,26 +1055,10 @@
10551055
int cnt = 0;
10561056
cnt++;
10571057
return TH_OK;
10581058
}
10591059
1060
-static int call_command(
1061
- Th_Interp *interp,
1062
- void *ctx,
1063
- int argc,
1064
- const char **argv,
1065
- int *argl
1066
-){
1067
- if( argc<2 ){
1068
- return Th_WrongNumArgs2(interp,
1069
- argv[0], argl[0],
1070
- "funcName ?args...?");
1071
- }
1072
-
1073
-
1074
-}
1075
-
10761060
/*
10771061
** Register the built-in th1 language commands with interpreter interp.
10781062
** Usually this is called soon after interpreter creation.
10791063
*/
10801064
int th_register_language(Th_Interp *interp){
@@ -1105,10 +1089,7 @@
11051089
{"error", simple_command, (void *)TH_ERROR},
11061090
11071091
{0, 0, 0}
11081092
};
11091093
rc = Th_register_commands(interp, aCommand);
1110
-#ifdef TH_USE_OUTBUF
1111
- rc |= th_register_ob(interp);
1112
-#endif
11131094
return rc;
11141095
}
11151096
--- src/th_lang.c
+++ src/th_lang.c
@@ -1055,26 +1055,10 @@
1055 int cnt = 0;
1056 cnt++;
1057 return TH_OK;
1058 }
1059
1060 static int call_command(
1061 Th_Interp *interp,
1062 void *ctx,
1063 int argc,
1064 const char **argv,
1065 int *argl
1066 ){
1067 if( argc<2 ){
1068 return Th_WrongNumArgs2(interp,
1069 argv[0], argl[0],
1070 "funcName ?args...?");
1071 }
1072
1073
1074 }
1075
1076 /*
1077 ** Register the built-in th1 language commands with interpreter interp.
1078 ** Usually this is called soon after interpreter creation.
1079 */
1080 int th_register_language(Th_Interp *interp){
@@ -1105,10 +1089,7 @@
1105 {"error", simple_command, (void *)TH_ERROR},
1106
1107 {0, 0, 0}
1108 };
1109 rc = Th_register_commands(interp, aCommand);
1110 #ifdef TH_USE_OUTBUF
1111 rc |= th_register_ob(interp);
1112 #endif
1113 return rc;
1114 }
1115
--- src/th_lang.c
+++ src/th_lang.c
@@ -1055,26 +1055,10 @@
1055 int cnt = 0;
1056 cnt++;
1057 return TH_OK;
1058 }
1059
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1060 /*
1061 ** Register the built-in th1 language commands with interpreter interp.
1062 ** Usually this is called soon after interpreter creation.
1063 */
1064 int th_register_language(Th_Interp *interp){
@@ -1105,10 +1089,7 @@
1089 {"error", simple_command, (void *)TH_ERROR},
1090
1091 {0, 0, 0}
1092 };
1093 rc = Th_register_commands(interp, aCommand);
 
 
 
1094 return rc;
1095 }
1096
+13 -10
--- src/th_main.c
+++ src/th_main.c
@@ -21,11 +21,11 @@
2121
#include "config.h"
2222
#include "th_main.h"
2323
#ifndef INTERFACE
2424
#include "blob.h"
2525
#endif
26
-#ifdef TH_USE_SQLITE
26
+#ifdef TH_ENABLE_SQLITE
2727
#include "sqlite3.h"
2828
#endif
2929
3030
/*#include "th_main.h"*/
3131
/*
@@ -542,11 +542,11 @@
542542
Th_SetResult(interp, g.zRepositoryName, -1);
543543
return TH_OK;
544544
}
545545
546546
547
-#ifdef TH_USE_ARGV
547
+#ifdef TH_ENABLE_ARGV
548548
extern const char *find_option(const char *zLong,
549549
const char *zShort,
550550
int hasArg) /* from main.c */;
551551
/*
552552
** TH Syntax:
@@ -837,13 +837,13 @@
837837
};
838838
Th_register_commands( interp, aCommand );
839839
}
840840
841841
#endif
842
-/* end TH_USE_ARGV */
842
+/* end TH_ENABLE_ARGV */
843843
844
-#ifdef TH_USE_SQLITE
844
+#ifdef TH_ENABLE_SQLITE
845845
846846
/*
847847
** Adds the given prepared statement to the interpreter. Returns the
848848
** statements opaque identifier (a positive value). Ownerships of
849849
** pStmt is transfered to interp and it must be cleaned up by the
@@ -1674,11 +1674,11 @@
16741674
assert( NULL != sq );
16751675
Th_CallSubCommand2( interp, sq, argc, argv, argl, aSub );
16761676
}
16771677
16781678
1679
-int th_register_sqlite(Th_Interp *interp){
1679
+int th_register_query(Th_Interp *interp){
16801680
enum { BufLen = 100 };
16811681
char buf[BufLen];
16821682
int i, l;
16831683
#define SET(K) l = snprintf(buf, BufLen, "%d", K); \
16841684
Th_SetVar( interp, #K, strlen(#K), buf, l );
@@ -1711,11 +1711,11 @@
17111711
}
17121712
return rc;
17131713
}
17141714
17151715
#endif
1716
-/* end TH_USE_SQLITE */
1716
+/* end TH_ENABLE_SQLITE */
17171717
17181718
int Th_register_commands( Th_Interp * interp,
17191719
Th_Command_Reg const * aCommand ){
17201720
int i;
17211721
int rc = TH_OK;
@@ -1772,14 +1772,17 @@
17721772
#ifdef FOSSIL_ENABLE_TCL
17731773
if( getenv("TH1_ENABLE_TCL")!=0 || db_get_boolean("tcl", 0) ){
17741774
th_register_tcl(g.interp, &g.tcl); /* Tcl integration commands. */
17751775
}
17761776
#endif
1777
-#ifdef TH_USE_SQLITE
1778
- th_register_sqlite(g.interp);
1777
+#ifdef TH_ENABLE_OUTBUF
1778
+ th_register_ob(g.interp);
1779
+#endif
1780
+#ifdef TH_ENABLE_SQLITE
1781
+ th_register_query(g.interp);
17791782
#endif
1780
-#ifdef TH_USE_ARGV
1783
+#ifdef TH_ENABLE_ARGV
17811784
th_register_argv(g.interp);
17821785
#endif
17831786
Th_register_commands( g.interp, aCommand );
17841787
Th_Eval( g.interp, 0, "proc incr {name {step 1}} {\n"
17851788
"upvar $name x\n"
@@ -1962,12 +1965,12 @@
19621965
usage("FILE");
19631966
assert(0 && "usage() does not return");
19641967
}
19651968
blob_zero(&in);
19661969
db_open_config(0); /* Needed for global "tcl" setting. */
1967
-#ifdef TH_USE_SQLITE
1970
+#ifdef TH_ENABLE_SQLITE
19681971
db_find_and_open_repository(OPEN_ANY_SCHEMA,0)
19691972
/* required for th1 query API. */;
19701973
#endif
19711974
blob_read_from_file(&in, g.argv[2]);
19721975
Th_Render(blob_str(&in), Th_Render_Flags_DEFAULT);
19731976
}
19741977
--- src/th_main.c
+++ src/th_main.c
@@ -21,11 +21,11 @@
21 #include "config.h"
22 #include "th_main.h"
23 #ifndef INTERFACE
24 #include "blob.h"
25 #endif
26 #ifdef TH_USE_SQLITE
27 #include "sqlite3.h"
28 #endif
29
30 /*#include "th_main.h"*/
31 /*
@@ -542,11 +542,11 @@
542 Th_SetResult(interp, g.zRepositoryName, -1);
543 return TH_OK;
544 }
545
546
547 #ifdef TH_USE_ARGV
548 extern const char *find_option(const char *zLong,
549 const char *zShort,
550 int hasArg) /* from main.c */;
551 /*
552 ** TH Syntax:
@@ -837,13 +837,13 @@
837 };
838 Th_register_commands( interp, aCommand );
839 }
840
841 #endif
842 /* end TH_USE_ARGV */
843
844 #ifdef TH_USE_SQLITE
845
846 /*
847 ** Adds the given prepared statement to the interpreter. Returns the
848 ** statements opaque identifier (a positive value). Ownerships of
849 ** pStmt is transfered to interp and it must be cleaned up by the
@@ -1674,11 +1674,11 @@
1674 assert( NULL != sq );
1675 Th_CallSubCommand2( interp, sq, argc, argv, argl, aSub );
1676 }
1677
1678
1679 int th_register_sqlite(Th_Interp *interp){
1680 enum { BufLen = 100 };
1681 char buf[BufLen];
1682 int i, l;
1683 #define SET(K) l = snprintf(buf, BufLen, "%d", K); \
1684 Th_SetVar( interp, #K, strlen(#K), buf, l );
@@ -1711,11 +1711,11 @@
1711 }
1712 return rc;
1713 }
1714
1715 #endif
1716 /* end TH_USE_SQLITE */
1717
1718 int Th_register_commands( Th_Interp * interp,
1719 Th_Command_Reg const * aCommand ){
1720 int i;
1721 int rc = TH_OK;
@@ -1772,14 +1772,17 @@
1772 #ifdef FOSSIL_ENABLE_TCL
1773 if( getenv("TH1_ENABLE_TCL")!=0 || db_get_boolean("tcl", 0) ){
1774 th_register_tcl(g.interp, &g.tcl); /* Tcl integration commands. */
1775 }
1776 #endif
1777 #ifdef TH_USE_SQLITE
1778 th_register_sqlite(g.interp);
 
 
 
1779 #endif
1780 #ifdef TH_USE_ARGV
1781 th_register_argv(g.interp);
1782 #endif
1783 Th_register_commands( g.interp, aCommand );
1784 Th_Eval( g.interp, 0, "proc incr {name {step 1}} {\n"
1785 "upvar $name x\n"
@@ -1962,12 +1965,12 @@
1962 usage("FILE");
1963 assert(0 && "usage() does not return");
1964 }
1965 blob_zero(&in);
1966 db_open_config(0); /* Needed for global "tcl" setting. */
1967 #ifdef TH_USE_SQLITE
1968 db_find_and_open_repository(OPEN_ANY_SCHEMA,0)
1969 /* required for th1 query API. */;
1970 #endif
1971 blob_read_from_file(&in, g.argv[2]);
1972 Th_Render(blob_str(&in), Th_Render_Flags_DEFAULT);
1973 }
1974
--- src/th_main.c
+++ src/th_main.c
@@ -21,11 +21,11 @@
21 #include "config.h"
22 #include "th_main.h"
23 #ifndef INTERFACE
24 #include "blob.h"
25 #endif
26 #ifdef TH_ENABLE_SQLITE
27 #include "sqlite3.h"
28 #endif
29
30 /*#include "th_main.h"*/
31 /*
@@ -542,11 +542,11 @@
542 Th_SetResult(interp, g.zRepositoryName, -1);
543 return TH_OK;
544 }
545
546
547 #ifdef TH_ENABLE_ARGV
548 extern const char *find_option(const char *zLong,
549 const char *zShort,
550 int hasArg) /* from main.c */;
551 /*
552 ** TH Syntax:
@@ -837,13 +837,13 @@
837 };
838 Th_register_commands( interp, aCommand );
839 }
840
841 #endif
842 /* end TH_ENABLE_ARGV */
843
844 #ifdef TH_ENABLE_SQLITE
845
846 /*
847 ** Adds the given prepared statement to the interpreter. Returns the
848 ** statements opaque identifier (a positive value). Ownerships of
849 ** pStmt is transfered to interp and it must be cleaned up by the
@@ -1674,11 +1674,11 @@
1674 assert( NULL != sq );
1675 Th_CallSubCommand2( interp, sq, argc, argv, argl, aSub );
1676 }
1677
1678
1679 int th_register_query(Th_Interp *interp){
1680 enum { BufLen = 100 };
1681 char buf[BufLen];
1682 int i, l;
1683 #define SET(K) l = snprintf(buf, BufLen, "%d", K); \
1684 Th_SetVar( interp, #K, strlen(#K), buf, l );
@@ -1711,11 +1711,11 @@
1711 }
1712 return rc;
1713 }
1714
1715 #endif
1716 /* end TH_ENABLE_SQLITE */
1717
1718 int Th_register_commands( Th_Interp * interp,
1719 Th_Command_Reg const * aCommand ){
1720 int i;
1721 int rc = TH_OK;
@@ -1772,14 +1772,17 @@
1772 #ifdef FOSSIL_ENABLE_TCL
1773 if( getenv("TH1_ENABLE_TCL")!=0 || db_get_boolean("tcl", 0) ){
1774 th_register_tcl(g.interp, &g.tcl); /* Tcl integration commands. */
1775 }
1776 #endif
1777 #ifdef TH_ENABLE_OUTBUF
1778 th_register_ob(g.interp);
1779 #endif
1780 #ifdef TH_ENABLE_SQLITE
1781 th_register_query(g.interp);
1782 #endif
1783 #ifdef TH_ENABLE_ARGV
1784 th_register_argv(g.interp);
1785 #endif
1786 Th_register_commands( g.interp, aCommand );
1787 Th_Eval( g.interp, 0, "proc incr {name {step 1}} {\n"
1788 "upvar $name x\n"
@@ -1962,12 +1965,12 @@
1965 usage("FILE");
1966 assert(0 && "usage() does not return");
1967 }
1968 blob_zero(&in);
1969 db_open_config(0); /* Needed for global "tcl" setting. */
1970 #ifdef TH_ENABLE_SQLITE
1971 db_find_and_open_repository(OPEN_ANY_SCHEMA,0)
1972 /* required for th1 query API. */;
1973 #endif
1974 blob_read_from_file(&in, g.argv[2]);
1975 Th_Render(blob_str(&in), Th_Render_Flags_DEFAULT);
1976 }
1977

Keyboard Shortcuts

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