1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
diff -rupN a/config.c b/config.c
--- a/config.c 2013-09-27 01:49:38.000000000 +0200
+++ b/config.c 2013-10-16 20:26:27.835675951 +0200
@@ -30,6 +30,9 @@ struct config_source {
int (*do_fgetc)(struct config_source *c);
int (*do_ungetc)(int c, struct config_source *conf);
long (*do_ftell)(struct config_source *c);
+ int (*do_fgetc_cb)(struct config_source *c);
+ int (*do_ungetc_cb)(int c, struct config_source *conf);
+ long (*do_ftell_cb)(struct config_source *c);
};
static struct config_source *cf;
@@ -217,13 +220,13 @@ int git_config_from_parameters(config_fn
static int get_next_char(void)
{
- int c = cf->do_fgetc(cf);
+ int c = cf->do_fgetc_cb(cf);
if (c == '\r') {
/* DOS like systems */
- c = cf->do_fgetc(cf);
+ c = cf->do_fgetc_cb(cf);
if (c != '\n') {
- cf->do_ungetc(c, cf);
+ cf->do_ungetc_cb(c, cf);
c = '\r';
}
}
@@ -995,6 +998,9 @@ int git_config_from_file(config_fn_t fn,
top.do_fgetc = config_file_fgetc;
top.do_ungetc = config_file_ungetc;
top.do_ftell = config_file_ftell;
+ top.do_fgetc_cb = config_file_fgetc;
+ top.do_ungetc_cb = config_file_ungetc;
+ top.do_ftell_cb = config_file_ftell;
ret = do_config_from(&top, fn, data);
@@ -1016,6 +1022,9 @@ int git_config_from_buf(config_fn_t fn,
top.do_fgetc = config_buf_fgetc;
top.do_ungetc = config_buf_ungetc;
top.do_ftell = config_buf_ftell;
+ top.do_fgetc_cb = config_buf_fgetc;
+ top.do_ungetc_cb = config_buf_ungetc;
+ top.do_ftell_cb = config_buf_ftell;
return do_config_from(&top, fn, data);
}
@@ -1196,7 +1205,7 @@ static int store_aux(const char *key, co
return 1;
}
- store.offset[store.seen] = cf->do_ftell(cf);
+ store.offset[store.seen] = cf->do_ftell_cb(cf);
store.seen++;
}
break;
@@ -1223,19 +1232,19 @@ static int store_aux(const char *key, co
* Do not increment matches: this is no match, but we
* just made sure we are in the desired section.
*/
- store.offset[store.seen] = cf->do_ftell(cf);
+ store.offset[store.seen] = cf->do_ftell_cb(cf);
/* fallthru */
case SECTION_END_SEEN:
case START:
if (matches(key, value)) {
- store.offset[store.seen] = cf->do_ftell(cf);
+ store.offset[store.seen] = cf->do_ftell_cb(cf);
store.state = KEY_SEEN;
store.seen++;
} else {
if (strrchr(key, '.') - key == store.baselen &&
!strncmp(key, store.key, store.baselen)) {
store.state = SECTION_SEEN;
- store.offset[store.seen] = cf->do_ftell(cf);
+ store.offset[store.seen] = cf->do_ftell_cb(cf);
}
}
}
|