Skip to content
Myr

Add setlocale() call (fix #1740)

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

authored by Nicolas Williams · committed by Nico Williams · parent ac3b70d · Browse files · 3 files+31 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+31 added−5 removed

  • tests:+23 added−5 removed
  • other:+8 added−0 removed

3 files+31 added−5 removed

modified:src/main.c+7 added
1#include <assert.h>2#include <ctype.h>3#include <errno.h>4#include <libgen.h>5#ifdef HAVE_SETLOCALE6#include <locale.h>7#endif8#include <stdlib.h>9#include <stdio.h>10#include <string.h>11#include <unistd.h>
309 unmodified lines
321 int options = 0;322 jv ARGS = jv_array(); /* positional arguments */323 jv program_arguments = jv_object(); /* named arguments */324325#ifdef HAVE_SETLOCALE326 (void) setlocale(LC_ALL, "");327#endif328329#ifdef WIN32330 jv_tsd_dtoa_ctx_init();331 fflush(stdout);332 fflush(stderr);
465 unmodified lines
modified:tests/shtest+23 added-5 removed
1#!/bin/sh -x23. "${0%/*}/setup" "$@"45msys=false6mingw=false7case "$(uname -s)" in8MSYS*) msys=true;;9MINGW*) mingw=true;;10esac1112JQ_NO_B=$JQ13JQ="$JQ -b"1415PATH=$JQBASEDIR:$PATH $JQBASEDIR/tests/jq-f-test.sh > /dev/null
486 unmodified lines
502cmp $d/color $d/expect503cmp $d/warning $d/expect_warning504505# Check $NO_COLOR499case "$(uname -s)" in500MSYS*) test_no_color=false;;501MINGW*) test_no_color=false;;502*) test_no_color=true;;503esac506test_no_color=true507$msys && test_no_color=false508$mingw && test_no_color=false509if $test_no_color && command -v script >/dev/null 2>&1; then510 unset NO_COLOR511 if script -qc echo /dev/null >/dev/null 2>&1; then512 faketty() { script -qec "$*" /dev/null; }
52 unmodified lines
565 echo "jq -f $JQTESTDIR/yes-main-program.jq failed"566 exit 1567fi568569if ( ! $msys && ! $mingw ) && locale -a > /dev/null; then570 locale=$(locale -a | egrep -v '^(C|LANG|POSIX|en)' | egrep -i 'utf8|utf-8' | head -1)571 if [ -z "$locale" ]; then572 echo "WARNING: Not testing localization"573 else574 date=$(LC_ALL="$locale" date +"%a %d %b %Y at %H:%M:%S")575 if ! LC_ALL="$locale" ./jq -nRe --arg date "$date" '$date|strptime("%a %d %b %Y at %H:%M:%S")? // false'; then576 echo "jq does not honor LC_ALL environment variable"577 exit 1;578 fi579 fi580fi581582exit 0
modified:configure.ac+1 added
147 unmodified lines
148AC_CHECK_MEMBER([struct tm.tm_gmtoff], [AC_DEFINE([HAVE_TM_TM_GMT_OFF],1,[Define to 1 if the system has the tm_gmt_off field in struct tm])],149 [], [[#include <time.h>]])150AC_CHECK_MEMBER([struct tm.__tm_gmtoff], [AC_DEFINE([HAVE_TM___TM_GMT_OFF],1,[Define to 1 if the system has the __tm_gmt_off field in struct tm])],151 [], [[#include <time.h>]])152AC_FIND_FUNC([setlocale], [c], [#include <locale.h>], [0,0])153154dnl Figure out if we have the pthread functions we actually need155AC_FIND_FUNC_NO_LIBS([pthread_key_create], [], [#include <pthread.h>], [NULL, NULL])156AC_FIND_FUNC_NO_LIBS([pthread_once], [], [#include <pthread.h>], [NULL, NULL])
142 unmodified lines