@@ -2294,10 +2294,9 @@ struct config_store_data {
22942294 int do_not_match ;
22952295 regex_t * value_regex ;
22962296 int multi_replace ;
2297- size_t * offset ;
2298- unsigned int offset_alloc ;
2297+ size_t * seen ;
2298+ unsigned int seen_nr , seen_alloc ;
22992299 enum { START , SECTION_SEEN , SECTION_END_SEEN , KEY_SEEN } state ;
2300- unsigned int seen ;
23012300};
23022301
23032302static int matches (const char * key , const char * value ,
@@ -2323,15 +2322,15 @@ static int store_aux(const char *key, const char *value, void *cb)
23232322 switch (store -> state ) {
23242323 case KEY_SEEN :
23252324 if (matches (key , value , store )) {
2326- if (store -> seen == 1 && store -> multi_replace == 0 ) {
2325+ if (store -> seen_nr == 1 && store -> multi_replace == 0 ) {
23272326 warning (_ ("%s has multiple values" ), key );
23282327 }
23292328
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 );
23322331
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 ++ ;
23352334 }
23362335 break ;
23372336 case SECTION_SEEN :
@@ -2357,26 +2356,26 @@ static int store_aux(const char *key, const char *value, void *cb)
23572356 * Do not increment matches: this is no match, but we
23582357 * just made sure we are in the desired section.
23592358 */
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 );
23632362 /* fallthru */
23642363 case SECTION_END_SEEN :
23652364 case START :
23662365 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 );
23702369 store -> state = KEY_SEEN ;
2371- store -> seen ++ ;
2370+ store -> seen_nr ++ ;
23722371 } else {
23732372 if (strrchr (key , '.' ) - key == store -> baselen &&
23742373 !strncmp (key , store -> key , store -> baselen )) {
23752374 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 ] =
23802379 cf -> do_ftell (cf );
23812380 }
23822381 }
@@ -2636,10 +2635,10 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
26362635 }
26372636 }
26382637
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 ;
26412640 store .state = START ;
2642- store .seen = 0 ;
2641+ store .seen_nr = 0 ;
26432642
26442643 /*
26452644 * 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,
26672666 }
26682667
26692668 /* 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 )) {
26722671 ret = CONFIG_NOTHING_SET ;
26732672 goto out_free ;
26742673 }
@@ -2699,19 +2698,19 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
26992698 goto out_free ;
27002699 }
27012700
2702- if (store .seen == 0 )
2703- store .seen = 1 ;
2701+ if (store .seen_nr == 0 )
2702+ store .seen_nr = 1 ;
27042703
2705- for (i = 0 , copy_begin = 0 ; i < store .seen ; i ++ ) {
2704+ for (i = 0 , copy_begin = 0 ; i < store .seen_nr ; i ++ ) {
27062705 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 ;
27092708 } else if (store .state != KEY_SEEN ) {
2710- copy_end = store .offset [i ];
2709+ copy_end = store .seen [i ];
27112710 } else
27122711 copy_end = find_beginning_of_line (
27132712 contents , contents_sz ,
2714- store .offset [i ], & new_line );
2713+ store .seen [i ], & new_line );
27152714
27162715 if (copy_end > 0 && contents [copy_end - 1 ] != '\n' )
27172716 new_line = 1 ;
@@ -2725,7 +2724,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
27252724 write_str_in_full (fd , "\n" ) < 0 )
27262725 goto write_err_out ;
27272726 }
2728- copy_begin = store .offset [i ];
2727+ copy_begin = store .seen [i ];
27292728 }
27302729
27312730 /* write the pair (value == NULL means unset) */
0 commit comments