Fossil SCM
Added (hasfeature json|ssl|tcl) function to TH1 to determine whether the given compile-time option is enabled.
Commit
2be3a876fdf5c8b05e644eaa761dd5ef601993b9
Parent
00b86a85be47313…
1 file changed
+50
+50
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -214,10 +214,59 @@ | ||
| 214 | 214 | Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc); |
| 215 | 215 | } |
| 216 | 216 | Th_SetResultInt(interp, rc); |
| 217 | 217 | return TH_OK; |
| 218 | 218 | } |
| 219 | + | |
| 220 | +/* | |
| 221 | +** TH command: hasfeature STRING | |
| 222 | +** | |
| 223 | +** Return true if the user has the given compile-time feature. | |
| 224 | +** The set of features includes: | |
| 225 | +** | |
| 226 | +** "json" = FOSSIL_ENABLE_JSON | |
| 227 | +** "tcl" = FOSSIL_ENABLE_TCL | |
| 228 | +** "ssl" = FOSSIL_ENABLE_SSL | |
| 229 | +*/ | |
| 230 | +static int hasfeatureCmd( | |
| 231 | + Th_Interp *interp, | |
| 232 | + void *p, | |
| 233 | + int argc, | |
| 234 | + const char **argv, | |
| 235 | + int *argl | |
| 236 | +){ | |
| 237 | + int rc = 0; | |
| 238 | + char const * zArg; | |
| 239 | + if( argc!=2 ){ | |
| 240 | + return Th_WrongNumArgs(interp, "hasfeature STRING"); | |
| 241 | + } | |
| 242 | + zArg = (char const*)argv[1]; | |
| 243 | + if(NULL==zArg){ | |
| 244 | + /* placeholder for following ifdefs... */ | |
| 245 | + } | |
| 246 | +#if defined(FOSSIL_ENABLE_JSON) | |
| 247 | + else if( 0 == fossil_strnicmp( zArg, "json", 4 ) ){ | |
| 248 | + rc = 1; | |
| 249 | + } | |
| 250 | +#endif | |
| 251 | +#if defined(FOSSIL_ENABLE_SSL) | |
| 252 | + else if( 0 == fossil_strnicmp( zArg, "ssl", 3 ) ){ | |
| 253 | + rc = 1; | |
| 254 | + } | |
| 255 | +#endif | |
| 256 | +#if defined(FOSSIL_ENABLE_TCL) | |
| 257 | + else if( 0 == fossil_strnicmp( zArg, "tcl", 3 ) ){ | |
| 258 | + rc = 1; | |
| 259 | + } | |
| 260 | +#endif | |
| 261 | + if( g.thTrace ){ | |
| 262 | + Th_Trace("[hasfeature %#h] => %d<br />\n", argl[1], zArg, rc); | |
| 263 | + } | |
| 264 | + Th_SetResultInt(interp, rc); | |
| 265 | + return TH_OK; | |
| 266 | +} | |
| 267 | + | |
| 219 | 268 | |
| 220 | 269 | /* |
| 221 | 270 | ** TH command: anycap STRING |
| 222 | 271 | ** |
| 223 | 272 | ** Return true if the user has any one of the capabilities listed in STRING. |
| @@ -382,10 +431,11 @@ | ||
| 382 | 431 | {"anycap", anycapCmd, 0}, |
| 383 | 432 | {"combobox", comboboxCmd, 0}, |
| 384 | 433 | {"enable_output", enableOutputCmd, 0}, |
| 385 | 434 | {"linecount", linecntCmd, 0}, |
| 386 | 435 | {"hascap", hascapCmd, 0}, |
| 436 | + {"hasfeature", hasfeatureCmd, 0}, | |
| 387 | 437 | {"htmlize", htmlizeCmd, 0}, |
| 388 | 438 | {"date", dateCmd, 0}, |
| 389 | 439 | {"html", putsCmd, 0}, |
| 390 | 440 | {"puts", putsCmd, (void*)1}, |
| 391 | 441 | {"wiki", wikiCmd, 0}, |
| 392 | 442 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -214,10 +214,59 @@ | |
| 214 | Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc); |
| 215 | } |
| 216 | Th_SetResultInt(interp, rc); |
| 217 | return TH_OK; |
| 218 | } |
| 219 | |
| 220 | /* |
| 221 | ** TH command: anycap STRING |
| 222 | ** |
| 223 | ** Return true if the user has any one of the capabilities listed in STRING. |
| @@ -382,10 +431,11 @@ | |
| 382 | {"anycap", anycapCmd, 0}, |
| 383 | {"combobox", comboboxCmd, 0}, |
| 384 | {"enable_output", enableOutputCmd, 0}, |
| 385 | {"linecount", linecntCmd, 0}, |
| 386 | {"hascap", hascapCmd, 0}, |
| 387 | {"htmlize", htmlizeCmd, 0}, |
| 388 | {"date", dateCmd, 0}, |
| 389 | {"html", putsCmd, 0}, |
| 390 | {"puts", putsCmd, (void*)1}, |
| 391 | {"wiki", wikiCmd, 0}, |
| 392 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -214,10 +214,59 @@ | |
| 214 | Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc); |
| 215 | } |
| 216 | Th_SetResultInt(interp, rc); |
| 217 | return TH_OK; |
| 218 | } |
| 219 | |
| 220 | /* |
| 221 | ** TH command: hasfeature STRING |
| 222 | ** |
| 223 | ** Return true if the user has the given compile-time feature. |
| 224 | ** The set of features includes: |
| 225 | ** |
| 226 | ** "json" = FOSSIL_ENABLE_JSON |
| 227 | ** "tcl" = FOSSIL_ENABLE_TCL |
| 228 | ** "ssl" = FOSSIL_ENABLE_SSL |
| 229 | */ |
| 230 | static int hasfeatureCmd( |
| 231 | Th_Interp *interp, |
| 232 | void *p, |
| 233 | int argc, |
| 234 | const char **argv, |
| 235 | int *argl |
| 236 | ){ |
| 237 | int rc = 0; |
| 238 | char const * zArg; |
| 239 | if( argc!=2 ){ |
| 240 | return Th_WrongNumArgs(interp, "hasfeature STRING"); |
| 241 | } |
| 242 | zArg = (char const*)argv[1]; |
| 243 | if(NULL==zArg){ |
| 244 | /* placeholder for following ifdefs... */ |
| 245 | } |
| 246 | #if defined(FOSSIL_ENABLE_JSON) |
| 247 | else if( 0 == fossil_strnicmp( zArg, "json", 4 ) ){ |
| 248 | rc = 1; |
| 249 | } |
| 250 | #endif |
| 251 | #if defined(FOSSIL_ENABLE_SSL) |
| 252 | else if( 0 == fossil_strnicmp( zArg, "ssl", 3 ) ){ |
| 253 | rc = 1; |
| 254 | } |
| 255 | #endif |
| 256 | #if defined(FOSSIL_ENABLE_TCL) |
| 257 | else if( 0 == fossil_strnicmp( zArg, "tcl", 3 ) ){ |
| 258 | rc = 1; |
| 259 | } |
| 260 | #endif |
| 261 | if( g.thTrace ){ |
| 262 | Th_Trace("[hasfeature %#h] => %d<br />\n", argl[1], zArg, rc); |
| 263 | } |
| 264 | Th_SetResultInt(interp, rc); |
| 265 | return TH_OK; |
| 266 | } |
| 267 | |
| 268 | |
| 269 | /* |
| 270 | ** TH command: anycap STRING |
| 271 | ** |
| 272 | ** Return true if the user has any one of the capabilities listed in STRING. |
| @@ -382,10 +431,11 @@ | |
| 431 | {"anycap", anycapCmd, 0}, |
| 432 | {"combobox", comboboxCmd, 0}, |
| 433 | {"enable_output", enableOutputCmd, 0}, |
| 434 | {"linecount", linecntCmd, 0}, |
| 435 | {"hascap", hascapCmd, 0}, |
| 436 | {"hasfeature", hasfeatureCmd, 0}, |
| 437 | {"htmlize", htmlizeCmd, 0}, |
| 438 | {"date", dateCmd, 0}, |
| 439 | {"html", putsCmd, 0}, |
| 440 | {"puts", putsCmd, (void*)1}, |
| 441 | {"wiki", wikiCmd, 0}, |
| 442 |