Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:Update
ding-libs.33681
0003-ini-Add-INI_PARSE_IGNORE_NON_KVP-flag.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0003-ini-Add-INI_PARSE_IGNORE_NON_KVP-flag.patch of Package ding-libs.33681
From 9591b1d8adbf195c40c123b1b5125db82e049a56 Mon Sep 17 00:00:00 2001 From: Dmitri Pal <dpal@redhat.com> Date: Jun 22 2016 08:30:06 +0000 Subject: ini: Add INI_PARSE_IGNORE_NON_KVP flag Ticket: https://fedorahosted.org/sssd/ticket/2751 Add INI_PARSE_IGNORE_NON_KVP flag to allow skipping lines that are not key-value pairs. Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com> --- diff --git a/ini/ini_configobj.h b/ini/ini_configobj.h index 6f2d692..12920db 100644 --- a/ini/ini_configobj.h +++ b/ini/ini_configobj.h @@ -363,6 +363,8 @@ enum ERR_PARSE { #define INI_PARSE_NOTAB 0x0004 /** @brief Do not allow C-style comments */ #define INI_PARSE_NO_C_COMMENTS 0x0008 +/** @brief Skip lines that are not KVPs */ +#define INI_PARSE_IGNORE_NON_KVP 0x0010 /** * @} diff --git a/ini/ini_parse.c b/ini/ini_parse.c index 0de4e35..e5baeca 100644 --- a/ini/ini_parse.c +++ b/ini/ini_parse.c @@ -966,8 +966,18 @@ static int handle_kvp(struct parser_obj *po, uint32_t *action) /* Check if we have the key */ if (*(str) == '=') { TRACE_ERROR_STRING("No key", str); - po->last_error = ERR_NOKEY; - *action = PARSE_ERROR; + + if (po->parse_flags & INI_PARSE_IGNORE_NON_KVP) { + /* Clean everything as if nothing happened */ + free(po->last_read); + po->last_read = NULL; + po->last_read_len = 0; + *action = PARSE_READ; + } else { + po->last_error = ERR_NOKEY; + *action = PARSE_ERROR; + } + TRACE_FLOW_EXIT(); return EOK; } @@ -975,9 +985,18 @@ static int handle_kvp(struct parser_obj *po, uint32_t *action) /* Find "=" */ eq = strchr(str, '='); if (eq == NULL) { - TRACE_ERROR_STRING("No equal sign", str); - po->last_error = ERR_NOEQUAL; - *action = PARSE_ERROR; + if (po->parse_flags & INI_PARSE_IGNORE_NON_KVP) { + /* Clean everything as if nothing happened */ + free(po->last_read); + po->last_read = NULL; + po->last_read_len = 0; + *action = PARSE_READ; + } else { + TRACE_ERROR_STRING("No equal sign", str); + po->last_error = ERR_NOEQUAL; + *action = PARSE_ERROR; + } + TRACE_FLOW_EXIT(); return EOK; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor