From a1bdcfa3ca8af4ddb69ee57d716aa943cf3fe94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 16 May 2020 16:33:18 +0200 Subject: New upstream version 3.25 --- aclocal.m4 | 1 - configure | 59 +++---------- configure.ac | 2 +- doc/api.txt | 6 +- doc/changelog.txt | 11 +++ doc/generate | 15 +++- doc/libHX_Documentation.lyx | 164 ++++++++--------------------------- doc/libHX_Documentation.pdf | Bin 507850 -> 522656 bytes include/libHX/defs.h | 29 ++----- include/libHX/libxml_helper.h | 1 - include/libHX/misc.h | 2 - include/libHX/string.h | 6 +- src/Makefile.am | 2 +- src/Makefile.in | 2 +- src/internal.h | 6 -- src/io.c | 1 + src/libHX.map | 195 ++++++++++++++---------------------------- src/map.c | 2 +- src/misc.c | 2 + src/rtcheck.c | 8 +- src/string.c | 12 +-- src/tc-dir.c | 1 + src/tc-link.c | 10 +-- src/tc-memmem.c | 1 + src/tc-string.c | 16 +++- src/time.c | 23 +++-- 26 files changed, 190 insertions(+), 387 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 578e3bd..7b980d4 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -591,7 +591,6 @@ dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl -AM_SILENT_RULES([yes]) # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile diff --git a/configure b/configure index 2e849c1..9327b1f 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libHX 3.24. +# Generated by GNU Autoconf 2.69 for libHX 3.25. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libHX' PACKAGE_TARNAME='libhx' -PACKAGE_VERSION='3.24' -PACKAGE_STRING='libHX 3.24' +PACKAGE_VERSION='3.25' +PACKAGE_STRING='libHX 3.25' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1342,7 +1342,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libHX 3.24 to adapt to many kinds of systems. +\`configure' configures libHX 3.25 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1412,7 +1412,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libHX 3.24:";; + short | recursive ) echo "Configuration of libHX 3.25:";; esac cat <<\_ACEOF @@ -1527,7 +1527,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libHX configure 3.24 +libHX configure 3.25 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2253,7 +2253,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libHX $as_me 3.24, which was +It was created by libHX $as_me 3.25, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3119,7 +3119,7 @@ fi # Define the identity of the package. PACKAGE='libhx' - VERSION='3.24' + VERSION='3.25' cat >>confdefs.h <<_ACEOF @@ -3254,45 +3254,6 @@ $as_echo "$am_cv_prog_tar_pax" >&6; } -# Check whether --enable-silent-rules was given. -if test "${enable_silent_rules+set}" = set; then : - enableval=$enable_silent_rules; -fi - -case $enable_silent_rules in # ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=0;; -esac -am_make=${MAKE-make} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 -$as_echo_n "checking whether $am_make supports nested variables... " >&6; } -if ${am_cv_make_support_nested_variables+:} false; then : - $as_echo_n "(cached) " >&6 -else - if $as_echo 'TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 -$as_echo "$am_cv_make_support_nested_variables" >&6; } -if test $am_cv_make_support_nested_variables = yes; then - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AM_BACKSLASH='\' - # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile @@ -17720,7 +17681,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libHX $as_me 3.24, which was +This file was extended by libHX $as_me 3.25, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -17786,7 +17747,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libHX config.status 3.24 +libHX config.status 3.25 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index f03a863..119bd7f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libHX], [3.24]) +AC_INIT([libHX], [3.25]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/api.txt b/doc/api.txt index eb3b06b..4649515 100644 --- a/doc/api.txt +++ b/doc/api.txt @@ -15,6 +15,8 @@ F column: Function first seen in version, possibly with different API. RMV MinVer FirstA Name ---------------------------------------------------------------------- +3.25 3.25 3.25 HX_split_fixed +3.25 3.25 3.25 HX_split_inplace 3.22 3.22 3.22 HXQUOTE_SQLBQUOTE 3.21 3.21 3.21 xml_getnsprop 3.19 3.19 3.19 HXQUOTE_SQLSQUOTE @@ -24,7 +26,6 @@ RMV MinVer FirstA Name 3.16 3.16 3.16 container_of 3.16 3.16 3.16 wxCDF 3.16 3.16 3.16 wxDSPAN -3.15 3.15 3.15 FIELD_SIZEOF 3.15 3.15 3.15 HXQUOTE_URIENC 3.15 3.15 3.15 HX_strchr2 3.13 3.13 3.13 DEMOTE_TO_PTR @@ -116,8 +117,6 @@ RMV MinVer FirstA Name 3.0 3.0 3.0 HXMAPT_RBTREE 3.0 3.0 3.0 HXMAP_DTRAV 3.0 3.0 3.0 HXMAP_NOREPLACE -3.0 3.0 3.0 HX_diff_timespec -3.0 3.0 3.0 HX_diff_timeval 3.0 3.0 3.0 HXhash_djb2 3.0 3.0 3.0 HXhash_jlookup3 3.0 3.0 3.0 HXhash_jlookup3s @@ -145,7 +144,6 @@ RMV MinVer FirstA Name 2.6 2.6 2.6 wxfv8 2.6 2.6 2.6 wxtu8 2.6 2.6 2.6 xml_strcasecmp -2.3 2.0 2.0 offsetof 2.3 1.25 1.25 HXmc_length 2.2 2.2 2.2 HXPROC_A0 2.2 2.2 2.2 HXPROC_EXECV diff --git a/doc/changelog.txt b/doc/changelog.txt index 9aff713..ffe75c1 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -1,4 +1,15 @@ +v3.25 (2020-05-14) +================== +Fixes: +* string: fix out-of-bounds access when calling HX_strlcpy(x,y,0) +Changes: +* string: HX_split4 renamed to HX_split_inplace +* string: HX_split5 renamed to HX_split_fixed +* defs.h: removed partially implementation of FIELD_SIZEOF +* defs.h: removed custom offsetof definition; you will need to include + or now. + v3.24 (2018-10-17) ================== diff --git a/doc/generate b/doc/generate index ed3b8aa..3fd48cf 100755 --- a/doc/generate +++ b/doc/generate @@ -3,4 +3,17 @@ if [ -z "$srcdir" ]; then srcdir="."; fi; -exec lyx -e pdf2 "$srcdir/libHX_Documentation.lyx"; +rm -f libHX_Documentation.pdf +lyx -e pdf2 "$srcdir/libHX_Documentation.lyx" || : +# lyx-2.3.2 does not work with texlive-babel-2017.135.3 +# """ +# Package babel Error: You haven't specified a language option. +# ...ry to proceed from here, type x to quit.) +# +# You need to specify a language, either as a global option +# or as an optional argument to the \usepackage command; +# You shouldn't try to proceed form here, type x to quit. +# """ +# babel you so stupid for breaking backward comapt. + +test -e libHX_Documentation.pdf diff --git a/doc/libHX_Documentation.lyx b/doc/libHX_Documentation.lyx index a28f1c6..9e2e9f5 100644 --- a/doc/libHX_Documentation.lyx +++ b/doc/libHX_Documentation.lyx @@ -91,7 +91,7 @@ \begin_body \begin_layout Title -libHX 3.24 +libHX 3.25 \begin_inset Newline newline \end_inset @@ -2620,26 +2620,6 @@ Locators \end_layout \begin_layout LyX-Code - -\series bold -long -\series default - offsetof(type, member); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -offsetof -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - output_type \series bold * @@ -2668,14 +2648,14 @@ containerof \series bold size_t \series default - FIELD_SIZEOF(struct_type, member); + HXsizeof_member(struct_type, member); \begin_inset Index idx status open \begin_layout Plain Layout \family typewriter -FIELD_SIZEOF +HXsizeof_member \end_layout \end_inset @@ -2699,55 +2679,6 @@ HXtypeof_member \end_layout -\begin_layout Standard -In case -\family typewriter -offsetof -\family default - and -\family typewriter -containerof -\family default - have not already defined by inclusion of another header file, libHX's defs.h - will define these accessors. - -\family typewriter -offsetof -\family default - is defined in -\family typewriter -stddef.h -\family default - (for C) or -\family typewriter -cstddef -\family default - (C++), but inclusion of these is not necessary if you have included -\family typewriter -defs.h -\family default -. - -\family typewriter -defs.h -\family default - will use GCC's -\family typewriter -__builtin_\SpecialChar softhyphen -offsetof -\family default - if available, which does some extra sanity checks in C++ mode. -\end_layout - -\begin_layout Standard - -\family typewriter -offsetof -\family default - calculates the offset of the specified member in the type, which needs - to be a struct or union. -\end_layout - \begin_layout Standard \family typewriter @@ -2830,31 +2761,15 @@ struct \begin_layout Standard -\family typewriter -FIELD_SIZEOF -\family default - (formerly \family typewriter HXsizeof_member \family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXsizeof_member -\end_layout - -\end_inset - -) and + and \family typewriter HXtypeof_member \family default - are convenient shortcuts to get the size or type of a named member in a - given struct: + are shortcuts (mainly for the C language) to get the size or type of a + named member in a given struct: \end_layout \begin_layout LyX-Code @@ -2869,6 +2784,18 @@ struct foo, baz)]; \end_layout +\begin_layout Standard +In C++, one can simply use +\family typewriter +sizeof(foo::baz) +\family default + and +\family typewriter +decltype(foo::baz) +\family default +. +\end_layout + \begin_layout Subsection Array size \end_layout @@ -12252,7 +12179,7 @@ HX_split \series bold char ** \series default -HX_split4( +HX_split_inplace( \series bold char * \series default @@ -12277,7 +12204,7 @@ status open \family typewriter \size normal \color none -HX_split4 +HX_split_inplace \end_layout \end_inset @@ -12290,7 +12217,7 @@ HX_split4 \series bold int \series default - HX_split5( + HX_split_fixed( \series bold char * \series default @@ -12306,7 +12233,7 @@ int \series bold char ** \series default -stack); +arr); \begin_inset Index idx status open @@ -12315,7 +12242,7 @@ status open \family typewriter \size normal \color none -HX_split5 +HX_split_fixed \end_layout \end_inset @@ -12456,7 +12383,7 @@ s \begin_layout Description \family typewriter -HX_split4 +HX_split_inplace \family default Split the string \family typewriter @@ -12499,7 +12426,7 @@ HX_split \begin_layout Description \family typewriter -HX_split5 +HX_split_fixed \family default Split the string \family typewriter @@ -12521,7 +12448,7 @@ delimiters The array for the substring pointers must be provided by the user through the \family typewriter -stack +arr \family default argument. @@ -13195,10 +13122,10 @@ Examples \end_layout \begin_layout Subsubsection -Using HX_split5 +Using HX_split_fixed \begin_inset CommandInset label LatexCommand label -name "subsec:string-ex-HX_split5" +name "subsec:string-ex-HX_split_fixed" \end_inset @@ -13208,31 +13135,10 @@ name "subsec:string-ex-HX_split5" \begin_layout Standard \family typewriter -HX_split5 -\family default -, where the -\begin_inset Quotes eld -\end_inset - -5 -\begin_inset Quotes erd -\end_inset - - should be interpreted (with a bit of imagination and the knowledge of leetspeak -) as an -\begin_inset Quotes eld -\end_inset - -S -\begin_inset Quotes erd -\end_inset - - for stack, as -\family typewriter -HX_split5 +HX_split_fixed \family default - is often used only with on-stack variables and where the field count of - interest is fixed, as the example for parsing + is often used just with scoped automatic-storage variables and where the + field count of interest is fixed, as the example for parsing \family typewriter /etc/passwd \family default @@ -13292,7 +13198,7 @@ while \series bold if \series default - (HX_split5(line, ":", ARRAY_SIZE(field), field) < 7) { + (HX_split_fixed(line, ":", ARRAY_SIZE(field), field) < 7) { \begin_inset Newline newline \end_inset @@ -13324,14 +13230,14 @@ n", field[0]); \end_layout \begin_layout Subsubsection -Using HX_split4 +Using HX_split_inplace \end_layout \begin_layout Standard Where the number of fields is not previously known and/or estimatable, but the string can be modified in place, one uses \family typewriter -HX_split4 +HX_split_inplace \family default as follows: \end_layout @@ -13377,7 +13283,7 @@ while \series bold char ** \series default -field = HX_split4(line, ":", NULL, 0); +field = HX_split_inplace(line, ":", NULL, 0); \begin_inset Newline newline \end_inset diff --git a/doc/libHX_Documentation.pdf b/doc/libHX_Documentation.pdf index 1e9db69..673a851 100644 Binary files a/doc/libHX_Documentation.pdf and b/doc/libHX_Documentation.pdf differ diff --git a/include/libHX/defs.h b/include/libHX/defs.h index 9ecdd32..1ace518 100644 --- a/include/libHX/defs.h +++ b/include/libHX/defs.h @@ -2,23 +2,14 @@ #define _LIBHX_DEFS_H 1 #ifdef __cplusplus -# define FIELD_SIZEOF(type, member) \ - sizeof(static_cast(NULL)->member) -# define HXsizeof_member(type, member) FIELD_SIZEOF(type, member) -# define HXtypeof_member(type, member) \ - __typeof__(static_cast(NULL)->member) -# if defined(__GNUC__) && __GNUC__ >= 4 && !defined(offsetof) - /* - * This is here so most programs can skip inclusion - * of stddef.h just to get offsetof. - */ -# define offsetof(type, member) __builtin_offsetof(type, member) -# endif -# ifndef offsetof -# define offsetof(type, member) \ - reinterpret_cast(&(static_cast(NULL)->member)) +# define HXsizeof_member(type, member) sizeof(type::member) +# if __cplusplus >= 201100L +# define HXtypeof_member(type, member) decltype(type::member) +# else +# define HXtypeof_member(type, member) __typeof__(type::member)) # endif # ifndef containerof +# include # define containerof(var, type, member) reinterpret_cast( \ reinterpret_cast(var) - offsetof(type, member)) # endif @@ -139,14 +130,8 @@ static __inline__ new_type signed_cast(unsigned char *expr) # ifndef reinterpret_cast # define reinterpret_cast(type, expr) ((type)(expr)) # endif -# if defined(__GNUC__) && __GNUC__ >= 4 && !defined(offsetof) -# define offsetof(type, member) __builtin_offsetof(type, member) -# endif -# ifndef offsetof -# define offsetof(type, member) \ - reinterpret_cast(long, &(static_cast(type *, NULL)->member)) -# endif # ifndef containerof +# include # define containerof(var, type, member) reinterpret_cast(type *, \ reinterpret_cast(char *, var) - offsetof(type, member)) # endif diff --git a/include/libHX/libxml_helper.h b/include/libHX/libxml_helper.h index 599ede1..ebe5613 100644 --- a/include/libHX/libxml_helper.h +++ b/include/libHX/libxml_helper.h @@ -6,7 +6,6 @@ #else # include #endif -#include #include #ifdef __cplusplus diff --git a/include/libHX/misc.h b/include/libHX/misc.h index 3f68917..adebf22 100644 --- a/include/libHX/misc.h +++ b/include/libHX/misc.h @@ -11,8 +11,6 @@ # include # include #endif -#include -#include #ifdef __cplusplus extern "C" { diff --git a/include/libHX/string.h b/include/libHX/string.h index f7146b5..4dc4c11 100644 --- a/include/libHX/string.h +++ b/include/libHX/string.h @@ -66,8 +66,10 @@ extern char *HX_dirname(const char *); extern hxmc_t *HX_getl(hxmc_t **, FILE *); extern void *HX_memmem(const void *, size_t, const void *, size_t); extern char **HX_split(const char *, const char *, int *, int); -extern char **HX_split4(char *, const char *, int *, int); -extern int HX_split5(char *, const char *, int, char **); +extern int HX_split_fixed(char *, const char *, int, char **); +extern char **HX_split_inplace(char *, const char *, int *, int); +#define HX_split4(a, b, c, d) HX_split_inplace((a), (b), (c), (d)) +#define HX_split5(a, b, c, d) HX_split_fixed((a), (b), (c), (d)) extern char *HX_strbchr(const char *, const char *, char); extern char *HX_strchr2(const char *, const char *); extern char *HX_strclone(char **, const char *); diff --git a/src/Makefile.am b/src/Makefile.am index 6788ddd..73a6bdb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,7 +13,7 @@ libHX_la_SOURCES = deque.c dl.c format.c io.c map.c \ mc.c misc.c opt.c \ rand.c string.c time.c libHX_la_LIBADD = ${libdl_LIBS} ${libpthread_LIBS} ${librt_LIBS} -libHX_la_LDFLAGS = -no-undefined -version-info 31:0:3 +libHX_la_LDFLAGS = -no-undefined -version-info 32:0:0 if WITH_GNU_LD libHX_la_LDFLAGS += -Wl,--version-script=${srcdir}/libHX.map endif diff --git a/src/Makefile.in b/src/Makefile.in index fd611ca..632d4ab 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -738,7 +738,7 @@ lib_LTLIBRARIES = libHX.la $(am__append_1) libHX_la_SOURCES = deque.c dl.c format.c io.c map.c mc.c misc.c opt.c \ rand.c string.c time.c $(am__append_3) $(am__append_4) libHX_la_LIBADD = ${libdl_LIBS} ${libpthread_LIBS} ${librt_LIBS} -libHX_la_LDFLAGS = -no-undefined -version-info 31:0:3 $(am__append_2) +libHX_la_LDFLAGS = -no-undefined -version-info 32:0:0 $(am__append_2) EXTRA_libHX_la_DEPENDENCIES = libHX.map libHX_rtcheck_la_SOURCES = rtcheck.c libHX_rtcheck_la_LIBADD = ${libdl_LIBS} diff --git a/src/internal.h b/src/internal.h index 83d2b9c..d348520 100644 --- a/src/internal.h +++ b/src/internal.h @@ -54,10 +54,4 @@ struct timeval; extern hxmc_t *HXparse_dequote_fmt(const char *, const char *, const char **); -/* time.c - these are obsolete, but kept for ABI */ -extern void HX_diff_timespec(struct timespec *, const struct timespec *, - const struct timespec *); -extern void HX_diff_timeval(struct timeval *, const struct timeval *, - const struct timeval *); - #endif /* LIBHX_INTERNAL_H */ diff --git a/src/io.c b/src/io.c index 6616e88..a4dd962 100644 --- a/src/io.c +++ b/src/io.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/libHX.map b/src/libHX.map index ebd97b2..d5ea9c7 100644 --- a/src/libHX.map +++ b/src/libHX.map @@ -1,6 +1,7 @@ -LIBHX_1.10.0 { +LIBHX_3.25 { global: HX_basename; + HX_basename_exact; HX_chomp; HX_copy_dir; HX_copy_file; @@ -9,33 +10,65 @@ global: HX_dlerror; HX_dlopen; HX_dlsym; + HX_drand; + HX_exit; HX_ffs; + HX_fls; + HX_getl; HX_getopt; HX_getopt_help; + HX_getopt_help_cb; HX_getopt_usage; + HX_getopt_usage_cb; + HX_hexdump; + HX_init; HX_irand; + HX_memmem; + HX_mkdir; HX_rand; + HX_readlink; + HX_realpath; HX_rrmdir; HX_shconfig; HX_shconfig_free; + HX_shconfig_map; HX_shconfig_pv; - HX_split5; HX_split; + HX_split_fixed; + HX_split_inplace; + HX_stpltrim; HX_strbchr; + HX_strchr2; HX_strclone; + HX_strdup; + HX_strlcat; + HX_strlcpy; + HX_strlncat; HX_strlower; HX_strltrim; HX_strmid; + HX_strndup; + HX_strnlen; + HX_strquote; HX_strrcspn; HX_strrev; HX_strrtrim; HX_strsep2; HX_strsep; HX_strupper; + HX_time_compare; + HX_timespec_add; + HX_timespec_isneg; + HX_timespec_mul; + HX_timespec_mulf; + HX_timespec_neg; + HX_timespec_sub; + HX_timeval_sub; HX_zvecfree; HXdeque_del; HXdeque_find; HXdeque_free; + HXdeque_genocide2; HXdeque_get; HXdeque_init; HXdeque_move; @@ -47,151 +80,49 @@ global: HXdir_close; HXdir_open; HXdir_read; -local: - *; -}; - -LIBHX_1.25 { -global: - HX_getl; - HXmc_free; - HXmc_length; - HXmc_memcat; - HXmc_memcpy; - HXmc_memdel; - HXmc_meminit; - HXmc_memins; - HXmc_mempcat; - HXmc_strcat; - HXmc_strcpy; - HXmc_strinit; - HXmc_strins; - HXmc_strpcat; - HXmc_trunc; -} LIBHX_1.10.0; - -LIBHX_1.26 { -global: - HX_hexdump; - HX_time_compare; -} LIBHX_1.25; - -LIBHX_2.0 { -global: - HXmc_setlen; -} LIBHX_1.26; - -LIBHX_2.2 { -global: - HX_split4; - HXproc_run_async; - HXproc_run_sync; - HXproc_wait; -} LIBHX_2.0; - -LIBHX_2.6 { -global: - HX_fls; -} LIBHX_2.2; - -LIBHX_2.9 { -global: - HX_basename_exact; -} LIBHX_2.6; - -LIBHX_3.0 { -global: - HX_diff_timespec; - HX_diff_timeval; HXformat_add; + HXformat_aprintf; + HXformat_fprintf; HXformat_free; HXformat_init; + HXformat_sprintf; HXhash_djb2; HXhash_jlookup3; HXhash_jlookup3s; HXhash_primes; + HXio_fullread; + HXio_fullwrite; HXmap_add; HXmap_del; HXmap_find; HXmap_free; HXmap_get; + HXmap_init5; + HXmap_init; HXmap_keysvalues; HXmap_qfe; HXmap_traverse; HXmap_travfree; HXmap_travinit; -} LIBHX_2.9; - -LIBHX_3.2 { -global: - HX_strquote; -} LIBHX_3.0; - -LIBHX_3.3 { -global: - HX_drand; - HX_shconfig_map; - HXdeque_genocide2; + HXmc_free; + HXmc_length; + HXmc_memcat; + HXmc_memcpy; + HXmc_memdel; + HXmc_meminit; + HXmc_memins; + HXmc_mempcat; + HXmc_setlen; + HXmc_strcat; + HXmc_strcpy; + HXmc_strinit; + HXmc_strins; + HXmc_strpcat; + HXmc_trunc; HXmc_zvecfree; -} LIBHX_3.2; - -LIBHX_3.4 { -global: - HX_exit; - HX_init; - HX_memmem; -} LIBHX_3.3; - -LIBHX_3.9 { -global: - HXio_fullread; - HXio_fullwrite; -} LIBHX_3.4; - -LIBHX_3.10 { -global: - HX_readlink; - HX_realpath; -} LIBHX_3.9; - -LIBHX_3.12 { -global: - HX_getopt_help_cb; - HX_getopt_usage_cb; - HX_mkdir; - HX_strdup; - HX_strlcat; - HX_strlcpy; - HX_strlncat; - HX_strndup; - HX_strnlen; - HXformat_aprintf; - HXformat_fprintf; - HXformat_sprintf; - HXmap_init5; - HXmap_init; -} LIBHX_3.10; - -# ABI 29 -LIBHX_3.13 { -global: - HX_timespec_add; - HX_timespec_isneg; - HX_timespec_mul; - HX_timespec_mulf; - HX_timespec_neg; - HX_timespec_sub; - HX_timeval_sub; -} LIBHX_3.12; - -# ABI 30 -LIBHX_3.15 { -global: - HX_strchr2; -} LIBHX_3.13; - -# ABI 31 -LIBHX_3.18 { -global: - HX_stpltrim; -} LIBHX_3.15; + HXproc_run_async; + HXproc_run_sync; + HXproc_wait; +local: + *; +}; diff --git a/src/map.c b/src/map.c index 38f0d34..6d89e36 100644 --- a/src/map.c +++ b/src/map.c @@ -1236,7 +1236,7 @@ static struct HXrbnode *HXrbtrav_rewalk(struct HXrbtrav *trav) } else { /* Search for the specific node to rebegin traversal at. */ const struct HXrbnode *newpath[RBT_MAXDEP]; - unsigned char newdir[RBT_MAXDEP]; + unsigned char newdir[RBT_MAXDEP] = {}; int newdepth = 0, res; bool found = false; diff --git a/src/misc.c b/src/misc.c index 2eec3c2..7778b08 100644 --- a/src/misc.c +++ b/src/misc.c @@ -82,6 +82,8 @@ EXPORT_SYMBOL void HX_hexdump(FILE *fp, const void *vptr, unsigned int len) EXPORT_SYMBOL void HX_zvecfree(char **args) { char **travp; + if (args == NULL) + return; for (travp = args; *travp != NULL; ++travp) free(*travp); free(args); diff --git a/src/rtcheck.c b/src/rtcheck.c index d9f623c..6f04baa 100644 --- a/src/rtcheck.c +++ b/src/rtcheck.c @@ -153,12 +153,8 @@ stub3(HX_timespec_mulf, (struct timespec *a, const struct timespec *b, stub2(HX_timespec_neg, (struct timespec *a, const struct timespec *b)); stub3(HX_timespec_sub, (struct timespec *a, const struct timespec *b, const struct timespec *c)); -stub3(HX_diff_timespec, (struct timespec *a, const struct timespec *b, - const struct timespec *c)); stub3(HX_timeval_sub, (struct timeval *a, const struct timeval *b, const struct timeval *c)); -stub3(HX_diff_timeval, (struct timeval *a, const struct timeval *b, - const struct timeval *c)); stub3(HX_time_compare, (const struct stat *a, const struct stat *b, char c)); stub1v(HX_zvecfree, (char **a)); @@ -255,8 +251,8 @@ stub1(HX_dirname, (const char *a)); stub2(HX_getl, (hxmc_t **a, FILE *b)); stub4(HX_memmem, (const void *a, size_t b, const void *c, size_t d)); stub4(HX_split, (const char *a, const char *b, int *c, int d)); -stub4(HX_split4, (char *a, const char *b, int *c, int d)); -stub4(HX_split5, (char *a, const char *b, int c, char **d)); +stub4(HX_split_inplace, (char *a, const char *b, int *c, int d)); +stub4(HX_split_fixed, (char *a, const char *b, int c, char **d)); stub1(HX_stpltrim, (const char *a)); stub1(HX_stprtrim, (char *a)); stub3(HX_strbchr, (const char *a, const char *b, char c)); diff --git a/src/string.c b/src/string.c index 2761276..354a409 100644 --- a/src/string.c +++ b/src/string.c @@ -232,7 +232,7 @@ EXPORT_SYMBOL char **HX_split(const char *str, const char *delim, return ret; } -EXPORT_SYMBOL char **HX_split4(char *s, const char *delim, int *fld, int max) +EXPORT_SYMBOL char **HX_split_inplace(char *s, const char *delim, int *fld, int max) { char **stk; const char *p = s; @@ -248,22 +248,22 @@ EXPORT_SYMBOL char **HX_split4(char *s, const char *delim, int *fld, int max) if (stk == NULL) return NULL; stk[count] = NULL; - count = HX_split5(s, delim, count, stk); + count = HX_split_fixed(s, delim, count, stk); if (fld != NULL) *fld = count; return stk; } -EXPORT_SYMBOL int HX_split5(char *s, const char *delim, int max, char **stk) +EXPORT_SYMBOL int HX_split_fixed(char *s, const char *delim, int max, char **stk) { /* - * HX_split5 - the "stack split" (we try to avoid using the heap): + * HX_split_fixed - the "stack split" (we try to avoid using the heap): * Split @s (modifies it, so must be writable!) at @delim with at most * @max fields and putting the results into @stk[0..@max-1]. * * Example on @max: * char *stk[max]; - * HX_split5(s, delim, max, stk); + * HX_split_fixed(s, delim, max, stk); */ int i = 0; char *p; @@ -336,6 +336,8 @@ EXPORT_SYMBOL char *HX_strlcat(char *dest, const char *src, size_t len) EXPORT_SYMBOL char *HX_strlcpy(char *dest, const char *src, size_t n) { + if (n == 0) + return dest; strncpy(dest, src, n); dest[n-1] = '\0'; return dest; diff --git a/src/tc-dir.c b/src/tc-dir.c index b87517a..d2e3885 100644 --- a/src/tc-dir.c +++ b/src/tc-dir.c @@ -13,6 +13,7 @@ # include #endif #include +#include #include static void lookatdir(const char *dname) diff --git a/src/tc-link.c b/src/tc-link.c index e508ca9..f20bfd7 100644 --- a/src/tc-link.c +++ b/src/tc-link.c @@ -95,8 +95,8 @@ static void *funcs[] = { HX_getl, HX_memmem, HX_split, - HX_split4, - HX_split5, + HX_split_fixed, + HX_split_inplace, HX_stpltrim, HX_strbchr, HX_strchr2, @@ -117,12 +117,6 @@ static void *funcs[] = { HX_strsep2, HX_strquote, HX_strupper, -#ifdef HAVE_STRUCT_TIMEVAL_TV_USEC - HX_diff_timeval, -#endif -#ifdef HAVE_STRUCT_TIMESPEC_TV_NSEC - HX_diff_timespec, -#endif HX_time_compare, #ifdef HAVE_STRUCT_TIMESPEC_TV_NSEC HX_timespec_add, diff --git a/src/tc-memmem.c b/src/tc-memmem.c index 9c59c7f..342500f 100644 --- a/src/tc-memmem.c +++ b/src/tc-memmem.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/src/tc-string.c b/src/tc-string.c index 112a845..6e85f66 100644 --- a/src/tc-string.c +++ b/src/tc-string.c @@ -160,8 +160,8 @@ static void t_split(void) memcpy(t2, t1, sizeof(t1)); a0 = HX_split(t1, ":", &f0, 0); - a1 = HX_split4(t1, ":", &f1, 0); - f2 = HX_split5(t2, ":", ARRAY_SIZE(a2), a2); + a1 = HX_split_inplace(t1, ":", &f1, 0); + f2 = HX_split_fixed(t2, ":", ARRAY_SIZE(a2), a2); /* complete allocation */ printf("HX_split1: a0[%p]:", a0); @@ -170,7 +170,7 @@ static void t_split(void) printf("\n"); /* array allocated */ - printf("HX_split4: a1[%p]:", a1); + printf("HX_split_inplace: a1[%p]:", a1); for (wp = a1; *wp != NULL; ++wp) printf(" %s[%p]", *wp, *wp); printf("\n"); @@ -202,6 +202,8 @@ extern char *f_strlcpy_mem(char *, const char *, size_t); EXPORT_SYMBOL char *f_strlcpy_str(char *d, const char *s, size_t n) { + if (n == 0) + return d; strncpy(d, s, n); d[n-1] = '\0'; return d; @@ -279,6 +281,13 @@ static void t_strlcpy(void) } } +static void t_strlcpy2(void) +{ + char a[3] = {49, 49, 49}; + HX_strlcpy(&a[1], &a[1], 0); + assert(a[0] == 49 && a[0] == a[1] && a[1] == a[2]); +} + int main(int argc, const char **argv) { hxmc_t *tx = NULL; @@ -308,6 +317,7 @@ int main(int argc, const char **argv) t_split(); t_split2(); t_strlcpy(); + t_strlcpy2(); HXmc_free(tx); HX_exit(); return EXIT_SUCCESS; diff --git a/src/time.c b/src/time.c index 3d25042..e7eee3f 100644 --- a/src/time.c +++ b/src/time.c @@ -81,12 +81,6 @@ EXPORT_SYMBOL struct timespec *HX_timespec_sub(struct timespec *r, return HX_timespec_add(r, a, HX_timespec_neg(&b2, b)); } -EXPORT_SYMBOL void HX_diff_timespec(struct timespec *delta, - const struct timespec *future, const struct timespec *past) -{ - HX_timespec_sub(delta, future, past); -} - EXPORT_SYMBOL struct timespec * HX_timespec_mul(struct timespec *r, const struct timespec *a, int f) { @@ -141,12 +135,6 @@ EXPORT_SYMBOL struct timeval *HX_timeval_sub(struct timeval *delta, } return delta; } - -EXPORT_SYMBOL void HX_diff_timeval(struct timeval *delta, - const struct timeval *future, const struct timeval *past) -{ - HX_timeval_sub(delta, future, past); -} #endif EXPORT_SYMBOL long HX_time_compare(const struct stat *a, @@ -210,6 +198,17 @@ EXPORT_SYMBOL long HX_time_compare(const struct stat *a, return a->st_atime - b->st_atime; else if (sel == 'c') return a->st_ctime - b->st_ctime; +#elif defined(HAVE_STRUCT_STAT_ST_MTIM) + if (sel == 'm') + return a->st_mtim - b->st_mtim; +#ifdef HAVE_STRUCT_STAT_ST_OTIM + else if (sel == 'o') + return a->st_otim - b->st_otim; +#endif + else if (sel == 'a') + return a->st_atim - b->st_atim; + else if (sel == 'c') + return a->st_ctim - b->st_ctim; #else # error Tis not ending well. #endif -- cgit v1.2.3