Fossil SCM
Fixed corner case in --args handling for 1-byte entry with no newline.
Commit
ee990ebb99ecfabe54125288da6bc2f28d62d37c
Parent
418ec701a347b27…
1 file changed
+9
-2
+9
-2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -420,17 +420,24 @@ | ||
| 420 | 420 | newArgv = fossil_malloc( sizeof(char*)*(g.argc + nLine*2) ); |
| 421 | 421 | for(j=0; j<i; j++) newArgv[j] = g.argv[j]; |
| 422 | 422 | |
| 423 | 423 | blob_rewind(&file); |
| 424 | 424 | while( (n = blob_line(&file, &line))>0 ){ |
| 425 | - if( n<=1 ) continue; | |
| 425 | + if( n<1 ) continue | |
| 426 | + /** | |
| 427 | + ** Reminder: corner-case: a line with 1 byte and no newline. | |
| 428 | + */; | |
| 426 | 429 | z = blob_buffer(&line); |
| 427 | - z[n-1] = 0; | |
| 430 | + if('\n'==z[n-1]){ | |
| 431 | + z[n-1] = 0; | |
| 432 | + } | |
| 433 | + | |
| 428 | 434 | if((n>1) && ('\r'==z[n-2])){ |
| 429 | 435 | if(n==2) continue /*empty line*/; |
| 430 | 436 | z[n-2] = 0; |
| 431 | 437 | } |
| 438 | + if(!z[0]) continue; | |
| 432 | 439 | newArgv[j++] = z; |
| 433 | 440 | if( z[0]=='-' ){ |
| 434 | 441 | for(k=1; z[k] && !fossil_isspace(z[k]); k++){} |
| 435 | 442 | if( z[k] ){ |
| 436 | 443 | z[k] = 0; |
| 437 | 444 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -420,17 +420,24 @@ | |
| 420 | newArgv = fossil_malloc( sizeof(char*)*(g.argc + nLine*2) ); |
| 421 | for(j=0; j<i; j++) newArgv[j] = g.argv[j]; |
| 422 | |
| 423 | blob_rewind(&file); |
| 424 | while( (n = blob_line(&file, &line))>0 ){ |
| 425 | if( n<=1 ) continue; |
| 426 | z = blob_buffer(&line); |
| 427 | z[n-1] = 0; |
| 428 | if((n>1) && ('\r'==z[n-2])){ |
| 429 | if(n==2) continue /*empty line*/; |
| 430 | z[n-2] = 0; |
| 431 | } |
| 432 | newArgv[j++] = z; |
| 433 | if( z[0]=='-' ){ |
| 434 | for(k=1; z[k] && !fossil_isspace(z[k]); k++){} |
| 435 | if( z[k] ){ |
| 436 | z[k] = 0; |
| 437 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -420,17 +420,24 @@ | |
| 420 | newArgv = fossil_malloc( sizeof(char*)*(g.argc + nLine*2) ); |
| 421 | for(j=0; j<i; j++) newArgv[j] = g.argv[j]; |
| 422 | |
| 423 | blob_rewind(&file); |
| 424 | while( (n = blob_line(&file, &line))>0 ){ |
| 425 | if( n<1 ) continue |
| 426 | /** |
| 427 | ** Reminder: corner-case: a line with 1 byte and no newline. |
| 428 | */; |
| 429 | z = blob_buffer(&line); |
| 430 | if('\n'==z[n-1]){ |
| 431 | z[n-1] = 0; |
| 432 | } |
| 433 | |
| 434 | if((n>1) && ('\r'==z[n-2])){ |
| 435 | if(n==2) continue /*empty line*/; |
| 436 | z[n-2] = 0; |
| 437 | } |
| 438 | if(!z[0]) continue; |
| 439 | newArgv[j++] = z; |
| 440 | if( z[0]=='-' ){ |
| 441 | for(k=1; z[k] && !fossil_isspace(z[k]); k++){} |
| 442 | if( z[k] ){ |
| 443 | z[k] = 0; |
| 444 |