From 677e5b0b948fe62d8017c198c57049275f6fe61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 20 Oct 2024 12:21:30 +0200 Subject: New upstream version 4.24 --- src/Makefile.am | 2 +- src/Makefile.in | 2 +- src/io.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++------ src/libHX.map | 5 +++++ src/tc-io.c | 12 ++++++++++++ src/tc-realpath.c | 10 ++++++++++ 6 files changed, 79 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 11a240e..f28c0a6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,7 +9,7 @@ libHX_la_SOURCES = deque.c dl.c format.c io.c map.c \ mc.c misc.c opt.c proc.c \ rand.c socket.c string.c time.c libHX_la_LIBADD = ${libdl_LIBS} -lm ${libpthread_LIBS} ${librt_LIBS} ${libsocket_LIBS} -libHX_la_LDFLAGS = -no-undefined -version-info 39:0:7 +libHX_la_LDFLAGS = -no-undefined -version-info 40:0:8 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 22766b5..0ad4cde 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -771,7 +771,7 @@ libHX_la_SOURCES = deque.c dl.c format.c io.c map.c mc.c misc.c opt.c \ proc.c rand.c socket.c string.c time.c $(am__append_3) libHX_la_LIBADD = ${libdl_LIBS} -lm ${libpthread_LIBS} ${librt_LIBS} \ ${libsocket_LIBS} $(am__append_4) -libHX_la_LDFLAGS = -no-undefined -version-info 39:0:7 $(am__append_1) \ +libHX_la_LDFLAGS = -no-undefined -version-info 40:0:8 $(am__append_1) \ $(am__append_2) EXTRA_libHX_la_DEPENDENCIES = libHX.map EXTRA_DIST = internal.h map_int.h libHX.map uxcompat.h analyze.sh diff --git a/src/io.c b/src/io.c index 9199d03..b9041e0 100644 --- a/src/io.c +++ b/src/io.c @@ -351,12 +351,17 @@ EXPORT_SYMBOL int HX_readlink(hxmc_t **target, const char *path) size_t linkbuf_size; if (allocate) { - linkbuf_size = 32; - *target = HXmc_meminit(NULL, 32); + linkbuf_size = 128; + *target = HXmc_meminit(nullptr, 128); if (*target == NULL) return -errno; } else { linkbuf_size = HXmc_length(*target); + if (linkbuf_size < 128) { + linkbuf_size = 128; + if (HXmc_setlen(target, 128) == nullptr) + return -errno; + } } while (true) { ssize_t ret = readlink(path, *target, linkbuf_size); @@ -453,6 +458,45 @@ HX_realpath_symres(struct HX_realpath_state *state, const char *path) return 1; } +EXPORT_SYMBOL int HX_getcwd(hxmc_t **target) +{ + bool allocate = *target == nullptr; + size_t linkbuf_size; + + if (allocate) { + linkbuf_size = 128; + *target = HXmc_meminit(nullptr, linkbuf_size); + if (*target == nullptr) + return -errno; + } else { + linkbuf_size = HXmc_length(*target); + if (linkbuf_size < 128) { + linkbuf_size = 128; + if (HXmc_setlen(target, linkbuf_size) == nullptr) + return -errno; + } + } + while (true) { + const char *ret = getcwd(*target, linkbuf_size); + if (ret != nullptr) { + HXmc_setlen(target, strlen(ret)); /* shrink to fit */ + return 1; + } + if (errno == ERANGE) { + if (HXmc_setlen(target, linkbuf_size *= 2) != nullptr) + continue; + /* errno already set by realloc, fall into next if block */ + } + int saved_errno = errno; + if (allocate) { + HXmc_free(*target); + *target = nullptr; + } + return -(errno = saved_errno); + } + return -EINVAL; +} + EXPORT_SYMBOL int HX_realpath(hxmc_t **dest_pptr, const char *path, unsigned int flags) { @@ -462,7 +506,7 @@ EXPORT_SYMBOL int HX_realpath(hxmc_t **dest_pptr, const char *path, int ret = 0; if (dnull) { - state.dest = HXmc_meminit(NULL, PATH_MAX); + state.dest = HXmc_meminit(NULL, 256); if (state.dest == NULL) goto err; } @@ -470,11 +514,9 @@ EXPORT_SYMBOL int HX_realpath(hxmc_t **dest_pptr, const char *path, if (*path == '/') { rq_slash = true; } else if (flags & HX_REALPATH_ABSOLUTE) { - if (getcwd(state.dest, PATH_MAX) == NULL) + if (HX_getcwd(&state.dest) < 0) goto err; rq_slash = true; - if (HXmc_setlen(&state.dest, strlen(state.dest)) == NULL) - goto err; } while (*path != '\0') { @@ -541,6 +583,8 @@ EXPORT_SYMBOL int HX_realpath(hxmc_t **dest_pptr, const char *path, /* If caller supplied a buffer, do not take it away. */ HXmc_free(state.dest); *dest_pptr = NULL; + } else { + *dest_pptr = state.dest; } HXmc_free(state.link_target); HXmc_free(state.new_path); diff --git a/src/libHX.map b/src/libHX.map index 374a881..922cc3c 100644 --- a/src/libHX.map +++ b/src/libHX.map @@ -183,3 +183,8 @@ LIBHX_4.18 { global: HX_getopt5; } LIBHX_4.16; + +LIBHX_4.24 { +global: + HX_getcwd; +} LIBHX_4.18; diff --git a/src/tc-io.c b/src/tc-io.c index 77baf01..024a46a 100644 --- a/src/tc-io.c +++ b/src/tc-io.c @@ -28,6 +28,16 @@ static void sf(void) close(src); } +static void t_getcwd(void) +{ + hxmc_t *s = nullptr; + if (HX_getcwd(&s) > 0) + printf("cwd1: >%s<\n", s); + HXmc_setlen(&s, 0); + if (HX_getcwd(&s) > 0) + printf("cwd2: >%s<\n", s); +} + int main(void) { size_t z; @@ -55,5 +65,7 @@ int main(void) fprintf(stderr, "copy_file ok\n"); unlink("tciocopy.txt"); } + + t_getcwd(); return 0; } diff --git a/src/tc-realpath.c b/src/tc-realpath.c index b71c127..4d6b79f 100644 --- a/src/tc-realpath.c +++ b/src/tc-realpath.c @@ -48,6 +48,15 @@ static void t_1(void) HXmc_free(tmp); } +static void t_2(void) +{ + hxmc_t *tmp = HXmc_strinit(""); + int ret = HX_realpath(&tmp, "../../../../dev/tty", HX_REALPATH_ABSOLUTE | HX_REALPATH_DEFAULT); + if (ret > 0) + printf("t_2: %s\n", tmp); + HXmc_free(tmp); +} + int main(int argc, char **oargv) { char **argv = nullptr; @@ -57,6 +66,7 @@ int main(int argc, char **oargv) if (!rp_get_options(oargv, &argc, &argv)) return EXIT_FAILURE; t_1(); + t_2(); res = NULL; for (int i = 1; i < argc; ++i) { -- cgit v1.2.3 From cec79a3f5578da4a9f9085282389482edf45c81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 16 Mar 2025 12:48:45 +0100 Subject: New upstream version 4.26 --- src/Makefile.in | 104 +++++++++++++++++++++++++++++++++++------------------ src/string.c | 16 ++++----- src/tc-compile.c | 1 + src/tc-string.c | 10 +++++- src/tx-compile.cpp | 1 + 5 files changed, 88 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/Makefile.in b/src/Makefile.in index 0ad4cde..0768775 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. +# Makefile.in generated by automake 1.17 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2024 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -72,6 +72,8 @@ am__make_running_with_option = \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +am__rm_f = rm -f $(am__rm_f_notfound) +am__rm_rf = rm -rf $(am__rm_f_notfound) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -155,10 +157,9 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ + { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && echo $$files | $(am__xargs_n) 40 $(am__rm_f); }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) @@ -556,6 +557,7 @@ am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ + $$am__collect_skipped_logs \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the @@ -580,6 +582,11 @@ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ +if test -n '$(IGNORE_SKIPPED_LOGS)'; then \ + am__collect_skipped_logs='--collect-skipped-logs no'; \ +else \ + am__collect_skipped_logs=''; \ +fi; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ @@ -712,8 +719,10 @@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__rm_f_notfound = @am__rm_f_notfound@ am__tar = @am__tar@ am__untar = @am__untar@ +am__xargs_n = @am__xargs_n@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -865,13 +874,8 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): clean-checkPROGRAMS: - @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list + $(am__rm_f) $(check_PROGRAMS) + test -z "$(EXEEXT)" || $(am__rm_f) $(check_PROGRAMS:$(EXEEXT)=) install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @@ -898,15 +902,13 @@ uninstall-libLTLIBRARIES: done clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + -$(am__rm_f) $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } + echo rm -f $${locs}; \ + $(am__rm_f) $${locs} libHX.la: $(libHX_la_OBJECTS) $(libHX_la_DEPENDENCIES) $(EXTRA_libHX_la_DEPENDENCIES) $(AM_V_CCLD)$(libHX_la_LINK) -rpath $(libdir) $(libHX_la_OBJECTS) $(libHX_la_LIBADD) $(LIBS) @@ -1130,7 +1132,7 @@ distclean-compile: $(am__depfiles_remade): @$(MKDIR_P) $(@D) - @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + @: >>$@ am--depfiles: $(am__depfiles_remade) @@ -1295,7 +1297,6 @@ distclean-tags: am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: - $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ @@ -1371,10 +1372,37 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ + output_system_information () \ + { \ + echo; \ + { uname -a | $(AWK) '{ \ + printf "System information (uname -a):"; \ + for (i = 1; i < NF; ++i) \ + { \ + if (i != 2) \ + printf " %s", $$i; \ + } \ + printf "\n"; \ +}'; } 2>&1; \ + if test -r /etc/os-release; then \ + echo "Distribution information (/etc/os-release):"; \ + sed 8q /etc/os-release; \ + elif test -r /etc/issue; then \ + echo "Distribution information (/etc/issue):"; \ + cat /etc/issue; \ + fi; \ + }; \ + please_report () \ + { \ +echo "Some test(s) failed. Please report this to $(PACKAGE_BUGREPORT),"; \ +echo "together with the test-suite.log file (gzipped) and your system"; \ +echo "information. Thanks."; \ + }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ + output_system_information; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ @@ -1394,26 +1422,25 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG) for debugging.$${std}";\ if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + please_report | sed -e "s/^/$${col}/" -e s/'$$'/"$${std}"/; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: $(check_PROGRAMS) - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @$(am__rm_f) $(RECHECK_LOGS) + @$(am__rm_f) $(RECHECK_LOGS:.log=.trs) + @$(am__rm_f) $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @$(am__rm_f) $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ @@ -1550,15 +1577,15 @@ install-strip: "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + -$(am__rm_f) $(TEST_LOGS) + -$(am__rm_f) $(TEST_LOGS:.log=.trs) + -$(am__rm_f) $(TEST_SUITE_LOG) clean-generic: distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -$(am__rm_f) $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || $(am__rm_f) $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -1569,7 +1596,7 @@ clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool mostlyclean-am distclean: distclean-am - -rm -f ./$(DEPDIR)/deque.Plo + -rm -f ./$(DEPDIR)/deque.Plo -rm -f ./$(DEPDIR)/dl.Plo -rm -f ./$(DEPDIR)/format.Plo -rm -f ./$(DEPDIR)/io.Plo @@ -1668,7 +1695,7 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -f ./$(DEPDIR)/deque.Plo + -rm -f ./$(DEPDIR)/deque.Plo -rm -f ./$(DEPDIR)/dl.Plo -rm -f ./$(DEPDIR)/format.Plo -rm -f ./$(DEPDIR)/io.Plo @@ -1764,3 +1791,10 @@ uninstall-am: uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: + +# Tell GNU make to disable its built-in pattern rules. +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% diff --git a/src/string.c b/src/string.c index e468063..3a85fa8 100644 --- a/src/string.c +++ b/src/string.c @@ -41,7 +41,7 @@ struct HX_quote_rule { const char *chars; }; -static const char HX_hexenc[16] = "0123456789ABCDEF"; +static const char HX_hexenc[] = "0123456789ABCDEF"; EXPORT_SYMBOL char *HX_basename(const char *s) { @@ -1175,7 +1175,7 @@ EXPORT_SYMBOL unsigned long long HX_strtoull_nsec(const char *s, char **out_end) EXPORT_SYMBOL char *HX_unit_seconds(char *out, size_t outsize, unsigned long long secs, unsigned int flags) { - unsigned long years = 0, months = 0, weeks = 0, days, hours, mins; + unsigned long long years = 0, months = 0, weeks = 0, days, hours, mins; char buf[HXSIZEOF_Z64+4]; if (flags & HXUNIT_YEARS) { years = secs / SECONDS_PER_YEAR; @@ -1197,31 +1197,31 @@ EXPORT_SYMBOL char *HX_unit_seconds(char *out, size_t outsize, secs %= 60; *out = '\0'; if (years > 0) { - snprintf(buf, ARRAY_SIZE(buf), "%luy", years); + snprintf(buf, ARRAY_SIZE(buf), "%lluy", years); HX_strlcat(out, buf, outsize); } if (months == 1) { HX_strlcat(out, "1month", outsize); } else if (months > 0) { - snprintf(buf, ARRAY_SIZE(buf), "%lumonths", months); + snprintf(buf, ARRAY_SIZE(buf), "%llumonths", months); HX_strlcat(out, buf, outsize); } if (weeks == 1) { HX_strlcat(out, "1week", outsize); } else if (weeks > 0) { - snprintf(buf, ARRAY_SIZE(buf), "%luweeks", weeks); + snprintf(buf, ARRAY_SIZE(buf), "%lluweeks", weeks); HX_strlcat(out, buf, outsize); } if (days > 0) { - snprintf(buf, ARRAY_SIZE(buf), "%lud", days); + snprintf(buf, ARRAY_SIZE(buf), "%llud", days); HX_strlcat(out, buf, outsize); } if (hours > 0) { - snprintf(buf, ARRAY_SIZE(buf), "%luh", hours); + snprintf(buf, ARRAY_SIZE(buf), "%lluh", hours); HX_strlcat(out, buf, outsize); } if (mins > 0) { - snprintf(buf, ARRAY_SIZE(buf), "%lumin", mins); + snprintf(buf, ARRAY_SIZE(buf), "%llumin", mins); HX_strlcat(out, buf, outsize); } if (secs > 0 || diff --git a/src/tc-compile.c b/src/tc-compile.c index d60ff21..b3f3b0e 100644 --- a/src/tc-compile.c +++ b/src/tc-compile.c @@ -5,6 +5,7 @@ # include #endif #include +#include #define ZZ 64 diff --git a/src/tc-string.c b/src/tc-string.c index e7f90c2..d777268 100644 --- a/src/tc-string.c +++ b/src/tc-string.c @@ -355,8 +355,16 @@ static int t_time_units(void) static const struct { unsigned long long input; unsigned int flags; - const char expect_out[24]; + const char expect_out[41]; } vt[] = { +#define SECONDS_PER_YEAR 31557600 /* 365.25 days */ +#define SECONDS_PER_MONTH 2629800 /* 1/12th of that year = 30.4375 days */ + {18446744073709551615ULL, 0, "213503982334601d7h15s"}, + {18446744073709526399ULL, 0, "213503982334600d23h59min59s"}, + {18446744073709180799ULL, HXUNIT_WEEKS, "30500568904942weeks2d23h59min59s"}, + {18446744073708451799ULL, HXUNIT_MONTHS, "7014504553087months2d23h59min59s"}, + {18446744073707636399ULL, HXUNIT_MONTHS | HXUNIT_WEEKS, "7014504553086months3weeks2d23h59min59s"}, + {18446744073688622999ULL, HXUNIT_YEARS | HXUNIT_MONTHS | HXUNIT_WEEKS, "584542046089y11months2weeks2d23h59min59s"}, {31536000, 0, "365d"}, {31622400, 0, "366d"}, {34819200, HXUNIT_WEEKS, "57weeks4d"}, diff --git a/src/tx-compile.cpp b/src/tx-compile.cpp index 2c21e3b..2bcdb1e 100644 --- a/src/tx-compile.cpp +++ b/src/tx-compile.cpp @@ -1 +1,2 @@ #include "tc-compile.c" +#include -- cgit v1.2.3