Fossil SCM

getenv() as the fallback strategy for json_getenv() now only enabled in CLI mode.

stephan 2011-10-08 14:15 UTC json-multitag-test
Commit 8c4a23aee42c162dd5668f20e0c117153a417419
1 file changed +5 -2
+5 -2
--- src/json.c
+++ src/json.c
@@ -421,11 +421,11 @@
421421
rc = cson_object_get( g.json.post.o, zKey );
422422
if(rc){
423423
return rc;
424424
}else{
425425
char const * cv = PD(zKey,NULL);
426
- if(!cv){
426
+ if(!cv && !g.isHTTP){
427427
/* reminder to self: in CLI mode i'd like to try
428428
find_option(zKey,NULL,XYZ) here, but we don't have a sane
429429
default for the XYZ param here.
430430
*/
431431
cv = getenv(zKey);
@@ -439,22 +439,25 @@
439439
int const scanRc = sscanf(cv,"%d%c",&intVal, &endOfIntCheck)
440440
/* The %c bit there is to make sure that we don't accept 123x
441441
as a number. sscanf() returns the number of tokens
442442
successfully parsed, so an RC of 1 will be correct for "123"
443443
but "123x" will have RC==2.
444
+
445
+ But it appears to not be working that way :/
444446
*/
445447
;
446448
if(1==scanRc){
447449
json_setenv( zKey, cson_value_new_integer(intVal) );
448450
}else{
449451
rc = cson_value_new_string(cv,strlen(cv));
450452
json_setenv( zKey, rc );
451453
}
452454
return rc;
455
+ }else{
456
+ return NULL;
453457
}
454458
}
455
- return NULL;
456459
}
457460
458461
/*
459462
** Wrapper around json_getenv() which...
460463
**
461464
--- 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

Keyboard Shortcuts

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