Skip to content

Commit a4a9cc1

Browse files
pcloudsgitster
authored andcommitted
fsck: produce camelCase config key names
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3ac68a9 commit a4a9cc1

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

fsck.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,15 @@ enum fsck_msg_id {
7474
#undef MSG_ID
7575

7676
#define STR(x) #x
77-
#define MSG_ID(id, msg_type) { STR(id), NULL, FSCK_##msg_type },
77+
#define MSG_ID(id, msg_type) { STR(id), NULL, NULL, FSCK_##msg_type },
7878
static struct {
7979
const char *id_string;
8080
const char *downcased;
81+
const char *camelcased;
8182
int msg_type;
8283
} msg_id_info[FSCK_MSG_MAX + 1] = {
8384
FOREACH_MSG_ID(MSG_ID)
84-
{ NULL, NULL, -1 }
85+
{ NULL, NULL, NULL, -1 }
8586
};
8687
#undef MSG_ID
8788

@@ -105,6 +106,20 @@ static void prepare_msg_ids(void)
105106
else
106107
*(q)++ = tolower(*(p)++);
107108
*q = '\0';
109+
110+
p = msg_id_info[i].id_string;
111+
q = xmalloc(len);
112+
msg_id_info[i].camelcased = q;
113+
while (*p) {
114+
if (*p == '_') {
115+
p++;
116+
if (*p)
117+
*q++ = *p++;
118+
} else {
119+
*q++ = tolower(*p++);
120+
}
121+
}
122+
*q = '\0';
108123
}
109124
}
110125

@@ -127,9 +142,8 @@ void list_config_fsck_msg_ids(struct string_list *list, const char *prefix)
127142

128143
prepare_msg_ids();
129144

130-
/* TODO: we can do better by producing camelCase names */
131145
for (i = 0; i < FSCK_MSG_MAX; i++)
132-
list_config_item(list, prefix, msg_id_info[i].downcased);
146+
list_config_item(list, prefix, msg_id_info[i].camelcased);
133147
}
134148

135149
static int fsck_msg_type(enum fsck_msg_id msg_id,

0 commit comments

Comments
 (0)