@@ -3395,12 +3395,10 @@ int parse_long_opt(const char *opt, const char **argv,
33953395 const char * * optarg )
33963396{
33973397 const char * arg = argv [0 ];
3398- if (arg [ 0 ] != '-' || arg [ 1 ] != '-' )
3398+ if (! skip_prefix ( arg , "--" , & arg ) )
33993399 return 0 ;
3400- arg += strlen ("--" );
3401- if (!starts_with (arg , opt ))
3400+ if (!skip_prefix (arg , opt , & arg ))
34023401 return 0 ;
3403- arg += strlen (opt );
34043402 if (* arg == '=' ) { /* stuck form: --option=value */
34053403 * optarg = arg + 1 ;
34063404 return 1 ;
@@ -3429,8 +3427,7 @@ static int stat_opt(struct diff_options *options, const char **av)
34293427
34303428 switch (* arg ) {
34313429 case '-' :
3432- if (starts_with (arg , "-width" )) {
3433- arg += strlen ("-width" );
3430+ if (skip_prefix (arg , "-width" , & arg )) {
34343431 if (* arg == '=' )
34353432 width = strtoul (arg + 1 , & end , 10 );
34363433 else if (!* arg && !av [1 ])
@@ -3439,8 +3436,7 @@ static int stat_opt(struct diff_options *options, const char **av)
34393436 width = strtoul (av [1 ], & end , 10 );
34403437 argcount = 2 ;
34413438 }
3442- } else if (starts_with (arg , "-name-width" )) {
3443- arg += strlen ("-name-width" );
3439+ } else if (skip_prefix (arg , "-name-width" , & arg )) {
34443440 if (* arg == '=' )
34453441 name_width = strtoul (arg + 1 , & end , 10 );
34463442 else if (!* arg && !av [1 ])
@@ -3449,8 +3445,7 @@ static int stat_opt(struct diff_options *options, const char **av)
34493445 name_width = strtoul (av [1 ], & end , 10 );
34503446 argcount = 2 ;
34513447 }
3452- } else if (starts_with (arg , "-graph-width" )) {
3453- arg += strlen ("-graph-width" );
3448+ } else if (skip_prefix (arg , "-graph-width" , & arg )) {
34543449 if (* arg == '=' )
34553450 graph_width = strtoul (arg + 1 , & end , 10 );
34563451 else if (!* arg && !av [1 ])
@@ -3459,8 +3454,7 @@ static int stat_opt(struct diff_options *options, const char **av)
34593454 graph_width = strtoul (av [1 ], & end , 10 );
34603455 argcount = 2 ;
34613456 }
3462- } else if (starts_with (arg , "-count" )) {
3463- arg += strlen ("-count" );
3457+ } else if (skip_prefix (arg , "-count" , & arg )) {
34643458 if (* arg == '=' )
34653459 count = strtoul (arg + 1 , & end , 10 );
34663460 else if (!* arg && !av [1 ])
@@ -3905,16 +3899,13 @@ static int diff_scoreopt_parse(const char *opt)
39053899 cmd = * opt ++ ;
39063900 if (cmd == '-' ) {
39073901 /* convert the long-form arguments into short-form versions */
3908- if (starts_with (opt , "break-rewrites" )) {
3909- opt += strlen ("break-rewrites" );
3902+ if (skip_prefix (opt , "break-rewrites" , & opt )) {
39103903 if (* opt == 0 || * opt ++ == '=' )
39113904 cmd = 'B' ;
3912- } else if (starts_with (opt , "find-copies" )) {
3913- opt += strlen ("find-copies" );
3905+ } else if (skip_prefix (opt , "find-copies" , & opt )) {
39143906 if (* opt == 0 || * opt ++ == '=' )
39153907 cmd = 'C' ;
3916- } else if (starts_with (opt , "find-renames" )) {
3917- opt += strlen ("find-renames" );
3908+ } else if (skip_prefix (opt , "find-renames" , & opt )) {
39183909 if (* opt == 0 || * opt ++ == '=' )
39193910 cmd = 'M' ;
39203911 }
0 commit comments