MCPcopy Create free account
hub / github.com/F-Stack/f-stack / find_chars_or_comment

Function find_chars_or_comment

lib/ff_ini_parser.c:47–62  ·  view source on GitHub ↗

Return pointer to first char (of chars) or inline comment in given string, or pointer to null at end of string if neither found. Inline comment must be prefixed by a whitespace character to register as a comment. */

Source from the content-addressed store, hash-verified

45 or pointer to null at end of string if neither found. Inline comment must
46 be prefixed by a whitespace character to register as a comment. */
47static char* find_chars_or_comment(const char* s, const char* chars)
48{
49#if INI_ALLOW_INLINE_COMMENTS
50 int was_space = 0;
51 while (*s && (!chars || !strchr(chars, *s)) &&
52 !(was_space && strchr(INI_INLINE_COMMENT_PREFIXES, *s))) {
53 was_space = isspace((unsigned char)(*s));
54 s++;
55 }
56#else
57 while (*s && (!chars || !strchr(chars, *s))) {
58 s++;
59 }
60#endif
61 return (char*)s;
62}
63
64/* Version of strncpy that ensures dest (size bytes) is null-terminated. */
65static char* strncpy0(char* dest, const char* src, size_t size)

Callers 1

ifFunction · 0.85

Calls 2

strchrFunction · 0.85
isspaceFunction · 0.85

Tested by

no test coverage detected