Fossil SCM
Cherrypicked [2ee87308], which was intended for the trunk.
Commit
6456fab6fe3b95f37e6ab59bc5d88852720f7eda277d18cee632b32d98dd1e75
Parent
f8f54535d5e9eb7…
1 file changed
+12
-2
+12
-2
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -2976,11 +2976,12 @@ | ||
| 2976 | 2976 | ** COMMAND: test-th-eval |
| 2977 | 2977 | ** |
| 2978 | 2978 | ** Usage: %fossil test-th-eval SCRIPT |
| 2979 | 2979 | ** |
| 2980 | 2980 | ** 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. | |
| 2982 | 2983 | ** |
| 2983 | 2984 | ** Options: |
| 2984 | 2985 | ** |
| 2985 | 2986 | ** --cgi Include a CGI response header in the output |
| 2986 | 2987 | ** --http Include an HTTP response header in the output |
| @@ -2990,11 +2991,13 @@ | ||
| 2990 | 2991 | ** --th-trace Trace TH1 execution (for debugging purposes) |
| 2991 | 2992 | */ |
| 2992 | 2993 | void test_th_eval(void){ |
| 2993 | 2994 | int rc; |
| 2994 | 2995 | const char *zRc; |
| 2996 | + const char *zCode = 0; | |
| 2995 | 2997 | int forceCgi, fullHttpReply; |
| 2998 | + Blob code = empty_blob; | |
| 2996 | 2999 | Th_InitTraceLog(); |
| 2997 | 3000 | forceCgi = find_option("cgi", 0, 0)!=0; |
| 2998 | 3001 | fullHttpReply = find_option("http", 0, 0)!=0; |
| 2999 | 3002 | if( fullHttpReply ) forceCgi = 1; |
| 3000 | 3003 | if( forceCgi ) Th_ForceCgi(fullHttpReply); |
| @@ -3012,16 +3015,23 @@ | ||
| 3012 | 3015 | g.useLocalauth = 1; |
| 3013 | 3016 | } |
| 3014 | 3017 | verify_all_options(); |
| 3015 | 3018 | if( g.argc!=3 ){ |
| 3016 | 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]; | |
| 3017 | 3026 | } |
| 3018 | 3027 | 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); | |
| 3020 | 3029 | zRc = Th_ReturnCodeName(rc, 1); |
| 3021 | 3030 | fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0)); |
| 3022 | 3031 | Th_PrintTraceLog(); |
| 3032 | + blob_reset(&code); | |
| 3023 | 3033 | if( forceCgi ) cgi_reply(); |
| 3024 | 3034 | } |
| 3025 | 3035 | |
| 3026 | 3036 | /* |
| 3027 | 3037 | ** COMMAND: test-th-source |
| 3028 | 3038 |
| --- 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 |