Skip to content
Myr

Add Solaris support (#3515)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

I love jq :) So while updating the version we ship in Solaris I have tried to modify stuff to make everything work out of the box. Just ``` autoreconf -fiv ./configure gmake gmake check ``` I also went ahead and created Solaris test action should you be interested in having it too. The changes are not extensive and I have tried to comment them nicely in each commit. Hopefully that's enough. Thanks for jq!

authored by Vladimír Marek · committed by GitHub · parent 27f417f · Browse files · 3 files+36 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+36 added−5 removed

  • tests:+12 added−3 removed
  • other:+24 added−2 removed

3 files+36 added−5 removed

modified:src/builtin.c+10 added-2 removed
1781 unmodified lines
1782 const char *fmt = jv_string_value(b);1783 int fmt_not_empty = *fmt != '\0';1784 size_t max_size = strlen(fmt) + 100;1785 char *buf = jv_mem_alloc(max_size);1786#ifdef __APPLE__1786#if defined(__APPLE__) || defined(__sun)1787 /* Apple Libc (as of version 1669.40.2) contains a bug which causes it to1788 * ignore the `tm.tm_gmtoff` in favor of the global timezone. To print the1789 * proper timezone offset we temporarily switch the TZ to UTC. */1790 char *tz = (tz = getenv("TZ")) != NULL ? strdup(tz) : NULL;1791 setenv("TZ", "UTC", 1);1792#endif1793#if defined(__sun)1794 /* Solaris moreover needs call to tzset to take the changed environment into1795 * account ... */1796 tzset();1797#endif1798 size_t n = strftime(buf, max_size, fmt, &tm);1794#ifdef __APPLE__1799#if defined(__APPLE__) || defined(__sun)1800 if (tz) {1801 setenv("TZ", tz, 1);1802 free(tz);1803 } else {1804 unsetenv("TZ");1805 }1806#endif1807#if defined(__sun)1808 tzset();1809#endif1810 jv_free(b);1811 /* POSIX doesn't provide errno values for strftime() failures; weird */1812 if ((n == 0 && fmt_not_empty) || n > max_size) {1813 free(buf);
286 unmodified lines
modified:tests/shtest+12 added-3 removed
2 unmodified lines
3. "${0%/*}/setup" "$@"45msys=false6mingw=false7sunos=false8case "$(uname -s)" in9MSYS*) msys=true;;10MINGW*) mingw=true;;11SunOS*) sunos=true;;12esac1314JQ_NO_B=$JQ15JQ="$JQ -b"1617# On Solaris, GNU tools are available in /usr/gnu. This script should prefer18# them over the native tools, because the native versions may lack some19# command-line options the script relies on.20$sunos && PATH="/usr/gnu/bin:$PATH"2122PATH=$JQBASEDIR:$PATH $JQBASEDIR/tests/jq-f-test.sh > /dev/null2324SHELL=/bin/sh25export SHELL
583 unmodified lines
609# Check invalid JQ_COLORS610echo 'Failed to set $JQ_COLORS' > $d/expect_warning611$JQ -Ccn '[{"a":true,"b":false},"abc",123,null]' > $d/expect612for colors in '/' '[30' '30m' '30:31m:32' '30:*:31' 'invalid'; do606 JQ_COLORS=$colors \607 $JQ -Ccn '[{"a":true,"b":false},"abc",123,null]' > $d/color 2>$d/warning613 export JQ_COLORS=$colors614 $JQ -Ccn '[{"a":true,"b":false},"abc",123,null]' > $d/color 2>$d/warning615 cmp $d/color $d/expect616 cmp $d/warning $d/expect_warning617done618unset JQ_COLORS619620# Check $NO_COLOR621test_no_color=true622$msys && test_no_color=false623$mingw && test_no_color=false624$sunos && test_no_color=false625if $test_no_color && command -v script >/dev/null 2>&1; then626 if script -qc echo /dev/null >/dev/null 2>&1; then627 faketty() { script -qec "$*" /dev/null; }628 else # macOS
60 unmodified lines
689 if [ -z "$l" ]; then690 echo "WARNING: Not testing localization"691 else692 dt1=$(LC_ALL=$l date +'%a %d %b %Y at %H:%M:%S')684 dt2=$(LC_ALL=$l jq -nr 'now | strflocaltime("%a %d %b %Y at %H:%M:%S")')693 dt2=$(LC_ALL=$l $JQ -nr 'now | strflocaltime("%a %d %b %Y at %H:%M:%S")')694 dt3=$(LC_ALL=$l date +'%a %d %b %Y at %H:%M:%S')695 if [ "$dt1" != "$dt2" ] && [ "$dt2" != "$dt3" ]; then696 echo "jq does not honor LC_ALL environment variable ($dt1, $dt2, $dt3)"697 exit 1
186 unmodified lines
modified:configure.ac+14 added
4 unmodified lines
5dnl Created autoconf implementation thompson@dtosolutions, 26NOV126AC_PREREQ([2.65])7AC_CONFIG_AUX_DIR([config])8AC_USE_SYSTEM_EXTENSIONS910dnl Prefer GNU make on Solaris where /usr/bin/make is not suitable11AS_IF([test -z "$MAKE"], [12 AS_CASE(["`uname -s`"], [SunOS], [MAKE=/usr/gnu/bin/make])13])1415AM_INIT_AUTOMAKE([1.11.2 subdir-objects parallel-tests foreign -Wall])16AM_SILENT_RULES([yes])17AM_PROG_AR18AM_MAINTAINER_MODE([disable])
269 unmodified lines
288289AM_CONDITIONAL([BUILD_ONIGURUMA], [test "x$build_oniguruma" = xyes])290AM_CONDITIONAL([WITH_ONIGURUMA], [test "x$with_oniguruma" != xno])291292dnl On Solaris, strptime clears the tm structure before parsing. This breaks the293dnl sentinel logic in builtin.c, which then incorrectly assumes that strptime set294dnl tm_wday and tm_yday. Defining _STRPTIME_DONTZERO disables that behavior.295AS_IF([test "x`uname -s 2>/dev/null`" = "xSunOS"], [296 CPPFLAGS="$CPPFLAGS -D_STRPTIME_DONTZERO"297])298299300AC_CONFIG_MACRO_DIRS([config/m4 m4])301AC_CONFIG_FILES([Makefile libjq.pc])302AC_OUTPUT303