Skip to content

Commit

Permalink
LIBSAIL: Update inih to version 57
Browse files Browse the repository at this point in the history
  • Loading branch information
HappySeaFox committed Oct 13, 2023
1 parent 8fd8929 commit a2493e4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/libsail/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ endif()
#
target_include_directories(sail PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
# Simplify the INIH parser
target_compile_definitions(sail PRIVATE INI_ALLOW_MULTILINE=0 INI_ALLOW_INLINE_COMMENTS=0 INI_CUSTOM_ALLOCATOR=0 INI_STOP_ON_FIRST_ERROR=1 INI_MAX_LINE=500)
target_compile_definitions(sail PRIVATE INI_ALLOW_MULTILINE=0 INI_ALLOW_INLINE_COMMENTS=0 INI_CUSTOM_ALLOCATOR=0 INI_STOP_ON_FIRST_ERROR=1 INI_MAX_LINE=500 INI_API=SAIL_HIDDEN)

if (SAIL_COMBINE_CODECS)
# Transfer user requirements
Expand Down
6 changes: 6 additions & 0 deletions src/libsail/ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
}
#if INI_ALLOW_MULTILINE
else if (*prev_name && *start && start > line) {
#if INI_ALLOW_INLINE_COMMENTS
end = find_chars_or_comment(start, NULL);
if (*end)
*end = '\0';
rstrip(start);
#endif
/* Non-blank line with leading whitespace, treat as continuation
of previous name's value (as per Python configparser). */
if (!HANDLER(user, section, prev_name, start) && !error)
Expand Down
29 changes: 25 additions & 4 deletions src/libsail/ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ extern "C" {
#define INI_HANDLER_LINENO 0
#endif

/* Visibility symbols, required for Windows DLLs */
#ifndef INI_API
#if defined _WIN32 || defined __CYGWIN__
# ifdef INI_SHARED_LIB
# ifdef INI_SHARED_LIB_BUILDING
# define INI_API __declspec(dllexport)
# else
# define INI_API __declspec(dllimport)
# endif
# else
# define INI_API
# endif
#else
# if defined(__GNUC__) && __GNUC__ >= 4
# define INI_API __attribute__ ((visibility ("default")))
# else
# define INI_API
# endif
#endif
#endif

/* Typedef for prototype of handler function. */
#if INI_HANDLER_LINENO
typedef int (*ini_handler)(void* user, const char* section,
Expand All @@ -54,22 +75,22 @@ typedef char* (*ini_reader)(char* str, int num, void* stream);
stop on first error), -1 on file open error, or -2 on memory allocation
error (only when INI_USE_STACK is zero).
*/
SAIL_HIDDEN int ini_parse(const char* filename, ini_handler handler, void* user);
INI_API int ini_parse(const char* filename, ini_handler handler, void* user);

/* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
close the file when it's finished -- the caller must do that. */
SAIL_HIDDEN int ini_parse_file(FILE* file, ini_handler handler, void* user);
INI_API int ini_parse_file(FILE* file, ini_handler handler, void* user);

/* Same as ini_parse(), but takes an ini_reader function pointer instead of
filename. Used for implementing custom or string-based I/O (see also
ini_parse_string). */
SAIL_HIDDEN int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
INI_API int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
void* user);

/* Same as ini_parse(), but takes a zero-terminated string with the INI data
instead of a file. Useful for parsing INI data from a network socket or
already in memory. */
SAIL_HIDDEN int ini_parse_string(const char* string, ini_handler handler, void* user);
INI_API int ini_parse_string(const char* string, ini_handler handler, void* user);

/* Nonzero to allow multi-line value parsing, in the style of Python's
configparser. If allowed, ini_parse() will call the handler with the same
Expand Down

0 comments on commit a2493e4

Please sign in to comment.