Fossil

Check-in [f80303ac73]
Login

Check-in [f80303ac73]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fix option/argument parsing for the case where an option is missing a required argument.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f80303ac73628dbfe30abd5964792ae99e638dca
User & Date: bharder 2009-02-09 18:09:03.000
Context
2009-02-11
05:00
Make command-alias for 'checkout': co. This command could -not- have been used previously as a shortcut, as it would be ambiguous becuase of 'commit' and 'configuration'. A natural mate for 'ci'. ... (check-in: a89b436bc9 user: bharder tags: trunk)
2009-02-09
18:09
fix option/argument parsing for the case where an option is missing a required argument. ... (check-in: f80303ac73 user: bharder tags: trunk)
04:41
'fossil' encode tagnames for manifest (for ticket 15f49be6b2b1e) (allows for tags with spaces in name) ... (check-in: 8be6204607 user: bharder tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
329
330
331
332
333
334
335

336
337
338
339
340
341
342
const char *find_option(const char *zLong, const char *zShort, int hasArg){
  int i;
  int nLong;
  const char *zReturn = 0;
  assert( hasArg==0 || hasArg==1 );
  nLong = strlen(zLong);
  for(i=2; i<g.argc; i++){

    char *z = g.argv[i];
    if( z[0]!='-' ) continue;
    z++;
    if( z[0]=='-' ){
      if( z[1]==0 ){
        remove_from_argv(i, 1);
        break;







>







329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
const char *find_option(const char *zLong, const char *zShort, int hasArg){
  int i;
  int nLong;
  const char *zReturn = 0;
  assert( hasArg==0 || hasArg==1 );
  nLong = strlen(zLong);
  for(i=2; i<g.argc; i++){
    if (i+hasArg >= g.argc) break;
    char *z = g.argv[i];
    if( z[0]!='-' ) continue;
    z++;
    if( z[0]=='-' ){
      if( z[1]==0 ){
        remove_from_argv(i, 1);
        break;
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
** Any remaining command-line argument begins with "-" print
** an error message and quit.
*/
void verify_all_options(void){
  int i;
  for(i=1; i<g.argc; i++){
    if( g.argv[i][0]=='-' ){
      fossil_fatal("unrecognized command-line option: %s", g.argv[i]);
    }
  }
}

/*
** Print a list of words in multiple columns.
*/







|







368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
** Any remaining command-line argument begins with "-" print
** an error message and quit.
*/
void verify_all_options(void){
  int i;
  for(i=1; i<g.argc; i++){
    if( g.argv[i][0]=='-' ){
      fossil_fatal("unrecognized command-line option, or missing argument: %s", g.argv[i]);
    }
  }
}

/*
** Print a list of words in multiple columns.
*/