Skip to content

Commit 5cc5e2c

Browse files
authored
Merge pull request #164 from benhoyt/ini-prefix
Add ini_ prefix even to static names so inih can be used as an #include
2 parents 4e618f7 + d032d6f commit 5cc5e2c

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

ini.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ typedef struct {
4545
} ini_parse_string_ctx;
4646

4747
/* Strip whitespace chars off end of given string, in place. Return s. */
48-
static char* rstrip(char* s)
48+
static char* ini_rstrip(char* s)
4949
{
5050
char* p = s + strlen(s);
5151
while (p > s && isspace((unsigned char)(*--p)))
@@ -54,7 +54,7 @@ static char* rstrip(char* s)
5454
}
5555

5656
/* Return pointer to first non-whitespace char in given string. */
57-
static char* lskip(const char* s)
57+
static char* ini_lskip(const char* s)
5858
{
5959
while (*s && isspace((unsigned char)(*s)))
6060
s++;
@@ -64,7 +64,7 @@ static char* lskip(const char* s)
6464
/* Return pointer to first char (of chars) or inline comment in given string,
6565
or pointer to NUL at end of string if neither found. Inline comment must
6666
be prefixed by a whitespace character to register as a comment. */
67-
static char* find_chars_or_comment(const char* s, const char* chars)
67+
static char* ini_find_chars_or_comment(const char* s, const char* chars)
6868
{
6969
#if INI_ALLOW_INLINE_COMMENTS
7070
int was_space = 0;
@@ -83,7 +83,7 @@ static char* find_chars_or_comment(const char* s, const char* chars)
8383

8484
/* Similar to strncpy, but ensures dest (size bytes) is
8585
NUL-terminated, and doesn't pad with NULs. */
86-
static char* strncpy0(char* dest, const char* src, size_t size)
86+
static char* ini_strncpy0(char* dest, const char* src, size_t size)
8787
{
8888
/* Could use strncpy internally, but it causes gcc warnings (see issue #91) */
8989
size_t i;
@@ -164,18 +164,18 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
164164
start += 3;
165165
}
166166
#endif
167-
start = lskip(rstrip(start));
167+
start = ini_lskip(ini_rstrip(start));
168168

169169
if (strchr(INI_START_COMMENT_PREFIXES, *start)) {
170170
/* Start-of-line comment */
171171
}
172172
#if INI_ALLOW_MULTILINE
173173
else if (*prev_name && *start && start > line) {
174174
#if INI_ALLOW_INLINE_COMMENTS
175-
end = find_chars_or_comment(start, NULL);
175+
end = ini_find_chars_or_comment(start, NULL);
176176
if (*end)
177177
*end = '\0';
178-
rstrip(start);
178+
ini_rstrip(start);
179179
#endif
180180
/* Non-blank line with leading whitespace, treat as continuation
181181
of previous name's value (as per Python configparser). */
@@ -185,10 +185,10 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
185185
#endif
186186
else if (*start == '[') {
187187
/* A "[section]" line */
188-
end = find_chars_or_comment(start + 1, "]");
188+
end = ini_find_chars_or_comment(start + 1, "]");
189189
if (*end == ']') {
190190
*end = '\0';
191-
strncpy0(section, start + 1, sizeof(section));
191+
ini_strncpy0(section, start + 1, sizeof(section));
192192
*prev_name = '\0';
193193
#if INI_CALL_HANDLER_ON_NEW_SECTION
194194
if (!HANDLER(user, section, NULL, NULL) && !error)
@@ -202,29 +202,29 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
202202
}
203203
else if (*start) {
204204
/* Not a comment, must be a name[=:]value pair */
205-
end = find_chars_or_comment(start, "=:");
205+
end = ini_find_chars_or_comment(start, "=:");
206206
if (*end == '=' || *end == ':') {
207207
*end = '\0';
208-
name = rstrip(start);
208+
name = ini_rstrip(start);
209209
value = end + 1;
210210
#if INI_ALLOW_INLINE_COMMENTS
211-
end = find_chars_or_comment(value, NULL);
211+
end = ini_find_chars_or_comment(value, NULL);
212212
if (*end)
213213
*end = '\0';
214214
#endif
215-
value = lskip(value);
216-
rstrip(value);
215+
value = ini_lskip(value);
216+
ini_rstrip(value);
217217

218218
/* Valid name[=:]value pair found, call handler */
219-
strncpy0(prev_name, name, sizeof(prev_name));
219+
ini_strncpy0(prev_name, name, sizeof(prev_name));
220220
if (!HANDLER(user, section, name, value) && !error)
221221
error = lineno;
222222
}
223223
else if (!error) {
224224
/* No '=' or ':' found on name[=:]value line */
225225
#if INI_ALLOW_NO_VALUE
226226
*end = '\0';
227-
name = rstrip(start);
227+
name = ini_rstrip(start);
228228
if (!HANDLER(user, section, name, NULL) && !error)
229229
error = lineno;
230230
#else

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project('inih',
22
['c'],
33
license : 'BSD-3-Clause',
4-
version : '57',
4+
version : '58',
55
default_options : ['cpp_std=c++11']
66
)
77

0 commit comments

Comments
 (0)