Fossil SCM

Add the "httpize" TH1 command, which does the same as Javascript's encodeURIComponent() function.

jan.nijtmans 2014-02-06 15:02 trunk
Commit fc6bb9368953e5b6f9ebc8d97088ab320a90dc0e
1 file changed +24
--- src/th_main.c
+++ src/th_main.c
@@ -97,10 +97,33 @@
9797
fossil_print("\n------------------ BEGIN TRACE LOG ------------------\n");
9898
fossil_print("%s", blob_str(&g.thLog));
9999
fossil_print("\n------------------- END TRACE LOG -------------------\n");
100100
}
101101
}
102
+
103
+/*
104
+** TH command: httpize STRING
105
+**
106
+** Escape all characters of STRING which have special meaning in URI
107
+** components. Return a new string result.
108
+*/
109
+static int httpizeCmd(
110
+ Th_Interp *interp,
111
+ void *p,
112
+ int argc,
113
+ const char **argv,
114
+ int *argl
115
+){
116
+ char *zOut;
117
+ if( argc!=2 ){
118
+ return Th_WrongNumArgs(interp, "httpize STRING");
119
+ }
120
+ zOut = httpize((char*)argv[1], argl[1]);
121
+ Th_SetResult(interp, zOut, -1);
122
+ free(zOut);
123
+ return TH_OK;
124
+}
102125
103126
/*
104127
** True if output is enabled. False if disabled.
105128
*/
106129
static int enableOutput = 1;
@@ -972,10 +995,11 @@
972995
{"anycap", anycapCmd, 0},
973996
{"combobox", comboboxCmd, 0},
974997
{"date", dateCmd, 0},
975998
{"decorate", wikiCmd, (void*)&aFlags[2]},
976999
{"enable_output", enableOutputCmd, 0},
1000
+ {"httpize", httpizeCmd, 0},
9771001
{"hascap", hascapCmd, 0},
9781002
{"hasfeature", hasfeatureCmd, 0},
9791003
{"html", putsCmd, (void*)&aFlags[0]},
9801004
{"htmlize", htmlizeCmd, 0},
9811005
{"http", httpCmd, 0},
9821006
--- src/th_main.c
+++ src/th_main.c
@@ -97,10 +97,33 @@
97 fossil_print("\n------------------ BEGIN TRACE LOG ------------------\n");
98 fossil_print("%s", blob_str(&g.thLog));
99 fossil_print("\n------------------- END TRACE LOG -------------------\n");
100 }
101 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
103 /*
104 ** True if output is enabled. False if disabled.
105 */
106 static int enableOutput = 1;
@@ -972,10 +995,11 @@
972 {"anycap", anycapCmd, 0},
973 {"combobox", comboboxCmd, 0},
974 {"date", dateCmd, 0},
975 {"decorate", wikiCmd, (void*)&aFlags[2]},
976 {"enable_output", enableOutputCmd, 0},
 
977 {"hascap", hascapCmd, 0},
978 {"hasfeature", hasfeatureCmd, 0},
979 {"html", putsCmd, (void*)&aFlags[0]},
980 {"htmlize", htmlizeCmd, 0},
981 {"http", httpCmd, 0},
982
--- src/th_main.c
+++ src/th_main.c
@@ -97,10 +97,33 @@
97 fossil_print("\n------------------ BEGIN TRACE LOG ------------------\n");
98 fossil_print("%s", blob_str(&g.thLog));
99 fossil_print("\n------------------- END TRACE LOG -------------------\n");
100 }
101 }
102
103 /*
104 ** TH command: httpize STRING
105 **
106 ** Escape all characters of STRING which have special meaning in URI
107 ** components. Return a new string result.
108 */
109 static int httpizeCmd(
110 Th_Interp *interp,
111 void *p,
112 int argc,
113 const char **argv,
114 int *argl
115 ){
116 char *zOut;
117 if( argc!=2 ){
118 return Th_WrongNumArgs(interp, "httpize STRING");
119 }
120 zOut = httpize((char*)argv[1], argl[1]);
121 Th_SetResult(interp, zOut, -1);
122 free(zOut);
123 return TH_OK;
124 }
125
126 /*
127 ** True if output is enabled. False if disabled.
128 */
129 static int enableOutput = 1;
@@ -972,10 +995,11 @@
995 {"anycap", anycapCmd, 0},
996 {"combobox", comboboxCmd, 0},
997 {"date", dateCmd, 0},
998 {"decorate", wikiCmd, (void*)&aFlags[2]},
999 {"enable_output", enableOutputCmd, 0},
1000 {"httpize", httpizeCmd, 0},
1001 {"hascap", hascapCmd, 0},
1002 {"hasfeature", hasfeatureCmd, 0},
1003 {"html", putsCmd, (void*)&aFlags[0]},
1004 {"htmlize", htmlizeCmd, 0},
1005 {"http", httpCmd, 0},
1006

Keyboard Shortcuts

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