Fossil SCM

Cherrypicked [2ee87308], which was intended for the trunk.

stephan 2021-06-15 14:25 trunk
Commit 6456fab6fe3b95f37e6ab59bc5d88852720f7eda277d18cee632b32d98dd1e75
1 file changed +12 -2
+12 -2
--- src/th_main.c
+++ src/th_main.c
@@ -2976,11 +2976,12 @@
29762976
** COMMAND: test-th-eval
29772977
**
29782978
** Usage: %fossil test-th-eval SCRIPT
29792979
**
29802980
** Evaluate SCRIPT as if it were a header or footer or ticket rendering
2981
-** script and show the results on standard output.
2981
+** script and show the results on standard output. SCRIPT may be either
2982
+** a filename or a string of th1 script code.
29822983
**
29832984
** Options:
29842985
**
29852986
** --cgi Include a CGI response header in the output
29862987
** --http Include an HTTP response header in the output
@@ -2990,11 +2991,13 @@
29902991
** --th-trace Trace TH1 execution (for debugging purposes)
29912992
*/
29922993
void test_th_eval(void){
29932994
int rc;
29942995
const char *zRc;
2996
+ const char *zCode = 0;
29952997
int forceCgi, fullHttpReply;
2998
+ Blob code = empty_blob;
29962999
Th_InitTraceLog();
29973000
forceCgi = find_option("cgi", 0, 0)!=0;
29983001
fullHttpReply = find_option("http", 0, 0)!=0;
29993002
if( fullHttpReply ) forceCgi = 1;
30003003
if( forceCgi ) Th_ForceCgi(fullHttpReply);
@@ -3012,16 +3015,23 @@
30123015
g.useLocalauth = 1;
30133016
}
30143017
verify_all_options();
30153018
if( g.argc!=3 ){
30163019
usage("script");
3020
+ }
3021
+ if(file_isfile(g.argv[2], ExtFILE)){
3022
+ blob_read_from_file(&code, g.argv[2], ExtFILE);
3023
+ zCode = blob_str(&code);
3024
+ }else{
3025
+ zCode = g.argv[2];
30173026
}
30183027
Th_FossilInit(TH_INIT_DEFAULT);
3019
- rc = Th_Eval(g.interp, 0, g.argv[2], -1);
3028
+ rc = Th_Eval(g.interp, 0, zCode, -1);
30203029
zRc = Th_ReturnCodeName(rc, 1);
30213030
fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
30223031
Th_PrintTraceLog();
3032
+ blob_reset(&code);
30233033
if( forceCgi ) cgi_reply();
30243034
}
30253035
30263036
/*
30273037
** COMMAND: test-th-source
30283038
--- src/th_main.c
+++ src/th_main.c
@@ -2976,11 +2976,12 @@
2976 ** COMMAND: test-th-eval
2977 **
2978 ** Usage: %fossil test-th-eval SCRIPT
2979 **
2980 ** Evaluate SCRIPT as if it were a header or footer or ticket rendering
2981 ** script and show the results on standard output.
 
2982 **
2983 ** Options:
2984 **
2985 ** --cgi Include a CGI response header in the output
2986 ** --http Include an HTTP response header in the output
@@ -2990,11 +2991,13 @@
2990 ** --th-trace Trace TH1 execution (for debugging purposes)
2991 */
2992 void test_th_eval(void){
2993 int rc;
2994 const char *zRc;
 
2995 int forceCgi, fullHttpReply;
 
2996 Th_InitTraceLog();
2997 forceCgi = find_option("cgi", 0, 0)!=0;
2998 fullHttpReply = find_option("http", 0, 0)!=0;
2999 if( fullHttpReply ) forceCgi = 1;
3000 if( forceCgi ) Th_ForceCgi(fullHttpReply);
@@ -3012,16 +3015,23 @@
3012 g.useLocalauth = 1;
3013 }
3014 verify_all_options();
3015 if( g.argc!=3 ){
3016 usage("script");
 
 
 
 
 
 
3017 }
3018 Th_FossilInit(TH_INIT_DEFAULT);
3019 rc = Th_Eval(g.interp, 0, g.argv[2], -1);
3020 zRc = Th_ReturnCodeName(rc, 1);
3021 fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
3022 Th_PrintTraceLog();
 
3023 if( forceCgi ) cgi_reply();
3024 }
3025
3026 /*
3027 ** COMMAND: test-th-source
3028
--- src/th_main.c
+++ src/th_main.c
@@ -2976,11 +2976,12 @@
2976 ** COMMAND: test-th-eval
2977 **
2978 ** Usage: %fossil test-th-eval SCRIPT
2979 **
2980 ** Evaluate SCRIPT as if it were a header or footer or ticket rendering
2981 ** script and show the results on standard output. SCRIPT may be either
2982 ** a filename or a string of th1 script code.
2983 **
2984 ** Options:
2985 **
2986 ** --cgi Include a CGI response header in the output
2987 ** --http Include an HTTP response header in the output
@@ -2990,11 +2991,13 @@
2991 ** --th-trace Trace TH1 execution (for debugging purposes)
2992 */
2993 void test_th_eval(void){
2994 int rc;
2995 const char *zRc;
2996 const char *zCode = 0;
2997 int forceCgi, fullHttpReply;
2998 Blob code = empty_blob;
2999 Th_InitTraceLog();
3000 forceCgi = find_option("cgi", 0, 0)!=0;
3001 fullHttpReply = find_option("http", 0, 0)!=0;
3002 if( fullHttpReply ) forceCgi = 1;
3003 if( forceCgi ) Th_ForceCgi(fullHttpReply);
@@ -3012,16 +3015,23 @@
3015 g.useLocalauth = 1;
3016 }
3017 verify_all_options();
3018 if( g.argc!=3 ){
3019 usage("script");
3020 }
3021 if(file_isfile(g.argv[2], ExtFILE)){
3022 blob_read_from_file(&code, g.argv[2], ExtFILE);
3023 zCode = blob_str(&code);
3024 }else{
3025 zCode = g.argv[2];
3026 }
3027 Th_FossilInit(TH_INIT_DEFAULT);
3028 rc = Th_Eval(g.interp, 0, zCode, -1);
3029 zRc = Th_ReturnCodeName(rc, 1);
3030 fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
3031 Th_PrintTraceLog();
3032 blob_reset(&code);
3033 if( forceCgi ) cgi_reply();
3034 }
3035
3036 /*
3037 ** COMMAND: test-th-source
3038

Keyboard Shortcuts

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