@@ -2294,10 +2294,9 @@ struct config_store_data {
2294
2294
int do_not_match ;
2295
2295
regex_t * value_regex ;
2296
2296
int multi_replace ;
2297
- size_t * offset ;
2298
- unsigned int offset_alloc ;
2297
+ size_t * seen ;
2298
+ unsigned int seen_nr , seen_alloc ;
2299
2299
enum { START , SECTION_SEEN , SECTION_END_SEEN , KEY_SEEN } state ;
2300
- unsigned int seen ;
2301
2300
};
2302
2301
2303
2302
static int matches (const char * key , const char * value ,
@@ -2323,15 +2322,15 @@ static int store_aux(const char *key, const char *value, void *cb)
2323
2322
switch (store -> state ) {
2324
2323
case KEY_SEEN :
2325
2324
if (matches (key , value , store )) {
2326
- if (store -> seen == 1 && store -> multi_replace == 0 ) {
2325
+ if (store -> seen_nr == 1 && store -> multi_replace == 0 ) {
2327
2326
warning (_ ("%s has multiple values" ), key );
2328
2327
}
2329
2328
2330
- ALLOC_GROW (store -> offset , store -> seen + 1 ,
2331
- store -> offset_alloc );
2329
+ ALLOC_GROW (store -> seen , store -> seen_nr + 1 ,
2330
+ store -> seen_alloc );
2332
2331
2333
- store -> offset [store -> seen ] = cf -> do_ftell (cf );
2334
- store -> seen ++ ;
2332
+ store -> seen [store -> seen_nr ] = cf -> do_ftell (cf );
2333
+ store -> seen_nr ++ ;
2335
2334
}
2336
2335
break ;
2337
2336
case SECTION_SEEN :
@@ -2357,26 +2356,26 @@ static int store_aux(const char *key, const char *value, void *cb)
2357
2356
* Do not increment matches: this is no match, but we
2358
2357
* just made sure we are in the desired section.
2359
2358
*/
2360
- ALLOC_GROW (store -> offset , store -> seen + 1 ,
2361
- store -> offset_alloc );
2362
- store -> offset [store -> seen ] = cf -> do_ftell (cf );
2359
+ ALLOC_GROW (store -> seen , store -> seen_nr + 1 ,
2360
+ store -> seen_alloc );
2361
+ store -> seen [store -> seen_nr ] = cf -> do_ftell (cf );
2363
2362
/* fallthru */
2364
2363
case SECTION_END_SEEN :
2365
2364
case START :
2366
2365
if (matches (key , value , store )) {
2367
- ALLOC_GROW (store -> offset , store -> seen + 1 ,
2368
- store -> offset_alloc );
2369
- store -> offset [store -> seen ] = cf -> do_ftell (cf );
2366
+ ALLOC_GROW (store -> seen , store -> seen_nr + 1 ,
2367
+ store -> seen_alloc );
2368
+ store -> seen [store -> seen_nr ] = cf -> do_ftell (cf );
2370
2369
store -> state = KEY_SEEN ;
2371
- store -> seen ++ ;
2370
+ store -> seen_nr ++ ;
2372
2371
} else {
2373
2372
if (strrchr (key , '.' ) - key == store -> baselen &&
2374
2373
!strncmp (key , store -> key , store -> baselen )) {
2375
2374
store -> state = SECTION_SEEN ;
2376
- ALLOC_GROW (store -> offset ,
2377
- store -> seen + 1 ,
2378
- store -> offset_alloc );
2379
- store -> offset [store -> seen ] =
2375
+ ALLOC_GROW (store -> seen ,
2376
+ store -> seen_nr + 1 ,
2377
+ store -> seen_alloc );
2378
+ store -> seen [store -> seen_nr ] =
2380
2379
cf -> do_ftell (cf );
2381
2380
}
2382
2381
}
@@ -2636,10 +2635,10 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2636
2635
}
2637
2636
}
2638
2637
2639
- ALLOC_GROW (store .offset , 1 , store .offset_alloc );
2640
- store .offset [0 ] = 0 ;
2638
+ ALLOC_GROW (store .seen , 1 , store .seen_alloc );
2639
+ store .seen [0 ] = 0 ;
2641
2640
store .state = START ;
2642
- store .seen = 0 ;
2641
+ store .seen_nr = 0 ;
2643
2642
2644
2643
/*
2645
2644
* After this, store.offset will contain the *end* offset
@@ -2667,8 +2666,8 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2667
2666
}
2668
2667
2669
2668
/* if nothing to unset, or too many matches, error out */
2670
- if ((store .seen == 0 && value == NULL ) ||
2671
- (store .seen > 1 && multi_replace == 0 )) {
2669
+ if ((store .seen_nr == 0 && value == NULL ) ||
2670
+ (store .seen_nr > 1 && multi_replace == 0 )) {
2672
2671
ret = CONFIG_NOTHING_SET ;
2673
2672
goto out_free ;
2674
2673
}
@@ -2699,19 +2698,19 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2699
2698
goto out_free ;
2700
2699
}
2701
2700
2702
- if (store .seen == 0 )
2703
- store .seen = 1 ;
2701
+ if (store .seen_nr == 0 )
2702
+ store .seen_nr = 1 ;
2704
2703
2705
- for (i = 0 , copy_begin = 0 ; i < store .seen ; i ++ ) {
2704
+ for (i = 0 , copy_begin = 0 ; i < store .seen_nr ; i ++ ) {
2706
2705
new_line = 0 ;
2707
- if (store .offset [i ] == 0 ) {
2708
- store .offset [i ] = copy_end = contents_sz ;
2706
+ if (store .seen [i ] == 0 ) {
2707
+ store .seen [i ] = copy_end = contents_sz ;
2709
2708
} else if (store .state != KEY_SEEN ) {
2710
- copy_end = store .offset [i ];
2709
+ copy_end = store .seen [i ];
2711
2710
} else
2712
2711
copy_end = find_beginning_of_line (
2713
2712
contents , contents_sz ,
2714
- store .offset [i ], & new_line );
2713
+ store .seen [i ], & new_line );
2715
2714
2716
2715
if (copy_end > 0 && contents [copy_end - 1 ] != '\n' )
2717
2716
new_line = 1 ;
@@ -2725,7 +2724,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2725
2724
write_str_in_full (fd , "\n" ) < 0 )
2726
2725
goto write_err_out ;
2727
2726
}
2728
- copy_begin = store .offset [i ];
2727
+ copy_begin = store .seen [i ];
2729
2728
}
2730
2729
2731
2730
/* write the pair (value == NULL means unset) */
0 commit comments