Hello community, here is the log from the commit of package iniparser for openSUSE:Factory checked in at 2018-08-27 13:00:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/iniparser (Old) and /work/SRC/openSUSE:Factory/.iniparser.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "iniparser" Mon Aug 27 13:00:06 2018 rev:9 rq:631638 version:4.1 Changes: -------- --- /work/SRC/openSUSE:Factory/iniparser/iniparser.changes 2015-08-25 11:50:04.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.iniparser.new/iniparser.changes 2018-08-27 13:00:08.456868016 +0200 @@ -1,0 +2,10 @@ +Sat Nov 11 05:21:56 UTC 2017 - [email protected] + +- Update to 4.1 (stable release) + + For full change set, see: + https://github.com/ndevilla/iniparser/compare/b1c4ac6f...v4.1 +- Cleanup with spec-cleaner +- Rebase iniparser_remove_rpath.patch +- so number bumped from 0 to 1 per upstream policy + +------------------------------------------------------------------- Old: ---- iniparser-4.0.0.git20150605_b1c4ac6f.tar.gz New: ---- iniparser-4.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ iniparser.spec ++++++ --- /var/tmp/diff_new_pack.OPxJxR/_old 2018-08-27 13:00:09.124868744 +0200 +++ /var/tmp/diff_new_pack.OPxJxR/_new 2018-08-27 13:00:09.128868749 +0200 @@ -1,7 +1,7 @@ # # spec file for package iniparser # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,28 +16,28 @@ # +# if bumping this, also update baselibs.conf +%define sonum 1 Name: iniparser -Version: 4.0.0.git20150605_b1c4ac6f +Version: 4.1 Release: 0 -Url: http://ndevilla.free.fr/iniparser/ Summary: Library to parse ini files License: MIT Group: System/Libraries -#Source: http://ndevilla.free.fr/iniparser/iniparser-%{version}.tar.gz -Source: iniparser-%{version}.tar.gz +URL: http://ndevilla.free.fr/iniparser/ +Source: https://github.com/ndevilla/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz Source2: baselibs.conf Patch00: iniparser_remove_rpath.patch -BuildRoot: %{_tmppath}/%{name}-%{version}-build %description Libiniparser offers parsing of ini files from the C level. - %if 0%{?suse_version} == 0 || 0%{?suse_version} > 1100 -%define libiniparser_name libiniparser0 +%define libiniparser_name libiniparser%{sonum} %else %define libiniparser_name libiniparser %endif + %package -n %{libiniparser_name} Summary: Library to parse ini files Group: System/Libraries @@ -45,8 +45,7 @@ %description -n %{libiniparser_name} Libiniparser offers parsing of ini files from the C level. -This package includes the libiniparser0 library. - +This package includes the libiniparser%{sonum} library. %package -n libiniparser-devel Summary: Libraries and Header Files to Develop Programs with libiniparser Support @@ -64,44 +63,37 @@ The libiniparser offers parsing of ini files from the C level. See a complete documentation in HTML format, from the -/usr/share/doc/packages/libiniparser-devel directory open the file +%{_docdir}/libiniparser-devel directory open the file html/index.html with any HTML-capable browser. Libraries and Header Files to Develop Programs with iniparser Support. - %prep %setup -q %patch00 -p1 %build -%{__make} %{?jobs:-j%jobs} CFLAGS="%{optflags} -fPIC" libiniparser.so +make %{?_smp_mflags} CFLAGS="%{optflags} -fPIC" %install -%__install -d -m 0755 %{buildroot}%{_includedir} -%__install -d -m 0755 %{buildroot}%{_libdir} -%__install -m 0755 libiniparser.so.0 %{buildroot}%{_libdir} -%__install -m 0644 src/{dictionary,iniparser}.h %{buildroot}%{_includedir} -%__ln_s -f libiniparser.so.0 %{buildroot}%{_libdir}/libiniparser.so +install -d -m 0755 %{buildroot}%{_includedir} +install -d -m 0755 %{buildroot}%{_libdir} +install -m 0755 libiniparser.so.%{sonum} %{buildroot}%{_libdir} +install -m 0644 src/{dictionary,iniparser}.h %{buildroot}%{_includedir} +ln -s -f libiniparser.so.%{sonum} %{buildroot}%{_libdir}/libiniparser.so %check -%__ln_s libiniparser.so.0 libiniparser.so -%{__make} check - -%clean -%__rm -rf %{buildroot} +ln -s libiniparser.so.%{sonum} libiniparser.so +make %{?_smp_mflags} check %post -n %{libiniparser_name} -p /sbin/ldconfig - %postun -n %{libiniparser_name} -p /sbin/ldconfig %files -n %{libiniparser_name} -%defattr(-,root,root) %{_libdir}/libiniparser.so.* %doc LICENSE %files -n libiniparser-devel -%defattr(-,root,root) %{_includedir}/*.h %{_libdir}/libiniparser.so %doc html ++++++ baselibs.conf ++++++ --- /var/tmp/diff_new_pack.OPxJxR/_old 2018-08-27 13:00:09.156868779 +0200 +++ /var/tmp/diff_new_pack.OPxJxR/_new 2018-08-27 13:00:09.160868783 +0200 @@ -1 +1 @@ -libiniparser0 +libiniparser1 \ No newline at end of file ++++++ iniparser-4.0.0.git20150605_b1c4ac6f.tar.gz -> iniparser-4.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/.gitignore new/iniparser-4.1/.gitignore --- old/iniparser-4.0.0.git20150605_b1c4ac6f/.gitignore 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/.gitignore 2017-11-02 10:09:15.000000000 +0100 @@ -3,7 +3,7 @@ *.a *.o *.so -*.so.0 +*.so.* /example/iniexample /example/parse # Autogenerate source file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/FAQ-en.md new/iniparser-4.1/FAQ-en.md --- old/iniparser-4.0.0.git20150605_b1c4ac6f/FAQ-en.md 1970-01-01 01:00:00.000000000 +0100 +++ new/iniparser-4.1/FAQ-en.md 2017-11-02 10:09:15.000000000 +0100 @@ -0,0 +1,37 @@ +# iniparser FAQ # + +## Is iniparser thread safe ? + +Starting from version 4, iniparser is designed to be thread-safe, provided +you surround it with your own mutex logic. The choice to not add thread +safety inside the library has been made to provide more freedom for the +developer, especially when dealing with their own custom reading logic +e.g. acquiring the mutex, reading entries with iniparser, then releasing +the mutex. + +## Your build system isn't portable, let me help you... + +We have received countless contributions from distrib people to modify the +Makefile into what they think is the "standard", which we had to reject. +The default, standard Makefile for Debian bears absolutely no relationship +with the one from SuSE or RedHat and there is no possible way to merge them +all. A build system is something so specific to each environment that it +is completely pointless to try and push anything that claims to be +standard. The provided Makefile in this project is purely here to have +something to play with quickly. + +## iniparser_dump() is slow + +The dumping functions are based on fprintf, which can turn out to be +surprisingly slow on some embedded platforms. You can replace fprintf by a +combined use of sprintf and fwrite, or you can use setvbuf() to change +buffering parameters to accomodate fprintf(). Something like: + +setvbuf(f, NULL, _IOFBF, 0); + +## iniparser does not compile with my C++ compiler! + +See the docs: iniparser is a C library. C++ is quite a different language, +despite the promises of compatibility. You will have to modify iniparser +quite heavily to make it work with a C++ compiler. Good luck! + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/FAQ-zhcn.md new/iniparser-4.1/FAQ-zhcn.md --- old/iniparser-4.0.0.git20150605_b1c4ac6f/FAQ-zhcn.md 1970-01-01 01:00:00.000000000 +0100 +++ new/iniparser-4.1/FAQ-zhcn.md 2017-11-02 10:09:15.000000000 +0100 @@ -0,0 +1,27 @@ +# iniparser FAQ # + +## iniparser线程安全吗 ? + +从版本4开始,iniparser被设计成线程安全的,你需要围绕它处理你自己的互斥逻辑。 +选择不在库中添加线程安全,是为开发者提供更多的自由,特别是在处理他们自己的读 +逻辑。如获取互斥锁,用iniparser阅读条目,然后释放互斥体。 + +## 你的构建系统不可移植,让我来帮助你... + +我们已经收到了来各地的开发人员的无数贡献,将Makefile修改为他们认为是“标准”的 +内容,但是我们不得不拒绝。 默认情况下,Debian的标准Makefile与SuSE或RedHat完 +全没有关系,没有可能的方式将它们全部合并。 构建系统对于每个环境来说都是特别的, +尝试推动任何声称是标准的东西是完全没有意义的。 在这个项目中提供的Makefile纯粹 +是为了快速的把库跑起来。 + +## iniparser_dump() 速度慢 + +dump函数是基于fprintf的,在嵌入式平台上它可能导致很慢。你可以把fprintf换成 +sprintf和fwrite的组合,或者可以使用setvbfu()来改变fprintf的缓存参数。比如: + +setvbuf(f, NULL, _IOFBF, 0); + +## 用我的c++编译器不能编译iniparser! + +看文档:iniparser是一个C库。虽然C++兼容C,但它却是另外一门语言。让iniparser在 +C++编译器下工作,会是一份繁重的工作。祝你好运! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/Makefile new/iniparser-4.1/Makefile --- old/iniparser-4.0.0.git20150605_b1c4ac6f/Makefile 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/Makefile 2017-11-02 10:09:15.000000000 +0100 @@ -1,17 +1,20 @@ # # iniparser Makefile # +.PHONY: example # Compiler settings CC ?= gcc CFLAGS += -fPIC -Wall -Wextra -ansi -pedantic ifndef DEBUG -CFLAGS += -O2 +ADDITIONAL_CFLAGS ?= -O2 else -CFLAGS += -g +ADDITIONAL_CFLAGS ?= -g endif +CFLAGS += ${ADDITIONAL_CFLAGS} + # Ar settings to build the library AR ?= ar ARFLAGS = rcv @@ -20,6 +23,9 @@ LDSHFLAGS = -shared -Wl,-Bsymbolic LDFLAGS += -Wl,-rpath -Wl,/usr/lib -Wl,-rpath,/usr/lib +# .so.0 is for version 3.x, .so.1 is 4.x +SO_TARGET ?= libiniparser.so.1 + # Set RANLIB to ranlib on systems that require it (Sun OS < 4, Mac OSX) # RANLIB = ranlib RANLIB = true @@ -50,22 +56,22 @@ OBJS = $(SRCS:.c=.o) -default: libiniparser.a libiniparser.so +default: libiniparser.a $(SO_TARGET) libiniparser.a: $(OBJS) $(QUIET_AR)$(AR) $(ARFLAGS) $@ $^ $(QUIET_RANLIB)$(RANLIB) $@ -libiniparser.so: $(OBJS) - $(QUIET_LINK)$(SHLD) $(LDSHFLAGS) $(LDFLAGS) -o [email protected] $(OBJS) \ - -Wl,-soname=`basename $@`.0 +$(SO_TARGET): $(OBJS) + $(QUIET_LINK)$(SHLD) $(LDSHFLAGS) $(LDFLAGS) -o $(SO_TARGET) $(OBJS) \ + -Wl,-soname=`basename $(SO_TARGET)` clean: $(RM) $(OBJS) @(cd test ; $(MAKE) clean) veryclean: - $(RM) $(OBJS) libiniparser.a libiniparser.so* + $(RM) $(OBJS) libiniparser.a $(SO_TARGET) rm -rf ./html ; mkdir html cd example ; $(MAKE) veryclean cd test ; $(MAKE) veryclean @@ -73,9 +79,8 @@ docs: @(cd doc ; $(MAKE)) -check: libiniparser.so +check: $(SO_TARGET) @(cd test ; $(MAKE)) -.PHONY: example example: libiniparser.a @(cd example ; $(MAKE)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/README.md new/iniparser-4.1/README.md --- old/iniparser-4.0.0.git20150605_b1c4ac6f/README.md 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/README.md 2017-11-02 10:09:15.000000000 +0100 @@ -33,20 +33,12 @@ ## IV - Versions -Current version is 4.0 which introduces breaking changes in the api. +Current version is 4.1. Version 4.0 introduces breaking changes in the api. Older versions 3.1 and 3.2 with the legacy api are available as tags. ## V - FAQ -### Is Iniparser thread safe ? - -Starting from version 4, iniparser is designed to be thread-safe, provided you surround it with your own mutex logic. -The choice not to add thread safety inside the library has been done to provide more freedom for the developer, especially when dealing with it own custom reading logic (i.g. acquiring the mutex, reading plenty of entries in iniparser, then releasing the mutex). - -### Your build system isn't portable, let me help you... - -I have received countless contributions from distrib people to modify the Makefile into what they think is the "standard", which I had to reject. -The default, standard Makefile for Debian bears absolutely no relationship with the one from SuSE or RedHat and there is no possible way to merge them all. -A build system is something so specific to each environment that it is completely pointless to try and push anything that claims to be standard. The provided Makefile in this project is purely here to have something to play with quickly. +See [FAQ-en.md](FAQ-en.md) in this directory for answers to Frequently Asked Questions. +还有简化中国翻译在[FAQ-zhcn.md](FAQ-zhcn.md). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/doc/iniparser.dox new/iniparser-4.1/doc/iniparser.dox --- old/iniparser-4.0.0.git20150605_b1c4ac6f/doc/iniparser.dox 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/doc/iniparser.dox 2017-11-02 10:09:15.000000000 +0100 @@ -1,5 +1,5 @@ PROJECT_NAME = iniparser -PROJECT_NUMBER = 4.0 +PROJECT_NUMBER = 4.1 OUTPUT_DIRECTORY = .. OUTPUT_LANGUAGE = English EXTRACT_ALL = YES diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/example/Makefile new/iniparser-4.1/example/Makefile --- old/iniparser-4.0.0.git20150605_b1c4ac6f/example/Makefile 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/example/Makefile 2017-11-02 10:09:15.000000000 +0100 @@ -2,12 +2,12 @@ # iniparser tests Makefile # -CC = gcc -CFLAGS = -g -I../src -LFLAGS = -L.. -liniparser -AR = ar -ARFLAGS = rcv -RM = rm -f +CC ?= gcc +CFLAGS += -g -I../src +LFLAGS += -L.. -liniparser +AR ?= ar +ARFLAGS += rcv +RM ?= rm -f default: all diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/html/index.html new/iniparser-4.1/html/index.html --- old/iniparser-4.0.0.git20150605_b1c4ac6f/html/index.html 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/html/index.html 2017-11-02 10:09:15.000000000 +0100 @@ -9,7 +9,7 @@ <body> <!-- Generated by Doxygen 1.6.3 --> <div class="contents"> -<h1>iniparser documentation </h1><h3 class="version">3.0 </h3><h2><a class="anchor" id="welcome"> +<h1>iniparser documentation </h1><h3 class="version">4.0 </h3><h2><a class="anchor" id="welcome"> Introduction</a></h2> <p>iniParser is a simple C library offering ini file parsing services. The library is pretty small (less than 1500 lines of C) and robust, and does not depend on any other external library to compile. It is written in ANSI C and should compile on most platforms without difficulty.</p> <h2><a class="anchor" id="inidef"> @@ -94,8 +94,8 @@ Authors</a></h2> <p>Nicolas Devillard (ndevilla AT free DOT fr). </p> </div> -<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Mar 2 22:04:58 2011 for iniparser by +<hr class="footer"/><address style="text-align: right;"><small>Generated on Sun Jun 12 19:07:18 2016 for iniparser by <a href="http://www.doxygen.org/index.html"> -<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> +<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </small></address> </body> </html> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/src/iniparser.c new/iniparser-4.1/src/iniparser.c --- old/iniparser-4.0.0.git20150605_b1c4ac6f/src/iniparser.c 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/src/iniparser.c 2017-11-02 10:09:15.000000000 +0100 @@ -8,6 +8,7 @@ /*--------------------------------------------------------------------------*/ /*---------------------------- Includes ------------------------------------*/ #include <ctype.h> +#include <stdarg.h> #include "iniparser.h" /*---------------------------- Defines -------------------------------------*/ @@ -87,7 +88,7 @@ @return unsigned New size of the string. */ /*--------------------------------------------------------------------------*/ -unsigned strstrip(char * s) +static unsigned strstrip(char * s) { char *last = NULL ; char *dest = s; @@ -109,6 +110,41 @@ /*-------------------------------------------------------------------------*/ /** + @brief Default error callback for iniparser: wraps `fprintf(stderr, ...)`. + */ +/*--------------------------------------------------------------------------*/ +static int default_error_callback(const char *format, ...) +{ + int ret; + va_list argptr; + va_start(argptr, format); + ret = vfprintf(stderr, format, argptr); + va_end(argptr); + return ret; +} + +static int (*iniparser_error_callback)(const char*, ...) = default_error_callback; + +/*-------------------------------------------------------------------------*/ +/** + @brief Configure a function to receive the error messages. + @param errback Function to call. + + By default, the error will be printed on stderr. If a null pointer is passed + as errback the error callback will be switched back to default. + */ +/*--------------------------------------------------------------------------*/ +void iniparser_set_error_callback(int (*errback)(const char *, ...)) +{ + if (errback) { + iniparser_error_callback = errback; + } else { + iniparser_error_callback = default_error_callback; + } +} + +/*-------------------------------------------------------------------------*/ +/** @brief Get number of sections in a dictionary @param d Dictionary to examine @return int Number of sections found in dictionary @@ -303,7 +339,8 @@ if (! iniparser_find_entry(d, s)) return nkeys; seclen = (int)strlen(s); - sprintf(keym, "%s:", s); + strlwc(s, keym, sizeof(keym)); + keym[seclen] = ':'; for (j=0 ; j<d->size ; j++) { if (d->key[j]==NULL) @@ -341,7 +378,8 @@ if (! iniparser_find_entry(d, s)) return NULL; seclen = (int)strlen(s); - sprintf(keym, "%s:", s); + strlwc(s, keym, sizeof(keym)); + keym[seclen] = ':'; i = 0; @@ -388,11 +426,11 @@ /*-------------------------------------------------------------------------*/ /** - @brief Get the string associated to a key, convert to an int + @brief Get the string associated to a key, convert to an long int @param d Dictionary to search @param key Key string to look for @param notfound Value to return in case of error - @return integer + @return long integer This function queries a dictionary for a key. A key as read from an ini file is given as "section:key". If the key cannot be found, @@ -413,13 +451,46 @@ Credits: Thanks to A. Becker for suggesting strtol() */ /*--------------------------------------------------------------------------*/ -int iniparser_getint(const dictionary * d, const char * key, int notfound) +long int iniparser_getlongint(const dictionary * d, const char * key, long int notfound) { const char * str ; str = iniparser_getstring(d, key, INI_INVALID_KEY); if (str==INI_INVALID_KEY) return notfound ; - return (int)strtol(str, NULL, 0); + return strtol(str, NULL, 0); +} + + +/*-------------------------------------------------------------------------*/ +/** + @brief Get the string associated to a key, convert to an int + @param d Dictionary to search + @param key Key string to look for + @param notfound Value to return in case of error + @return integer + + This function queries a dictionary for a key. A key as read from an + ini file is given as "section:key". If the key cannot be found, + the notfound value is returned. + + Supported values for integers include the usual C notation + so decimal, octal (starting with 0) and hexadecimal (starting with 0x) + are supported. Examples: + + "42" -> 42 + "042" -> 34 (octal -> decimal) + "0x42" -> 66 (hexa -> decimal) + + Warning: the conversion may overflow in various ways. Conversion is + totally outsourced to strtol(), see the associated man page for overflow + handling. + + Credits: Thanks to A. Becker for suggesting strtol() + */ +/*--------------------------------------------------------------------------*/ +int iniparser_getint(const dictionary * d, const char * key, int notfound) +{ + return (int)iniparser_getlongint(d, key, notfound); } /*-------------------------------------------------------------------------*/ @@ -586,9 +657,14 @@ strlwc(section, section, len); sta = LINE_SECTION ; } else if (sscanf (line, "%[^=] = \"%[^\"]\"", key, value) == 2 - || sscanf (line, "%[^=] = '%[^\']'", key, value) == 2 - || sscanf (line, "%[^=] = %[^;#]", key, value) == 2) { - /* Usual key=value, with or without comments */ + || sscanf (line, "%[^=] = '%[^\']'", key, value) == 2) { + /* Usual key=value with quotes, with or without comments */ + strstrip(key); + strlwc(key, key, len); + /* Don't strip spaces from values surrounded with quotes */ + sta = LINE_VALUE ; + } else if (sscanf (line, "%[^=] = %[^;#]", key, value) == 2) { + /* Usual key=value without quotes, with or without comments */ strstrip(key); strlwc(key, key, len); strstrip(value); @@ -649,11 +725,12 @@ int len ; int lineno=0 ; int errs=0; + int mem_err=0; dictionary * dict ; if ((in=fopen(ininame, "r"))==NULL) { - fprintf(stderr, "iniparser: cannot open %s\n", ininame); + iniparser_error_callback("iniparser: cannot open %s\n", ininame); return NULL ; } @@ -672,14 +749,14 @@ while (fgets(line+last, ASCIILINESZ-last, in)!=NULL) { lineno++ ; len = (int)strlen(line)-1; - if (len==0) + if (len<=0) continue; /* Safety check against buffer overflows */ if (line[len]!='\n' && !feof(in)) { - fprintf(stderr, - "iniparser: input line too long in %s (%d)\n", - ininame, - lineno); + iniparser_error_callback( + "iniparser: input line too long in %s (%d)\n", + ininame, + lineno); dictionary_del(dict); fclose(in); return NULL ; @@ -707,19 +784,20 @@ break ; case LINE_SECTION: - errs = dictionary_set(dict, section, NULL); + mem_err = dictionary_set(dict, section, NULL); break ; case LINE_VALUE: sprintf(tmp, "%s:%s", section, key); - errs = dictionary_set(dict, tmp, val) ; + mem_err = dictionary_set(dict, tmp, val); break ; case LINE_ERROR: - fprintf(stderr, "iniparser: syntax error in %s (%d):\n", - ininame, - lineno); - fprintf(stderr, "-> %s\n", line); + iniparser_error_callback( + "iniparser: syntax error in %s (%d):\n-> %s\n", + ininame, + lineno, + line); errs++ ; break; @@ -728,8 +806,8 @@ } memset(line, 0, ASCIILINESZ); last=0; - if (errs<0) { - fprintf(stderr, "iniparser: memory allocation failure\n"); + if (mem_err<0) { + iniparser_error_callback("iniparser: memory allocation failure\n"); break ; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/src/iniparser.h new/iniparser-4.1/src/iniparser.h --- old/iniparser-4.0.0.git20150605_b1c4ac6f/src/iniparser.h 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/src/iniparser.h 2017-11-02 10:09:15.000000000 +0100 @@ -33,6 +33,18 @@ /*-------------------------------------------------------------------------*/ /** + @brief Configure a function to receive the error messages. + @param errback Function to call. + + By default, the error will be printed on stderr. If a null pointer is passed + as errback the error callback will be switched back to default. + */ +/*--------------------------------------------------------------------------*/ + +void iniparser_set_error_callback(int (*errback)(const char *, ...)); + +/*-------------------------------------------------------------------------*/ +/** @brief Get number of sections in a dictionary @param d Dictionary to examine @return int Number of sections found in dictionary @@ -192,6 +204,34 @@ /*-------------------------------------------------------------------------*/ /** + @brief Get the string associated to a key, convert to an long int + @param d Dictionary to search + @param key Key string to look for + @param notfound Value to return in case of error + @return integer + + This function queries a dictionary for a key. A key as read from an + ini file is given as "section:key". If the key cannot be found, + the notfound value is returned. + + Supported values for integers include the usual C notation + so decimal, octal (starting with 0) and hexadecimal (starting with 0x) + are supported. Examples: + + - "42" -> 42 + - "042" -> 34 (octal -> decimal) + - "0x42" -> 66 (hexa -> decimal) + + Warning: the conversion may overflow in various ways. Conversion is + totally outsourced to strtol(), see the associated man page for overflow + handling. + */ +/*--------------------------------------------------------------------------*/ +long int iniparser_getlongint(const dictionary * d, const char * key, long int notfound); + + +/*-------------------------------------------------------------------------*/ +/** @brief Get the string associated to a key, convert to a double @param d Dictionary to search @param key Key string to look for diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/test/CuTest.c new/iniparser-4.1/test/CuTest.c --- old/iniparser-4.0.0.git20150605_b1c4ac6f/test/CuTest.c 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/test/CuTest.c 2017-11-02 10:09:15.000000000 +0100 @@ -211,6 +211,15 @@ CuFail_Line(tc, file, line, message, buf); } +void CuAssertLongIntEquals_LineMsg(CuTest *tc, const char *file, int line, const char *message, + long int expected, long int actual) +{ + char buf[STRING_MAX]; + if (expected == actual) return; + sprintf(buf, "expected <%ld> but was <%ld>", expected, actual); + CuFail_Line(tc, file, line, message, buf); +} + void CuAssertDblEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message, double expected, double actual, double delta) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/test/CuTest.h new/iniparser-4.1/test/CuTest.h --- old/iniparser-4.0.0.git20150605_b1c4ac6f/test/CuTest.h 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/test/CuTest.h 2017-11-02 10:09:15.000000000 +0100 @@ -64,6 +64,9 @@ void CuAssertIntEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message, int expected, int actual); +void CuAssertLongIntEquals_LineMsg(CuTest *tc, + const char *file, int line, const char *message, + long int expected, long int actual); void CuAssertDblEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message, double expected, double actual, double delta); @@ -81,6 +84,8 @@ #define CuAssertStrEquals_Msg(tc,ms,ex,ac) CuAssertStrEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac)) #define CuAssertIntEquals(tc,ex,ac) CuAssertIntEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac)) #define CuAssertIntEquals_Msg(tc,ms,ex,ac) CuAssertIntEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac)) +#define CuAssertLongIntEquals(tc,ex,ac) CuAssertLongIntEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac)) +#define CuAssertLongIntEquals_Msg(tc,ms,ex,ac) CuAssertLongIntEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac)) #define CuAssertDblEquals(tc,ex,ac,dl) CuAssertDblEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac),(dl)) #define CuAssertDblEquals_Msg(tc,ms,ex,ac,dl) CuAssertDblEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac),(dl)) #define CuAssertPtrEquals(tc,ex,ac) CuAssertPtrEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/test/Makefile new/iniparser-4.1/test/Makefile --- old/iniparser-4.0.0.git20150605_b1c4ac6f/test/Makefile 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/test/Makefile 2017-11-02 10:09:15.000000000 +0100 @@ -11,8 +11,9 @@ OBJ = $(SRC:.c=.o) INCLUDE = -I../src -CFLAGS = -pipe -ansi -pedantic -Wall -Wextra -g -LDFLAGS = +CFLAGS += -pipe -ansi -pedantic -Wall -Wextra -g +LDFLAGS += + all: check check: testrun diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/test/ressources/bad_ini/ends_well.ini new/iniparser-4.1/test/ressources/bad_ini/ends_well.ini --- old/iniparser-4.0.0.git20150605_b1c4ac6f/test/ressources/bad_ini/ends_well.ini 1970-01-01 01:00:00.000000000 +0100 +++ new/iniparser-4.1/test/ressources/bad_ini/ends_well.ini 2017-11-02 10:09:15.000000000 +0100 @@ -0,0 +1,6 @@ +# +# This dict contains an error but ends up with a correct entry +# +[section] +error is here +a = b diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/test/test_dictionary.c new/iniparser-4.1/test/test_dictionary.c --- old/iniparser-4.0.0.git20150605_b1c4ac6f/test/test_dictionary.c 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/test/test_dictionary.c 2017-11-02 10:09:15.000000000 +0100 @@ -122,7 +122,10 @@ fclose(fd); return NULL; } - fread(dump_buff, 1, dump_size, fd); + if (fread(dump_buff, 1, dump_size, fd) != (size_t)dump_size) { + fclose(fd); + return NULL; + } fclose(fd); return dump_buff; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/iniparser-4.0.0.git20150605_b1c4ac6f/test/test_iniparser.c new/iniparser-4.1/test/test_iniparser.c --- old/iniparser-4.0.0.git20150605_b1c4ac6f/test/test_iniparser.c 2015-06-05 18:42:26.000000000 +0200 +++ new/iniparser-4.1/test/test_iniparser.c 2017-11-02 10:09:15.000000000 +0100 @@ -3,6 +3,7 @@ #include <unistd.h> #include <sys/stat.h> #include <sys/types.h> +#include <stdarg.h> #include "CuTest.h" #include "dictionary.h" @@ -230,9 +231,9 @@ dictionary_unset(dic, "sec0:key2"); CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, "sec42", keys)); - nkeys = iniparser_getsecnkeys(dic, "sec99"); + nkeys = iniparser_getsecnkeys(dic, "Sec99"); CuAssertIntEquals(tc, nkeys, 9); - CuAssertPtrEquals(tc, keys, iniparser_getseckeys(dic, "sec99", keys)); + CuAssertPtrEquals(tc, keys, iniparser_getseckeys(dic, "Sec99", keys)); for (i = 0; i < 9; ++i) { sprintf(key_name, "sec99:key%d", i); CuAssertStrEquals(tc, key_name, keys[i]); @@ -337,6 +338,69 @@ dictionary_del(dic); } +void Test_iniparser_getlongint(CuTest *tc) +{ + unsigned i; + char key_name[64]; + dictionary *dic; + const struct { long int num; const char *value; } good_val[] = { + { 0, "0" }, + { 1, "1" }, + { -1, "-1" }, + { 1000, "1000" }, + { 077, "077" }, + { -01000, "-01000" }, + { 0x7FFFFFFFFFFFFFFF, "0x7FFFFFFFFFFFFFFF" }, + { -0x7FFFFFFFFFFFFFFF, "-0x7FFFFFFFFFFFFFFF" }, + { 0x4242, "0x4242" }, + { 0, NULL} /* must be last */ + }; + const char *bad_val[] = { + "", + "notanumber", + "0x", + "k2000", + " ", + "0xG1" + }; + /* NULL test */ + CuAssertLongIntEquals(tc, -42, iniparser_getlongint(NULL, NULL, -42)); + CuAssertLongIntEquals(tc, -42, iniparser_getlongint(NULL, "dummy", -42)); + + /* Check the def return element */ + dic = dictionary_new(10); + CuAssertLongIntEquals(tc, 42, iniparser_getlongint(dic, "dummy", 42)); + CuAssertLongIntEquals(tc, 0x7FFFFFFFFFFFFFFF, iniparser_getlongint(dic, NULL, 0x7FFFFFFFFFFFFFFF)); + CuAssertLongIntEquals(tc, -0x7FFFFFFFFFFFFFFF, iniparser_getlongint(dic, "dummy", -0x7FFFFFFFFFFFFFFF)); + dictionary_del(dic); + + /* Generic dictionary */ + dic = dictionary_new(10); + for (i = 0; good_val[i].value != NULL; ++i) { + sprintf(key_name, "longint:value%d", i); + dictionary_set(dic, key_name, good_val[i].value); + } + for (i = 0; good_val[i].value != NULL; ++i) { + sprintf(key_name, "longint:value%d", i); + CuAssertLongIntEquals(tc, good_val[i].num, + iniparser_getlongint(dic, key_name, 0)); + } + dictionary_del(dic); + + /* Test bad names */ + dic = dictionary_new(10); + for (i = 0; i < sizeof (bad_val) / sizeof (char *); ++i) { + sprintf(key_name, "longint:bad%d", i); + dictionary_set(dic, key_name, bad_val[i]); + } + for (i = 0; i < sizeof (bad_val) / sizeof (char *); ++i) { + sprintf(key_name, "longint:bad%d", i); + CuAssertLongIntEquals(tc, 0, + iniparser_getlongint(dic, key_name, 0)); + } + dictionary_del(dic); +} + void Test_iniparser_getdouble(CuTest *tc) { dictionary *dic; @@ -487,6 +551,10 @@ CuAssertStrEquals(tc, "empty_value", key); CuAssertStrEquals(tc, "", val); + CuAssertIntEquals(tc, LINE_VALUE, iniparser_line("empty_value = \t\n", section, key, val)); + CuAssertStrEquals(tc, "empty_value", key); + CuAssertStrEquals(tc, "", val); + CuAssertIntEquals(tc, LINE_VALUE, iniparser_line("key =\tval # comment", section, key, val)); CuAssertStrEquals(tc, "key", key); CuAssertStrEquals(tc, "val", val); @@ -498,10 +566,27 @@ CuAssertIntEquals(tc, LINE_COMMENT, iniparser_line(";comment", section, key, val)); CuAssertIntEquals(tc, LINE_COMMENT, iniparser_line(" # comment", section, key, val)); + CuAssertIntEquals(tc, LINE_VALUE, iniparser_line("key = \" do_not_strip \"", section, key, val)); + CuAssertStrEquals(tc, "key", key); + CuAssertStrEquals(tc, " do_not_strip ", val); + + CuAssertIntEquals(tc, LINE_VALUE, iniparser_line("key = ' '", section, key, val)); + CuAssertStrEquals(tc, "key", key); + CuAssertStrEquals(tc, " ", val); + + CuAssertIntEquals(tc, LINE_VALUE, iniparser_line("key = \"\"", section, key, val)); + CuAssertStrEquals(tc, "key", key); + CuAssertStrEquals(tc, "", val); + + CuAssertIntEquals(tc, LINE_VALUE, iniparser_line("key = ''", section, key, val)); + CuAssertStrEquals(tc, "key", key); + CuAssertStrEquals(tc, "", val); + /* Test syntax error */ CuAssertIntEquals(tc, LINE_ERROR, iniparser_line("empty_value", section, key, val)); CuAssertIntEquals(tc, LINE_ERROR, iniparser_line("not finished\\", section, key, val)); CuAssertIntEquals(tc, LINE_ERROR, iniparser_line("0x42 / 0b101010", section, key, val)); + } void Test_iniparser_load(CuTest *tc) @@ -577,3 +662,37 @@ iniparser_freedict(dic); } + +static char _last_error[1024]; +static int _error_callback(const char *format, ...) +{ + int ret; + va_list argptr; + va_start(argptr, format); + ret = vsprintf(_last_error, format, argptr); + va_end(argptr); + return ret; + +} + +void Test_iniparser_error_callback(CuTest *tc) +{ + dictionary *dic; + + /* Specify our custom error_callback */ + iniparser_set_error_callback(_error_callback); + + /* Trigger an error and check it was written on the right output */ + dic = iniparser_load("/path/to/nowhere.ini"); + CuAssertPtrEquals(tc, NULL, dic); + CuAssertStrEquals(tc, "iniparser: cannot open /path/to/nowhere.ini\n", _last_error); + + /* Reset erro_callback */ + _last_error[0] = '\0'; + iniparser_set_error_callback(NULL); + + /* Make sure custom callback is no more called */ + dic = iniparser_load("/path/to/nowhere.ini"); + CuAssertPtrEquals(tc, NULL, dic); + CuAssertStrEquals(tc, "", _last_error); +} ++++++ iniparser_remove_rpath.patch ++++++ --- /var/tmp/diff_new_pack.OPxJxR/_old 2018-08-27 13:00:09.220868849 +0200 +++ /var/tmp/diff_new_pack.OPxJxR/_new 2018-08-27 13:00:09.224868853 +0200 @@ -1,13 +1,13 @@ Index: iniparser/Makefile =================================================================== ---- iniparser.orig/Makefile -+++ iniparser/Makefile -@@ -18,7 +18,7 @@ ARFLAGS = rcv +--- a/Makefile ++++ b/Makefile +@@ -21,7 +21,7 @@ ARFLAGS = rcv SHLD = ${CC} ${CFLAGS} LDSHFLAGS = -shared -Wl,-Bsymbolic -LDFLAGS += -Wl,-rpath -Wl,/usr/lib -Wl,-rpath,/usr/lib -+LDFLAGS += ++LDFLAGS += - # Set RANLIB to ranlib on systems that require it (Sun OS < 4, Mac OSX) - # RANLIB = ranlib + # .so.0 is for version 3.x, .so.1 is 4.x + SO_TARGET ?= libiniparser.so.1
