Fossil SCM
getenv() as the fallback strategy for json_getenv() now only enabled in CLI mode.
Commit
8c4a23aee42c162dd5668f20e0c117153a417419
Parent
a8af09fc166f8a3…
1 file changed
+5
-2
+5
-2
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -421,11 +421,11 @@ | ||
| 421 | 421 | rc = cson_object_get( g.json.post.o, zKey ); |
| 422 | 422 | if(rc){ |
| 423 | 423 | return rc; |
| 424 | 424 | }else{ |
| 425 | 425 | char const * cv = PD(zKey,NULL); |
| 426 | - if(!cv){ | |
| 426 | + if(!cv && !g.isHTTP){ | |
| 427 | 427 | /* reminder to self: in CLI mode i'd like to try |
| 428 | 428 | find_option(zKey,NULL,XYZ) here, but we don't have a sane |
| 429 | 429 | default for the XYZ param here. |
| 430 | 430 | */ |
| 431 | 431 | cv = getenv(zKey); |
| @@ -439,22 +439,25 @@ | ||
| 439 | 439 | int const scanRc = sscanf(cv,"%d%c",&intVal, &endOfIntCheck) |
| 440 | 440 | /* The %c bit there is to make sure that we don't accept 123x |
| 441 | 441 | as a number. sscanf() returns the number of tokens |
| 442 | 442 | successfully parsed, so an RC of 1 will be correct for "123" |
| 443 | 443 | but "123x" will have RC==2. |
| 444 | + | |
| 445 | + But it appears to not be working that way :/ | |
| 444 | 446 | */ |
| 445 | 447 | ; |
| 446 | 448 | if(1==scanRc){ |
| 447 | 449 | json_setenv( zKey, cson_value_new_integer(intVal) ); |
| 448 | 450 | }else{ |
| 449 | 451 | rc = cson_value_new_string(cv,strlen(cv)); |
| 450 | 452 | json_setenv( zKey, rc ); |
| 451 | 453 | } |
| 452 | 454 | return rc; |
| 455 | + }else{ | |
| 456 | + return NULL; | |
| 453 | 457 | } |
| 454 | 458 | } |
| 455 | - return NULL; | |
| 456 | 459 | } |
| 457 | 460 | |
| 458 | 461 | /* |
| 459 | 462 | ** Wrapper around json_getenv() which... |
| 460 | 463 | ** |
| 461 | 464 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -421,11 +421,11 @@ | |
| 421 | rc = cson_object_get( g.json.post.o, zKey ); |
| 422 | if(rc){ |
| 423 | return rc; |
| 424 | }else{ |
| 425 | char const * cv = PD(zKey,NULL); |
| 426 | if(!cv){ |
| 427 | /* reminder to self: in CLI mode i'd like to try |
| 428 | find_option(zKey,NULL,XYZ) here, but we don't have a sane |
| 429 | default for the XYZ param here. |
| 430 | */ |
| 431 | cv = getenv(zKey); |
| @@ -439,22 +439,25 @@ | |
| 439 | int const scanRc = sscanf(cv,"%d%c",&intVal, &endOfIntCheck) |
| 440 | /* The %c bit there is to make sure that we don't accept 123x |
| 441 | as a number. sscanf() returns the number of tokens |
| 442 | successfully parsed, so an RC of 1 will be correct for "123" |
| 443 | but "123x" will have RC==2. |
| 444 | */ |
| 445 | ; |
| 446 | if(1==scanRc){ |
| 447 | json_setenv( zKey, cson_value_new_integer(intVal) ); |
| 448 | }else{ |
| 449 | rc = cson_value_new_string(cv,strlen(cv)); |
| 450 | json_setenv( zKey, rc ); |
| 451 | } |
| 452 | return rc; |
| 453 | } |
| 454 | } |
| 455 | return NULL; |
| 456 | } |
| 457 | |
| 458 | /* |
| 459 | ** Wrapper around json_getenv() which... |
| 460 | ** |
| 461 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -421,11 +421,11 @@ | |
| 421 | rc = cson_object_get( g.json.post.o, zKey ); |
| 422 | if(rc){ |
| 423 | return rc; |
| 424 | }else{ |
| 425 | char const * cv = PD(zKey,NULL); |
| 426 | if(!cv && !g.isHTTP){ |
| 427 | /* reminder to self: in CLI mode i'd like to try |
| 428 | find_option(zKey,NULL,XYZ) here, but we don't have a sane |
| 429 | default for the XYZ param here. |
| 430 | */ |
| 431 | cv = getenv(zKey); |
| @@ -439,22 +439,25 @@ | |
| 439 | int const scanRc = sscanf(cv,"%d%c",&intVal, &endOfIntCheck) |
| 440 | /* The %c bit there is to make sure that we don't accept 123x |
| 441 | as a number. sscanf() returns the number of tokens |
| 442 | successfully parsed, so an RC of 1 will be correct for "123" |
| 443 | but "123x" will have RC==2. |
| 444 | |
| 445 | But it appears to not be working that way :/ |
| 446 | */ |
| 447 | ; |
| 448 | if(1==scanRc){ |
| 449 | json_setenv( zKey, cson_value_new_integer(intVal) ); |
| 450 | }else{ |
| 451 | rc = cson_value_new_string(cv,strlen(cv)); |
| 452 | json_setenv( zKey, rc ); |
| 453 | } |
| 454 | return rc; |
| 455 | }else{ |
| 456 | return NULL; |
| 457 | } |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | /* |
| 462 | ** Wrapper around json_getenv() which... |
| 463 | ** |
| 464 |