Fossil SCM
Add the [string trim ...] command to TH1. Accept query parameters in tktview.
Commit
7ba3f653822d98843f02693e9f6eb638034684b2
Parent
23c75abde4e26af…
2 files changed
+23
+1
+23
| --- src/th_lang.c | ||
| +++ src/th_lang.c | ||
| @@ -817,10 +817,32 @@ | ||
| 817 | 817 | return TH_OK; |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | /* |
| 821 | 821 | ** TH Syntax: |
| 822 | +** | |
| 823 | +** string trim STRING | |
| 824 | +*/ | |
| 825 | +static int string_trim_command( | |
| 826 | + Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl | |
| 827 | +){ | |
| 828 | + int n; | |
| 829 | + const char *z; | |
| 830 | + | |
| 831 | + if( argc!=3 ){ | |
| 832 | + return Th_WrongNumArgs(interp, "string trim string"); | |
| 833 | + } | |
| 834 | + z = argv[2]; | |
| 835 | + n = argl[2]; | |
| 836 | + while( n && th_isspace(z[0]) ){ z++; n--; } | |
| 837 | + while( n && th_isspace(z[n-1]) ){ n--; } | |
| 838 | + Th_SetResult(interp, z, n); | |
| 839 | + return TH_OK; | |
| 840 | +} | |
| 841 | + | |
| 842 | +/* | |
| 843 | +** TH Syntax: | |
| 822 | 844 | ** |
| 823 | 845 | ** info exists VAR |
| 824 | 846 | */ |
| 825 | 847 | static int info_exists_command( |
| 826 | 848 | Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl |
| @@ -897,10 +919,11 @@ | ||
| 897 | 919 | { "is", string_is_command }, |
| 898 | 920 | { "last", string_last_command }, |
| 899 | 921 | { "length", string_length_command }, |
| 900 | 922 | { "range", string_range_command }, |
| 901 | 923 | { "repeat", string_repeat_command }, |
| 924 | + { "trim", string_trim_command }, | |
| 902 | 925 | { 0, 0 } |
| 903 | 926 | }; |
| 904 | 927 | return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub); |
| 905 | 928 | } |
| 906 | 929 | |
| 907 | 930 |
| --- src/th_lang.c | |
| +++ src/th_lang.c | |
| @@ -817,10 +817,32 @@ | |
| 817 | return TH_OK; |
| 818 | } |
| 819 | |
| 820 | /* |
| 821 | ** TH Syntax: |
| 822 | ** |
| 823 | ** info exists VAR |
| 824 | */ |
| 825 | static int info_exists_command( |
| 826 | Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl |
| @@ -897,10 +919,11 @@ | |
| 897 | { "is", string_is_command }, |
| 898 | { "last", string_last_command }, |
| 899 | { "length", string_length_command }, |
| 900 | { "range", string_range_command }, |
| 901 | { "repeat", string_repeat_command }, |
| 902 | { 0, 0 } |
| 903 | }; |
| 904 | return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub); |
| 905 | } |
| 906 | |
| 907 |
| --- src/th_lang.c | |
| +++ src/th_lang.c | |
| @@ -817,10 +817,32 @@ | |
| 817 | return TH_OK; |
| 818 | } |
| 819 | |
| 820 | /* |
| 821 | ** TH Syntax: |
| 822 | ** |
| 823 | ** string trim STRING |
| 824 | */ |
| 825 | static int string_trim_command( |
| 826 | Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl |
| 827 | ){ |
| 828 | int n; |
| 829 | const char *z; |
| 830 | |
| 831 | if( argc!=3 ){ |
| 832 | return Th_WrongNumArgs(interp, "string trim string"); |
| 833 | } |
| 834 | z = argv[2]; |
| 835 | n = argl[2]; |
| 836 | while( n && th_isspace(z[0]) ){ z++; n--; } |
| 837 | while( n && th_isspace(z[n-1]) ){ n--; } |
| 838 | Th_SetResult(interp, z, n); |
| 839 | return TH_OK; |
| 840 | } |
| 841 | |
| 842 | /* |
| 843 | ** TH Syntax: |
| 844 | ** |
| 845 | ** info exists VAR |
| 846 | */ |
| 847 | static int info_exists_command( |
| 848 | Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl |
| @@ -897,10 +919,11 @@ | |
| 919 | { "is", string_is_command }, |
| 920 | { "last", string_last_command }, |
| 921 | { "length", string_length_command }, |
| 922 | { "range", string_range_command }, |
| 923 | { "repeat", string_repeat_command }, |
| 924 | { "trim", string_trim_command }, |
| 925 | { 0, 0 } |
| 926 | }; |
| 927 | return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub); |
| 928 | } |
| 929 | |
| 930 |
+1
| --- src/tkt.c | ||
| +++ src/tkt.c | ||
| @@ -325,10 +325,11 @@ | ||
| 325 | 325 | g.zTop, zUuid, g.zTop, zUuid); |
| 326 | 326 | } |
| 327 | 327 | style_header("View Ticket"); |
| 328 | 328 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW<br />\n", -1); |
| 329 | 329 | ticket_init(); |
| 330 | + initializeVariablesFromCGI(); | |
| 330 | 331 | initializeVariablesFromDb(); |
| 331 | 332 | zScript = ticket_viewpage_code(); |
| 332 | 333 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW_SCRIPT<br />\n", -1); |
| 333 | 334 | Th_Render(zScript); |
| 334 | 335 | if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1); |
| 335 | 336 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -325,10 +325,11 @@ | |
| 325 | g.zTop, zUuid, g.zTop, zUuid); |
| 326 | } |
| 327 | style_header("View Ticket"); |
| 328 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW<br />\n", -1); |
| 329 | ticket_init(); |
| 330 | initializeVariablesFromDb(); |
| 331 | zScript = ticket_viewpage_code(); |
| 332 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW_SCRIPT<br />\n", -1); |
| 333 | Th_Render(zScript); |
| 334 | if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1); |
| 335 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -325,10 +325,11 @@ | |
| 325 | g.zTop, zUuid, g.zTop, zUuid); |
| 326 | } |
| 327 | style_header("View Ticket"); |
| 328 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW<br />\n", -1); |
| 329 | ticket_init(); |
| 330 | initializeVariablesFromCGI(); |
| 331 | initializeVariablesFromDb(); |
| 332 | zScript = ticket_viewpage_code(); |
| 333 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW_SCRIPT<br />\n", -1); |
| 334 | Th_Render(zScript); |
| 335 | if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1); |
| 336 |