Fossil SCM

Add the [string trim ...] command to TH1. Accept query parameters in tktview.

drh 2012-11-23 16:37 UTC ticket-enhancements
Commit 7ba3f653822d98843f02693e9f6eb638034684b2
2 files changed +23 +1
--- src/th_lang.c
+++ src/th_lang.c
@@ -817,10 +817,32 @@
817817
return TH_OK;
818818
}
819819
820820
/*
821821
** 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:
822844
**
823845
** info exists VAR
824846
*/
825847
static int info_exists_command(
826848
Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
@@ -897,10 +919,11 @@
897919
{ "is", string_is_command },
898920
{ "last", string_last_command },
899921
{ "length", string_length_command },
900922
{ "range", string_range_command },
901923
{ "repeat", string_repeat_command },
924
+ { "trim", string_trim_command },
902925
{ 0, 0 }
903926
};
904927
return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub);
905928
}
906929
907930
--- 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 @@
325325
g.zTop, zUuid, g.zTop, zUuid);
326326
}
327327
style_header("View Ticket");
328328
if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW<br />\n", -1);
329329
ticket_init();
330
+ initializeVariablesFromCGI();
330331
initializeVariablesFromDb();
331332
zScript = ticket_viewpage_code();
332333
if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW_SCRIPT<br />\n", -1);
333334
Th_Render(zScript);
334335
if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1);
335336
--- 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

Keyboard Shortcuts

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