| | @@ -320,11 +320,12 @@ |
| 320 | 320 | unsigned int nLine; /* Number of lines in the file*/ |
| 321 | 321 | unsigned int i, j, k; /* Loop counters */ |
| 322 | 322 | int n; /* Number of bytes in one line */ |
| 323 | 323 | char *z; /* General use string pointer */ |
| 324 | 324 | char **newArgv; /* New expanded g.argv under construction */ |
| 325 | | - |
| 325 | + char const * zFileName; /* input file name */ |
| 326 | + FILE * zInFile; /* input FILE */ |
| 326 | 327 | for(i=1; i<g.argc-1; i++){ |
| 327 | 328 | z = g.argv[i]; |
| 328 | 329 | if( z[0]!='-' ) continue; |
| 329 | 330 | z++; |
| 330 | 331 | if( z[0]=='-' ) z++; |
| | @@ -331,11 +332,23 @@ |
| 331 | 332 | if( z[0]==0 ) return; /* Stop searching at "--" */ |
| 332 | 333 | if( fossil_strcmp(z, "args")==0 ) break; |
| 333 | 334 | } |
| 334 | 335 | if( i>=g.argc-1 ) return; |
| 335 | 336 | |
| 336 | | - blob_read_from_file(&file, g.argv[i+1]); |
| 337 | + zFileName = g.argv[i+1]; |
| 338 | + zInFile = (0==strcmp("-",zFileName)) |
| 339 | + ? stdin |
| 340 | + : fopen(zFileName,"rb"); |
| 341 | + if(!zInFile){ |
| 342 | + fossil_panic("Cannot open -args file [%s]", zFileName); |
| 343 | + }else{ |
| 344 | + blob_read_from_channel(&file, zInFile, -1); |
| 345 | + if(stdin != zInFile){ |
| 346 | + fclose(zInFile); |
| 347 | + } |
| 348 | + zInFile = NULL; |
| 349 | + } |
| 337 | 350 | z = blob_str(&file); |
| 338 | 351 | for(k=0, nLine=1; z[k]; k++) if( z[k]=='\n' ) nLine++; |
| 339 | 352 | newArgv = fossil_malloc( sizeof(char*)*(g.argc + nLine*2) ); |
| 340 | 353 | for(j=0; j<i; j++) newArgv[j] = g.argv[j]; |
| 341 | 354 | |
| | @@ -342,10 +355,14 @@ |
| 342 | 355 | blob_rewind(&file); |
| 343 | 356 | while( (n = blob_line(&file, &line))>0 ){ |
| 344 | 357 | if( n<=1 ) continue; |
| 345 | 358 | z = blob_buffer(&line); |
| 346 | 359 | z[n-1] = 0; |
| 360 | + if((n>1) && ('\r'==z[n-2])){ |
| 361 | + if(n==2) continue /*empty line*/; |
| 362 | + z[n-2] = 0; |
| 363 | + } |
| 347 | 364 | newArgv[j++] = z; |
| 348 | 365 | if( z[0]=='-' ){ |
| 349 | 366 | for(k=1; z[k] && !fossil_isspace(z[k]); k++){} |
| 350 | 367 | if( z[k] ){ |
| 351 | 368 | z[k] = 0; |
| 352 | 369 | |