summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Makefile.in2
-rw-r--r--src/internal.h6
-rw-r--r--src/io.c1
-rw-r--r--src/libHX.map195
-rw-r--r--src/map.c2
-rw-r--r--src/misc.c2
-rw-r--r--src/rtcheck.c8
-rw-r--r--src/string.c12
-rw-r--r--src/tc-dir.c1
-rw-r--r--src/tc-link.c10
-rw-r--r--src/tc-memmem.c1
-rw-r--r--src/tc-string.c16
-rw-r--r--src/time.c23
14 files changed, 106 insertions, 175 deletions
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 <limits.h>
#include <stdarg.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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 <cstdlib>
#endif
#include <libHX/init.h>
+#include <libHX/io.h>
#include <libHX/misc.h>
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 <stdio.h>
#include <stdlib.h>
#include <time.h>
+#include <libHX/defs.h>
#include <libHX/init.h>
#include <libHX/misc.h>
#include <libHX/string.h>
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