Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5b5cbefb8 | ||
|
|
365c1000e7 | ||
|
|
f957a5d639 | ||
|
|
f98c2b375d | ||
|
|
70335ccd4f | ||
|
|
4723a173f5 | ||
|
|
c4ee746b16 | ||
|
|
5843bb350f | ||
|
|
b60c9eb3e8 | ||
|
|
068300229b | ||
|
|
66f7ce5ac3 | ||
|
|
3045979f6c |
No files matched your search
+2
-6
@@ -5,9 +5,6 @@
|
||||
*.lai
|
||||
*.so
|
||||
*.so.*
|
||||
*.gcda
|
||||
*.gcno
|
||||
*.gcov
|
||||
*~
|
||||
.*.sw[a-p]
|
||||
tags
|
||||
@@ -16,13 +13,12 @@ jq
|
||||
!tests/modules/lib/jq/
|
||||
jq.1
|
||||
|
||||
# Generated source
|
||||
src/builtin.inc
|
||||
# Something delightfully recursive happens otherwise
|
||||
docs/content/2.download/source/*
|
||||
|
||||
# Autotools junk
|
||||
.libs
|
||||
.deps
|
||||
.dirstamp
|
||||
libtool
|
||||
*.log
|
||||
stamp-h1
|
||||
|
||||
+9
-31
@@ -1,7 +1,3 @@
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
sudo: false
|
||||
|
||||
language: c
|
||||
@@ -14,56 +10,39 @@ matrix:
|
||||
include:
|
||||
- compiler: gcc
|
||||
env: COVERAGE="--disable-valgrind --enable-gcov"
|
||||
os: linux
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libonig-dev
|
||||
- valgrind
|
||||
- bison
|
||||
|
||||
before_install:
|
||||
- echo "$TRAVIS_OS_NAME"
|
||||
- uname -s
|
||||
- brew update || true;
|
||||
brew install flex || true;
|
||||
brew install bison || true;
|
||||
brew install oniguruma || true;
|
||||
- rm src/{lexer,parser}.{c,h}
|
||||
- rm lexer.h lexer.c parser.h parser.c
|
||||
|
||||
install:
|
||||
- bundle install --gemfile=docs/Gemfile
|
||||
|
||||
- wget http://ftp.debian.org/debian/pool/main/b/bison/bison_3.0.2.dfsg-2_amd64.deb
|
||||
- ar p bison_3.0.2.dfsg-2_amd64.deb data.tar.xz | tar xJ
|
||||
|
||||
- if [ -n "$COVERAGE" ]; then pip install --user cpp-coveralls; fi
|
||||
|
||||
before_script:
|
||||
# If this is OS X we'll get bison from brew, else we'll get bison
|
||||
# from the .deb unpacked above in the install section.
|
||||
- PATH=/usr/local/opt/bison/bin:$PWD/usr/bin:$PATH
|
||||
- echo SHELL=$SHELL
|
||||
- echo PATH=$PATH
|
||||
- which bison
|
||||
- bison --version
|
||||
- autoreconf -i
|
||||
- ./configure YACC="$(which bison) -y" $COVERAGE
|
||||
- ./configure
|
||||
YACC="usr/bin/bison -y"
|
||||
$COVERAGE
|
||||
|
||||
script:
|
||||
# When using the bison from Debian we need to tell that bison where
|
||||
# to find its data. Yay non-relocatable code. Not.
|
||||
- echo PATH=$PATH
|
||||
- which bison
|
||||
- make BISON_PKGDATADIR=$PWD/usr/share/bison src/parser.c || make src/parser.c
|
||||
- make -j4
|
||||
- make -j4 BISON_PKGDATADIR=$(pwd)/usr/share/bison
|
||||
- make check -j4
|
||||
|
||||
after_script:
|
||||
- |
|
||||
if [ -n "$COVERAGE" ]; then
|
||||
rm -rf src/.libs # don't care about coverage for libjq
|
||||
coveralls --gcov-options '\-lp' \
|
||||
-e src/lexer.c -e src/parser.c -e src/jv_dtoa.c
|
||||
rm -rf .libs usr # don't care about coverage for libjq and bison
|
||||
coveralls -e lexer.c -e parser.c -e jv_dtoa.c --gcov-options '\-lp'
|
||||
fi
|
||||
|
||||
after_failure:
|
||||
@@ -72,4 +51,3 @@ after_failure:
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
@@ -4,59 +4,62 @@ Stephen Dolan <mu@netsoc.tcd.ie>
|
||||
Maintained by:
|
||||
Nicolas Williams <nico@cryptonector.com>
|
||||
William Langford <wlangfor@gmail.com>
|
||||
David Tolnay <dtolnay@gmail.com>
|
||||
|
||||
Contributions by:
|
||||
Aaron Peschel <apeschel@zendesk.com>
|
||||
Adam Lindberg <hello@alind.io>
|
||||
Alex Chamberlain <alex@alexchamberlain.co.uk>
|
||||
Andrew O'Brien <obrien.andrew@gmail.com> - docs build
|
||||
Andrew Rodland <andrew@cleverdomain.org> - bug fixes
|
||||
Ankur <ankz.kothari@gmail.com> - bug fixes
|
||||
Anthony Shortland <anthony.shortland@me.com> - rpmbuild target
|
||||
Assaf Gordon <assafgordon@gmail.com> - error handling
|
||||
Brendan Macmillan <melbourne.research@gmail.com> - bug fixes, load library from ~/.jq
|
||||
cdnbacon <mike@busbud.com>
|
||||
Charles Merriam <charles.merriam@gmail.com>
|
||||
Colin von Heuring <colin@janrain.com>
|
||||
Damian Gryski <damian@gryski.com>
|
||||
David Haguenauer <ml@kurokatta.org>
|
||||
David R. MacIver <david@drmaciver.com> - bug fixes
|
||||
David Tolnay <dtolnay@gmail.com> - destructuring, build improvements
|
||||
Doug Luce <doug@github.con.com> - build
|
||||
Eiichi Sato <sato.eiichi@gmail.com>
|
||||
Filippo Giunchedi <fgiunchedi@gmail.com> - bug fixes
|
||||
Filippo Valsorda <filippo.valsorda@gmail.com> - recursive object merge (`*`)
|
||||
Hanfei Shen <qqshfox@gmail.com>
|
||||
i <isomorphisms@sdf.org>
|
||||
Ian Miell <ian.miell@gmail.com>
|
||||
Jack Pearkes <jackpearkes@gmail.com> - update tutorial
|
||||
James Andariese <james.andariese@locationlabs.com> - Dockerfile
|
||||
Jingwen Owen Ou <jingweno@gmail.com> - jqplay.org and link to it
|
||||
jkleint <jkleint@gmail.com>
|
||||
Joe Littlejohn <joe.littlejohn@nokia.com> - bug fixes
|
||||
Joel Purra <code+github@joelpurra.com>
|
||||
Juan Guerrero <juan.guerrero.lozano@gmail.com> - bug fixes
|
||||
Juan Guerrero <juan.guerrero.lozano@gmail.com> - bug fixes
|
||||
Kenny Shen <kenny.shen@zalora.com> - doc fixes
|
||||
Kim De Mey <kim.demey@gmail.com> - build
|
||||
Kim Toms <kim.toms@bplglobal.net>
|
||||
LCD 47 <lcd047@gmail.com>
|
||||
Lee Thompson <stagr.lee@gmail.com> - autoconf stuff, rpm
|
||||
Marc Abramowitz <marc@marc-abramowitz.com>
|
||||
Marc Bruggmann <marcbr@spotify.com>
|
||||
Lee Thompson <stagr.lee@gmail.com> - autoconf stuff
|
||||
Markus Lanthaler <mark_lanthaler@gmx.net> - doc fixes
|
||||
Maxime Biais <maxime.biais@gmail.com> - build
|
||||
Michael Daines <michael@mdaines.com> - add sqrt; doc fixes
|
||||
Mike Fletcher <john.m.fletcher@bankofamerica.com>
|
||||
Mike McCabe <mccabe@archive.org> - math (libm) functions
|
||||
Nicolas Pouillard <nicolas.pouillard@gmail.com> - add tests
|
||||
Nicolas Williams <nico@cryptonector.com> - library-fication, autoconf stuff, exception handling, various
|
||||
Peter van Dijk <peter@7bits.nl> - doc fixes
|
||||
Philipp Hagemeister <phihag@phihag.de> - doc fixes
|
||||
pkoppstein <pkoppstein@gmail.com> - various builtins, improvements
|
||||
polyester <paul@cleanclothes.org> - automake version update
|
||||
Ryoichi KATO <ryo1kato@gmail.com> - doc fixes
|
||||
Rémy Léone <remy.leone@gmail.com> - add .travis.yml
|
||||
Ryoichi KATO <ryo1kato@gmail.com> - doc fixes
|
||||
Santiago Lapresta <santiago.lapresta@gmail.com> - join, arrays, all, any, other filters
|
||||
pkoppstein <pkoppstein@gmail.com> - various builtins, improvements
|
||||
13ren <melbourne.research@gmail.com>
|
||||
Aaron Peschel <apeschel@zendesk.com>
|
||||
Adam Lindberg <hello@alind.io>
|
||||
Alex Chamberlain <alex@alexchamberlain.co.uk>
|
||||
Andrew O'Brien <obrien.andrew@gmail.com> - docs build
|
||||
Assaf Gordon <assafgordon@gmail.com> - error handling
|
||||
cdnbacon <mike@busbud.com>
|
||||
Charles Merriam <charles.merriam@gmail.com>
|
||||
Colin von Heuring <colin@janrain.com>
|
||||
Damian Gryski <damian@gryski.com>
|
||||
David Haguenauer <ml@kurokatta.org>
|
||||
Doug Luce <doug@github.con.com> - build
|
||||
Eiichi Sato <sato.eiichi@gmail.com>
|
||||
Hanfei Shen <qqshfox@gmail.com>
|
||||
Ian Miell <ian.miell@gmail.com>
|
||||
i <isomorphisms@sdf.org>
|
||||
James Andariese <james.andariese@locationlabs.com> - Dockerfile
|
||||
jkleint <jkleint@gmail.com>
|
||||
Joel Purra <code+github@joelpurra.com>
|
||||
Kim De Mey <kim.demey@gmail.com> - build
|
||||
Kim Toms <kim.toms@bplglobal.net>
|
||||
LCD 47 <lcd047@gmail.com>
|
||||
Lee Thompson <thompson@dtosolutions.com> - rpm
|
||||
Marc Abramowitz <marc@marc-abramowitz.com>
|
||||
Marc Bruggmann <marcbr@spotify.com>
|
||||
Maxime Biais <maxime.biais@gmail.com> - build
|
||||
Mike Fletcher <john.m.fletcher@bankofamerica.com>
|
||||
Sebastian Freundt <freundt@ga-group.nl> - build
|
||||
Shay Elkin <shay@everything.me>
|
||||
Simon Elsbrock <simon@iodev.org> - Debian
|
||||
@@ -68,4 +71,3 @@ Steven Penny <svnpenn@gmail.com> - Windows bug fixes
|
||||
tal@whatexit.org <tal@whatexit.org>
|
||||
Travis Gockel <travis@gockelhut.com>
|
||||
Zhiming Wang <zmwangx@gmail.com>
|
||||
13ren <melbourne.research@gmail.com>
|
||||
@@ -30,9 +30,9 @@ license, which can be found at:
|
||||
The documentation website includes a copy of Twitter's Boostrap and
|
||||
relies on Bonsai, Liquid templates and various other projects, look
|
||||
them up for detailed licensing conditions.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
jq incorporates David M. Gay's dtoa.c and g_fmt.c, which bear the
|
||||
following notices:
|
||||
|
||||
|
||||
+25
-28
@@ -8,46 +8,43 @@ COPY . /app
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
build-essential \
|
||||
autoconf \
|
||||
libtool \
|
||||
git \
|
||||
bison \
|
||||
flex \
|
||||
ruby \
|
||||
wget \
|
||||
ruby-dev && \
|
||||
wget https://github.com/kkos/oniguruma/archive/v5.9.6.tar.gz -O onig-5.9.6.tar.gz && \
|
||||
sha512sum onig-5.9.6.tar.gz | grep 6b048d345e148c9da38af7a8df76d4a358eb3d4db91fa7834076e511f526a63544284f212b0d56badbbd33112c8b458a5fff02bfbbda012ecfe478bc436ea679 && \
|
||||
autoconf \
|
||||
libtool \
|
||||
git \
|
||||
bison \
|
||||
flex \
|
||||
ruby \
|
||||
wget \
|
||||
ruby-dev && \
|
||||
wget http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.6.tar.gz && \
|
||||
sha512sum onig-5.9.6.tar.gz | grep 4a181ea6f0e1a018bbaf6c87e666dfffd1ef4b8f5dcead07fa0b6564a76174e7e01854173924668433ae74c455dbced6a0e1b43e9066f0499b4a57e855e1a2b2 && \
|
||||
tar zxvf onig-5.9.6.tar.gz && \
|
||||
(cd oniguruma-5.9.6 && \
|
||||
touch NEWS ChangeLog && \
|
||||
autoreconf -i && \
|
||||
(cd onig-5.9.6 && \
|
||||
./configure --prefix=/usr/local && \
|
||||
make && \
|
||||
make install ) && \
|
||||
make install ) && \
|
||||
gem install bundler && \
|
||||
(cd /app/docs && bundle install) && \
|
||||
(cd /app && \
|
||||
autoreconf -i && \
|
||||
./configure --disable-valgrind --enable-all-static --prefix=/usr/local && \
|
||||
make -j8 && \
|
||||
make check && \
|
||||
make install && \
|
||||
make distclean ) && \
|
||||
(cd oniguruma-5.9.6 && \
|
||||
make -j8 && \
|
||||
make check && \
|
||||
make install && \
|
||||
make distclean ) && \
|
||||
(cd onig-5.9.6 && \
|
||||
make uninstall ) && \
|
||||
apt-get purge -y \
|
||||
build-essential \
|
||||
autoconf \
|
||||
libtool \
|
||||
bison \
|
||||
git \
|
||||
flex \
|
||||
ruby \
|
||||
ruby-dev && \
|
||||
autoconf \
|
||||
libtool \
|
||||
bison \
|
||||
git \
|
||||
flex \
|
||||
ruby \
|
||||
ruby-dev && \
|
||||
apt-get autoremove -y && \
|
||||
rm -rf oniguruma-5.9.6 && \
|
||||
rm -rf onig-5.9.6 && \
|
||||
rm -rf /var/lib/apt/lists/* /var/lib/gems
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/jq"]
|
||||
CMD []
|
||||
@@ -1,8 +0,0 @@
|
||||
pub 4096R/71523402 2015-10-11
|
||||
Key fingerprint = 4FD7 01D6 FA9B 3D2D F5AC 935D AF19 040C 7152 3402
|
||||
uid jq Release Signing Key <jq@stedolan.github.io>
|
||||
|
||||
pub 2048R/D15684DB 2015-10-12 [expires: 2017-10-11]
|
||||
Key fingerprint = 7F6C 7BD3 0412 AFD5 8C1A 5007 EB26 A4F8 D156 84DB
|
||||
uid Nicolas Williams <nico@cryptonector.com>
|
||||
sub 2048R/9C9CCD6A 2015-10-12 [expires: 2017-10-11]
|
||||
+65
-62
@@ -1,22 +1,18 @@
|
||||
|
||||
### C source files to be built and distributed.
|
||||
|
||||
LIBJQ_INCS = src/builtin.h src/bytecode.h src/compile.h \
|
||||
src/exec_stack.h src/jq_parser.h src/jv_alloc.h src/jv_dtoa.h \
|
||||
src/jv_unicode.h src/jv_utf8_tables.h src/lexer.l src/libm.h \
|
||||
src/linker.h src/locfile.h src/opcode_list.h src/parser.y \
|
||||
src/util.h
|
||||
LIBJQ_INCS = jq_parser.h builtin.h bytecode.h compile.h exec_stack.h \
|
||||
libm.h jv_alloc.h jv_dtoa.h jv_unicode.h locfile.h \
|
||||
opcode_list.h parser.y jv_utf8_tables.h lexer.l util.h linker.h
|
||||
|
||||
LIBJQ_SRC = src/builtin.c src/bytecode.c src/compile.c src/execute.c \
|
||||
src/jq_test.c src/jv.c src/jv_alloc.c src/jv_aux.c \
|
||||
src/jv_dtoa.c src/jv_file.c src/jv_parse.c src/jv_print.c \
|
||||
src/jv_unicode.c src/linker.c src/locfile.c src/util.c \
|
||||
${LIBJQ_INCS}
|
||||
LIBJQ_SRC = locfile.c bytecode.c compile.c execute.c builtin.c jv.c \
|
||||
jv_parse.c jv_print.c jv_dtoa.c jv_unicode.c jv_aux.c jv_file.c \
|
||||
jv_alloc.c jq_test.c util.c linker.c ${LIBJQ_INCS}
|
||||
|
||||
### C build options
|
||||
|
||||
AM_CFLAGS = -Wextra -Wall -Wno-missing-field-initializers \
|
||||
-Wno-unused-parameter -Wno-unused-function
|
||||
AM_CFLAGS = -Wextra -Wall -Wno-missing-field-initializers \
|
||||
-Wno-unused-parameter -Wno-unused-function
|
||||
|
||||
ACLOCAL_AMFLAGS = -I config/m4
|
||||
|
||||
@@ -25,13 +21,12 @@ ACLOCAL_AMFLAGS = -I config/m4
|
||||
# While there is some autoconf macro support for lex/flex, it doesn't support
|
||||
# header file creation so we'll use good old make
|
||||
if MAINTAINER_MODE
|
||||
BUILT_SOURCES = src/lexer.h src/lexer.c src/parser.h src/parser.c \
|
||||
src/builtin.inc src/version.h
|
||||
src/lexer.c: src/lexer.l
|
||||
$(AM_V_LEX) flex -o src/lexer.c --header-file=src/lexer.h $<
|
||||
src/lexer.h: src/lexer.c
|
||||
BUILT_SOURCES = lexer.h lexer.c parser.h parser.c version.h
|
||||
lexer.c: lexer.l
|
||||
$(AM_V_LEX) flex -o lexer.c --header-file=lexer.h $<
|
||||
lexer.h: lexer.c
|
||||
else
|
||||
BUILT_SOURCES = src/builtin.inc src/version.h
|
||||
BUILT_SOURCES =
|
||||
.y.c:
|
||||
$(AM_V_YACC) echo "NOT building parser.c!"
|
||||
.l.c:
|
||||
@@ -50,28 +45,15 @@ libjq_la_SOURCES = ${LIBJQ_SRC}
|
||||
libjq_la_LIBADD = -lm
|
||||
libjq_la_LDFLAGS = -export-symbols-regex '^j[qv]_' -version-info 1:4:0
|
||||
|
||||
if WIN32
|
||||
libjq_la_LIBADD += -lshlwapi
|
||||
endif
|
||||
|
||||
include_HEADERS = src/jv.h src/jq.h
|
||||
|
||||
if ENABLE_UBSAN
|
||||
AM_CFLAGS += -fsanitize=undefined
|
||||
endif
|
||||
include_HEADERS = jv.h jq.h
|
||||
|
||||
### Running tests under Valgrind
|
||||
|
||||
if ENABLE_ASAN
|
||||
AM_CFLAGS += -fsanitize=address
|
||||
NO_VALGRIND = 1
|
||||
else
|
||||
if ENABLE_VALGRIND
|
||||
NO_VALGRIND =
|
||||
else
|
||||
NO_VALGRIND = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
### Code coverage with gcov
|
||||
|
||||
@@ -83,7 +65,7 @@ endif
|
||||
|
||||
if ENABLE_ERROR_INJECTION
|
||||
lib_LTLIBRARIES += libinject_errors.la
|
||||
libinject_errors_la_SOURCES = src/inject_errors.c
|
||||
libinject_errors_la_SOURCES = inject_errors.c
|
||||
libinject_errors_la_LIBADD = -ldl
|
||||
libinject_errors_la_LDFLAGS = -module
|
||||
endif
|
||||
@@ -95,17 +77,13 @@ endif
|
||||
.FORCE:
|
||||
generate_ver = ver="`{ $(srcdir)/scripts/version || echo '$(VERSION)' ; } | sed 's/.*/\#define JQ_VERSION \"&\"/'`"
|
||||
.remake-version-h: .FORCE
|
||||
@ $(generate_ver); test "x`cat src/version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h
|
||||
src/version.h: .remake-version-h
|
||||
@ $(generate_ver); test "x`cat version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h
|
||||
version.h: .remake-version-h
|
||||
$(AM_V_GEN) $(generate_ver); echo "$$ver" > $@
|
||||
src/main.c: src/version.h
|
||||
|
||||
src/builtin.inc: src/builtin.jq
|
||||
$(AM_V_GEN) sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $^ > $@
|
||||
src/builtin.o: src/builtin.inc
|
||||
main.c: version.h
|
||||
|
||||
bin_PROGRAMS = jq
|
||||
jq_SOURCES = src/main.c src/version.h
|
||||
jq_SOURCES = main.c version.h
|
||||
jq_LDFLAGS = -static-libtool-libs
|
||||
jq_LDADD = libjq.la -lm
|
||||
|
||||
@@ -115,21 +93,39 @@ endif
|
||||
|
||||
### Tests (make check)
|
||||
|
||||
TESTS = tests/optionaltest tests/mantest tests/jqtest tests/onigtest tests/shtest tests/utf8test
|
||||
TESTS = tests/mantest tests/jqtest tests/onigtest tests/shtest
|
||||
TESTS_ENVIRONMENT = NO_VALGRIND=$(NO_VALGRIND)
|
||||
|
||||
|
||||
### Building the manpage
|
||||
|
||||
# If ENABLE_DOCS is not set, just copy jq.1.default to jq.1
|
||||
# The real_docs target succeeds (possibly after building jq.1) only if ENABLE_DOCS is set
|
||||
# Thus, making "dist" depend on "real_docs" ensures that we never build a tarball with
|
||||
# a stub manpage.
|
||||
|
||||
man_MANS = jq.1
|
||||
.PHONY: real_docs
|
||||
if ENABLE_DOCS
|
||||
jq.1: $(srcdir)/docs/content/3.manual/manual.yml
|
||||
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage ) > $@ || { rm -f $@; false; }
|
||||
jq.1.prebuilt: jq.1
|
||||
$(AM_V_GEN) cp $^ $@ || { rm -f $@; false; }
|
||||
jq.1.default: $(srcdir)/docs/default_manpage.md
|
||||
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage_default ) > $@ || { rm -f $@; false; }
|
||||
real_docs: jq.1 jq.1.prebuilt
|
||||
@if cmp jq.1 $(srcdir)/jq.1.default > /dev/null; then\
|
||||
rm -f jq.1; $(MAKE) $(AM_MAKEFLAGS) jq.1;\
|
||||
fi
|
||||
else
|
||||
jq.1: $(srcdir)/jq.1.prebuilt
|
||||
$(AM_V_GEN) cp $^ $@
|
||||
real_docs:
|
||||
@echo "Ruby dependencies not found, cannot build manpage." > /dev/stderr
|
||||
@echo "Follow the instructions in docs/README.md to install them" > /dev/stderr
|
||||
@echo "and then rerun ./configure" > /dev/stderr
|
||||
@echo "A pre-built, possibly out-of-date manpage used." > /dev/stderr
|
||||
false
|
||||
endif
|
||||
|
||||
|
||||
@@ -142,26 +138,33 @@ docs/site.yml: configure.ac
|
||||
install-binaries: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-exec
|
||||
|
||||
DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
|
||||
docs/Gemfile docs/Gemfile.lock docs/Rakefile docs/README.md \
|
||||
docs/default_manpage.md jq.1.default
|
||||
# Ensure "make dist" fails when we can't build the real manpage
|
||||
dist-hook: real_docs
|
||||
|
||||
EXTRA_DIST = $(DOC_FILES) $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) \
|
||||
jq.1.prebuilt jq.spec src/lexer.c src/lexer.h src/parser.c \
|
||||
src/parser.h src/version.h src/builtin.inc \
|
||||
scripts/version tests/jq.test tests/modules/.jq \
|
||||
tests/modules/a.jq tests/modules/b/b.jq tests/modules/c/c.jq \
|
||||
tests/modules/c/d.jq tests/modules/data.json \
|
||||
tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq \
|
||||
tests/modules/syntaxerror/syntaxerror.jq \
|
||||
tests/modules/test_bind_order.jq \
|
||||
tests/modules/test_bind_order0.jq \
|
||||
tests/modules/test_bind_order1.jq \
|
||||
tests/modules/test_bind_order2.jq tests/onig.supp \
|
||||
tests/onig.test tests/setup tests/torture/input0.json
|
||||
DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
|
||||
docs/Gemfile docs/Gemfile.lock docs/Rakefile docs/README.md \
|
||||
docs/default_manpage.md jq.1.default
|
||||
|
||||
# setup is only used by distribution developers, not package developers.
|
||||
# Still, as a matter of allowing patching, its not a bad idea to distribute
|
||||
# the developer setup script in the tarball.
|
||||
EXTRA_DIST = $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) jq.spec \
|
||||
$(DOC_FILES) scripts/version parser.h parser.c lexer.h \
|
||||
lexer.c tests/onig.supp tests/torture/input0.json \
|
||||
tests/modules/.jq tests/modules/a.jq tests/modules/b/b.jq \
|
||||
tests/modules/c/c.jq tests/modules/c/d.jq \
|
||||
tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq \
|
||||
tests/setup tests/jq.test tests/onig.test \
|
||||
tests/modules/data.json \
|
||||
tests/modules/syntaxerror/syntaxerror.jq \
|
||||
tests/modules/test_bind_order.jq \
|
||||
tests/modules/test_bind_order0.jq \
|
||||
tests/modules/test_bind_order1.jq \
|
||||
tests/modules/test_bind_order2.jq \
|
||||
jq.1.prebuilt
|
||||
|
||||
|
||||
# README.md is expected in Github projects, good stuff in it, so we'll
|
||||
# README.md is expected in Github projects, good stuff in it, so we'll
|
||||
# distribute it and install it with the package in the doc directory.
|
||||
docdir = ${datadir}/doc/${PACKAGE}
|
||||
dist_doc_DATA = README.md COPYING AUTHORS README
|
||||
@@ -184,12 +187,12 @@ dist-clean-local:
|
||||
clean-local-docs:
|
||||
if ENABLE_DOCS
|
||||
rm -f jq.1
|
||||
endif
|
||||
endif
|
||||
|
||||
clean-local-gcov:
|
||||
rm -f src/*.gcno src/*.gcda src/*.gcov
|
||||
rm -f *.gcno *.gcda *.gcov
|
||||
|
||||
clean-local: clean-local-docs clean-local-gcov
|
||||
rm -f src/version.h .remake-version-h
|
||||
rm -f version.h .remake-version-h
|
||||
|
||||
.PHONY: clean-local-docs clean-local-gcov
|
||||
+1646
File diff suppressed because it is too large.
Load diff
@@ -1,12 +1,11 @@
|
||||
|
||||
Release history
|
||||
|
||||
* jq version 1.5 was released on Sat Aug 15 2015
|
||||
* jq version 1.4 was released on Mon Jun 9 2014
|
||||
* jq version 1.3 was released on Sun May 19 2013
|
||||
* jq version 1.2 was released on Thu Dec 20 2012
|
||||
* jq version 1.1 was released on Sun Oct 21 2012
|
||||
* jq version 1.0 was released on Sun Oct 21 2012
|
||||
* jq version 1.1 was released on Sun Oct 21 2012
|
||||
* jq version 1.2 was released on Thu Dec 20 2012
|
||||
* jq version 1.3 was released on Sun May 19 2013
|
||||
* jq version 1.4 was released on Mon Jun 9 2014
|
||||
|
||||
New features in 1.5 since 1.4:
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
jq
|
||||
==
|
||||
|
||||
jq is a lightweight and flexible command-line JSON processor.
|
||||
|
||||
[](https://coveralls.io/github/stedolan/jq?branch=master),
|
||||
Unix: [](https://travis-ci.org/stedolan/jq),
|
||||
Windows: [](https://ci.appveyor.com/project/stedolan/jq)
|
||||
|
||||
jq is a command-line JSON processor.
|
||||
|
||||
If you want to learn to use jq, read the documentation at
|
||||
[https://stedolan.github.io/jq](https://stedolan.github.io/jq). This
|
||||
@@ -15,9 +10,7 @@ You can also try it online at [jqplay.org](https://jqplay.org).
|
||||
|
||||
If you want to hack on jq, feel free, but be warned that its internals
|
||||
are not well-documented at the moment. Bring a hard hat and a
|
||||
shovel. Also, read the wiki: https://github.com/stedolan/jq/wiki, where
|
||||
you will find cookbooks, discussion of advanced topics, internals,
|
||||
release engineering, and more.
|
||||
shovel. Also, read the wiki: https://github.com/stedolan/jq/wiki
|
||||
|
||||
Source tarball and built executable releases can be found on the
|
||||
homepage and on the github release page, https://github.com/stedolan/jq/releases
|
||||
|
||||
Vendored
+1255
File diff suppressed because it is too large.
Load diff
@@ -1,49 +0,0 @@
|
||||
environment:
|
||||
matrix:
|
||||
- MSYSTEM: MINGW64
|
||||
PATH: C:\msys64\usr\bin;C:\msys64\mingw64\bin;C:\Windows\System32;C:\Windows;%PATH%
|
||||
- MSYSTEM: MINGW32
|
||||
PATH: C:\msys64\usr\bin;C:\msys64\mingw32\bin;C:\Windows\System32;C:\Windows;%PATH%
|
||||
|
||||
|
||||
install:
|
||||
# update mysy2
|
||||
- C:\msys64\usr\bin\bash -lc "pacman --needed --noconfirm -Sy pacman-mirrors"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S autoconf automake bison flex"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-oniguruma mingw-w64-x86_64-oniguruma"
|
||||
|
||||
|
||||
build_script:
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && autoreconf -i"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && ./configure --disable-shared --enable-static --enable-all-static"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make -j8"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && cat jq.1 | groff -mandoc -Thtml > jq.html"
|
||||
- 7z a jq-package.zip jq.1 jq.html jq.exe
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && pwd && ls -la"
|
||||
- file jq.exe
|
||||
|
||||
test_script:
|
||||
# tests/optionaltest and tests/shtest fail on Windows; run them
|
||||
# anyways but ignore their failures. Also, trace shtest.
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make -j3 'TESTS=tests/mantest tests/jqtest tests/onigtest' check"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make TESTS=tests/optionaltest check || cat test-suite.log"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make TRACE_TESTS=1 TESTS=tests/shtest check || cat test-suite.log"
|
||||
|
||||
artifacts:
|
||||
- path: jq-package.zip
|
||||
name: jq-package
|
||||
|
||||
- path: jq.exe
|
||||
name: jq-exe
|
||||
|
||||
- path: test-suite.log
|
||||
name: logs
|
||||
|
||||
|
||||
on_failure:
|
||||
- cat test-suite.log
|
||||
- appveyor PushArtifact test-suite.log
|
||||
# also push the jq.exe so that someone can download it anyways...
|
||||
- appveyor PushArtifact jq-package.zip
|
||||
|
||||
+20676
File diff suppressed because it is too large.
Load diff
+20676
File diff suppressed because it is too large.
Load diff
+20676
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,550 @@
|
||||
# This file was generated by Autom4te Thu Apr 10 10:06:43 UTC 2014.
|
||||
# It contains the lists of macros which have been traced.
|
||||
# It can be safely removed.
|
||||
|
||||
@request = (
|
||||
bless( [
|
||||
'0',
|
||||
1,
|
||||
[
|
||||
'/usr/share/autoconf'
|
||||
],
|
||||
[
|
||||
'/usr/share/autoconf/autoconf/autoconf.m4f',
|
||||
'-',
|
||||
'/usr/share/aclocal-1.14/internal/ac-config-macro-dirs.m4',
|
||||
'/usr/share/aclocal/argz.m4',
|
||||
'/usr/share/aclocal/libtool.m4',
|
||||
'/usr/share/aclocal/ltdl.m4',
|
||||
'/usr/share/aclocal/ltoptions.m4',
|
||||
'/usr/share/aclocal/ltsugar.m4',
|
||||
'/usr/share/aclocal/ltversion.m4',
|
||||
'/usr/share/aclocal/lt~obsolete.m4',
|
||||
'/usr/share/aclocal-1.14/amversion.m4',
|
||||
'/usr/share/aclocal-1.14/ar-lib.m4',
|
||||
'/usr/share/aclocal-1.14/auxdir.m4',
|
||||
'/usr/share/aclocal-1.14/cond.m4',
|
||||
'/usr/share/aclocal-1.14/depend.m4',
|
||||
'/usr/share/aclocal-1.14/depout.m4',
|
||||
'/usr/share/aclocal-1.14/init.m4',
|
||||
'/usr/share/aclocal-1.14/install-sh.m4',
|
||||
'/usr/share/aclocal-1.14/lead-dot.m4',
|
||||
'/usr/share/aclocal-1.14/maintainer.m4',
|
||||
'/usr/share/aclocal-1.14/make.m4',
|
||||
'/usr/share/aclocal-1.14/missing.m4',
|
||||
'/usr/share/aclocal-1.14/options.m4',
|
||||
'/usr/share/aclocal-1.14/prog-cc-c-o.m4',
|
||||
'/usr/share/aclocal-1.14/runlog.m4',
|
||||
'/usr/share/aclocal-1.14/sanity.m4',
|
||||
'/usr/share/aclocal-1.14/silent.m4',
|
||||
'/usr/share/aclocal-1.14/strip.m4',
|
||||
'/usr/share/aclocal-1.14/substnot.m4',
|
||||
'/usr/share/aclocal-1.14/tar.m4',
|
||||
'config/m4/check-math-func.m4',
|
||||
'config/m4/find-func-no-libs.m4',
|
||||
'config/m4/find-func-no-libs2.m4',
|
||||
'config/m4/find-func.m4',
|
||||
'config/m4/misc.m4',
|
||||
'configure.ac'
|
||||
],
|
||||
{
|
||||
'AM_MAINTAINER_MODE' => 1,
|
||||
'AC_LIBLTDL_CONVENIENCE' => 1,
|
||||
'AC_LTDL_ENABLE_INSTALL' => 1,
|
||||
'LT_PATH_NM' => 1,
|
||||
'AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH' => 1,
|
||||
'_LT_PROG_ECHO_BACKSLASH' => 1,
|
||||
'LT_SYS_DLOPEN_SELF' => 1,
|
||||
'_LTDL_SETUP' => 1,
|
||||
'LT_SYS_DLSEARCH_PATH' => 1,
|
||||
'AC_LIBTOOL_F77' => 1,
|
||||
'm4_pattern_forbid' => 1,
|
||||
'm4_pattern_allow' => 1,
|
||||
'LT_SYS_MODULE_PATH' => 1,
|
||||
'_LT_LIBOBJ' => 1,
|
||||
'AC_CHECK_LIBM' => 1,
|
||||
'_LT_PATH_TOOL_PREFIX' => 1,
|
||||
'AC_LIBTOOL_LANG_RC_CONFIG' => 1,
|
||||
'AC_FIND_FUNC' => 1,
|
||||
'LT_SYS_DLOPEN_DEPLIBS' => 1,
|
||||
'AC_LIB_LTDL' => 1,
|
||||
'gl_FUNC_ARGZ' => 1,
|
||||
'LT_LIB_DLLOAD' => 1,
|
||||
'AM_ENABLE_SHARED' => 1,
|
||||
'AC_PROG_LD_RELOAD_FLAG' => 1,
|
||||
'AC_LIBTOOL_OBJDIR' => 1,
|
||||
'_LT_PROG_LTMAIN' => 1,
|
||||
'LTSUGAR_VERSION' => 1,
|
||||
'AC_LIBTOOL_SYS_OLD_ARCHIVE' => 1,
|
||||
'AC_LIBTOOL_RC' => 1,
|
||||
'LT_LANG' => 1,
|
||||
'_AM_PROG_CC_C_O' => 1,
|
||||
'LTDL_INIT' => 1,
|
||||
'_LT_COMPILER_BOILERPLATE' => 1,
|
||||
'AM_PROG_INSTALL_STRIP' => 1,
|
||||
'LTOPTIONS_VERSION' => 1,
|
||||
'AC_LIBTOOL_DLOPEN' => 1,
|
||||
'_LT_AC_PROG_ECHO_BACKSLASH' => 1,
|
||||
'_LT_COMPILER_OPTION' => 1,
|
||||
'_AM_SET_OPTION' => 1,
|
||||
'_LT_AC_LANG_GCJ_CONFIG' => 1,
|
||||
'LT_CMD_MAX_LEN' => 1,
|
||||
'AM_SET_DEPDIR' => 1,
|
||||
'AC_PROG_LD_GNU' => 1,
|
||||
'AC_PATH_MAGIC' => 1,
|
||||
'_LT_CC_BASENAME' => 1,
|
||||
'AM_MISSING_PROG' => 1,
|
||||
'LT_OUTPUT' => 1,
|
||||
'AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE' => 1,
|
||||
'AC_PATH_TOOL_PREFIX' => 1,
|
||||
'LT_INIT' => 1,
|
||||
'_LT_AC_LANG_F77_CONFIG' => 1,
|
||||
'AC_WITH_LTDL' => 1,
|
||||
'AC_LIBTOOL_POSTDEP_PREDEP' => 1,
|
||||
'AC_LIBTOOL_LANG_C_CONFIG' => 1,
|
||||
'AC_LIBTOOL_PROG_CC_C_O' => 1,
|
||||
'_LT_AC_TRY_DLOPEN_SELF' => 1,
|
||||
'LT_LIB_M' => 1,
|
||||
'LT_SYS_MODULE_EXT' => 1,
|
||||
'AC_LTDL_DLSYM_USCORE' => 1,
|
||||
'AC_DEFUN' => 1,
|
||||
'_AC_PROG_LIBTOOL' => 1,
|
||||
'_LT_PROG_F77' => 1,
|
||||
'AC_LIBTOOL_SYS_DYNAMIC_LINKER' => 1,
|
||||
'AM_SILENT_RULES' => 1,
|
||||
'AC_LIBTOOL_LANG_CXX_CONFIG' => 1,
|
||||
'AM_DEP_TRACK' => 1,
|
||||
'AM_PROG_LD' => 1,
|
||||
'AC_LIBTOOL_SYS_LIB_STRIP' => 1,
|
||||
'AC_LTDL_SHLIBPATH' => 1,
|
||||
'AM_RUN_LOG' => 1,
|
||||
'AC_DISABLE_STATIC' => 1,
|
||||
'AU_DEFUN' => 1,
|
||||
'include' => 1,
|
||||
'_LT_AC_SYS_COMPILER' => 1,
|
||||
'AC_LIBTOOL_PROG_COMPILER_NO_RTTI' => 1,
|
||||
'LT_AC_PROG_GCJ' => 1,
|
||||
'AC_LIBTOOL_COMPILER_OPTION' => 1,
|
||||
'AC_LTDL_SYMBOL_USCORE' => 1,
|
||||
'AC_LIBTOOL_PICMODE' => 1,
|
||||
'LT_AC_PROG_SED' => 1,
|
||||
'_LT_AC_FILE_LTDLL_C' => 1,
|
||||
'LT_AC_PROG_EGREP' => 1,
|
||||
'AC_PROG_LD' => 1,
|
||||
'_AM_PROG_TAR' => 1,
|
||||
'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1,
|
||||
'_m4_warn' => 1,
|
||||
'AC_LIBTOOL_SYS_MAX_CMD_LEN' => 1,
|
||||
'_LT_AC_CHECK_DLFCN' => 1,
|
||||
'LT_SUPPORTED_TAG' => 1,
|
||||
'_AC_AM_CONFIG_HEADER_HOOK' => 1,
|
||||
'AC_LIBTOOL_CONFIG' => 1,
|
||||
'_LT_AC_LANG_F77' => 1,
|
||||
'LTDL_INSTALLABLE' => 1,
|
||||
'AC_CONFIG_MACRO_DIR_TRACE' => 1,
|
||||
'AC_LIBTOOL_DLOPEN_SELF' => 1,
|
||||
'_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
|
||||
'AC_LTDL_SYS_DLOPEN_DEPLIBS' => 1,
|
||||
'_LT_LINKER_OPTION' => 1,
|
||||
'LTOBSOLETE_VERSION' => 1,
|
||||
'AC_LTDL_SYSSEARCHPATH' => 1,
|
||||
'AC_ENABLE_SHARED' => 1,
|
||||
'AM_AUX_DIR_EXPAND' => 1,
|
||||
'_LT_AC_TAGVAR' => 1,
|
||||
'LT_AC_PROG_RC' => 1,
|
||||
'LT_FUNC_DLSYM_USCORE' => 1,
|
||||
'LT_SYS_SYMBOL_USCORE' => 1,
|
||||
'AC_LIBTOOL_PROG_COMPILER_PIC' => 1,
|
||||
'LTDL_CONVENIENCE' => 1,
|
||||
'AC_PROG_EGREP' => 1,
|
||||
'AM_PROG_AR' => 1,
|
||||
'AC_ENABLE_FAST_INSTALL' => 1,
|
||||
'AX_PROG_BISON_VERSION' => 1,
|
||||
'_LT_WITH_SYSROOT' => 1,
|
||||
'AC_FIND_FUNC_NO_LIBS2' => 1,
|
||||
'AM_INIT_AUTOMAKE' => 1,
|
||||
'AC_LTDL_OBJDIR' => 1,
|
||||
'AC_PROG_LIBTOOL' => 1,
|
||||
'_LT_AC_LOCK' => 1,
|
||||
'AC_LIBTOOL_PROG_LD_SHLIBS' => 1,
|
||||
'AC_LTDL_SHLIBEXT' => 1,
|
||||
'upcase' => 1,
|
||||
'LT_PROG_GCJ' => 1,
|
||||
'AX_COMPARE_VERSION' => 1,
|
||||
'AC_LTDL_DLLIB' => 1,
|
||||
'_LT_AC_LANG_RC_CONFIG' => 1,
|
||||
'AC_CONFIG_MACRO_DIR' => 1,
|
||||
'_LT_PROG_CXX' => 1,
|
||||
'AM_PROG_CC_C_O' => 1,
|
||||
'AM_PROG_NM' => 1,
|
||||
'LT_PATH_LD' => 1,
|
||||
'_AM_IF_OPTION' => 1,
|
||||
'_AM_MANGLE_OPTION' => 1,
|
||||
'AM_DISABLE_SHARED' => 1,
|
||||
'm4_include' => 1,
|
||||
'_AM_SET_OPTIONS' => 1,
|
||||
'_LT_AC_SYS_LIBPATH_AIX' => 1,
|
||||
'AM_ENABLE_STATIC' => 1,
|
||||
'AC_DEFUN_ONCE' => 1,
|
||||
'_AM_AUTOCONF_VERSION' => 1,
|
||||
'AC_DEPLIBS_CHECK_METHOD' => 1,
|
||||
'AM_PROG_LIBTOOL' => 1,
|
||||
'AC_DISABLE_SHARED' => 1,
|
||||
'AM_SUBST_NOTMAKE' => 1,
|
||||
'_LT_AC_PROG_CXXCPP' => 1,
|
||||
'AC_LTDL_PREOPEN' => 1,
|
||||
'_LT_LINKER_BOILERPLATE' => 1,
|
||||
'AC_LIBTOOL_SETUP' => 1,
|
||||
'AC_CHECK_MATH_FUNC' => 1,
|
||||
'AM_SANITY_CHECK' => 1,
|
||||
'_LT_AC_LANG_CXX' => 1,
|
||||
'_LT_AC_TAGCONFIG' => 1,
|
||||
'LT_WITH_LTDL' => 1,
|
||||
'LT_CONFIG_LTDL_DIR' => 1,
|
||||
'_LT_REQUIRED_DARWIN_CHECKS' => 1,
|
||||
'AC_LIBTOOL_FC' => 1,
|
||||
'AC_LIBTOOL_SYS_HARD_LINK_LOCKS' => 1,
|
||||
'AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
|
||||
'AM_MISSING_HAS_RUN' => 1,
|
||||
'AM_PROG_INSTALL_SH' => 1,
|
||||
'AC_LIBTOOL_WIN32_DLL' => 1,
|
||||
'AC_ENABLE_STATIC' => 1,
|
||||
'_LT_PREPARE_SED_QUOTE_VARS' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'_LT_AC_SHELL_INIT' => 1,
|
||||
'AM_SET_LEADING_DOT' => 1,
|
||||
'LTVERSION_VERSION' => 1,
|
||||
'AC_LIBLTDL_INSTALLABLE' => 1,
|
||||
'LT_PROG_RC' => 1,
|
||||
'_AM_DEPENDENCIES' => 1,
|
||||
'LT_PROG_GO' => 1,
|
||||
'AC_LIBTOOL_GCJ' => 1,
|
||||
'gl_PREREQ_ARGZ' => 1,
|
||||
'_AM_CONFIG_MACRO_DIRS' => 1,
|
||||
'AC_FIND_FUNC_NO_LIBS' => 1,
|
||||
'AC_LIBTOOL_CXX' => 1,
|
||||
'AM_DISABLE_STATIC' => 1,
|
||||
'AC_LIBTOOL_LANG_F77_CONFIG' => 1,
|
||||
'AM_AUTOMAKE_VERSION' => 1,
|
||||
'AC_LIBTOOL_LINKER_OPTION' => 1,
|
||||
'AM_CONDITIONAL' => 1,
|
||||
'_LT_AC_LANG_GCJ' => 1,
|
||||
'AC_PROG_NM' => 1,
|
||||
'AC_DISABLE_FAST_INSTALL' => 1,
|
||||
'_LT_AC_LANG_CXX_CONFIG' => 1,
|
||||
'_LT_AC_LANG_C_CONFIG' => 1,
|
||||
'AM_MAKE_INCLUDE' => 1,
|
||||
'_LT_PROG_FC' => 1,
|
||||
'AC_LIBTOOL_LANG_GCJ_CONFIG' => 1
|
||||
}
|
||||
], 'Autom4te::Request' ),
|
||||
bless( [
|
||||
'1',
|
||||
1,
|
||||
[
|
||||
'/usr/share/autoconf'
|
||||
],
|
||||
[
|
||||
'/usr/share/autoconf/autoconf/autoconf.m4f',
|
||||
'aclocal.m4',
|
||||
'configure.ac'
|
||||
],
|
||||
{
|
||||
'AC_FC_PP_DEFINE' => 1,
|
||||
'AC_INIT' => 1,
|
||||
'AM_XGETTEXT_OPTION' => 1,
|
||||
'AC_CONFIG_LIBOBJ_DIR' => 1,
|
||||
'AM_PROG_CC_C_O' => 1,
|
||||
'include' => 1,
|
||||
'AC_LIBSOURCE' => 1,
|
||||
'AM_PROG_FC_C_O' => 1,
|
||||
'AM_GNU_GETTEXT' => 1,
|
||||
'AC_CANONICAL_HOST' => 1,
|
||||
'AM_POT_TOOLS' => 1,
|
||||
'AM_NLS' => 1,
|
||||
'_AM_MAKEFILE_INCLUDE' => 1,
|
||||
'AM_CONDITIONAL' => 1,
|
||||
'AH_OUTPUT' => 1,
|
||||
'_AM_COND_ELSE' => 1,
|
||||
'_AM_COND_IF' => 1,
|
||||
'AM_AUTOMAKE_VERSION' => 1,
|
||||
'AM_SILENT_RULES' => 1,
|
||||
'AM_INIT_AUTOMAKE' => 1,
|
||||
'AC_PROG_LIBTOOL' => 1,
|
||||
'AM_PROG_MOC' => 1,
|
||||
'AM_PROG_CXX_C_O' => 1,
|
||||
'AC_CONFIG_LINKS' => 1,
|
||||
'm4_sinclude' => 1,
|
||||
'AC_CONFIG_SUBDIRS' => 1,
|
||||
'AM_PROG_AR' => 1,
|
||||
'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
|
||||
'AC_CONFIG_HEADERS' => 1,
|
||||
'AC_SUBST_TRACE' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'AM_MAKEFILE_INCLUDE' => 1,
|
||||
'AM_EXTRA_RECURSIVE_TARGETS' => 1,
|
||||
'AC_CANONICAL_SYSTEM' => 1,
|
||||
'AM_PROG_MKDIR_P' => 1,
|
||||
'AC_SUBST' => 1,
|
||||
'AM_PATH_GUILE' => 1,
|
||||
'LT_INIT' => 1,
|
||||
'sinclude' => 1,
|
||||
'AM_PROG_F77_C_O' => 1,
|
||||
'LT_CONFIG_LTDL_DIR' => 1,
|
||||
'_LT_AC_TAGCONFIG' => 1,
|
||||
'AC_DEFINE_TRACE_LITERAL' => 1,
|
||||
'm4_pattern_forbid' => 1,
|
||||
'm4_pattern_allow' => 1,
|
||||
'AC_FC_PP_SRCEXT' => 1,
|
||||
'AC_FC_FREEFORM' => 1,
|
||||
'AC_CANONICAL_BUILD' => 1,
|
||||
'LT_SUPPORTED_TAG' => 1,
|
||||
'AM_ENABLE_MULTILIB' => 1,
|
||||
'_m4_warn' => 1,
|
||||
'AC_CONFIG_FILES' => 1,
|
||||
'AC_CONFIG_AUX_DIR' => 1,
|
||||
'AC_FC_SRCEXT' => 1,
|
||||
'AC_CANONICAL_TARGET' => 1,
|
||||
'_AM_COND_ENDIF' => 1,
|
||||
'm4_include' => 1,
|
||||
'AM_MAINTAINER_MODE' => 1,
|
||||
'AC_REQUIRE_AUX_FILE' => 1
|
||||
}
|
||||
], 'Autom4te::Request' ),
|
||||
bless( [
|
||||
'2',
|
||||
1,
|
||||
[
|
||||
'/usr/share/autoconf'
|
||||
],
|
||||
[
|
||||
'/usr/share/autoconf/autoconf/autoconf.m4f',
|
||||
'-',
|
||||
'/usr/share/aclocal-1.14/internal/ac-config-macro-dirs.m4',
|
||||
'/usr/share/aclocal/argz.m4',
|
||||
'/usr/share/aclocal/ltdl.m4',
|
||||
'/usr/share/aclocal-1.14/amversion.m4',
|
||||
'/usr/share/aclocal-1.14/ar-lib.m4',
|
||||
'/usr/share/aclocal-1.14/auxdir.m4',
|
||||
'/usr/share/aclocal-1.14/cond.m4',
|
||||
'/usr/share/aclocal-1.14/depend.m4',
|
||||
'/usr/share/aclocal-1.14/depout.m4',
|
||||
'/usr/share/aclocal-1.14/init.m4',
|
||||
'/usr/share/aclocal-1.14/install-sh.m4',
|
||||
'/usr/share/aclocal-1.14/lead-dot.m4',
|
||||
'/usr/share/aclocal-1.14/maintainer.m4',
|
||||
'/usr/share/aclocal-1.14/make.m4',
|
||||
'/usr/share/aclocal-1.14/missing.m4',
|
||||
'/usr/share/aclocal-1.14/options.m4',
|
||||
'/usr/share/aclocal-1.14/prog-cc-c-o.m4',
|
||||
'/usr/share/aclocal-1.14/runlog.m4',
|
||||
'/usr/share/aclocal-1.14/sanity.m4',
|
||||
'/usr/share/aclocal-1.14/silent.m4',
|
||||
'/usr/share/aclocal-1.14/strip.m4',
|
||||
'/usr/share/aclocal-1.14/substnot.m4',
|
||||
'/usr/share/aclocal-1.14/tar.m4',
|
||||
'config/m4/check-math-func.m4',
|
||||
'config/m4/find-func-no-libs.m4',
|
||||
'config/m4/find-func-no-libs2.m4',
|
||||
'config/m4/find-func.m4',
|
||||
'config/m4/libtool.m4',
|
||||
'config/m4/ltoptions.m4',
|
||||
'config/m4/ltsugar.m4',
|
||||
'config/m4/ltversion.m4',
|
||||
'config/m4/lt~obsolete.m4',
|
||||
'config/m4/misc.m4',
|
||||
'configure.ac'
|
||||
],
|
||||
{
|
||||
'AC_LIBTOOL_DLOPEN_SELF' => 1,
|
||||
'_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
|
||||
'AC_LTDL_SYS_DLOPEN_DEPLIBS' => 1,
|
||||
'_LT_LINKER_OPTION' => 1,
|
||||
'AC_ENABLE_SHARED' => 1,
|
||||
'AC_LTDL_SYSSEARCHPATH' => 1,
|
||||
'LTOBSOLETE_VERSION' => 1,
|
||||
'_LT_AC_TAGVAR' => 1,
|
||||
'AM_AUX_DIR_EXPAND' => 1,
|
||||
'LT_AC_PROG_RC' => 1,
|
||||
'AC_LIBTOOL_CONFIG' => 1,
|
||||
'_LT_AC_LANG_F77' => 1,
|
||||
'AC_CONFIG_MACRO_DIR_TRACE' => 1,
|
||||
'LTDL_INSTALLABLE' => 1,
|
||||
'_AM_PROG_TAR' => 1,
|
||||
'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1,
|
||||
'_m4_warn' => 1,
|
||||
'AC_LIBTOOL_SYS_MAX_CMD_LEN' => 1,
|
||||
'_LT_AC_CHECK_DLFCN' => 1,
|
||||
'LT_SUPPORTED_TAG' => 1,
|
||||
'_AC_AM_CONFIG_HEADER_HOOK' => 1,
|
||||
'_LT_AC_FILE_LTDLL_C' => 1,
|
||||
'LT_AC_PROG_EGREP' => 1,
|
||||
'AC_PROG_LD' => 1,
|
||||
'_LT_AC_LANG_RC_CONFIG' => 1,
|
||||
'AC_LTDL_DLLIB' => 1,
|
||||
'AC_CONFIG_MACRO_DIR' => 1,
|
||||
'_LT_PROG_CXX' => 1,
|
||||
'AM_PROG_CC_C_O' => 1,
|
||||
'AM_PROG_NM' => 1,
|
||||
'LT_PATH_LD' => 1,
|
||||
'AM_INIT_AUTOMAKE' => 1,
|
||||
'AC_LTDL_OBJDIR' => 1,
|
||||
'AC_PROG_LIBTOOL' => 1,
|
||||
'_LT_AC_LOCK' => 1,
|
||||
'AC_LIBTOOL_PROG_LD_SHLIBS' => 1,
|
||||
'AC_LTDL_SHLIBEXT' => 1,
|
||||
'LT_PROG_GCJ' => 1,
|
||||
'upcase' => 1,
|
||||
'AX_COMPARE_VERSION' => 1,
|
||||
'AC_LIBTOOL_PROG_COMPILER_PIC' => 1,
|
||||
'LTDL_CONVENIENCE' => 1,
|
||||
'AC_ENABLE_FAST_INSTALL' => 1,
|
||||
'AM_PROG_AR' => 1,
|
||||
'AC_PROG_EGREP' => 1,
|
||||
'AX_PROG_BISON_VERSION' => 1,
|
||||
'_LT_WITH_SYSROOT' => 1,
|
||||
'AC_FIND_FUNC_NO_LIBS2' => 1,
|
||||
'LT_FUNC_DLSYM_USCORE' => 1,
|
||||
'LT_SYS_SYMBOL_USCORE' => 1,
|
||||
'_LT_AC_TAGCONFIG' => 1,
|
||||
'LT_WITH_LTDL' => 1,
|
||||
'_LT_REQUIRED_DARWIN_CHECKS' => 1,
|
||||
'LT_CONFIG_LTDL_DIR' => 1,
|
||||
'AC_LIBTOOL_FC' => 1,
|
||||
'AM_SUBST_NOTMAKE' => 1,
|
||||
'_LT_AC_PROG_CXXCPP' => 1,
|
||||
'AC_LTDL_PREOPEN' => 1,
|
||||
'AC_CHECK_MATH_FUNC' => 1,
|
||||
'_LT_LINKER_BOILERPLATE' => 1,
|
||||
'AC_LIBTOOL_SETUP' => 1,
|
||||
'AM_SANITY_CHECK' => 1,
|
||||
'_LT_AC_LANG_CXX' => 1,
|
||||
'AC_DEFUN_ONCE' => 1,
|
||||
'AM_ENABLE_STATIC' => 1,
|
||||
'_AM_AUTOCONF_VERSION' => 1,
|
||||
'AM_PROG_LIBTOOL' => 1,
|
||||
'AC_DEPLIBS_CHECK_METHOD' => 1,
|
||||
'AC_DISABLE_SHARED' => 1,
|
||||
'_AM_IF_OPTION' => 1,
|
||||
'_AM_MANGLE_OPTION' => 1,
|
||||
'AM_DISABLE_SHARED' => 1,
|
||||
'_AM_SET_OPTIONS' => 1,
|
||||
'm4_include' => 1,
|
||||
'_LT_AC_SYS_LIBPATH_AIX' => 1,
|
||||
'_LT_AC_LANG_GCJ' => 1,
|
||||
'AC_PROG_NM' => 1,
|
||||
'AC_DISABLE_FAST_INSTALL' => 1,
|
||||
'_LT_AC_LANG_CXX_CONFIG' => 1,
|
||||
'_LT_PROG_FC' => 1,
|
||||
'AM_MAKE_INCLUDE' => 1,
|
||||
'_LT_AC_LANG_C_CONFIG' => 1,
|
||||
'AC_LIBTOOL_LANG_GCJ_CONFIG' => 1,
|
||||
'gl_PREREQ_ARGZ' => 1,
|
||||
'_AM_CONFIG_MACRO_DIRS' => 1,
|
||||
'AC_FIND_FUNC_NO_LIBS' => 1,
|
||||
'AM_DISABLE_STATIC' => 1,
|
||||
'AC_LIBTOOL_CXX' => 1,
|
||||
'AC_LIBTOOL_LANG_F77_CONFIG' => 1,
|
||||
'AM_AUTOMAKE_VERSION' => 1,
|
||||
'AC_LIBTOOL_LINKER_OPTION' => 1,
|
||||
'AM_CONDITIONAL' => 1,
|
||||
'_LT_AC_SHELL_INIT' => 1,
|
||||
'AM_SET_LEADING_DOT' => 1,
|
||||
'LTVERSION_VERSION' => 1,
|
||||
'LT_PROG_RC' => 1,
|
||||
'_AM_DEPENDENCIES' => 1,
|
||||
'AC_LIBLTDL_INSTALLABLE' => 1,
|
||||
'LT_PROG_GO' => 1,
|
||||
'AC_LIBTOOL_GCJ' => 1,
|
||||
'AM_MISSING_HAS_RUN' => 1,
|
||||
'AC_LIBTOOL_SYS_HARD_LINK_LOCKS' => 1,
|
||||
'AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
|
||||
'AM_PROG_INSTALL_SH' => 1,
|
||||
'AC_LIBTOOL_WIN32_DLL' => 1,
|
||||
'_LT_PREPARE_SED_QUOTE_VARS' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'AC_ENABLE_STATIC' => 1,
|
||||
'LT_SYS_MODULE_PATH' => 1,
|
||||
'_LT_PATH_TOOL_PREFIX' => 1,
|
||||
'AC_CHECK_LIBM' => 1,
|
||||
'_LT_LIBOBJ' => 1,
|
||||
'AC_LIBTOOL_LANG_RC_CONFIG' => 1,
|
||||
'LT_SYS_DLSEARCH_PATH' => 1,
|
||||
'AC_LIBTOOL_F77' => 1,
|
||||
'm4_pattern_forbid' => 1,
|
||||
'm4_pattern_allow' => 1,
|
||||
'_LT_PROG_ECHO_BACKSLASH' => 1,
|
||||
'AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH' => 1,
|
||||
'LT_SYS_DLOPEN_SELF' => 1,
|
||||
'_LTDL_SETUP' => 1,
|
||||
'AC_LIBLTDL_CONVENIENCE' => 1,
|
||||
'AM_MAINTAINER_MODE' => 1,
|
||||
'AC_LTDL_ENABLE_INSTALL' => 1,
|
||||
'LT_PATH_NM' => 1,
|
||||
'LT_LANG' => 1,
|
||||
'_AM_PROG_CC_C_O' => 1,
|
||||
'LTDL_INIT' => 1,
|
||||
'_LT_COMPILER_BOILERPLATE' => 1,
|
||||
'AM_ENABLE_SHARED' => 1,
|
||||
'AC_LIBTOOL_OBJDIR' => 1,
|
||||
'AC_PROG_LD_RELOAD_FLAG' => 1,
|
||||
'LTSUGAR_VERSION' => 1,
|
||||
'_LT_PROG_LTMAIN' => 1,
|
||||
'AC_LIBTOOL_RC' => 1,
|
||||
'AC_LIBTOOL_SYS_OLD_ARCHIVE' => 1,
|
||||
'gl_FUNC_ARGZ' => 1,
|
||||
'LT_LIB_DLLOAD' => 1,
|
||||
'AC_FIND_FUNC' => 1,
|
||||
'LT_SYS_DLOPEN_DEPLIBS' => 1,
|
||||
'AC_LIB_LTDL' => 1,
|
||||
'AM_MISSING_PROG' => 1,
|
||||
'LT_OUTPUT' => 1,
|
||||
'AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE' => 1,
|
||||
'AC_PATH_TOOL_PREFIX' => 1,
|
||||
'LT_INIT' => 1,
|
||||
'_LT_CC_BASENAME' => 1,
|
||||
'_AM_SET_OPTION' => 1,
|
||||
'_LT_AC_LANG_GCJ_CONFIG' => 1,
|
||||
'LT_CMD_MAX_LEN' => 1,
|
||||
'AM_SET_DEPDIR' => 1,
|
||||
'AC_PATH_MAGIC' => 1,
|
||||
'AC_PROG_LD_GNU' => 1,
|
||||
'AM_PROG_INSTALL_STRIP' => 1,
|
||||
'LTOPTIONS_VERSION' => 1,
|
||||
'_LT_AC_PROG_ECHO_BACKSLASH' => 1,
|
||||
'AC_LIBTOOL_DLOPEN' => 1,
|
||||
'_LT_COMPILER_OPTION' => 1,
|
||||
'AC_DISABLE_STATIC' => 1,
|
||||
'AU_DEFUN' => 1,
|
||||
'include' => 1,
|
||||
'_LT_AC_SYS_COMPILER' => 1,
|
||||
'LT_AC_PROG_GCJ' => 1,
|
||||
'AC_LIBTOOL_PROG_COMPILER_NO_RTTI' => 1,
|
||||
'AC_LIBTOOL_COMPILER_OPTION' => 1,
|
||||
'AC_LIBTOOL_PICMODE' => 1,
|
||||
'AC_LTDL_SYMBOL_USCORE' => 1,
|
||||
'LT_AC_PROG_SED' => 1,
|
||||
'_LT_PROG_F77' => 1,
|
||||
'_AC_PROG_LIBTOOL' => 1,
|
||||
'AC_LIBTOOL_SYS_DYNAMIC_LINKER' => 1,
|
||||
'AM_SILENT_RULES' => 1,
|
||||
'AC_LIBTOOL_LANG_CXX_CONFIG' => 1,
|
||||
'AC_LIBTOOL_SYS_LIB_STRIP' => 1,
|
||||
'AM_PROG_LD' => 1,
|
||||
'AM_DEP_TRACK' => 1,
|
||||
'AC_LTDL_SHLIBPATH' => 1,
|
||||
'AM_RUN_LOG' => 1,
|
||||
'AC_LIBTOOL_PROG_CC_C_O' => 1,
|
||||
'AC_LIBTOOL_LANG_C_CONFIG' => 1,
|
||||
'_LT_AC_TRY_DLOPEN_SELF' => 1,
|
||||
'LT_SYS_MODULE_EXT' => 1,
|
||||
'LT_LIB_M' => 1,
|
||||
'AC_LTDL_DLSYM_USCORE' => 1,
|
||||
'AC_DEFUN' => 1,
|
||||
'_LT_AC_LANG_F77_CONFIG' => 1,
|
||||
'AC_WITH_LTDL' => 1,
|
||||
'AC_LIBTOOL_POSTDEP_PREDEP' => 1
|
||||
}
|
||||
], 'Autom4te::Request' )
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+290
-78
@@ -1,12 +1,6 @@
|
||||
#define _BSD_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#ifndef __sun__
|
||||
# define _XOPEN_SOURCE
|
||||
# define _XOPEN_SOURCE_EXTENDED 1
|
||||
#else
|
||||
# define _XPG6
|
||||
# define __EXTENSIONS__
|
||||
#endif
|
||||
#define _XOPEN_SOURCE
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
@@ -110,24 +104,9 @@ static jv f_ ## name(jq_state *jq, jv input, jv a, jv b) { \
|
||||
return ret; \
|
||||
}
|
||||
#define LIBM_DDD_NO(name)
|
||||
|
||||
#define LIBM_DDDD(name) \
|
||||
static jv f_ ## name(jq_state *jq, jv input, jv a, jv b, jv c) { \
|
||||
if (jv_get_kind(a) != JV_KIND_NUMBER || jv_get_kind(b) != JV_KIND_NUMBER) \
|
||||
return type_error(input, "number required"); \
|
||||
jv_free(input); \
|
||||
jv ret = jv_number(name(jv_number_value(a), jv_number_value(b), jv_number_value(c))); \
|
||||
jv_free(a); \
|
||||
jv_free(b); \
|
||||
jv_free(c); \
|
||||
return ret; \
|
||||
}
|
||||
#define LIBM_DDDD_NO(name)
|
||||
#include "libm.h"
|
||||
#undef LIBM_DDDD_NO
|
||||
#undef LIBM_DDD_NO
|
||||
#undef LIBM_DD_NO
|
||||
#undef LIBM_DDDD
|
||||
#undef LIBM_DDD
|
||||
#undef LIBM_DD
|
||||
|
||||
@@ -388,12 +367,6 @@ static jv f_tostring(jq_state *jq, jv input) {
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_utf8bytelength(jq_state *jq, jv input) {
|
||||
if (jv_get_kind(input) != JV_KIND_STRING)
|
||||
return type_error(input, "only strings have UTF-8 byte length");
|
||||
return jv_number(jv_string_length_bytes(input));
|
||||
}
|
||||
|
||||
#define CHARS_ALPHANUM "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
|
||||
static jv escape_string(jv input, const char* escapings) {
|
||||
@@ -1247,17 +1220,14 @@ static jv f_now(jq_state *jq, jv a) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static jv f_current_filename(jq_state *jq, jv a) {
|
||||
jv_free(a);
|
||||
|
||||
static jv f_current_filename(jq_state *jq) {
|
||||
jv r = jq_util_input_get_current_filename(jq);
|
||||
if (jv_is_valid(r))
|
||||
return r;
|
||||
jv_free(r);
|
||||
return jv_null();
|
||||
}
|
||||
static jv f_current_line(jq_state *jq, jv a) {
|
||||
jv_free(a);
|
||||
static jv f_current_line(jq_state *jq) {
|
||||
return jq_util_input_get_current_line(jq);
|
||||
}
|
||||
|
||||
@@ -1269,10 +1239,6 @@ static jv f_current_line(jq_state *jq, jv a) {
|
||||
{(cfunction_ptr)f_ ## name, "_" #name, 3},
|
||||
#define LIBM_DDD_NO(name)
|
||||
|
||||
#define LIBM_DDDD(name) \
|
||||
{(cfunction_ptr)f_ ## name, "_" #name, 4},
|
||||
#define LIBM_DDDD_NO(name)
|
||||
|
||||
static const struct cfunction function_list[] = {
|
||||
#include "libm.h"
|
||||
{(cfunction_ptr)f_plus, "_plus", 3},
|
||||
@@ -1307,7 +1273,6 @@ static const struct cfunction function_list[] = {
|
||||
{(cfunction_ptr)f_greatereq, "_greatereq", 3},
|
||||
{(cfunction_ptr)f_contains, "contains", 2},
|
||||
{(cfunction_ptr)f_length, "length", 1},
|
||||
{(cfunction_ptr)f_utf8bytelength, "utf8bytelength", 1},
|
||||
{(cfunction_ptr)f_type, "type", 1},
|
||||
{(cfunction_ptr)f_isinfinite, "isinfinite", 1},
|
||||
{(cfunction_ptr)f_isnan, "isnan", 1},
|
||||
@@ -1340,10 +1305,8 @@ static const struct cfunction function_list[] = {
|
||||
{(cfunction_ptr)f_current_filename, "input_filename", 1},
|
||||
{(cfunction_ptr)f_current_line, "input_line_number", 1},
|
||||
};
|
||||
#undef LIBM_DDDD_NO
|
||||
#undef LIBM_DDD_NO
|
||||
#undef LIBM_DD_NO
|
||||
#undef LIBM_DDDD
|
||||
#undef LIBM_DDD
|
||||
#undef LIBM_DD
|
||||
|
||||
@@ -1376,15 +1339,9 @@ static block bind_bytecoded_builtins(block b) {
|
||||
{
|
||||
// Note that we can now define `range` as a jq-coded function
|
||||
block rangevar = gen_op_var_fresh(STOREV, "rangevar");
|
||||
block rangestart = gen_op_var_fresh(STOREV, "rangestart");
|
||||
block range = BLOCK(gen_op_simple(DUP),
|
||||
gen_call("start", gen_noop()),
|
||||
rangestart,
|
||||
block init = BLOCK(gen_op_simple(DUP), gen_call("start", gen_noop()), rangevar);
|
||||
block range = BLOCK(init,
|
||||
gen_call("end", gen_noop()),
|
||||
gen_op_simple(DUP),
|
||||
gen_op_bound(LOADV, rangestart),
|
||||
// Reset rangevar for every value generated by "end"
|
||||
rangevar,
|
||||
gen_op_bound(RANGE, rangevar));
|
||||
builtins = BLOCK(builtins, gen_function("range",
|
||||
BLOCK(gen_param("start"), gen_param("end")),
|
||||
@@ -1394,39 +1351,292 @@ static block bind_bytecoded_builtins(block b) {
|
||||
return block_bind_referenced(builtins, b, OP_IS_CALL_PSEUDO);
|
||||
}
|
||||
|
||||
#define LIBM_DD(name) "def " #name ": _" #name ";"
|
||||
#define LIBM_DDD(name) "def " #name "(a;b): _" #name "(a;b);"
|
||||
#define LIBM_DDDD(name) "def " #name "(a;b;c): _" #name "(a;b;c);"
|
||||
#define LIBM_DD_NO(name)
|
||||
#define LIBM_DDD_NO(name)
|
||||
#define LIBM_DDDD_NO(name)
|
||||
#define LIBM_DD(name) "def " #name ": _" #name ";",
|
||||
#define LIBM_DDD(name) "def " #name "(a;b): _" #name "(a;b);",
|
||||
#define LIBM_DD_NO(name) "def " #name ": \"Error: " #name "() not found at build time\"|error;",
|
||||
#define LIBM_DDD_NO(name) "def " #name "(a;b): \"Error: " #name "() not found at build time\"|error;",
|
||||
|
||||
static const char* const jq_builtins =
|
||||
/* Include supported math functions first */
|
||||
static const char* const jq_builtins[] = {
|
||||
"def error: error(.);",
|
||||
"def map(f): [.[] | f];",
|
||||
"def select(f): if f then . else empty end;",
|
||||
"def sort_by(f): _sort_by_impl(map([f]));",
|
||||
"def group_by(f): _group_by_impl(map([f]));",
|
||||
"def unique: group_by(.) | map(.[0]);",
|
||||
"def unique_by(f): group_by(f) | map(.[0]);",
|
||||
"def max_by(f): _max_by_impl(map([f]));",
|
||||
"def min_by(f): _min_by_impl(map([f]));",
|
||||
#include "libm.h"
|
||||
/* Include jq-coded builtins next (some depend on math) */
|
||||
#include "src/builtin.inc"
|
||||
"def add: reduce .[] as $x (null; . + $x);",
|
||||
"def del(f): delpaths([path(f)]);",
|
||||
"def _assign(paths; value): value as $v | reduce path(paths) as $p (.; setpath($p; $v));",
|
||||
"def _modify(paths; update): reduce path(paths) as $p (.; setpath($p; getpath($p) | update));",
|
||||
"def map_values(f): .[] |= f;",
|
||||
|
||||
/* Include unsupported math functions next */
|
||||
#undef LIBM_DDDD_NO
|
||||
// recurse
|
||||
"def recurse(f): def r: ., (f | select(. != null) | r); r;",
|
||||
"def recurse(f; cond): def r: ., (f | select(cond) | r); r;",
|
||||
"def recurse: recurse(.[]?);",
|
||||
"def recurse_down: recurse;",
|
||||
|
||||
"def to_entries: [keys_unsorted[] as $k | {key: $k, value: .[$k]}];",
|
||||
"def from_entries: map({(.key // .Key // .Name): (if has(\"value\") then .value else .Value end)}) | add | .//={};",
|
||||
"def with_entries(f): to_entries | map(f) | from_entries;",
|
||||
"def reverse: [.[length - 1 - range(0;length)]];",
|
||||
"def indices($i): if type == \"array\" and ($i|type) == \"array\" then .[$i]"
|
||||
" elif type == \"array\" then .[[$i]]"
|
||||
" elif type == \"string\" and ($i|type) == \"string\" then _strindices($i)"
|
||||
" else .[$i] end;",
|
||||
"def index($i): indices($i) | .[0];", // TODO: optimize
|
||||
"def rindex($i): indices($i) | .[-1:][0];", // TODO: optimize
|
||||
"def paths: path(recurse(if (type|. == \"array\" or . == \"object\") then .[] else empty end))|select(length > 0);",
|
||||
"def paths(node_filter): . as $dot|paths|select(. as $p|$dot|getpath($p)|node_filter);",
|
||||
"def any(generator; condition):"
|
||||
" [label $out | foreach generator as $i"
|
||||
" (false;"
|
||||
" if . then break $out elif $i | condition then true else . end;"
|
||||
" if . then . else empty end)] | length == 1;",
|
||||
"def any(condition): any(.[]; condition);",
|
||||
"def any: any(.);",
|
||||
"def all(generator; condition): "
|
||||
" [label $out | foreach generator as $i"
|
||||
" (true;"
|
||||
" if .|not then break $out elif $i | condition then . else false end;"
|
||||
" if .|not then . else empty end)] | length == 0;",
|
||||
"def all(condition): all(.[]; condition);",
|
||||
"def all: all(.);",
|
||||
"def isfinite: type == \"number\" and (isinfinite | not);",
|
||||
"def arrays: select(type == \"array\");",
|
||||
"def objects: select(type == \"object\");",
|
||||
"def iterables: arrays, objects;",
|
||||
"def booleans: select(type == \"boolean\");",
|
||||
"def numbers: select(type == \"number\");",
|
||||
"def normals: select(isnormal);",
|
||||
"def finites: select(isfinite);",
|
||||
"def strings: select(type == \"string\");",
|
||||
"def nulls: select(type == \"null\");",
|
||||
"def values: select(. != null);",
|
||||
"def scalars: select(. == null or . == true or . == false or type == \"number\" or type == \"string\");",
|
||||
"def scalars_or_empty: select(. == null or . == true or . == false or type == \"number\" or type == \"string\" or ((type==\"array\" or type==\"object\") and length==0));",
|
||||
"def leaf_paths: paths(scalars);",
|
||||
"def join($x): reduce .[] as $i (null; (.//\"\") + (if . == null then $i else $x + $i end))//\"\";",
|
||||
"def _flatten($x): reduce .[] as $i ([]; if $i | type == \"array\" and $x != 0 then . + ($i | _flatten($x-1)) else . + [$i] end);",
|
||||
"def flatten($x): if $x < 0 then error(\"flatten depth must not be negative\") else _flatten($x) end;",
|
||||
"def flatten: _flatten(-1);",
|
||||
"def range($x): range(0;$x);",
|
||||
"def fromdateiso8601: strptime(\"%Y-%m-%dT%H:%M:%SZ\")|mktime;",
|
||||
"def todateiso8601: strftime(\"%Y-%m-%dT%H:%M:%SZ\");",
|
||||
"def fromdate: fromdateiso8601;",
|
||||
"def todate: todateiso8601;",
|
||||
"def match(re; mode): _match_impl(re; mode; false)|.[];",
|
||||
"def match($val): ($val|type) as $vt | if $vt == \"string\" then match($val; null)"
|
||||
" elif $vt == \"array\" and ($val | length) > 1 then match($val[0]; $val[1])"
|
||||
" elif $vt == \"array\" and ($val | length) > 0 then match($val[0]; null)"
|
||||
" else error( $vt + \" not a string or array\") end;",
|
||||
"def test(re; mode): _match_impl(re; mode; true);",
|
||||
"def test($val): ($val|type) as $vt | if $vt == \"string\" then test($val; null)"
|
||||
" elif $vt == \"array\" and ($val | length) > 1 then test($val[0]; $val[1])"
|
||||
" elif $vt == \"array\" and ($val | length) > 0 then test($val[0]; null)"
|
||||
" else error( $vt + \" not a string or array\") end;",
|
||||
"def capture(re; mods): match(re; mods) | reduce ( .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair ({}; . + $pair);",
|
||||
"def capture($val): ($val|type) as $vt | if $vt == \"string\" then capture($val; null)"
|
||||
" elif $vt == \"array\" and ($val | length) > 1 then capture($val[0]; $val[1])"
|
||||
" elif $vt == \"array\" and ($val | length) > 0 then capture($val[0]; null)"
|
||||
" else error( $vt + \" not a string or array\") end;",
|
||||
"def scan(re):"
|
||||
" match(re; \"g\")"
|
||||
" | if (.captures|length > 0)"
|
||||
" then [ .captures | .[] | .string ]"
|
||||
" else .string"
|
||||
" end ;",
|
||||
//
|
||||
// If input is an array, then emit a stream of successive subarrays of length n (or less),
|
||||
// and similarly for strings.
|
||||
"def _nwise(a; $n): if a|length <= $n then a else a[0:$n] , _nwise(a[$n:]; $n) end;",
|
||||
"def _nwise($n): _nwise(.; $n);",
|
||||
//
|
||||
// splits/1 produces a stream; split/1 is retained for backward compatibility.
|
||||
"def splits($re; flags): . as $s"
|
||||
// # multiple occurrences of "g" are acceptable
|
||||
" | [ match($re; \"g\" + flags) | (.offset, .offset + .length) ]"
|
||||
" | [0] + . +[$s|length]"
|
||||
" | _nwise(2)"
|
||||
" | $s[.[0]:.[1] ] ;",
|
||||
"def splits($re): splits($re; null);",
|
||||
//
|
||||
// split emits an array for backward compatibility
|
||||
"def split($re; flags): [ splits($re; flags) ];",
|
||||
//
|
||||
// If s contains capture variables, then create a capture object and pipe it to s
|
||||
"def sub($re; s):"
|
||||
" . as $in"
|
||||
" | [match($re)]"
|
||||
" | if length == 0 then $in"
|
||||
" else .[0]"
|
||||
" | . as $r"
|
||||
// # create the \"capture\" object:
|
||||
" | reduce ( $r | .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair"
|
||||
" ({}; . + $pair)"
|
||||
" | $in[0:$r.offset] + s + $in[$r.offset+$r.length:]"
|
||||
" end ;",
|
||||
//
|
||||
// If s contains capture variables, then create a capture object and pipe it to s
|
||||
"def sub($re; s; flags):"
|
||||
" def subg: explode | select(. != 103) | implode;"
|
||||
// # "fla" should be flags with all occurrences of g removed; gs should be non-nil if flags has a g
|
||||
" def sub1(fla; gs):"
|
||||
" def mysub:"
|
||||
" . as $in"
|
||||
" | [match($re; fla)]"
|
||||
" | if length == 0 then $in"
|
||||
" else .[0] as $edit"
|
||||
" | ($edit | .offset + .length) as $len"
|
||||
// # create the "capture" object:
|
||||
" | reduce ( $edit | .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair"
|
||||
" ({}; . + $pair)"
|
||||
" | $in[0:$edit.offset]"
|
||||
" + s"
|
||||
" + ($in[$len:] | if gs then mysub else . end)"
|
||||
" end ;"
|
||||
" mysub ;"
|
||||
" (flags | index(\"g\")) as $gs"
|
||||
" | (flags | if $gs then subg else . end) as $fla"
|
||||
" | sub1($fla; $gs);",
|
||||
//
|
||||
"def sub($re; s): sub($re; s; \"\");",
|
||||
// repeated substitution of re (which may contain named captures)
|
||||
"def gsub($re; s; flags): sub($re; s; flags + \"g\");",
|
||||
"def gsub($re; s): sub($re; s; \"g\");",
|
||||
|
||||
//#######################################################################
|
||||
// range/3, with a `by` expression argument
|
||||
"def range($init; $upto; $by): "
|
||||
" def _range: "
|
||||
" if ($by > 0 and . < $upto) or ($by < 0 and . > $upto) then ., ((.+$by)|_range) else . end; "
|
||||
" if $by == 0 then $init else $init|_range end | select(($by > 0 and . < $upto) or ($by < 0 and . > $upto));",
|
||||
// generic iterator/generator
|
||||
"def while(cond; update): "
|
||||
" def _while: "
|
||||
" if cond then ., (update | _while) else empty end; "
|
||||
" _while;",
|
||||
"def until(cond; next): "
|
||||
" def _until: "
|
||||
" if cond then . else (next|_until) end;"
|
||||
" _until;",
|
||||
"def limit($n; exp): if $n < 0 then exp else label $out | foreach exp as $item ([$n, null]; if .[0] < 1 then break $out else [.[0] -1, $item] end; .[1]) end;",
|
||||
"def first(g): label $out | foreach g as $item ([false, null]; if .[0]==true then break $out else [true, $item] end; .[1]);",
|
||||
"def last(g): reduce g as $item (null; $item);",
|
||||
"def nth($n; g): if $n < 0 then error(\"nth doesn't support negative indices\") else last(limit($n + 1; g)) end;",
|
||||
"def first: .[0];",
|
||||
"def last: .[-1];",
|
||||
"def nth($n): .[$n];",
|
||||
"def combinations:"
|
||||
" if length == 0 then [] else"
|
||||
" .[0][] as $x"
|
||||
" | (.[1:] | combinations) as $y"
|
||||
" | [$x] + $y"
|
||||
" end;",
|
||||
"def combinations(n):"
|
||||
" . as $dot"
|
||||
" | [range(n) | $dot]"
|
||||
" | combinations;",
|
||||
// # transpose a possibly jagged matrix, quickly;
|
||||
// # rows are padded with nulls so the result is always rectangular.
|
||||
"def transpose:"
|
||||
" if . == [] then []"
|
||||
" else . as $in"
|
||||
" | (map(length) | max) as $max"
|
||||
" | length as $length"
|
||||
" | reduce range(0; $max) as $j"
|
||||
" ([]; . + [reduce range(0;$length) as $i ([]; . + [ $in[$i][$j] ] )] )"
|
||||
" end;",
|
||||
"def in(xs): . as $x | xs | has($x);",
|
||||
"def inside(xs): . as $x | xs | contains($x);",
|
||||
"def input: _input;",
|
||||
"def repeat(exp): "
|
||||
" def _repeat: "
|
||||
" exp, _repeat;"
|
||||
" _repeat;",
|
||||
"def inputs: try repeat(_input) catch if .==\"break\" then empty else .|error end;",
|
||||
// # like ruby's downcase - only characters A to Z are affected
|
||||
"def ascii_downcase:"
|
||||
" explode | map( if 65 <= . and . <= 90 then . + 32 else . end) | implode;",
|
||||
// # like ruby's upcase - only characters a to z are affected
|
||||
"def ascii_upcase:"
|
||||
" explode | map( if 97 <= . and . <= 122 then . - 32 else . end) | implode;",
|
||||
|
||||
// Streaming utilities
|
||||
"def truncate_stream(stream):"
|
||||
" . as $n | null | stream | . as $input | if (.[0]|length) > $n then setpath([0];$input[0][1:]) else empty end;",
|
||||
"def fromstream(i):"
|
||||
" foreach i as $item ("
|
||||
" [null,false,null,false];"
|
||||
" if ($item[0]|length) == 0 then [null,false,.[2],.[3]]"
|
||||
" elif ($item|length) == 1 and ($item[0]|length) < 2 then [null,false,.[0],.[1]]"
|
||||
" else . end |"
|
||||
" . as $state |"
|
||||
" if ($item|length) > 1 and ($item[0]|length) > 0 then"
|
||||
" [.[0]|setpath(($item|.[0]); ($item|.[1])), "
|
||||
" true, "
|
||||
" $state[2], "
|
||||
" $state[3]] "
|
||||
" else ."
|
||||
" end;"
|
||||
" if ($item[0]|length) == 1 and ($item|length == 1) and .[3] then .[2] else empty end,"
|
||||
" if ($item[0]|length) == 0 then $item[1] else empty end"
|
||||
" );",
|
||||
"def tostream:\n"
|
||||
" {string:true,number:true,boolean:true,null:true} as $leaf_types |\n"
|
||||
" . as $dot |\n"
|
||||
" if $leaf_types[$dot|type] or length==0 then [[],$dot]\n"
|
||||
" else\n"
|
||||
" # We really need a _streaming_ form of `keys`.\n"
|
||||
" # We can use `range` for arrays, but not for objects.\n"
|
||||
" keys as $keys |\n"
|
||||
" $keys[-1] as $last|\n"
|
||||
" ((# for each key\n"
|
||||
" $keys[] | . as $key |\n"
|
||||
" $dot[$key] | . as $dot |\n"
|
||||
" # recurse on each key/value\n"
|
||||
" tostream|.[0]|=[$key]+.),\n"
|
||||
" # then add the closing marker\n"
|
||||
" [[$last]])\n"
|
||||
" end;",
|
||||
|
||||
|
||||
// # Assuming the input array is sorted, bsearch/1 returns
|
||||
// # the index of the target if the target is in the input array; and otherwise
|
||||
// # (-1 - ix), where ix is the insertion point that would leave the array sorted.
|
||||
// # If the input is not sorted, bsearch will terminate but with irrelevant results.
|
||||
"def bsearch(target):"
|
||||
" if length == 0 then -1"
|
||||
" elif length == 1 then"
|
||||
" if target == .[0] then 0 elif target < .[0] then -1 else -2 end"
|
||||
" else . as $in"
|
||||
"" // # state variable: [start, end, answer]
|
||||
"" // # where start and end are the upper and lower offsets to use.
|
||||
" | [0, length-1, null]"
|
||||
" | until( .[0] > .[1] ;"
|
||||
" if .[2] != null then (.[1] = -1)" // # i.e. break
|
||||
" else"
|
||||
" ( ( (.[1] + .[0]) / 2 ) | floor ) as $mid"
|
||||
" | $in[$mid] as $monkey"
|
||||
" | if $monkey == target then (.[2] = $mid)" // # success
|
||||
" elif .[0] == .[1] then (.[1] = -1)" // # failure
|
||||
" elif $monkey < target then (.[0] = ($mid + 1))"
|
||||
" else (.[1] = ($mid - 1))"
|
||||
" end"
|
||||
" end )"
|
||||
" | if .[2] == null then" // # compute the insertion point
|
||||
" if $in[ .[0] ] < target then (-2 -.[0])"
|
||||
" else (-1 -.[0])"
|
||||
" end"
|
||||
" else .[2]"
|
||||
" end"
|
||||
" end;",
|
||||
};
|
||||
#undef LIBM_DDD_NO
|
||||
#undef LIBM_DD_NO
|
||||
#undef LIBM_DDDD
|
||||
#undef LIBM_DDD
|
||||
#undef LIBM_DD
|
||||
#define LIBM_DD(name)
|
||||
#define LIBM_DDD(name)
|
||||
#define LIBM_DDDD(name)
|
||||
#define LIBM_DD_NO(name) "def " #name ": \"Error: " #name "() not found at build time\"|error;"
|
||||
#define LIBM_DDD_NO(name) "def " #name "(a;b): \"Error: " #name "() not found at build time\"|error;"
|
||||
#define LIBM_DDDD_NO(name) "def " #name "(a;b;c): \"Error: " #name "() not found at build time\"|error;"
|
||||
#include "libm.h"
|
||||
;
|
||||
|
||||
#undef LIBM_DDDD_NO
|
||||
#undef LIBM_DDD_NO
|
||||
#undef LIBM_DD_NO
|
||||
#undef LIBM_DDDD
|
||||
#undef LIBM_DDD
|
||||
#undef LIBM_DD
|
||||
|
||||
@@ -1464,8 +1674,10 @@ int builtins_bind(jq_state *jq, block* bb) {
|
||||
block_free(*bb);
|
||||
return nerrors;
|
||||
}
|
||||
nerrors = builtins_bind_one(jq, bb, jq_builtins);
|
||||
assert(!nerrors);
|
||||
for (int i=(int)(sizeof(jq_builtins)/sizeof(jq_builtins[0]))-1; i>=0; i--) {
|
||||
nerrors = builtins_bind_one(jq, bb, jq_builtins[i]);
|
||||
assert(!nerrors);
|
||||
}
|
||||
*bb = bind_bytecoded_builtins(*bb);
|
||||
*bb = gen_cbinding(function_list, sizeof(function_list)/sizeof(function_list[0]), *bb);
|
||||
return nerrors;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -12,8 +12,8 @@ NJOBS="-j`sysctl -n hw.ncpu || echo 1`"
|
||||
# Get oniguruma
|
||||
rm -rf $PWD/build/ios onig-5.9.5
|
||||
echo "Downloading oniguruma 5.9.5"
|
||||
curl -L https://github.com/kkos/oniguruma/archive/v5.9.6.tar.gz | tar xz
|
||||
cd oniguruma-5.9.5
|
||||
curl http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.5.tar.gz | tar xz
|
||||
cd onig-5.9.5
|
||||
|
||||
# So, we need to remake the configure scripts so that the arm64 architecture
|
||||
# exists in config.sub. In order to keep autoreconf from failing, create
|
||||
|
||||
@@ -495,24 +495,21 @@ jv block_module_meta(block b) {
|
||||
return jv_null();
|
||||
}
|
||||
|
||||
block gen_import(const char* name, const char* as, int is_data) {
|
||||
block gen_import(const char* name, block metadata, const char* as, int is_data) {
|
||||
assert(metadata.first == NULL || block_is_const(metadata));
|
||||
inst* i = inst_new(DEPS);
|
||||
jv meta = jv_object();
|
||||
jv meta;
|
||||
if (block_is_const(metadata))
|
||||
meta = block_const(metadata);
|
||||
else
|
||||
meta = jv_object();
|
||||
if (as != NULL)
|
||||
meta = jv_object_set(meta, jv_string("as"), jv_string(as));
|
||||
meta = jv_object_set(meta, jv_string("is_data"), is_data ? jv_true() : jv_false());
|
||||
meta = jv_object_set(meta, jv_string("relpath"), jv_string(name));
|
||||
i->imm.constant = meta;
|
||||
return inst_block(i);
|
||||
}
|
||||
|
||||
block gen_import_meta(block import, block metadata) {
|
||||
assert(block_is_single(import) && import.first->op == DEPS);
|
||||
assert(block_is_const(metadata) && block_const_kind(metadata) == JV_KIND_OBJECT);
|
||||
inst *i = import.first;
|
||||
i->imm.constant = jv_object_merge(block_const(metadata), i->imm.constant);
|
||||
block_free(metadata);
|
||||
return import;
|
||||
return inst_block(i);
|
||||
}
|
||||
|
||||
block gen_function(const char* name, block formals, block body) {
|
||||
@@ -595,10 +592,6 @@ block gen_const_object(block expr) {
|
||||
is_const = 0;
|
||||
break;
|
||||
}
|
||||
if (jv_get_kind(k) != JV_KIND_STRING) {
|
||||
is_const = 0;
|
||||
break;
|
||||
}
|
||||
o = jv_object_set(o, k, v);
|
||||
k = jv_null();
|
||||
v = jv_null();
|
||||
@@ -704,27 +697,12 @@ static block bind_matcher(block matcher, block body) {
|
||||
|
||||
block gen_reduce(block source, block matcher, block init, block body) {
|
||||
block res_var = gen_op_var_fresh(STOREV, "reduce");
|
||||
block update_var = gen_op_bound(STOREV, res_var);
|
||||
block jmp = gen_op_target(JUMP, body);
|
||||
block loop = BLOCK(gen_op_simple(DUPN),
|
||||
source,
|
||||
bind_matcher(matcher,
|
||||
BLOCK(gen_op_bound(LOADVN, res_var),
|
||||
/*
|
||||
* We fork to the body, jump to
|
||||
* the STOREV. This means that
|
||||
* if body produces no results
|
||||
* (i.e., it just does empty)
|
||||
* then we keep the current
|
||||
* reduction state as-is.
|
||||
*
|
||||
* To break out of a
|
||||
* reduction... use break.
|
||||
*/
|
||||
gen_op_target(FORK, jmp),
|
||||
jmp,
|
||||
body,
|
||||
update_var)),
|
||||
gen_op_bound(STOREV, res_var))),
|
||||
gen_op_simple(BACKTRACK));
|
||||
return BLOCK(gen_op_simple(DUP),
|
||||
init,
|
||||
@@ -32,8 +32,7 @@ block gen_op_var_fresh(opcode op, const char* name);
|
||||
|
||||
block gen_module(block metadata);
|
||||
jv block_module_meta(block b);
|
||||
block gen_import(const char* name, const char *as, int is_data);
|
||||
block gen_import_meta(block import, block metadata);
|
||||
block gen_import(const char* name, block metadata, const char *as, int is_data);
|
||||
block gen_function(const char* name, block formals, block body);
|
||||
block gen_param_regular(const char* name);
|
||||
block gen_param(const char* name);
|
||||
Executable
+270
@@ -0,0 +1,270 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for Microsoft lib.exe
|
||||
|
||||
me=ar-lib
|
||||
scriptversion=2012-03-01.08; # UTC
|
||||
|
||||
# Copyright (C) 2010-2013 Free Software Foundation, Inc.
|
||||
# Written by Peter Rosin <peda@lysator.liu.se>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
|
||||
# func_error message
|
||||
func_error ()
|
||||
{
|
||||
echo "$me: $1" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv in
|
||||
mingw)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_at_file at_file operation archive
|
||||
# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
|
||||
# for each of them.
|
||||
# When interpreting the content of the @FILE, do NOT use func_file_conv,
|
||||
# since the user would need to supply preconverted file names to
|
||||
# binutils ar, at least for MinGW.
|
||||
func_at_file ()
|
||||
{
|
||||
operation=$2
|
||||
archive=$3
|
||||
at_file_contents=`cat "$1"`
|
||||
eval set x "$at_file_contents"
|
||||
shift
|
||||
|
||||
for member
|
||||
do
|
||||
$AR -NOLOGO $operation:"$member" "$archive" || exit $?
|
||||
done
|
||||
}
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
func_error "no command. Try '$0 --help' for more information."
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<EOF
|
||||
Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
|
||||
|
||||
Members may be specified in a file named with @FILE.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "$me, version $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if test $# -lt 3; then
|
||||
func_error "you must specify a program, an action and an archive"
|
||||
fi
|
||||
|
||||
AR=$1
|
||||
shift
|
||||
while :
|
||||
do
|
||||
if test $# -lt 2; then
|
||||
func_error "you must specify a program, an action and an archive"
|
||||
fi
|
||||
case $1 in
|
||||
-lib | -LIB \
|
||||
| -ltcg | -LTCG \
|
||||
| -machine* | -MACHINE* \
|
||||
| -subsystem* | -SUBSYSTEM* \
|
||||
| -verbose | -VERBOSE \
|
||||
| -wx* | -WX* )
|
||||
AR="$AR $1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
action=$1
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
orig_archive=$1
|
||||
shift
|
||||
func_file_conv "$orig_archive"
|
||||
archive=$file
|
||||
|
||||
# strip leading dash in $action
|
||||
action=${action#-}
|
||||
|
||||
delete=
|
||||
extract=
|
||||
list=
|
||||
quick=
|
||||
replace=
|
||||
index=
|
||||
create=
|
||||
|
||||
while test -n "$action"
|
||||
do
|
||||
case $action in
|
||||
d*) delete=yes ;;
|
||||
x*) extract=yes ;;
|
||||
t*) list=yes ;;
|
||||
q*) quick=yes ;;
|
||||
r*) replace=yes ;;
|
||||
s*) index=yes ;;
|
||||
S*) ;; # the index is always updated implicitly
|
||||
c*) create=yes ;;
|
||||
u*) ;; # TODO: don't ignore the update modifier
|
||||
v*) ;; # TODO: don't ignore the verbose modifier
|
||||
*)
|
||||
func_error "unknown action specified"
|
||||
;;
|
||||
esac
|
||||
action=${action#?}
|
||||
done
|
||||
|
||||
case $delete$extract$list$quick$replace,$index in
|
||||
yes,* | ,yes)
|
||||
;;
|
||||
yesyes*)
|
||||
func_error "more than one action specified"
|
||||
;;
|
||||
*)
|
||||
func_error "no action specified"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -n "$delete"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_at_file "${1#@}" -REMOVE "$archive"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
$AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
elif test -n "$extract"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
if test $# -gt 0; then
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_at_file "${1#@}" -EXTRACT "$archive"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
$AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
$AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
|
||||
do
|
||||
$AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
|
||||
done
|
||||
fi
|
||||
|
||||
elif test -n "$quick$replace"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
if test -z "$create"; then
|
||||
echo "$me: creating $orig_archive"
|
||||
fi
|
||||
orig_archive=
|
||||
else
|
||||
orig_archive=$archive
|
||||
fi
|
||||
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_file_conv "${1#@}"
|
||||
set x "$@" "@$file"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
set x "$@" "$file"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
shift
|
||||
done
|
||||
|
||||
if test -n "$orig_archive"; then
|
||||
$AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
|
||||
else
|
||||
$AR -NOLOGO -OUT:"$archive" "$@" || exit $?
|
||||
fi
|
||||
|
||||
elif test -n "$list"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
$AR -NOLOGO -LIST "$archive" || exit $?
|
||||
fi
|
||||
Executable
+347
@@ -0,0 +1,347 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2012-10-14.11; # UTC
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/lib$lib.a"; then
|
||||
found=yes
|
||||
lib=$dir/lib$lib.a
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
+1558
File diff suppressed because it is too large.
Load diff
+1791
File diff suppressed because it is too large.
Load diff
Executable
+791
@@ -0,0 +1,791 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2013-05-30.07; # UTC
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by 'PROGRAMS ARGS'.
|
||||
object Object file output by 'PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputting dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get the directory component of the given path, and save it in the
|
||||
# global variables '$dir'. Note that this directory component will
|
||||
# be either empty or ending with a '/' character. This is deliberate.
|
||||
set_dir_from ()
|
||||
{
|
||||
case $1 in
|
||||
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
|
||||
*) dir=;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Get the suffix-stripped basename of the given path, and save it the
|
||||
# global variable '$base'.
|
||||
set_base_from ()
|
||||
{
|
||||
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
|
||||
}
|
||||
|
||||
# If no dependency file was actually created by the compiler invocation,
|
||||
# we still have to create a dummy depfile, to avoid errors with the
|
||||
# Makefile "include basename.Plo" scheme.
|
||||
make_dummy_depfile ()
|
||||
{
|
||||
echo "#dummy" > "$depfile"
|
||||
}
|
||||
|
||||
# Factor out some common post-processing of the generated depfile.
|
||||
# Requires the auxiliary global variable '$tmpdepfile' to be set.
|
||||
aix_post_process_depfile ()
|
||||
{
|
||||
# If the compiler actually managed to produce a dependency file,
|
||||
# post-process it.
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form 'foo.o: dependency.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# $object: dependency.h
|
||||
# and one to simply output
|
||||
# dependency.h:
|
||||
# which is needed to avoid the deleted-header problem.
|
||||
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
|
||||
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
|
||||
} > "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
}
|
||||
|
||||
# A tabulation character.
|
||||
tab=' '
|
||||
# A newline character.
|
||||
nl='
|
||||
'
|
||||
# Character ranges might be problematic outside the C locale.
|
||||
# These definitions help.
|
||||
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
lower=abcdefghijklmnopqrstuvwxyz
|
||||
digits=0123456789
|
||||
alpha=${upper}${lower}
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Avoid interferences from the environment.
|
||||
gccflag= dashmflag=
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
if test "$depmode" = msvc7msys; then
|
||||
# This is just like msvc7 but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvc7
|
||||
fi
|
||||
|
||||
if test "$depmode" = xlc; then
|
||||
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
|
||||
gccflag=-qmakedep=gcc,-MF
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
|
||||
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
|
||||
## (see the conditional assignment to $gccflag above).
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say). Also, it might not be
|
||||
## supported by the other compilers which use the 'gcc' depmode.
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The second -e expression handles DOS-style file names with drive
|
||||
# letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the "deleted header file" problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
## Some versions of gcc put a space before the ':'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well. hp depmode also adds that space, but also prefixes the VPATH
|
||||
## to the object. Take care to not repeat it in the output.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like '#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
|
||||
| tr "$nl" ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
xlc)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts '$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
tcc)
|
||||
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
|
||||
# FIXME: That version still under development at the moment of writing.
|
||||
# Make that this statement remains true also for stable, released
|
||||
# versions.
|
||||
# It will wrap lines (doesn't matter whether long or short) with a
|
||||
# trailing '\', as in:
|
||||
#
|
||||
# foo.o : \
|
||||
# foo.c \
|
||||
# foo.h \
|
||||
#
|
||||
# It will put a trailing '\' even on the last line, and will use leading
|
||||
# spaces rather than leading tabs (at least since its commit 0394caf7
|
||||
# "Emit spaces for -MD").
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
|
||||
# We have to change lines of the first kind to '$object: \'.
|
||||
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
|
||||
# And for each line of the second kind, we have to emit a 'dep.h:'
|
||||
# dummy dependency, to avoid the deleted-header problem.
|
||||
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
## The order of this option in the case statement is important, since the
|
||||
## shell code in configure will try each of these formats in the order
|
||||
## listed in this file. A plain '-MD' option would be understood by many
|
||||
## compilers, so we must ensure this comes after the gcc and icc options.
|
||||
pgcc)
|
||||
# Portland's C compiler understands '-MD'.
|
||||
# Will always output deps to 'file.d' where file is the root name of the
|
||||
# source file under compilation, even if file resides in a subdirectory.
|
||||
# The object file name does not affect the name of the '.d' file.
|
||||
# pgcc 10.2 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using '\' :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
set_dir_from "$object"
|
||||
# Use the source, not the object, to determine the base name, since
|
||||
# that's sadly what pgcc will do too.
|
||||
set_base_from "$source"
|
||||
tmpdepfile=$base.d
|
||||
|
||||
# For projects that build the same source file twice into different object
|
||||
# files, the pgcc approach of using the *source* file root name can cause
|
||||
# problems in parallel builds. Use a locking strategy to avoid stomping on
|
||||
# the same $tmpdepfile.
|
||||
lockdir=$base.d-lock
|
||||
trap "
|
||||
echo '$0: caught signal, cleaning up...' >&2
|
||||
rmdir '$lockdir'
|
||||
exit 1
|
||||
" 1 2 13 15
|
||||
numtries=100
|
||||
i=$numtries
|
||||
while test $i -gt 0; do
|
||||
# mkdir is a portable test-and-set.
|
||||
if mkdir "$lockdir" 2>/dev/null; then
|
||||
# This process acquired the lock.
|
||||
"$@" -MD
|
||||
stat=$?
|
||||
# Release the lock.
|
||||
rmdir "$lockdir"
|
||||
break
|
||||
else
|
||||
# If the lock is being held by a different process, wait
|
||||
# until the winning process is done or we timeout.
|
||||
while test -d "$lockdir" && test $i -gt 0; do
|
||||
sleep 1
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
fi
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
trap - 1 2 13 15
|
||||
if test $i -le 0; then
|
||||
echo "$0: failed to acquire lock after $numtries attempts" >&2
|
||||
echo "$0: check lockdir '$lockdir'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add 'dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in 'foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# Libtool generates 2 separate objects for the 2 libraries. These
|
||||
# two compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
|
||||
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
# Same post-processing that is required for AIX mode.
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
msvc7)
|
||||
if test "$libtool" = yes; then
|
||||
showIncludes=-Wc,-showIncludes
|
||||
else
|
||||
showIncludes=-showIncludes
|
||||
fi
|
||||
"$@" $showIncludes > "$tmpdepfile"
|
||||
stat=$?
|
||||
grep -v '^Note: including file: ' "$tmpdepfile"
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The first sed program below extracts the file names and escapes
|
||||
# backslashes for cygpath. The second sed program outputs the file
|
||||
# name when reading, but also accumulates all include files in the
|
||||
# hold buffer in order to output them again at the end. This only
|
||||
# works with sed implementations that can handle large buffers.
|
||||
sed < "$tmpdepfile" -n '
|
||||
/^Note: including file: *\(.*\)/ {
|
||||
s//\1/
|
||||
s/\\/\\\\/g
|
||||
p
|
||||
}' | $cygpath_u | sort -u | sed -n '
|
||||
s/ /\\ /g
|
||||
s/\(.*\)/'"$tab"'\1 \\/p
|
||||
s/.\(.*\) \\/\1:/
|
||||
H
|
||||
$ {
|
||||
s/.*/'"$tab"'/
|
||||
G
|
||||
p
|
||||
}' >> "$depfile"
|
||||
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvc7msys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for ':'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this sed invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
# makedepend may prepend the VPATH from the source file name to the object.
|
||||
# No need to regex-escape $object, excess matching of '.' is harmless.
|
||||
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process the last invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed '1,2d' "$tmpdepfile" \
|
||||
| tr ' ' "$nl" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E \
|
||||
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
| sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
|
||||
echo "$tab" >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
Executable
+527
@@ -0,0 +1,527 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2011-11-20.07; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# 'make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit=${DOITPROG-}
|
||||
if test -z "$doit"; then
|
||||
doit_exec=exec
|
||||
else
|
||||
doit_exec=$doit
|
||||
fi
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_glob='?'
|
||||
initialize_posix_glob='
|
||||
test "$posix_glob" != "?" || {
|
||||
if (set -f) 2>/dev/null; then
|
||||
posix_glob=
|
||||
else
|
||||
posix_glob=:
|
||||
fi
|
||||
}
|
||||
'
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
no_target_directory=
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve the last data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *' '* | *'
|
||||
'* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-t) dst_arg=$2
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-T) no_target_directory=true;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call 'install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $src in
|
||||
-* | [=\(\)!]) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst_arg
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||
dstdir=`
|
||||
(dirname "$dst") 2>/dev/null ||
|
||||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$dst" : 'X\(//\)[^/]' \| \
|
||||
X"$dst" : 'X\(//\)$' \| \
|
||||
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$dst" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'
|
||||
`
|
||||
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
[-=\(\)!]*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
eval "$initialize_posix_glob"
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
$posix_glob set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
$posix_glob set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test X"$d" = X && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
|
||||
eval "$initialize_posix_glob" &&
|
||||
$posix_glob set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
$posix_glob set +f &&
|
||||
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
+9661
File diff suppressed because it is too large.
Load diff
Vendored
+7997
File diff suppressed because it is too large.
Load diff
Vendored
+384
@@ -0,0 +1,384 @@
|
||||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
#
|
||||
# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# Written by Gary V. Vaughan, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 7 ltoptions.m4
|
||||
|
||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
|
||||
|
||||
|
||||
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
|
||||
# ------------------------------------------
|
||||
m4_define([_LT_MANGLE_OPTION],
|
||||
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
|
||||
|
||||
|
||||
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
|
||||
# ---------------------------------------
|
||||
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
|
||||
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
|
||||
# saved as a flag.
|
||||
m4_define([_LT_SET_OPTION],
|
||||
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
|
||||
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
|
||||
_LT_MANGLE_DEFUN([$1], [$2]),
|
||||
[m4_warning([Unknown $1 option `$2'])])[]dnl
|
||||
])
|
||||
|
||||
|
||||
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
|
||||
# ------------------------------------------------------------
|
||||
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
|
||||
m4_define([_LT_IF_OPTION],
|
||||
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
|
||||
|
||||
|
||||
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
|
||||
# -------------------------------------------------------
|
||||
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
|
||||
# are set.
|
||||
m4_define([_LT_UNLESS_OPTIONS],
|
||||
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
|
||||
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
|
||||
[m4_define([$0_found])])])[]dnl
|
||||
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
|
||||
])[]dnl
|
||||
])
|
||||
|
||||
|
||||
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
|
||||
# ----------------------------------------
|
||||
# OPTION-LIST is a space-separated list of Libtool options associated
|
||||
# with MACRO-NAME. If any OPTION has a matching handler declared with
|
||||
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
|
||||
# the unknown option and exit.
|
||||
m4_defun([_LT_SET_OPTIONS],
|
||||
[# Set options
|
||||
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
|
||||
[_LT_SET_OPTION([$1], _LT_Option)])
|
||||
|
||||
m4_if([$1],[LT_INIT],[
|
||||
dnl
|
||||
dnl Simply set some default values (i.e off) if boolean options were not
|
||||
dnl specified:
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
|
||||
])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
|
||||
])
|
||||
dnl
|
||||
dnl If no reference was made to various pairs of opposing options, then
|
||||
dnl we run the default mode handler for the pair. For example, if neither
|
||||
dnl `shared' nor `disable-shared' was passed, we enable building of shared
|
||||
dnl archives by default:
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
|
||||
[_LT_ENABLE_FAST_INSTALL])
|
||||
])
|
||||
])# _LT_SET_OPTIONS
|
||||
|
||||
|
||||
## --------------------------------- ##
|
||||
## Macros to handle LT_INIT options. ##
|
||||
## --------------------------------- ##
|
||||
|
||||
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
|
||||
# -----------------------------------------
|
||||
m4_define([_LT_MANGLE_DEFUN],
|
||||
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
|
||||
|
||||
|
||||
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
|
||||
# -----------------------------------------------
|
||||
m4_define([LT_OPTION_DEFINE],
|
||||
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
|
||||
])# LT_OPTION_DEFINE
|
||||
|
||||
|
||||
# dlopen
|
||||
# ------
|
||||
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
|
||||
])
|
||||
|
||||
AU_DEFUN([AC_LIBTOOL_DLOPEN],
|
||||
[_LT_SET_OPTION([LT_INIT], [dlopen])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the `dlopen' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
|
||||
|
||||
|
||||
# win32-dll
|
||||
# ---------
|
||||
# Declare package support for building win32 dll's.
|
||||
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
|
||||
[enable_win32_dll=yes
|
||||
|
||||
case $host in
|
||||
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
|
||||
AC_CHECK_TOOL(AS, as, false)
|
||||
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
|
||||
AC_CHECK_TOOL(OBJDUMP, objdump, false)
|
||||
;;
|
||||
esac
|
||||
|
||||
test -z "$AS" && AS=as
|
||||
_LT_DECL([], [AS], [1], [Assembler program])dnl
|
||||
|
||||
test -z "$DLLTOOL" && DLLTOOL=dlltool
|
||||
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
|
||||
|
||||
test -z "$OBJDUMP" && OBJDUMP=objdump
|
||||
_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
|
||||
])# win32-dll
|
||||
|
||||
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||
_LT_SET_OPTION([LT_INIT], [win32-dll])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the `win32-dll' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
|
||||
|
||||
|
||||
# _LT_ENABLE_SHARED([DEFAULT])
|
||||
# ----------------------------
|
||||
# implement the --enable-shared flag, and supports the `shared' and
|
||||
# `disable-shared' LT_INIT options.
|
||||
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||
m4_define([_LT_ENABLE_SHARED],
|
||||
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([shared],
|
||||
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
|
||||
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
|
||||
[p=${PACKAGE-default}
|
||||
case $enableval in
|
||||
yes) enable_shared=yes ;;
|
||||
no) enable_shared=no ;;
|
||||
*)
|
||||
enable_shared=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||
for pkg in $enableval; do
|
||||
IFS="$lt_save_ifs"
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_shared=yes
|
||||
fi
|
||||
done
|
||||
IFS="$lt_save_ifs"
|
||||
;;
|
||||
esac],
|
||||
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
|
||||
|
||||
_LT_DECL([build_libtool_libs], [enable_shared], [0],
|
||||
[Whether or not to build shared libraries])
|
||||
])# _LT_ENABLE_SHARED
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
|
||||
|
||||
# Old names:
|
||||
AC_DEFUN([AC_ENABLE_SHARED],
|
||||
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_DISABLE_SHARED],
|
||||
[_LT_SET_OPTION([LT_INIT], [disable-shared])
|
||||
])
|
||||
|
||||
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
|
||||
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
|
||||
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
|
||||
|
||||
|
||||
|
||||
# _LT_ENABLE_STATIC([DEFAULT])
|
||||
# ----------------------------
|
||||
# implement the --enable-static flag, and support the `static' and
|
||||
# `disable-static' LT_INIT options.
|
||||
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||
m4_define([_LT_ENABLE_STATIC],
|
||||
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([static],
|
||||
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
|
||||
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
|
||||
[p=${PACKAGE-default}
|
||||
case $enableval in
|
||||
yes) enable_static=yes ;;
|
||||
no) enable_static=no ;;
|
||||
*)
|
||||
enable_static=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||
for pkg in $enableval; do
|
||||
IFS="$lt_save_ifs"
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_static=yes
|
||||
fi
|
||||
done
|
||||
IFS="$lt_save_ifs"
|
||||
;;
|
||||
esac],
|
||||
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
|
||||
|
||||
_LT_DECL([build_old_libs], [enable_static], [0],
|
||||
[Whether or not to build static libraries])
|
||||
])# _LT_ENABLE_STATIC
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
|
||||
|
||||
# Old names:
|
||||
AC_DEFUN([AC_ENABLE_STATIC],
|
||||
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_DISABLE_STATIC],
|
||||
[_LT_SET_OPTION([LT_INIT], [disable-static])
|
||||
])
|
||||
|
||||
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
|
||||
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
|
||||
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
|
||||
|
||||
|
||||
|
||||
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
|
||||
# ----------------------------------
|
||||
# implement the --enable-fast-install flag, and support the `fast-install'
|
||||
# and `disable-fast-install' LT_INIT options.
|
||||
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||
m4_define([_LT_ENABLE_FAST_INSTALL],
|
||||
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([fast-install],
|
||||
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
|
||||
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
|
||||
[p=${PACKAGE-default}
|
||||
case $enableval in
|
||||
yes) enable_fast_install=yes ;;
|
||||
no) enable_fast_install=no ;;
|
||||
*)
|
||||
enable_fast_install=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||
for pkg in $enableval; do
|
||||
IFS="$lt_save_ifs"
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_fast_install=yes
|
||||
fi
|
||||
done
|
||||
IFS="$lt_save_ifs"
|
||||
;;
|
||||
esac],
|
||||
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
|
||||
|
||||
_LT_DECL([fast_install], [enable_fast_install], [0],
|
||||
[Whether or not to optimize for fast installation])dnl
|
||||
])# _LT_ENABLE_FAST_INSTALL
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
|
||||
|
||||
# Old names:
|
||||
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
|
||||
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||
the `fast-install' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
|
||||
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||
the `disable-fast-install' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
|
||||
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
|
||||
|
||||
|
||||
# _LT_WITH_PIC([MODE])
|
||||
# --------------------
|
||||
# implement the --with-pic flag, and support the `pic-only' and `no-pic'
|
||||
# LT_INIT options.
|
||||
# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
|
||||
m4_define([_LT_WITH_PIC],
|
||||
[AC_ARG_WITH([pic],
|
||||
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
|
||||
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
|
||||
[lt_p=${PACKAGE-default}
|
||||
case $withval in
|
||||
yes|no) pic_mode=$withval ;;
|
||||
*)
|
||||
pic_mode=default
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||
for lt_pkg in $withval; do
|
||||
IFS="$lt_save_ifs"
|
||||
if test "X$lt_pkg" = "X$lt_p"; then
|
||||
pic_mode=yes
|
||||
fi
|
||||
done
|
||||
IFS="$lt_save_ifs"
|
||||
;;
|
||||
esac],
|
||||
[pic_mode=default])
|
||||
|
||||
test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
|
||||
|
||||
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
|
||||
])# _LT_WITH_PIC
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
|
||||
|
||||
# Old name:
|
||||
AU_DEFUN([AC_LIBTOOL_PICMODE],
|
||||
[_LT_SET_OPTION([LT_INIT], [pic-only])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the `pic-only' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
|
||||
|
||||
## ----------------- ##
|
||||
## LTDL_INIT Options ##
|
||||
## ----------------- ##
|
||||
|
||||
m4_define([_LTDL_MODE], [])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
|
||||
[m4_define([_LTDL_MODE], [nonrecursive])])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
|
||||
[m4_define([_LTDL_MODE], [recursive])])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
|
||||
[m4_define([_LTDL_MODE], [subproject])])
|
||||
|
||||
m4_define([_LTDL_TYPE], [])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [installable],
|
||||
[m4_define([_LTDL_TYPE], [installable])])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
|
||||
[m4_define([_LTDL_TYPE], [convenience])])
|
||||
Vendored
+123
@@ -0,0 +1,123 @@
|
||||
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
|
||||
# Written by Gary V. Vaughan, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 6 ltsugar.m4
|
||||
|
||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
|
||||
|
||||
|
||||
# lt_join(SEP, ARG1, [ARG2...])
|
||||
# -----------------------------
|
||||
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
|
||||
# associated separator.
|
||||
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
|
||||
# versions in m4sugar had bugs.
|
||||
m4_define([lt_join],
|
||||
[m4_if([$#], [1], [],
|
||||
[$#], [2], [[$2]],
|
||||
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
|
||||
m4_define([_lt_join],
|
||||
[m4_if([$#$2], [2], [],
|
||||
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
|
||||
|
||||
|
||||
# lt_car(LIST)
|
||||
# lt_cdr(LIST)
|
||||
# ------------
|
||||
# Manipulate m4 lists.
|
||||
# These macros are necessary as long as will still need to support
|
||||
# Autoconf-2.59 which quotes differently.
|
||||
m4_define([lt_car], [[$1]])
|
||||
m4_define([lt_cdr],
|
||||
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
|
||||
[$#], 1, [],
|
||||
[m4_dquote(m4_shift($@))])])
|
||||
m4_define([lt_unquote], $1)
|
||||
|
||||
|
||||
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
|
||||
# ------------------------------------------
|
||||
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
|
||||
# Note that neither SEPARATOR nor STRING are expanded; they are appended
|
||||
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
|
||||
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
|
||||
# than defined and empty).
|
||||
#
|
||||
# This macro is needed until we can rely on Autoconf 2.62, since earlier
|
||||
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
|
||||
m4_define([lt_append],
|
||||
[m4_define([$1],
|
||||
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
|
||||
|
||||
|
||||
|
||||
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
|
||||
# ----------------------------------------------------------
|
||||
# Produce a SEP delimited list of all paired combinations of elements of
|
||||
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
|
||||
# has the form PREFIXmINFIXSUFFIXn.
|
||||
# Needed until we can rely on m4_combine added in Autoconf 2.62.
|
||||
m4_define([lt_combine],
|
||||
[m4_if(m4_eval([$# > 3]), [1],
|
||||
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
|
||||
[[m4_foreach([_Lt_prefix], [$2],
|
||||
[m4_foreach([_Lt_suffix],
|
||||
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
|
||||
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
|
||||
|
||||
|
||||
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
|
||||
# -----------------------------------------------------------------------
|
||||
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
|
||||
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
|
||||
m4_define([lt_if_append_uniq],
|
||||
[m4_ifdef([$1],
|
||||
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
|
||||
[lt_append([$1], [$2], [$3])$4],
|
||||
[$5])],
|
||||
[lt_append([$1], [$2], [$3])$4])])
|
||||
|
||||
|
||||
# lt_dict_add(DICT, KEY, VALUE)
|
||||
# -----------------------------
|
||||
m4_define([lt_dict_add],
|
||||
[m4_define([$1($2)], [$3])])
|
||||
|
||||
|
||||
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
|
||||
# --------------------------------------------
|
||||
m4_define([lt_dict_add_subkey],
|
||||
[m4_define([$1($2:$3)], [$4])])
|
||||
|
||||
|
||||
# lt_dict_fetch(DICT, KEY, [SUBKEY])
|
||||
# ----------------------------------
|
||||
m4_define([lt_dict_fetch],
|
||||
[m4_ifval([$3],
|
||||
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
|
||||
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
|
||||
|
||||
|
||||
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
|
||||
# -----------------------------------------------------------------
|
||||
m4_define([lt_if_dict_fetch],
|
||||
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
|
||||
[$5],
|
||||
[$6])])
|
||||
|
||||
|
||||
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
|
||||
# --------------------------------------------------------------
|
||||
m4_define([lt_dict_filter],
|
||||
[m4_if([$5], [], [],
|
||||
[lt_join(m4_quote(m4_default([$4], [[, ]])),
|
||||
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
|
||||
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
|
||||
])
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
# ltversion.m4 -- version numbers -*- Autoconf -*-
|
||||
#
|
||||
# Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
# Written by Scott James Remnant, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# @configure_input@
|
||||
|
||||
# serial 3337 ltversion.m4
|
||||
# This file is part of GNU Libtool
|
||||
|
||||
m4_define([LT_PACKAGE_VERSION], [2.4.2])
|
||||
m4_define([LT_PACKAGE_REVISION], [1.3337])
|
||||
|
||||
AC_DEFUN([LTVERSION_VERSION],
|
||||
[macro_version='2.4.2'
|
||||
macro_revision='1.3337'
|
||||
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
|
||||
_LT_DECL(, macro_revision, 0)
|
||||
])
|
||||
Vendored
+98
@@ -0,0 +1,98 @@
|
||||
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
|
||||
# Written by Scott James Remnant, 2004.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 5 lt~obsolete.m4
|
||||
|
||||
# These exist entirely to fool aclocal when bootstrapping libtool.
|
||||
#
|
||||
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
|
||||
# which have later been changed to m4_define as they aren't part of the
|
||||
# exported API, or moved to Autoconf or Automake where they belong.
|
||||
#
|
||||
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
|
||||
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
|
||||
# using a macro with the same name in our local m4/libtool.m4 it'll
|
||||
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
|
||||
# and doesn't know about Autoconf macros at all.)
|
||||
#
|
||||
# So we provide this file, which has a silly filename so it's always
|
||||
# included after everything else. This provides aclocal with the
|
||||
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
|
||||
# because those macros already exist, or will be overwritten later.
|
||||
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
|
||||
#
|
||||
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
|
||||
# Yes, that means every name once taken will need to remain here until
|
||||
# we give up compatibility with versions before 1.7, at which point
|
||||
# we need to keep only those names which we still refer to.
|
||||
|
||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
|
||||
|
||||
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
|
||||
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
|
||||
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
|
||||
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
|
||||
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
|
||||
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
|
||||
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
|
||||
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
|
||||
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
|
||||
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
|
||||
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
|
||||
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
|
||||
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
|
||||
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
|
||||
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
|
||||
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
|
||||
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
|
||||
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
|
||||
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
|
||||
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
|
||||
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
|
||||
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
|
||||
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
|
||||
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
|
||||
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
|
||||
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
|
||||
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
|
||||
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
|
||||
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
|
||||
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
|
||||
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
|
||||
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
|
||||
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
|
||||
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
|
||||
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
|
||||
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
|
||||
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
|
||||
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
|
||||
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
|
||||
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
|
||||
Executable
+215
@@ -0,0 +1,215 @@
|
||||
#! /bin/sh
|
||||
# Common wrapper for a few potentially missing GNU programs.
|
||||
|
||||
scriptversion=2013-10-28.13; # UTC
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try '$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
|
||||
--is-lightweight)
|
||||
# Used by our autoconf macros to check whether the available missing
|
||||
# script is modern enough.
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--run)
|
||||
# Back-compat with the calling convention used by older automake.
|
||||
shift
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
|
||||
to PROGRAM being missing or too old.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal autoconf autoheader autom4te automake makeinfo
|
||||
bison yacc flex lex help2man
|
||||
|
||||
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
|
||||
'g' are ignored when checking the name.
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: unknown '$1' option"
|
||||
echo 1>&2 "Try '$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# Run the given program, remember its exit status.
|
||||
"$@"; st=$?
|
||||
|
||||
# If it succeeded, we are done.
|
||||
test $st -eq 0 && exit 0
|
||||
|
||||
# Also exit now if we it failed (or wasn't found), and '--version' was
|
||||
# passed; such an option is passed most likely to detect whether the
|
||||
# program is present and works.
|
||||
case $2 in --version|--help) exit $st;; esac
|
||||
|
||||
# Exit code 63 means version mismatch. This often happens when the user
|
||||
# tries to use an ancient version of a tool on a file that requires a
|
||||
# minimum version.
|
||||
if test $st -eq 63; then
|
||||
msg="probably too old"
|
||||
elif test $st -eq 127; then
|
||||
# Program was missing.
|
||||
msg="missing on your system"
|
||||
else
|
||||
# Program was found and executed, but failed. Give up.
|
||||
exit $st
|
||||
fi
|
||||
|
||||
perl_URL=http://www.perl.org/
|
||||
flex_URL=http://flex.sourceforge.net/
|
||||
gnu_software_URL=http://www.gnu.org/software
|
||||
|
||||
program_details ()
|
||||
{
|
||||
case $1 in
|
||||
aclocal|automake)
|
||||
echo "The '$1' program is part of the GNU Automake package:"
|
||||
echo "<$gnu_software_URL/automake>"
|
||||
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
|
||||
echo "<$gnu_software_URL/autoconf>"
|
||||
echo "<$gnu_software_URL/m4/>"
|
||||
echo "<$perl_URL>"
|
||||
;;
|
||||
autoconf|autom4te|autoheader)
|
||||
echo "The '$1' program is part of the GNU Autoconf package:"
|
||||
echo "<$gnu_software_URL/autoconf/>"
|
||||
echo "It also requires GNU m4 and Perl in order to run:"
|
||||
echo "<$gnu_software_URL/m4/>"
|
||||
echo "<$perl_URL>"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
give_advice ()
|
||||
{
|
||||
# Normalize program name to check for.
|
||||
normalized_program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
printf '%s\n' "'$1' is $msg."
|
||||
|
||||
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
|
||||
case $normalized_program in
|
||||
autoconf*)
|
||||
echo "You should only need it if you modified 'configure.ac',"
|
||||
echo "or m4 files included by it."
|
||||
program_details 'autoconf'
|
||||
;;
|
||||
autoheader*)
|
||||
echo "You should only need it if you modified 'acconfig.h' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'autoheader'
|
||||
;;
|
||||
automake*)
|
||||
echo "You should only need it if you modified 'Makefile.am' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'automake'
|
||||
;;
|
||||
aclocal*)
|
||||
echo "You should only need it if you modified 'acinclude.m4' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'aclocal'
|
||||
;;
|
||||
autom4te*)
|
||||
echo "You might have modified some maintainer files that require"
|
||||
echo "the 'autom4te' program to be rebuilt."
|
||||
program_details 'autom4te'
|
||||
;;
|
||||
bison*|yacc*)
|
||||
echo "You should only need it if you modified a '.y' file."
|
||||
echo "You may want to install the GNU Bison package:"
|
||||
echo "<$gnu_software_URL/bison/>"
|
||||
;;
|
||||
lex*|flex*)
|
||||
echo "You should only need it if you modified a '.l' file."
|
||||
echo "You may want to install the Fast Lexical Analyzer package:"
|
||||
echo "<$flex_URL>"
|
||||
;;
|
||||
help2man*)
|
||||
echo "You should only need it if you modified a dependency" \
|
||||
"of a man page."
|
||||
echo "You may want to install the GNU Help2man package:"
|
||||
echo "<$gnu_software_URL/help2man/>"
|
||||
;;
|
||||
makeinfo*)
|
||||
echo "You should only need it if you modified a '.texi' file, or"
|
||||
echo "any other file indirectly affecting the aspect of the manual."
|
||||
echo "You might want to install the Texinfo package:"
|
||||
echo "<$gnu_software_URL/texinfo/>"
|
||||
echo "The spurious makeinfo call might also be the consequence of"
|
||||
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
|
||||
echo "want to install GNU make:"
|
||||
echo "<$gnu_software_URL/make/>"
|
||||
;;
|
||||
*)
|
||||
echo "You might have modified some files without having the proper"
|
||||
echo "tools for further handling them. Check the 'README' file, it"
|
||||
echo "often tells you about the needed prerequisites for installing"
|
||||
echo "this package. You may also peek at any GNU archive site, in"
|
||||
echo "case some other package contains this missing '$1' program."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
give_advice "$1" | sed -e '1s/^/WARNING: /' \
|
||||
-e '2,$s/^/ /' >&2
|
||||
|
||||
# Propagate the correct exit status (expected to be 127 for a program
|
||||
# not found, 63 for a program that failed due to version mismatch).
|
||||
exit $st
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
Executable
+139
@@ -0,0 +1,139 @@
|
||||
#! /bin/sh
|
||||
# test-driver - basic testsuite driver script.
|
||||
|
||||
scriptversion=2013-07-13.22; # UTC
|
||||
|
||||
# Copyright (C) 2011-2013 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
# Make unconditional expansion of undefined variables an error. This
|
||||
# helps a lot in preventing typo-related bugs.
|
||||
set -u
|
||||
|
||||
usage_error ()
|
||||
{
|
||||
echo "$0: $*" >&2
|
||||
print_usage >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
print_usage ()
|
||||
{
|
||||
cat <<END
|
||||
Usage:
|
||||
test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
|
||||
[--expect-failure={yes|no}] [--color-tests={yes|no}]
|
||||
[--enable-hard-errors={yes|no}] [--]
|
||||
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
|
||||
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
|
||||
END
|
||||
}
|
||||
|
||||
test_name= # Used for reporting.
|
||||
log_file= # Where to save the output of the test script.
|
||||
trs_file= # Where to save the metadata of the test run.
|
||||
expect_failure=no
|
||||
color_tests=no
|
||||
enable_hard_errors=yes
|
||||
while test $# -gt 0; do
|
||||
case $1 in
|
||||
--help) print_usage; exit $?;;
|
||||
--version) echo "test-driver $scriptversion"; exit $?;;
|
||||
--test-name) test_name=$2; shift;;
|
||||
--log-file) log_file=$2; shift;;
|
||||
--trs-file) trs_file=$2; shift;;
|
||||
--color-tests) color_tests=$2; shift;;
|
||||
--expect-failure) expect_failure=$2; shift;;
|
||||
--enable-hard-errors) enable_hard_errors=$2; shift;;
|
||||
--) shift; break;;
|
||||
-*) usage_error "invalid option: '$1'";;
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
missing_opts=
|
||||
test x"$test_name" = x && missing_opts="$missing_opts --test-name"
|
||||
test x"$log_file" = x && missing_opts="$missing_opts --log-file"
|
||||
test x"$trs_file" = x && missing_opts="$missing_opts --trs-file"
|
||||
if test x"$missing_opts" != x; then
|
||||
usage_error "the following mandatory options are missing:$missing_opts"
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
usage_error "missing argument"
|
||||
fi
|
||||
|
||||
if test $color_tests = yes; then
|
||||
# Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
|
||||
red='[0;31m' # Red.
|
||||
grn='[0;32m' # Green.
|
||||
lgn='[1;32m' # Light green.
|
||||
blu='[1;34m' # Blue.
|
||||
mgn='[0;35m' # Magenta.
|
||||
std='[m' # No color.
|
||||
else
|
||||
red= grn= lgn= blu= mgn= std=
|
||||
fi
|
||||
|
||||
do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
|
||||
trap "st=129; $do_exit" 1
|
||||
trap "st=130; $do_exit" 2
|
||||
trap "st=141; $do_exit" 13
|
||||
trap "st=143; $do_exit" 15
|
||||
|
||||
# Test script is run here.
|
||||
"$@" >$log_file 2>&1
|
||||
estatus=$?
|
||||
if test $enable_hard_errors = no && test $estatus -eq 99; then
|
||||
estatus=1
|
||||
fi
|
||||
|
||||
case $estatus:$expect_failure in
|
||||
0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
|
||||
0:*) col=$grn res=PASS recheck=no gcopy=no;;
|
||||
77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
|
||||
99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
|
||||
*:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
|
||||
*:*) col=$red res=FAIL recheck=yes gcopy=yes;;
|
||||
esac
|
||||
|
||||
# Report outcome to console.
|
||||
echo "${col}${res}${std}: $test_name"
|
||||
|
||||
# Register the test result, and other relevant metadata.
|
||||
echo ":test-result: $res" > $trs_file
|
||||
echo ":global-test-result: $res" >> $trs_file
|
||||
echo ":recheck: $recheck" >> $trs_file
|
||||
echo ":copy-in-global-log: $gcopy" >> $trs_file
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
Executable
+247
@@ -0,0 +1,247 @@
|
||||
#! /bin/sh
|
||||
# ylwrap - wrapper for lex/yacc invocations.
|
||||
|
||||
scriptversion=2013-01-12.17; # UTC
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
get_dirname ()
|
||||
{
|
||||
case $1 in
|
||||
*/*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';;
|
||||
# Otherwise, we want the empty string (not ".").
|
||||
esac
|
||||
}
|
||||
|
||||
# guard FILE
|
||||
# ----------
|
||||
# The CPP macro used to guard inclusion of FILE.
|
||||
guard ()
|
||||
{
|
||||
printf '%s\n' "$1" \
|
||||
| sed \
|
||||
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
|
||||
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g' \
|
||||
-e 's/__*/_/g'
|
||||
}
|
||||
|
||||
# quote_for_sed [STRING]
|
||||
# ----------------------
|
||||
# Return STRING (or stdin) quoted to be used as a sed pattern.
|
||||
quote_for_sed ()
|
||||
{
|
||||
case $# in
|
||||
0) cat;;
|
||||
1) printf '%s\n' "$1";;
|
||||
esac \
|
||||
| sed -e 's|[][\\.*]|\\&|g'
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'')
|
||||
echo "$0: No files given. Try '$0 --help' for more information." 1>&2
|
||||
exit 1
|
||||
;;
|
||||
--basedir)
|
||||
basedir=$2
|
||||
shift 2
|
||||
;;
|
||||
-h|--h*)
|
||||
cat <<\EOF
|
||||
Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
|
||||
|
||||
Wrapper for lex/yacc invocations, renaming files as desired.
|
||||
|
||||
INPUT is the input file
|
||||
OUTPUT is one file PROG generates
|
||||
DESIRED is the file we actually want instead of OUTPUT
|
||||
PROGRAM is program to run
|
||||
ARGS are passed to PROG
|
||||
|
||||
Any number of OUTPUT,DESIRED pairs may be used.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v|--v*)
|
||||
echo "ylwrap $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# The input.
|
||||
input=$1
|
||||
shift
|
||||
# We'll later need for a correct munging of "#line" directives.
|
||||
input_sub_rx=`get_dirname "$input" | quote_for_sed`
|
||||
case $input in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
# Absolute path; do nothing.
|
||||
;;
|
||||
*)
|
||||
# Relative path. Make it absolute.
|
||||
input=`pwd`/$input
|
||||
;;
|
||||
esac
|
||||
input_rx=`get_dirname "$input" | quote_for_sed`
|
||||
|
||||
# Since DOS filename conventions don't allow two dots,
|
||||
# the DOS version of Bison writes out y_tab.c instead of y.tab.c
|
||||
# and y_tab.h instead of y.tab.h. Test to see if this is the case.
|
||||
y_tab_nodot=false
|
||||
if test -f y_tab.c || test -f y_tab.h; then
|
||||
y_tab_nodot=true
|
||||
fi
|
||||
|
||||
# The parser itself, the first file, is the destination of the .y.c
|
||||
# rule in the Makefile.
|
||||
parser=$1
|
||||
|
||||
# A sed program to s/FROM/TO/g for all the FROM/TO so that, for
|
||||
# instance, we rename #include "y.tab.h" into #include "parse.h"
|
||||
# during the conversion from y.tab.c to parse.c.
|
||||
sed_fix_filenames=
|
||||
|
||||
# Also rename header guards, as Bison 2.7 for instance uses its header
|
||||
# guard in its implementation file.
|
||||
sed_fix_header_guards=
|
||||
|
||||
while test $# -ne 0; do
|
||||
if test x"$1" = x"--"; then
|
||||
shift
|
||||
break
|
||||
fi
|
||||
from=$1
|
||||
# Handle y_tab.c and y_tab.h output by DOS
|
||||
if $y_tab_nodot; then
|
||||
case $from in
|
||||
"y.tab.c") from=y_tab.c;;
|
||||
"y.tab.h") from=y_tab.h;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
to=$1
|
||||
shift
|
||||
sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;"
|
||||
sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;"
|
||||
done
|
||||
|
||||
# The program to run.
|
||||
prog=$1
|
||||
shift
|
||||
# Make any relative path in $prog absolute.
|
||||
case $prog in
|
||||
[\\/]* | ?:[\\/]*) ;;
|
||||
*[\\/]*) prog=`pwd`/$prog ;;
|
||||
esac
|
||||
|
||||
dirname=ylwrap$$
|
||||
do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
mkdir $dirname || exit 1
|
||||
|
||||
cd $dirname
|
||||
|
||||
case $# in
|
||||
0) "$prog" "$input" ;;
|
||||
*) "$prog" "$@" "$input" ;;
|
||||
esac
|
||||
ret=$?
|
||||
|
||||
if test $ret -eq 0; then
|
||||
for from in *
|
||||
do
|
||||
to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"`
|
||||
if test -f "$from"; then
|
||||
# If $2 is an absolute path name, then just use that,
|
||||
# otherwise prepend '../'.
|
||||
case $to in
|
||||
[\\/]* | ?:[\\/]*) target=$to;;
|
||||
*) target=../$to;;
|
||||
esac
|
||||
|
||||
# Do not overwrite unchanged header files to avoid useless
|
||||
# recompilations. Always update the parser itself: it is the
|
||||
# destination of the .y.c rule in the Makefile. Divert the
|
||||
# output of all other files to a temporary file so we can
|
||||
# compare them to existing versions.
|
||||
if test $from != $parser; then
|
||||
realtarget=$target
|
||||
target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'`
|
||||
fi
|
||||
|
||||
# Munge "#line" or "#" directives. Don't let the resulting
|
||||
# debug information point at an absolute srcdir. Use the real
|
||||
# output file name, not yy.lex.c for instance. Adjust the
|
||||
# include guards too.
|
||||
sed -e "/^#/!b" \
|
||||
-e "s|$input_rx|$input_sub_rx|" \
|
||||
-e "$sed_fix_filenames" \
|
||||
-e "$sed_fix_header_guards" \
|
||||
"$from" >"$target" || ret=$?
|
||||
|
||||
# Check whether files must be updated.
|
||||
if test "$from" != "$parser"; then
|
||||
if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
|
||||
echo "$to is unchanged"
|
||||
rm -f "$target"
|
||||
else
|
||||
echo "updating $to"
|
||||
mv -f "$target" "$realtarget"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# A missing file is only an error for the parser. This is a
|
||||
# blatant hack to let us support using "yacc -d". If -d is not
|
||||
# specified, don't fail when the header file is "missing".
|
||||
if test "$from" = "$parser"; then
|
||||
ret=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Remove the directory.
|
||||
cd ..
|
||||
rm -rf $dirname
|
||||
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
File diff suppressed because it is too large.
Load diff
+28
-69
@@ -9,7 +9,7 @@ m4_include([m4/ax_prog_bison_version.m4])
|
||||
dnl Created autoconf implementation thompson@dtosolutions, 26NOV12
|
||||
AC_PREREQ([2.64])
|
||||
AC_CONFIG_AUX_DIR([config])
|
||||
AM_INIT_AUTOMAKE([1.11.2 subdir-objects parallel-tests foreign -Wall])
|
||||
AM_INIT_AUTOMAKE([1.11.2 parallel-tests foreign -Wall])
|
||||
AM_SILENT_RULES([yes])
|
||||
AM_PROG_AR
|
||||
AM_MAINTAINER_MODE([enable])
|
||||
@@ -52,26 +52,27 @@ fi
|
||||
AC_ARG_WITH([oniguruma],
|
||||
[AS_HELP_STRING([--with-oniguruma=prefix],
|
||||
[try this for a non-standard install prefix of the oniguruma library])],
|
||||
[],
|
||||
[with_oniguruma=yes])
|
||||
[ONIGURUMAPATHSET=1],
|
||||
[ONIGURUMAPATHSET=0])
|
||||
|
||||
if test $ONIGURUMAPATHSET = 1; then
|
||||
CFLAGS="$CFLAGS -I${with_oniguruma}/include"
|
||||
LDFLAGS="$LDFLAGS -L${with_oniguruma}/lib"
|
||||
fi
|
||||
|
||||
# check for ONIGURUMA library
|
||||
HAVE_ONIGURUMA=0
|
||||
AC_CHECK_HEADER("oniguruma.h",
|
||||
AC_CHECK_LIB([onig],[onig_version],[LIBS="$LIBS -lonig"; HAVE_ONIGURUMA=1;]))
|
||||
|
||||
# handle check results
|
||||
if test $HAVE_ONIGURUMA != 1; then
|
||||
AC_MSG_NOTICE([Oniguruma was not found.])
|
||||
AC_MSG_NOTICE([ Try setting the location using '--with-oniguruma=PREFIX' ])
|
||||
else
|
||||
AC_DEFINE([HAVE_ONIGURUMA],1,[Define to 1 if Oniguruma is installed])
|
||||
fi
|
||||
|
||||
AS_IF([test "x$with_oniguruma" != xno], [
|
||||
AS_IF([test "x$with_oniguruma" != xyes], [
|
||||
CFLAGS="$CFLAGS -I${with_oniguruma}/include"
|
||||
LDFLAGS="$LDFLAGS -L${with_oniguruma}/lib"
|
||||
])
|
||||
# check for ONIGURUMA library
|
||||
have_oniguruma=0
|
||||
AC_CHECK_HEADER("oniguruma.h",
|
||||
AC_CHECK_LIB([onig],[onig_version],[LIBS="$LIBS -lonig"; have_oniguruma=1;]))
|
||||
# handle check results
|
||||
AS_IF([test $have_oniguruma = 1], [
|
||||
AC_DEFINE([HAVE_ONIGURUMA], 1, [Define to 1 if Oniguruma is installed])
|
||||
], [
|
||||
AC_MSG_NOTICE([Oniguruma was not found.])
|
||||
AC_MSG_NOTICE([Try setting the location using '--with-oniguruma=PREFIX'])
|
||||
])
|
||||
])
|
||||
|
||||
dnl Check for valgrind
|
||||
AC_CHECK_PROGS(valgrind_cmd, valgrind)
|
||||
@@ -81,8 +82,6 @@ fi
|
||||
AC_CHECK_FUNCS(memmem)
|
||||
AC_CHECK_FUNCS(mkstemp)
|
||||
|
||||
AC_CHECK_HEADER("shlwapi.h",[have_win32=1;])
|
||||
AM_CONDITIONAL([WIN32], [test "x$have_win32" = x1])
|
||||
|
||||
dnl Running tests with Valgrind is slow. It is faster to iterate on
|
||||
dnl code without Valgrind until tests pass, then enable Valgrind and
|
||||
@@ -90,15 +89,6 @@ dnl fix leaks.
|
||||
AC_ARG_ENABLE([valgrind],
|
||||
AC_HELP_STRING([--disable-valgrind], [do not run tests under Valgrind]))
|
||||
|
||||
dnl Running tests with Valgrind is slow; address sanitizer (ASAN) is
|
||||
dnl faster.
|
||||
AC_ARG_ENABLE([asan],
|
||||
AC_HELP_STRING([--enable-asan], [enable address sanitizer]))
|
||||
|
||||
dnl Undefined Behavior Sanitizer
|
||||
AC_ARG_ENABLE([ubsan],
|
||||
AC_HELP_STRING([--enable-ubsan], [enable undefined behavior sanitizer]))
|
||||
|
||||
dnl Code coverage
|
||||
AC_ARG_ENABLE([gcov],
|
||||
AC_HELP_STRING([--enable-gcov], [enable gcov code coverage tool]))
|
||||
@@ -127,7 +117,7 @@ AS_IF([test "x$enable_docs" != "xno"],[
|
||||
*****************************************************************
|
||||
* Ruby dependencies for building jq documentation not found. *
|
||||
* You can still build, install and hack on jq, but the manpage *
|
||||
* will not be rebuilt and some of the tests will not run. *
|
||||
* will not be rebuilt and some of the tests won't run. *
|
||||
* See docs/README.md for how to install the docs dependencies. *
|
||||
*****************************************************************
|
||||
EOF
|
||||
@@ -140,8 +130,6 @@ EOF
|
||||
])
|
||||
|
||||
AM_CONDITIONAL([ENABLE_VALGRIND], [test "x$enable_valgrind" != xno])
|
||||
AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = xyes])
|
||||
AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = xyes])
|
||||
AM_CONDITIONAL([ENABLE_GCOV], [test "x$enable_gcov" = xyes])
|
||||
AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno])
|
||||
AM_CONDITIONAL([ENABLE_ERROR_INJECTION], [test "x$enable_error_injection" = xyes])
|
||||
@@ -179,61 +167,31 @@ AC_CHECK_MATH_FUNC(acos, [.5])
|
||||
AC_CHECK_MATH_FUNC(acosh, [.5])
|
||||
AC_CHECK_MATH_FUNC(asin, [.5])
|
||||
AC_CHECK_MATH_FUNC(asinh, [.5])
|
||||
AC_CHECK_MATH_FUNC(atan2, [.5,.5])
|
||||
AC_CHECK_MATH_FUNC(atan, [.5])
|
||||
AC_CHECK_MATH_FUNC(atanh, [.5])
|
||||
AC_CHECK_MATH_FUNC(cbrt, [.5])
|
||||
AC_CHECK_MATH_FUNC(ceil,[.5])
|
||||
AC_CHECK_MATH_FUNC(copysign,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(cos, [.5])
|
||||
AC_CHECK_MATH_FUNC(cosh, [.5])
|
||||
AC_CHECK_MATH_FUNC(drem,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(erf,[.5])
|
||||
AC_CHECK_MATH_FUNC(erfc,[.5])
|
||||
AC_CHECK_MATH_FUNC(exp10,[.5])
|
||||
AC_CHECK_MATH_FUNC(exp2, [.5])
|
||||
AC_CHECK_MATH_FUNC(exp, [.5])
|
||||
AC_CHECK_MATH_FUNC(expm1,[.5])
|
||||
AC_CHECK_MATH_FUNC(fabs,[.5])
|
||||
AC_CHECK_MATH_FUNC(fdim,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(floor, [.5])
|
||||
AC_CHECK_MATH_FUNC(fma,[.5,1.0,1.5])
|
||||
AC_CHECK_MATH_FUNC(fmax,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(fmin,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(fmod,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(frexp,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(gamma,[.5])
|
||||
AC_CHECK_MATH_FUNC(hypot, [.5,.5])
|
||||
AC_CHECK_MATH_FUNC(j0, [.5])
|
||||
AC_CHECK_MATH_FUNC(j1, [.5])
|
||||
AC_CHECK_MATH_FUNC(ldexp,[.5,2])
|
||||
AC_CHECK_MATH_FUNC(lgamma,[.5])
|
||||
AC_CHECK_MATH_FUNC(log10, [.5])
|
||||
AC_CHECK_MATH_FUNC(log1p,[.5])
|
||||
AC_CHECK_MATH_FUNC(log2, [.5])
|
||||
AC_CHECK_MATH_FUNC(log, [.5])
|
||||
AC_CHECK_MATH_FUNC(logb,[.5])
|
||||
AC_CHECK_MATH_FUNC(modf,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(nearbyint,[.5])
|
||||
AC_CHECK_MATH_FUNC(nextafter,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(nexttoward,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(pow10,[.5])
|
||||
AC_CHECK_MATH_FUNC(pow, [2,2])
|
||||
AC_CHECK_MATH_FUNC(remainder, [3,2])
|
||||
AC_CHECK_MATH_FUNC(rint,[.5])
|
||||
AC_CHECK_MATH_FUNC(round,[.5])
|
||||
AC_CHECK_MATH_FUNC(scalb,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(scalbln,[.5,2])
|
||||
AC_CHECK_MATH_FUNC(significand,[.5])
|
||||
AC_CHECK_MATH_FUNC(sin, [.5])
|
||||
AC_CHECK_MATH_FUNC(sinh, [.5])
|
||||
AC_CHECK_MATH_FUNC(sqrt, [.5])
|
||||
AC_CHECK_MATH_FUNC(tan, [.5])
|
||||
AC_CHECK_MATH_FUNC(tanh, [.5])
|
||||
AC_CHECK_MATH_FUNC(tgamma, [.5])
|
||||
AC_CHECK_MATH_FUNC(trunc,[.5])
|
||||
AC_CHECK_MATH_FUNC(y0, [.5])
|
||||
AC_CHECK_MATH_FUNC(y1, [.5])
|
||||
AC_CHECK_MATH_FUNC(pow, [2,2])
|
||||
AC_CHECK_MATH_FUNC(atan2, [.5,.5])
|
||||
AC_CHECK_MATH_FUNC(hypot, [.5,.5])
|
||||
AC_CHECK_MATH_FUNC(remainder, [3,2])
|
||||
|
||||
dnl Thread local storage
|
||||
have___thread=no
|
||||
@@ -242,7 +200,7 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([
|
||||
static __thread int x ;
|
||||
int main () { x = 123; return x; }
|
||||
])], have___thread=yes)
|
||||
if test $have___thread = yes; then
|
||||
if test $have___thread = yes; then
|
||||
AC_DEFINE([HAVE___THREAD],1,[Define to 1 if the system supports __thread])
|
||||
fi
|
||||
AC_MSG_RESULT($have___thread)
|
||||
@@ -260,3 +218,4 @@ AC_CONFIG_MACRO_DIR([config/m4])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
|
||||
+137
-16
@@ -1,24 +1,145 @@
|
||||
current_dir = File.dirname(__FILE__)
|
||||
rakefile_manual = File.expand_path(File.join(current_dir, "Rakefile.manual"))
|
||||
rakefile_website = File.expand_path(File.join(current_dir, "Rakefile.website"))
|
||||
require 'yaml'
|
||||
require 'bonsai'
|
||||
require 'liquid'
|
||||
require 'maruku'
|
||||
require 'json'
|
||||
require 'ronn'
|
||||
require 'tempfile'
|
||||
require 'yaml'
|
||||
|
||||
desc "Build the manpage from the bonsai source of the manual"
|
||||
task :manpage do
|
||||
system %(#{$0} -f #{rakefile_manual} manpage)
|
||||
module ExtraFilters
|
||||
def markdownify(input)
|
||||
Maruku.new(input).to_html
|
||||
end
|
||||
|
||||
def sanitize(input)
|
||||
input.gsub(/[^a-zA-Z0-9_]/,"")
|
||||
end
|
||||
|
||||
def json(input)
|
||||
input.to_json
|
||||
end
|
||||
|
||||
def unique(input)
|
||||
@n = (@n || 0) + 1
|
||||
input + @n.to_s
|
||||
end
|
||||
end
|
||||
|
||||
desc "Collect jq unit test cases from the bonsai source of the manual"
|
||||
task :mantests do
|
||||
system %(#{$0} -f #{rakefile_manual} mantests)
|
||||
end
|
||||
Liquid::Template.register_filter(ExtraFilters)
|
||||
|
||||
desc "Build the website from the bonsai sources"
|
||||
task :build do
|
||||
system %(#{$0} -f #{rakefile_website} build)
|
||||
end
|
||||
|
||||
desc "Serve a live view of the website on http://localhost:5000/jq/"
|
||||
task :serve do
|
||||
system %(#{$0} -f #{rakefile_website} serve)
|
||||
begin
|
||||
Bonsai.log "Press Control+C to quit"
|
||||
|
||||
require 'rack'
|
||||
require 'sinatra'
|
||||
require 'watch'
|
||||
require 'launchy'
|
||||
|
||||
Bonsai.root_dir = Dir.pwd
|
||||
|
||||
server = fork {
|
||||
app = Rack::Builder.app {
|
||||
map "/jq" do
|
||||
use Bonsai::StaticPassThrough, :root => Bonsai.root_dir + "/output", :urls => ["/"]
|
||||
end
|
||||
run Bonsai::DevelopmentServer
|
||||
}
|
||||
Rack::Handler.default.run(app, :Port => 5000) do
|
||||
Launchy.open("http://localhost:5000/jq/")
|
||||
end
|
||||
}
|
||||
Watch.new("{content,templates,public}/**/*") { Bonsai::Exporter.process! }
|
||||
rescue Interrupt
|
||||
Process.kill("QUIT", server)
|
||||
Process.wait(server)
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
task :build do
|
||||
Bonsai.root_dir = Dir.pwd
|
||||
Bonsai::Exporter.publish!
|
||||
end
|
||||
|
||||
$BINARIES = {
|
||||
:osx32 => "--host=i686-apple-darwin10 CFLAGS='-m32 -g -O'",
|
||||
:osx64 => "--host=i686-apple-darwin10 CFLAGS='-m64 -g -O'",
|
||||
:win32 => "--host=i686-w64-mingw32 CFLAGS='-g -O'",
|
||||
:win64 => "--host=x86_64-w64-mingw32 CFLAGS='-g -O'",
|
||||
:linux32 => "--host=x86_64-linux-gnu CFLAGS='-m32 -g -O'",
|
||||
:linux64 => "--host=x86_64-linux-gnu CFLAGS='-m64 -g -O'"
|
||||
}
|
||||
|
||||
$BINARIES.each do |name, args|
|
||||
file "../build/#{name}" do |t|
|
||||
sh "../scripts/crosscompile -j4 #{name} #{args}"
|
||||
end
|
||||
task :binaries => ["../build/#{name}"]
|
||||
end
|
||||
|
||||
task :binaries => ["output/download"] do
|
||||
$BINARIES.each do |name, args|
|
||||
FileUtils.cp_r "../build/#{name}", "output/download/"
|
||||
end
|
||||
end
|
||||
|
||||
def load_manual
|
||||
YAML::load(File.open("content/3.manual/manual.yml"))
|
||||
end
|
||||
|
||||
task :manpage do
|
||||
Tempfile.open "manpage" do |f|
|
||||
manual = load_manual
|
||||
f.puts manual['manpage_intro']
|
||||
f.puts manual['body']
|
||||
manual['sections'].each do |section|
|
||||
|
||||
f.puts "## #{section['title'].upcase}\n"
|
||||
f.puts section['body']
|
||||
f.puts ""
|
||||
(section['entries'] || []).each do |entry|
|
||||
f.puts "### #{entry['title']}\n"
|
||||
f.puts entry['body']
|
||||
f.puts ""
|
||||
(entry['examples'] || []).each do |example|
|
||||
f.puts " jq '#{example['program']}'"
|
||||
f.puts " #{example['input']}"
|
||||
f.puts " => #{example['output'].join(", ")}"
|
||||
f.puts
|
||||
end
|
||||
end
|
||||
f.puts ""
|
||||
end
|
||||
f.puts manual['manpage_epilogue']
|
||||
f.close
|
||||
puts Ronn::Document.new(f.path).convert('roff').gsub(/<\/?code>/,"")
|
||||
end
|
||||
end
|
||||
|
||||
task :manpage_default => ["default_manpage.md"] do
|
||||
puts Ronn::Document.new("default_manpage.md").convert('roff').gsub(/<\/?code>/,"")
|
||||
end
|
||||
|
||||
task :mantests do
|
||||
load_manual['sections'].each do |section|
|
||||
(section['entries'] || []).each do |entry|
|
||||
(entry['examples'] || []).each do |example|
|
||||
puts example['program'].gsub("\n", " ")
|
||||
puts example['input']
|
||||
example['output'].each do |s| puts s end
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
directory "output/download/source"
|
||||
task :tarball => ["output/download/source"] do
|
||||
sh "cd ..; ./configure && make dist && make distclean"
|
||||
sh "cp ../jq-*.tar.gz output/download/source"
|
||||
end
|
||||
|
||||
task :dist => [:build, :binaries, :tarball]
|
||||
@@ -1,49 +0,0 @@
|
||||
require 'ronn'
|
||||
require 'tempfile'
|
||||
require 'yaml'
|
||||
|
||||
def load_manual
|
||||
YAML::load(File.open("content/3.manual/manual.yml"))
|
||||
end
|
||||
|
||||
task :manpage do
|
||||
Tempfile.open "manpage" do |f|
|
||||
manual = load_manual
|
||||
f.puts manual['manpage_intro']
|
||||
f.puts manual['body']
|
||||
manual['sections'].each do |section|
|
||||
|
||||
f.puts "## #{section['title'].upcase}\n"
|
||||
f.puts section['body']
|
||||
f.puts ""
|
||||
(section['entries'] || []).each do |entry|
|
||||
f.puts "### #{entry['title']}\n"
|
||||
f.puts entry['body']
|
||||
f.puts ""
|
||||
(entry['examples'] || []).each do |example|
|
||||
f.puts " jq '#{example['program']}'"
|
||||
f.puts " #{example['input']}"
|
||||
f.puts " => #{example['output'].join(", ")}"
|
||||
f.puts
|
||||
end
|
||||
end
|
||||
f.puts ""
|
||||
end
|
||||
f.puts manual['manpage_epilogue']
|
||||
f.close
|
||||
puts Ronn::Document.new(f.path).convert('roff').gsub(/<\/?code>/,"")
|
||||
end
|
||||
end
|
||||
|
||||
task :mantests do
|
||||
load_manual['sections'].each do |section|
|
||||
(section['entries'] || []).each do |entry|
|
||||
(entry['examples'] || []).each do |example|
|
||||
puts example['program'].gsub("\n", " ")
|
||||
puts example['input']
|
||||
example['output'].each do |s| puts s end
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,66 +0,0 @@
|
||||
require 'bonsai'
|
||||
require 'json'
|
||||
require 'liquid'
|
||||
require 'maruku'
|
||||
|
||||
module ExtraFilters
|
||||
def markdownify(input)
|
||||
Maruku.new(input).to_html
|
||||
end
|
||||
def search_id(input)
|
||||
input.gsub(/`/, '')
|
||||
end
|
||||
def section_id(input)
|
||||
input.gsub(/[^a-zA-Z0-9_]/, '')
|
||||
end
|
||||
def entry_id(input)
|
||||
input.gsub(/[ `]/, '')
|
||||
end
|
||||
def no_paragraph(input)
|
||||
input.gsub('<p>', '').gsub('</p>', '')
|
||||
end
|
||||
def json(input)
|
||||
input.to_json
|
||||
end
|
||||
def unique(input)
|
||||
@n = (@n || 0) + 1
|
||||
input + @n.to_s
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_filter(ExtraFilters)
|
||||
|
||||
task :build do
|
||||
Bonsai.root_dir = Dir.pwd
|
||||
Bonsai::Exporter.publish!
|
||||
end
|
||||
|
||||
task :serve do
|
||||
begin
|
||||
Bonsai.log "Press Control+C to quit"
|
||||
|
||||
require 'rack'
|
||||
require 'sinatra'
|
||||
require 'watch'
|
||||
require 'launchy'
|
||||
|
||||
Bonsai.root_dir = Dir.pwd
|
||||
|
||||
server = fork {
|
||||
app = Rack::Builder.app {
|
||||
map "/jq" do
|
||||
use Bonsai::StaticPassThrough, :root => Bonsai.root_dir + "/output", :urls => ["/"]
|
||||
end
|
||||
run Bonsai::DevelopmentServer
|
||||
}
|
||||
Rack::Handler.default.run(app, :Port => 5000) do
|
||||
Launchy.open("http://localhost:5000/jq/")
|
||||
end
|
||||
}
|
||||
Watch.new("{content,templates,public}/**/*") { Bonsai::Exporter.process! }
|
||||
rescue Interrupt
|
||||
Process.kill("QUIT", server)
|
||||
Process.wait(server)
|
||||
exit
|
||||
end
|
||||
end
|
||||
@@ -15,110 +15,55 @@ body:
|
||||
|
||||
|
||||
### Linux
|
||||
|
||||
* jq 1.4 binaries for [64-bit](linux64/jq) or [32-bit](linux32/jq) systems.
|
||||
* jq 1.3 binaries for [64-bit](linux64/jq-1.3/jq) or [32-bit](linux32/jq-1.3/jq) systems.
|
||||
|
||||
* jq 1.5 is in the official [Debian](https://packages.debian.org/jq) and
|
||||
* For Arch users, a PKGBUILD for jq-1.1 is in the
|
||||
[AUR](https://aur.archlinux.org/packages.php?ID=63849), as
|
||||
well as a PKGBUILD for the HEAD of master
|
||||
([jq-git](https://aur.archlinux.org/packages.php?ID=63850)).
|
||||
You can install them using
|
||||
[Yaourt](https://wiki.archlinux.org/index.php/Yaourt) or
|
||||
manually by following instructions on [Arch Linux's
|
||||
Wiki](https://wiki.archlinux.org/index.php/Arch_UseRepository).
|
||||
|
||||
* jq 1.4 is in the official [Debian](https://packages.debian.org/jq) and
|
||||
[Ubuntu](http://packages.ubuntu.com/jq) repositories. Install using
|
||||
`sudo apt-get install jq`.
|
||||
|
||||
* jq 1.5 is in the official
|
||||
[Fedora](http://pkgs.fedoraproject.org/cgit/jq.git/) repository.
|
||||
Install using `sudo dnf install jq`.
|
||||
* jq 1.4 is [in Debian](http://packages.debian.org/jq)
|
||||
|
||||
* jq 1.4 is in the official [openSUSE](https://software.opensuse.org/package/jq)
|
||||
repository. Install using `sudo zypper install jq`.
|
||||
|
||||
* jq 1.5 is in the official
|
||||
[Arch](https://www.archlinux.org/packages/?sort=&q=jq&maintainer=&flagged=)
|
||||
repository. Install using `sudo pacman -Sy jq`.
|
||||
|
||||
* jq 1.5 binaries for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux32).
|
||||
|
||||
* jq 1.4 binaries for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-linux-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-linux-x86).
|
||||
|
||||
* jq 1.3 binaries for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-linux-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-linux-x86).
|
||||
* jq 1.3.2 is in the official Fedora repository. You can install using
|
||||
`sudo yum install jq`.
|
||||
|
||||
### OS X
|
||||
|
||||
* Use [Homebrew](http://brew.sh/) to install jq 1.5 with
|
||||
`brew install jq`.
|
||||
* `brew install jq` using [homebrew](http://mxcl.github.com/homebrew/)
|
||||
|
||||
* jq 1.5 binary for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64).
|
||||
* Or, grab prebuilt jq 1.4 [64-bit binaries](osx64/jq) or [32-bit
|
||||
binaries](osx32/jq)
|
||||
|
||||
* jq 1.4 binaries for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-osx-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-osx-x86).
|
||||
|
||||
* jq 1.3 binaries for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-osx-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-osx-x86).
|
||||
|
||||
### FreeBSD
|
||||
|
||||
* Use [FreshPorts](https://www.freshports.org/textproc/jq/) to install
|
||||
jq 1.4 with `pkg install jq`.
|
||||
* Or, grab prebuilt jq 1.3 [64-bit binaries](osx64/jq-1.3/jq) or [32-bit
|
||||
binaries](osx32/jq-1.3/jq)
|
||||
|
||||
### Solaris
|
||||
|
||||
* `pkgutil -i jq` in [OpenCSW](https://www.opencsw.org/p/jq) for Solaris
|
||||
10+, Sparc and x86.
|
||||
* `pkgutil -i jq` in [OpenCSW](http://www.opencsw.org/p/jq) for Solaris 10+, Sparc and x86
|
||||
|
||||
* jq 1.4 binaries for Solaris 11
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-solaris11-64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-solaris11-32).
|
||||
* jq 1.4 executables for Solaris 11 [64-bit](solaris11-64/jq) or [32-bit](solaris11-32/jq)
|
||||
|
||||
### Windows
|
||||
|
||||
* Use [Chocolatey NuGet](https://chocolatey.org/) to install jq 1.5 with
|
||||
`chocolatey install jq`.
|
||||
* `chocolatey install jq` using [Chocolatey NuGet](https://chocolatey.org/)
|
||||
|
||||
* jq 1.5 executables for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win64.exe)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win32.exe).
|
||||
* jq 1.4 executables for [64-bit](win64/jq.exe) or [32-bit](win32/jq.exe)
|
||||
|
||||
* jq 1.4 executables for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-win64.exe)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-win32.exe).
|
||||
|
||||
* jq 1.3 executables for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-win64.exe)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-win32.exe).
|
||||
|
||||
### Checksums and signatures
|
||||
|
||||
SHA-256 checksums are provided for all release and pre-release binaries.
|
||||
They can be found under
|
||||
[sig/v1.x/sha256sum.txt](https://github.com/stedolan/jq/tree/master/sig).
|
||||
The checksums for jq 1.5 are in
|
||||
[sig/v1.5/sha256sum.txt](https://raw.githubusercontent.com/stedolan/jq/master/sig/v1.5/sha256sum.txt).
|
||||
|
||||
Additionally, all binaries are signed by the
|
||||
[jq Package Signing Key](https://raw.githubusercontent.com/stedolan/jq/master/sig/jq-release.key).
|
||||
The signatures can be found under
|
||||
[sig/v1.x/\*.asc](https://github.com/stedolan/jq/tree/master/sig).
|
||||
The signatures for jq 1.5 are in
|
||||
[sig/v1.5/\*.asc](https://github.com/stedolan/jq/tree/master/sig/v1.5).
|
||||
You can use [GnuPG](https://gnupg.org/) to verify a signature by downloading
|
||||
the signature and running `gpg --verify signature.asc`.
|
||||
* jq 1.3 executables for [64-bit](win64/jq-1.3/jq-1.3.exe) or [32-bit](win32/jq-1.3/jq-1.3.exe)
|
||||
|
||||
### From source on Linux, OS X, Cygwin, and other POSIX-like operating systems
|
||||
|
||||
* [Source tarball for jq 1.5](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz)
|
||||
* [Source tarball for jq 1.4](source/jq-1.4.tar.gz)
|
||||
|
||||
You can build it using the usual `./configure && make && sudo
|
||||
make install` rigmarole.
|
||||
@@ -128,13 +73,15 @@ body:
|
||||
git clone https://github.com/stedolan/jq.git
|
||||
cd jq
|
||||
autoreconf -i
|
||||
./configure --disable-maintainer-mode
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
|
||||
To build it from a git clone, you'll need to install a few
|
||||
packages first:
|
||||
|
||||
* [Flex](http://flex.sourceforge.net/)
|
||||
* [Bison](https://www.gnu.org/software/bison/)
|
||||
* [GCC](https://gcc.gnu.org)
|
||||
* [Make](https://www.gnu.org/software/make/)
|
||||
* [Autotools](https://www.gnu.org/software/automake/)
|
||||
@@ -149,12 +96,11 @@ body:
|
||||
by Apple. This can be found in [Homebrew](http://brew.sh) or
|
||||
[MacPorts](https://macports.org/).
|
||||
|
||||
The `--disable-maintainer-mode` flag says to use the pre-generated lexer
|
||||
and parser that come with the code. To compile the lexer and parser also
|
||||
from source, leave out this flag. You will need to install
|
||||
[Flex](http://flex.sourceforge.net/) and
|
||||
[Bison](https://www.gnu.org/software/bison/).
|
||||
|
||||
`flex` and `bison` are used to generate the lexer and parser for
|
||||
jq. For jq 1.5, neither is required if you use `./configure
|
||||
--disable-maintainer-mode` instead of `./configure`. This flag says to use
|
||||
the pre-generated lexer and parser that come with the code.
|
||||
|
||||
#### Building the documentation
|
||||
|
||||
jq's documentation is compiled into static HTML using
|
||||
@@ -168,3 +114,4 @@ body:
|
||||
the YAML docs, and you'll still need the Ruby dependencies to
|
||||
build the manpage.
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ headline: jq Manual (development version)
|
||||
|
||||
history: |
|
||||
|
||||
*For released versions, see [jq 1.5](/jq/manual/v1.5),
|
||||
[jq 1.4](/jq/manual/v1.4) or [jq 1.3](/jq/manual/v1.3).*
|
||||
*For released versions, see [jq 1.4](/jq/manual/v1.4) or
|
||||
[jq 1.3](/jq/manual/v1.3).*
|
||||
|
||||
body: |
|
||||
|
||||
@@ -107,7 +107,7 @@ sections:
|
||||
output and an ASCII LF (line feed) is printed after every
|
||||
output. Input JSON texts that fail to parse are ignored (but
|
||||
warned about), discarding all subsequent input until the next
|
||||
RS. This mode also parses the output of jq without the `--seq`
|
||||
RS. This more also parses the output of jq without the `--seq`
|
||||
option.
|
||||
|
||||
* `--stream`:
|
||||
@@ -433,7 +433,6 @@ sections:
|
||||
|
||||
- title: "`|`"
|
||||
body: |
|
||||
|
||||
The | operator combines two filters by feeding the output(s) of
|
||||
the one on the left into the input of the one on the right. It's
|
||||
pretty much the same as the Unix shell's pipe, if you're used to
|
||||
@@ -444,29 +443,11 @@ sections:
|
||||
expression `.[] | .foo` retrieves the "foo" field of each
|
||||
element of the input array.
|
||||
|
||||
Note that `.a.b.c` is the same as `.a | .b | .c`.
|
||||
|
||||
Note too that `.` is the input value at the particular stage
|
||||
in a "pipeline", specifically: where the `.` expression appears.
|
||||
Thus `.a | . | .b` is the same as `.a.b`, as the `.` in the
|
||||
middle refers to whatever value `.a` produced.
|
||||
|
||||
examples:
|
||||
- program: '.[] | .name'
|
||||
input: '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]'
|
||||
output: ['"JSON"', '"XML"']
|
||||
|
||||
- title: "Parenthesis"
|
||||
body: |
|
||||
|
||||
Parenthesis work as a grouping operator just as in any typical
|
||||
programming language.
|
||||
|
||||
examples:
|
||||
- program: '(. + 2) * 5'
|
||||
input: '1'
|
||||
output: [15]
|
||||
|
||||
- title: Types and Values
|
||||
body: |
|
||||
|
||||
@@ -638,7 +619,7 @@ sections:
|
||||
that string that many times. `"x" * 0` produces **null**.
|
||||
|
||||
Dividing a string by another splits the first using the second
|
||||
as separators.
|
||||
as separators.
|
||||
|
||||
Multiplying two objects will merge them recursively: this works
|
||||
like addition but if both objects contain a value for the
|
||||
@@ -681,18 +662,6 @@ sections:
|
||||
input: '[[1,2], "string", {"a":2}, null]'
|
||||
output: [2, 6, 1, 0]
|
||||
|
||||
|
||||
- title: "`utf8bytelength`"
|
||||
body: |
|
||||
|
||||
The builtin function `utf8bytelength` outputs the number of
|
||||
bytes used to encode a string in UTF-8.
|
||||
|
||||
examples:
|
||||
- program: 'utf8bytelength'
|
||||
input: '"\u03bc"'
|
||||
output: [2]
|
||||
|
||||
- title: "`keys`, `keys_unsorted`"
|
||||
body: |
|
||||
|
||||
@@ -741,12 +710,12 @@ sections:
|
||||
|
||||
- title: "`in`"
|
||||
body: |
|
||||
|
||||
The builtin function `in` returns whether or not the input key is in the
|
||||
|
||||
The builtin function `in` returns the input key is in the
|
||||
given object, or the input index corresponds to an element
|
||||
in the given array. It is, essentially, an inversed version
|
||||
of `has`.
|
||||
|
||||
|
||||
examples:
|
||||
- program: '.[] | in({"foo": 42})'
|
||||
input: '["foo", "bar"]'
|
||||
@@ -754,35 +723,13 @@ sections:
|
||||
- program: 'map(in([0,1]))'
|
||||
input: '[2, 0]'
|
||||
output: ['[false, true]']
|
||||
|
||||
- title: "`map(x)`, `map_values(x)`"
|
||||
body: |
|
||||
|
||||
For any filter `x`, `map(x)` will run that filter for each
|
||||
element of the input array, and return the outputs in a new
|
||||
array. `map(.+1)` will increment each element of an array of numbers.
|
||||
|
||||
Similarly, `map_values(x)` will run that filter for each element,
|
||||
but it will return an object when an object is passed.
|
||||
|
||||
`map(x)` is equivalent to `[.[] | x]`. In fact, this is how
|
||||
it's defined. Similarly, `map_values(x)` is defined as `.[] |= x`.
|
||||
|
||||
examples:
|
||||
- program: 'map(.+1)'
|
||||
input: '[1,2,3]'
|
||||
output: ['[2,3,4]']
|
||||
|
||||
- program: 'map_values(.+1)'
|
||||
input: '{"a": 1, "b": 2, "c": 3}'
|
||||
output: ['{"a": 2, "b": 3, "c": 4}']
|
||||
|
||||
|
||||
- title: "`path(path_expression)`"
|
||||
body: |
|
||||
|
||||
Outputs array representations of the given path expression
|
||||
in `.`. The outputs are arrays of strings (object keys)
|
||||
and/or numbers (array indices).
|
||||
in `.`. The outputs are arrays of strings (keys in objects0
|
||||
and/or numbers (array indices.
|
||||
|
||||
Path expressions are jq expressions like `.a`, but also `.[]`.
|
||||
There are two types of path expressions: ones that can match
|
||||
@@ -823,48 +770,6 @@ sections:
|
||||
input: '["foo", "bar", "baz"]'
|
||||
output: ['["foo"]']
|
||||
|
||||
- title: "`getpath(PATHS)`"
|
||||
body: |
|
||||
|
||||
The builtin function `getpath` outputs the values in `.` found
|
||||
at each path in `PATHS`.
|
||||
|
||||
examples:
|
||||
- program: 'getpath(["a","b"])'
|
||||
input: 'null'
|
||||
output: ['null']
|
||||
- program: '[getpath(["a","b"], ["a","c"])]'
|
||||
input: '{"a":{"b":0, "c":1}}'
|
||||
output: ['[0, 1]']
|
||||
|
||||
- title: "`setpath(PATHS; VALUE)`"
|
||||
body: |
|
||||
|
||||
The builtin function `setpath` sets the `PATHS` in `.` to `VALUE`.
|
||||
|
||||
examples:
|
||||
- program: 'setpath(["a","b"]; 1)'
|
||||
input: 'null'
|
||||
output: ['{"a": {"b": 1}}']
|
||||
- program: 'setpath(["a","b"]; 1)'
|
||||
input: '{"a":{"b":0}}'
|
||||
output: ['{"a": {"b": 1}}']
|
||||
- program: 'setpath([0,"a"]; 1)'
|
||||
input: 'null'
|
||||
output: ['[{"a":1}]']
|
||||
|
||||
- title: "`delpaths(PATHS)`"
|
||||
body: |
|
||||
|
||||
The builtin function `delpaths` sets the `PATHS` in `.`.
|
||||
`PATHS` must be an array of paths, where each path is an array
|
||||
of strings and numbers.
|
||||
|
||||
examples:
|
||||
- program: 'delpaths([["a","b"]])'
|
||||
input: '{"a":{"b":1},"x":{"y":2}}'
|
||||
output: ['{"a":{},"x":{"y":2}}']
|
||||
|
||||
- title: "`to_entries`, `from_entries`, `with_entries`"
|
||||
body: |
|
||||
|
||||
@@ -877,7 +782,7 @@ sections:
|
||||
`with_entries(foo)` is a shorthand for `to_entries |
|
||||
map(foo) | from_entries`, useful for doing some operation to
|
||||
all keys and values of an object. `from_entries` accepts key, Key,
|
||||
name, Name, value and Value as keys.
|
||||
Name, value and Value as keys.
|
||||
|
||||
examples:
|
||||
- program: 'to_entries'
|
||||
@@ -957,6 +862,28 @@ sections:
|
||||
input: 'null'
|
||||
output: ['"{\"file\":\"<top-level>\",\"line\":1}"']
|
||||
|
||||
- title: "`map(x)`, `map_values(x)`"
|
||||
body: |
|
||||
|
||||
For any filter `x`, `map(x)` will run that filter for each
|
||||
element of the input array, and produce the outputs a new
|
||||
array. `map(.+1)` will increment each element of an array of numbers.
|
||||
|
||||
Similarly, `map_values(x)` will run that filter for each element,
|
||||
but it will return an object when an object is passed.
|
||||
|
||||
`map(x)` is equivalent to `[.[] | x]`. In fact, this is how
|
||||
it's defined. Similarly, `map_values(x)` is defined as `.[] |= x`.
|
||||
|
||||
examples:
|
||||
- program: 'map(.+1)'
|
||||
input: '[1,2,3]'
|
||||
output: ['[2,3,4]']
|
||||
|
||||
- program: 'map_values(.+1)'
|
||||
input: '{"a": 1, "b": 2, "c": 3}'
|
||||
output: ['{"a": 2, "b": 3, "c": 4}']
|
||||
|
||||
- title: "`paths`, `paths(node_filter)`, `leaf_paths`"
|
||||
body: |
|
||||
|
||||
@@ -1005,8 +932,8 @@ sections:
|
||||
body: |
|
||||
|
||||
The filter `any` takes as input an array of boolean values,
|
||||
and produces `true` as output if any of the elements of
|
||||
the array are `true`.
|
||||
and produces `true` as output if any of the the elements of
|
||||
the array is `true`.
|
||||
|
||||
If the input is an empty array, `any` returns `false`.
|
||||
|
||||
@@ -1031,7 +958,7 @@ sections:
|
||||
body: |
|
||||
|
||||
The filter `all` takes as input an array of boolean values,
|
||||
and produces `true` as output if all of the elements of
|
||||
and produces `true` as output if all of the the elements of
|
||||
the array are `true`.
|
||||
|
||||
The `all(condition)` form applies the given condition to the
|
||||
@@ -1053,7 +980,7 @@ sections:
|
||||
input: '[]'
|
||||
output: ["true"]
|
||||
|
||||
- title: "`flatten`, `flatten(depth)`"
|
||||
- title: "\\[Requires 1.5\\] `flatten`, `flatten(depth)`"
|
||||
body: |
|
||||
|
||||
The filter `flatten` takes as input an array of nested arrays,
|
||||
@@ -1459,7 +1386,7 @@ sections:
|
||||
input: '[65, 66, 67]'
|
||||
output: ['"ABC"']
|
||||
|
||||
- title: "`split(str)`"
|
||||
- title: "`split`"
|
||||
body: |
|
||||
|
||||
Splits an input string on the separator argument.
|
||||
@@ -1477,22 +1404,16 @@ sections:
|
||||
running `split("foo") | join("foo")` over any input string
|
||||
returns said input string.
|
||||
|
||||
Numbers and booleans in the input are converted to strings.
|
||||
Null values are treated as empty strings. Arrays and objects
|
||||
in the input are not supported.
|
||||
|
||||
examples:
|
||||
- program: 'join(", ")'
|
||||
input: '["a","b,c,d","e"]'
|
||||
output: ['"a, b,c,d, e"']
|
||||
- program: 'join(" ")'
|
||||
input: '["a",1,2.3,true,null,false]'
|
||||
output: ['"a 1 2.3 true false"']
|
||||
|
||||
|
||||
- title: "`ascii_downcase`, `ascii_upcase`"
|
||||
body: |
|
||||
|
||||
Emit a copy of the input string with its alphabetic characters (a-z and A-Z)
|
||||
Emit a copy of the input string with its alphabetic characters (a-z and A-Z)
|
||||
converted to the specified case.
|
||||
|
||||
example:
|
||||
@@ -1601,33 +1522,6 @@ sections:
|
||||
- 4
|
||||
- 16
|
||||
|
||||
- title: "`walk(f)`"
|
||||
body: |
|
||||
|
||||
The `walk(f)` function applies f recursively to every
|
||||
component of the input entity. When an array is
|
||||
encountered, f is first applied to its elements and then to
|
||||
the array itself; when an object is encountered, f is first
|
||||
applied to all the values and then to the object. In
|
||||
practice, f will usually test the type of its input, as
|
||||
illustrated in the following examples. The first example
|
||||
highlights the usefulness of processing the elements of an
|
||||
array of arrays before processing the array itself. The second
|
||||
example shows how all the keys of all the objects within the
|
||||
input can be considered for alteration.
|
||||
|
||||
examples:
|
||||
- program: 'walk(if type == "array" then sort else . end)'
|
||||
input: '[[4, 1, 7], [8, 5, 2], [3, 6, 9]]'
|
||||
output:
|
||||
- '[[1,4,7],[2,5,8],[3,6,9]]'
|
||||
|
||||
- program: 'walk( if type == "object" then with_entries( .key |= sub( "^_+"; "") ) else . end )'
|
||||
input: '[ { "_a": { "__b": 2 } } ]'
|
||||
output:
|
||||
- '[{"a":{"b":2}}]'
|
||||
|
||||
|
||||
- title: "`..`"
|
||||
body: |
|
||||
|
||||
@@ -1655,7 +1549,7 @@ sections:
|
||||
- title: "`transpose`"
|
||||
body: |
|
||||
|
||||
Transpose a possibly jagged matrix (an array of arrays).
|
||||
Transpose a possibly jagged matrix (an array of arrays).
|
||||
Rows are padded with nulls so the result is always rectangular.
|
||||
|
||||
examples:
|
||||
@@ -1866,46 +1760,6 @@ sections:
|
||||
input: '"2015-03-05T23:51:47Z"'
|
||||
output: ['1425599507']
|
||||
|
||||
- title: "SQL-Style Operators"
|
||||
body: |
|
||||
|
||||
jq provides a few SQL-style operators.
|
||||
|
||||
* INDEX(stream; index_expression):
|
||||
|
||||
This builtin produces an object whose keys are computed by
|
||||
the given index expression applied to each value from the
|
||||
given stream.
|
||||
|
||||
* JOIN($idx; stream; idx_expr; join_expr):
|
||||
|
||||
This builtin joins the values from the given stream to the
|
||||
given index. The index's keys are computed by applying the
|
||||
given index expression to each value from the given stream.
|
||||
An array of the value in the stream and the corresponding
|
||||
value from the index is fed to the given join expression to
|
||||
produce each result.
|
||||
|
||||
* JOIN($idx; stream; idx_expr):
|
||||
|
||||
Same as `JOIN($idx; stream; idx_expr; .)`.
|
||||
|
||||
* JOIN($idx; idx_expr):
|
||||
|
||||
This builtin joins the input `.` to the given index, applying
|
||||
the given index expression to `.` to compute the index key.
|
||||
The join operation is as described above.
|
||||
|
||||
* IN(s):
|
||||
|
||||
This builtin outputs `true` if `.` appears in the given
|
||||
stream, otherwise it outputs `false`.
|
||||
|
||||
* IN(source; s):
|
||||
|
||||
This builtin outputs `true` if any value in the source stream
|
||||
appears in the second stream, otherwise it outputs `false`.
|
||||
|
||||
- title: Conditionals and Comparisons
|
||||
entries:
|
||||
- title: "`==`, `!=`"
|
||||
@@ -1940,9 +1794,9 @@ sections:
|
||||
need something more like `if (.name | length) > 0 then A else
|
||||
B end` instead.
|
||||
|
||||
If the condition `A` produces multiple results, then `B` is evaluated
|
||||
once for each result that is not false or null, and `C` is evaluated
|
||||
once for each false or null.
|
||||
If the condition A produces multiple results, it is
|
||||
considered "true" if any of those results is not false or
|
||||
null. If it produces zero results, it's considered false.
|
||||
|
||||
More cases can be added to an if using `elif A then B` syntax.
|
||||
|
||||
@@ -2142,7 +1996,7 @@ sections:
|
||||
evaluates to: true, true, false, false.
|
||||
|
||||
entries:
|
||||
- title: "`test(val)`, `test(regex; flags)`"
|
||||
- title: "\\[Requires 1.5\\] `test(val)`, `test(regex; flags)`"
|
||||
body: |
|
||||
|
||||
Like `match`, but does not return match objects, only `true` or `false`
|
||||
@@ -2156,7 +2010,7 @@ sections:
|
||||
input: '["xabcd", "ABC"]'
|
||||
output: ['true', 'true']
|
||||
|
||||
- title: "`match(val)`, `match(regex; flags)`"
|
||||
- title: "\\[Requires 1.5\\] `match(val)`, `match(regex; flags)`"
|
||||
body: |
|
||||
|
||||
**match** outputs an object for each match it finds. Matches have
|
||||
@@ -2201,7 +2055,7 @@ sections:
|
||||
output: [3]
|
||||
|
||||
|
||||
- title: "`capture(val)`, `capture(regex; flags)`"
|
||||
- title: "\\[Requires 1.5\\] `capture(val)`, `capture(regex; flags)`"
|
||||
body: |
|
||||
|
||||
Collects the named captures in a JSON object, with the name
|
||||
@@ -2213,7 +2067,7 @@ sections:
|
||||
input: '"xyzzy-14"'
|
||||
output: ['{ "a": "xyzzy", "n": "14" }']
|
||||
|
||||
- title: "`scan(regex)`, `scan(regex; flags)`"
|
||||
- title: "\\[Requires 1.5\\] `scan(regex)`, `scan(regex; flags)`"
|
||||
body: |
|
||||
|
||||
Emit a stream of the non-overlapping substrings of the input
|
||||
@@ -2242,7 +2096,7 @@ sections:
|
||||
output: ['"ab","cd","ef"']
|
||||
|
||||
|
||||
- title: "`splits(regex)`, `splits(regex; flags)`"
|
||||
- title: "\\[Requires 1.5\\] `splits(regex)`, `splits(regex; flags)`"
|
||||
body: |
|
||||
|
||||
These provide the same results as their `split` counterparts,
|
||||
@@ -2253,7 +2107,7 @@ sections:
|
||||
input: '("ab,cd", "ef, gh")'
|
||||
output: ['"ab"', '"cd"', '"ef"', '"gh"']
|
||||
|
||||
- title: "`sub(regex; tostring)` `sub(regex; string; flags)`"
|
||||
- title: "\\[Requires 1.5\\] `sub(regex; tostring)` `sub(regex; string; flags)`"
|
||||
body: |
|
||||
|
||||
Emit the string obtained by replacing the first match of regex in the
|
||||
@@ -2269,7 +2123,7 @@ sections:
|
||||
output: '"ZabcZabc"'
|
||||
|
||||
|
||||
- title: "`gsub(regex; string)`, `gsub(regex; string; flags)`"
|
||||
- title: "\\[Requires 1.5\\] `gsub(regex; string)`, `gsub(regex; string; flags)`"
|
||||
body: |
|
||||
|
||||
`gsub` is like `sub` but all the non-overlapping occurrences of the regex are
|
||||
@@ -2420,17 +2274,17 @@ sections:
|
||||
def increment: . + 1;
|
||||
|
||||
From then on, `increment` is usable as a filter just like a
|
||||
builtin function (in fact, this is how many of the builtins
|
||||
builtin function (in fact, this is how some of the builtins
|
||||
are defined). A function may take arguments:
|
||||
|
||||
def map(f): [.[] | f];
|
||||
|
||||
Arguments are passed as _filters_ (functions with no
|
||||
arguments), _not_ as values. The same argument may be
|
||||
referenced multiple times with different inputs (here `f` is
|
||||
run for each element of the input array). Arguments to a
|
||||
function work more like callbacks than like value arguments.
|
||||
This is important to understand. Consider:
|
||||
Arguments are passed as filters, not as values. The
|
||||
same argument may be referenced multiple times with
|
||||
different inputs (here `f` is run for each element of the
|
||||
input array). Arguments to a function work more like
|
||||
callbacks than like value arguments. This is important to
|
||||
understand. Consider:
|
||||
|
||||
def foo(f): f|f;
|
||||
5|foo(.*2)
|
||||
@@ -2451,16 +2305,12 @@ sections:
|
||||
def addvalue($f): ...;
|
||||
|
||||
With either definition, `addvalue(.foo)` will add the current
|
||||
input's `.foo` field to each element of the array. Do note
|
||||
that calling `addvalue(.[])` will cause the `map(. + $f)` part
|
||||
to be evaluated once per value in the value of `.` at the call
|
||||
site.
|
||||
input's `.foo` field to each element of the array.
|
||||
|
||||
Multiple definitions using the same function name are allowed.
|
||||
Each re-definition replaces the previous one for the same
|
||||
number of function arguments, but only for references from
|
||||
functions (or main program) subsequent to the re-definition.
|
||||
See also the section below on scoping.
|
||||
|
||||
examples:
|
||||
- program: 'def addvalue(f): . + [f]; map(addvalue(.[0]))'
|
||||
@@ -2470,23 +2320,6 @@ sections:
|
||||
input: '[[1,2],[10,20]]'
|
||||
output: ['[[1,2,1,2], [10,20,1,2]]']
|
||||
|
||||
- title: 'Scoping'
|
||||
body: |
|
||||
|
||||
There are two types of symbols in jq: value bindings (a.k.a.,
|
||||
"variables"), and functions. Both are scoped lexically,
|
||||
with expressions being able to refer only to symbols that
|
||||
have been defined "to the left" of them. The only exception
|
||||
to this rule is that functions can refer to themselves so as
|
||||
to be able to create recursive functions.
|
||||
|
||||
For example, in the following expression there is a binding
|
||||
which is visible "to the right" of it, `... | .*3 as
|
||||
$times_three | [. + $times_three] | ...`, but not "to the
|
||||
left". Consider this expression now, `... | (.*3 as
|
||||
$times_three | [.+ $times_three]) | ...`: here the binding
|
||||
`$times_three` is _not_ visible past the closing parenthesis.
|
||||
|
||||
- title: Reduce
|
||||
body: |
|
||||
|
||||
@@ -2505,18 +2338,10 @@ sections:
|
||||
(2 as $item | . + $item) |
|
||||
(1 as $item | . + $item)
|
||||
|
||||
If the reduction update expression outputs `empty` (that is,
|
||||
no values), then the reduction state is left as-is. For
|
||||
example, `reduce range(4) as $n ({}; if .==2 then empty else
|
||||
.[$n|tostring] |= $n)` will produce `{"0":0,"1":1,"3":3}`.
|
||||
|
||||
examples:
|
||||
- program: 'reduce .[] as $item (0; . + $item)'
|
||||
input: '[10,2,5,3]'
|
||||
output: ['20']
|
||||
- program: 'reduce .[] as $n ([]; if $n%2==0 then empty else . + [$n] end)'
|
||||
input: '[0,1,2,3,4,5]'
|
||||
output: ['[1,3,5]']
|
||||
|
||||
- title: "`limit(n; exp)`"
|
||||
body: |
|
||||
@@ -2669,30 +2494,13 @@ sections:
|
||||
that take a single input argument (e.g., `sin()`) are available as
|
||||
zero-argument jq functions. C math functions that take two input
|
||||
arguments (e.g., `pow()`) are available as two-argument jq
|
||||
functions that ignore `.`. C math functions that take three input
|
||||
arguments are available as three-argument jq functions that ignore
|
||||
`.`.
|
||||
functions that ignore `.`.
|
||||
|
||||
Availability of standard math functions depends on the
|
||||
availability of the corresponding math functions in your operating
|
||||
system and C math library. Unavailable math functions will be
|
||||
defined but will raise an error.
|
||||
|
||||
One-input C math functions: `acos` `acosh` `asin` `asinh` `atan`
|
||||
`atanh` `cbrt` `ceil` `cos` `cosh` `erf` `erfc` `exp` `exp10`
|
||||
`exp2` `expm1` `fabs` `floor` `gamma` `j0` `j1` `lgamma` `log`
|
||||
`log10` `log1p` `log2` `logb` `nearbyint` `pow10` `rint` `round`
|
||||
`significand` `sin` `sinh` `sqrt` `tan` `tanh` `tgamma` `trunc`
|
||||
`y0` `y1`.
|
||||
|
||||
Two-input C math functions: `atan2` `copysign` `drem` `fdim`
|
||||
`fmax` `fmin` `fmod` `frexp` `hypot` `jn` `ldexp` `modf`
|
||||
`nextafter` `nexttoward` `pow` `remainder` `scalb` `scalbln` `yn`.
|
||||
|
||||
Three-input C math functions: `fma`.
|
||||
|
||||
See your system's manual for more information on each of these.
|
||||
|
||||
- title: 'I/O'
|
||||
body: |
|
||||
|
||||
@@ -2709,10 +2517,6 @@ sections:
|
||||
application-specific behavior, such as for executables that use
|
||||
the libjq C API but aren't the jq executable itself.
|
||||
|
||||
Most jq builtins are referentially transparent, and yield constant
|
||||
and repeatable value streams when applied to constant inputs.
|
||||
This is not true of I/O builtins.
|
||||
|
||||
entries:
|
||||
- title: "`input`"
|
||||
body: |
|
||||
@@ -2758,11 +2562,11 @@ sections:
|
||||
|
||||
However, streaming isn't easy to deal with as the jq program will
|
||||
have `[<path>, <leaf-value>]` (and a few other forms) as inputs.
|
||||
|
||||
|
||||
Several builtins are provided to make handling streams easier.
|
||||
|
||||
The examples below use the streamed form of `[0,[1]]`, which is
|
||||
`[[0],0],[[1,0],1],[[1,0]],[[1]]`.
|
||||
The examples below use the the streamed form of `[0,[1]]`, which
|
||||
is `[[0],0],[[1,0],1],[[1,0]],[[1]]`.
|
||||
|
||||
Streaming forms include `[<path>, <leaf-value>]` (to indicate any
|
||||
scalar value, empty array, or empty object), and `[<path>]` (to
|
||||
@@ -2824,15 +2628,6 @@ sections:
|
||||
All the assignment operators in jq have path expressions on the
|
||||
left-hand side.
|
||||
|
||||
Values in jq are always immutable. Internally, assignment works
|
||||
by using a reduction to compute new, replacement values for `.` that
|
||||
have had all the desired assignments applied to `.`, then
|
||||
outputting the modified value. This might be made clear by this
|
||||
example: `{a:{b:{c:1}}} | (.a.b|=3), .`. This will output
|
||||
`{"a":{"b":3}}` and `{"a":{"b":{"c":1}}}` because the last
|
||||
sub-expression, `.`, sees the original value, not the modified
|
||||
value.
|
||||
|
||||
entries:
|
||||
- title: "`=`"
|
||||
body: |
|
||||
@@ -2900,12 +2695,8 @@ sections:
|
||||
not a valid or useful path expression in `.`); use `$var |
|
||||
.foo |= . + 1` instead.
|
||||
|
||||
If the right-hand side outputs no values (i.e., `empty`), then
|
||||
the left-hand side path will be deleted, as with `del(path)`.
|
||||
|
||||
If the right-hand side outputs multiple values, only the first
|
||||
one will be used (NOTE: it used to be that only the last one was
|
||||
used).
|
||||
If the right-hand side outputs multiple values, only the last
|
||||
one will be used.
|
||||
|
||||
examples:
|
||||
|
||||
@@ -3024,7 +2815,7 @@ sections:
|
||||
this time jq only uses the "search" key/value of the metadata.
|
||||
The metadata is also made available to users via the
|
||||
`modulemeta` builtin.
|
||||
|
||||
|
||||
The "search" key in the metadata, if present, should have a
|
||||
string or array value (array of strings); this is the search
|
||||
path to be prefixed to the top-level search path.
|
||||
@@ -3057,7 +2848,7 @@ sections:
|
||||
this time jq only uses the "search" key/value of the metadata.
|
||||
The metadata is also made available to users via the
|
||||
`modulemeta` builtin.
|
||||
|
||||
|
||||
The "search" key in the metadata, if present, should have a
|
||||
string or array value (array of strings); this is the search
|
||||
path to be prefixed to the top-level search path.
|
||||
|
||||
@@ -16,7 +16,7 @@ body: |
|
||||
Filters can be combined in various ways - you can pipe the output of
|
||||
one filter into another filter, or collect the output of a filter
|
||||
into an array.
|
||||
|
||||
|
||||
Some filters produce multiple results, for instance there's one that
|
||||
produces all the elements of its input array. Piping that filter
|
||||
into a second runs the second filter for each element of the
|
||||
@@ -50,7 +50,7 @@ manpage_intro: |
|
||||
By default, `jq` reads a stream of JSON objects (whitespace
|
||||
separated) from `stdin`. One or more <files> may be specified, in
|
||||
which case `jq` will read input from those instead.
|
||||
|
||||
|
||||
The <options> are described in the [INVOKING JQ] section, they
|
||||
mostly concern input and output formatting. The <filter> is written
|
||||
in the jq language and specifies how to transform the input
|
||||
@@ -68,11 +68,11 @@ manpage_epilogue: |
|
||||
## AUTHOR
|
||||
|
||||
Stephen Dolan `<mu@netsoc.tcd.ie>`
|
||||
|
||||
|
||||
sections:
|
||||
- title: Invoking jq
|
||||
body: |
|
||||
|
||||
|
||||
jq filters run on a stream of JSON data. The input to jq is
|
||||
parsed as a sequence of whitespace-separated JSON values which
|
||||
are passed through the provided filter one at a time. The
|
||||
@@ -83,46 +83,46 @@ sections:
|
||||
using some command-line options:
|
||||
|
||||
* `--slurp`/`-s`:
|
||||
|
||||
|
||||
Instead of running the filter for each JSON object in the
|
||||
input, read the entire input stream into a large array and run
|
||||
the filter just once.
|
||||
|
||||
|
||||
* `--raw-input`/`-R`:
|
||||
|
||||
|
||||
Don't parse the input as JSON. Instead, each line of text is
|
||||
passed to the filter as a string. If combined with `--slurp`,
|
||||
then the entire input is passed to the filter as a single long
|
||||
string.
|
||||
|
||||
|
||||
* `--null-input`/`-n`:
|
||||
|
||||
|
||||
Don't read any input at all! Instead, the filter is run once
|
||||
using `null` as the input. This is useful when using jq as a
|
||||
simple calculator or to construct JSON data from scratch.
|
||||
|
||||
|
||||
* `--compact-output` / `-c`:
|
||||
|
||||
|
||||
By default, jq pretty-prints JSON output. Using this option
|
||||
will result in more compact output by instead putting each
|
||||
JSON object on a single line.
|
||||
|
||||
* `--color-output` / `-C` and `--monochrome-output` / `-M`:
|
||||
|
||||
|
||||
* `--colour-output` / `-C` and `--monochrome-output` / `-M`:
|
||||
|
||||
By default, jq outputs colored JSON if writing to a
|
||||
terminal. You can force it to produce color even if writing to
|
||||
a pipe or a file using `-C`, and disable color with `-M`.
|
||||
|
||||
|
||||
* `--ascii-output` / `-a`:
|
||||
|
||||
|
||||
jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
|
||||
if the input specified them as escape sequences (like
|
||||
"\u03bc"). Using this option, you can force jq to produce pure
|
||||
ASCII output with every non-ASCII character replaced with the
|
||||
equivalent escape sequence.
|
||||
|
||||
|
||||
* `--raw-output` / `-r`:
|
||||
|
||||
|
||||
With this option, if the filter's result is a string then it
|
||||
will be written directly to standard output rather than being
|
||||
formatted as a JSON string with quotes. This can be useful for
|
||||
@@ -138,7 +138,7 @@ sections:
|
||||
entries:
|
||||
- title: "`.`"
|
||||
body: |
|
||||
|
||||
|
||||
The absolute simplest (and least interesting) filter
|
||||
is `.`. This is a filter that takes its input and
|
||||
produces it unchanged as output.
|
||||
@@ -154,7 +154,7 @@ sections:
|
||||
|
||||
- title: "`.foo`"
|
||||
body: |
|
||||
|
||||
|
||||
The simplest *useful* filter is .foo. When given a
|
||||
JSON object (aka dictionary or hash) as input, it produces
|
||||
the value at the key "foo", or null if there's none present.
|
||||
@@ -169,7 +169,7 @@ sections:
|
||||
|
||||
- title: "`.[foo]`, `.[2]`, `.[10:15]`"
|
||||
body: |
|
||||
|
||||
|
||||
You can also look up fields of an object using syntax like
|
||||
`.["foo"]` (.foo above is a shorthand version of this). This
|
||||
one works for arrays as well, if the key is an
|
||||
@@ -195,7 +195,7 @@ sections:
|
||||
- program: '.[2:4]'
|
||||
input: '["a","b","c","d","e"]'
|
||||
output: ['["c", "d"]']
|
||||
|
||||
|
||||
- program: '.[:3]'
|
||||
input: '["a","b","c","d","e"]'
|
||||
output: ['["a", "b", "c"]']
|
||||
@@ -206,7 +206,7 @@ sections:
|
||||
|
||||
- title: "`.[]`"
|
||||
body: |
|
||||
|
||||
|
||||
If you use the `.[foo]` syntax, but omit the index
|
||||
entirely, it will return *all* of the elements of an
|
||||
array. Running `.[]` with the input `[1,2,3]` will produce the
|
||||
@@ -233,7 +233,7 @@ sections:
|
||||
|
||||
- title: "`,`"
|
||||
body: |
|
||||
|
||||
|
||||
If two filters are separated by a comma, then the
|
||||
input will be fed into both and there will be multiple
|
||||
outputs: first, all of the outputs produced by the left
|
||||
@@ -248,18 +248,18 @@ sections:
|
||||
|
||||
- program: ".user, .projects[]"
|
||||
input: '{"user":"stedolan", "projects": ["jq", "wikiflow"]}'
|
||||
output: ['"stedolan"', '"jq"', '"wikiflow"']
|
||||
|
||||
output: ['"stedolan"', '"jq"', '"wikiflow"']
|
||||
|
||||
- program: '.[4,2]'
|
||||
input: '["a","b","c","d","e"]'
|
||||
output: ['"e"', '"c"']
|
||||
|
||||
|
||||
- title: "`|`"
|
||||
body: |
|
||||
The | operator combines two filters by feeding the output(s) of
|
||||
the one on the left into the input of the one on the right. It's
|
||||
pretty much the same as the Unix shell's pipe, if you're used to
|
||||
that.
|
||||
that.
|
||||
|
||||
If the one on the left produces multiple results, the one on
|
||||
the right will be run for each of those results. So, the
|
||||
@@ -273,7 +273,7 @@ sections:
|
||||
|
||||
- title: Types and Values
|
||||
body: |
|
||||
|
||||
|
||||
jq supports the same set of datatypes as JSON - numbers,
|
||||
strings, booleans, arrays, objects (which in JSON-speak are
|
||||
hashes with only string keys), and "null".
|
||||
@@ -287,7 +287,7 @@ sections:
|
||||
entries:
|
||||
- title: Array construction - `[]`
|
||||
body: |
|
||||
|
||||
|
||||
As in JSON, `[]` is used to construct arrays, as in
|
||||
`[1,2,3]`. The elements of the arrays can be any jq
|
||||
expression. All of the results produced by all of the
|
||||
@@ -295,7 +295,7 @@ sections:
|
||||
to construct an array out of a known quantity of values (as
|
||||
in `[.foo, .bar, .baz]`) or to "collect" all the results of a
|
||||
filter into an array (as in `[.items[].name]`)
|
||||
|
||||
|
||||
Once you understand the "," operator, you can look at jq's array
|
||||
syntax in a different light: the expression `[1,2,3]` is not using a
|
||||
built-in syntax for comma-separated arrays, but is instead applying
|
||||
@@ -315,49 +315,49 @@ sections:
|
||||
|
||||
Like JSON, `{}` is for constructing objects (aka
|
||||
dictionaries or hashes), as in: `{"a": 42, "b": 17}`.
|
||||
|
||||
|
||||
If the keys are "sensible" (all alphabetic characters), then
|
||||
the quotes can be left off. The value can be any expression
|
||||
(although you may need to wrap it in parentheses if it's a
|
||||
complicated one), which gets applied to the {} expression's
|
||||
input (remember, all filters have an input and an
|
||||
output).
|
||||
|
||||
|
||||
{foo: .bar}
|
||||
|
||||
|
||||
will produce the JSON object `{"foo": 42}` if given the JSON
|
||||
object `{"bar":42, "baz":43}`. You can use this to select
|
||||
particular fields of an object: if the input is an object
|
||||
with "user", "title", "id", and "content" fields and you
|
||||
just want "user" and "title", you can write
|
||||
|
||||
|
||||
{user: .user, title: .title}
|
||||
|
||||
|
||||
Because that's so common, there's a shortcut syntax: `{user, title}`.
|
||||
|
||||
|
||||
If one of the expressions produces multiple results,
|
||||
multiple dictionaries will be produced. If the input's
|
||||
|
||||
|
||||
{"user":"stedolan","titles":["JQ Primer", "More JQ"]}
|
||||
|
||||
|
||||
then the expression
|
||||
|
||||
|
||||
{user, title: .titles[]}
|
||||
|
||||
will produce two outputs:
|
||||
|
||||
|
||||
will produce two outputs:
|
||||
|
||||
{"user":"stedolan", "title": "JQ Primer"}
|
||||
{"user":"stedolan", "title": "More JQ"}
|
||||
|
||||
|
||||
Putting parentheses around the key means it will be evaluated as an
|
||||
expression. With the same input as above,
|
||||
|
||||
|
||||
{(.user): .titles}
|
||||
|
||||
|
||||
produces
|
||||
|
||||
|
||||
{"stedolan": ["JQ Primer", "More JQ"]}
|
||||
|
||||
|
||||
examples:
|
||||
- program: '{user, title: .titles[]}'
|
||||
input: '{"user":"stedolan","titles":["JQ Primer", "More JQ"]}'
|
||||
@@ -376,7 +376,7 @@ sections:
|
||||
etc.). However, jq never does implicit type conversions. If you
|
||||
try to add a string to an object you'll get an error message and
|
||||
no result.
|
||||
|
||||
|
||||
entries:
|
||||
- title: Addition - `+`
|
||||
body: |
|
||||
@@ -390,12 +390,12 @@ sections:
|
||||
- **Arrays** are added by being concatenated into a larger array.
|
||||
|
||||
- **Strings** are added by being joined into a larger string.
|
||||
|
||||
|
||||
- **Objects** are added by merging, that is, inserting all
|
||||
the key-value pairs from both objects into a single
|
||||
combined object. If both objects contain a value for the
|
||||
same key, the object on the right of the `+` wins.
|
||||
|
||||
|
||||
`null` can be added to any value, and returns the other
|
||||
value unchanged.
|
||||
|
||||
@@ -464,7 +464,7 @@ sections:
|
||||
|
||||
- title: `keys`
|
||||
body: |
|
||||
|
||||
|
||||
The builtin function `keys`, when given an object, returns
|
||||
its keys in an array.
|
||||
|
||||
@@ -487,7 +487,7 @@ sections:
|
||||
|
||||
- title: `has`
|
||||
body: |
|
||||
|
||||
|
||||
The builtin function `has` returns whether the input object
|
||||
has the given key, or the input array has an element at the
|
||||
given index.
|
||||
@@ -506,11 +506,11 @@ sections:
|
||||
|
||||
- title: `to_entries`, `from_entries`, `with_entries`
|
||||
body: |
|
||||
|
||||
|
||||
These functions convert between an object and an array of
|
||||
key-value pairs. If `to_entries` is passed an object, then
|
||||
for each `k: v` entry in the input, the output array
|
||||
includes `{"key": k, "value": v}`.
|
||||
includes `{"key": k, "value": v}`.
|
||||
|
||||
`from_entries` does the opposite conversion, and
|
||||
`with_entries(foo)` is a shorthand for `to_entries |
|
||||
@@ -531,7 +531,7 @@ sections:
|
||||
|
||||
- title: `select`
|
||||
body: |
|
||||
|
||||
|
||||
The function `select(foo)` produces its input unchanged if
|
||||
`foo` returns true for that input, and produces no output
|
||||
otherwise.
|
||||
@@ -546,7 +546,7 @@ sections:
|
||||
|
||||
- title: `empty`
|
||||
body: |
|
||||
|
||||
|
||||
`empty` returns no results. None at all. Not even `null`.
|
||||
|
||||
It's useful on occasion. You'll know if you need it :)
|
||||
@@ -598,10 +598,10 @@ sections:
|
||||
|
||||
- title: `range`
|
||||
body: |
|
||||
|
||||
|
||||
The `range` function produces a range of numbers. `range(4;10)`
|
||||
produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
|
||||
are produced as separate outputs. Use `[range(4;10)]` to get a range as
|
||||
are produced as separate outputs. Use `[range(4;10)]` to get a range as
|
||||
an array.
|
||||
|
||||
examples:
|
||||
@@ -611,7 +611,7 @@ sections:
|
||||
- program: '[range(2;4)]'
|
||||
input: 'null'
|
||||
output: ['[2,3]']
|
||||
|
||||
|
||||
- title: `tonumber`
|
||||
body: |
|
||||
|
||||
@@ -638,7 +638,7 @@ sections:
|
||||
|
||||
- title: `type`
|
||||
body: |
|
||||
|
||||
|
||||
The `type` function returns the type of its argument as a
|
||||
string, which is one of null, boolean, number, string, array
|
||||
or object.
|
||||
@@ -650,7 +650,7 @@ sections:
|
||||
|
||||
- title: `sort, sort_by`
|
||||
body: |
|
||||
|
||||
|
||||
The `sort` functions sorts its input, which must be an
|
||||
array. Values are sorted in the following order:
|
||||
|
||||
@@ -682,7 +682,7 @@ sections:
|
||||
|
||||
- title: `group_by`
|
||||
body: |
|
||||
|
||||
|
||||
`group_by(.foo)` takes as input an array, groups the
|
||||
elements having the same `.foo` field into separate arrays,
|
||||
and produces all of these arrays as elements of a larger
|
||||
@@ -699,7 +699,7 @@ sections:
|
||||
|
||||
- title: `min`, `max`, `min_by`, `max_by`
|
||||
body: |
|
||||
|
||||
|
||||
Find the minimum or maximum element of the input array. The
|
||||
`_by` versions allow you to specify a particular field or
|
||||
property to examine, e.g. `min_by(.foo)` finds the object
|
||||
@@ -715,7 +715,7 @@ sections:
|
||||
|
||||
- title: `unique`
|
||||
body: |
|
||||
|
||||
|
||||
The `unique` function takes as input an array and produces
|
||||
an array of the same elements, in sorted order, with
|
||||
duplicates removed.
|
||||
@@ -727,7 +727,7 @@ sections:
|
||||
|
||||
- title: `reverse`
|
||||
body: |
|
||||
|
||||
|
||||
This function reverses an array.
|
||||
|
||||
examples:
|
||||
@@ -766,7 +766,7 @@ sections:
|
||||
|
||||
- title: `recurse`
|
||||
body: |
|
||||
|
||||
|
||||
The `recurse` function allows you to search through a
|
||||
recursive structure, and extract interesting data from all
|
||||
levels. Suppose your input represents a filesystem:
|
||||
@@ -778,7 +778,7 @@ sections:
|
||||
{"name": "/home", "children": [
|
||||
{"name": "/home/stephen", "children": [
|
||||
{"name": "/home/stephen/jq", "children": []}]}]}]}
|
||||
|
||||
|
||||
Now suppose you want to extract all of the filenames
|
||||
present. You need to retrieve `.name`, `.children[].name`,
|
||||
`.children[].children[].name`, and so on. You can do this
|
||||
@@ -789,7 +789,7 @@ sections:
|
||||
examples:
|
||||
- program: 'recurse(.foo[])'
|
||||
input: '{"foo":[{"foo": []}, {"foo":[{"foo":[]}]}]}'
|
||||
output:
|
||||
output:
|
||||
- '{"foo":[{"foo":[]},{"foo":[{"foo":[]}]}]}'
|
||||
- '{"foo":[]}'
|
||||
- '{"foo":[{"foo":[]}]}'
|
||||
@@ -807,7 +807,7 @@ sections:
|
||||
- program: '"The input was \(.), which is one less than \(.+1)"'
|
||||
input: '42'
|
||||
output: ['"The input was 42, which is one less than 43"']
|
||||
|
||||
|
||||
- title: "Format strings and escaping"
|
||||
body: |
|
||||
|
||||
@@ -836,17 +836,17 @@ sections:
|
||||
characters to a `%xx` sequence.
|
||||
|
||||
* `@csv`:
|
||||
|
||||
|
||||
The input must be an array, and it is rendered as CSV
|
||||
with double quotes for strings, and quotes escaped by
|
||||
repetition.
|
||||
|
||||
* `@sh`:
|
||||
|
||||
|
||||
The input is escaped suitable for use in a command-line
|
||||
for a POSIX shell. If the input is an array, the output
|
||||
will be a series of space-separated strings.
|
||||
|
||||
|
||||
* `@base64`:
|
||||
|
||||
The input is converted to base64 as specified by RFC 4648.
|
||||
@@ -879,7 +879,7 @@ sections:
|
||||
- program: '@sh "echo \(.)"'
|
||||
input: "\"O'Hara's Ale\""
|
||||
output: ["\"echo 'O'\\\\''Hara'\\\\''s Ale'\""]
|
||||
|
||||
|
||||
- title: Conditionals and Comparisons
|
||||
entries:
|
||||
- title: `==`, `!=`
|
||||
@@ -891,7 +891,7 @@ sections:
|
||||
to numbers. If you're coming from Javascript, jq's == is like
|
||||
Javascript's === - considering values equal only when they have the
|
||||
same type as well as the same value.
|
||||
|
||||
|
||||
!= is "not equal", and 'a != b' returns the opposite value of 'a == b'
|
||||
|
||||
examples:
|
||||
@@ -904,7 +904,7 @@ sections:
|
||||
`if A then B else C end` will act the same as `B` if `A`
|
||||
produces a value other than false or null, but act the same
|
||||
as `C` otherwise.
|
||||
|
||||
|
||||
Checking for false or null is a simpler notion of
|
||||
"truthiness" than is found in Javascript or Python, but it
|
||||
means that you'll sometimes have to be more explicit about
|
||||
@@ -912,11 +912,11 @@ sections:
|
||||
string is empty using `if .name then A else B end`, you'll
|
||||
need something more like `if (.name | count) > 0 then A else
|
||||
B end` instead.
|
||||
|
||||
If the condition `A` produces multiple results, then `B` is evaluated
|
||||
once for each result that is not false or null, and `C` is evaluated
|
||||
once for each false or null.
|
||||
|
||||
|
||||
If the condition A produces multiple results, it is
|
||||
considered "true" if any of those results is not false or
|
||||
null. If it produces zero results, it's considered false.
|
||||
|
||||
More cases can be added to an if using `elif A then B` syntax.
|
||||
|
||||
examples:
|
||||
@@ -930,10 +930,10 @@ sections:
|
||||
end
|
||||
input: 2
|
||||
output: ['"many"']
|
||||
|
||||
|
||||
- title: `>, >=, <=, <`
|
||||
body: |
|
||||
|
||||
|
||||
The comparison operators `>`, `>=`, `<=`, `<` return whether
|
||||
their left argument is greater than, greater than or equal
|
||||
to, less than or equal to or less than their right argument
|
||||
@@ -960,14 +960,14 @@ sections:
|
||||
so it is called as a filter to which things can be piped
|
||||
rather than with special syntax, as in `.foo and .bar |
|
||||
not`.
|
||||
|
||||
|
||||
These three only produce the values "true" and "false", and
|
||||
so are only useful for genuine Boolean operations, rather
|
||||
than the common Perl/Python/Ruby idiom of
|
||||
"value_that_may_be_null or default". If you want to use this
|
||||
form of "or", picking between two values rather than
|
||||
evaluating a condition, see the "//" operator below.
|
||||
|
||||
|
||||
examples:
|
||||
- program: '42 and "a string"'
|
||||
input: 'null'
|
||||
@@ -1005,7 +1005,7 @@ sections:
|
||||
- program: '.foo // 42'
|
||||
input: '{}'
|
||||
output: [42]
|
||||
|
||||
|
||||
- title: Advanced features
|
||||
body: |
|
||||
Variables are an absolute necessity in most programming languages, but
|
||||
@@ -1030,67 +1030,67 @@ sections:
|
||||
entries:
|
||||
- title: Variables
|
||||
body: |
|
||||
|
||||
|
||||
In jq, all filters have an input and an output, so manual
|
||||
plumbing is not necessary to pass a value from one part of a program
|
||||
to the next. Many expressions, for instance `a + b`, pass their input
|
||||
to two distinct subexpressions (here `a` and `b` are both passed the
|
||||
same input), so variables aren't usually necessary in order to use a
|
||||
value twice.
|
||||
|
||||
|
||||
For instance, calculating the average value of an array of numbers
|
||||
requires a few variables in most languages - at least one to hold the
|
||||
array, perhaps one for each element or for a loop counter. In jq, it's
|
||||
simply `add / length` - the `add` expression is given the array and
|
||||
produces its sum, and the `length` expression is given the array and
|
||||
produces its length.
|
||||
|
||||
|
||||
So, there's generally a cleaner way to solve most problems in jq that
|
||||
defining variables. Still, sometimes they do make things easier, so jq
|
||||
lets you define variables using `expression as $variable`. All
|
||||
variable names start with `$`. Here's a slightly uglier version of the
|
||||
array-averaging example:
|
||||
|
||||
|
||||
length as $array_length | add / $array_length
|
||||
|
||||
|
||||
We'll need a more complicated problem to find a situation where using
|
||||
variables actually makes our lives easier.
|
||||
|
||||
|
||||
|
||||
|
||||
Suppose we have an array of blog posts, with "author" and "title"
|
||||
fields, and another object which is used to map author usernames to
|
||||
real names. Our input looks like:
|
||||
|
||||
|
||||
{"posts": [{"title": "Frist psot", "author": "anon"},
|
||||
{"title": "A well-written article", "author": "person1"}],
|
||||
"realnames": {"anon": "Anonymous Coward",
|
||||
"person1": "Person McPherson"}}
|
||||
|
||||
|
||||
We want to produce the posts with the author field containing a real
|
||||
name, as in:
|
||||
|
||||
|
||||
{"title": "Frist psot", "author": "Anonymous Coward"}
|
||||
{"title": "A well-written article", "author": "Person McPherson"}
|
||||
|
||||
|
||||
We use a variable, $names, to store the realnames object, so that we
|
||||
can refer to it later when looking up author usernames:
|
||||
|
||||
|
||||
.realnames as $names | .posts[] | {title, author: $names[.author]}
|
||||
|
||||
|
||||
The expression `exp as $x | ...` means: for each value of expression
|
||||
`exp`, run the rest of the pipeline with the entire original input, and
|
||||
with `$x` set to that value. Thus `as` functions as something of a
|
||||
with `$x` set to that value. Thus `as` functions as something of a
|
||||
foreach loop.
|
||||
|
||||
Variables are scoped over the rest of the expression that defines
|
||||
them, so
|
||||
|
||||
them, so
|
||||
|
||||
.realnames as $names | (.posts[] | {title, author: $names[.author]})
|
||||
|
||||
will work, but
|
||||
|
||||
|
||||
will work, but
|
||||
|
||||
(.realnames as $names | .posts[]) | {title, author: $names[.author]}
|
||||
|
||||
|
||||
won't.
|
||||
|
||||
examples:
|
||||
@@ -1100,11 +1100,11 @@ sections:
|
||||
|
||||
- title: 'Defining Functions'
|
||||
body: |
|
||||
|
||||
|
||||
You can give a filter a name using "def" syntax:
|
||||
|
||||
def increment: . + 1;
|
||||
|
||||
|
||||
From then on, `increment` is usable as a filter just like a
|
||||
builtin function (in fact, this is how some of the builtins
|
||||
are defined). A function may take arguments:
|
||||
@@ -1135,19 +1135,19 @@ sections:
|
||||
|
||||
- title: Reduce
|
||||
body: |
|
||||
|
||||
|
||||
The `reduce` syntax in jq allows you to combine all of the
|
||||
results of an expression by accumulating them into a single
|
||||
answer. As an example, we'll pass `[3,2,1]` to this expression:
|
||||
|
||||
reduce .[] as $item (0; . + $item)
|
||||
|
||||
|
||||
For each result that `.[]` produces, `. + $item` is run to
|
||||
accumulate a running total, starting from 0. In this
|
||||
example, `.[]` produces the results 3, 2, and 1, so the
|
||||
effect is similar to running something like this:
|
||||
|
||||
0 | (3 as $item | . + $item) |
|
||||
0 | (3 as $item | . + $item) |
|
||||
(2 as $item | . + $item) |
|
||||
(1 as $item | . + $item)
|
||||
|
||||
@@ -1155,7 +1155,7 @@ sections:
|
||||
- program: 'reduce .[] as $item (0; . + $item)'
|
||||
input: '[10,2,5,3]'
|
||||
output: ['20']
|
||||
|
||||
|
||||
|
||||
- title: Assignment
|
||||
body: |
|
||||
@@ -1177,14 +1177,14 @@ sections:
|
||||
entries:
|
||||
- title: "`=`"
|
||||
body: |
|
||||
|
||||
|
||||
The filter `.foo = 1` will take as input an object
|
||||
and produce as output an object with the "foo" field set to
|
||||
1. There is no notion of "modifying" or "changing" something
|
||||
in jq - all jq values are immutable. For instance,
|
||||
|
||||
|
||||
.foo = .bar | .foo.baz = 1
|
||||
|
||||
|
||||
will not have the side-effect of setting .bar.baz to be set
|
||||
to 1, as the similar-looking program in Javascript, Python,
|
||||
Ruby or other languages would. Unlike these languages (but
|
||||
@@ -1193,7 +1193,7 @@ sections:
|
||||
"the same object". They can be equal, or not equal, but if
|
||||
we change one of them in no circumstances will the other
|
||||
change behind our backs.
|
||||
|
||||
|
||||
This means that it's impossible to build circular values in
|
||||
jq (such as an array whose first element is itself). This is
|
||||
quite intentional, and ensures that anything a jq program
|
||||
@@ -1206,14 +1206,14 @@ sections:
|
||||
works out the new value for the property being assigned to by running
|
||||
the old value through this expression. For instance, .foo |= .+1 will
|
||||
build an object with the "foo" field set to the input's "foo" plus 1.
|
||||
|
||||
|
||||
This example should show the difference between '=' and '|=':
|
||||
|
||||
|
||||
Provide input '{"a": {"b": 10}, "b": 20}' to the programs:
|
||||
|
||||
|
||||
.a = .b
|
||||
.a |= .b
|
||||
|
||||
|
||||
The former will set the "a" field of the input to the "b" field of the
|
||||
input, and produce the output {"a": 20}. The latter will set the "a"
|
||||
field of the input to the "a" field's "b" field, producing {"a": 10}.
|
||||
@@ -1228,43 +1228,43 @@ sections:
|
||||
- program: .foo += 1
|
||||
input: '{"foo": 42}'
|
||||
output: ['{"foo": 43}']
|
||||
|
||||
|
||||
- title: Complex assignments
|
||||
body: |
|
||||
Lots more things are allowed on the left-hand side of a jq assignment
|
||||
than in most langauges. We've already seen simple field accesses on
|
||||
the left hand side, and it's no surprise that array accesses work just
|
||||
as well:
|
||||
|
||||
|
||||
.posts[0].title = "JQ Manual"
|
||||
|
||||
|
||||
What may come as a surprise is that the expression on the left may
|
||||
produce multiple results, referring to different points in the input
|
||||
document:
|
||||
|
||||
|
||||
.posts[].comments |= . + ["this is great"]
|
||||
|
||||
|
||||
That example appends the string "this is great" to the "comments"
|
||||
array of each post in the input (where the input is an object with a
|
||||
field "posts" which is an array of posts).
|
||||
|
||||
|
||||
When jq encounters an assignment like 'a = b', it records the "path"
|
||||
taken to select a part of the input document while executing a. This
|
||||
path is then used to find which part of the input to change while
|
||||
executing the assignment. Any filter may be used on the
|
||||
left-hand side of an equals - whichever paths it selects from the
|
||||
input will be where the assignment is performed.
|
||||
|
||||
|
||||
This is a very powerful operation. Suppose we wanted to add a comment
|
||||
to blog posts, using the same "blog" input above. This time, we only
|
||||
want to comment on the posts written by "stedolan". We can find those
|
||||
posts using the "select" function described earlier:
|
||||
|
||||
|
||||
.posts[] | select(.author == "stedolan")
|
||||
|
||||
|
||||
The paths provided by this operation point to each of the posts that
|
||||
"stedolan" wrote, and we can comment on each of them in the same way
|
||||
that we did before:
|
||||
|
||||
|
||||
(.posts[] | select(.author == "stedolan") | .comments) |=
|
||||
. + ["terrible."]
|
||||
@@ -16,7 +16,7 @@ body: |
|
||||
Filters can be combined in various ways - you can pipe the output of
|
||||
one filter into another filter, or collect the output of a filter
|
||||
into an array.
|
||||
|
||||
|
||||
Some filters produce multiple results, for instance there's one that
|
||||
produces all the elements of its input array. Piping that filter
|
||||
into a second runs the second filter for each element of the
|
||||
@@ -50,7 +50,7 @@ manpage_intro: |
|
||||
By default, `jq` reads a stream of JSON objects (whitespace
|
||||
separated) from `stdin`. One or more <files> may be specified, in
|
||||
which case `jq` will read input from those instead.
|
||||
|
||||
|
||||
The <options> are described in the [INVOKING JQ] section, they
|
||||
mostly concern input and output formatting. The <filter> is written
|
||||
in the jq language and specifies how to transform the input
|
||||
@@ -68,11 +68,11 @@ manpage_epilogue: |
|
||||
## AUTHOR
|
||||
|
||||
Stephen Dolan `<mu@netsoc.tcd.ie>`
|
||||
|
||||
|
||||
sections:
|
||||
- title: Invoking jq
|
||||
body: |
|
||||
|
||||
|
||||
jq filters run on a stream of JSON data. The input to jq is
|
||||
parsed as a sequence of whitespace-separated JSON values which
|
||||
are passed through the provided filter one at a time. The
|
||||
@@ -98,44 +98,44 @@ sections:
|
||||
Output the jq version and exit with zero.
|
||||
|
||||
* `--slurp`/`-s`:
|
||||
|
||||
|
||||
Instead of running the filter for each JSON object in the
|
||||
input, read the entire input stream into a large array and run
|
||||
the filter just once.
|
||||
|
||||
* `--online-input`/`-I`:
|
||||
|
||||
|
||||
When the top-level input value is an array produce its elements
|
||||
instead of the array. This allows on-line processing of
|
||||
potentially very large top-level arrays' elements.
|
||||
|
||||
|
||||
* `--raw-input`/`-R`:
|
||||
|
||||
|
||||
Don't parse the input as JSON. Instead, each line of text is
|
||||
passed to the filter as a string. If combined with `--slurp`,
|
||||
then the entire input is passed to the filter as a single long
|
||||
string.
|
||||
|
||||
|
||||
* `--null-input`/`-n`:
|
||||
|
||||
|
||||
Don't read any input at all! Instead, the filter is run once
|
||||
using `null` as the input. This is useful when using jq as a
|
||||
simple calculator or to construct JSON data from scratch.
|
||||
|
||||
|
||||
* `--compact-output` / `-c`:
|
||||
|
||||
|
||||
By default, jq pretty-prints JSON output. Using this option
|
||||
will result in more compact output by instead putting each
|
||||
JSON object on a single line.
|
||||
|
||||
* `--color-output` / `-C` and `--monochrome-output` / `-M`:
|
||||
|
||||
|
||||
* `--colour-output` / `-C` and `--monochrome-output` / `-M`:
|
||||
|
||||
By default, jq outputs colored JSON if writing to a
|
||||
terminal. You can force it to produce color even if writing to
|
||||
a pipe or a file using `-C`, and disable color with `-M`.
|
||||
|
||||
|
||||
* `--ascii-output` / `-a`:
|
||||
|
||||
|
||||
jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
|
||||
if the input specified them as escape sequences (like
|
||||
"\u03bc"). Using this option, you can force jq to produce pure
|
||||
@@ -149,11 +149,11 @@ sections:
|
||||
output elsewhere).
|
||||
|
||||
* `--sort-keys` / `-S`:
|
||||
|
||||
|
||||
Output the fields of each object with the keys in sorted order.
|
||||
|
||||
* `--raw-output` / `-r`:
|
||||
|
||||
|
||||
With this option, if the filter's result is a string then it
|
||||
will be written directly to standard output rather than being
|
||||
formatted as a JSON string with quotes. This can be useful for
|
||||
@@ -191,7 +191,7 @@ sections:
|
||||
entries:
|
||||
- title: "`.`"
|
||||
body: |
|
||||
|
||||
|
||||
The absolute simplest (and least interesting) filter
|
||||
is `.`. This is a filter that takes its input and
|
||||
produces it unchanged as output.
|
||||
@@ -207,7 +207,7 @@ sections:
|
||||
|
||||
- title: "`.foo`, `.foo.bar`"
|
||||
body: |
|
||||
|
||||
|
||||
The simplest *useful* filter is `.foo`. When given a
|
||||
JSON object (aka dictionary or hash) as input, it produces
|
||||
the value at the key "foo", or null if there's none present.
|
||||
@@ -216,7 +216,7 @@ sections:
|
||||
it with double quotes like this: `."foo$"`.
|
||||
|
||||
A filter of the form `.foo.bar` is equivalent to `.foo|.bar`.
|
||||
|
||||
|
||||
examples:
|
||||
- program: '.foo'
|
||||
input: '{"foo": 42, "bar": "less interesting data"}'
|
||||
@@ -230,7 +230,7 @@ sections:
|
||||
|
||||
- title: "`.foo?`"
|
||||
body: |
|
||||
|
||||
|
||||
Just like `.foo`, but does not output even an error when `.`
|
||||
is not an array or an object.
|
||||
|
||||
@@ -250,7 +250,7 @@ sections:
|
||||
|
||||
- title: "`.[<string>]`, `.[2]`, `.[10:15]`"
|
||||
body: |
|
||||
|
||||
|
||||
You can also look up fields of an object using syntax like
|
||||
`.["foo"]` (.foo above is a shorthand version of this). This
|
||||
one works for arrays as well, if the key is an
|
||||
@@ -285,7 +285,7 @@ sections:
|
||||
- program: '.[2:4]'
|
||||
input: '"abcdefghi"'
|
||||
output: ['"cd"']
|
||||
|
||||
|
||||
- program: '.[:3]'
|
||||
input: '["a","b","c","d","e"]'
|
||||
output: ['["a", "b", "c"]']
|
||||
@@ -296,7 +296,7 @@ sections:
|
||||
|
||||
- title: "`.[]`"
|
||||
body: |
|
||||
|
||||
|
||||
If you use the `.[index]` syntax, but omit the index
|
||||
entirely, it will return *all* of the elements of an
|
||||
array. Running `.[]` with the input `[1,2,3]` will produce the
|
||||
@@ -323,13 +323,13 @@ sections:
|
||||
|
||||
- title: "`.[]?`"
|
||||
body: |
|
||||
|
||||
|
||||
Like `.[]`, but no errors will be output if . is not an array
|
||||
or object.
|
||||
|
||||
- title: "`,`"
|
||||
body: |
|
||||
|
||||
|
||||
If two filters are separated by a comma, then the
|
||||
input will be fed into both and there will be multiple
|
||||
outputs: first, all of the outputs produced by the left
|
||||
@@ -344,18 +344,18 @@ sections:
|
||||
|
||||
- program: ".user, .projects[]"
|
||||
input: '{"user":"stedolan", "projects": ["jq", "wikiflow"]}'
|
||||
output: ['"stedolan"', '"jq"', '"wikiflow"']
|
||||
|
||||
output: ['"stedolan"', '"jq"', '"wikiflow"']
|
||||
|
||||
- program: '.[4,2]'
|
||||
input: '["a","b","c","d","e"]'
|
||||
output: ['"e"', '"c"']
|
||||
|
||||
|
||||
- title: "`|`"
|
||||
body: |
|
||||
The | operator combines two filters by feeding the output(s) of
|
||||
the one on the left into the input of the one on the right. It's
|
||||
pretty much the same as the Unix shell's pipe, if you're used to
|
||||
that.
|
||||
that.
|
||||
|
||||
If the one on the left produces multiple results, the one on
|
||||
the right will be run for each of those results. So, the
|
||||
@@ -369,7 +369,7 @@ sections:
|
||||
|
||||
- title: Types and Values
|
||||
body: |
|
||||
|
||||
|
||||
jq supports the same set of datatypes as JSON - numbers,
|
||||
strings, booleans, arrays, objects (which in JSON-speak are
|
||||
hashes with only string keys), and "null".
|
||||
@@ -383,7 +383,7 @@ sections:
|
||||
entries:
|
||||
- title: Array construction - `[]`
|
||||
body: |
|
||||
|
||||
|
||||
As in JSON, `[]` is used to construct arrays, as in
|
||||
`[1,2,3]`. The elements of the arrays can be any jq
|
||||
expression. All of the results produced by all of the
|
||||
@@ -391,7 +391,7 @@ sections:
|
||||
to construct an array out of a known quantity of values (as
|
||||
in `[.foo, .bar, .baz]`) or to "collect" all the results of a
|
||||
filter into an array (as in `[.items[].name]`)
|
||||
|
||||
|
||||
Once you understand the "," operator, you can look at jq's array
|
||||
syntax in a different light: the expression `[1,2,3]` is not using a
|
||||
built-in syntax for comma-separated arrays, but is instead applying
|
||||
@@ -411,49 +411,49 @@ sections:
|
||||
|
||||
Like JSON, `{}` is for constructing objects (aka
|
||||
dictionaries or hashes), as in: `{"a": 42, "b": 17}`.
|
||||
|
||||
|
||||
If the keys are "sensible" (all alphabetic characters), then
|
||||
the quotes can be left off. The value can be any expression
|
||||
(although you may need to wrap it in parentheses if it's a
|
||||
complicated one), which gets applied to the {} expression's
|
||||
input (remember, all filters have an input and an
|
||||
output).
|
||||
|
||||
|
||||
{foo: .bar}
|
||||
|
||||
|
||||
will produce the JSON object `{"foo": 42}` if given the JSON
|
||||
object `{"bar":42, "baz":43}`. You can use this to select
|
||||
particular fields of an object: if the input is an object
|
||||
with "user", "title", "id", and "content" fields and you
|
||||
just want "user" and "title", you can write
|
||||
|
||||
|
||||
{user: .user, title: .title}
|
||||
|
||||
|
||||
Because that's so common, there's a shortcut syntax: `{user, title}`.
|
||||
|
||||
|
||||
If one of the expressions produces multiple results,
|
||||
multiple dictionaries will be produced. If the input's
|
||||
|
||||
|
||||
{"user":"stedolan","titles":["JQ Primer", "More JQ"]}
|
||||
|
||||
|
||||
then the expression
|
||||
|
||||
|
||||
{user, title: .titles[]}
|
||||
|
||||
will produce two outputs:
|
||||
|
||||
|
||||
will produce two outputs:
|
||||
|
||||
{"user":"stedolan", "title": "JQ Primer"}
|
||||
{"user":"stedolan", "title": "More JQ"}
|
||||
|
||||
|
||||
Putting parentheses around the key means it will be evaluated as an
|
||||
expression. With the same input as above,
|
||||
|
||||
|
||||
{(.user): .titles}
|
||||
|
||||
|
||||
produces
|
||||
|
||||
|
||||
{"stedolan": ["JQ Primer", "More JQ"]}
|
||||
|
||||
|
||||
examples:
|
||||
- program: '{user, title: .titles[]}'
|
||||
input: '{"user":"stedolan","titles":["JQ Primer", "More JQ"]}'
|
||||
@@ -472,7 +472,7 @@ sections:
|
||||
etc.). However, jq never does implicit type conversions. If you
|
||||
try to add a string to an object you'll get an error message and
|
||||
no result.
|
||||
|
||||
|
||||
entries:
|
||||
- title: Addition - `+`
|
||||
body: |
|
||||
@@ -486,13 +486,13 @@ sections:
|
||||
- **Arrays** are added by being concatenated into a larger array.
|
||||
|
||||
- **Strings** are added by being joined into a larger string.
|
||||
|
||||
|
||||
- **Objects** are added by merging, that is, inserting all
|
||||
the key-value pairs from both objects into a single
|
||||
combined object. If both objects contain a value for the
|
||||
same key, the object on the right of the `+` wins. (For
|
||||
recursive merge use the `*` operator.)
|
||||
|
||||
|
||||
`null` can be added to any value, and returns the other
|
||||
value unchanged.
|
||||
|
||||
@@ -578,7 +578,7 @@ sections:
|
||||
|
||||
- title: "`keys`"
|
||||
body: |
|
||||
|
||||
|
||||
The builtin function `keys`, when given an object, returns
|
||||
its keys in an array.
|
||||
|
||||
@@ -601,7 +601,7 @@ sections:
|
||||
|
||||
- title: "`has`"
|
||||
body: |
|
||||
|
||||
|
||||
The builtin function `has` returns whether the input object
|
||||
has the given key, or the input array has an element at the
|
||||
given index.
|
||||
@@ -620,25 +620,25 @@ sections:
|
||||
|
||||
- title: "`del`"
|
||||
body: |
|
||||
|
||||
|
||||
The builtin function `del` removes a key and its corresponding
|
||||
value from an object.
|
||||
|
||||
|
||||
examples:
|
||||
- program: 'del(.foo)'
|
||||
input: '{"foo": 42, "bar": 9001, "baz": 42}'
|
||||
input: '[{"foo": 42, "bar": 9001, "baz": 42}]'
|
||||
output: ['{"bar": 9001, "baz": 42}']
|
||||
- program: 'del(.[1, 2])'
|
||||
input: '["foo", "bar", "baz"]'
|
||||
input: '[["foo", "bar", "baz"]]'
|
||||
output: ['["foo"]']
|
||||
|
||||
- title: "`to_entries`, `from_entries`, `with_entries`"
|
||||
body: |
|
||||
|
||||
|
||||
These functions convert between an object and an array of
|
||||
key-value pairs. If `to_entries` is passed an object, then
|
||||
for each `k: v` entry in the input, the output array
|
||||
includes `{"key": k, "value": v}`.
|
||||
includes `{"key": k, "value": v}`.
|
||||
|
||||
`from_entries` does the opposite conversion, and
|
||||
`with_entries(foo)` is a shorthand for `to_entries |
|
||||
@@ -659,7 +659,7 @@ sections:
|
||||
|
||||
- title: "`select`"
|
||||
body: |
|
||||
|
||||
|
||||
The function `select(foo)` produces its input unchanged if
|
||||
`foo` returns true for that input, and produces no output
|
||||
otherwise.
|
||||
@@ -675,7 +675,7 @@ sections:
|
||||
|
||||
- title: "`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `strings`, `nulls`, `values`, `scalars`"
|
||||
body: |
|
||||
|
||||
|
||||
These built-ins select only inputs that are arrays, objects,
|
||||
iterables (arrays or objects), booleans, numbers, strings,
|
||||
null, non-null values, and non-iterables, respectively.
|
||||
@@ -687,7 +687,7 @@ sections:
|
||||
|
||||
- title: "`empty`"
|
||||
body: |
|
||||
|
||||
|
||||
`empty` returns no results. None at all. Not even `null`.
|
||||
|
||||
It's useful on occasion. You'll know if you need it :)
|
||||
@@ -721,7 +721,7 @@ sections:
|
||||
Outputs the paths to all the elements in its input (except it
|
||||
does not output the empty list, representing . itself).
|
||||
|
||||
`paths` is equivalent to
|
||||
`paths` is equivalent to
|
||||
|
||||
def paths: path(recurse(if (type|. == "array" or . == "object") then .[] else empty end))|select(length > 0);
|
||||
|
||||
@@ -765,13 +765,13 @@ sections:
|
||||
|
||||
- title: "`any`"
|
||||
body: |
|
||||
|
||||
|
||||
The filter `any` takes as input an array of boolean values,
|
||||
and produces `true` as output if any of the elements of
|
||||
the array are `true`.
|
||||
|
||||
and produces `true` as output if any of the the elements of
|
||||
the array is `true`.
|
||||
|
||||
If the input is an empty array, `any` returns `false`.
|
||||
|
||||
|
||||
examples:
|
||||
- program: any
|
||||
input: '[true, false]'
|
||||
@@ -785,13 +785,13 @@ sections:
|
||||
|
||||
- title: "`all`"
|
||||
body: |
|
||||
|
||||
|
||||
The filter `all` takes as input an array of boolean values,
|
||||
and produces `true` as output if all of the elements of
|
||||
and produces `true` as output if all of the the elements of
|
||||
the array are `true`.
|
||||
|
||||
|
||||
If the input is an empty array, `all` returns `true`.
|
||||
|
||||
|
||||
examples:
|
||||
- program: all
|
||||
input: '[true, false]'
|
||||
@@ -805,10 +805,10 @@ sections:
|
||||
|
||||
- title: "`range`"
|
||||
body: |
|
||||
|
||||
|
||||
The `range` function produces a range of numbers. `range(4;10)`
|
||||
produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
|
||||
are produced as separate outputs. Use `[range(4;10)]` to get a range as
|
||||
are produced as separate outputs. Use `[range(4;10)]` to get a range as
|
||||
an array.
|
||||
|
||||
examples:
|
||||
@@ -818,7 +818,7 @@ sections:
|
||||
- program: '[range(2;4)]'
|
||||
input: 'null'
|
||||
output: ['[2,3]']
|
||||
|
||||
|
||||
- title: "`floor`"
|
||||
body: |
|
||||
|
||||
@@ -828,7 +828,7 @@ sections:
|
||||
- program: 'floor'
|
||||
input: '3.14159'
|
||||
output: ['3']
|
||||
|
||||
|
||||
- title: "`sqrt`"
|
||||
body: |
|
||||
|
||||
@@ -838,7 +838,7 @@ sections:
|
||||
- program: 'sqrt'
|
||||
input: '9'
|
||||
output: ['3']
|
||||
|
||||
|
||||
- title: "`tonumber`"
|
||||
body: |
|
||||
|
||||
@@ -865,7 +865,7 @@ sections:
|
||||
|
||||
- title: "`type`"
|
||||
body: |
|
||||
|
||||
|
||||
The `type` function returns the type of its argument as a
|
||||
string, which is one of null, boolean, number, string, array
|
||||
or object.
|
||||
@@ -877,7 +877,7 @@ sections:
|
||||
|
||||
- title: "`sort, sort_by`"
|
||||
body: |
|
||||
|
||||
|
||||
The `sort` functions sorts its input, which must be an
|
||||
array. Values are sorted in the following order:
|
||||
|
||||
@@ -909,7 +909,7 @@ sections:
|
||||
|
||||
- title: "`group_by`"
|
||||
body: |
|
||||
|
||||
|
||||
`group_by(.foo)` takes as input an array, groups the
|
||||
elements having the same `.foo` field into separate arrays,
|
||||
and produces all of these arrays as elements of a larger
|
||||
@@ -926,7 +926,7 @@ sections:
|
||||
|
||||
- title: "`min`, `max`, `min_by`, `max_by`"
|
||||
body: |
|
||||
|
||||
|
||||
Find the minimum or maximum element of the input array. The
|
||||
`_by` versions allow you to specify a particular field or
|
||||
property to examine, e.g. `min_by(.foo)` finds the object
|
||||
@@ -942,7 +942,7 @@ sections:
|
||||
|
||||
- title: "`unique`"
|
||||
body: |
|
||||
|
||||
|
||||
The `unique` function takes as input an array and produces
|
||||
an array of the same elements, in sorted order, with
|
||||
duplicates removed.
|
||||
@@ -954,25 +954,25 @@ sections:
|
||||
|
||||
- title: "`unique_by`"
|
||||
body: |
|
||||
|
||||
|
||||
The `unique_by(.foo)` function takes as input an array and produces
|
||||
an array of the same elements, in sorted order, with
|
||||
elqements with a duplicate `.foo` field removed. Think of it as making
|
||||
an array by taking one element out of every group produced by
|
||||
`group_by`.
|
||||
|
||||
|
||||
examples:
|
||||
- program: 'unique_by(.foo)'
|
||||
input: '[{"foo": 1, "bar": 2}, {"foo": 1, "bar": 3}, {"foo": 4, "bar": 5}]'
|
||||
output: ['[{"foo": 1, "bar": 2}, {"foo": 4, "bar": 5}]']
|
||||
- program: 'unique_by(length)'
|
||||
input: '["chunky", "bacon", "kitten", "cicada", "asparagus"]'
|
||||
output: ['["bacon", "chunky", "asparagus"]']
|
||||
output: ['["chunky", "bacon", "asparagus"]']
|
||||
|
||||
|
||||
- title: "`reverse`"
|
||||
body: |
|
||||
|
||||
|
||||
This function reverses an array.
|
||||
|
||||
examples:
|
||||
@@ -1038,7 +1038,7 @@ sections:
|
||||
- program: 'index(", ")'
|
||||
input: '"a,b, cd, efg, hijk"'
|
||||
output: ['3']
|
||||
- program: 'rindex(", ")'
|
||||
- program: 'rindex(", ")]'
|
||||
input: '"a,b, cd, efg, hijk"'
|
||||
output: ['12']
|
||||
|
||||
@@ -1060,7 +1060,7 @@ sections:
|
||||
examples:
|
||||
- program: '[.[]|endswith("foo")]'
|
||||
input: '["foobar", "barfoo"]'
|
||||
output: ['[false, true]']
|
||||
output: ['[false, true, true, false, false]']
|
||||
|
||||
- title: "`ltrimstr`"
|
||||
body: |
|
||||
@@ -1117,12 +1117,12 @@ sections:
|
||||
|
||||
- title: "`join`"
|
||||
body: |
|
||||
|
||||
|
||||
Joins the array of elements given as input, using the
|
||||
argument as separator. It is the inverse of `split`: that is,
|
||||
running `split("foo") | join("foo")` over any input string
|
||||
returns said input string.
|
||||
|
||||
|
||||
examples:
|
||||
- program: 'join(", ")'
|
||||
input: '["a","b,c,d","e"]'
|
||||
@@ -1131,7 +1131,7 @@ sections:
|
||||
|
||||
- title: "`recurse`"
|
||||
body: |
|
||||
|
||||
|
||||
The `recurse` function allows you to search through a
|
||||
recursive structure, and extract interesting data from all
|
||||
levels. Suppose your input represents a filesystem:
|
||||
@@ -1143,7 +1143,7 @@ sections:
|
||||
{"name": "/home", "children": [
|
||||
{"name": "/home/stephen", "children": [
|
||||
{"name": "/home/stephen/jq", "children": []}]}]}]}
|
||||
|
||||
|
||||
Now suppose you want to extract all of the filenames
|
||||
present. You need to retrieve `.name`, `.children[].name`,
|
||||
`.children[].children[].name`, and so on. You can do this
|
||||
@@ -1154,7 +1154,7 @@ sections:
|
||||
examples:
|
||||
- program: 'recurse(.foo[])'
|
||||
input: '{"foo":[{"foo": []}, {"foo":[{"foo":[]}]}]}'
|
||||
output:
|
||||
output:
|
||||
- '{"foo":[{"foo":[]},{"foo":[{"foo":[]}]}]}'
|
||||
- '{"foo":[]}'
|
||||
- '{"foo":[{"foo":[]}]}'
|
||||
@@ -1162,14 +1162,14 @@ sections:
|
||||
|
||||
- title: "`recurse_down`"
|
||||
body: |
|
||||
|
||||
|
||||
A quieter version of `recurse(.[])`, equivalent to:
|
||||
|
||||
def recurse_down: recurse(.[]?);
|
||||
|
||||
- title: "`..`"
|
||||
body: |
|
||||
|
||||
|
||||
Short-hand for `recurse_down`. This is intended to resemble
|
||||
the XPath `//` operator. Note that `..a` does not work; use
|
||||
`..|a` instead.
|
||||
@@ -1190,7 +1190,7 @@ sections:
|
||||
- program: '"The input was \(.), which is one less than \(.+1)"'
|
||||
input: '42'
|
||||
output: ['"The input was 42, which is one less than 43"']
|
||||
|
||||
|
||||
- title: "Convert to/from JSON"
|
||||
body: |
|
||||
|
||||
@@ -1238,17 +1238,17 @@ sections:
|
||||
characters to a `%xx` sequence.
|
||||
|
||||
* `@csv`:
|
||||
|
||||
|
||||
The input must be an array, and it is rendered as CSV
|
||||
with double quotes for strings, and quotes escaped by
|
||||
repetition.
|
||||
|
||||
* `@sh`:
|
||||
|
||||
|
||||
The input is escaped suitable for use in a command-line
|
||||
for a POSIX shell. If the input is an array, the output
|
||||
will be a series of space-separated strings.
|
||||
|
||||
|
||||
* `@base64`:
|
||||
|
||||
The input is converted to base64 as specified by RFC 4648.
|
||||
@@ -1281,7 +1281,7 @@ sections:
|
||||
- program: '@sh "echo \(.)"'
|
||||
input: "\"O'Hara's Ale\""
|
||||
output: ["\"echo 'O'\\\\''Hara'\\\\''s Ale'\""]
|
||||
|
||||
|
||||
- title: Conditionals and Comparisons
|
||||
entries:
|
||||
- title: "`==`, `!=`"
|
||||
@@ -1293,7 +1293,7 @@ sections:
|
||||
to numbers. If you're coming from Javascript, jq's == is like
|
||||
Javascript's === - considering values equal only when they have the
|
||||
same type as well as the same value.
|
||||
|
||||
|
||||
!= is "not equal", and 'a != b' returns the opposite value of 'a == b'
|
||||
|
||||
examples:
|
||||
@@ -1306,7 +1306,7 @@ sections:
|
||||
`if A then B else C end` will act the same as `B` if `A`
|
||||
produces a value other than false or null, but act the same
|
||||
as `C` otherwise.
|
||||
|
||||
|
||||
Checking for false or null is a simpler notion of
|
||||
"truthiness" than is found in Javascript or Python, but it
|
||||
means that you'll sometimes have to be more explicit about
|
||||
@@ -1314,11 +1314,11 @@ sections:
|
||||
string is empty using `if .name then A else B end`, you'll
|
||||
need something more like `if (.name | length) > 0 then A else
|
||||
B end` instead.
|
||||
|
||||
If the condition `A` produces multiple results, then `B` is evaluated
|
||||
once for each result that is not false or null, and `C` is evaluated
|
||||
once for each false or null.
|
||||
|
||||
|
||||
If the condition A produces multiple results, it is
|
||||
considered "true" if any of those results is not false or
|
||||
null. If it produces zero results, it's considered false.
|
||||
|
||||
More cases can be added to an if using `elif A then B` syntax.
|
||||
|
||||
examples:
|
||||
@@ -1332,10 +1332,10 @@ sections:
|
||||
end
|
||||
input: 2
|
||||
output: ['"many"']
|
||||
|
||||
|
||||
- title: "`>, >=, <=, <`"
|
||||
body: |
|
||||
|
||||
|
||||
The comparison operators `>`, `>=`, `<=`, `<` return whether
|
||||
their left argument is greater than, greater than or equal
|
||||
to, less than or equal to or less than their right argument
|
||||
@@ -1362,14 +1362,14 @@ sections:
|
||||
so it is called as a filter to which things can be piped
|
||||
rather than with special syntax, as in `.foo and .bar |
|
||||
not`.
|
||||
|
||||
|
||||
These three only produce the values "true" and "false", and
|
||||
so are only useful for genuine Boolean operations, rather
|
||||
than the common Perl/Python/Ruby idiom of
|
||||
"value_that_may_be_null or default". If you want to use this
|
||||
form of "or", picking between two values rather than
|
||||
evaluating a condition, see the "//" operator below.
|
||||
|
||||
|
||||
examples:
|
||||
- program: '42 and "a string"'
|
||||
input: 'null'
|
||||
@@ -1407,7 +1407,7 @@ sections:
|
||||
- program: '.foo // 42'
|
||||
input: '{}'
|
||||
output: [42]
|
||||
|
||||
|
||||
- title: Advanced features
|
||||
body: |
|
||||
Variables are an absolute necessity in most programming languages, but
|
||||
@@ -1432,67 +1432,67 @@ sections:
|
||||
entries:
|
||||
- title: Variables
|
||||
body: |
|
||||
|
||||
|
||||
In jq, all filters have an input and an output, so manual
|
||||
plumbing is not necessary to pass a value from one part of a program
|
||||
to the next. Many expressions, for instance `a + b`, pass their input
|
||||
to two distinct subexpressions (here `a` and `b` are both passed the
|
||||
same input), so variables aren't usually necessary in order to use a
|
||||
value twice.
|
||||
|
||||
|
||||
For instance, calculating the average value of an array of numbers
|
||||
requires a few variables in most languages - at least one to hold the
|
||||
array, perhaps one for each element or for a loop counter. In jq, it's
|
||||
simply `add / length` - the `add` expression is given the array and
|
||||
produces its sum, and the `length` expression is given the array and
|
||||
produces its length.
|
||||
|
||||
|
||||
So, there's generally a cleaner way to solve most problems in jq than
|
||||
defining variables. Still, sometimes they do make things easier, so jq
|
||||
lets you define variables using `expression as $variable`. All
|
||||
variable names start with `$`. Here's a slightly uglier version of the
|
||||
array-averaging example:
|
||||
|
||||
|
||||
length as $array_length | add / $array_length
|
||||
|
||||
|
||||
We'll need a more complicated problem to find a situation where using
|
||||
variables actually makes our lives easier.
|
||||
|
||||
|
||||
|
||||
|
||||
Suppose we have an array of blog posts, with "author" and "title"
|
||||
fields, and another object which is used to map author usernames to
|
||||
real names. Our input looks like:
|
||||
|
||||
|
||||
{"posts": [{"title": "Frist psot", "author": "anon"},
|
||||
{"title": "A well-written article", "author": "person1"}],
|
||||
"realnames": {"anon": "Anonymous Coward",
|
||||
"person1": "Person McPherson"}}
|
||||
|
||||
|
||||
We want to produce the posts with the author field containing a real
|
||||
name, as in:
|
||||
|
||||
|
||||
{"title": "Frist psot", "author": "Anonymous Coward"}
|
||||
{"title": "A well-written article", "author": "Person McPherson"}
|
||||
|
||||
|
||||
We use a variable, $names, to store the realnames object, so that we
|
||||
can refer to it later when looking up author usernames:
|
||||
|
||||
|
||||
.realnames as $names | .posts[] | {title, author: $names[.author]}
|
||||
|
||||
|
||||
The expression `exp as $x | ...` means: for each value of expression
|
||||
`exp`, run the rest of the pipeline with the entire original input, and
|
||||
with `$x` set to that value. Thus `as` functions as something of a
|
||||
with `$x` set to that value. Thus `as` functions as something of a
|
||||
foreach loop.
|
||||
|
||||
Variables are scoped over the rest of the expression that defines
|
||||
them, so
|
||||
|
||||
them, so
|
||||
|
||||
.realnames as $names | (.posts[] | {title, author: $names[.author]})
|
||||
|
||||
will work, but
|
||||
|
||||
|
||||
will work, but
|
||||
|
||||
(.realnames as $names | .posts[]) | {title, author: $names[.author]}
|
||||
|
||||
|
||||
won't.
|
||||
|
||||
examples:
|
||||
@@ -1502,11 +1502,11 @@ sections:
|
||||
|
||||
- title: 'Defining Functions'
|
||||
body: |
|
||||
|
||||
|
||||
You can give a filter a name using "def" syntax:
|
||||
|
||||
def increment: . + 1;
|
||||
|
||||
|
||||
From then on, `increment` is usable as a filter just like a
|
||||
builtin function (in fact, this is how some of the builtins
|
||||
are defined). A function may take arguments:
|
||||
@@ -1537,19 +1537,19 @@ sections:
|
||||
|
||||
- title: Reduce
|
||||
body: |
|
||||
|
||||
|
||||
The `reduce` syntax in jq allows you to combine all of the
|
||||
results of an expression by accumulating them into a single
|
||||
answer. As an example, we'll pass `[3,2,1]` to this expression:
|
||||
|
||||
reduce .[] as $item (0; . + $item)
|
||||
|
||||
|
||||
For each result that `.[]` produces, `. + $item` is run to
|
||||
accumulate a running total, starting from 0. In this
|
||||
example, `.[]` produces the results 3, 2, and 1, so the
|
||||
effect is similar to running something like this:
|
||||
|
||||
0 | (3 as $item | . + $item) |
|
||||
0 | (3 as $item | . + $item) |
|
||||
(2 as $item | . + $item) |
|
||||
(1 as $item | . + $item)
|
||||
|
||||
@@ -1557,7 +1557,7 @@ sections:
|
||||
- program: 'reduce .[] as $item (0; . + $item)'
|
||||
input: '[10,2,5,3]'
|
||||
output: ['20']
|
||||
|
||||
|
||||
|
||||
- title: Assignment
|
||||
body: |
|
||||
@@ -1579,14 +1579,14 @@ sections:
|
||||
entries:
|
||||
- title: "`=`"
|
||||
body: |
|
||||
|
||||
|
||||
The filter `.foo = 1` will take as input an object
|
||||
and produce as output an object with the "foo" field set to
|
||||
1. There is no notion of "modifying" or "changing" something
|
||||
in jq - all jq values are immutable. For instance,
|
||||
|
||||
|
||||
.foo = .bar | .foo.baz = 1
|
||||
|
||||
|
||||
will not have the side-effect of setting .bar.baz to be set
|
||||
to 1, as the similar-looking program in Javascript, Python,
|
||||
Ruby or other languages would. Unlike these languages (but
|
||||
@@ -1595,7 +1595,7 @@ sections:
|
||||
"the same object". They can be equal, or not equal, but if
|
||||
we change one of them in no circumstances will the other
|
||||
change behind our backs.
|
||||
|
||||
|
||||
This means that it's impossible to build circular values in
|
||||
jq (such as an array whose first element is itself). This is
|
||||
quite intentional, and ensures that anything a jq program
|
||||
@@ -1608,14 +1608,14 @@ sections:
|
||||
works out the new value for the property being assigned to by running
|
||||
the old value through this expression. For instance, .foo |= .+1 will
|
||||
build an object with the "foo" field set to the input's "foo" plus 1.
|
||||
|
||||
|
||||
This example should show the difference between '=' and '|=':
|
||||
|
||||
|
||||
Provide input '{"a": {"b": 10}, "b": 20}' to the programs:
|
||||
|
||||
|
||||
.a = .b
|
||||
.a |= .b
|
||||
|
||||
|
||||
The former will set the "a" field of the input to the "b" field of the
|
||||
input, and produce the output {"a": 20}. The latter will set the "a"
|
||||
field of the input to the "a" field's "b" field, producing {"a": 10}.
|
||||
@@ -1630,43 +1630,43 @@ sections:
|
||||
- program: .foo += 1
|
||||
input: '{"foo": 42}'
|
||||
output: ['{"foo": 43}']
|
||||
|
||||
|
||||
- title: Complex assignments
|
||||
body: |
|
||||
Lots more things are allowed on the left-hand side of a jq assignment
|
||||
than in most langauges. We've already seen simple field accesses on
|
||||
the left hand side, and it's no surprise that array accesses work just
|
||||
as well:
|
||||
|
||||
|
||||
.posts[0].title = "JQ Manual"
|
||||
|
||||
|
||||
What may come as a surprise is that the expression on the left may
|
||||
produce multiple results, referring to different points in the input
|
||||
document:
|
||||
|
||||
|
||||
.posts[].comments |= . + ["this is great"]
|
||||
|
||||
|
||||
That example appends the string "this is great" to the "comments"
|
||||
array of each post in the input (where the input is an object with a
|
||||
field "posts" which is an array of posts).
|
||||
|
||||
|
||||
When jq encounters an assignment like 'a = b', it records the "path"
|
||||
taken to select a part of the input document while executing a. This
|
||||
path is then used to find which part of the input to change while
|
||||
executing the assignment. Any filter may be used on the
|
||||
left-hand side of an equals - whichever paths it selects from the
|
||||
input will be where the assignment is performed.
|
||||
|
||||
|
||||
This is a very powerful operation. Suppose we wanted to add a comment
|
||||
to blog posts, using the same "blog" input above. This time, we only
|
||||
want to comment on the posts written by "stedolan". We can find those
|
||||
posts using the "select" function described earlier:
|
||||
|
||||
|
||||
.posts[] | select(.author == "stedolan")
|
||||
|
||||
|
||||
The paths provided by this operation point to each of the posts that
|
||||
"stedolan" wrote, and we can comment on each of them in the same way
|
||||
that we did before:
|
||||
|
||||
|
||||
(.posts[] | select(.author == "stedolan") | .comments) |=
|
||||
. + ["terrible."]
|
||||
File diff suppressed because it is too large.
Load diff
@@ -24,7 +24,7 @@ body3: |
|
||||
|
||||
tail: |
|
||||
|
||||
Go read the [tutorial](/jq/tutorial/) for more, or the [manual](/jq/manual/)
|
||||
Go read the [tutorial](tutorial/) for more, or the [manual](manual/)
|
||||
for *way* more.
|
||||
|
||||
Ask questions on [stackoverflow](https://stackoverflow.com/) using the [jq
|
||||
@@ -33,34 +33,18 @@ tail: |
|
||||
[Freenode](https://webchat.freenode.net/).
|
||||
|
||||
news:
|
||||
- date: 15 August 2015
|
||||
- date: 2015-01-01
|
||||
body: |
|
||||
|
||||
jq 1.5 released, including new datetime, math, and regexp functions,
|
||||
try/catch syntax, array and object destructuring, a streaming parser,
|
||||
and a module system. See installation options on the
|
||||
[download](/jq/download/) page, and the
|
||||
[release notes](https://github.com/stedolan/jq/releases/tag/jq-1.5)
|
||||
for details.
|
||||
|
||||
- date: 26 July 2015
|
||||
body: |
|
||||
|
||||
jq 1.5rc2 is available. Get it on the
|
||||
jq 1.5rc1 Get it on the
|
||||
[releases](https://github.com/stedolan/jq/releases) page.
|
||||
|
||||
- date: 01 January 2015
|
||||
- date: 2014-06-08
|
||||
body: |
|
||||
|
||||
jq 1.5rc1 is available. Get it on the
|
||||
[releases](https://github.com/stedolan/jq/releases) page.
|
||||
jq 1.4 (finally) released! Get it on the [download](download/) page.
|
||||
|
||||
- date: 09 June 2014
|
||||
body: |
|
||||
|
||||
jq 1.4 (finally) released! Get it on the [download](/jq/download/) page.
|
||||
|
||||
- date: 19 May 2013
|
||||
- date: 2013-05-19
|
||||
body: |
|
||||
|
||||
jq 1.3 released.
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
jq(1) -- Command-line JSON processor
|
||||
====================================
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
`jq` can transform JSON in various ways, by selecting, iterating,
|
||||
reducing and otherwise mangling JSON documents.
|
||||
|
||||
This version of `jq` was built without a manual, so this manpage is a
|
||||
stub. For full documentation of the `jq` language, see:
|
||||
|
||||
https://stedolan.github.io/jq
|
||||
|
||||
## BUGS
|
||||
|
||||
Presumably. Report them or discuss them at:
|
||||
|
||||
https://github.com/stedolan/jq/issues
|
||||
|
||||
## AUTHOR
|
||||
|
||||
Stephen Dolan `<mu@netsoc.tcd.ie>`
|
||||
@@ -12,7 +12,7 @@ FileETag All
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
|
||||
# Cache, aggressively
|
||||
# Cache, aggressively
|
||||
<IfModule mod_expires.c>
|
||||
ExpiresActive On
|
||||
ExpiresDefault "access plus 10 days"
|
||||
@@ -25,4 +25,4 @@ FileETag All
|
||||
# Mime-types
|
||||
AddType application/vnd.ms-fontobject .eot
|
||||
AddType font/ttf .ttf
|
||||
AddType font/otf .otf
|
||||
AddType font/otf .otf
|
||||
+1058
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* Bootstrap Responsive v2.1.1
|
||||
*
|
||||
* Copyright 2012 Twitter, Inc
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
||||
*/.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}.visible-desktop{display:inherit!important}@media(min-width:768px) and (max-width:979px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}}@media(max-width:767px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-phone{display:inherit!important}.hidden-phone{display:none!important}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:30px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.564102564102564%;*margin-left:2.5109110747408616%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145299145%;*width:91.39979996362975%}.row-fluid .span10{width:82.90598290598291%;*width:82.8527914166212%}.row-fluid .span9{width:74.35897435897436%;*width:74.30578286961266%}.row-fluid .span8{width:65.81196581196582%;*width:65.75877432260411%}.row-fluid .span7{width:57.26495726495726%;*width:57.21176577559556%}.row-fluid .span6{width:48.717948717948715%;*width:48.664757228587014%}.row-fluid .span5{width:40.17094017094017%;*width:40.11774868157847%}.row-fluid .span4{width:31.623931623931625%;*width:31.570740134569924%}.row-fluid .span3{width:23.076923076923077%;*width:23.023731587561375%}.row-fluid .span2{width:14.52991452991453%;*width:14.476723040552828%}.row-fluid .span1{width:5.982905982905983%;*width:5.929714493544281%}.row-fluid .offset12{margin-left:105.12820512820512%;*margin-left:105.02182214948171%}.row-fluid .offset12:first-child{margin-left:102.56410256410257%;*margin-left:102.45771958537915%}.row-fluid .offset11{margin-left:96.58119658119658%;*margin-left:96.47481360247316%}.row-fluid .offset11:first-child{margin-left:94.01709401709402%;*margin-left:93.91071103837061%}.row-fluid .offset10{margin-left:88.03418803418803%;*margin-left:87.92780505546462%}.row-fluid .offset10:first-child{margin-left:85.47008547008548%;*margin-left:85.36370249136206%}.row-fluid .offset9{margin-left:79.48717948717949%;*margin-left:79.38079650845607%}.row-fluid .offset9:first-child{margin-left:76.92307692307693%;*margin-left:76.81669394435352%}.row-fluid .offset8{margin-left:70.94017094017094%;*margin-left:70.83378796144753%}.row-fluid .offset8:first-child{margin-left:68.37606837606839%;*margin-left:68.26968539734497%}.row-fluid .offset7{margin-left:62.393162393162385%;*margin-left:62.28677941443899%}.row-fluid .offset7:first-child{margin-left:59.82905982905982%;*margin-left:59.72267685033642%}.row-fluid .offset6{margin-left:53.84615384615384%;*margin-left:53.739770867430444%}.row-fluid .offset6:first-child{margin-left:51.28205128205128%;*margin-left:51.175668303327875%}.row-fluid .offset5{margin-left:45.299145299145295%;*margin-left:45.1927623204219%}.row-fluid .offset5:first-child{margin-left:42.73504273504273%;*margin-left:42.62865975631933%}.row-fluid .offset4{margin-left:36.75213675213675%;*margin-left:36.645753773413354%}.row-fluid .offset4:first-child{margin-left:34.18803418803419%;*margin-left:34.081651209310785%}.row-fluid .offset3{margin-left:28.205128205128204%;*margin-left:28.0987452264048%}.row-fluid .offset3:first-child{margin-left:25.641025641025642%;*margin-left:25.53464266230224%}.row-fluid .offset2{margin-left:19.65811965811966%;*margin-left:19.551736679396257%}.row-fluid .offset2:first-child{margin-left:17.094017094017094%;*maLine truncated
|
||||
+5224
File diff suppressed because it is too large.
Load diff
+9
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* Bootstrap v2.1.1
|
||||
*
|
||||
* Copyright 2012 Twitter, Inc
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
||||
*/article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{width:auto\9;height:auto;max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:20px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover{color:#005580;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.127659574468085%;*margin-left:2.074468085106383%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.48936170212765%;*width:91.43617021276594%}.row-fluid .span10{width:82.97872340425532%;*width:82.92553191489361%}.row-fluid .span9{width:74.46808510638297%;*width:74.41489361702126%}.row-fluid .span8{width:65.95744680851064%;*width:65.90425531914893%}.row-fluid .span7{width:57.44680851063829%;*width:57.39361702127659%}.row-fluid .span6{width:48.93617021276595%;*width:48.88297872340425%}.row-fluid .span5{width:40.42553191489362%;*width:40.37234042553192%}.row-fluid .span4{width:31.914893617021278%;*width:31.861702127659576%}.row-fluid .span3{width:23.404255319148934%;*width:23.351063829787233%}.row-fluid .span2{width:14.893617021276595%;*width:14.840425531914894%}.row-fluid .span1{width:6.382978723404255%;*width:6.329787234042553%}.row-fluid .offset12{margin-left:104.25531914893617%;*margin-left:104.14893617021275%}.row-fluid .offset12:first-child{margin-left:102.12765957446808%;*margin-left:102.02127659574467%}.row-fluid .offset11{margin-left:95.74468085106382%;*margin-left:95.6382978723404%}.row-fluid .offset11:first-child{margin-left:93.61702127659574%;*margin-left:93.51063829787232%}.row-fluid .offset10{margin-left:87.23404255319149%;*margin-left:87.12765957446807%}.row-fluid .offset10:first-child{margin-left:85.1063829787234%;*margin-left:84.99999999999999%}.row-fluid .offset9{margin-left:78.72340425531914%;*margin-left:78.61702127659572%}.row-fluid .offset9:first-child{margin-left:76.59574468085106%;*margin-left:76.48936170212764%}.row-fluiLine truncated
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
+2027
File diff suppressed because it is too large.
Load diff
+6
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* Bootstrap.js by @fat & @mdo
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
*/
|
||||
!function(e){e(function(){"use strict";e.support.transition=function(){var e=function(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},n;for(n in t)if(e.style[n]!==undefined)return t[n]}();return e&&{end:e}}()})}(window.jQuery),!function(e){"use strict";var t='[data-dismiss="alert"]',n=function(n){e(n).on("click",t,this.close)};n.prototype.close=function(t){function s(){i.trigger("closed").remove()}var n=e(this),r=n.attr("data-target"),i;r||(r=n.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,"")),i=e(r),t&&t.preventDefault(),i.length||(i=n.hasClass("alert")?n:n.parent()),i.trigger(t=e.Event("close"));if(t.isDefaultPrevented())return;i.removeClass("in"),e.support.transition&&i.hasClass("fade")?i.on(e.support.transition.end,s):s()},e.fn.alert=function(t){return this.each(function(){var r=e(this),i=r.data("alert");i||r.data("alert",i=new n(this)),typeof t=="string"&&i[t].call(r)})},e.fn.alert.Constructor=n,e(function(){e("body").on("click.alert.data-api",t,n.prototype.close)})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.button.defaults,n)};t.prototype.setState=function(e){var t="disabled",n=this.$element,r=n.data(),i=n.is("input")?"val":"html";e+="Text",r.resetText||n.data("resetText",n[i]()),n[i](r[e]||this.options[e]),setTimeout(function(){e=="loadingText"?n.addClass(t).attr(t,t):n.removeClass(t).removeAttr(t)},0)},t.prototype.toggle=function(){var e=this.$element.closest('[data-toggle="buttons-radio"]');e&&e.find(".active").removeClass("active"),this.$element.toggleClass("active")},e.fn.button=function(n){return this.each(function(){var r=e(this),i=r.data("button"),s=typeof n=="object"&&n;i||r.data("button",i=new t(this,s)),n=="toggle"?i.toggle():n&&i.setState(n)})},e.fn.button.defaults={loadingText:"loading..."},e.fn.button.Constructor=t,e(function(){e("body").on("click.button.data-api","[data-toggle^=button]",function(t){var n=e(t.target);n.hasClass("btn")||(n=n.closest(".btn")),n.button("toggle")})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=n,this.options.slide&&this.slide(this.options.slide),this.options.pause=="hover"&&this.$element.on("mouseenter",e.proxy(this.pause,this)).on("mouseleave",e.proxy(this.cycle,this))};t.prototype={cycle:function(t){return t||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval(e.proxy(this.next,this),this.options.interval)),this},to:function(t){var n=this.$element.find(".item.active"),r=n.parent().children(),i=r.index(n),s=this;if(t>r.length-1||t<0)return;return this.sliding?this.$element.one("slid",function(){s.to(t)}):i==t?this.pause().cycle():this.slide(t>i?"next":"prev",e(r[t]))},pause:function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&e.support.transition.end&&(this.$element.trigger(e.support.transition.end),this.cycle()),clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(t,n){var r=this.$element.find(".item.active"),i=n||r[t](),s=this.interval,o=t=="next"?"left":"right",u=t=="next"?"first":"last",a=this,f=e.Event("slide",{relatedTarget:i[0]});this.sliding=!0,s&&this.pause(),i=i.length?i:this.$element.find(".item")[u]();if(i.hasClass("active"))return;if(e.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass(t),i[0].offsetWidth,r.addClass(o),i.addClass(o),this.$element.one(e.support.transition.end,function(){i.removeClass([t,o].join(" ")).addClass("active"),r.removeClass(["active",o].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger("slid")},0)})}else{this.$element.trigger(f);if(f.isDefaultPrevented())return;r.removeClass("active"),i.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return s&&this.cycle(),this}},e.fn.carousel=function(n){return this.each(function(){var r=e(this),i=r.data("carousel"),s=e.extend({},e.fn.carousel.defaults,typeof n=="object"&&n),o=typeof n=="string"?n:s.slide;i||r.data("carousel",i=new t(this,s)),typeof n=="number"?i.to(n):o?i[o]():s.interval&&i.cycle()})},e.fn.carousel.defaults={interval:5e3,pause:"hover"},e.fn.carousel.Constructor=t,e(function(){e("body").on("click.carousel.data-api","[data-slide]",function(t){var n=e(this),r,i=e(n.attr("data-target")||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,"")),s=!i.data("modal")&&e.extend({},i.data(),n.data());i.carousel(s),t.preventDefault()})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.collapse.defaults,n),this.options.parent&&(this.$parent=e(this.options.parent)),this.options.toggle&&this.toggle()};t.prototype={constructor:t,dimension:function(){var e=this.$element.hLine truncated
|
||||
+69
-151
@@ -1,79 +1,85 @@
|
||||
@charset "utf-8";
|
||||
body {
|
||||
padding-top: 80px;
|
||||
padding-top: 60px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 970px;
|
||||
footer {
|
||||
background-color: #F5F5F5;
|
||||
padding: 40px 0;
|
||||
height: 100px;
|
||||
margin-top: 40px;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
/* index.liquid *******************************************/
|
||||
section {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.manual-example {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
|
||||
.manual-example td {
|
||||
white-space: pre-wrap;
|
||||
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
|
||||
}
|
||||
|
||||
.manual-example td.jqprogram {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.manual-example th {
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.tutorial-example {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.tutorial-example pre {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.tutorial-example a {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
padding: 15px 8px;
|
||||
color: #777777;
|
||||
font-weight: bold;
|
||||
line-height: 10px;
|
||||
font-size: 12px;
|
||||
border-left: 1px solid #DDDDDD;
|
||||
bottom: 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#blurb {
|
||||
padding-top: 40px;
|
||||
p {
|
||||
font-size: 1.9em;
|
||||
}
|
||||
.btn-group {
|
||||
margin: 4px;
|
||||
}
|
||||
padding-right: 50px;
|
||||
}
|
||||
|
||||
#blurb p {
|
||||
font-size: 20pt;
|
||||
}
|
||||
|
||||
#blurb .btn-group {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#multiblurb {
|
||||
line-height: 1.7;
|
||||
text-align: center;
|
||||
font-size: 12pt;
|
||||
code {
|
||||
border: 0;
|
||||
font-size: 12pt;
|
||||
}
|
||||
}
|
||||
|
||||
#news {
|
||||
#multiblurb code {
|
||||
border: 0;
|
||||
font-size: 12pt;
|
||||
.date {
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
||||
/* default.liquid *****************************************/
|
||||
|
||||
.tutorial-example {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
pre {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
a {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
padding: 15px 8px;
|
||||
color: #777777;
|
||||
font-weight: bold;
|
||||
line-height: 10px;
|
||||
font-size: 12px;
|
||||
border-left: 1px solid #DDDDDD;
|
||||
display: block;
|
||||
}
|
||||
.accordion-body pre {
|
||||
margin: 0 4px;
|
||||
border-top: 0;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
.tutorial-example a {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* manual.liquid ******************************************/
|
||||
|
||||
section {
|
||||
padding-top: 24px;
|
||||
}
|
||||
|
||||
h3 code {
|
||||
@@ -81,101 +87,13 @@ h3 code {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
@media(max-width: 991px){
|
||||
#navcolumn {
|
||||
/* Put nav column above manual content */
|
||||
position: relative !important;
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
}
|
||||
|
||||
@media(min-width: 992px) {
|
||||
#manualcontent {
|
||||
/* Put nav column left of manual content */
|
||||
padding-left: 280px;
|
||||
}
|
||||
}
|
||||
|
||||
.nav-pills {
|
||||
li a {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.manual-example table {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
td {
|
||||
white-space: pre-wrap;
|
||||
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
|
||||
}
|
||||
td.jqprogram {
|
||||
font-weight: bold;
|
||||
}
|
||||
th {
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
#navcolumn {
|
||||
display: none !important;
|
||||
}
|
||||
.manual-example {
|
||||
display: block !important;
|
||||
height: auto !important;
|
||||
}
|
||||
.jqplay-btn {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* shared/_footer.liquid **********************************/
|
||||
|
||||
footer {
|
||||
background-color: #F5F5F5;
|
||||
padding: 20px 0;
|
||||
margin-top: 40px;
|
||||
color: #999999;
|
||||
text-align: center;
|
||||
p {
|
||||
margin: 8px 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* typeahead **********************************************/
|
||||
|
||||
.twitter-typeahead {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tt-menu {
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
padding: 8px 0;
|
||||
border: 1px solid #ccc;
|
||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||
-webkit-border-radius: 8px;
|
||||
-moz-border-radius: 8px;
|
||||
border-radius: 8px;
|
||||
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
}
|
||||
|
||||
.tt-suggestion {
|
||||
padding: 3px 20px;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
color: #fff;
|
||||
background-color: #446e9b;
|
||||
#news {
|
||||
font-size: 12pt;
|
||||
.date {
|
||||
font-style: italic;
|
||||
}
|
||||
&.tt-cursor {
|
||||
color: #fff;
|
||||
background-color: #446e9b;
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
var section_names = function(q) {
|
||||
if (!q) {
|
||||
return [];
|
||||
}
|
||||
var matches = [];
|
||||
q = q.toLowerCase();
|
||||
$.each(section_map, function(k, v) {
|
||||
if (k.toLowerCase().indexOf(q) != -1) {
|
||||
matches.push(k);
|
||||
}
|
||||
});
|
||||
matches.sort(function(a, b) {
|
||||
// shortest to longest
|
||||
return a.length - b.length;
|
||||
});
|
||||
return matches;
|
||||
}
|
||||
var section_names_cb = function(q, cb) {
|
||||
cb(section_names(q));
|
||||
}
|
||||
var go_to_section = function() {
|
||||
query = $('#searchbox').val();
|
||||
results = section_names(query);
|
||||
if (results.length == 0) {
|
||||
return;
|
||||
}
|
||||
result = results[0];
|
||||
location.hash = '#' + section_map[result];
|
||||
if (result != query) {
|
||||
$('#searchbox').val(result);
|
||||
}
|
||||
}
|
||||
$(function(){
|
||||
$('#searchbox').typeahead(
|
||||
{hint: false, highlight: true, minLength: 1},
|
||||
{name: "contents", source: section_names_cb, limit: 6}
|
||||
).on('typeahead:selected', function(e, data) {
|
||||
go_to_section();
|
||||
});
|
||||
$('#searchbox').change(go_to_section);
|
||||
});
|
||||
// add "Run" button to execute examples on jqplay.org
|
||||
$(function() {
|
||||
$.each($('.manual-example table'), function(index, value) {
|
||||
$value = $(value)
|
||||
var j = $value.find('tr:nth-child(2) td:first').text();
|
||||
var q = $value.find('.jqprogram').text().replace(/^jq /, '').replace(/^'(.+)'$/, '$1');
|
||||
var url = 'https://jqplay.org/jq?q=' + encodeURIComponent(q) +'&j=' + encodeURIComponent(j)
|
||||
var $last_tr = $value.find('tr:last');
|
||||
$last_tr.after('<tr class="jqplay-btn"><th><a href="' + url + '" class="btn btn-primary btn-sm">Run</a></th><th></th></tr><tr><th></th><th></th></tr>');
|
||||
});
|
||||
});
|
||||
+10
-1
@@ -1,9 +1,18 @@
|
||||
# The key value pairs found below are available within the templates.
|
||||
|
||||
:url: https://stedolan.github.io/jq
|
||||
:url: http://stedolan.github.io/jq
|
||||
|
||||
# This line is modified by the Makefile. To change the version number,
|
||||
# edit the Autoconf version number at the top of configure.ac
|
||||
jq_version: "1.4-2-g15c4a7f-dirty"
|
||||
|
||||
root: '/jq'
|
||||
footer: |
|
||||
|
||||
This website is made with [Bonsai](http://www.tinytree.info) and
|
||||
[Twitter Bootstrap](http://twitter.github.com/bootstrap/), themed
|
||||
with [Bootswatch](http://bootswatch.com).
|
||||
|
||||
jq is licensed under the MIT license (code) and the
|
||||
[CC-BY-3.0](http://creativecommons.org/licenses/by/3.0/) license
|
||||
(docs).
|
||||
Vendored
+10
-10
@@ -1,34 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{% include "shared/head" %}
|
||||
|
||||
{% include "shared/head" %}
|
||||
<body id="{{slug}}">
|
||||
{% include "shared/navbar" %}
|
||||
|
||||
{% include "shared/header" %}
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="row">
|
||||
<h1>{{headline}}</h1>
|
||||
{% for item in body %}
|
||||
{% if item.text %}
|
||||
{{ item.text | replace: '$JQ_VERSION', jq_version | markdownify }}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if item.command %}
|
||||
|
||||
|
||||
{% capture resultID %}{{ "result" | unique}}{% endcapture %}
|
||||
<div class="tutorial-example">
|
||||
<div class="accordion-heading">
|
||||
<pre>{{item.command}}</pre>
|
||||
<a data-toggle="collapse" href="#{{resultID}}">Show result</a>
|
||||
</div>
|
||||
<div id="{{resultID}}" class="accordion-body collapse">
|
||||
<pre>{{item.result}}</pre>
|
||||
</div>
|
||||
<div id="{{resultID}}" class="accordion-body collapse"><pre>{{item.result}}</pre></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "shared/footer" %}
|
||||
{% include "shared/footer" %}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Vendored
+33
-46
@@ -1,73 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{% include "shared/head" %}
|
||||
|
||||
{% include "shared/head" %}
|
||||
<body id="{{slug}}">
|
||||
{% include "shared/navbar" %}
|
||||
|
||||
{% include "shared/header" %}
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="jumbotron">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<img src="{{root}}/jq.png" class="img-responsive" alt="jq logo"
|
||||
width="400" height="220">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div id="blurb">
|
||||
{{blurb | markdownify}}
|
||||
<div class="hero-unit">
|
||||
<img src="{{root}}/jq.png" style="width: 400px; height: 220px; float: left; margin-right: 60px">
|
||||
<div id="blurb">
|
||||
{{blurb | markdownify}}
|
||||
|
||||
<div class="btn-toolbar" role="toolbar">
|
||||
<div class="btn-group" role="group">
|
||||
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
Download jq 1.5
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64">Linux (64-bit)</a></li>
|
||||
<li><a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64">OS X (64-bit)</a></li>
|
||||
<li><a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win64.exe">Windows (64-bit)</a></li>
|
||||
<li><a href="/jq/download/">Other platforms, older versions, and source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-primary" href="https://jqplay.org">
|
||||
Try online at jqplay.org!
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group" style="float:right">
|
||||
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
Download jq-{{jq_version}}
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{root}}/download/linux64/jq">Linux (64-bit)</a></li>
|
||||
<li><a href="{{root}}/download/osx64/jq">OS X (64-bit)</a></li>
|
||||
<li><a href="{{root}}/download/solaris11-64/jq">Solaris (64-bit)</a></li>
|
||||
<li><a href="{{root}}/download/win64/jq.exe">Windows (64-bit)</a></li>
|
||||
<li><a href="{{root}}/download/">Other platforms, older versions, and source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="btn-group" style="float:right">
|
||||
<a class="btn btn-primary" href="https://jqplay.org">
|
||||
Try online at jqplay.org!
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row" id="multiblurb">
|
||||
<div class="col-sm-4">{{body1 | markdownify}}</div>
|
||||
<div class="col-sm-4">{{body2 | markdownify}}</div>
|
||||
<div class="col-sm-4">{{body3 | markdownify}}</div>
|
||||
<div class="span4">{{body1 | markdownify}}</div>
|
||||
<div class="span4">{{body2 | markdownify}}</div>
|
||||
<div class="span4">{{body3 | markdownify}}</div>
|
||||
</div>
|
||||
|
||||
<div class="row" style="text-align:center; margin-top: 30px">
|
||||
{{tail | markdownify}}
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<h2>News</h2>
|
||||
<div id="news">
|
||||
<ul>
|
||||
{% for item in news %}
|
||||
<li>
|
||||
<span class="date">{{item.date}}</span>
|
||||
{{item.body | markdownify}}
|
||||
</li>
|
||||
<li><span class="date">{{ item.date | date: '%m %B %Y' }}</span>{{item.body | markdownify}}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "shared/footer" %}
|
||||
{% include "shared/footer" %}
|
||||
</body>
|
||||
</html>
|
||||
Vendored
+90
-67
@@ -1,99 +1,122 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{% include "shared/head" %}
|
||||
|
||||
{% include "shared/head" %}
|
||||
<body id="{{slug}}" data-spy="scroll" data-target="#navcolumn" data-offset="100">
|
||||
{% include "shared/navbar" %}
|
||||
|
||||
{% include "shared/header" %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="affix" id="navcolumn">
|
||||
<div class="span3" id="navcolumn">
|
||||
<div class="affix">
|
||||
<h4>Contents</h4>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
{% for section in sections %}
|
||||
<li>
|
||||
<a href="#{{section.title | section_id}}">{{section.title}}</a>
|
||||
<li {% if forloop.first %} class="active" {% endif %}>
|
||||
<a href="#{{section.title | sanitize}}">{{section.title}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<form class="form-group" onsubmit="go_to_section(); return false;">
|
||||
<form class="form-search">
|
||||
<script type="text/javascript">
|
||||
var section_map = {
|
||||
{% for section in sections %}
|
||||
{% for entry in section.entries %}
|
||||
{{entry.title | json}} : {{entry.title | sanitize | json}},
|
||||
{% endfor %}
|
||||
{{section.title | json}} : {{section.title | sanitize | json}}
|
||||
{% unless forloop.last %},{% endunless %}
|
||||
{% endfor %}
|
||||
};
|
||||
var section_names = $.map(section_map, function(v,k){return k});
|
||||
$(function(){
|
||||
$('#searchbox').typeahead({source: section_names})
|
||||
$('#searchbox').change(function() {
|
||||
if ($(this).val() in section_map) {
|
||||
location.hash = '#' + section_map[$(this).val()];
|
||||
}
|
||||
});
|
||||
});
|
||||
// add "Run" button to execute examples on jqplay.org
|
||||
$(function() {
|
||||
$.each($('table.manual-example'), function(index, value) {
|
||||
$value = $(value)
|
||||
var j = $value.find('tr:nth-child(2) td:first').text();
|
||||
var q = $value.find('.jqprogram').text().replace(/^jq /, '').replace(/^'(.+)'$/, '$1');
|
||||
var url = 'https://jqplay.org/jq?q=' + encodeURIComponent(q) +'&j=' + encodeURIComponent(j)
|
||||
var $last_tr = $value.find('tr:last');
|
||||
$last_tr.after('<tr><th><a href="' + url + '" class="btn btn-primary btn-small">Run</a></th><th></th></tr><tr><th></th><th></th></tr>');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
placeholder="Search"
|
||||
autocomplete="off"
|
||||
id="searchbox">
|
||||
class="input-medium search-query"
|
||||
placeholder="Search"
|
||||
autocomplete="off"
|
||||
id="searchbox">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="manualcontent">
|
||||
<div class="span9">
|
||||
<h1>{{headline}}</h1>
|
||||
{{ history | markdownify }}
|
||||
{{ body | markdownify }}
|
||||
{% for section in sections %}
|
||||
<section id="{{section.title | section_id}}">
|
||||
<section id="{{section.title | sanitize}}">
|
||||
<h2>{{section.title}}</h2>
|
||||
{{section.body | markdownify}}
|
||||
{% for entry in section.entries %}
|
||||
<section id="{{entry.title | entry_id}}">
|
||||
<h3>
|
||||
{{entry.title | markdownify | no_paragraph}}
|
||||
{% if entry.subtitle %}<small>{{entry.subtitle}}</small>{% endif %}
|
||||
</h3>
|
||||
{{entry.body | markdownify}}
|
||||
<section id="{{entry.title | sanitize}}">
|
||||
<h3>
|
||||
{{entry.title | markdownify}}
|
||||
{% if entry.subtitle %}<small>{{entry.subtitle}}</small>{% endif %}
|
||||
</h3>
|
||||
{{entry.body | markdownify}}
|
||||
|
||||
{% if entry.examples %}
|
||||
<div>
|
||||
{% capture exampleID %}{{ "" | unique }}{% endcapture %}
|
||||
<a data-toggle="collapse" href="#example{{exampleID}}">
|
||||
<i class="glyphicon glyphicon-chevron-right"></i>
|
||||
{% if entry.examples[1] %}Examples{%else%}Example{%endif%}
|
||||
</a>
|
||||
<div id="example{{exampleID}}" class="manual-example collapse">
|
||||
{% for example in entry.examples %}
|
||||
<table>
|
||||
<tr><th></th><td class="jqprogram">jq '{{example.program | escape}}'</td></tr>
|
||||
<tr><th>Input</th><td>{{example.input | escape}}</td></tr>
|
||||
{% unless example.output[0] %}
|
||||
<tr>
|
||||
<th>Output</th>
|
||||
<td><i>none</i></td>
|
||||
</tr>
|
||||
{% endunless %}
|
||||
{% for output in example.output %}
|
||||
<tr>
|
||||
{% if forloop.index == 1 %}
|
||||
<th>Output</th>
|
||||
{% else %}
|
||||
<th></th>
|
||||
{% endif %}
|
||||
<td>{{output | escape}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% if entry.examples %}
|
||||
<div>
|
||||
{% capture exampleID %}{{ "" | unique }}{% endcapture %}
|
||||
<a data-toggle="collapse" href="#example{{exampleID}}">
|
||||
<i class="icon-chevron-right"></i>
|
||||
{% if entry.examples[1] %}Examples{%else%}Example{%endif%}
|
||||
</a>
|
||||
<div id="example{{exampleID}}" class="collapse">
|
||||
|
||||
{% for example in entry.examples %}
|
||||
<table class="manual-example">
|
||||
<tr><th></th><td class="jqprogram">jq '{{example.program | escape}}'</td></tr>
|
||||
<tr><th>Input</th><td>{{example.input | escape}}</td></tr>
|
||||
{% unless example.output[0] %}
|
||||
<tr>
|
||||
<th>Output</th>
|
||||
<td><i>none</i></td>
|
||||
</tr>
|
||||
{% endunless %}
|
||||
{% for output in example.output %}
|
||||
<tr>
|
||||
{% if forloop.index == 1 %}
|
||||
<th>Output</th>
|
||||
{% else %}
|
||||
<th></th>
|
||||
{% endif %}
|
||||
<td>{{output | escape}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</table>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endfor %}
|
||||
</section>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% include "shared/footer" %}
|
||||
<script>
|
||||
var section_map = {
|
||||
{% for section in sections %}
|
||||
{% for entry in section.entries %}
|
||||
{{entry.title | search_id | json}} : {{entry.title | entry_id | json}},
|
||||
{% endfor %}
|
||||
{{section.title | search_id | json}} : {{section.title | section_id | json}}
|
||||
{% unless forloop.last %},{% endunless %}
|
||||
{% endfor %}
|
||||
};
|
||||
</script>
|
||||
<script src="{{root}}/js/manual-search.js"></script>
|
||||
</div>
|
||||
{% include "shared/footer" %}
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
Vendored
+5
-10
@@ -1,10 +1,5 @@
|
||||
<footer>
|
||||
<div class="container">
|
||||
<p>This website is made with <a href="http://www.tinytree.info">Bonsai</a> and <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
|
||||
<p>jq is licensed under the MIT license (code) and the <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license (docs).</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
|
||||
<script src="https://twitter.github.io/typeahead.js/releases/0.11.1/typeahead.bundle.js"></script>
|
||||
<footer>
|
||||
<div class="container">
|
||||
{{ footer | markdownify }}
|
||||
</div>
|
||||
</footer>
|
||||
Vendored
+12
-17
@@ -1,17 +1,12 @@
|
||||
<head>
|
||||
<script>
|
||||
if ((window.location.host == "stedolan.github.io") && (window.location.protocol != "https:"))
|
||||
window.location.protocol = "https";
|
||||
</script>
|
||||
<meta charset="utf-8">
|
||||
<title>{{headline}}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<link rel="canonical" href="{{url}}{{permalink | remove:'/index'}}" />
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/spacelab/bootstrap.min.css" rel="stylesheet" integrity="sha256-j7Dtnd7ZjexEiPNbscbopFn9+Cs0b3TLipKsWAPHZIM= sha512-RFhfi6P8zWMAJrEGU+CPjuxPh3r/UUBGqQ+/o6WKPIVZmQqeOipGotH2ihRULuQ8wsMBoK15TSZqc/7VYWyuIw==" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="{{root}}/css/base.css" type="text/css">
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<head>
|
||||
<meta charset=UTF-8>
|
||||
<title>{{headline}}</title>
|
||||
<link rel="stylesheet" href="{{root}}/bootstrap/css/bootstrap.css" type="text/css">
|
||||
<link rel="stylesheet" href="{{root}}/css/base.css" type="text/css">
|
||||
<!--[if IE]>
|
||||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
|
||||
<script src="{{root}}/bootstrap/js/bootstrap.js"></script>
|
||||
|
||||
</head>
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="brand" href="{{root}}/">jq</a>
|
||||
<div class="nav-collapse collapse">
|
||||
<ul class="nav">
|
||||
{% for item in navigation %}
|
||||
<li {% if item.permalink == permalink %} class="active" {% endif %}>
|
||||
<a href="{{root}}{{item.permalink}}">{{item.name}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li><a href="https://github.com/stedolan/jq/issues">Issues</a></li>
|
||||
<li><a href="https://github.com/stedolan/jq">Source</a></li>
|
||||
<li><a href="https://jqplay.org">Try online!</a></li>
|
||||
<li><a href="https://raw.githubusercontent.com/stedolan/jq/master/NEWS">News</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Vendored
-27
@@ -1,27 +0,0 @@
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#nav-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="{{root}}/">jq</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse" id="nav-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
{% for item in navigation %}
|
||||
<li {% if item.permalink == permalink %} class="active" {% endif %}>
|
||||
<a href="{{root}}{{item.permalink}}">{{item.name}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li><a href="https://github.com/stedolan/jq/issues">Issues</a></li>
|
||||
<li><a href="https://github.com/stedolan/jq">Source</a></li>
|
||||
<li><a href="https://jqplay.org">Try online!</a></li>
|
||||
<li><a href="https://raw.githubusercontent.com/stedolan/jq/master/NEWS">News</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
File renamed without changes.
@@ -64,7 +64,7 @@ struct frame {
|
||||
stack_ptr env; // jq stack address of frame to return to
|
||||
stack_ptr retdata; // jq stack address to unwind to on RET
|
||||
uint16_t* retaddr; // jq bytecode return address
|
||||
union frame_entry entries[]; // nclosures + nlocals
|
||||
union frame_entry entries[0]; // nclosures + nlocals
|
||||
};
|
||||
|
||||
static int frame_size(struct bytecode* bc) {
|
||||
File renamed without changes.
@@ -0,0 +1,39 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "JQ" "1" "August 2015" "" ""
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBjq\fR \- Command\-line JSON processor
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
\fBjq\fR can transform JSON in various ways, by selecting, iterating, reducing and otherwise mangling JSON documents\.
|
||||
.
|
||||
.P
|
||||
This version of \fBjq\fR was built without a manual, so this manpage is a stub\. For full documentation of the \fBjq\fR language, see:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
https://stedolan\.github\.io/jq
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "BUGS"
|
||||
Presumably\. Report them or discuss them at:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
https://github\.com/stedolan/jq/issues
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "AUTHOR"
|
||||
Stephen Dolan \fB<mu@netsoc\.tcd\.ie>\fR
|
||||
+73
-274
@@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "JQ" "1" "February 2017" "" ""
|
||||
.TH "JQ" "1" "July 2015" "" ""
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBjq\fR \- Command\-line JSON processor
|
||||
@@ -52,7 +52,7 @@ Output the jq version and exit with zero\.
|
||||
\fB\-\-seq\fR:
|
||||
.
|
||||
.IP
|
||||
Use the \fBapplication/json\-seq\fR MIME type scheme for separating JSON texts in jq\'s input and output\. This means that an ASCII RS (record separator) character is printed before each value on output and an ASCII LF (line feed) is printed after every output\. Input JSON texts that fail to parse are ignored (but warned about), discarding all subsequent input until the next RS\. This mode also parses the output of jq without the \fB\-\-seq\fR option\.
|
||||
Use the \fBapplication/json\-seq\fR MIME type scheme for separating JSON texts in jq\'s input and output\. This means that an ASCII RS (record separator) character is printed before each value on output and an ASCII LF (line feed) is printed after every output\. Input JSON texts that fail to parse are ignored (but warned about), discarding all subsequent input until the next RS\. This more also parses the output of jq without the \fB\-\-seq\fR option\.
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
\fB\-\-stream\fR:
|
||||
@@ -178,13 +178,13 @@ This option reads all the JSON texts in the named file and binds an array of the
|
||||
Do not use\. Use \fB\-\-slurpfile\fR instead\.
|
||||
.
|
||||
.IP
|
||||
(This option is like \fB\-\-slurpfile\fR, but when the file has just one text, then that is used, else an array of texts is used as in \fB\-\-slurpfile\fR\.)
|
||||
(This option is like \fB\-\-slurpfile\fR, but when the file has just one text, then that is used, else an array of texts is used as in \fB\-\-slurfile\fR\.)
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
\fB\-\-run\-tests [filename]\fR:
|
||||
.
|
||||
.IP
|
||||
Runs the tests in the given file or standard input\. This must be the last option given and does not honor all preceding options\. The input consists of comment lines, empty lines, and program lines followed by one input line, as many lines of output as are expected (one per output), and a terminating empty line\. Compilation failure tests start with a line containing only "%%FAIL", then a line containing the program to compile, then a line containing an error message to compare to the actual\.
|
||||
Runs the tests in the given file or standard input\. This must be the last option given and does not honor all preceding options\. The input consts of comment lines, empty lines, and program lines followed by one input line, as many lines of output as are expected (one per output), and a terminating empty line\. Compilation failure tests start with a line containing only "%%FAIL", then a line containing the program to compile, then a line containing an error message to compare to the actual\.
|
||||
.
|
||||
.IP
|
||||
Be warned that this option can change backwards\-incompatibly\.
|
||||
@@ -277,7 +277,7 @@ The \fB\.[10:15]\fR syntax can be used to return a subarray of an array or subst
|
||||
The \fB\.[2]\fR syntax can be used to return the element at the given index\. Negative indices are allowed, with \-1 referring to the last element, \-2 referring to the next to last element, and so on\.
|
||||
.
|
||||
.P
|
||||
The \fB\.foo\fR syntax only works for simply keys i\.e\. keys that are all alphanumeric characters\. \fB\.[<string>]\fR works with keys that contain special characters such as colons and dots\. For example \fB\.["foo::bar"]\fR and \fB\.["foo\.bar"]\fR work while \fB\.foo::bar\fR and \fB\.foo\.bar\fR would not\.
|
||||
The \fB\.foo\fR syntax only works for simply keys i\.e\. keys that are all alphanumeric characters\. \fB\.[<string>]\fR works with keys that contain special charactors such as colons and dots\. For example \fB\.["foo::bar"]\fR and \fB\.["foo\.bar"]\fR work while \fB\.foo::bar\fR and \fB\.foo\.bar\fR would not\.
|
||||
.
|
||||
.P
|
||||
The \fB?\fR "operator" can also be used with the slice operator, as in \fB\.[10:15]?\fR, which outputs values where the inputs are slice\-able\.
|
||||
@@ -376,12 +376,6 @@ The | operator combines two filters by feeding the output(s) of the one on the l
|
||||
.P
|
||||
If the one on the left produces multiple results, the one on the right will be run for each of those results\. So, the expression \fB\.[] | \.foo\fR retrieves the "foo" field of each element of the input array\.
|
||||
.
|
||||
.P
|
||||
Note that \fB\.a\.b\.c\fR is the same as \fB\.a | \.b | \.c\fR\.
|
||||
.
|
||||
.P
|
||||
Note too that \fB\.\fR is the input value at the particular stage in a "pipeline", specifically: where the \fB\.\fR expression appears\. Thus \fB\.a | \. | \.b\fR is the same as \fB\.a\.b\fR, as the \fB\.\fR in the middle refers to whatever value \fB\.a\fR produced\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
@@ -394,21 +388,6 @@ jq \'\.[] | \.name\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "Parenthesis"
|
||||
Parenthesis work as a grouping operator just as in any typical programming language\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'(\. + 2) * 5\'
|
||||
1
|
||||
=> 15
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "TYPES AND VALUES"
|
||||
jq supports the same set of datatypes as JSON \- numbers, strings, booleans, arrays, objects (which in JSON\-speak are hashes with only string keys), and "null"\.
|
||||
.
|
||||
@@ -594,7 +573,7 @@ jq \'{a: 1} + {b: 2} + {c: 3} + {a: 42}\'
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "Subtraction \- \-"
|
||||
As well as normal arithmetic subtraction on numbers, the \fB\-\fR operator can be used on arrays to remove all occurrences of the second array\'s elements from the first array\.
|
||||
As well as normal arithmetic subtraction on numbers, the \fB\-\fR operator can be used on arrays to remove all occurences of the second array\'s elements from the first array\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -613,13 +592,13 @@ jq \'\. \- ["xml", "yaml"]\'
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "Multiplication, division, modulo \- *, /, and %"
|
||||
These infix operators behave as expected when given two numbers\. Division by zero raises an error\. \fBx % y\fR computes x modulo y\.
|
||||
These operators only work on numbers, and do the expected\.
|
||||
.
|
||||
.P
|
||||
Multiplying a string by a number produces the concatenation of that string that many times\. \fB"x" * 0\fR produces \fBnull\fR\.
|
||||
Multiplying a string by a number produces the concatenation of that string that many times\.
|
||||
.
|
||||
.P
|
||||
Dividing a string by another splits the first using the second as separators\.
|
||||
Dividing a string by another splits the first using the second as separators\. Division by zero raises an error\.
|
||||
.
|
||||
.P
|
||||
Multiplying two objects will merge them recursively: this works like addition but if both objects contain a value for the same key, and the values are objects, the two are merged with the same strategy\.
|
||||
@@ -668,21 +647,6 @@ jq \'\.[] | length\' [[1,2], "string", {"a":2}, null] => 2, 6, 1, 0
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "utf8bytelength"
|
||||
The builtin function \fButf8bytelength\fR outputs the number of bytes used to encode a string in UTF\-8\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'utf8bytelength\'
|
||||
"\eu03bc"
|
||||
=> 2
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "keys, keys_unsorted"
|
||||
The builtin function \fBkeys\fR, when given an object, returns its keys in an array\.
|
||||
.
|
||||
@@ -734,7 +698,7 @@ jq \'map(has(2))\'
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "in"
|
||||
The builtin function \fBin\fR returns whether or not the input key is in the given object, or the input index corresponds to an element in the given array\. It is, essentially, an inversed version of \fBhas\fR\.
|
||||
The builtin function \fBin\fR returns the input key is in the given object, or the input index corresponds to an element in the given array\. It is, essentially, an inversed version of \fBhas\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -752,33 +716,8 @@ jq \'map(in([0,1]))\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "map(x), map_values(x)"
|
||||
For any filter \fBx\fR, \fBmap(x)\fR will run that filter for each element of the input array, and return the outputs in a new array\. \fBmap(\.+1)\fR will increment each element of an array of numbers\.
|
||||
.
|
||||
.P
|
||||
Similarly, \fBmap_values(x)\fR will run that filter for each element, but it will return an object when an object is passed\.
|
||||
.
|
||||
.P
|
||||
\fBmap(x)\fR is equivalent to \fB[\.[] | x]\fR\. In fact, this is how it\'s defined\. Similarly, \fBmap_values(x)\fR is defined as \fB\.[] |= x\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'map(\.+1)\'
|
||||
[1,2,3]
|
||||
=> [2,3,4]
|
||||
|
||||
jq \'map_values(\.+1)\'
|
||||
{"a": 1, "b": 2, "c": 3}
|
||||
=> {"a": 2, "b": 3, "c": 4}
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "path(path_expression)"
|
||||
Outputs array representations of the given path expression in \fB\.\fR\. The outputs are arrays of strings (object keys) and/or numbers (array indices)\.
|
||||
Outputs array representations of the given path expression in \fB\.\fR\. The outputs are arrays of strings (keys in objects0 and/or numbers (array indices\.
|
||||
.
|
||||
.P
|
||||
Path expressions are jq expressions like \fB\.a\fR, but also \fB\.[]\fR\. There are two types of path expressions: ones that can match exactly, and ones that cannot\. For example, \fB\.a\.b\.c\fR is an exact match path expression, while \fB\.a[]\.b\fR is not\.
|
||||
@@ -827,68 +766,11 @@ jq \'del(\.[1, 2])\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "getpath(PATHS)"
|
||||
The builtin function \fBgetpath\fR outputs the values in \fB\.\fR found at each path in \fBPATHS\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'getpath(["a","b"])\'
|
||||
null
|
||||
=> null
|
||||
|
||||
jq \'[getpath(["a","b"], ["a","c"])]\'
|
||||
{"a":{"b":0, "c":1}}
|
||||
=> [0, 1]
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "setpath(PATHS; VALUE)"
|
||||
The builtin function \fBsetpath\fR sets the \fBPATHS\fR in \fB\.\fR to \fBVALUE\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'setpath(["a","b"]; 1)\'
|
||||
null
|
||||
=> {"a": {"b": 1}}
|
||||
|
||||
jq \'setpath(["a","b"]; 1)\'
|
||||
{"a":{"b":0}}
|
||||
=> {"a": {"b": 1}}
|
||||
|
||||
jq \'setpath([0,"a"]; 1)\'
|
||||
null
|
||||
=> [{"a":1}]
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "delpaths(PATHS)"
|
||||
The builtin function \fBdelpaths\fR sets the \fBPATHS\fR in \fB\.\fR\. \fBPATHS\fR must be an array of paths, where each path is an array of strings and numbers\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'delpaths([["a","b"]])\'
|
||||
{"a":{"b":1},"x":{"y":2}}
|
||||
=> {"a":{},"x":{"y":2}}
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "to_entries, from_entries, with_entries"
|
||||
These functions convert between an object and an array of key\-value pairs\. If \fBto_entries\fR is passed an object, then for each \fBk: v\fR entry in the input, the output array includes \fB{"key": k, "value": v}\fR\.
|
||||
.
|
||||
.P
|
||||
\fBfrom_entries\fR does the opposite conversion, and \fBwith_entries(foo)\fR is a shorthand for \fBto_entries | map(foo) | from_entries\fR, useful for doing some operation to all keys and values of an object\. \fBfrom_entries\fR accepts key, Key, name, Name, value and Value as keys\.
|
||||
\fBfrom_entries\fR does the opposite conversion, and \fBwith_entries(foo)\fR is a shorthand for \fBto_entries | map(foo) | from_entries\fR, useful for doing some operation to all keys and values of an object\. \fBfrom_entries\fR accepts key, Key, Name, value and Value as keys\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -987,6 +869,31 @@ jq \'try error("\e($__loc__)") catch \.\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "map(x), map_values(x)"
|
||||
For any filter \fBx\fR, \fBmap(x)\fR will run that filter for each element of the input array, and produce the outputs a new array\. \fBmap(\.+1)\fR will increment each element of an array of numbers\.
|
||||
.
|
||||
.P
|
||||
Similarly, \fBmap_values(x)\fR will run that filter for each element, but it will return an object when an object is passed\.
|
||||
.
|
||||
.P
|
||||
\fBmap(x)\fR is equivalent to \fB[\.[] | x]\fR\. In fact, this is how it\'s defined\. Similarly, \fBmap_values(x)\fR is defined as \fB\.[] |= x\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'map(\.+1)\'
|
||||
[1,2,3]
|
||||
=> [2,3,4]
|
||||
|
||||
jq \'map_values(\.+1)\'
|
||||
{"a": 1, "b": 2, "c": 3}
|
||||
=> {"a": 2, "b": 3, "c": 4}
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "paths, paths(node_filter), leaf_paths"
|
||||
\fBpaths\fR outputs the paths to all the elements in its input (except it does not output the empty list, representing \. itself)\.
|
||||
.
|
||||
@@ -1039,7 +946,7 @@ jq \'add\'
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "any, any(condition), any(generator; condition)"
|
||||
The filter \fBany\fR takes as input an array of boolean values, and produces \fBtrue\fR as output if any of the elements of the array are \fBtrue\fR\.
|
||||
The filter \fBany\fR takes as input an array of boolean values, and produces \fBtrue\fR as output if any of the the elements of the array is \fBtrue\fR\.
|
||||
.
|
||||
.P
|
||||
If the input is an empty array, \fBany\fR returns \fBfalse\fR\.
|
||||
@@ -1071,7 +978,7 @@ jq \'any\'
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "all, all(condition), all(generator; condition)"
|
||||
The filter \fBall\fR takes as input an array of boolean values, and produces \fBtrue\fR as output if all of the elements of the array are \fBtrue\fR\.
|
||||
The filter \fBall\fR takes as input an array of boolean values, and produces \fBtrue\fR as output if all of the the elements of the array are \fBtrue\fR\.
|
||||
.
|
||||
.P
|
||||
The \fBall(condition)\fR form applies the given condition to the elements of the input array\.
|
||||
@@ -1102,7 +1009,7 @@ jq \'all\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "flatten, flatten(depth)"
|
||||
.SS "[Requires 1\.5] flatten, flatten(depth)"
|
||||
The filter \fBflatten\fR takes as input an array of nested arrays, and produces a flat array in which all arrays inside the original array have been recursively replaced by their values\. You can pass an argument to it to specify how many levels of nesting to flatten\.
|
||||
.
|
||||
.P
|
||||
@@ -1621,7 +1528,7 @@ jq \'implode\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "split(str)"
|
||||
.SS "split"
|
||||
Splits an input string on the separator argument\.
|
||||
.
|
||||
.IP "" 4
|
||||
@@ -1639,9 +1546,6 @@ jq \'split(", ")\'
|
||||
.SS "join(str)"
|
||||
Joins the array of elements given as input, using the argument as separator\. It is the inverse of \fBsplit\fR: that is, running \fBsplit("foo") | join("foo")\fR over any input string returns said input string\.
|
||||
.
|
||||
.P
|
||||
Numbers and booleans in the input are converted to strings\. Null values are treated as empty strings\. Arrays and objects in the input are not supported\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
@@ -1649,10 +1553,6 @@ Numbers and booleans in the input are converted to strings\. Null values are tre
|
||||
jq \'join(", ")\'
|
||||
["a","b,c,d","e"]
|
||||
=> "a, b,c,d, e"
|
||||
|
||||
jq \'join(" ")\'
|
||||
["a",1,2\.3,true,null,false]
|
||||
=> "a 1 2\.3 true false"
|
||||
.
|
||||
.fi
|
||||
.
|
||||
@@ -1764,25 +1664,6 @@ jq \'recurse(\. * \.; \. < 20)\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "walk(f)"
|
||||
The \fBwalk(f)\fR function applies f recursively to every component of the input entity\. When an array is encountered, f is first applied to its elements and then to the array itself; when an object is encountered, f is first applied to all the values and then to the object\. In practice, f will usually test the type of its input, as illustrated in the following examples\. The first example highlights the usefulness of processing the elements of an array of arrays before processing the array itself\. The second example shows how all the keys of all the objects within the input can be considered for alteration\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'walk(if type == "array" then sort else \. end)\'
|
||||
[[4, 1, 7], [8, 5, 2], [3, 6, 9]]
|
||||
=> [[1,4,7],[2,5,8],[3,6,9]]
|
||||
|
||||
jq \'walk( if type == "object" then with_entries( \.key |= sub( "^_+"; "") ) else \. end )\'
|
||||
[ { "_a": { "__b": 2 } } ]
|
||||
=> [{"a":{"b":2}}]
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "\.\."
|
||||
Short\-hand for \fBrecurse\fR without arguments\. This is intended to resemble the XPath \fB//\fR operator\. Note that \fB\.\.a\fR does not work; use \fB\.\.|a\fR instead\. In the example below we use \fB\.\.|\.a?\fR to find all the values of object keys "a" in any object found "below" \fB\.\fR\.
|
||||
.
|
||||
@@ -1902,7 +1783,7 @@ Calls \fBtostring\fR, see that function for details\.
|
||||
\fB@json\fR:
|
||||
.
|
||||
.IP
|
||||
Serializes the input as JSON\.
|
||||
Serialises the input as JSON\.
|
||||
.
|
||||
.TP
|
||||
\fB@html\fR:
|
||||
@@ -1947,7 +1828,7 @@ This syntax can be combined with string interpolation in a useful way\. You can
|
||||
.
|
||||
.nf
|
||||
|
||||
@uri "https://www\.google\.com/search?q=\e(\.search)"
|
||||
@uri "http://www\.google\.com/search?q=\e(\.search)"
|
||||
.
|
||||
.fi
|
||||
.
|
||||
@@ -1960,7 +1841,7 @@ will produce the following output for the input \fB{"search":"what is jq?"}\fR:
|
||||
.
|
||||
.nf
|
||||
|
||||
"https://www\.google\.com/search?q=what%20is%20jq%3F"
|
||||
"http://www\.google\.com/search?q=what%20is%20jq%3F"
|
||||
.
|
||||
.fi
|
||||
.
|
||||
@@ -2041,45 +1922,6 @@ jq \'strptime("%Y\-%m\-%dT%H:%M:%SZ")|mktime\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "SQL\-Style Operators"
|
||||
jq provides a few SQL\-style operators\.
|
||||
.
|
||||
.TP
|
||||
INDEX(stream; index_expression):
|
||||
.
|
||||
.IP
|
||||
This builtin produces an object whose keys are computed by the given index expression applied to each value from the given stream\.
|
||||
.
|
||||
.TP
|
||||
JOIN($idx; stream; idx_expr; join_expr):
|
||||
.
|
||||
.IP
|
||||
This builtin joins the values from the given stream to the given index\. The index\'s keys are computed by applying the given index expression to each value from the given stream\. An array of the value in the stream and the corresponding value from the index is fed to the given join expression to produce each result\.
|
||||
.
|
||||
.TP
|
||||
JOIN($idx; stream; idx_expr):
|
||||
.
|
||||
.IP
|
||||
Same as \fBJOIN($idx; stream; idx_expr; \.)\fR\.
|
||||
.
|
||||
.TP
|
||||
JOIN($idx; idx_expr):
|
||||
.
|
||||
.IP
|
||||
This builtin joins the input \fB\.\fR to the given index, applying the given index expression to \fB\.\fR to compute the index key\. The join operation is as described above\.
|
||||
.
|
||||
.TP
|
||||
IN(s):
|
||||
.
|
||||
.IP
|
||||
This builtin outputs \fBtrue\fR if \fB\.\fR appears in the given stream, otherwise it outputs \fBfalse\fR\.
|
||||
.
|
||||
.TP
|
||||
IN(source; s):
|
||||
.
|
||||
.IP
|
||||
This builtin outputs \fBtrue\fR if any value in the source stream appears in the second stream, otherwise it outputs \fBfalse\fR\.
|
||||
.
|
||||
.SH "CONDITIONALS AND COMPARISONS"
|
||||
.
|
||||
.SS "==, !="
|
||||
@@ -2107,7 +1949,7 @@ jq \'\.[] == 1\'
|
||||
Checking for false or null is a simpler notion of "truthiness" than is found in Javascript or Python, but it means that you\'ll sometimes have to be more explicit about the condition you want: you can\'t test whether, e\.g\. a string is empty using \fBif \.name then A else B end\fR, you\'ll need something more like \fBif (\.name | length) > 0 then A else B end\fR instead\.
|
||||
.
|
||||
.P
|
||||
If the condition \fBA\fR produces multiple results, then \fBB\fR is evaluated once for each result that is not false or null, and \fBC\fR is evaluated once for each false or null\.
|
||||
If the condition A produces multiple results, it is considered "true" if any of those results is not false or null\. If it produces zero results, it\'s considered false\.
|
||||
.
|
||||
.P
|
||||
More cases can be added to an if using \fBelif A then B\fR syntax\.
|
||||
@@ -2123,7 +1965,18 @@ jq \'if \. == 0 then
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
"zero" elif \. == 1 then "one" else "many" end\' 2 => "many"
|
||||
"zero" elif \. == 1 then "one" else "many" end\'
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
2
|
||||
=> "many"
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS ">, >=, <=, <"
|
||||
The comparison operators \fB>\fR, \fB>=\fR, \fB<=\fR, \fB<\fR return whether their left argument is greater than, greater than or equal to, less than or equal to or less than their right argument (respectively)\.
|
||||
@@ -2379,7 +2232,7 @@ jq \-n \'("test", "TEst", "teST", "TEST") | test( "(?i)te(?\-i)st" )\'
|
||||
.P
|
||||
evaluates to: true, true, false, false\.
|
||||
.
|
||||
.SS "test(val), test(regex; flags)"
|
||||
.SS "[Requires 1\.5] test(val), test(regex; flags)"
|
||||
Like \fBmatch\fR, but does not return match objects, only \fBtrue\fR or \fBfalse\fR for whether or not the regex matches the input\.
|
||||
.
|
||||
.IP "" 4
|
||||
@@ -2398,7 +2251,7 @@ jq \'\.[] | test("a b c # spaces are ignored"; "ix")\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "match(val), match(regex; flags)"
|
||||
.SS "[Requires 1\.5] match(val), match(regex; flags)"
|
||||
\fBmatch\fR outputs an object for each match it finds\. Matches have the following fields:
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
@@ -2463,7 +2316,7 @@ jq \'[ match("\."; "g")] | length\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "capture(val), capture(regex; flags)"
|
||||
.SS "[Requires 1\.5] capture(val), capture(regex; flags)"
|
||||
Collects the named captures in a JSON object, with the name of each capture as the key, and the matched string as the corresponding value\.
|
||||
.
|
||||
.IP "" 4
|
||||
@@ -2478,19 +2331,19 @@ jq \'capture("(?<a>[a\-z]+)\-(?<n>[0\-9]+)")\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "scan(regex), scan(regex; flags)"
|
||||
.SS "[Requires 1\.5] scan(regex), scan(regex; flags)"
|
||||
Emit a stream of the non\-overlapping substrings of the input that match the regex in accordance with the flags, if any have been specified\. If there is no match, the stream is empty\. To capture all the matches for each input string, use the idiom \fB[ expr ]\fR, e\.g\. \fB[ scan(regex) ]\fR\.
|
||||
.
|
||||
.SS "split(regex; flags)"
|
||||
For backwards compatibility, \fBsplit\fR splits on a string, not a regex\.
|
||||
.
|
||||
.SS "splits(regex), splits(regex; flags)"
|
||||
.SS "[Requires 1\.5] splits(regex), splits(regex; flags)"
|
||||
These provide the same results as their \fBsplit\fR counterparts, but as a stream instead of an array\.
|
||||
.
|
||||
.SS "sub(regex; tostring) sub(regex; string; flags)"
|
||||
.SS "[Requires 1\.5] sub(regex; tostring) sub(regex; string; flags)"
|
||||
Emit the string obtained by replacing the first match of regex in the input string with \fBtostring\fR, after interpolation\. \fBtostring\fR should be a jq string, and may contain references to named captures\. The named captures are, in effect, presented as a JSON object (as constructed by \fBcapture\fR) to \fBtostring\fR, so a reference to a captured variable named "x" would take the form: "(\.x)"\.
|
||||
.
|
||||
.SS "gsub(regex; string), gsub(regex; string; flags)"
|
||||
.SS "[Requires 1\.5] gsub(regex; string), gsub(regex; string; flags)"
|
||||
\fBgsub\fR is like \fBsub\fR but all the non\-overlapping occurrences of the regex are replaced by the string, after interpolation\.
|
||||
.
|
||||
.SH "ADVANCED FEATURES"
|
||||
@@ -2671,7 +2524,7 @@ def increment: \. + 1;
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
From then on, \fBincrement\fR is usable as a filter just like a builtin function (in fact, this is how many of the builtins are defined)\. A function may take arguments:
|
||||
From then on, \fBincrement\fR is usable as a filter just like a builtin function (in fact, this is how some of the builtins are defined)\. A function may take arguments:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -2684,7 +2537,7 @@ def map(f): [\.[] | f];
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Arguments are passed as \fIfilters\fR (functions with no arguments), \fInot\fR as values\. The same argument may be referenced multiple times with different inputs (here \fBf\fR is run for each element of the input array)\. Arguments to a function work more like callbacks than like value arguments\. This is important to understand\. Consider:
|
||||
Arguments are passed as filters, not as values\. The same argument may be referenced multiple times with different inputs (here \fBf\fR is run for each element of the input array)\. Arguments to a function work more like callbacks than like value arguments\. This is important to understand\. Consider:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -2727,10 +2580,10 @@ def addvalue($f): \.\.\.;
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
With either definition, \fBaddvalue(\.foo)\fR will add the current input\'s \fB\.foo\fR field to each element of the array\. Do note that calling \fBaddvalue(\.[])\fR will cause the \fBmap(\. + $f)\fR part to be evaluated once per value in the value of \fB\.\fR at the call site\.
|
||||
With either definition, \fBaddvalue(\.foo)\fR will add the current input\'s \fB\.foo\fR field to each element of the array\.
|
||||
.
|
||||
.P
|
||||
Multiple definitions using the same function name are allowed\. Each re\-definition replaces the previous one for the same number of function arguments, but only for references from functions (or main program) subsequent to the re\-definition\. See also the section below on scoping\.
|
||||
Multiple definitions using the same function name are allowed\. Each re\-definition replaces the previous one for the same number of function arguments, but only for references from functions (or main program) subsequent to the re\-definition\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -2748,12 +2601,6 @@ jq \'def addvalue(f): f as $x | map(\. + $x); addvalue(\.[0])\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "Scoping"
|
||||
There are two types of symbols in jq: value bindings (a\.k\.a\., "variables"), and functions\. Both are scoped lexically, with expressions being able to refer only to symbols that have been defined "to the left" of them\. The only exception to this rule is that functions can refer to themselves so as to be able to create recursive functions\.
|
||||
.
|
||||
.P
|
||||
For example, in the following expression there is a binding which is visible "to the right" of it, \fB\.\.\. | \.*3 as $times_three | [\. + $times_three] | \.\.\.\fR, but not "to the left"\. Consider this expression now, \fB\.\.\. | (\.*3 as $times_three | [\.+ $times_three]) | \.\.\.\fR: here the binding \fB$times_three\fR is \fInot\fR visible past the closing parenthesis\.
|
||||
.
|
||||
.SS "Reduce"
|
||||
The \fBreduce\fR syntax in jq allows you to combine all of the results of an expression by accumulating them into a single answer\. As an example, we\'ll pass \fB[3,2,1]\fR to this expression:
|
||||
.
|
||||
@@ -2777,25 +2624,10 @@ For each result that \fB\.[]\fR produces, \fB\. + $item\fR is run to accumulate
|
||||
0 | (3 as $item | \. + $item) |
|
||||
(2 as $item | \. + $item) |
|
||||
(1 as $item | \. + $item)
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
If the reduction update expression outputs \fBempty\fR (that is, no values), then the reduction state is left as\-is\. For example, \fBreduce range(4) as $n ({}; if \.==2 then empty else \.[$n|tostring] |= $n)\fR will produce \fB{"0":0,"1":1,"3":3}\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'reduce \.[] as $item (0; \. + $item)\'
|
||||
[10,2,5,3]
|
||||
=> 20
|
||||
|
||||
jq \'reduce \.[] as $n ([]; if $n%2==0 then empty else \. + [$n] end)\'
|
||||
[0,1,2,3,4,5]
|
||||
=> [1,3,5]
|
||||
.
|
||||
.fi
|
||||
.
|
||||
@@ -2877,7 +2709,7 @@ jq \'[foreach \.[] as $item ([[],[]]; if $item == null then [[],\.[0]] else [(\.
|
||||
As described above, \fBrecurse\fR uses recursion, and any jq function can be recursive\. The \fBwhile\fR builtin is also implemented in terms of recursion\.
|
||||
.
|
||||
.P
|
||||
Tail calls are optimized whenever the expression to the left of the recursive call outputs its last value\. In practice this means that the expression to the left of the recursive call should not produce more than one output for each input\.
|
||||
Tail calls are optmized whenever the expression to the left of the recursive call outputs its last value\. In practice this means that the expression to the left of the recursive call should not produce more than one output for each input\.
|
||||
.
|
||||
.P
|
||||
For example:
|
||||
@@ -2934,32 +2766,17 @@ jq \'def while(cond; update): def _while: if cond then \., (update | _while) els
|
||||
jq currently only has IEEE754 double\-precision (64\-bit) floating point number support\.
|
||||
.
|
||||
.P
|
||||
Besides simple arithmetic operators such as \fB+\fR, jq also has most standard math functions from the C math library\. C math functions that take a single input argument (e\.g\., \fBsin()\fR) are available as zero\-argument jq functions\. C math functions that take two input arguments (e\.g\., \fBpow()\fR) are available as two\-argument jq functions that ignore \fB\.\fR\. C math functions that take three input arguments are available as three\-argument jq functions that ignore \fB\.\fR\.
|
||||
Besides simple arithmetic operators such as \fB+\fR, jq also has most standard math functions from the C math library\. C math functions that take a single input argument (e\.g\., \fBsin()\fR) are available as zero\-argument jq functions\. C math functions that take two input arguments (e\.g\., \fBpow()\fR) are available as two\-argument jq functions that ignore \fB\.\fR\.
|
||||
.
|
||||
.P
|
||||
Availability of standard math functions depends on the availability of the corresponding math functions in your operating system and C math library\. Unavailable math functions will be defined but will raise an error\.
|
||||
.
|
||||
.P
|
||||
One\-input C math functions: \fBacos\fR \fBacosh\fR \fBasin\fR \fBasinh\fR \fBatan\fR \fBatanh\fR \fBcbrt\fR \fBceil\fR \fBcos\fR \fBcosh\fR \fBerf\fR \fBerfc\fR \fBexp\fR \fBexp10\fR \fBexp2\fR \fBexpm1\fR \fBfabs\fR \fBfloor\fR \fBgamma\fR \fBj0\fR \fBj1\fR \fBlgamma\fR \fBlog\fR \fBlog10\fR \fBlog1p\fR \fBlog2\fR \fBlogb\fR \fBnearbyint\fR \fBpow10\fR \fBrint\fR \fBround\fR \fBsignificand\fR \fBsin\fR \fBsinh\fR \fBsqrt\fR \fBtan\fR \fBtanh\fR \fBtgamma\fR \fBtrunc\fR \fBy0\fR \fBy1\fR\.
|
||||
.
|
||||
.P
|
||||
Two\-input C math functions: \fBatan2\fR \fBcopysign\fR \fBdrem\fR \fBfdim\fR \fBfmax\fR \fBfmin\fR \fBfmod\fR \fBfrexp\fR \fBhypot\fR \fBjn\fR \fBldexp\fR \fBmodf\fR \fBnextafter\fR \fBnexttoward\fR \fBpow\fR \fBremainder\fR \fBscalb\fR \fBscalbln\fR \fByn\fR\.
|
||||
.
|
||||
.P
|
||||
Three\-input C math functions: \fBfma\fR\.
|
||||
.
|
||||
.P
|
||||
See your system\'s manual for more information on each of these\.
|
||||
.
|
||||
.SH "I/O"
|
||||
At this time jq has minimal support for I/O, mostly in the form of control over when inputs are read\. Two builtins functions are provided for this, \fBinput\fR and \fBinputs\fR, that read from the same sources (e\.g\., \fBstdin\fR, files named on the command\-line) as jq itself\. These two builtins, and jq\'s own reading actions, can be interleaved with each other\.
|
||||
.
|
||||
.P
|
||||
One builtin provides minimal output capabilities, \fBdebug\fR\. (Recall that a jq program\'s output values are always output as JSON texts on \fBstdout\fR\.) The \fBdebug\fR builtin can have application\-specific behavior, such as for executables that use the libjq C API but aren\'t the jq executable itself\.
|
||||
.
|
||||
.P
|
||||
Most jq builtins are referentially transparent, and yield constant and repeatable value streams when applied to constant inputs\. This is not true of I/O builtins\.
|
||||
.
|
||||
.SS "input"
|
||||
Outputs one new input\.
|
||||
.
|
||||
@@ -2988,7 +2805,7 @@ However, streaming isn\'t easy to deal with as the jq program will have \fB[<pat
|
||||
Several builtins are provided to make handling streams easier\.
|
||||
.
|
||||
.P
|
||||
The examples below use the streamed form of \fB[0,[1]]\fR, which is \fB[[0],0],[[1,0],1],[[1,0]],[[1]]\fR\.
|
||||
The examples below use the the streamed form of \fB[0,[1]]\fR, which is \fB[[0],1],[[1,0],2],[[1,0]],[[1]])]\fR\.
|
||||
.
|
||||
.P
|
||||
Streaming forms include \fB[<path>, <leaf\-value>]\fR (to indicate any scalar value, empty array, or empty object), and \fB[<path>]\fR (to indicate the end of an array or object)\. Future versions of jq run with \fB\-\-stream\fR and \fB\-seq\fR may output additional forms such as \fB["error message"]\fR when an input text fails to parse\.
|
||||
@@ -3044,12 +2861,6 @@ Assignment works a little differently in jq than in most programming languages\.
|
||||
.P
|
||||
If an object has two fields which are arrays, \fB\.foo\fR and \fB\.bar\fR, and you append something to \fB\.foo\fR, then \fB\.bar\fR will not get bigger\. Even if you\'ve just set \fB\.bar = \.foo\fR\. If you\'re used to programming in languages like Python, Java, Ruby, Javascript, etc\. then you can think of it as though jq does a full deep copy of every object before it does the assignment (for performance, it doesn\'t actually do that, but that\'s the general idea)\.
|
||||
.
|
||||
.P
|
||||
All the assignment operators in jq have path expressions on the left\-hand side\.
|
||||
.
|
||||
.P
|
||||
Values in jq are always immutable\. Internally, assignment works by using a reduction to compute new, replacement values for \fB\.\fR that have had all the desired assignments applied to \fB\.\fR, then outputting the modified value\. This might be made clear by this example: \fB{a:{b:{c:1}}} | (\.a\.b|=3), \.\fR\. This will output \fB{"a":{"b":3}}\fR and \fB{"a":{"b":{"c":1}}}\fR because the last sub\-expression, \fB\.\fR, sees the original value, not the modified value\.
|
||||
.
|
||||
.SS "="
|
||||
The filter \fB\.foo = 1\fR will take as input an object and produce as output an object with the "foo" field set to 1\. There is no notion of "modifying" or "changing" something in jq \- all jq values are immutable\. For instance,
|
||||
.
|
||||
@@ -3063,13 +2874,7 @@ will not have the side\-effect of setting \.bar\.baz to be set to 1, as the simi
|
||||
This means that it\'s impossible to build circular values in jq (such as an array whose first element is itself)\. This is quite intentional, and ensures that anything a jq program can produce can be represented in JSON\.
|
||||
.
|
||||
.P
|
||||
Note that the left\-hand side of \'=\' refers to a value in \fB\.\fR\. Thus \fB$var\.foo = 1\fR won\'t work as expected (\fB$var\.foo\fR is not a valid or useful path expression in \fB\.\fR); use \fB$var | \.foo = 1\fR instead\.
|
||||
.
|
||||
.P
|
||||
If the right\-hand side of \'=\' produces multiple values, then for each such value jq will set the paths on the left\-hand side to the value and then it will output the modified \fB\.\fR\. For example, \fB(\.a,\.b)=range(2)\fR outputs \fB{"a":0,"b":0}\fR, then \fB{"a":1,"b":1}\fR\. The "update" assignment forms (see below) do not do this\.
|
||||
.
|
||||
.P
|
||||
Note too that \fB\.a,\.b=0\fR does not set \fB\.a\fR and \fB\.b\fR, but \fB(\.a,\.b)=0\fR sets both\.
|
||||
Note that the left\-hand side of \'=\' refers to a value in \fB\.\fR\. Thus \fB$var\.foo = 1\fR won\'t work as expected; use \fB$var | \.foo = 1\fR instead\.
|
||||
.
|
||||
.SS "|="
|
||||
As well as the assignment operator \'=\', jq provides the "update" operator \'|=\', which takes a filter on the right\-hand side and works out the new value for the property of \fB\.\fR being assigned to by running the old value through this expression\. For instance, \.foo |= \.+1 will build an object with the "foo" field set to the input\'s "foo" plus 1\.
|
||||
@@ -3090,13 +2895,7 @@ The former will set the "a" field of the input to the "b" field of the input, an
|
||||
The left\-hand side can be any general path expression; see \fBpath()\fR\.
|
||||
.
|
||||
.P
|
||||
Note that the left\-hand side of \'|=\' refers to a value in \fB\.\fR\. Thus \fB$var\.foo |= \. + 1\fR won\'t work as expected (\fB$var\.foo\fR is not a valid or useful path expression in \fB\.\fR); use \fB$var | \.foo |= \. + 1\fR instead\.
|
||||
.
|
||||
.P
|
||||
If the right\-hand side outputs no values (i\.e\., \fBempty\fR), then the left\-hand side path will be deleted, as with \fBdel(path)\fR\.
|
||||
.
|
||||
.P
|
||||
If the right\-hand side outputs multiple values, only the first one will be used (NOTE: it used to be that only the last one was used)\.
|
||||
Note that the left\-hand side of \'|=\' refers to a value in \fB\.\fR\. Thus \fB$var\.foo |= \. + 1\fR won\'t work as expected; use \fB$var | \.foo |= \. + 1\fR instead\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#define JQ_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "jv.h"
|
||||
#include <jv.h>
|
||||
|
||||
enum {JQ_DEBUG_TRACE = 1};
|
||||
|
||||
File renamed without changes.
@@ -157,7 +157,7 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata) {
|
||||
printf(" for test at line number %u: %s\n", lineno, prog);
|
||||
pass = 0;
|
||||
}
|
||||
jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOR|JV_PRINT_REFCOUNT));
|
||||
jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOUR|JV_PRINT_REFCOUNT));
|
||||
jv reparsed = jv_parse_sized(jv_string_value(as_string), jv_string_length_bytes(jv_copy(as_string)));
|
||||
assert(jv_equal(jv_copy(expected), jv_copy(reparsed)));
|
||||
jv_free(as_string);
|
||||
+1
-2
@@ -6,7 +6,6 @@
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "jv_alloc.h"
|
||||
#include "jv.h"
|
||||
@@ -1303,7 +1302,7 @@ int jv_identical(jv a, jv b) {
|
||||
r = a.u.ptr == b.u.ptr;
|
||||
break;
|
||||
case JV_KIND_NUMBER:
|
||||
r = memcmp(&a.u.number, &b.u.number, sizeof(a.u.number)) == 0;
|
||||
r = a.u.number == b.u.number;
|
||||
break;
|
||||
default:
|
||||
r = 1;
|
||||
+14
-42
@@ -92,16 +92,13 @@ jv jv_array_indexes(jv, jv);
|
||||
#define JV_ARRAY_9(e1,e2,e3,e4,e5,e6,e7,e8,e9) (jv_array_append(JV_ARRAY_8(e1,e2,e3,e4,e5,e6,e7,e8),e9))
|
||||
#define JV_ARRAY_IDX(_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME
|
||||
#define JV_ARRAY(...) \
|
||||
JV_ARRAY_IDX(__VA_ARGS__, JV_ARRAY_9, JV_ARRAY_8, JV_ARRAY_7, JV_ARRAY_6, JV_ARRAY_5, JV_ARRAY_4, JV_ARRAY_3, JV_ARRAY_2, JV_ARRAY_1, dummy)(__VA_ARGS__)
|
||||
JV_ARRAY_IDX(__VA_ARGS__, JV_ARRAY_9, JV_ARRAY_8, JV_ARRAY_7, JV_ARRAY_6, JV_ARRAY_5, JV_ARRAY_4, JV_ARRAY_3, JV_ARRAY_2, JV_ARRAY_1)(__VA_ARGS__)
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define JV_PRINTF_LIKE(fmt_arg_num, args_num) \
|
||||
__attribute__ ((__format__( __printf__, fmt_arg_num, args_num)))
|
||||
#define JV_VPRINTF_LIKE(fmt_arg_num) \
|
||||
__attribute__ ((__format__( __printf__, fmt_arg_num, 0)))
|
||||
#else
|
||||
#define JV_PRINTF_LIKE(fmt_arg_num, args_num)
|
||||
#define JV_VPRINTF_LIKE(fmt_arg_num)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -115,8 +112,8 @@ const char* jv_string_value(jv);
|
||||
jv jv_string_indexes(jv j, jv k);
|
||||
jv jv_string_slice(jv j, int start, int end);
|
||||
jv jv_string_concat(jv, jv);
|
||||
jv jv_string_vfmt(const char* fmt, va_list ap) JV_VPRINTF_LIKE(1);
|
||||
jv jv_string_fmt(const char* fmt, ...) JV_PRINTF_LIKE(1, 2);
|
||||
jv jv_string_vfmt(const char*, va_list) JV_VPRINTF_LIKE(1);
|
||||
jv jv_string_fmt(const char*, ...) JV_PRINTF_LIKE(1, 2);
|
||||
jv jv_string_append_codepoint(jv a, uint32_t c);
|
||||
jv jv_string_append_buf(jv a, const char* buf, int len);
|
||||
jv jv_string_append_str(jv a, const char* str);
|
||||
@@ -147,51 +144,26 @@ jv jv_object_iter_value(jv, int);
|
||||
: 0; \
|
||||
jv_i__ = jv_object_iter_next(t, jv_i__)) \
|
||||
|
||||
#define JV_OBJECT_1(k1) (jv_object_set(jv_object(),(k1),jv_null()))
|
||||
#define JV_OBJECT_1(k) (jv_object_set(jv_object(),(k),jv_null()))
|
||||
#define JV_OBJECT_2(k1,v1) (jv_object_set(jv_object(),(k1),(v1)))
|
||||
#define JV_OBJECT_3(k1,v1,k2) (jv_object_set(JV_OBJECT_2((k1),(v1)),(k2),jv_null()))
|
||||
#define JV_OBJECT_4(k1,v1,k2,v2) (jv_object_set(JV_OBJECT_2((k1),(v1)),(k2),(v2)))
|
||||
#define JV_OBJECT_5(k1,v1,k2,v2,k3) (jv_object_set(JV_OBJECT_4((k1),(v1),(k2),(v2)),(k3),jv_null()))
|
||||
#define JV_OBJECT_6(k1,v1,k2,v2,k3,v3) (jv_object_set(JV_OBJECT_4((k1),(v1),(k2),(v2)),(k3),(v3)))
|
||||
#define JV_OBJECT_7(k1,v1,k2,v2,k3,v3,k4) (jv_object_set(JV_OBJECT_6((k1),(v1),(k2),(v2),(k3),(v3)),(k4),jv_null()))
|
||||
#define JV_OBJECT_8(k1,v1,k2,v2,k3,v3,k4,v4) (jv_object_set(JV_OBJECT_6((k1),(v1),(k2),(v2),(k3),(v3)),(k4),(v4)))
|
||||
#define JV_OBJECT_9(k1,v1,k2,v2,k3,v3,k4,v4,k5) \
|
||||
(jv_object_set(JV_OBJECT_8((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4)),(k5),jv_null()))
|
||||
#define JV_OBJECT_10(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5) \
|
||||
(jv_object_set(JV_OBJECT_8((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4)),(k5),(v5)))
|
||||
#define JV_OBJECT_11(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6) \
|
||||
(jv_object_set(JV_OBJECT_10((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5)),(k6),jv_null()))
|
||||
#define JV_OBJECT_12(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6) \
|
||||
(jv_object_set(JV_OBJECT_10((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5)),(k6),(v6)))
|
||||
#define JV_OBJECT_13(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7) \
|
||||
(jv_object_set(JV_OBJECT_12((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6)),(k7),jv_null()))
|
||||
#define JV_OBJECT_14(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7) \
|
||||
(jv_object_set(JV_OBJECT_12((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6)),(k7),(v7)))
|
||||
#define JV_OBJECT_15(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8) \
|
||||
(jv_object_set(JV_OBJECT_14((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6),(k7),(v7)),(k8),jv_null()))
|
||||
#define JV_OBJECT_16(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8) \
|
||||
(jv_object_set(JV_OBJECT_14((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6),(k7),(v7)),(k8),(v8)))
|
||||
#define JV_OBJECT_17(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8,k9) \
|
||||
(jv_object_set(JV_OBJECT_16((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6),(k7),(v7),(k8),(v8)),(k9),jv_null()))
|
||||
#define JV_OBJECT_18(k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8,k9,v9) \
|
||||
(jv_object_set(JV_OBJECT_16((k1),(v1),(k2),(v2),(k3),(v3),(k4),(v4),(k5),(v5),(k6),(v6),(k7),(v7),(k8),(v8)),(k9),(v9)))
|
||||
#define JV_OBJECT_IDX(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,NAME,...) NAME
|
||||
#define JV_OBJECT_3(k1,v1,k2) (jv_object_set(JV_OBJECT_2(k1,v1),k2,jv_null()))
|
||||
#define JV_OBJECT_4(k1,v1,k2,v2) (jv_object_set(JV_OBJECT_2(k1,v1),k2,v2))
|
||||
#define JV_OBJECT_5(k1,v1,k2,v2,k3) (jv_object_set(JV_OBJECT_4(k1,v1,k2,v2),k3,jv_null))
|
||||
#define JV_OBJECT_6(k1,v1,k2,v2,k3,v3) (jv_object_set(JV_OBJECT_4(k1,v1,k2,v2),k3,v3))
|
||||
#define JV_OBJECT_7(k1,v1,k2,v2,k3,v3,k4) (jv_object_set(JV_OBJECT_6(k1,v1,k2,v2,k3,v3),k4,jv_null()))
|
||||
#define JV_OBJECT_8(k1,v1,k2,v2,k3,v3,k4,v4) (jv_object_set(JV_OBJECT_6(k1,v1,k2,v2,k3,v3),k4,v4))
|
||||
#define JV_OBJECT_IDX(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
|
||||
#define JV_OBJECT(...) \
|
||||
JV_OBJECT_IDX(__VA_ARGS__, \
|
||||
JV_OBJECT_18, JV_OBJECT_17, JV_OBJECT_16, JV_OBJECT_15, \
|
||||
JV_OBJECT_14, JV_OBJECT_13, JV_OBJECT_12, JV_OBJECT_11, \
|
||||
JV_OBJECT_10, JV_OBJECT_9, JV_OBJECT_8, JV_OBJECT_7, \
|
||||
JV_OBJECT_6, JV_OBJECT_5, JV_OBJECT_4, JV_OBJECT_3, \
|
||||
JV_OBJECT_2, JV_OBJECT_1)(__VA_ARGS__)
|
||||
JV_OBJECT_IDX(__VA_ARGS__, JV_OBJECT_8, JV_OBJECT_7, JV_OBJECT_6, JV_OBJECT_5, JV_OBJECT_4, JV_OBJECT_3, JV_OBJECT_2, JV_OBJECT_1)(__VA_ARGS__)
|
||||
|
||||
|
||||
|
||||
int jv_get_refcnt(jv);
|
||||
|
||||
enum {
|
||||
enum jv_print_flags {
|
||||
JV_PRINT_PRETTY = 1,
|
||||
JV_PRINT_ASCII = 2,
|
||||
JV_PRINT_COLOR = 4,
|
||||
JV_PRINT_COLOUR = 4,
|
||||
JV_PRINT_SORTED = 8,
|
||||
JV_PRINT_INVALID = 16,
|
||||
JV_PRINT_REFCOUNT = 32,
|
||||
File renamed without changes.
File renamed without changes.
+12
-36
@@ -214,7 +214,7 @@ jv jv_has(jv t, jv k) {
|
||||
}
|
||||
|
||||
// assumes keys is a sorted array
|
||||
static jv jv_dels(jv t, jv keys) {
|
||||
jv jv_dels(jv t, jv keys) {
|
||||
assert(jv_get_kind(keys) == JV_KIND_ARRAY);
|
||||
assert(jv_is_valid(t));
|
||||
|
||||
@@ -222,17 +222,13 @@ static jv jv_dels(jv t, jv keys) {
|
||||
// no change
|
||||
} else if (jv_get_kind(t) == JV_KIND_ARRAY) {
|
||||
// extract slices, they must be handled differently
|
||||
jv neg_keys = jv_array();
|
||||
jv nonneg_keys = jv_array();
|
||||
jv orig_keys = keys;
|
||||
keys = jv_array();
|
||||
jv new_array = jv_array();
|
||||
jv starts = jv_array(), ends = jv_array();
|
||||
jv_array_foreach(keys, i, key) {
|
||||
jv_array_foreach(orig_keys, i, key) {
|
||||
if (jv_get_kind(key) == JV_KIND_NUMBER) {
|
||||
if (jv_number_value(key) < 0) {
|
||||
neg_keys = jv_array_append(neg_keys, key);
|
||||
} else {
|
||||
nonneg_keys = jv_array_append(nonneg_keys, key);
|
||||
}
|
||||
keys = jv_array_append(keys, key);
|
||||
} else if (jv_get_kind(key) == JV_KIND_OBJECT) {
|
||||
int start, end;
|
||||
if (parse_slice(jv_copy(t), key, &start, &end)) {
|
||||
@@ -252,30 +248,18 @@ static jv jv_dels(jv t, jv keys) {
|
||||
}
|
||||
}
|
||||
|
||||
int neg_idx = 0;
|
||||
int nonneg_idx = 0;
|
||||
int len = jv_array_length(jv_copy(t));
|
||||
int kidx = 0;
|
||||
jv_array_foreach(t, i, elem) {
|
||||
int del = 0;
|
||||
while (neg_idx < jv_array_length(jv_copy(neg_keys))) {
|
||||
int delidx = len + (int)jv_number_value(jv_array_get(jv_copy(neg_keys), neg_idx));
|
||||
while (kidx < jv_array_length(jv_copy(keys))) {
|
||||
int delidx = (int)jv_number_value(jv_array_get(jv_copy(keys), kidx));
|
||||
if (i == delidx) {
|
||||
del = 1;
|
||||
}
|
||||
if (i < delidx) {
|
||||
break;
|
||||
}
|
||||
neg_idx++;
|
||||
}
|
||||
while (nonneg_idx < jv_array_length(jv_copy(nonneg_keys))) {
|
||||
int delidx = (int)jv_number_value(jv_array_get(jv_copy(nonneg_keys), nonneg_idx));
|
||||
if (i == delidx) {
|
||||
del = 1;
|
||||
}
|
||||
if (i < delidx) {
|
||||
break;
|
||||
}
|
||||
nonneg_idx++;
|
||||
kidx++;
|
||||
}
|
||||
for (int sidx=0; !del && sidx<jv_array_length(jv_copy(starts)); sidx++) {
|
||||
if ((int)jv_number_value(jv_array_get(jv_copy(starts), sidx)) <= i &&
|
||||
@@ -289,10 +273,9 @@ static jv jv_dels(jv t, jv keys) {
|
||||
jv_free(elem);
|
||||
}
|
||||
arr_out:
|
||||
jv_free(neg_keys);
|
||||
jv_free(nonneg_keys);
|
||||
jv_free(starts);
|
||||
jv_free(ends);
|
||||
jv_free(orig_keys);
|
||||
jv_free(t);
|
||||
t = new_array;
|
||||
} else if (jv_get_kind(t) == JV_KIND_OBJECT) {
|
||||
@@ -407,11 +390,6 @@ static jv delpaths_sorted(jv object, jv paths, int start) {
|
||||
}
|
||||
|
||||
jv jv_delpaths(jv object, jv paths) {
|
||||
if (jv_get_kind(paths) != JV_KIND_ARRAY) {
|
||||
jv_free(object);
|
||||
jv_free(paths);
|
||||
return jv_invalid_with_msg(jv_string("Paths must be specified as an array"));
|
||||
}
|
||||
paths = jv_sort(paths, jv_copy(paths));
|
||||
jv_array_foreach(paths, i, elem) {
|
||||
if (jv_get_kind(elem) != JV_KIND_ARRAY) {
|
||||
@@ -571,15 +549,14 @@ int jv_cmp(jv a, jv b) {
|
||||
struct sort_entry {
|
||||
jv object;
|
||||
jv key;
|
||||
int index;
|
||||
};
|
||||
|
||||
static int sort_cmp(const void* pa, const void* pb) {
|
||||
const struct sort_entry* a = pa;
|
||||
const struct sort_entry* b = pb;
|
||||
int r = jv_cmp(jv_copy(a->key), jv_copy(b->key));
|
||||
// comparing by index if r == 0 makes the sort stable
|
||||
return r ? r : (a->index - b->index);
|
||||
// comparing by address if r == 0 makes the sort stable
|
||||
return r ? r : (int)(a - b);
|
||||
}
|
||||
|
||||
static struct sort_entry* sort_items(jv objects, jv keys) {
|
||||
@@ -591,7 +568,6 @@ static struct sort_entry* sort_items(jv objects, jv keys) {
|
||||
for (int i=0; i<n; i++) {
|
||||
entries[i].object = jv_array_get(jv_copy(objects), i);
|
||||
entries[i].key = jv_array_get(jv_copy(keys), i);
|
||||
entries[i].index = i;
|
||||
}
|
||||
jv_free(objects);
|
||||
jv_free(keys);
|
||||
@@ -2327,7 +2327,7 @@ retlow1:
|
||||
jvp_strtod
|
||||
(struct dtoa_context* C, const char *s00, char **se)
|
||||
{
|
||||
int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1, test_scale;
|
||||
int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1;
|
||||
int esign, i, j, k, nd, nd0, nf, nz, nz0, nz1, sign;
|
||||
CONST char *s, *s0, *s1;
|
||||
double aadj, aadj1;
|
||||
@@ -2941,11 +2941,12 @@ jvp_strtod
|
||||
if (!word1(&rv)
|
||||
&& !(word0(&rv) & Frac_mask)) {
|
||||
y = word0(&rv) & Exp_mask;
|
||||
test_scale = y;
|
||||
#ifdef Avoid_Underflow
|
||||
test_scale = (!bc.scale || y > 2*P*Exp_msk1);
|
||||
if (!bc.scale || y > 2*P*Exp_msk1)
|
||||
#else
|
||||
if (y)
|
||||
#endif
|
||||
if (test_scale) {
|
||||
{
|
||||
delta = lshift(C, delta,Log2P);
|
||||
if (cmp(C, delta, bs) <= 0)
|
||||
adj.d = -0.5;
|
||||
File renamed without changes.
@@ -4,7 +4,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jv.h"
|
||||
#include "jv_unicode.h"
|
||||
|
||||
jv jv_load_file(const char* filename, int raw) {
|
||||
FILE* file = fopen(filename, "r");
|
||||
@@ -21,23 +20,11 @@ jv jv_load_file(const char* filename, int raw) {
|
||||
data = jv_array();
|
||||
parser = jv_parser_new(0);
|
||||
}
|
||||
|
||||
// To avoid mangling UTF-8 multi-byte sequences that cross the end of our read
|
||||
// buffer, we need to be able to read the remainder of a sequence and add that
|
||||
// before appending.
|
||||
const int max_utf8_len = 4;
|
||||
char buf[4096+max_utf8_len];
|
||||
while (!feof(file) && !ferror(file)) {
|
||||
size_t n = fread(buf, 1, sizeof(buf)-max_utf8_len, file);
|
||||
int len = 0;
|
||||
if (jvp_utf8_backtrack(buf+(n-1), buf, &len) && len > 0) {
|
||||
if (!feof(file) && !ferror(file)) {
|
||||
n += fread(buf+n, 1, len, file);
|
||||
}
|
||||
}
|
||||
|
||||
char buf[4096];
|
||||
size_t n = fread(buf, 1, sizeof(buf), file);
|
||||
if (raw) {
|
||||
data = jv_string_append_buf(data, buf, n);
|
||||
data = jv_string_concat(data, jv_string_sized(buf, (int)n));
|
||||
} else {
|
||||
jv_parser_set_buf(parser, buf, n, !feof(file));
|
||||
jv value;
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
typedef const char* presult;
|
||||
|
||||
#ifndef MAX_PARSING_DEPTH
|
||||
#define MAX_PARSING_DEPTH (256)
|
||||
#endif
|
||||
|
||||
#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
|
||||
#ifdef __GNUC__
|
||||
#define pfunc __attribute__((warn_unused_result)) presult
|
||||
@@ -151,13 +147,11 @@ static void push(struct jv_parser* p, jv v) {
|
||||
static pfunc parse_token(struct jv_parser* p, char ch) {
|
||||
switch (ch) {
|
||||
case '[':
|
||||
if (p->stackpos >= MAX_PARSING_DEPTH) return "Exceeds depth limit for parsing";
|
||||
if (jv_is_valid(p->next)) return "Expected separator between values";
|
||||
push(p, jv_array());
|
||||
break;
|
||||
|
||||
case '{':
|
||||
if (p->stackpos >= MAX_PARSING_DEPTH) return "Exceeds depth limit for parsing";
|
||||
if (jv_is_valid(p->next)) return "Expected separator between values";
|
||||
push(p, jv_object());
|
||||
break;
|
||||
@@ -389,7 +383,7 @@ static pfunc stream_token(struct jv_parser* p, char ch) {
|
||||
|
||||
static void tokenadd(struct jv_parser* p, char c) {
|
||||
assert(p->tokenpos <= p->tokenlen);
|
||||
if (p->tokenpos >= (p->tokenlen - 1)) {
|
||||
if (p->tokenpos == p->tokenlen) {
|
||||
p->tokenlen = p->tokenlen*2 + 256;
|
||||
p->tokenbuf = jv_mem_realloc(p->tokenbuf, p->tokenlen);
|
||||
}
|
||||
@@ -491,7 +485,7 @@ static pfunc check_literal(struct jv_parser* p) {
|
||||
TRY(value(p, v));
|
||||
} else {
|
||||
// FIXME: better parser
|
||||
p->tokenbuf[p->tokenpos] = 0;
|
||||
p->tokenbuf[p->tokenpos] = 0; // FIXME: invalid
|
||||
char* end = 0;
|
||||
double d = jvp_strtod(&p->dtoa, p->tokenbuf, &end);
|
||||
if (end == 0 || *end != 0)
|
||||
+24
-30
@@ -13,23 +13,19 @@
|
||||
#include "jv_dtoa.h"
|
||||
#include "jv_unicode.h"
|
||||
|
||||
#ifndef MAX_PRINT_DEPTH
|
||||
#define MAX_PRINT_DEPTH (256)
|
||||
#endif
|
||||
|
||||
#define ESC "\033"
|
||||
#define COL(c) (ESC "[" c "m")
|
||||
#define COLRESET (ESC "[0m")
|
||||
|
||||
// Color table. See https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
||||
// Colour table. See https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
||||
// for how to choose these.
|
||||
static const jv_kind color_kinds[] =
|
||||
static const jv_kind colour_kinds[] =
|
||||
{JV_KIND_NULL, JV_KIND_FALSE, JV_KIND_TRUE, JV_KIND_NUMBER,
|
||||
JV_KIND_STRING, JV_KIND_ARRAY, JV_KIND_OBJECT};
|
||||
static const char* const colors[] =
|
||||
static const char* const colours[] =
|
||||
{COL("1;30"), COL("0;39"), COL("0;39"), COL("0;39"),
|
||||
COL("0;32"), COL("1;39"), COL("1;39")};
|
||||
#define FIELD_COLOR COL("34;1")
|
||||
#define FIELD_COLOUR COL("34;1")
|
||||
|
||||
static void put_buf(const char *s, int len, FILE *fout, jv *strout, int is_tty) {
|
||||
if (strout) {
|
||||
@@ -119,10 +115,10 @@ static void jvp_dump_string(jv str, int ascii_only, FILE* F, jv* S, int T) {
|
||||
}
|
||||
if (unicode_escape) {
|
||||
if (c <= 0xffff) {
|
||||
snprintf(buf, sizeof(buf), "\\u%04x", c);
|
||||
sprintf(buf, "\\u%04x", c);
|
||||
} else {
|
||||
c -= 0x10000;
|
||||
snprintf(buf, sizeof(buf), "\\u%04x\\u%04x",
|
||||
sprintf(buf, "\\u%04x\\u%04x",
|
||||
0xD800 | ((c & 0xffc00) >> 10),
|
||||
0xDC00 | (c & 0x003ff));
|
||||
}
|
||||
@@ -143,20 +139,18 @@ static void put_refcnt(struct dtoa_context* C, int refcnt, FILE *F, jv* S, int T
|
||||
|
||||
static void jv_dump_term(struct dtoa_context* C, jv x, int flags, int indent, FILE* F, jv* S) {
|
||||
char buf[JVP_DTOA_FMT_MAX_LEN];
|
||||
const char* color = 0;
|
||||
const char* colour = 0;
|
||||
double refcnt = (flags & JV_PRINT_REFCOUNT) ? jv_get_refcnt(x) - 1 : -1;
|
||||
if (flags & JV_PRINT_COLOR) {
|
||||
for (unsigned i=0; i<sizeof(color_kinds)/sizeof(color_kinds[0]); i++) {
|
||||
if (jv_get_kind(x) == color_kinds[i]) {
|
||||
color = colors[i];
|
||||
put_str(color, F, S, flags & JV_PRINT_ISATTY);
|
||||
if (flags & JV_PRINT_COLOUR) {
|
||||
for (unsigned i=0; i<sizeof(colour_kinds)/sizeof(colour_kinds[0]); i++) {
|
||||
if (jv_get_kind(x) == colour_kinds[i]) {
|
||||
colour = colours[i];
|
||||
put_str(colour, F, S, flags & JV_PRINT_ISATTY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (indent > MAX_PRINT_DEPTH) {
|
||||
put_str("<skipped: too deep>", F, S, flags & JV_PRINT_ISATTY);
|
||||
} else switch (jv_get_kind(x)) {
|
||||
switch (jv_get_kind(x)) {
|
||||
default:
|
||||
case JV_KIND_INVALID:
|
||||
if (flags & JV_PRINT_INVALID) {
|
||||
@@ -219,13 +213,13 @@ static void jv_dump_term(struct dtoa_context* C, jv x, int flags, int indent, FI
|
||||
}
|
||||
}
|
||||
jv_dump_term(C, elem, flags, indent + 1, F, S);
|
||||
if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);
|
||||
if (colour) put_str(colour, F, S, flags & JV_PRINT_ISATTY);
|
||||
}
|
||||
if (flags & JV_PRINT_PRETTY) {
|
||||
put_char('\n', F, S, flags & JV_PRINT_ISATTY);
|
||||
put_indent(indent, flags, F, S, flags & JV_PRINT_ISATTY);
|
||||
}
|
||||
if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);
|
||||
if (colour) put_str(colour, F, S, flags & JV_PRINT_ISATTY);
|
||||
put_char(']', F, S, flags & JV_PRINT_ISATTY);
|
||||
if (flags & JV_PRINT_REFCOUNT)
|
||||
put_refcnt(C, refcnt, F, S, flags & JV_PRINT_ISATTY);
|
||||
@@ -278,33 +272,33 @@ static void jv_dump_term(struct dtoa_context* C, jv x, int flags, int indent, FI
|
||||
put_str(",", F, S, flags & JV_PRINT_ISATTY);
|
||||
}
|
||||
}
|
||||
if (color) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
|
||||
if (colour) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
|
||||
|
||||
first = 0;
|
||||
if (color) put_str(FIELD_COLOR, F, S, flags & JV_PRINT_ISATTY);
|
||||
if (colour) put_str(FIELD_COLOUR, F, S, flags & JV_PRINT_ISATTY);
|
||||
jvp_dump_string(key, flags & JV_PRINT_ASCII, F, S, flags & JV_PRINT_ISATTY);
|
||||
jv_free(key);
|
||||
if (color) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
|
||||
if (colour) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
|
||||
|
||||
if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);
|
||||
if (colour) put_str(colour, F, S, flags & JV_PRINT_ISATTY);
|
||||
put_str((flags & JV_PRINT_PRETTY) ? ": " : ":", F, S, flags & JV_PRINT_ISATTY);
|
||||
if (color) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
|
||||
if (colour) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
|
||||
|
||||
jv_dump_term(C, value, flags, indent + 1, F, S);
|
||||
if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);
|
||||
if (colour) put_str(colour, F, S, flags & JV_PRINT_ISATTY);
|
||||
}
|
||||
if (flags & JV_PRINT_PRETTY) {
|
||||
put_char('\n', F, S, flags & JV_PRINT_ISATTY);
|
||||
put_indent(indent, flags, F, S, flags & JV_PRINT_ISATTY);
|
||||
}
|
||||
if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);
|
||||
if (colour) put_str(colour, F, S, flags & JV_PRINT_ISATTY);
|
||||
put_char('}', F, S, flags & JV_PRINT_ISATTY);
|
||||
if (flags & JV_PRINT_REFCOUNT)
|
||||
put_refcnt(C, refcnt, F, S, flags & JV_PRINT_ISATTY);
|
||||
}
|
||||
}
|
||||
jv_free(x);
|
||||
if (color) {
|
||||
if (colour) {
|
||||
put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
|
||||
}
|
||||
}
|
||||
@@ -323,7 +317,7 @@ void jv_dump(jv x, int flags) {
|
||||
/* This one is nice for use in debuggers */
|
||||
void jv_show(jv x, int flags) {
|
||||
if (flags == -1)
|
||||
flags = JV_PRINT_PRETTY | JV_PRINT_COLOR | JV_PRINT_INDENT_FLAGS(2);
|
||||
flags = JV_PRINT_PRETTY | JV_PRINT_COLOUR | JV_PRINT_INDENT_FLAGS(2);
|
||||
jv_dumpf(jv_copy(x), stderr, flags | JV_PRINT_INVALID);
|
||||
fflush(stderr);
|
||||
}
|
||||
@@ -3,29 +3,6 @@
|
||||
#include "jv_unicode.h"
|
||||
#include "jv_utf8_tables.h"
|
||||
|
||||
// jvp_utf8_backtrack returns the beginning of the last codepoint in the
|
||||
// string, assuming that start is the last byte in the string.
|
||||
// If the last codepoint is incomplete, returns the number of missing bytes via
|
||||
// *missing_bytes. If there are no leading bytes or an invalid byte is
|
||||
// encountered, NULL is returned and *missing_bytes is not altered.
|
||||
const char* jvp_utf8_backtrack(const char* start, const char* min, int *missing_bytes) {
|
||||
assert(min < start);
|
||||
if (min == start) {
|
||||
return min;
|
||||
}
|
||||
int length = 0;
|
||||
int seen = 1;
|
||||
while (start >= min && (length = utf8_coding_length[(unsigned char)*start]) == UTF8_CONTINUATION_BYTE) {
|
||||
start--;
|
||||
seen++;
|
||||
}
|
||||
if (length == 0 || length == UTF8_CONTINUATION_BYTE || length - seen < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (missing_bytes) *missing_bytes = length - seen;
|
||||
return start;
|
||||
}
|
||||
|
||||
const char* jvp_utf8_next(const char* in, const char* end, int* codepoint_ret) {
|
||||
assert(in <= end);
|
||||
if (in == end) {
|
||||
@@ -82,12 +59,11 @@ int jvp_utf8_is_valid(const char* in, const char* end) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Assumes startchar is the first byte of a valid character sequence */
|
||||
int jvp_utf8_decode_length(char startchar) {
|
||||
if ((startchar & 0x80) == 0) return 1; // 0___ ____
|
||||
else if ((startchar & 0xE0) == 0xC0) return 2; // 110_ ____
|
||||
else if ((startchar & 0xF0) == 0xE0) return 3; // 1110 ____
|
||||
else return 4; // 1111 ____
|
||||
if ((startchar & 0x80) == 0) return 1;
|
||||
else if ((startchar & 0xC0) == 0xC0) return 2;
|
||||
else if ((startchar & 0xE0) == 0xE0) return 3;
|
||||
else return 4;
|
||||
}
|
||||
|
||||
int jvp_utf8_encode_length(int codepoint) {
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef JV_UNICODE_H
|
||||
#define JV_UNICODE_H
|
||||
|
||||
const char* jvp_utf8_backtrack(const char* start, const char* min, int *missing_bytes);
|
||||
const char* jvp_utf8_next(const char* in, const char* end, int* codepoint);
|
||||
int jvp_utf8_is_valid(const char* in, const char* end);
|
||||
|
||||
File renamed without changes.
@@ -1134,8 +1134,8 @@ YY_RULE_SETUP
|
||||
case 38:
|
||||
YY_RULE_SETUP
|
||||
#line 88 "lexer.l"
|
||||
{
|
||||
yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL;
|
||||
{
|
||||
yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL;
|
||||
}
|
||||
YY_BREAK
|
||||
case 39:
|
||||
@@ -2399,7 +2399,7 @@ static int try_exit(int c, int state, yyscan_t yyscanner) {
|
||||
case IN_BRACE: match = ret = '}'; break;
|
||||
|
||||
case IN_QQINTERP:
|
||||
match = ')';
|
||||
match = ')';
|
||||
ret = QQSTRING_INTERP_END;
|
||||
break;
|
||||
|
||||
File renamed without changes.
@@ -85,8 +85,8 @@ struct lexer_param;
|
||||
yylval->literal = jv_string_sized(yytext + 1, yyleng - 1); return FORMAT;
|
||||
}
|
||||
|
||||
[0-9.]+([eE][+-]?[0-9]+)? {
|
||||
yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL;
|
||||
[0-9.]+([eE][+-]?[0-9]+)? {
|
||||
yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL;
|
||||
}
|
||||
|
||||
"\"" {
|
||||
@@ -117,7 +117,7 @@ struct lexer_param;
|
||||
return INVALID_CHARACTER;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
([a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]* { yylval->literal = jv_string(yytext); return IDENT;}
|
||||
\.[a-zA-Z_][a-zA-Z_0-9]* { yylval->literal = jv_string(yytext+1); return FIELD;}
|
||||
@@ -142,7 +142,7 @@ static int try_exit(int c, int state, yyscan_t yyscanner) {
|
||||
case IN_BRACE: match = ret = '}'; break;
|
||||
|
||||
case IN_QQINTERP:
|
||||
match = ')';
|
||||
match = ')';
|
||||
ret = QQSTRING_INTERP_END;
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
#ifdef HAVE_ACOS
|
||||
LIBM_DD(acos)
|
||||
#else
|
||||
LIBM_DD_NO(acos)
|
||||
#endif
|
||||
#ifdef HAVE_ACOSH
|
||||
LIBM_DD(acosh)
|
||||
#else
|
||||
LIBM_DD_NO(acosh)
|
||||
#endif
|
||||
#ifdef HAVE_ASIN
|
||||
LIBM_DD(asin)
|
||||
#else
|
||||
LIBM_DD_NO(asin)
|
||||
#endif
|
||||
#ifdef HAVE_ASINH
|
||||
LIBM_DD(asinh)
|
||||
#else
|
||||
LIBM_DD_NO(asinh)
|
||||
#endif
|
||||
#ifdef HAVE_ATAN
|
||||
LIBM_DD(atan)
|
||||
#else
|
||||
LIBM_DD_NO(atan)
|
||||
#endif
|
||||
#ifdef HAVE_ATANH
|
||||
LIBM_DD(atanh)
|
||||
#else
|
||||
LIBM_DD_NO(atanh)
|
||||
#endif
|
||||
#ifdef HAVE_CBRT
|
||||
LIBM_DD(cbrt)
|
||||
#else
|
||||
LIBM_DD_NO(cbrt)
|
||||
#endif
|
||||
#ifdef HAVE_COS
|
||||
LIBM_DD(cos)
|
||||
#else
|
||||
LIBM_DD_NO(cos)
|
||||
#endif
|
||||
#ifdef HAVE_COSH
|
||||
LIBM_DD(cosh)
|
||||
#else
|
||||
LIBM_DD_NO(cosh)
|
||||
#endif
|
||||
#ifdef HAVE_EXP2
|
||||
LIBM_DD(exp2)
|
||||
#else
|
||||
LIBM_DD_NO(exp2)
|
||||
#endif
|
||||
#ifdef HAVE_EXP
|
||||
LIBM_DD(exp)
|
||||
#else
|
||||
LIBM_DD_NO(exp)
|
||||
#endif
|
||||
#ifdef HAVE_FLOOR
|
||||
LIBM_DD(floor)
|
||||
#else
|
||||
LIBM_DD_NO(floor)
|
||||
#endif
|
||||
#ifdef HAVE_J0
|
||||
LIBM_DD(j0)
|
||||
#else
|
||||
LIBM_DD_NO(j0)
|
||||
#endif
|
||||
#ifdef HAVE_J1
|
||||
LIBM_DD(j1)
|
||||
#else
|
||||
LIBM_DD_NO(j1)
|
||||
#endif
|
||||
#ifdef HAVE_LOG10
|
||||
LIBM_DD(log10)
|
||||
#else
|
||||
LIBM_DD_NO(log10)
|
||||
#endif
|
||||
#ifdef HAVE_LOG2
|
||||
LIBM_DD(log2)
|
||||
#else
|
||||
LIBM_DD_NO(log2)
|
||||
#endif
|
||||
#ifdef HAVE_LOG
|
||||
LIBM_DD(log)
|
||||
#else
|
||||
LIBM_DD_NO(log)
|
||||
#endif
|
||||
#ifdef HAVE_SIN
|
||||
LIBM_DD(sin)
|
||||
#else
|
||||
LIBM_DD_NO(sin)
|
||||
#endif
|
||||
#ifdef HAVE_SINH
|
||||
LIBM_DD(sinh)
|
||||
#else
|
||||
LIBM_DD_NO(sinh)
|
||||
#endif
|
||||
#ifdef HAVE_SQRT
|
||||
LIBM_DD(sqrt)
|
||||
#else
|
||||
LIBM_DD_NO(sqrt)
|
||||
#endif
|
||||
#ifdef HAVE_TAN
|
||||
LIBM_DD(tan)
|
||||
#else
|
||||
LIBM_DD_NO(tan)
|
||||
#endif
|
||||
#ifdef HAVE_TANH
|
||||
LIBM_DD(tanh)
|
||||
#else
|
||||
LIBM_DD_NO(tanh)
|
||||
#endif
|
||||
#ifdef HAVE_TGAMMA
|
||||
LIBM_DD(tgamma)
|
||||
#else
|
||||
LIBM_DD_NO(tgamma)
|
||||
#endif
|
||||
#ifdef HAVE_Y0
|
||||
LIBM_DD(y0)
|
||||
#else
|
||||
LIBM_DD_NO(y0)
|
||||
#endif
|
||||
#ifdef HAVE_Y1
|
||||
LIBM_DD(y1)
|
||||
#else
|
||||
LIBM_DD_NO(y1)
|
||||
#endif
|
||||
#ifdef HAVE_POW
|
||||
LIBM_DDD(pow)
|
||||
#else
|
||||
LIBM_DDD_NO(pow)
|
||||
#endif
|
||||
#ifdef HAVE_JN
|
||||
LIBM_DID(jn)
|
||||
#endif
|
||||
#ifdef HAVE_YN
|
||||
LIBM_DID(yn)
|
||||
#endif
|
||||
#ifdef HAVE_ATAN2
|
||||
LIBM_DDD(atan2)
|
||||
#else
|
||||
LIBM_DDD_NO(atan2)
|
||||
#endif
|
||||
#ifdef HAVE_HYPOT
|
||||
LIBM_DDD(hypot)
|
||||
#else
|
||||
LIBM_DDD_NO(hypot)
|
||||
#endif
|
||||
#ifdef HAVE_REMAINDER
|
||||
LIBM_DDD(remainder)
|
||||
#else
|
||||
LIBM_DDD_NO(remainder)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifdef HAVE_SCALBN
|
||||
LIBM_DDI(scalbn)
|
||||
#endif
|
||||
#ifdef HAVE_LGAMMA_R
|
||||
LIBM_DDIP(lgamma_r)
|
||||
#endif
|
||||
#endif
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <libgen.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
#endif
|
||||
|
||||
File renamed without changes.
File renamed without changes.
Loaded 100 of 160 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user