Fossil SCM

Renamed --format|-F to --mimetype|-M. Stumbled across a char-is-signed assumption and replaced it with (int).

stephan 2014-05-30 18:04 UTC wiki-keep-mimetype
Commit 918d07bface57b3cc27d9fd8862da8fd5d93ca9c
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -245,29 +245,29 @@
245245
** If the "format" (CLI: -f) flag is set function returns the same as
246246
** json_wiki_get_content_format_flag(), else it returns true (non-0)
247247
** if either the includeContent (HTTP) or -content|-c boolean flags
248248
** (CLI) are set.
249249
*/
250
-static char json_artifact_get_content_format_flag(){
250
+static int json_artifact_get_content_format_flag(){
251251
enum { MagicValue = -9 };
252
- char contentFormat = json_wiki_get_content_format_flag(MagicValue);
252
+ int contentFormat = json_wiki_get_content_format_flag(MagicValue);
253253
if(MagicValue == contentFormat){
254254
contentFormat = json_find_option_bool("includeContent","content","c",0) /* deprecated */ ? -1 : 0;
255255
}
256256
return contentFormat;
257257
}
258258
259
-extern char json_wiki_get_content_format_flag( char defaultValue ) /* json_wiki.c */;
259
+extern int json_wiki_get_content_format_flag( int defaultValue ) /* json_wiki.c */;
260260
261261
cson_value * json_artifact_wiki(cson_object * zParent, int rid){
262262
if( ! g.perm.RdWiki ){
263263
json_set_err(FSL_JSON_E_DENIED,
264264
"Requires 'j' privileges.");
265265
return NULL;
266266
}else{
267267
enum { MagicValue = -9 };
268
- char const contentFormat = json_artifact_get_content_format_flag();
268
+ int const contentFormat = json_artifact_get_content_format_flag();
269269
return json_get_wiki_page_by_rid(rid, contentFormat);
270270
}
271271
}
272272
273273
/*
@@ -289,11 +289,11 @@
289289
290290
cson_value * json_artifact_file(cson_object * zParent, int rid){
291291
cson_object * pay = NULL;
292292
Stmt q = empty_Stmt;
293293
cson_array * checkin_arr = NULL;
294
- char contentFormat;
294
+ int contentFormat;
295295
i64 contentSize = -1;
296296
char * parentUuid;
297297
if( ! g.perm.Read ){
298298
json_set_err(FSL_JSON_E_DENIED,
299299
"Requires 'o' privileges.");
300300
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -245,29 +245,29 @@
245 ** If the "format" (CLI: -f) flag is set function returns the same as
246 ** json_wiki_get_content_format_flag(), else it returns true (non-0)
247 ** if either the includeContent (HTTP) or -content|-c boolean flags
248 ** (CLI) are set.
249 */
250 static char json_artifact_get_content_format_flag(){
251 enum { MagicValue = -9 };
252 char contentFormat = json_wiki_get_content_format_flag(MagicValue);
253 if(MagicValue == contentFormat){
254 contentFormat = json_find_option_bool("includeContent","content","c",0) /* deprecated */ ? -1 : 0;
255 }
256 return contentFormat;
257 }
258
259 extern char json_wiki_get_content_format_flag( char defaultValue ) /* json_wiki.c */;
260
261 cson_value * json_artifact_wiki(cson_object * zParent, int rid){
262 if( ! g.perm.RdWiki ){
263 json_set_err(FSL_JSON_E_DENIED,
264 "Requires 'j' privileges.");
265 return NULL;
266 }else{
267 enum { MagicValue = -9 };
268 char const contentFormat = json_artifact_get_content_format_flag();
269 return json_get_wiki_page_by_rid(rid, contentFormat);
270 }
271 }
272
273 /*
@@ -289,11 +289,11 @@
289
290 cson_value * json_artifact_file(cson_object * zParent, int rid){
291 cson_object * pay = NULL;
292 Stmt q = empty_Stmt;
293 cson_array * checkin_arr = NULL;
294 char contentFormat;
295 i64 contentSize = -1;
296 char * parentUuid;
297 if( ! g.perm.Read ){
298 json_set_err(FSL_JSON_E_DENIED,
299 "Requires 'o' privileges.");
300
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -245,29 +245,29 @@
245 ** If the "format" (CLI: -f) flag is set function returns the same as
246 ** json_wiki_get_content_format_flag(), else it returns true (non-0)
247 ** if either the includeContent (HTTP) or -content|-c boolean flags
248 ** (CLI) are set.
249 */
250 static int json_artifact_get_content_format_flag(){
251 enum { MagicValue = -9 };
252 int contentFormat = json_wiki_get_content_format_flag(MagicValue);
253 if(MagicValue == contentFormat){
254 contentFormat = json_find_option_bool("includeContent","content","c",0) /* deprecated */ ? -1 : 0;
255 }
256 return contentFormat;
257 }
258
259 extern int json_wiki_get_content_format_flag( int defaultValue ) /* json_wiki.c */;
260
261 cson_value * json_artifact_wiki(cson_object * zParent, int rid){
262 if( ! g.perm.RdWiki ){
263 json_set_err(FSL_JSON_E_DENIED,
264 "Requires 'j' privileges.");
265 return NULL;
266 }else{
267 enum { MagicValue = -9 };
268 int const contentFormat = json_artifact_get_content_format_flag();
269 return json_get_wiki_page_by_rid(rid, contentFormat);
270 }
271 }
272
273 /*
@@ -289,11 +289,11 @@
289
290 cson_value * json_artifact_file(cson_object * zParent, int rid){
291 cson_object * pay = NULL;
292 Stmt q = empty_Stmt;
293 cson_array * checkin_arr = NULL;
294 int contentFormat;
295 i64 contentSize = -1;
296 char * parentUuid;
297 if( ! g.perm.Read ){
298 json_set_err(FSL_JSON_E_DENIED,
299 "Requires 'o' privileges.");
300
+7 -7
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -80,11 +80,11 @@
8080
** the page.
8181
**
8282
** The returned value, if not NULL, is-a JSON Object owned by the
8383
** caller. If it returns NULL then it may set g.json's error state.
8484
*/
85
-cson_value * json_get_wiki_page_by_rid(int rid, char contentFormat){
85
+cson_value * json_get_wiki_page_by_rid(int rid, int contentFormat){
8686
Manifest * pWiki = NULL;
8787
if( NULL == (pWiki = manifest_get(rid, CFTYPE_WIKI, 0)) ){
8888
json_set_err( FSL_JSON_E_UNKNOWN,
8989
"Error reading wiki page from manifest (rid=%d).",
9090
rid );
@@ -145,11 +145,11 @@
145145
/*
146146
** Searches for the latest version of a wiki page with the given
147147
** name. If found it behaves like json_get_wiki_page_by_rid(theRid,
148148
** contentFormat), else it returns NULL.
149149
*/
150
-cson_value * json_get_wiki_page_by_name(char const * zPageName, char contentFormat){
150
+cson_value * json_get_wiki_page_by_name(char const * zPageName, int contentFormat){
151151
int rid;
152152
rid = db_int(0,
153153
"SELECT x.rid FROM tag t, tagxref x, blob b"
154154
" WHERE x.tagid=t.tagid AND t.tagname='wiki-%q' "
155155
" AND b.rid=x.rid"
@@ -175,12 +175,12 @@
175175
** [r]aw = -1
176176
**
177177
** The return value is intended for use with
178178
** json_get_wiki_page_by_rid() and friends.
179179
*/
180
-char json_wiki_get_content_format_flag( char defaultValue ){
181
- char contentFormat = defaultValue;
180
+int json_wiki_get_content_format_flag( int defaultValue ){
181
+ int contentFormat = defaultValue;
182182
char const * zFormat = json_find_option_cstr("format",NULL,"f");
183183
if( !zFormat || !*zFormat ){
184184
return contentFormat;
185185
}
186186
else if('r'==*zFormat){
@@ -203,11 +203,11 @@
203203
** json_get_wiki_page_by_name() will be returned (owned by the
204204
** caller). On error g.json's error state is set and NULL is returned.
205205
*/
206206
static cson_value * json_wiki_get_by_name_or_symname(char const * zPageName,
207207
char const * zSymname,
208
- char contentFormat ){
208
+ int contentFormat ){
209209
if(!zSymname || !*zSymname){
210210
return json_get_wiki_page_by_name(zPageName, contentFormat);
211211
}else{
212212
int rid = symbolic_name_to_rid( zSymname ? zSymname : zPageName, "w" );
213213
if(rid<0){
@@ -229,11 +229,11 @@
229229
**
230230
*/
231231
static cson_value * json_wiki_get(){
232232
char const * zPageName;
233233
char const * zSymName = NULL;
234
- char contentFormat = -1;
234
+ int contentFormat = -1;
235235
if( !g.perm.RdWiki && !g.perm.Read ){
236236
json_set_err(FSL_JSON_E_DENIED,
237237
"Requires 'o' or 'j' access.");
238238
return NULL;
239239
}
@@ -373,11 +373,11 @@
373373
contentLen = (int)cson_string_length_bytes(jstr);
374374
if(contentLen){
375375
blob_append(&content, cson_string_cstr(jstr),contentLen);
376376
}
377377
378
- zMimeType = json_find_option_cstr("format","format","F");
378
+ zMimeType = json_find_option_cstr("mimetype","mimetype","M");
379379
380380
wiki_cmd_commit(zPageName, 0==rid, &content, zMimeType);
381381
blob_reset(&content);
382382
/*
383383
Our return value here has a race condition: if this operation
384384
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -80,11 +80,11 @@
80 ** the page.
81 **
82 ** The returned value, if not NULL, is-a JSON Object owned by the
83 ** caller. If it returns NULL then it may set g.json's error state.
84 */
85 cson_value * json_get_wiki_page_by_rid(int rid, char contentFormat){
86 Manifest * pWiki = NULL;
87 if( NULL == (pWiki = manifest_get(rid, CFTYPE_WIKI, 0)) ){
88 json_set_err( FSL_JSON_E_UNKNOWN,
89 "Error reading wiki page from manifest (rid=%d).",
90 rid );
@@ -145,11 +145,11 @@
145 /*
146 ** Searches for the latest version of a wiki page with the given
147 ** name. If found it behaves like json_get_wiki_page_by_rid(theRid,
148 ** contentFormat), else it returns NULL.
149 */
150 cson_value * json_get_wiki_page_by_name(char const * zPageName, char contentFormat){
151 int rid;
152 rid = db_int(0,
153 "SELECT x.rid FROM tag t, tagxref x, blob b"
154 " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q' "
155 " AND b.rid=x.rid"
@@ -175,12 +175,12 @@
175 ** [r]aw = -1
176 **
177 ** The return value is intended for use with
178 ** json_get_wiki_page_by_rid() and friends.
179 */
180 char json_wiki_get_content_format_flag( char defaultValue ){
181 char contentFormat = defaultValue;
182 char const * zFormat = json_find_option_cstr("format",NULL,"f");
183 if( !zFormat || !*zFormat ){
184 return contentFormat;
185 }
186 else if('r'==*zFormat){
@@ -203,11 +203,11 @@
203 ** json_get_wiki_page_by_name() will be returned (owned by the
204 ** caller). On error g.json's error state is set and NULL is returned.
205 */
206 static cson_value * json_wiki_get_by_name_or_symname(char const * zPageName,
207 char const * zSymname,
208 char contentFormat ){
209 if(!zSymname || !*zSymname){
210 return json_get_wiki_page_by_name(zPageName, contentFormat);
211 }else{
212 int rid = symbolic_name_to_rid( zSymname ? zSymname : zPageName, "w" );
213 if(rid<0){
@@ -229,11 +229,11 @@
229 **
230 */
231 static cson_value * json_wiki_get(){
232 char const * zPageName;
233 char const * zSymName = NULL;
234 char contentFormat = -1;
235 if( !g.perm.RdWiki && !g.perm.Read ){
236 json_set_err(FSL_JSON_E_DENIED,
237 "Requires 'o' or 'j' access.");
238 return NULL;
239 }
@@ -373,11 +373,11 @@
373 contentLen = (int)cson_string_length_bytes(jstr);
374 if(contentLen){
375 blob_append(&content, cson_string_cstr(jstr),contentLen);
376 }
377
378 zMimeType = json_find_option_cstr("format","format","F");
379
380 wiki_cmd_commit(zPageName, 0==rid, &content, zMimeType);
381 blob_reset(&content);
382 /*
383 Our return value here has a race condition: if this operation
384
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -80,11 +80,11 @@
80 ** the page.
81 **
82 ** The returned value, if not NULL, is-a JSON Object owned by the
83 ** caller. If it returns NULL then it may set g.json's error state.
84 */
85 cson_value * json_get_wiki_page_by_rid(int rid, int contentFormat){
86 Manifest * pWiki = NULL;
87 if( NULL == (pWiki = manifest_get(rid, CFTYPE_WIKI, 0)) ){
88 json_set_err( FSL_JSON_E_UNKNOWN,
89 "Error reading wiki page from manifest (rid=%d).",
90 rid );
@@ -145,11 +145,11 @@
145 /*
146 ** Searches for the latest version of a wiki page with the given
147 ** name. If found it behaves like json_get_wiki_page_by_rid(theRid,
148 ** contentFormat), else it returns NULL.
149 */
150 cson_value * json_get_wiki_page_by_name(char const * zPageName, int contentFormat){
151 int rid;
152 rid = db_int(0,
153 "SELECT x.rid FROM tag t, tagxref x, blob b"
154 " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q' "
155 " AND b.rid=x.rid"
@@ -175,12 +175,12 @@
175 ** [r]aw = -1
176 **
177 ** The return value is intended for use with
178 ** json_get_wiki_page_by_rid() and friends.
179 */
180 int json_wiki_get_content_format_flag( int defaultValue ){
181 int contentFormat = defaultValue;
182 char const * zFormat = json_find_option_cstr("format",NULL,"f");
183 if( !zFormat || !*zFormat ){
184 return contentFormat;
185 }
186 else if('r'==*zFormat){
@@ -203,11 +203,11 @@
203 ** json_get_wiki_page_by_name() will be returned (owned by the
204 ** caller). On error g.json's error state is set and NULL is returned.
205 */
206 static cson_value * json_wiki_get_by_name_or_symname(char const * zPageName,
207 char const * zSymname,
208 int contentFormat ){
209 if(!zSymname || !*zSymname){
210 return json_get_wiki_page_by_name(zPageName, contentFormat);
211 }else{
212 int rid = symbolic_name_to_rid( zSymname ? zSymname : zPageName, "w" );
213 if(rid<0){
@@ -229,11 +229,11 @@
229 **
230 */
231 static cson_value * json_wiki_get(){
232 char const * zPageName;
233 char const * zSymName = NULL;
234 int contentFormat = -1;
235 if( !g.perm.RdWiki && !g.perm.Read ){
236 json_set_err(FSL_JSON_E_DENIED,
237 "Requires 'o' or 'j' access.");
238 return NULL;
239 }
@@ -373,11 +373,11 @@
373 contentLen = (int)cson_string_length_bytes(jstr);
374 if(contentLen){
375 blob_append(&content, cson_string_cstr(jstr),contentLen);
376 }
377
378 zMimeType = json_find_option_cstr("mimetype","mimetype","M");
379
380 wiki_cmd_commit(zPageName, 0==rid, &content, zMimeType);
381 blob_reset(&content);
382 /*
383 Our return value here has a race condition: if this operation
384
+7 -7
--- src/wiki.c
+++ src/wiki.c
@@ -1027,18 +1027,18 @@
10271027
** %fossil wiki export PAGENAME ?FILE?
10281028
**
10291029
** Sends the latest version of the PAGENAME wiki
10301030
** entry to the given file or standard output.
10311031
**
1032
-** %fossil wiki commit PAGENAME ?FILE? [-format TEXT-FORMAT]
1032
+** %fossil wiki commit PAGENAME ?FILE? [-mimetype TEXT-FORMAT]
10331033
**
10341034
** Commit changes to a wiki page from FILE or from standard
1035
-** input. The -format flag specifies the mime type, defaulting
1036
-** to the type used by the previous version of the page or
1037
-** (for new pages) text/x-fossil-wiki.
1035
+** input. The -mimetype (-M) flag specifies the mime type,
1036
+** defaulting to the type used by the previous version of
1037
+** the page or (for new pages) text/x-fossil-wiki.
10381038
**
1039
-** %fossil wiki create PAGENAME ?FILE? [-format TEXT-FORMAT]
1039
+** %fossil wiki create PAGENAME ?FILE? [-mimetype TEXT-FORMAT]
10401040
**
10411041
** Create a new wiki page with initial content taken from
10421042
** FILE or from standard input.
10431043
**
10441044
** %fossil wiki list
@@ -1094,13 +1094,13 @@
10941094
|| strncmp(g.argv[2],"create",n)==0 ){
10951095
char const *zPageName; /* page name */
10961096
Blob content; /* Input content */
10971097
int rid;
10981098
Manifest *pWiki = 0; /* Parsed wiki page content */
1099
- char const * zMimeType = find_option("format", "F", 1);
1099
+ char const * zMimeType = find_option("mimetype", "M", 1);
11001100
if( g.argc!=4 && g.argc!=5 ){
1101
- usage("commit PAGENAME ?FILE? [-format TEXT-FORMAT]");
1101
+ usage("commit PAGENAME ?FILE? [-mimetype TEXT-FORMAT]");
11021102
}
11031103
zPageName = g.argv[3];
11041104
if( g.argc==4 ){
11051105
blob_read_from_channel(&content, stdin, -1);
11061106
}else{
11071107
--- src/wiki.c
+++ src/wiki.c
@@ -1027,18 +1027,18 @@
1027 ** %fossil wiki export PAGENAME ?FILE?
1028 **
1029 ** Sends the latest version of the PAGENAME wiki
1030 ** entry to the given file or standard output.
1031 **
1032 ** %fossil wiki commit PAGENAME ?FILE? [-format TEXT-FORMAT]
1033 **
1034 ** Commit changes to a wiki page from FILE or from standard
1035 ** input. The -format flag specifies the mime type, defaulting
1036 ** to the type used by the previous version of the page or
1037 ** (for new pages) text/x-fossil-wiki.
1038 **
1039 ** %fossil wiki create PAGENAME ?FILE? [-format TEXT-FORMAT]
1040 **
1041 ** Create a new wiki page with initial content taken from
1042 ** FILE or from standard input.
1043 **
1044 ** %fossil wiki list
@@ -1094,13 +1094,13 @@
1094 || strncmp(g.argv[2],"create",n)==0 ){
1095 char const *zPageName; /* page name */
1096 Blob content; /* Input content */
1097 int rid;
1098 Manifest *pWiki = 0; /* Parsed wiki page content */
1099 char const * zMimeType = find_option("format", "F", 1);
1100 if( g.argc!=4 && g.argc!=5 ){
1101 usage("commit PAGENAME ?FILE? [-format TEXT-FORMAT]");
1102 }
1103 zPageName = g.argv[3];
1104 if( g.argc==4 ){
1105 blob_read_from_channel(&content, stdin, -1);
1106 }else{
1107
--- src/wiki.c
+++ src/wiki.c
@@ -1027,18 +1027,18 @@
1027 ** %fossil wiki export PAGENAME ?FILE?
1028 **
1029 ** Sends the latest version of the PAGENAME wiki
1030 ** entry to the given file or standard output.
1031 **
1032 ** %fossil wiki commit PAGENAME ?FILE? [-mimetype TEXT-FORMAT]
1033 **
1034 ** Commit changes to a wiki page from FILE or from standard
1035 ** input. The -mimetype (-M) flag specifies the mime type,
1036 ** defaulting to the type used by the previous version of
1037 ** the page or (for new pages) text/x-fossil-wiki.
1038 **
1039 ** %fossil wiki create PAGENAME ?FILE? [-mimetype TEXT-FORMAT]
1040 **
1041 ** Create a new wiki page with initial content taken from
1042 ** FILE or from standard input.
1043 **
1044 ** %fossil wiki list
@@ -1094,13 +1094,13 @@
1094 || strncmp(g.argv[2],"create",n)==0 ){
1095 char const *zPageName; /* page name */
1096 Blob content; /* Input content */
1097 int rid;
1098 Manifest *pWiki = 0; /* Parsed wiki page content */
1099 char const * zMimeType = find_option("mimetype", "M", 1);
1100 if( g.argc!=4 && g.argc!=5 ){
1101 usage("commit PAGENAME ?FILE? [-mimetype TEXT-FORMAT]");
1102 }
1103 zPageName = g.argv[3];
1104 if( g.argc==4 ){
1105 blob_read_from_channel(&content, stdin, -1);
1106 }else{
1107

Keyboard Shortcuts

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