mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-12 12:01:14 -03:00
Compare commits
117 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed5c1db392 | ||
|
|
37f5db2bf9 | ||
|
|
8a97bffd02 | ||
|
|
2fd48bce11 | ||
|
|
d1a3e6abf5 | ||
|
|
1a29979bbd | ||
|
|
69814e5066 | ||
|
|
4dbac8f941 | ||
|
|
303473f20c | ||
|
|
480a29594e | ||
|
|
dfe3dc1429 | ||
|
|
2ea00ce444 | ||
|
|
ac13bdeaa7 | ||
|
|
22cb7dd2d7 | ||
|
|
20698cc813 | ||
|
|
1ebf571da5 | ||
|
|
7c822cbf30 | ||
|
|
90302d9232 | ||
|
|
bee6805ff9 | ||
|
|
65035c4dc7 | ||
|
|
2b0d64184a | ||
|
|
51d7159ba7 | ||
|
|
0a4819be27 | ||
|
|
72ad4e0d3b | ||
|
|
21de293a44 | ||
|
|
8b395d05ef | ||
|
|
8392902cec | ||
|
|
a5abdd2792 | ||
|
|
e784683b8a | ||
|
|
7fadf6c083 | ||
|
|
7ff76476ed | ||
|
|
cd9102214b | ||
|
|
8da54a1955 | ||
|
|
6899e4e734 | ||
|
|
486e0dbe84 | ||
|
|
441c109afb | ||
|
|
4b0810d7e9 | ||
|
|
51d58a6a7c | ||
|
|
7a884e11a6 | ||
|
|
c4acfdd87c | ||
|
|
41f8007a03 | ||
|
|
8207030b21 | ||
|
|
a2c70f495e | ||
|
|
b11f366bb0 | ||
|
|
0e1a3c7c4a | ||
|
|
d3a75a354a | ||
|
|
afc49dded2 | ||
|
|
49b232df84 | ||
|
|
248d11c462 | ||
|
|
6b1570b745 | ||
|
|
dc3634dc94 | ||
|
|
696b4df1c6 | ||
|
|
65f4d6e866 | ||
|
|
8833e8f4ea | ||
|
|
f29026b767 | ||
|
|
7ecf7c1fac | ||
|
|
4a2fa5ea34 | ||
|
|
03f6656af6 | ||
|
|
8e6dbe245c | ||
|
|
daf171aa86 | ||
|
|
d1bbb89389 | ||
|
|
bd0c1573df | ||
|
|
2700a9b697 | ||
|
|
474f6e90ff | ||
|
|
7cbc11f1c3 | ||
|
|
09f9d43be3 | ||
|
|
109e7455a8 | ||
|
|
9b95332aa9 | ||
|
|
cccd13db92 | ||
|
|
2c8a2c9f61 | ||
|
|
f05e1f6e48 | ||
|
|
f439c4a484 | ||
|
|
2fba53b113 | ||
|
|
8a2846ed44 | ||
|
|
91b63e4989 | ||
|
|
89d876d0f7 | ||
|
|
e79fdcb194 | ||
|
|
60f0533821 | ||
|
|
0768cf7e53 | ||
|
|
bdd83d338c | ||
|
|
db369a9ad7 | ||
|
|
aa895c6740 | ||
|
|
8e06805f2d | ||
|
|
00360d8fbc | ||
|
|
3b365d9f8d | ||
|
|
3835000e9d | ||
|
|
9bbe19bfb8 | ||
|
|
787e99d901 | ||
|
|
713748c782 | ||
|
|
c9eb74fa4b | ||
|
|
b2d940c25a | ||
|
|
2a7bc8c04b | ||
|
|
013d3dbb89 | ||
|
|
0aff94dd4c | ||
|
|
431850b4ec | ||
|
|
e280d10033 | ||
|
|
8c4708b51e | ||
|
|
4ba9ac28bb | ||
|
|
4664d65af7 | ||
|
|
1b7157a03f | ||
|
|
e1dd17a7dd | ||
|
|
5c8d9bd13c | ||
|
|
1c9a173b3d | ||
|
|
a0c40fcf8d | ||
|
|
f36811b7be | ||
|
|
40ed01f6f2 | ||
|
|
b2e2743195 | ||
|
|
1dc033f71c | ||
|
|
ba4166d17d | ||
|
|
46c6f7880b | ||
|
|
bef7fff383 | ||
|
|
0811613fe9 | ||
|
|
a09abea737 | ||
|
|
fd4e5e6777 | ||
|
|
57b3965518 | ||
|
|
3e843f8219 | ||
|
|
2343ce5a0c |
143
Makefile.in
143
Makefile.in
@@ -36,10 +36,6 @@
|
||||
CC := @CC@
|
||||
INSTALL:=@INSTALL@
|
||||
|
||||
CFLAGS:=@CFLAGS@
|
||||
CPPFLAGS=@CPPFLAGS@
|
||||
LDFLAGS:= @LIBS@ @LDFLAGS@
|
||||
|
||||
# Installation directories
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
@@ -47,8 +43,17 @@ datadir = @datadir@
|
||||
bindir = @bindir@
|
||||
mandir = @mandir@
|
||||
sysconfdir = @sysconfdir@
|
||||
fishinputfile = @fishinputfile@
|
||||
docdir = @docdir@
|
||||
localedir = @localedir@
|
||||
prefix = @prefix@
|
||||
optbindirs = @optbindirs@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
|
||||
MACROS=-DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\"
|
||||
CFLAGS=@CFLAGS@ $(MACROS)
|
||||
CPPFLAGS=@CPPFLAGS@
|
||||
LDFLAGS= @LIBS@ @LDFLAGS@
|
||||
|
||||
|
||||
#etc files to install
|
||||
ETC_DIR_INSTALL = etc/fish_interactive.fish
|
||||
@@ -65,7 +70,7 @@ FISH_OBJS := function.o builtin.o complete.o env.o exec.o \
|
||||
expand.o highlight.o history.o kill.o parser.o proc.o reader.o \
|
||||
sanity.o tokenizer.o wildcard.o wgetopt.o wutil.o input.o \
|
||||
output.o intern.o env_universal.o env_universal_common.o \
|
||||
input_common.o event.o signal.o io.o translate.o parse_util.o common.o \
|
||||
input_common.o event.o signal.o io.o parse_util.o common.o \
|
||||
|
||||
# Additional files used by builtin.o
|
||||
BUILTIN_FILES := builtin_help.c builtin_set.c builtin_commandline.c \
|
||||
@@ -74,7 +79,7 @@ BUILTIN_FILES := builtin_help.c builtin_set.c builtin_commandline.c \
|
||||
# All objects that the system needs to build fish_pager
|
||||
FISH_PAGER_OBJS := fish_pager.o output.o wutil.o \
|
||||
tokenizer.o input_common.o env_universal.o env_universal_common.o \
|
||||
translate.o common.o
|
||||
common.o
|
||||
|
||||
# All objects that the system needs to build fish_tests
|
||||
FISH_TESTS_OBJS := $(FISH_OBJS) fish_tests.o
|
||||
@@ -88,9 +93,7 @@ MIME_OBJS := mimedb.o xdgmimealias.o xdgmime.o xdgmimeglob.o \
|
||||
xdgmimeint.o xdgmimemagic.o xdgmimeparent.o wutil.o common.o
|
||||
|
||||
#
|
||||
# Files containing documentation for builtins. Should be listed
|
||||
# alphabetically, since this is the order in which they will be written
|
||||
# in the help file.
|
||||
# Files containing documentation for builtins.
|
||||
#
|
||||
BUILTIN_DOC_SRC := doc_src/source.txt doc_src/and.txt \
|
||||
doc_src/begin.txt doc_src/bg.txt doc_src/bind.txt \
|
||||
@@ -111,9 +114,7 @@ BUILTIN_DOC_SRC := doc_src/source.txt doc_src/and.txt \
|
||||
BUILTIN_DOC_HDR := $(BUILTIN_DOC_SRC:.txt=.doxygen)
|
||||
|
||||
#
|
||||
# Files containing documentation for external commands. Should be listed
|
||||
# alphabetically, since this is the order in which they will be written
|
||||
# in the help file.
|
||||
# Files containing documentation for external commands.
|
||||
#
|
||||
CMD_DOC_SRC := doc_src/contains.txt doc_src/count.txt doc_src/dirh.txt \
|
||||
doc_src/dirs.txt doc_src/fish_pager.txt doc_src/fishd.txt \
|
||||
@@ -184,7 +185,7 @@ TRANSLATIONS_SRC := $(wildcard po/*.po)
|
||||
TRANSLATIONS := $(TRANSLATIONS_SRC:.po=.gmo)
|
||||
|
||||
#Make everything needed for installing fish
|
||||
all: $(PROGRAMS) user_doc
|
||||
all: $(PROGRAMS) user_doc etc/fish share/fish etc/fish_interactive.fish $(TRANSLATIONS)
|
||||
@echo fish has now been built.
|
||||
@echo Use \'make install\' to install fish.
|
||||
.PHONY: all
|
||||
@@ -195,8 +196,11 @@ configure: configure.ac
|
||||
Makefile: Makefile.in configure
|
||||
./config.status
|
||||
|
||||
fish.spec: fish.spec.in
|
||||
./config.status
|
||||
|
||||
debug:
|
||||
make fish CFLAGS="@CFLAGS@ -O0 -Wno-unused -Werror -g"
|
||||
make fish CFLAGS="@CFLAGS@ $(MACROS) -O0 -Wno-unused -Werror -g"
|
||||
.PHONY: debug
|
||||
|
||||
# User documentation, describing the features of the fish shell.
|
||||
@@ -234,11 +238,17 @@ xsel-0.9.6/xsel: xsel-0.9.6
|
||||
doc.h:$(BUILTIN_DOC_SRC) $(CMD_DOC_SRC) doc_src/doc.hdr
|
||||
cat doc_src/doc.hdr >doc.h;
|
||||
echo "/** \page builtins Builtin commands" >>doc.h;
|
||||
cat $(BUILTIN_DOC_SRC) >>doc.h;
|
||||
for i in `printf "%s\n" $(BUILTIN_DOC_SRC)|sort`; do \
|
||||
echo "<hr>" >>doc.h; \
|
||||
cat $$i >>doc.h; \
|
||||
done
|
||||
echo "*/" >>doc.h
|
||||
echo "/** \page commands External commands" >>doc.h;
|
||||
echo "\c fish is shipped with commands which do not use any internal parts of the shell, and are therefore not written as builtins, but separate commands." >>doc.h
|
||||
cat $(CMD_DOC_SRC) >>doc.h;
|
||||
for i in `printf "%s\n" $(CMD_DOC_SRC)|sort`; do \
|
||||
echo "<hr>" >>doc.h; \
|
||||
cat $$i >>doc.h; \
|
||||
done
|
||||
echo "*/" >>doc.h
|
||||
|
||||
# This rule creates complete doxygen headers from each of the various
|
||||
@@ -250,10 +260,14 @@ doc.h:$(BUILTIN_DOC_SRC) $(CMD_DOC_SRC) doc_src/doc.hdr
|
||||
cat $*.txt >>$@;
|
||||
echo "*/" >>$@
|
||||
|
||||
%: %.in Makefile
|
||||
sed <$@.in >$@ -e "s,@sysconfdir\@,$(sysconfdir)," -e "s,@datadir\@,$(datadir)," -e "s,@docdir\@,$(docdir)," -e "s|@configure_input\@|$@, generated from $@.in by the Makefile. DO NOT MANUALLY EDIT THIS FILE!|" -e "s,@prefix\@,$(prefix)," -e "s,@optbindirs\@,$(optbindirs),"
|
||||
#-e "s,@\@,$(),"
|
||||
|
||||
# Compile translation file
|
||||
%.gmo:
|
||||
if test $(HAVE_GETTEXT) = 1; then \
|
||||
msgfmt $*.po -o $*.gmo; \
|
||||
msgfmt -o $*.gmo $*.po; \
|
||||
fi
|
||||
|
||||
# Update existing po file or copy messages.pot
|
||||
@@ -270,7 +284,7 @@ doc.h:$(BUILTIN_DOC_SRC) $(CMD_DOC_SRC) doc_src/doc.hdr
|
||||
messages.pot: *.c *.h etc/*.in share/fish share/completions/*.fish share/functions/*.fish seq
|
||||
if test $(HAVE_GETTEXT) = 1;then \
|
||||
xgettext -k_ -kN_ *.c *.h -o messages.pot; \
|
||||
if ! xgettext -j -k_ -kN_ -LShell etc/*.in share/fish share/completions/*.fish share/functions/*.fish seq -o messages.pot; then \
|
||||
if xgettext -j -k_ -kN_ -LShell etc/*.in share/fish share/completions/*.fish share/functions/*.fish seq -o messages.pot; then true; else \
|
||||
echo "Your xgettext version is too old to build the messages.pot file"\
|
||||
rm messages.pot\
|
||||
false;\
|
||||
@@ -321,12 +335,15 @@ doc_src/builtin_doc: $(BUILTIN_DOC_SRC) doc_src/count.txt builtin_help.hdr $(CMD
|
||||
echo "*/" >>$$FILE; \
|
||||
done
|
||||
cd doc_src; doxygen; cd ..;
|
||||
for i in doc_src/builtin_doc/man/man1/*.1; do \
|
||||
sed -i -e "s/\(.\)\\.SH/\1/" $$i; \
|
||||
done
|
||||
touch doc_src/builtin_doc
|
||||
|
||||
builtin_help.c: doc_src/builtin_doc gen_hdr.sh
|
||||
$(MAKE) gen_hdr2 # Don't depend on gen_hdr2, because then we would need to rebuild the docs whenever we use a fresh tarball
|
||||
cp builtin_help.hdr builtin_help.c;
|
||||
if ! test -x gen_hdr.sh; then chmod 755 gen_hdr.sh; fi
|
||||
if test -x gen_hdr.sh; then true; else chmod 755 gen_hdr.sh; fi
|
||||
for i in $(BUILTIN_DOC_HDR) doc_src/count.doxygen ; do \
|
||||
echo ' hash_put( &tbl, L"'`basename $$i .doxygen`'",' >>$@; \
|
||||
./gen_hdr.sh $$i >>$@; \
|
||||
@@ -375,8 +392,12 @@ check-uninstall:
|
||||
fi;
|
||||
.PHONY: check-uninstall
|
||||
|
||||
install-sh:
|
||||
if test -x install-sh; then true; else chmod 755 install-sh; fi
|
||||
.PHONY: install-sh
|
||||
|
||||
# Try to install after checking for incompatible installed versions
|
||||
install: all check-uninstall install-force
|
||||
install: all install-sh check-uninstall install-force
|
||||
.PHONY: install
|
||||
|
||||
# Force installation, even in presense of incompatible previous
|
||||
@@ -432,14 +453,17 @@ uninstall: uninstall-translations
|
||||
rm -f $(DESTDIR)$(bindir)/xsel
|
||||
rm -f $(DESTDIR)$(sysconfdir)/fish
|
||||
rm -f $(DESTDIR)$(sysconfdir)/fish_inputrc
|
||||
if test -f $(DESTDIR)$(sysconfdir)/fish.d/fish_interactive.fish; then \
|
||||
rm -f $(DESTDIR)$(sysconfdir)/fish.d/fish_interactive.fish; \
|
||||
fi
|
||||
if test -d $(DESTDIR)$(datadir)/fish; then \
|
||||
rm -r $(DESTDIR)$(datadir)/fish; \
|
||||
fi
|
||||
if test -d $(DESTDIR)$(docdir); then \
|
||||
rm -r $(DESTDIR)$(docdir);\
|
||||
fi
|
||||
for i in fish.1 @XSEL_MAN@ mimedb.1 fishd.1 set_color.1 count.1; do \
|
||||
rm -f $(DESTDIR)$(mandir)/man1/$$i*; \
|
||||
for i in $(MANUALS); do \
|
||||
rm -f $(DESTDIR)$(mandir)/man1/`basename $$i`*; \
|
||||
done;
|
||||
.PHONY: uninstall
|
||||
|
||||
@@ -500,18 +524,18 @@ fish_tests: $(FISH_TESTS_OBJS)
|
||||
|
||||
# mimedb does not need any libraries, so we don't use LDFLAGS here
|
||||
mimedb: $(MIME_OBJS) doc_src/mimedb.o
|
||||
$(CC) $(MIME_OBJS) doc_src/mimedb.o -o $@
|
||||
$(CC) $(MIME_OBJS) doc_src/mimedb.o $(LDFLAGS) -o $@
|
||||
|
||||
# count does not need any libraries, so we don't use LDFLAGS here
|
||||
count: count.o
|
||||
$(CC) count.o -o $@
|
||||
|
||||
set_color: set_color.o doc_src/set_color.o fallback.o
|
||||
$(CC) set_color.o doc_src/set_color.o fallback.o $(LDFLAGS) -o $@
|
||||
set_color: set_color.o doc_src/set_color.o common.o
|
||||
$(CC) set_color.o doc_src/set_color.o common.o $(LDFLAGS) -o $@
|
||||
|
||||
# Test program for the tokenizer library
|
||||
tokenizer_test: tokenizer.c tokenizer.h wutil.o common.o
|
||||
$(CC) ${CFLAGS} tokenizer.c wutil.o common.o -D TOKENIZER_TEST $(LDFLAGS) -o $@
|
||||
$(CC) $(CFLAGS) tokenizer.c wutil.o common.o -D TOKENIZER_TEST $(LDFLAGS) -o $@
|
||||
|
||||
# Neat little program to show output from terminal
|
||||
key_reader: key_reader.o input_common.o common.o env_universal.o env_universal_common.o wutil.o
|
||||
@@ -569,8 +593,8 @@ dist: fish-@PACKAGE_VERSION@.tar.bz2
|
||||
|
||||
# Create .rpm file for the current systems architecture and an
|
||||
# .src.rpm file.
|
||||
rpm: fish-@PACKAGE_VERSION@.tar.bz2
|
||||
@if ! which rpmbuild; then \
|
||||
rpm: fish-@PACKAGE_VERSION@.tar.bz2 fish.spec
|
||||
@if which rpmbuild; then true; else \
|
||||
echo Could not find the rpmbuild command, needed to build an rpm; \
|
||||
echo You may be able to install it using the following command:; \
|
||||
echo \'yum install rpm-build\'; \
|
||||
@@ -614,47 +638,45 @@ clean:
|
||||
builtin.o: config.h fallback.h util.h wutil.h builtin.h function.h complete.h
|
||||
builtin.o: proc.h io.h parser.h event.h reader.h env.h common.h wgetopt.h
|
||||
builtin.o: sanity.h tokenizer.h wildcard.h input_common.h input.h intern.h
|
||||
builtin.o: signal.h translate.h halloc.h halloc_util.h parse_util.h expand.h
|
||||
builtin.o: signal.h halloc.h halloc_util.h parse_util.h expand.h
|
||||
builtin.o: builtin_help.c builtin_set.c builtin_commandline.c
|
||||
builtin.o: builtin_complete.c builtin_ulimit.c builtin_jobs.c
|
||||
builtin_commandline.o: signal.h config.h fallback.h util.h wutil.h builtin.h
|
||||
builtin_commandline.o: common.h wgetopt.h reader.h proc.h io.h parser.h
|
||||
builtin_commandline.o: event.h tokenizer.h input_common.h input.h translate.h
|
||||
builtin_commandline.o: event.h tokenizer.h input_common.h input.h
|
||||
builtin_commandline.o: parse_util.h
|
||||
builtin_complete.o: signal.h config.h fallback.h util.h wutil.h builtin.h
|
||||
builtin_complete.o: common.h complete.h wgetopt.h parser.h proc.h io.h
|
||||
builtin_complete.o: event.h reader.h translate.h
|
||||
builtin_complete.o: event.h reader.h
|
||||
builtin_help.o: config.h util.h common.h halloc_util.h
|
||||
builtin_jobs.o: config.h fallback.h util.h wutil.h builtin.h proc.h io.h
|
||||
builtin_jobs.o: parser.h event.h common.h wgetopt.h translate.h
|
||||
builtin_jobs.o: parser.h event.h common.h wgetopt.h
|
||||
builtin_set.o: signal.h config.h fallback.h util.h wutil.h builtin.h env.h
|
||||
builtin_set.o: expand.h common.h wgetopt.h proc.h io.h parser.h event.h
|
||||
builtin_set.o: translate.h
|
||||
builtin_ulimit.o: config.h fallback.h util.h builtin.h common.h wgetopt.h
|
||||
builtin_ulimit.o: translate.h
|
||||
common.o: config.h fallback.h util.h wutil.h common.h expand.h proc.h io.h
|
||||
common.o: wildcard.h parser.h event.h util.c halloc.c halloc.h halloc_util.c
|
||||
common.o: fallback.c
|
||||
complete.o: signal.h config.h fallback.h util.h tokenizer.h wildcard.h proc.h
|
||||
complete.o: io.h parser.h event.h function.h complete.h builtin.h env.h
|
||||
complete.o: exec.h expand.h common.h reader.h history.h intern.h translate.h
|
||||
complete.o: parse_util.h halloc.h halloc_util.h wutil.h
|
||||
complete.o: exec.h expand.h common.h reader.h history.h intern.h parse_util.h
|
||||
complete.o: halloc.h halloc_util.h wutil.h
|
||||
env.o: config.h signal.h fallback.h util.h wutil.h proc.h io.h common.h env.h
|
||||
env.o: sanity.h expand.h history.h reader.h parser.h event.h env_universal.h
|
||||
env.o: env_universal_common.h input_common.h translate.h complete.h
|
||||
env.o: env_universal_common.h input_common.h complete.h
|
||||
env_universal.o: config.h signal.h fallback.h util.h common.h wutil.h
|
||||
env_universal.o: env_universal_common.h env_universal.h
|
||||
env_universal_common.o: config.h signal.h fallback.h util.h common.h wutil.h
|
||||
env_universal_common.o: env_universal_common.h
|
||||
event.o: signal.h config.h fallback.h util.h wutil.h function.h proc.h io.h
|
||||
event.o: parser.h event.h common.h translate.h halloc_util.h
|
||||
event.o: parser.h event.h common.h halloc_util.h
|
||||
exec.o: signal.h config.h fallback.h util.h common.h wutil.h proc.h io.h
|
||||
exec.o: exec.h parser.h event.h builtin.h function.h env.h wildcard.h
|
||||
exec.o: sanity.h expand.h env_universal.h env_universal_common.h translate.h
|
||||
exec.o: halloc.h halloc_util.h parse_util.h
|
||||
exec.o: sanity.h expand.h env_universal.h env_universal_common.h halloc.h
|
||||
exec.o: halloc_util.h parse_util.h
|
||||
expand.o: signal.h config.h fallback.h util.h common.h wutil.h env.h proc.h
|
||||
expand.o: io.h parser.h event.h expand.h wildcard.h exec.h tokenizer.h
|
||||
expand.o: complete.h translate.h parse_util.h halloc_util.h
|
||||
expand.o: complete.h parse_util.h halloc_util.h
|
||||
fallback.o: config.h fallback.h util.h
|
||||
fishd.o: config.h signal.h fallback.h util.h common.h wutil.h
|
||||
fishd.o: env_universal_common.h
|
||||
@@ -665,8 +687,8 @@ fish_tests.o: config.h signal.h fallback.h util.h common.h proc.h io.h
|
||||
fish_tests.o: reader.h builtin.h function.h complete.h wutil.h env.h expand.h
|
||||
fish_tests.o: parser.h event.h tokenizer.h output.h exec.h halloc_util.h
|
||||
function.o: signal.h config.h wutil.h fallback.h util.h function.h proc.h
|
||||
function.o: io.h translate.h parser.h event.h common.h intern.h reader.h
|
||||
function.o: parse_util.h env.h expand.h
|
||||
function.o: io.h parser.h event.h common.h intern.h reader.h parse_util.h
|
||||
function.o: env.h expand.h
|
||||
halloc.o: config.h fallback.h util.h common.h halloc.h
|
||||
halloc_util.o: config.h fallback.h util.h common.h halloc.h
|
||||
highlight.o: signal.h config.h fallback.h util.h wutil.h highlight.h
|
||||
@@ -677,50 +699,47 @@ history.o: config.h fallback.h util.h wutil.h history.h common.h reader.h
|
||||
history.o: env.h sanity.h signal.h
|
||||
input.o: config.h signal.h fallback.h util.h wutil.h reader.h proc.h io.h
|
||||
input.o: common.h sanity.h input_common.h input.h parser.h event.h env.h
|
||||
input.o: expand.h translate.h output.h
|
||||
input.o: expand.h output.h intern.h
|
||||
input_common.o: config.h fallback.h util.h common.h wutil.h input_common.h
|
||||
input_common.o: env_universal.h env_universal_common.h
|
||||
intern.o: config.h fallback.h util.h wutil.h common.h intern.h
|
||||
io.o: config.h fallback.h util.h wutil.h exec.h proc.h io.h common.h
|
||||
io.o: translate.h halloc.h
|
||||
io.o: config.h fallback.h util.h wutil.h exec.h proc.h io.h common.h halloc.h
|
||||
key_reader.o: config.h fallback.h input_common.h
|
||||
kill.o: signal.h config.h fallback.h util.h wutil.h kill.h proc.h io.h
|
||||
kill.o: sanity.h common.h env.h exec.h parser.h event.h halloc.h
|
||||
main.o: config.h signal.h fallback.h util.h common.h reader.h builtin.h
|
||||
main.o: function.h complete.h wutil.h env.h sanity.h proc.h io.h parser.h
|
||||
main.o: event.h expand.h intern.h exec.h output.h translate.h halloc_util.h
|
||||
main.o: history.h
|
||||
main.o: event.h expand.h intern.h exec.h output.h halloc_util.h history.h
|
||||
mimedb.o: config.h xdgmime.h fallback.h util.h
|
||||
output.o: config.h signal.h fallback.h util.h wutil.h expand.h common.h
|
||||
output.o: output.h halloc_util.h highlight.h
|
||||
parser.o: signal.h config.h fallback.h util.h common.h wutil.h proc.h io.h
|
||||
parser.o: parser.h event.h tokenizer.h exec.h wildcard.h function.h builtin.h
|
||||
parser.o: env.h expand.h reader.h sanity.h env_universal.h
|
||||
parser.o: env_universal_common.h translate.h intern.h parse_util.h halloc.h
|
||||
parser.o: halloc_util.h
|
||||
parser.o: env_universal_common.h intern.h parse_util.h halloc.h halloc_util.h
|
||||
parse_util.o: config.h fallback.h util.h wutil.h common.h tokenizer.h
|
||||
parse_util.o: parse_util.h expand.h intern.h exec.h proc.h io.h env.h
|
||||
parse_util.o: wildcard.h halloc_util.h
|
||||
proc.o: config.h signal.h fallback.h util.h wutil.h proc.h io.h common.h
|
||||
proc.o: reader.h sanity.h env.h parser.h event.h translate.h halloc.h
|
||||
proc.o: halloc_util.h output.h
|
||||
proc.o: reader.h sanity.h env.h parser.h event.h halloc.h halloc_util.h
|
||||
proc.o: output.h
|
||||
reader.o: config.h signal.h fallback.h util.h wutil.h highlight.h reader.h
|
||||
reader.o: proc.h io.h parser.h event.h complete.h history.h common.h sanity.h
|
||||
reader.o: env.h exec.h expand.h tokenizer.h kill.h input_common.h input.h
|
||||
reader.o: function.h output.h translate.h parse_util.h
|
||||
reader.o: function.h output.h parse_util.h
|
||||
sanity.o: signal.h config.h fallback.h util.h common.h sanity.h proc.h io.h
|
||||
sanity.o: history.h reader.h kill.h wutil.h translate.h
|
||||
set_color.o: config.h
|
||||
sanity.o: history.h reader.h kill.h wutil.h
|
||||
set_color.o: config.h fallback.h
|
||||
signal.o: config.h signal.h common.h util.h fallback.h wutil.h event.h
|
||||
signal.o: reader.h proc.h io.h translate.h
|
||||
signal.o: reader.h proc.h io.h
|
||||
test.o: stringtab.h
|
||||
tokenizer.o: config.h fallback.h util.h wutil.h tokenizer.h common.h
|
||||
tokenizer.o: wildcard.h translate.h
|
||||
translate.o: config.h common.h util.h fallback.h halloc_util.h
|
||||
tokenizer.o: wildcard.h
|
||||
util.o: config.h fallback.h util.h common.h wutil.h
|
||||
wgetopt.o: config.h wgetopt.h wutil.h fallback.h translate.h
|
||||
wgetopt.o: config.h wgetopt.h wutil.h fallback.h
|
||||
wildcard.o: config.h fallback.h util.h wutil.h complete.h common.h wildcard.h
|
||||
wildcard.o: reader.h expand.h translate.h
|
||||
wutil.o: config.h fallback.h util.h common.h wutil.h
|
||||
wildcard.o: reader.h expand.h
|
||||
wutil.o: config.h fallback.h util.h common.h wutil.h halloc.h halloc_util.h
|
||||
xdgmimealias.o: xdgmimealias.h xdgmime.h xdgmimeint.h
|
||||
xdgmime.o: xdgmime.h xdgmimeint.h xdgmimeglob.h xdgmimemagic.h xdgmimealias.h
|
||||
xdgmime.o: xdgmimeparent.h
|
||||
|
||||
10
builtin.c
10
builtin.c
@@ -21,6 +21,8 @@
|
||||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -37,8 +39,6 @@
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
#include "intern.h"
|
||||
#include "event.h"
|
||||
#include "signal.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "halloc.h"
|
||||
#include "halloc_util.h"
|
||||
#include "parse_util.h"
|
||||
@@ -3126,7 +3126,7 @@ void builtin_push_io( int in )
|
||||
{
|
||||
if( builtin_stdin != -1 )
|
||||
{
|
||||
al_push( &io_stack, (void *)(long)builtin_stdin );
|
||||
al_push_long( &io_stack, (long)builtin_stdin );
|
||||
al_push( &io_stack, sb_out );
|
||||
al_push( &io_stack, sb_err );
|
||||
}
|
||||
@@ -3149,7 +3149,7 @@ void builtin_pop_io()
|
||||
{
|
||||
sb_err = (string_buffer_t *)al_pop( &io_stack );
|
||||
sb_out = (string_buffer_t *)al_pop( &io_stack );
|
||||
builtin_stdin = (int)(long)al_pop( &io_stack );
|
||||
builtin_stdin = (int)al_pop_long( &io_stack );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
Functions used for implementing the commandline builtin.
|
||||
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -11,8 +13,6 @@ Functions used for implementing the commandline builtin.
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -26,7 +26,7 @@ Functions used for implementing the commandline builtin.
|
||||
#include "tokenizer.h"
|
||||
#include "input_common.h"
|
||||
#include "input.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "parse_util.h"
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
Functions used for implementing the complete builtin.
|
||||
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -11,8 +13,6 @@ Functions used for implementing the complete builtin.
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -23,7 +23,7 @@ Functions used for implementing the complete builtin.
|
||||
#include "wgetopt.h"
|
||||
#include "parser.h"
|
||||
#include "reader.h"
|
||||
#include "translate.h"
|
||||
|
||||
|
||||
/**
|
||||
Internal storage for the builtin_get_temporary_buffer() function.
|
||||
@@ -364,7 +364,7 @@ static int builtin_complete( wchar_t **argv )
|
||||
}
|
||||
,
|
||||
{
|
||||
L"do-complete", required_argument, 0, 'C'
|
||||
L"do-complete", optional_argument, 0, 'C'
|
||||
}
|
||||
,
|
||||
{
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
various help files in the doc_src directory.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
#include "common.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/** \file builtin_jobs.c
|
||||
Functions for executing the jobs builtin.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -13,8 +14,6 @@
|
||||
#include <string.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -24,7 +23,7 @@
|
||||
#include "parser.h"
|
||||
#include "common.h"
|
||||
#include "wgetopt.h"
|
||||
#include "translate.h"
|
||||
|
||||
|
||||
/**
|
||||
Print modes for the jobs builtin
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
Functions used for implementing the set builtin.
|
||||
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -11,8 +13,6 @@ Functions used for implementing the set builtin.
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -24,7 +24,7 @@ Functions used for implementing the set builtin.
|
||||
#include "wgetopt.h"
|
||||
#include "proc.h"
|
||||
#include "parser.h"
|
||||
#include "translate.h"
|
||||
|
||||
|
||||
/**
|
||||
Error message for invalid path operations
|
||||
@@ -81,7 +81,7 @@ static int my_env_set( const wchar_t *key, array_list_t *val, int scope )
|
||||
show_perror = 1;
|
||||
}
|
||||
|
||||
if( !( S_IFDIR & buff.st_mode ) )
|
||||
if( !( S_ISDIR(buff.st_mode) ) )
|
||||
{
|
||||
error = 1;
|
||||
|
||||
@@ -233,7 +233,6 @@ static int parse_index( array_list_t *indexes,
|
||||
{
|
||||
wchar_t *end;
|
||||
long l_ind = wcstol(src, &end, 10);
|
||||
int *ind;
|
||||
|
||||
if (end == src)
|
||||
{
|
||||
@@ -246,9 +245,7 @@ static int parse_index( array_list_t *indexes,
|
||||
l_ind = var_count+l_ind+1;
|
||||
}
|
||||
|
||||
ind = (int *) calloc(1, sizeof(int));
|
||||
*ind = (int) l_ind;
|
||||
al_push(indexes, ind);
|
||||
al_push_long(indexes, l_ind);
|
||||
src = end;
|
||||
count++;
|
||||
while (iswspace(*src)) src++;
|
||||
@@ -275,7 +272,11 @@ static int update_values( array_list_t *list,
|
||||
/* Replace values where needed */
|
||||
for( i = 0; i < al_get_count(indexes); i++ )
|
||||
{
|
||||
int ind = *(int *) al_get(indexes, i) - 1;
|
||||
/*
|
||||
The '- 1' below is because the indices in fish are
|
||||
one-based, but the array_lsit_t uses zero-based indices
|
||||
*/
|
||||
long ind = al_get_long(indexes, i) - 1;
|
||||
void *new = (void *) al_get(values, i);
|
||||
if( ind <= 0 )
|
||||
{
|
||||
@@ -291,18 +292,18 @@ static int update_values( array_list_t *list,
|
||||
|
||||
|
||||
/**
|
||||
Return 1 if an array list of int* pointers contains the specified
|
||||
Return 1 if an array list of longs contains the specified
|
||||
value, 0 otherwise
|
||||
*/
|
||||
static int al_contains_int( array_list_t *list,
|
||||
int val)
|
||||
static int al_contains_long( array_list_t *list,
|
||||
long val)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < al_get_count(list); i++)
|
||||
{
|
||||
int *current = (int *) al_get(list, i);
|
||||
if( current != 0 && *current == val )
|
||||
long current = al_get_long(list, i);
|
||||
if( current != 0 && current == val )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -324,7 +325,7 @@ static void erase_values(array_list_t *list, array_list_t *indexes)
|
||||
|
||||
for (i = 0; i < al_get_count(list); i++)
|
||||
{
|
||||
if (!al_contains_int(indexes, i + 1))
|
||||
if (!al_contains_long(indexes, (long)i + 1))
|
||||
{
|
||||
al_push(&result, al_get(list, i));
|
||||
}
|
||||
@@ -749,7 +750,6 @@ static int builtin_set( wchar_t **argv )
|
||||
al_foreach( &result, &free );
|
||||
al_destroy( &result );
|
||||
|
||||
al_foreach( &indexes, &free );
|
||||
al_destroy(&indexes);
|
||||
al_destroy(&values);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Functions used for implementing the ulimit builtin.
|
||||
#include "builtin.h"
|
||||
#include "common.h"
|
||||
#include "wgetopt.h"
|
||||
#include "translate.h"
|
||||
|
||||
|
||||
/**
|
||||
Struct describing a resource limit
|
||||
|
||||
43
common.c
43
common.c
@@ -7,6 +7,16 @@ parts of fish.
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_STROPTS_H
|
||||
#include <stropts.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SIGINFO_H
|
||||
#include <siginfo.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <wchar.h>
|
||||
@@ -14,7 +24,15 @@ parts of fish.
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_TERMIOS_H
|
||||
#include <sys/termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <wctype.h>
|
||||
@@ -825,9 +843,27 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||
break;
|
||||
}
|
||||
|
||||
case L'a':
|
||||
{
|
||||
in[out_pos]=L'\a';
|
||||
break;
|
||||
}
|
||||
|
||||
case L'f':
|
||||
{
|
||||
in[out_pos]=L'\f';
|
||||
break;
|
||||
}
|
||||
|
||||
case L'v':
|
||||
{
|
||||
in[out_pos]=L'\v';
|
||||
break;
|
||||
}
|
||||
|
||||
case L'e':
|
||||
{
|
||||
in[out_pos]=L'\e';
|
||||
in[out_pos]=L'\x1b';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1402,10 +1438,15 @@ int acquire_lock_file( const char *lockfile, const int timeout, int force )
|
||||
|
||||
void common_handle_winch( int signal )
|
||||
{
|
||||
#ifdef HAVE_WINSIZE
|
||||
if (ioctl(1,TIOCGWINSZ,&termsize)!=0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#else
|
||||
termsize.ws_col = 80;
|
||||
termsize.ws_row = 24;
|
||||
#endif
|
||||
}
|
||||
|
||||
int common_get_width()
|
||||
|
||||
10
common.h
10
common.h
@@ -96,6 +96,16 @@ extern wchar_t *program_name;
|
||||
exit(1); \
|
||||
} \
|
||||
|
||||
/**
|
||||
Shorthand for wgettext call
|
||||
*/
|
||||
#define _(wstr) wgettext(wstr)
|
||||
|
||||
/**
|
||||
Noop, used to tell xgettext that a string should be translated, even though it is not directly sent to wgettext.
|
||||
*/
|
||||
#define N_(wstr) wstr
|
||||
|
||||
/**
|
||||
Take an array_list_t containing wide strings and converts them to a
|
||||
single null-terminated wchar_t **. The array is allocated using
|
||||
|
||||
89
complete.c
89
complete.c
@@ -3,6 +3,8 @@
|
||||
|
||||
These functions are used for storing and retrieving tab-completion data, as well as for performing tab-completion.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
@@ -20,7 +22,6 @@
|
||||
#include <signal.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
@@ -39,7 +40,7 @@
|
||||
#include "reader.h"
|
||||
#include "history.h"
|
||||
#include "intern.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "parse_util.h"
|
||||
#include "halloc.h"
|
||||
#include "halloc_util.h"
|
||||
@@ -233,6 +234,51 @@ static hash_table_t *condition_cache=0;
|
||||
*/
|
||||
static string_buffer_t *get_desc_buff=0;
|
||||
|
||||
|
||||
static void complete_free_entry( complete_entry *c );
|
||||
static void clear_hash_entry( void *key, void *data );
|
||||
|
||||
|
||||
/**
|
||||
Destroys various structures used for tab-completion and free()s the memory used by them.
|
||||
*/
|
||||
static void complete_destroy()
|
||||
{
|
||||
complete_entry *i=first_entry, *prev;
|
||||
|
||||
while( i )
|
||||
{
|
||||
prev = i;
|
||||
i=i->next;
|
||||
complete_free_entry( prev );
|
||||
}
|
||||
first_entry = 0;
|
||||
|
||||
if( suffix_hash )
|
||||
{
|
||||
hash_foreach( suffix_hash, &clear_hash_entry );
|
||||
hash_destroy( suffix_hash );
|
||||
free( suffix_hash );
|
||||
suffix_hash=0;
|
||||
}
|
||||
|
||||
parse_util_load_reset( L"fish_complete_path", 0 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Make sure complete_destroy is called on exit
|
||||
*/
|
||||
static void complete_init()
|
||||
{
|
||||
static int is_init = 0;
|
||||
if( !is_init )
|
||||
{
|
||||
is_init = 1;
|
||||
halloc_register_function_void( global_context, &complete_destroy );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
This command clears the cache of condition tests created by \c condition_test().
|
||||
*/
|
||||
@@ -329,34 +375,6 @@ static void clear_hash_entry( void *key, void *data )
|
||||
free( (void *)data );
|
||||
}
|
||||
|
||||
void complete_init()
|
||||
{
|
||||
}
|
||||
|
||||
void complete_destroy()
|
||||
{
|
||||
complete_entry *i=first_entry, *prev;
|
||||
|
||||
while( i )
|
||||
{
|
||||
prev = i;
|
||||
i=i->next;
|
||||
complete_free_entry( prev );
|
||||
}
|
||||
first_entry = 0;
|
||||
|
||||
if( suffix_hash )
|
||||
{
|
||||
hash_foreach( suffix_hash, &clear_hash_entry );
|
||||
hash_destroy( suffix_hash );
|
||||
free( suffix_hash );
|
||||
suffix_hash=0;
|
||||
}
|
||||
|
||||
parse_util_load_reset( L"fish_complete_path", 0 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Search for an exactly matching completion entry
|
||||
*/
|
||||
@@ -390,6 +408,8 @@ void complete_add( const wchar_t *cmd,
|
||||
|
||||
CHECK( cmd, );
|
||||
|
||||
complete_init();
|
||||
|
||||
c = complete_find_exact_entry( cmd, cmd_type );
|
||||
|
||||
if( c == 0 )
|
||||
@@ -934,6 +954,7 @@ const wchar_t *complete_get_desc( const wchar_t *filename )
|
||||
|
||||
if( !get_desc_buff )
|
||||
{
|
||||
complete_init();
|
||||
get_desc_buff = sb_halloc( global_context);
|
||||
}
|
||||
else
|
||||
@@ -1060,7 +1081,7 @@ static void copy_strings_with_prefix( array_list_t *comp_out,
|
||||
wchar_t *wc, *tmp;
|
||||
|
||||
tmp = expand_one( 0,
|
||||
wcsdup(wc_escaped), EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_WILDCARDS);
|
||||
wcsdup(wc_escaped), EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_WILDCARDS);
|
||||
if(!tmp)
|
||||
return;
|
||||
|
||||
@@ -1765,14 +1786,14 @@ static void complete_param_expand( wchar_t *str,
|
||||
}
|
||||
/*
|
||||
debug( 3,
|
||||
L"expand_string( \"%ls\", comp_out, EXPAND_SKIP_SUBSHELL | ACCEPT_INCOMPLETE | %ls );",
|
||||
L"expand_string( \"%ls\", comp_out, EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE | %ls );",
|
||||
comp_str,
|
||||
do_file?L"0":L"EXPAND_SKIP_WILDCARDS" );
|
||||
*/
|
||||
expand_string( 0,
|
||||
wcsdup(comp_str),
|
||||
comp_out,
|
||||
EXPAND_SKIP_SUBSHELL | ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) );
|
||||
EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1965,6 +1986,8 @@ void complete( const wchar_t *cmd,
|
||||
CHECK( cmd, );
|
||||
CHECK( comp, );
|
||||
|
||||
complete_init();
|
||||
|
||||
// debug( 1, L"Complete '%ls'", cmd );
|
||||
|
||||
cursor_pos = wcslen(cmd );
|
||||
|
||||
@@ -67,14 +67,9 @@
|
||||
#define PROG_COMPLETE_SEP L'\t'
|
||||
|
||||
/**
|
||||
Initializes various structures used for tab-completion.
|
||||
Terminator for completions sent to the fish_pager
|
||||
*/
|
||||
void complete_init();
|
||||
|
||||
/**
|
||||
Destroys various structures used for tab-completion and free()s the memory used by them.
|
||||
*/
|
||||
void complete_destroy();
|
||||
#define COMPLETE_TERMINATOR L'\006'
|
||||
|
||||
/**
|
||||
|
||||
|
||||
113
configure.ac
113
configure.ac
@@ -1,5 +1,5 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(fish,1.21.9,fish-users@lists.sf.net)
|
||||
AC_INIT(fish,1.21.11,fish-users@lists.sf.net)
|
||||
|
||||
# If needed, run autoconf to regenerate the configure file
|
||||
AC_MSG_CHECKING([if autoconf needs to be run])
|
||||
@@ -82,15 +82,6 @@ AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
|
||||
# Check for doxygen, which is needed to build
|
||||
AC_CHECK_PROG( has_doxygen, [doxygen], "true")
|
||||
|
||||
if ! test "$has_doxygen" = "true"; then
|
||||
AC_MSG_ERROR( [cannot find the Doxygen program in your path.
|
||||
This program is needed to build fish.
|
||||
Please install it and try again.])
|
||||
fi
|
||||
|
||||
# Check for seq command. If missing, make sure fallback shellscript
|
||||
# implementation is installed
|
||||
AC_CHECK_PROG( SEQ_FALLBACK, seq, [ ], [seq])
|
||||
@@ -112,15 +103,22 @@ else
|
||||
AC_SUBST( XSEL_MAN_PATH,[ ])
|
||||
fi
|
||||
|
||||
# These help out with getting better prototypes on some platforms
|
||||
|
||||
#
|
||||
# Test if the compiler accepts the -std=c99 flag. If so, using it
|
||||
# increases the odds of correct compilation, since we want to use the
|
||||
# *wprintf functions, which where defined in C99.
|
||||
#
|
||||
# *wprintf functions, which where defined in C99. On some platforms
|
||||
# (Solaris 10) adding -std=c99 in turn requires that _POSIX_C_SOURCE
|
||||
# be defined to 200112L otherwise several POSIX-specific, non-ISO-C99
|
||||
# types/prototypes are made unavailable e.g. siginfo_t. Finally,
|
||||
# defining _XOPEN_SOURCE to 600 is compatible with the
|
||||
# _POSIX_C_SOURCE value and provides a little assurance that
|
||||
# extension functions' prototypes are available, e.g. killpg().
|
||||
|
||||
XCFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -std=c99"
|
||||
AC_MSG_CHECKING(if -std=c99 works)
|
||||
CFLAGS="$CFLAGS -std=c99 -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L"
|
||||
AC_MSG_CHECKING(if -std=c99 -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L works)
|
||||
AC_CACHE_VAL(local_cv_has__std_c99,[
|
||||
AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
@@ -194,8 +192,8 @@ if test "$glibc" = yes; then
|
||||
# fallback.h, in order to keep fish working on non-gnu platforms.
|
||||
#
|
||||
|
||||
CFLAGS="$CFLAGS -D _GNU_SOURCE -D _ISOC99_SOURCE"
|
||||
|
||||
AC_DEFINE( _GNU_SOURCE, 1, [Macro to enable additional prototypes under Glibc])
|
||||
AC_DEFINE( _ISOC99_SOURCE, 1, [Macro to enable additional prototypes under Glibc])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
@@ -215,23 +213,43 @@ if test $target_cpu = powerpc; then
|
||||
AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work])
|
||||
fi
|
||||
|
||||
# Solaris-specific flags go here
|
||||
AC_MSG_CHECKING([if we are under Solaris])
|
||||
case $target_os in
|
||||
solaris*)
|
||||
AC_DEFINE( __EXTENSIONS__, 1, [Macro to enable additional prototypes under Solaris])
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# BSD-specific flags go here
|
||||
AC_MSG_CHECKING([if we are under BSD])
|
||||
case $target_os in
|
||||
*bsd*)
|
||||
AC_DEFINE( __BSD_VISIBLE, 1, [Macro to enable additional prototypes under BSD])
|
||||
AC_DEFINE( _NETBSD_SOURCE, 1, [Macro to enable additional prototypes under BSD])
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# Set up PREFIX and related preprocessor symbols. Fish needs to know
|
||||
# where it will be installed. One of the reasons for this is so that
|
||||
# it can make sure the fish installation directory is in the path
|
||||
# during startup.
|
||||
if [[ "$prefix" = NONE ]]; then
|
||||
AC_DEFINE_UNQUOTED( [PREFIX], L"/usr/local", [Installation directory])
|
||||
AC_SUBST( PREFIX, /usr/local)
|
||||
export prefix=/usr/local
|
||||
AC_SUBST( prefix, /usr/local)
|
||||
else
|
||||
AC_DEFINE_UNQUOTED( [PREFIX], L"$prefix", [Installation directory])
|
||||
AC_SUBST( PREFIX, [$prefix])
|
||||
AC_SUBST( prefix, [$prefix])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED( SYSCONFDIR, [L"$(eval echo $sysconfdir)"], [System configuration directory] )
|
||||
AC_DEFINE_UNQUOTED( DATADIR, [L"$(eval echo $datadir)"], [System configuration directory] )
|
||||
AC_SUBST( SYSCONFDIR, ["$(eval echo $sysconfdir)"] )
|
||||
AC_SUBST( DATADIR, ["$(eval echo $datadir)"] )
|
||||
|
||||
|
||||
# Set up the directory where the documentation files should be
|
||||
@@ -239,16 +257,14 @@ AC_SUBST( DATADIR, ["$(eval echo $datadir)"] )
|
||||
AC_ARG_VAR( [docdir], [Documentation direcotry] )
|
||||
|
||||
if test -z $docdir; then
|
||||
AC_SUBST(docdir,[$datadir/doc/fish])
|
||||
AC_SUBST(docdir, [$datadir/doc/fish] )
|
||||
else
|
||||
AC_SUBST(docdir, [$docdir])
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED( DOCDIR, [L"$(eval echo $docdir)"], [Documentation directory] )
|
||||
|
||||
|
||||
# Set up locale directory. This is where the .po files will be
|
||||
# installed.
|
||||
AC_DEFINE_UNQUOTED( [LOCALEDIR], "$(eval echo $datadir)/locale", [Locale directory])
|
||||
AC_SUBST( [LOCALEDIR], [$datadir/locale])
|
||||
AC_SUBST( [localedir], [$datadir/locale])
|
||||
|
||||
# See if Linux procfs is present. This is used to get extra
|
||||
# information about running processes.
|
||||
@@ -261,22 +277,25 @@ AC_DEFINE([HAVE_TRANSLATE_H], [1],
|
||||
[Define to 1 if the wgettext function should be used for translating strings.])
|
||||
|
||||
# Check for presense of various libraries
|
||||
AC_SEARCH_LIBS( gettext, intl, AC_SUBST( HAVE_GETTEXT, [1] ), AC_SUBST( HAVE_GETTEXT, [0] ) )
|
||||
AC_SEARCH_LIBS( gettext, intl,,)
|
||||
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
|
||||
AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
|
||||
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
|
||||
|
||||
# Check for presense of various header files
|
||||
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h libintl.h ncurses.h curses.h])
|
||||
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h libintl.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h sys/termios.h])
|
||||
|
||||
AC_CHECK_HEADER([regex.h],
|
||||
[AC_DEFINE([HAVE_REGEX_H], [1], [Define to 1 if you have the <regex.h> header file.])],
|
||||
[AC_MSG_ERROR([Could not find the header regex.h, needed to build fish])])
|
||||
|
||||
# Check for presense of various functions
|
||||
AC_CHECK_FUNCS( wcsdup wcsndup wcslen wcscasecmp wcsncasecmp gettext fwprintf )
|
||||
AC_CHECK_FUNCS( gettext wcsdup wcsndup wcslen wcscasecmp wcsncasecmp fwprintf )
|
||||
AC_CHECK_FUNCS( futimes wcwidth wcswidth getopt_long wcstok fputwc fgetwc )
|
||||
AC_CHECK_FUNCS( wcstol dcgettext wcslcat wcslcpy lrand48_r)
|
||||
AC_CHECK_FUNCS( wcstol dcgettext wcslcat wcslcpy lrand48_r killpg)
|
||||
|
||||
# The Makefile also needs to know if we have gettext, so it knows if the translations should be installed.
|
||||
AC_CHECK_FUNC( gettext, AC_SUBST( HAVE_GETTEXT, 1 ), AC_SUBST( HAVE_GETTEXT, 0 ) )
|
||||
|
||||
# Here follows a list of small programs used to test for various
|
||||
# features that Autoconf doesn't tell us about
|
||||
@@ -300,6 +319,24 @@ else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
|
||||
# Check if struct winsize exists
|
||||
AC_MSG_CHECKING([if struct winsize and TIOCGWINSZ exist])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([
|
||||
#ifdef HAVE_SYS_TERMIOS_H
|
||||
#include <sys/termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
],
|
||||
[struct winsize termsize = {0}; TIOCGWINSZ;])],
|
||||
[AC_MSG_RESULT(yes); AC_DEFINE([HAVE_WINSIZE], [1], [Define to 1 if the winsize struct and TIOCGWINSZ macro exist])],
|
||||
AC_MSG_RESULT(no))
|
||||
|
||||
# If we have a fwprintf in libc, test that it actually works. As of
|
||||
# March 2006, it is broken under Dragonfly BSD.
|
||||
if test "$ac_cv_func_fwprintf" = yes; then
|
||||
@@ -342,14 +379,14 @@ else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check if we are using basic BSD curses - in that case we redefine
|
||||
# Check if del_curterm is broken - in that case we redefine
|
||||
# del_curterm as a no-op, to avoid a double-free
|
||||
|
||||
AC_MSG_CHECKING([If we are using BSD curses])
|
||||
AC_MSG_CHECKING([If del_curterm is broken])
|
||||
case $target_os in
|
||||
*bsd*)
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_CHECK_LIB( ncurses, del_curterm, true, [AC_DEFINE([HAVE_BROKEN_DEL_CURTERM],[1],[We are using basic BSD curses, redefine del_curterm to a no-op to avoid a double-free bug])])
|
||||
AC_DEFINE([HAVE_BROKEN_DEL_CURTERM],[1],[del_curterm si broken, redefine it to a no-op to avoid a double-free bug])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
@@ -357,7 +394,7 @@ case $target_os in
|
||||
esac
|
||||
|
||||
# Tell the world what we know
|
||||
AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile etc/fish etc/fish_interactive.fish share/fish seq])
|
||||
AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile seq])
|
||||
AC_OUTPUT
|
||||
|
||||
echo "fish is now configured."
|
||||
|
||||
2
count.c
2
count.c
@@ -2,6 +2,8 @@
|
||||
The length command, used for determining the number of items in an
|
||||
environment variable array.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
\subsection begin-description Description
|
||||
|
||||
The \c begin builtin is used to create a new block of code. The block
|
||||
is unconditionally executed. Begin is equivalent to <tt>if
|
||||
true</tt>. The begin command is used to group any number of commands
|
||||
into a block. The reason for this is usually either to introduce a new
|
||||
variable scope or to redirect the input to output of this set of
|
||||
commands as a group.
|
||||
is unconditionally executed. <code>begin; ...; end</tt> is equivalent
|
||||
to <tt>if true; ...; end</tt>. The begin command is used to group any
|
||||
number of commands into a block. The reason for doing so is usually
|
||||
either to introduce a new variable scope, to redirect the input or
|
||||
output of a set of commands as a group, or to specify precedence when
|
||||
using the conditional commands like \c and.
|
||||
|
||||
The \c begin command does not change the current exit status.
|
||||
|
||||
@@ -30,3 +31,17 @@ end
|
||||
# the block and was killed
|
||||
echo $PIRATE
|
||||
</pre>
|
||||
|
||||
In the following code, all output is redirected to the file out.html.
|
||||
|
||||
<pre>
|
||||
begin
|
||||
echo $xml_header
|
||||
echo $html_header
|
||||
if test -e $file
|
||||
...
|
||||
end
|
||||
...
|
||||
|
||||
end > out.html
|
||||
</pre>
|
||||
|
||||
@@ -105,11 +105,14 @@ would remove the two files 'cumbersome' and 'filename.txt'.
|
||||
Some characters can not be written directly on the command line. For
|
||||
these characters, so called escape sequences are provided. These are:
|
||||
|
||||
- <code>'\\n'</code>, escapes a newline character
|
||||
- <code>'\\t'</code>, escapes the tab character
|
||||
- <code>'\\a'</code>, escapes the alert character
|
||||
- <code>'\\b'</code>, escapes the backspace character
|
||||
- <code>'\\r'</code>, escapes the carriage return character
|
||||
- <code>'\\e'</code>, escapes the escape character
|
||||
- <code>'\\f'</code>, escapes the form feed character
|
||||
- <code>'\\n'</code>, escapes a newline character
|
||||
- <code>'\\r'</code>, escapes the carriage return character
|
||||
- <code>'\\t'</code>, escapes the tab character
|
||||
- <code>'\\v'</code>, escapes the vertical tab character
|
||||
- <code>'\\ '</code>, escapes the space character
|
||||
- <code>'\\$'</code>, escapes the dollar character
|
||||
- <code>'\\\\'</code>, escapes the backslash character
|
||||
@@ -259,22 +262,38 @@ $argv</code> should be called when ll is invoked. $argv is an array
|
||||
variable, which always contains all arguments sent to the function. In
|
||||
the example above, these are simply passed on to the ls command. For
|
||||
more information on functions, see the documentation for the <a
|
||||
href='builtin.html#function'>function</a> builtin.
|
||||
href='builtins.html#function'>function</a> builtin.
|
||||
|
||||
\subsubsection Autoloading functions
|
||||
|
||||
Functions can be defined on the commandline or in a configuration
|
||||
file, but they can also be automatically loaded. Fish automatically
|
||||
searches through any directories in the array variable
|
||||
\$fish_function_path, and any functions defined are automatically
|
||||
loaded when needed. A function definition file must have a filename
|
||||
consisting of the name of the function plus the suffix '.fish'.
|
||||
file, but they can also be automatically loaded. This method of
|
||||
defining functions has several advantages. An autoloaded function
|
||||
becomes avaialble automatically to all running shells, if the function
|
||||
definition is changed, all running shells will automatically reload
|
||||
the altered version, startup time and memory usage is improved, etc.
|
||||
|
||||
Fish automatically searches through any directories in the array
|
||||
variable \$fish_function_path, and any functions defined are
|
||||
automatically loaded when needed. A function definition file must have
|
||||
a filename consisting of the name of the function plus the suffix
|
||||
'.fish'.
|
||||
|
||||
The default value for \$fish_function_path is \c ~/.fish.d/functions
|
||||
\c /etc/fish.d/functions \c /usr/share/fish/functions. The exact path to the
|
||||
last two of these may be slighly different depending on what install
|
||||
path prefix was chosen at configuration time. The rationale behind
|
||||
having three different directories is that the first one is for user
|
||||
specific functions, the second one is for system-wide additional
|
||||
functions and the last one is for default fish functions.
|
||||
\c /etc/fish.d/functions \c /usr/share/fish/functions. The exact path
|
||||
to the last two of these may be slighly different depending on what
|
||||
install path prefix was chosen at configuration time. The rationale
|
||||
behind having three different directories is that the first one is for
|
||||
user specific functions, the second one is for system-wide additional
|
||||
functions and the last one is for default fish functions. The path
|
||||
list is searched in order, meaning that by default, the system
|
||||
administrator can override default fish functions, and the user can
|
||||
override functions defined by the system administrator.
|
||||
|
||||
It is very important that function definition files only contain the
|
||||
definition for the specified function and nothing else, otherwise it
|
||||
is possible that autoloading a function files requires that the
|
||||
function already be loaded, i.e. a circular dependency.
|
||||
|
||||
\subsection syntax-words Some common words
|
||||
|
||||
@@ -477,7 +496,7 @@ shells allow you to specify a variable name using '$VARNAME' or
|
||||
'${VARNAME}'. Fish supports the former, and has no support whatsoever
|
||||
for the latter or anything like it. So what is '{$VARNAME}' then?
|
||||
Well, '{WHATEVER}' is <a href='#brace'>brace expansion</a>, identical
|
||||
to that supported by Posix shells, i.e. 'a{b,c}d' -> 'abd acd' works
|
||||
to that supported by e.g. bash. 'a{b,c}d' -> 'abd acd' works
|
||||
both in bash and on fish. So '{$VARNAME}' is a bracket-expansion with
|
||||
only a single element, i.e. it becomes expanded to '$VARNAME', which
|
||||
will be variable expanded to the value of the variable 'VARNAME'. So
|
||||
@@ -1140,9 +1159,9 @@ When defining a new function in fish, it is possible to make it into an
|
||||
event handler, i.e. a function that is automatically run when a
|
||||
specific event takes place. Events that can trigger a handler currently are:
|
||||
|
||||
* When a signal is delivered
|
||||
* When a process or job exits
|
||||
* When the value of a variable is updated
|
||||
- When a signal is delivered
|
||||
- When a process or job exits
|
||||
- When the value of a variable is updated
|
||||
|
||||
Example:
|
||||
|
||||
@@ -2438,6 +2457,7 @@ DAMAGES.
|
||||
- <a href='#faq-cd-implicit'>I accidentally entered a directory path and fish changed directory. What happened?</a>
|
||||
- <a href='#faq-open'>The open command doesn't work.</a>
|
||||
- <a href='#faq-default'>How do I make fish my default shell?</a>
|
||||
- <a href='#faq-titlebar'>I'm seeing weird output before each prompt when using screen. What's wrong?</a>
|
||||
|
||||
<hr>
|
||||
|
||||
@@ -2509,6 +2529,34 @@ package manager), you first need to add fish to the list of shells by
|
||||
executing the following command (assuming you installed fish in
|
||||
/usr/local) as root:
|
||||
|
||||
\section faq-titlebar I'm seeing weird output before each prompt when using screen. What's wrong?
|
||||
|
||||
Quick answer:
|
||||
|
||||
Add
|
||||
|
||||
<pre>
|
||||
function fish_title;end
|
||||
</pre>
|
||||
|
||||
To your ~/.fish file. Problem solved.
|
||||
|
||||
The long answer:
|
||||
|
||||
Fish is trying to set the titlebar message of your terminal. While
|
||||
screen itself supports this feature, your terminal does
|
||||
not. Unfortuntaly, when the underlying terminal doesn't support
|
||||
setting the titlebar, screen simply passes through the escape codes
|
||||
and text to the underlying terminal instead of ignoring them. It is
|
||||
impossible detect and resolve this problem from inside fish since fish
|
||||
has no way of knowing what the underlying terminal type is. For now,
|
||||
the only way to fix this is to unset the titlebar message, as
|
||||
suggested above.
|
||||
|
||||
Note that fish has a default titlebar message, so simply unsetting the
|
||||
fish_title function will not work.
|
||||
|
||||
|
||||
<code>echo /usr/local/bin/fish >>/etc/shells</code>
|
||||
|
||||
If you installed a prepackaged version of fish, the package manager
|
||||
|
||||
@@ -10,7 +10,7 @@ begin; [COMMANDS...] end
|
||||
|
||||
\subsection end-description Description
|
||||
<tt>end</tt> ends a block of commands. For more information, read the
|
||||
documentation for the block constructs, such as \c if, \c for and \
|
||||
documentation for the block constructs, such as \c if, \c for and \c
|
||||
while.
|
||||
|
||||
The \c end command does not change the current exit status.
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
- <code>-s</code> or <code>--on-signal SIGSPEC</code> tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP)
|
||||
- <code>-v</code> or <code>--on-variable VARIABLE_NAME</code> tells fish to run this function when the variable VARIABLE_NAME changes value
|
||||
|
||||
This builtin command is used to create a new function. A Function is a
|
||||
This builtin command is used to create a new function. A function is a
|
||||
list of commands that will be executed when the name of the function
|
||||
is entered. The function
|
||||
|
||||
@@ -25,7 +25,7 @@ end
|
||||
will write <code>hello</code> whenever the user enters \c hi.
|
||||
|
||||
If the user enters any additional arguments after the function, they
|
||||
are inserted into the environment variable <a href="index.html#variables-arrays">array</a> argv.
|
||||
are inserted into the environment <a href="index.html#variables-arrays">variable array</a> argv.
|
||||
|
||||
\subsection function-example Example
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
\subsection trap-description Description
|
||||
|
||||
Trap is a shellscript wrapper around the fish event delivery
|
||||
framework. IT is defined for backwards compatibility reasons. For
|
||||
other uses, it is recommended to define a <a
|
||||
framework. It exists for backwards compatibility with Posix
|
||||
shells. For other uses, it is recommended to define a <a
|
||||
href='index.html#event'>event handler</a>.
|
||||
|
||||
- ARG is the command to be executed on signal delivery
|
||||
|
||||
@@ -22,7 +22,7 @@ value. Other options are interpreted as follows:
|
||||
|
||||
- <code>-a</code> or <code>--all</code> Set or get all current limits
|
||||
- <code>-c</code> or <code>--core-size</code> The maximum size of core files created
|
||||
- <code>-d</code> or <code>--data-size</code> The maximum size of a process’s data segment
|
||||
- <code>-d</code> or <code>--data-size</code> The maximum size of a process's data segment
|
||||
- <code>-f</code> or <code>--file-size</code> The maximum size of files created by the shell
|
||||
- <code>-l</code> or <code>--lock-size</code> The maximum size that may be locked into memory
|
||||
- <code>-m</code> or <code>--resident-set-size</code> The maximum resident set size
|
||||
|
||||
29
env.c
29
env.c
@@ -31,6 +31,10 @@
|
||||
#include <ncurses/term.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_LIBINTL_H
|
||||
#include <libintl.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
@@ -49,13 +53,13 @@
|
||||
#include "env_universal.h"
|
||||
#include "input_common.h"
|
||||
#include "event.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "complete.h"
|
||||
|
||||
/**
|
||||
Command used to start fishd
|
||||
*/
|
||||
#define FISHD_CMD L"if which fishd >/dev/null; fishd ^/tmp/fishd.log.%s; end"
|
||||
#define FISHD_CMD L"if which fishd 2>/dev/null >/dev/null; fishd ^/tmp/fishd.log.%s; end"
|
||||
|
||||
/**
|
||||
Value denoting a null string
|
||||
@@ -305,16 +309,17 @@ static void handle_locale()
|
||||
if( wcscmp( wsetlocale( LC_MESSAGES, (void *)0 ), old ) != 0 )
|
||||
{
|
||||
|
||||
/* Try to make change known to gettext. */
|
||||
#ifdef HAVE__NL_MSG_CAT_CNTR
|
||||
{
|
||||
extern int _nl_msg_cat_cntr;
|
||||
++_nl_msg_cat_cntr;
|
||||
}
|
||||
#elif HAVE_DCGETTEXT
|
||||
dcgettext("fish","Changing language to English",LC_MESSAGES);
|
||||
#endif
|
||||
|
||||
/*
|
||||
Try to make change known to gettext. Both changing
|
||||
_nl_msg_cat_cntr and calling dcgettext might potentially
|
||||
tell some gettext implementation that the translation
|
||||
strings should be reloaded. We do both and hope for the
|
||||
best.
|
||||
*/
|
||||
extern int _nl_msg_cat_cntr;
|
||||
++_nl_msg_cat_cntr;
|
||||
dcgettext( "fish", "Changing language to English", LC_MESSAGES );
|
||||
|
||||
if( is_interactive )
|
||||
{
|
||||
debug( 0, _(L"Changing language to English") );
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -25,6 +25,10 @@
|
||||
#include <ncurses/term.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "fallback.h"
|
||||
@@ -256,11 +260,11 @@ void env_universal_destroy()
|
||||
wperror( L"fcntl" );
|
||||
}
|
||||
try_send_all( &env_universal_server );
|
||||
}
|
||||
|
||||
if( close( env_universal_server.fd ) )
|
||||
{
|
||||
wperror( L"close" );
|
||||
|
||||
if( close( env_universal_server.fd ) )
|
||||
{
|
||||
wperror( L"close" );
|
||||
}
|
||||
}
|
||||
|
||||
env_universal_server.fd =-1;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -28,6 +28,10 @@
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
# Set default search paths for completions and shellscript functions
|
||||
#
|
||||
|
||||
set -g fish_function_path ~/.fish.d/functions @SYSCONFDIR@/fish.d/functions @DATADIR@/fish/functions
|
||||
set -g fish_complete_path ~/.fish.d/completions @SYSCONFDIR@/fish.d/completions @DATADIR@/fish/completions
|
||||
set -g fish_function_path ~/.fish.d/functions @sysconfdir@/fish.d/functions @datadir@/fish/functions
|
||||
set -g fish_complete_path ~/.fish.d/completions @sysconfdir@/fish.d/completions @datadir@/fish/completions
|
||||
|
||||
#
|
||||
# Set default field separators
|
||||
|
||||
@@ -30,10 +30,10 @@ end
|
||||
# be exported, since the fish inputrc file plays nice with other files
|
||||
# by including them when found.
|
||||
# Give priority to the default file installed with fish in
|
||||
# @SYSCONFDIR@/fish_inputrc.
|
||||
# @sysconfdir@/fish_inputrc.
|
||||
#
|
||||
|
||||
for i in ~/.fish_inputrc @SYSCONFDIR@/fish_inputrc ~/.inputrc /etc/inputrc
|
||||
for i in ~/.fish_inputrc @sysconfdir@/fish_inputrc ~/.inputrc /etc/inputrc
|
||||
if test -f $i
|
||||
set -xg INPUTRC $i
|
||||
break
|
||||
|
||||
25
event.c
25
event.c
@@ -3,6 +3,8 @@
|
||||
Functions for handling event triggers
|
||||
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -11,8 +13,6 @@
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "common.h"
|
||||
#include "event.h"
|
||||
#include "signal.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "halloc_util.h"
|
||||
|
||||
/**
|
||||
@@ -391,9 +391,9 @@ static int event_is_killed( event_t *e )
|
||||
|
||||
/**
|
||||
Perform the specified event. Since almost all event firings will
|
||||
not match a single event handler, we make sureto optimize the 'no
|
||||
matches' path. This means that nothing is allocated/initialized
|
||||
unless that is needed.
|
||||
not be matched by even a single event handler, we make sure to
|
||||
optimize the 'no matches' path. This means that nothing is
|
||||
allocated/initialized unless needed.
|
||||
*/
|
||||
static void event_fire_internal( event_t *event )
|
||||
{
|
||||
@@ -473,7 +473,7 @@ static void event_fire_internal( event_t *event )
|
||||
|
||||
/*
|
||||
Event handlers are not part of the main flow of code, so
|
||||
they are marked as non-interactive and as a subshell
|
||||
they are marked as non-interactive
|
||||
*/
|
||||
proc_push_interactive(0);
|
||||
parser_push_block( EVENT );
|
||||
@@ -510,6 +510,13 @@ static void event_fire_delayed()
|
||||
|
||||
int i;
|
||||
|
||||
/*
|
||||
If is_event is one, we are running the event-handler non-recursively.
|
||||
|
||||
When the event handler has called a piece of code that triggers
|
||||
another event, we do not want to fire delayed events because of
|
||||
concurrency problems.
|
||||
*/
|
||||
if( blocked && is_event==1)
|
||||
{
|
||||
array_list_t *new_blocked = 0;
|
||||
@@ -533,7 +540,7 @@ static void event_fire_delayed()
|
||||
free( blocked );
|
||||
blocked = new_blocked;
|
||||
}
|
||||
|
||||
|
||||
while( sig_list[active_list].count > 0 )
|
||||
{
|
||||
signal_list_t *lst;
|
||||
@@ -594,7 +601,7 @@ void event_fire( event_t *event )
|
||||
/*
|
||||
This means we are in a signal handler. We must be very
|
||||
careful not do do anything that could cause a memory
|
||||
allocation or something else that might be illegal in a
|
||||
allocation or something else that might be bad when in a
|
||||
signal handler.
|
||||
*/
|
||||
if( sig_list[active_list].count < SIG_UNHANDLED_MAX )
|
||||
|
||||
119
exec.c
119
exec.c
@@ -5,6 +5,8 @@
|
||||
manual, though I the changes performed have been massive.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
@@ -21,7 +23,9 @@
|
||||
#include <assert.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_SIGINFO_H
|
||||
#include <siginfo.h>
|
||||
#endif
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
@@ -39,7 +43,7 @@
|
||||
#include "expand.h"
|
||||
#include "signal.h"
|
||||
#include "env_universal.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "halloc.h"
|
||||
#include "halloc_util.h"
|
||||
#include "parse_util.h"
|
||||
@@ -75,7 +79,6 @@ static array_list_t *open_fds=0;
|
||||
|
||||
static int set_child_group( job_t *j, process_t *p, int print_errors );
|
||||
|
||||
|
||||
void exec_close( int fd )
|
||||
{
|
||||
int i;
|
||||
@@ -94,13 +97,12 @@ void exec_close( int fd )
|
||||
{
|
||||
for( i=0; i<al_get_count( open_fds ); i++ )
|
||||
{
|
||||
int n = (int)(long)al_get( open_fds, i );
|
||||
int n = (int)al_get_long( open_fds, i );
|
||||
if( n == fd )
|
||||
{
|
||||
al_set( open_fds,
|
||||
i,
|
||||
al_get( open_fds,
|
||||
al_get_count( open_fds ) -1 ) );
|
||||
al_set_long( open_fds,
|
||||
i,
|
||||
al_get_long( open_fds, al_get_count( open_fds ) -1 ) );
|
||||
al_truncate( open_fds,
|
||||
al_get_count( open_fds ) -1 );
|
||||
break;
|
||||
@@ -130,8 +132,8 @@ int exec_pipe( int fd[2])
|
||||
open_fds = al_halloc( global_context );
|
||||
}
|
||||
|
||||
al_push( open_fds, (void *)(long)fd[0] );
|
||||
al_push( open_fds, (void *)(long)fd[1] );
|
||||
al_push_long( open_fds, (long)fd[0] );
|
||||
al_push_long( open_fds, (long)fd[1] );
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -176,7 +178,7 @@ static void close_unused_internal_pipes( io_data_t *io )
|
||||
{
|
||||
for( ;i<al_get_count( open_fds ); i++ )
|
||||
{
|
||||
int n = (int)(long)al_get( open_fds, i );
|
||||
int n = (long)al_get_long( open_fds, i );
|
||||
if( !use_fd_in_pipe( n, io) )
|
||||
{
|
||||
debug( 4, L"Close fd %d, used in other context", n );
|
||||
@@ -674,11 +676,39 @@ void exec( job_t *j )
|
||||
if( no_exec )
|
||||
return;
|
||||
|
||||
|
||||
|
||||
sigemptyset( &chldset );
|
||||
sigaddset( &chldset, SIGCHLD );
|
||||
|
||||
debug( 4, L"Exec job '%ls' with id %d", j->command, j->job_id );
|
||||
|
||||
if( block_io )
|
||||
{
|
||||
if( j->io )
|
||||
j->io = io_add( io_duplicate( j, block_io), j->io );
|
||||
else
|
||||
j->io=io_duplicate( j, block_io);
|
||||
}
|
||||
|
||||
io_data_t *input_redirect = io_get( j->io, 0 );
|
||||
|
||||
if( input_redirect &&
|
||||
(input_redirect->io_mode == IO_BUFFER) &&
|
||||
input_redirect->param3.is_input )
|
||||
{
|
||||
/*
|
||||
Input redirection - create a new gobetween process to take
|
||||
care of buffering
|
||||
*/
|
||||
|
||||
process_t *fake = halloc( j, sizeof(process_t) );
|
||||
fake->type = INTERNAL_BUFFER;
|
||||
fake->pipe_fd = 1;
|
||||
fake->next = j->first_process;
|
||||
j->first_process = fake;
|
||||
}
|
||||
|
||||
if( j->first_process->type==INTERNAL_EXEC )
|
||||
{
|
||||
/*
|
||||
@@ -703,7 +733,7 @@ void exec( job_t *j )
|
||||
j->first_process->completed=1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
pipe_read.fd=0;
|
||||
@@ -716,20 +746,14 @@ void exec( job_t *j )
|
||||
pipe_write.next=0;
|
||||
pipe_write.param1.pipe_fd[0]=pipe_write.param1.pipe_fd[1]=-1;
|
||||
|
||||
//fwprintf( stderr, L"Run command %ls\n", j->command );
|
||||
|
||||
|
||||
if( block_io )
|
||||
{
|
||||
if( j->io )
|
||||
j->io = io_add( io_duplicate( j, block_io), j->io );
|
||||
else
|
||||
j->io=io_duplicate( j, block_io);
|
||||
}
|
||||
//fwprintf( stderr, L"Run command %ls\n", j->command );
|
||||
|
||||
j->io = io_add( j->io, &pipe_write );
|
||||
|
||||
signal_block();
|
||||
|
||||
|
||||
/*
|
||||
This loop loops over every process_t in the job, starting it as
|
||||
appropriate. This turns out to be rather complex, since a
|
||||
@@ -737,12 +761,12 @@ void exec( job_t *j )
|
||||
|
||||
The loop also has to handle pipelining between the jobs.
|
||||
*/
|
||||
|
||||
|
||||
for( p=j->first_process; p; p = p->next )
|
||||
{
|
||||
mypipe[1]=-1;
|
||||
skip_fork=0;
|
||||
|
||||
|
||||
pipe_write.fd = p->pipe_fd;
|
||||
|
||||
/*
|
||||
@@ -811,7 +835,7 @@ void exec( job_t *j )
|
||||
|
||||
if( p->next )
|
||||
{
|
||||
io_buffer = io_buffer_create();
|
||||
io_buffer = io_buffer_create( 0 );
|
||||
j->io = io_add( j->io, io_buffer );
|
||||
}
|
||||
|
||||
@@ -827,7 +851,7 @@ void exec( job_t *j )
|
||||
{
|
||||
if( p->next )
|
||||
{
|
||||
io_buffer = io_buffer_create();
|
||||
io_buffer = io_buffer_create( 0 );
|
||||
j->io = io_add( j->io, io_buffer );
|
||||
}
|
||||
|
||||
@@ -835,7 +859,7 @@ void exec( job_t *j )
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
case INTERNAL_BUILTIN:
|
||||
{
|
||||
int builtin_stdin=0;
|
||||
@@ -945,6 +969,7 @@ void exec( job_t *j )
|
||||
|
||||
switch( p->type )
|
||||
{
|
||||
|
||||
case INTERNAL_BLOCK:
|
||||
case INTERNAL_FUNCTION:
|
||||
{
|
||||
@@ -1025,6 +1050,46 @@ void exec( job_t *j )
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
case INTERNAL_BUFFER:
|
||||
{
|
||||
|
||||
pid = fork();
|
||||
|
||||
if( pid == 0 )
|
||||
{
|
||||
/*
|
||||
This is the child process. Write out the contents of the pipeline.
|
||||
*/
|
||||
p->pid = getpid();
|
||||
setup_child_process( j, p );
|
||||
|
||||
write( 1,
|
||||
input_redirect->param2.out_buffer->buff,
|
||||
input_redirect->param2.out_buffer->used );
|
||||
exit( 0 );
|
||||
}
|
||||
else if( pid < 0 )
|
||||
{
|
||||
/* The fork failed. */
|
||||
debug( 0, FORK_ERROR );
|
||||
wperror (L"fork");
|
||||
exit (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
This is the parent process. Store away
|
||||
information on the child, and possibly give
|
||||
it control over the terminal.
|
||||
*/
|
||||
p->pid = pid;
|
||||
set_child_group( j, p, 0 );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case INTERNAL_BUILTIN:
|
||||
{
|
||||
@@ -1222,7 +1287,7 @@ int exec_subshell( const wchar_t *cmd,
|
||||
}
|
||||
|
||||
is_subshell=1;
|
||||
io_buffer= io_buffer_create();
|
||||
io_buffer= io_buffer_create( 0 );
|
||||
|
||||
prev_status = proc_get_last_status();
|
||||
|
||||
|
||||
226
expand.c
226
expand.c
@@ -5,6 +5,8 @@ parameter expansion.
|
||||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -26,8 +28,6 @@ parameter expansion.
|
||||
#include <procfs.h>
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -42,10 +42,30 @@ parameter expansion.
|
||||
#include "signal.h"
|
||||
#include "tokenizer.h"
|
||||
#include "complete.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "parse_util.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
/**
|
||||
Error issued on invalid variable name
|
||||
*/
|
||||
#define COMPLETE_VAR_DESC _( L"The '$' character begins a variable name. The character '%lc', which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'.")
|
||||
|
||||
/**
|
||||
Error issued on invalid variable name
|
||||
*/
|
||||
#define COMPLETE_VAR_NULL_DESC _( L"The '$' begins a variable name. It was given at the end of an argument. Variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'.")
|
||||
|
||||
/**
|
||||
Error issued on invalid variable name
|
||||
*/
|
||||
#define COMPLETE_VAR_BRACKET_DESC _( L"Did you mean %ls{$%ls}%ls? The '$' character begins a variable name. A bracket, which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'." )
|
||||
|
||||
/**
|
||||
Error issued on invalid variable name
|
||||
*/
|
||||
#define COMPLETE_VAR_PARAN_DESC _( L"Did you mean (COMMAND)? In fish, the '$' character is only used for accessing variables. To learn more about command substitution in fish, type 'help expand-command-substitution'.")
|
||||
|
||||
/**
|
||||
Description for child process
|
||||
*/
|
||||
@@ -575,12 +595,9 @@ static int expand_pid( wchar_t *in,
|
||||
array_list_t *out )
|
||||
{
|
||||
|
||||
if( !in || !out)
|
||||
{
|
||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
||||
return 0;
|
||||
}
|
||||
|
||||
CHECK( in, 0 );
|
||||
CHECK( out, 0 );
|
||||
|
||||
if( *in != PROCESS_EXPAND )
|
||||
{
|
||||
al_push( out, in );
|
||||
@@ -649,6 +666,83 @@ static int expand_pid( wchar_t *in,
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
|
||||
{
|
||||
int stop_pos = token_pos+1;
|
||||
|
||||
switch( token[stop_pos] )
|
||||
{
|
||||
case BRACKET_BEGIN:
|
||||
{
|
||||
wchar_t *cpy = wcsdup( token );
|
||||
*(cpy+token_pos)=0;
|
||||
wchar_t *name = &cpy[stop_pos+1];
|
||||
wchar_t *end = wcschr( name, BRACKET_END );
|
||||
wchar_t *post;
|
||||
int is_var=0;
|
||||
if( end )
|
||||
{
|
||||
post = end+1;
|
||||
*end = 0;
|
||||
|
||||
if( !wcsvarname( name ) )
|
||||
{
|
||||
is_var = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( is_var )
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
error_pos,
|
||||
COMPLETE_VAR_BRACKET_DESC,
|
||||
cpy,
|
||||
name,
|
||||
post );
|
||||
}
|
||||
else
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
error_pos,
|
||||
COMPLETE_VAR_BRACKET_DESC,
|
||||
L"",
|
||||
L"VARIABLE",
|
||||
L"" );
|
||||
}
|
||||
free( cpy );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case INTERNAL_SEPARATOR:
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
error_pos,
|
||||
COMPLETE_VAR_PARAN_DESC );
|
||||
break;
|
||||
}
|
||||
|
||||
case 0:
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
error_pos,
|
||||
COMPLETE_VAR_NULL_DESC );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
error_pos,
|
||||
COMPLETE_VAR_DESC,
|
||||
token[stop_pos] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Expand all environment variables in the string *ptr.
|
||||
|
||||
@@ -674,12 +768,9 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
|
||||
static string_buffer_t *var_tmp = 0;
|
||||
static array_list_t *var_idx_list = 0;
|
||||
|
||||
if( !in || !out)
|
||||
{
|
||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
||||
return 0;
|
||||
}
|
||||
|
||||
CHECK( in, 0 );
|
||||
CHECK( out, 0 );
|
||||
|
||||
if( !var_tmp )
|
||||
{
|
||||
var_tmp = sb_halloc( global_context );
|
||||
@@ -735,43 +826,8 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
|
||||
|
||||
if( var_len == 0 )
|
||||
{
|
||||
switch( in[stop_pos] )
|
||||
{
|
||||
case BRACKET_BEGIN:
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
-1,
|
||||
COMPLETE_VAR_BRACKET_DESC );
|
||||
break;
|
||||
}
|
||||
|
||||
case INTERNAL_SEPARATOR:
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
-1,
|
||||
COMPLETE_VAR_PARAN_DESC );
|
||||
break;
|
||||
}
|
||||
|
||||
case 0:
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
-1,
|
||||
COMPLETE_VAR_NULL_DESC );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
-1,
|
||||
COMPLETE_VAR_DESC,
|
||||
in[stop_pos] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
expand_variable_error( in, stop_pos-1, -1 );
|
||||
|
||||
is_ok = 0;
|
||||
break;
|
||||
}
|
||||
@@ -818,7 +874,7 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
|
||||
is_ok = 0;
|
||||
break;
|
||||
}
|
||||
al_push( var_idx_list, (void *)tmp );
|
||||
al_push_long( var_idx_list, tmp );
|
||||
stop_pos = end-in;
|
||||
}
|
||||
}
|
||||
@@ -831,12 +887,17 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
|
||||
int j;
|
||||
for( j=0; j<al_get_count( var_idx_list ); j++)
|
||||
{
|
||||
long tmp = (long)al_get( var_idx_list, j );
|
||||
long tmp = al_get_long( var_idx_list, j );
|
||||
if( tmp < 0 )
|
||||
{
|
||||
tmp = al_get_count( &var_item_list)+tmp+1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Check that we are within array
|
||||
bounds. If not, truncate the list to
|
||||
exit.
|
||||
*/
|
||||
if( tmp < 1 || tmp > al_get_count( &var_item_list ) )
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
@@ -848,12 +909,11 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Move string from list l to list idx */
|
||||
al_set( var_idx_list, j, al_get( &var_item_list, tmp-1 ) );
|
||||
al_set( &var_item_list, tmp-1, 0 );
|
||||
/* Replace each index in var_idx_list inplace with the string value at the specified index */
|
||||
al_set( var_idx_list, j, wcsdup(al_get( &var_item_list, tmp-1 ) ) );
|
||||
}
|
||||
}
|
||||
/* Free remaining strings in list l and truncate it */
|
||||
/* Free strings in list var_item_list and truncate it */
|
||||
al_foreach( &var_item_list, &free );
|
||||
al_truncate( &var_item_list, 0 );
|
||||
/* Add items from list idx back to list l */
|
||||
@@ -1002,13 +1062,10 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )
|
||||
|
||||
wchar_t *item_begin;
|
||||
int len1, len2, tot_len;
|
||||
|
||||
if( !in || !out)
|
||||
{
|
||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
||||
return 0;
|
||||
}
|
||||
|
||||
CHECK( in, 0 );
|
||||
CHECK( out, 0 );
|
||||
|
||||
for( pos=in;
|
||||
(*pos) && !syntax_error;
|
||||
pos++ )
|
||||
@@ -1127,9 +1184,9 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )
|
||||
}
|
||||
|
||||
/**
|
||||
Perform subshell expansion
|
||||
Perform cmdsubst expansion
|
||||
*/
|
||||
static int expand_subshell( wchar_t *in, array_list_t *out )
|
||||
static int expand_cmdsubst( wchar_t *in, array_list_t *out )
|
||||
{
|
||||
wchar_t *paran_begin=0, *paran_end=0;
|
||||
int len1, len2;
|
||||
@@ -1139,12 +1196,9 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
|
||||
int i, j;
|
||||
const wchar_t *item_begin;
|
||||
|
||||
if( !in || !out)
|
||||
{
|
||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
||||
return 0;
|
||||
}
|
||||
|
||||
CHECK( in, 0 );
|
||||
CHECK( out, 0 );
|
||||
|
||||
switch( parse_util_locate_cmdsubst(in,
|
||||
¶n_begin,
|
||||
¶n_end,
|
||||
@@ -1178,16 +1232,10 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
|
||||
wcslcpy( subcmd, paran_begin+1, paran_end-paran_begin );
|
||||
subcmd[ paran_end-paran_begin-1]=0;
|
||||
|
||||
if( exec_subshell( subcmd, &sub_res)==-1 )
|
||||
{
|
||||
al_foreach( &sub_res, &free );
|
||||
al_destroy( &sub_res );
|
||||
free( subcmd );
|
||||
return 0;
|
||||
}
|
||||
exec_subshell( subcmd, &sub_res);
|
||||
|
||||
al_init( &tail_expand );
|
||||
expand_subshell( wcsdup(paran_end+1), &tail_expand );
|
||||
expand_cmdsubst( wcsdup(paran_end+1), &tail_expand );
|
||||
|
||||
for( i=0; i<al_get_count( &sub_res ); i++ )
|
||||
{
|
||||
@@ -1246,6 +1294,8 @@ static wchar_t *expand_unescape( const wchar_t * in, int escape_special )
|
||||
static wchar_t * expand_tilde_internal( wchar_t *in )
|
||||
{
|
||||
|
||||
CHECK( in, 0 );
|
||||
|
||||
if( in[0] == HOME_DIRECTORY )
|
||||
{
|
||||
int tilde_error = 0;
|
||||
@@ -1332,12 +1382,14 @@ wchar_t *expand_tilde( wchar_t *in)
|
||||
|
||||
/**
|
||||
Remove any internal separators. Also optionally convert wildcard characters to
|
||||
regular equivalents. This is done to support EXPAN_SKIP_WILDCARDS.
|
||||
regular equivalents. This is done to support EXPAND_SKIP_WILDCARDS.
|
||||
*/
|
||||
static void remove_internal_separator( const void *s, int conv )
|
||||
{
|
||||
wchar_t *in = (wchar_t *)s;
|
||||
wchar_t *out=in;
|
||||
|
||||
CHECK( s, );
|
||||
|
||||
while( *in )
|
||||
{
|
||||
@@ -1376,7 +1428,7 @@ int expand_string( void *context,
|
||||
array_list_t *in, *out;
|
||||
|
||||
int i;
|
||||
int subshell_ok = 1;
|
||||
int cmdsubst_ok = 1;
|
||||
int res = EXPAND_OK;
|
||||
int start_count = al_get_count( end_out );
|
||||
|
||||
@@ -1393,7 +1445,7 @@ int expand_string( void *context,
|
||||
al_init( &list1 );
|
||||
al_init( &list2 );
|
||||
|
||||
if( EXPAND_SKIP_SUBSHELL & flags )
|
||||
if( EXPAND_SKIP_CMDSUBST & flags )
|
||||
{
|
||||
wchar_t *begin, *end;
|
||||
|
||||
@@ -1402,7 +1454,7 @@ int expand_string( void *context,
|
||||
&end,
|
||||
1 ) != 0 )
|
||||
{
|
||||
error( SUBSHELL_ERROR, -1, L"Subshells not allowed" );
|
||||
error( CMDSUBST_ERROR, -1, L"Command substitutions not allowed" );
|
||||
free( str );
|
||||
al_destroy( &list1 );
|
||||
al_destroy( &list2 );
|
||||
@@ -1412,10 +1464,10 @@ int expand_string( void *context,
|
||||
}
|
||||
else
|
||||
{
|
||||
subshell_ok = expand_subshell( str, &list1 );
|
||||
cmdsubst_ok = expand_cmdsubst( str, &list1 );
|
||||
}
|
||||
|
||||
if( !subshell_ok )
|
||||
if( !cmdsubst_ok )
|
||||
{
|
||||
al_destroy( &list1 );
|
||||
return EXPAND_ERROR;
|
||||
|
||||
43
expand.h
43
expand.h
@@ -20,9 +20,9 @@
|
||||
#include "util.h"
|
||||
|
||||
/**
|
||||
Flag specifying that subshell expansion should be skipped
|
||||
Flag specifying that cmdsubst expansion should be skipped
|
||||
*/
|
||||
#define EXPAND_SKIP_SUBSHELL 1
|
||||
#define EXPAND_SKIP_CMDSUBST 1
|
||||
|
||||
/**
|
||||
Flag specifying that variable expansion should be skipped
|
||||
@@ -112,26 +112,6 @@ enum
|
||||
/** String containing the character for separating two array elements */
|
||||
#define ARRAY_SEP_STR L"\x1e"
|
||||
|
||||
/**
|
||||
Error issued on invalid variable name
|
||||
*/
|
||||
#define COMPLETE_VAR_DESC _( L"The '$' character begins a variable name. The character '%lc', which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'.")
|
||||
|
||||
/**
|
||||
Error issued on invalid variable name
|
||||
*/
|
||||
#define COMPLETE_VAR_NULL_DESC _( L"The '$' begins a variable name. It was given at the end of an argument. Variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'.")
|
||||
|
||||
/**
|
||||
Error issued on invalid variable name
|
||||
*/
|
||||
#define COMPLETE_VAR_BRACKET_DESC _( L"Did you mean {$VARIABLE}? The '$' character begins a variable name. A bracket, which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'." )
|
||||
|
||||
/**
|
||||
Error issued on invalid variable name
|
||||
*/
|
||||
#define COMPLETE_VAR_PARAN_DESC _( L"Did you mean (COMMAND)? In fish, the '$' character is only used for accessing variables. To learn more about command substitution in fish, type 'help expand-command-substitution'.")
|
||||
|
||||
/**
|
||||
Error issued on array out of bounds
|
||||
*/
|
||||
@@ -142,7 +122,7 @@ enum
|
||||
Perform various forms of expansion on in, such as tilde expansion
|
||||
(\~USER becomes the users home directory), variable expansion
|
||||
(\$VAR_NAME becomes the value of the environment variable VAR_NAME),
|
||||
subshell expansion and wildcard expansion. The results are inserted
|
||||
cmdsubst expansion and wildcard expansion. The results are inserted
|
||||
into the list out.
|
||||
|
||||
If the parameter does not need expansion, it is copied into the list
|
||||
@@ -155,7 +135,7 @@ enum
|
||||
|
||||
\param context the halloc context to use for automatic deallocation
|
||||
\param in The parameter to expand
|
||||
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
||||
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_CMDSUBST EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
||||
\param out The list to which the result will be appended.
|
||||
\return One of EXPAND_OK, EXPAND_ERROR, EXPAND_WILDCARD_MATCH and EXPAND_WILDCARD_NO_MATCH. EXPAND_WILDCARD_NO_MATCH and EXPAND_WILDCARD_MATCH are normal exit conditions used only on strings containing wildcards to tell if the wildcard produced any matches.
|
||||
*/
|
||||
@@ -171,7 +151,7 @@ int expand_string( void *context, wchar_t *in, array_list_t *out, int flag );
|
||||
|
||||
\param context the halloc context to use for automatic deallocation
|
||||
\param in The parameter to expand
|
||||
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
||||
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_CMDSUBST EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
||||
\return The expanded parameter, or 0 on failiure
|
||||
*/
|
||||
wchar_t *expand_one( void *context, wchar_t *in, int flag );
|
||||
@@ -207,4 +187,17 @@ wchar_t *expand_tilde(wchar_t *in);
|
||||
*/
|
||||
int expand_is_clean( const wchar_t *in );
|
||||
|
||||
/**
|
||||
Perform error reporting for a syntax error related to the variable
|
||||
expansion beginning at the specified character of the specified
|
||||
token. This function will call the error function with an
|
||||
explanatory string about what is wrong with the specified token.
|
||||
|
||||
\param token The token containing the error
|
||||
\param token_pos The position where the expansion begins
|
||||
\param error_pos The position on the line to report to the error function.
|
||||
*/
|
||||
void expand_variable_error( const wchar_t *token, int token_pos, int error_pos );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
62
fallback.c
62
fallback.c
@@ -2,6 +2,10 @@
|
||||
This file only contains fallback implementations of functions which
|
||||
have been found to be missing or broken by the configuration
|
||||
scripts.
|
||||
|
||||
Many of these functions are more or less broken and
|
||||
incomplete. lrand28_r internally uses the regular (bad) rand_r
|
||||
function, the gettext function doesn't actually do anything, etc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@@ -21,6 +25,7 @@
|
||||
#include <dirent.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
@@ -65,7 +70,11 @@ int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t))
|
||||
|
||||
#ifdef INTERNAL_FWPRINTF
|
||||
|
||||
void pad( void (*writer)(wchar_t), int count)
|
||||
/**
|
||||
Internal function for the wprintf fallbacks. USed to write the
|
||||
specified number of spaces.
|
||||
*/
|
||||
static void pad( void (*writer)(wchar_t), int count)
|
||||
{
|
||||
|
||||
int i;
|
||||
@@ -997,14 +1006,6 @@ wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BROKEN_DEL_CURTERM
|
||||
|
||||
int del_curterm(TERMINAL *oterm)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LRAND48_R
|
||||
|
||||
int lrand48_r(struct drand48_data *buffer, long int *result)
|
||||
@@ -1029,6 +1030,49 @@ int futimes(int fd, const struct timeval *times)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETTEXT
|
||||
|
||||
char * gettext (const char * msgid)
|
||||
{
|
||||
return (char *)msgid;
|
||||
}
|
||||
|
||||
char * bindtextdomain (const char * domainname, const char * dirname)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
char * textdomain (const char * domainname)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DCGETTEXT
|
||||
|
||||
char * dcgettext ( const char * domainname,
|
||||
const char * msgid,
|
||||
int category)
|
||||
{
|
||||
return (char *)msgid;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE__NL_MSG_CAT_CNTR
|
||||
|
||||
int _nl_msg_cat_cntr=0;
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_KILLPG
|
||||
int killpg( int pgr, int sig )
|
||||
{
|
||||
assert( pgr > 0 );
|
||||
return kill( -pgr, sig );
|
||||
}
|
||||
#endif
|
||||
|
||||
68
fallback.h
68
fallback.h
@@ -43,6 +43,20 @@ typedef int tputs_arg_t;
|
||||
typedef char tputs_arg_t;
|
||||
#endif
|
||||
|
||||
#ifndef SIGIO
|
||||
#define SIGIO SIGUSR1
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WINSIZE
|
||||
struct winsize
|
||||
{
|
||||
unsigned short ws_row;
|
||||
unsigned short ws_col;
|
||||
}
|
||||
;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TPUTS_KLUDGE
|
||||
|
||||
/**
|
||||
@@ -290,7 +304,7 @@ size_t wcslcpy( wchar_t *dst, const wchar_t *src, size_t siz );
|
||||
/**
|
||||
BSD del_curterm seems to do a double-free. We redefine it as a no-op
|
||||
*/
|
||||
int del_curterm(TERMINAL *oterm);
|
||||
#define del_curterm(oterm) 1
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LRAND48_R
|
||||
@@ -310,20 +324,66 @@ struct drand48_data
|
||||
/**
|
||||
Fallback implementation of lrand48_r. Internally uses rand_r, so it is pretty weak.
|
||||
*/
|
||||
int lrand48_r(struct drand48_data *buffer, long int *result);
|
||||
int lrand48_r( struct drand48_data *buffer, long int *result );
|
||||
|
||||
/**
|
||||
Fallback implementation of srand48_r, the seed function for lrand48_r.
|
||||
*/
|
||||
int srand48_r(long int seedval, struct drand48_data *buffer);
|
||||
int srand48_r( long int seedval, struct drand48_data *buffer );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FUTIMES
|
||||
|
||||
int futimes(int fd, const struct timeval *times);
|
||||
int futimes( int fd, const struct timeval *times );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETTEXT
|
||||
|
||||
/**
|
||||
Fallback implementation of gettext. Just returns the original string.
|
||||
*/
|
||||
char * gettext( const char * msgid );
|
||||
|
||||
/**
|
||||
Fallback implementation of bindtextdomain. Does nothing.
|
||||
*/
|
||||
char * bindtextdomain( const char * domainname, const char * dirname );
|
||||
|
||||
/**
|
||||
Fallback implementation of textdomain. Does nothing.
|
||||
*/
|
||||
char * textdomain( const char * domainname );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DCGETTEXT
|
||||
|
||||
/**
|
||||
Fallback implementation of dcgettext. Just returns the original string.
|
||||
*/
|
||||
char * dcgettext ( const char * domainname,
|
||||
const char * msgid,
|
||||
int category );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE__NL_MSG_CAT_CNTR
|
||||
|
||||
/**
|
||||
Some gettext implementation use have this variable, and by
|
||||
increasing it, one can tell the system that the translations need
|
||||
to be reloaded.
|
||||
*/
|
||||
extern int _nl_msg_cat_cntr;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_KILLPG
|
||||
int killpg( int pgr, int sig );
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
78
fish.spec.in
78
fish.spec.in
@@ -1,5 +1,3 @@
|
||||
%define xinclude %( if test -d /usr/X11R6/include; then echo /usr/X11R6/include; else echo /usr/include; fi )
|
||||
|
||||
Summary: A friendly interactive shell
|
||||
Name: @PACKAGE_NAME@
|
||||
|
||||
@@ -13,20 +11,52 @@ URL: http://roo.no-ip.org/fish/
|
||||
Source0: http://roo.no-ip.org/%{name}/files/%{version}/%{name}-%{version}.tar.bz2
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: ncurses-devel
|
||||
BuildRequires: %{xinclude}/X11/StringDefs.h, %{xinclude}/X11/Xlib.h
|
||||
BuildRequires: %{xinclude}/X11/Intrinsic.h, %{xinclude}/X11/Xatom.h
|
||||
BuildRequires: ncurses-devel gettext groff
|
||||
|
||||
|
||||
# Locate correct build time-dependencies for providing X headers
|
||||
%if "%fedora" >= "5"
|
||||
|
||||
# Modern Fedora version, has modular X.org
|
||||
BuildRequires: xorg-x11-proto-devel libX11-devel libXt-devel libXext-devel
|
||||
|
||||
%endif
|
||||
|
||||
%if "%fedora" < "5"
|
||||
%if "%fedora" >= "3"
|
||||
|
||||
# Semi-old Fedora version, has non-modular X.org
|
||||
BuildRequires: xorg-x11-devel
|
||||
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora}
|
||||
%if "%fedora" < "3"
|
||||
|
||||
# Ancient Fedora version, has XFree86
|
||||
BuildRequires: XFree86-devel
|
||||
|
||||
%endif
|
||||
%else
|
||||
|
||||
# The %fedora variable has not been correctly defined, or this is is
|
||||
# not a Fedora system, try guessing BuildRequires by looking at the
|
||||
# directory structure
|
||||
%define xinclude /usr%(if [ -d /usr/X11R6/include ]; then echo /X11R6; fi)/include
|
||||
BuildRequires: %{xinclude}/X11/StringDefs.h, %{xinclude}/X11/Xlib.h
|
||||
BuildRequires: %{xinclude}/X11/Intrinsic.h, %{xinclude}/X11/Xatom.h
|
||||
|
||||
%endif
|
||||
|
||||
|
||||
%description
|
||||
fish is a shell geared towards interactive use. It's features are
|
||||
focused on user friendlieness and discoverability. The language syntax
|
||||
|
||||
fish is a shell geared towards interactive use. Its features are
|
||||
focused on user friendliness and discoverability. The language syntax
|
||||
is simple but incompatible with other shell languages.
|
||||
|
||||
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
@@ -34,6 +64,9 @@ is simple but incompatible with other shell languages.
|
||||
|
||||
|
||||
%build
|
||||
# The docdir argument is to make the name of the cosumantation
|
||||
# directory 'fish-VERSION', instead of the default, which is simply
|
||||
# 'fish'.
|
||||
%configure docdir=%_datadir/doc/%{name}-%{version}
|
||||
make %{?_smp_mflags}
|
||||
|
||||
@@ -44,6 +77,8 @@ make %{?_smp_mflags}
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make install DESTDIR="$RPM_BUILD_ROOT"
|
||||
|
||||
# Find translation files
|
||||
%find_lang %{name}.\*
|
||||
|
||||
|
||||
|
||||
@@ -54,6 +89,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
|
||||
%post
|
||||
# Add fish to the list of allowed shells in /etc/shells
|
||||
if ! grep %_bindir/fish %_sysconfdir/shells >/dev/null; then
|
||||
echo %_bindir/fish >>%_sysconfdir/shells
|
||||
fi
|
||||
@@ -62,6 +98,7 @@ fi
|
||||
|
||||
|
||||
%postun
|
||||
# Remove fish from the list of allowed shells in /etc/shells
|
||||
if [ "$1" = 0 ]; then
|
||||
grep -v %_bindir/fish %_sysconfdir/shells >%_sysconfdir/fish.tmp
|
||||
mv %_sysconfdir/fish.tmp %_sysconfdir/shells
|
||||
@@ -70,11 +107,14 @@ fi
|
||||
|
||||
|
||||
|
||||
%files
|
||||
%files -f %{name}.\*.lang
|
||||
|
||||
%defattr(-,root,root,-)
|
||||
|
||||
# The documentation directory
|
||||
%doc %_datadir/doc/%{name}-%{version}
|
||||
|
||||
# man files
|
||||
%_mandir/man1/fish.1*
|
||||
%_mandir/man1/xsel.1x*
|
||||
%_mandir/man1/mimedb.1*
|
||||
@@ -83,6 +123,7 @@ fi
|
||||
%_mandir/man1/fishd.1*
|
||||
%_mandir/man1/fish_pager.1*
|
||||
|
||||
# The program binaries
|
||||
%attr(0755,root,root) %_bindir/fish
|
||||
%attr(0755,root,root) %_bindir/fishd
|
||||
%attr(0755,root,root) %_bindir/fish_pager
|
||||
@@ -91,26 +132,41 @@ fi
|
||||
%attr(0755,root,root) %_bindir/mimedb
|
||||
%attr(0755,root,root) %_bindir/count
|
||||
|
||||
# Configuration files
|
||||
%config %_sysconfdir/fish
|
||||
%config %_sysconfdir/fish_inputrc
|
||||
%dir %_sysconfdir/fish.d
|
||||
%config %_sysconfdir/fish.d/fish_*.fish
|
||||
|
||||
# Non-configuration initialization files
|
||||
%dir %_datadir/fish
|
||||
%_datadir/fish/fish
|
||||
|
||||
# Program specific tab-completions
|
||||
%dir %_datadir/fish/completions
|
||||
%_datadir/fish/completions/*.fish
|
||||
|
||||
# Dynamically loaded shellscript functions
|
||||
%dir %_datadir/fish/functions
|
||||
%_datadir/fish/functions/*.fish
|
||||
|
||||
%_datadir/locale/*/LC_MESSAGES/fish.mo
|
||||
|
||||
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Aug 4 2006 Axel Liljencrantz<axel@liljencrantz.se> 1.21.10-4
|
||||
- Add better translation finding code from fedora spec to main spec. Thank you to Michael Schwendt.
|
||||
- Add missing dependency libXext-devel.
|
||||
- Remove one nesting level from dependency checking code.
|
||||
|
||||
* Tue Aug 1 2006 Axel Liljencrantz<axel@liljencrantz.se> 1.21.10-1
|
||||
- Improved the dependency check for X headers. Thank you to Michael Schwendt for pointers on how to do this
|
||||
|
||||
* Mon Jul 31 2006 Axel Liljencrantz<axel@liljencrantz.se> 1.21.10-1
|
||||
- Fixed spelling and punctuation as a per patch from Paul Howarth
|
||||
- Fixed dependencies as per patch from Paul Howarth
|
||||
|
||||
* Tue Nov 29 2005 Axel Liljencrantz <axel@liljencrantz.se> 1.17.0-0
|
||||
- 1.17.0
|
||||
|
||||
|
||||
111
fish_pager.c
111
fish_pager.c
@@ -9,7 +9,14 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_SYS_TERMIOS_H
|
||||
#include <sys/termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <dirent.h>
|
||||
@@ -131,14 +138,21 @@ typedef struct
|
||||
|
||||
static int get_color( int highlight )
|
||||
{
|
||||
wchar_t *val;
|
||||
|
||||
if( highlight < 0 )
|
||||
return FISH_COLOR_NORMAL;
|
||||
if( highlight >= (4) )
|
||||
return FISH_COLOR_NORMAL;
|
||||
|
||||
wchar_t *val = env_universal_get( hightlight_var[highlight]);
|
||||
val = wgetenv( hightlight_var[highlight]);
|
||||
|
||||
if( !val )
|
||||
{
|
||||
val = env_universal_get( hightlight_var[highlight]);
|
||||
}
|
||||
|
||||
if( val == 0 )
|
||||
if( !val )
|
||||
{
|
||||
return FISH_COLOR_NORMAL;
|
||||
}
|
||||
@@ -881,15 +895,29 @@ static void init()
|
||||
the resulting output back to the caller
|
||||
*/
|
||||
int out = dup( 1 );
|
||||
int in = dup( 0 );
|
||||
close(1);
|
||||
if( open( ttyname(0), O_WRONLY ) != 1 )
|
||||
close(0);
|
||||
|
||||
if( (in = open( ttyname(2), O_RDWR )) != -1 )
|
||||
{
|
||||
if( dup2( 2, 1 ) == -1 )
|
||||
{
|
||||
debug( 0, L"Could not set up file descriptors for pager" );
|
||||
debug( 0, L"Could not set up output file descriptors for pager" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
if( dup2( in, 0 ) == -1 )
|
||||
{
|
||||
debug( 0, L"Could not set up input file descriptors for pager %d", in );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug( 0, L"Could not open tty for pager" );
|
||||
exit( 1 );
|
||||
}
|
||||
out_file = fdopen( out, "w" );
|
||||
|
||||
/**
|
||||
@@ -949,11 +977,54 @@ void destroy()
|
||||
env_universal_destroy();
|
||||
input_common_destroy();
|
||||
halloc_util_destroy();
|
||||
del_curterm( cur_term );
|
||||
if( del_curterm( cur_term ) == ERR )
|
||||
{
|
||||
debug( 0, _(L"Error while closing terminfo") );
|
||||
}
|
||||
|
||||
sb_destroy( &out_buff );
|
||||
fclose( out_file );
|
||||
}
|
||||
|
||||
#define BUFSIZE 1024
|
||||
void read_array( FILE* file, array_list_t *comp )
|
||||
{
|
||||
char buffer[BUFSIZE];
|
||||
int c;
|
||||
int i;
|
||||
wchar_t *wcs, *unescaped;
|
||||
|
||||
while( !feof( file ) )
|
||||
{
|
||||
i = 0;
|
||||
while( i < BUFSIZE-1 )
|
||||
{
|
||||
c = getc( file );
|
||||
if( c == EOF )
|
||||
{
|
||||
return;
|
||||
|
||||
}
|
||||
if( c == '\n' )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
buffer[ i++ ] = c;
|
||||
}
|
||||
|
||||
buffer[ i ] = '\0';
|
||||
|
||||
wcs = str2wcs( buffer );
|
||||
if( wcs )
|
||||
{
|
||||
unescaped = unescape( wcs, 0 );
|
||||
al_push( comp, unescaped );
|
||||
free( wcs );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
int i;
|
||||
@@ -961,8 +1032,6 @@ int main( int argc, char **argv )
|
||||
array_list_t *comp;
|
||||
wchar_t *prefix;
|
||||
|
||||
init();
|
||||
|
||||
if( argc < 3 )
|
||||
{
|
||||
debug( 0, L"Insufficient arguments" );
|
||||
@@ -976,19 +1045,29 @@ int main( int argc, char **argv )
|
||||
|
||||
debug( 3, L"prefix is '%ls'", prefix );
|
||||
|
||||
for( i=3; i<argc; i++ )
|
||||
if( argc > 3 )
|
||||
{
|
||||
wchar_t *wcs = str2wcs( argv[i] );
|
||||
if( wcs )
|
||||
for( i=3; i<argc; i++ )
|
||||
{
|
||||
al_push( comp, wcs );
|
||||
wchar_t *wcs = str2wcs( argv[i] );
|
||||
if( wcs )
|
||||
{
|
||||
al_push( comp, wcs );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mangle_descriptions( comp );
|
||||
if( wcscmp( prefix, L"-" ) == 0 )
|
||||
join_completions( comp );
|
||||
mangle_completions( comp, prefix );
|
||||
else
|
||||
{
|
||||
read_array( stdin, comp );
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
|
||||
mangle_descriptions( comp );
|
||||
if( wcscmp( prefix, L"-" ) == 0 )
|
||||
join_completions( comp );
|
||||
mangle_completions( comp, prefix );
|
||||
|
||||
for( i = 6; i>0; i-- )
|
||||
{
|
||||
|
||||
40
fish_tests.c
40
fish_tests.c
@@ -152,7 +152,7 @@ static void pq_test( int elements )
|
||||
*/
|
||||
static int stack_test( int elements )
|
||||
{
|
||||
int i;
|
||||
long i;
|
||||
|
||||
int res=1;
|
||||
|
||||
@@ -162,12 +162,12 @@ static int stack_test( int elements )
|
||||
|
||||
for( i=0; i<elements; i++ )
|
||||
{
|
||||
int foo;
|
||||
long foo;
|
||||
|
||||
al_push( &s, (void*)i);
|
||||
al_push( &s, (void*)i);
|
||||
al_push_long( &s, i);
|
||||
al_push_long( &s, i);
|
||||
|
||||
if( (foo=(int)al_pop( &s )) != i )
|
||||
if( (foo=al_pop_long( &s )) != i )
|
||||
{
|
||||
err( L"Unexpected data" );
|
||||
res = 0;
|
||||
@@ -177,16 +177,14 @@ static int stack_test( int elements )
|
||||
|
||||
for( i=0; i<elements; i++ )
|
||||
{
|
||||
int foo;
|
||||
long foo;
|
||||
|
||||
if( (foo=(int)al_pop( &s )) != (elements-i-1) )
|
||||
if( (foo=al_pop_long( &s )) != (elements-i-1) )
|
||||
{
|
||||
err( L"Unexpected data" );
|
||||
res = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +196,7 @@ static int stack_test( int elements )
|
||||
/**
|
||||
Hash function for pointers
|
||||
*/
|
||||
static int hash_func( const void *data )
|
||||
static int hash_func( void *data )
|
||||
{
|
||||
/* srand( (int)data );
|
||||
return rand();
|
||||
@@ -210,7 +208,7 @@ static int hash_func( const void *data )
|
||||
/**
|
||||
Pointer hash comparison function
|
||||
*/
|
||||
static int compare_func( const void *key1, const void *key2 )
|
||||
static int compare_func( void *key1, void *key2 )
|
||||
{
|
||||
return key1==key2;
|
||||
}
|
||||
@@ -297,22 +295,22 @@ static int hash_test( int elements )
|
||||
*/
|
||||
static void al_test( int sz)
|
||||
{
|
||||
int i;
|
||||
long i;
|
||||
array_list_t l;
|
||||
|
||||
|
||||
|
||||
al_init( &l );
|
||||
|
||||
al_set( &l, 1, (void *)7 );
|
||||
al_set( &l, sz, (void *)7 );
|
||||
al_set_long( &l, 1, 7L );
|
||||
al_set_long( &l, sz, 7L );
|
||||
|
||||
if( al_get_count( &l ) != maxf( sz+1, 2 ) )
|
||||
if( al_get_count( &l ) != maxi( sz+1, 2 ) )
|
||||
err( L"Wrong number of elements in array list" );
|
||||
|
||||
for( i=0; i<al_get_count( &l ); i++ )
|
||||
{
|
||||
int val = (int)((long) al_get( &l, i ));
|
||||
long val = al_get_long( &l, i );
|
||||
if( (i == 1) || (i==sz))
|
||||
{
|
||||
if( val != 7 )
|
||||
@@ -577,7 +575,7 @@ static int expand_test( const wchar_t *in, int flags, ... )
|
||||
}
|
||||
va_end( va );
|
||||
|
||||
al_foreach( &out, (void (*)(const void *))&free );
|
||||
al_foreach( &out, &free );
|
||||
return res;
|
||||
|
||||
}
|
||||
@@ -642,7 +640,7 @@ void perf_complete()
|
||||
|
||||
matches += al_get_count( &out );
|
||||
|
||||
al_foreach( &out, (void (*)(const void *))&free );
|
||||
al_foreach( &out, &free );
|
||||
al_truncate( &out, 0 );
|
||||
}
|
||||
t2=get_time();
|
||||
@@ -664,7 +662,7 @@ void perf_complete()
|
||||
|
||||
matches += al_get_count( &out );
|
||||
|
||||
al_foreach( &out, (void (*)(const void *))&free );
|
||||
al_foreach( &out, &free );
|
||||
al_truncate( &out, 0 );
|
||||
}
|
||||
t2=get_time();
|
||||
@@ -696,7 +694,6 @@ int main( int argc, char **argv )
|
||||
parser_init();
|
||||
function_init();
|
||||
builtin_init();
|
||||
complete_init();
|
||||
reader_init();
|
||||
env_init();
|
||||
|
||||
@@ -718,7 +715,6 @@ int main( int argc, char **argv )
|
||||
parser_destroy();
|
||||
function_destroy();
|
||||
builtin_destroy();
|
||||
complete_destroy();
|
||||
wutil_destroy();
|
||||
event_destroy();
|
||||
proc_destroy();
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
/** \file function.c
|
||||
Functions for storing and retrieving function information.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -8,15 +11,12 @@
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "wutil.h"
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "function.h"
|
||||
#include "proc.h"
|
||||
#include "translate.h"
|
||||
#include "parser.h"
|
||||
#include "common.h"
|
||||
#include "intern.h"
|
||||
|
||||
29
highlight.c
29
highlight.c
@@ -1,6 +1,8 @@
|
||||
/** \file highlight.c
|
||||
Functions for syntax highlighting
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -11,8 +13,6 @@
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "output.h"
|
||||
#include "halloc.h"
|
||||
#include "halloc_util.h"
|
||||
#include "wildcard.h"
|
||||
|
||||
/**
|
||||
Number of elements in the highlight_var array
|
||||
@@ -102,6 +103,9 @@ static int is_potential_path( const wchar_t *path )
|
||||
case BRACKET_BEGIN:
|
||||
case BRACKET_END:
|
||||
case BRACKET_SEP:
|
||||
case ANY_CHAR:
|
||||
case ANY_STRING:
|
||||
case ANY_STRING_RECURSIVE:
|
||||
{
|
||||
has_magic = 1;
|
||||
break;
|
||||
@@ -132,7 +136,10 @@ static int is_potential_path( const wchar_t *path )
|
||||
{
|
||||
dir = wopendir( unescaped );
|
||||
res = !!dir;
|
||||
closedir( dir );
|
||||
if( dir )
|
||||
{
|
||||
closedir( dir );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -579,7 +586,7 @@ void highlight_shell( wchar_t * buff,
|
||||
{
|
||||
wchar_t *dir = expand_one( context,
|
||||
wcsdup(tok_last( &tok )),
|
||||
EXPAND_SKIP_SUBSHELL );
|
||||
EXPAND_SKIP_CMDSUBST );
|
||||
if( dir )
|
||||
{
|
||||
if( !parser_cdpath_get( context, dir ) )
|
||||
@@ -605,7 +612,7 @@ void highlight_shell( wchar_t * buff,
|
||||
*/
|
||||
cmd = expand_one( context,
|
||||
wcsdup(tok_last( &tok )),
|
||||
EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES);
|
||||
EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES);
|
||||
|
||||
if( cmd == 0 )
|
||||
{
|
||||
@@ -722,9 +729,9 @@ void highlight_shell( wchar_t * buff,
|
||||
{
|
||||
case TOK_STRING:
|
||||
{
|
||||
target = expand_one( context, wcsdup( tok_last( &tok ) ), EXPAND_SKIP_SUBSHELL);
|
||||
target = expand_one( context, wcsdup( tok_last( &tok ) ), EXPAND_SKIP_CMDSUBST);
|
||||
/*
|
||||
Redirect filename may contain a subshell.
|
||||
Redirect filename may contain a cmdsubst.
|
||||
If so, it will be ignored/not flagged.
|
||||
*/
|
||||
}
|
||||
@@ -825,7 +832,7 @@ void highlight_shell( wchar_t * buff,
|
||||
tok_destroy( &tok );
|
||||
|
||||
/*
|
||||
Locate and syntax highlight subshells recursively
|
||||
Locate and syntax highlight cmdsubsts recursively
|
||||
*/
|
||||
|
||||
wchar_t *buffcpy = halloc_wcsdup( context, buff );
|
||||
@@ -956,7 +963,7 @@ static void highlight_universal_internal( wchar_t * buff,
|
||||
if( level == 0 )
|
||||
{
|
||||
level++;
|
||||
al_push( &l, (void *)(str-buff) );
|
||||
al_push_long( &l, (long)(str-buff) );
|
||||
prev_q = *str;
|
||||
}
|
||||
else
|
||||
@@ -966,7 +973,7 @@ static void highlight_universal_internal( wchar_t * buff,
|
||||
long pos1, pos2;
|
||||
|
||||
level--;
|
||||
pos1 = (long)al_pop( &l );
|
||||
pos1 = al_pop_long( &l );
|
||||
pos2 = str-buff;
|
||||
if( pos1==pos || pos2==pos )
|
||||
{
|
||||
@@ -980,7 +987,7 @@ static void highlight_universal_internal( wchar_t * buff,
|
||||
else
|
||||
{
|
||||
level++;
|
||||
al_push( &l, (void *)(str-buff) );
|
||||
al_push_long( &l, (long)(str-buff) );
|
||||
prev_q = *str;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/** \file history.c
|
||||
History functions, part of the user interface.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -11,8 +13,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
127
input.c
127
input.c
@@ -17,7 +17,15 @@ implementation in fish is as of yet incomplete.
|
||||
#include <termios.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_SYS_TERMIOS_H
|
||||
#include <sys/termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <wchar.h>
|
||||
|
||||
@@ -59,7 +67,7 @@ implementation in fish is as of yet incomplete.
|
||||
#include "expand.h"
|
||||
#include "event.h"
|
||||
#include "signal.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "output.h"
|
||||
#include "intern.h"
|
||||
|
||||
@@ -121,7 +129,8 @@ static const wchar_t *name_arr[] =
|
||||
L"history-token-search-forward",
|
||||
L"self-insert",
|
||||
L"null",
|
||||
L"eof"
|
||||
L"eof",
|
||||
L"vi-arg-digit"
|
||||
}
|
||||
;
|
||||
|
||||
@@ -159,7 +168,8 @@ static const wchar_t *desc_arr[] =
|
||||
L"Search forward through list of previous commands for matching token",
|
||||
L"Insert the pressed key",
|
||||
L"Do nothing",
|
||||
L"End of file"
|
||||
L"End of file",
|
||||
L"Repeat command"
|
||||
}
|
||||
;
|
||||
*/
|
||||
@@ -196,7 +206,8 @@ static const wchar_t code_arr[] =
|
||||
R_HISTORY_TOKEN_SEARCH_FORWARD,
|
||||
R_SELF_INSERT,
|
||||
R_NULL,
|
||||
R_EOF
|
||||
R_EOF,
|
||||
R_VI_ARG_DIGIT
|
||||
}
|
||||
;
|
||||
|
||||
@@ -238,6 +249,19 @@ static int inputrc_error = 0;
|
||||
*/
|
||||
static int is_init = 0;
|
||||
|
||||
|
||||
/**
|
||||
This is the variable telling us how many timew the next command
|
||||
should bne repeated. Only actually used in vi-mode.
|
||||
*/
|
||||
static int repeat_count = 1;
|
||||
|
||||
/**
|
||||
This is the type of the first command in a vi-mode two-part combo
|
||||
like 'dw' or '3d3l'.
|
||||
*/
|
||||
static wint_t first_command = 0;
|
||||
|
||||
wchar_t input_get_code( const wchar_t *name )
|
||||
{
|
||||
|
||||
@@ -998,7 +1022,7 @@ void input_parse_inputrc_line( wchar_t *cmd )
|
||||
{
|
||||
if( wcscmp( key, L"editing-mode" ) == 0 )
|
||||
{
|
||||
// current_mode_mappings = get_mapping( value );
|
||||
current_mode_mappings = get_mapping( value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1305,12 +1329,29 @@ static void add_vi_bindings()
|
||||
add_mapping( L"vi-command", L"$", L"$", L"end-of-line" );
|
||||
add_mapping( L"vi-command", L"^", L"^", L"beginning-of-line" );
|
||||
add_mapping( L"vi-command", L"0", L"0", L"beginning-of-line" );
|
||||
|
||||
add_mapping( L"vi-command", L"b", L"b", L"backward-word" );
|
||||
add_mapping( L"vi-command", L"B", L"B", L"backward-word" );
|
||||
add_mapping( L"vi-command", L"w", L"w", L"forward-word" );
|
||||
add_mapping( L"vi-command", L"W", L"W", L"forward-word" );
|
||||
|
||||
add_mapping( L"vi-command", L"x", L"x", L"delete-char" );
|
||||
|
||||
|
||||
add_mapping( L"vi-command", L"1", L"1", L"vi-arg-digit" );
|
||||
add_mapping( L"vi-command", L"2", L"2", L"vi-arg-digit" );
|
||||
add_mapping( L"vi-command", L"3", L"3", L"vi-arg-digit" );
|
||||
add_mapping( L"vi-command", L"4", L"4", L"vi-arg-digit" );
|
||||
add_mapping( L"vi-command", L"5", L"5", L"vi-arg-digit" );
|
||||
add_mapping( L"vi-command", L"6", L"6", L"vi-arg-digit" );
|
||||
add_mapping( L"vi-command", L"7", L"7", L"vi-arg-digit" );
|
||||
add_mapping( L"vi-command", L"8", L"8", L"vi-arg-digit" );
|
||||
add_mapping( L"vi-command", L"9", L"9", L"vi-arg-digit" );
|
||||
|
||||
|
||||
add_mapping( L"vi-command", L"d", L"d", L"vi-delete-to" );
|
||||
add_mapping( L"vi-command", L"D", L"D", L"vi-delete-to" );
|
||||
|
||||
|
||||
/*
|
||||
movement ("h", "l"), word movement
|
||||
("b", "B", "w", "W", "e", "E"), moving to beginning and end of line
|
||||
@@ -1448,7 +1489,11 @@ void input_destroy()
|
||||
hash_foreach( &all_mappings, &destroy_mapping );
|
||||
hash_destroy( &all_mappings );
|
||||
|
||||
del_curterm( cur_term );
|
||||
if( del_curterm( cur_term ) == ERR )
|
||||
{
|
||||
debug( 0, _(L"Error while closing terminfo") );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1456,6 +1501,8 @@ void input_destroy()
|
||||
*/
|
||||
static wint_t input_exec_binding( mapping *m, const wchar_t *seq )
|
||||
{
|
||||
int i;
|
||||
|
||||
// fwprintf( stderr, L"Binding %ls\n", m->command );
|
||||
wchar_t code = input_get_code( m->command );
|
||||
if( code != -1 )
|
||||
@@ -1464,15 +1511,63 @@ static wint_t input_exec_binding( mapping *m, const wchar_t *seq )
|
||||
{
|
||||
case R_DUMP_FUNCTIONS:
|
||||
{
|
||||
dump_functions();
|
||||
for( i=0; i<repeat_count; i++ )
|
||||
dump_functions();
|
||||
repeat_count = 1;
|
||||
return R_NULL;
|
||||
}
|
||||
|
||||
case R_SELF_INSERT:
|
||||
{
|
||||
for( i=1; i<repeat_count; i++ )
|
||||
input_unreadch( seq[0] );
|
||||
repeat_count = 1;
|
||||
return seq[0];
|
||||
}
|
||||
|
||||
case R_VI_ARG_DIGIT:
|
||||
{
|
||||
int repeat = seq[0]-L'0';
|
||||
if( repeat > 0 && repeat <= 9 )
|
||||
repeat_count *= repeat;
|
||||
|
||||
return R_NULL;
|
||||
}
|
||||
|
||||
case R_VI_DELETE_TO:
|
||||
{
|
||||
first_command = R_VI_DELETE_TO;
|
||||
return R_NULL;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
if( first_command )
|
||||
{
|
||||
switch( first_command )
|
||||
{
|
||||
case R_VI_DELETE_TO:
|
||||
{
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i=1; i<repeat_count; i++ )
|
||||
{
|
||||
input_unreadch( code );
|
||||
}
|
||||
}
|
||||
|
||||
repeat_count = 1;
|
||||
first_command = 0;
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1511,6 +1606,13 @@ static wint_t input_try_mapping( mapping *m)
|
||||
{
|
||||
int j, k;
|
||||
wint_t c=0;
|
||||
|
||||
c = input_common_readch( 0 );
|
||||
if( c == input_get_code( m->command ) )
|
||||
{
|
||||
return input_exec_binding( m, m->seq );
|
||||
}
|
||||
input_unreadch( c );
|
||||
|
||||
if( m->seq != 0 )
|
||||
{
|
||||
@@ -1524,9 +1626,14 @@ static wint_t input_try_mapping( mapping *m)
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
Return the read characters
|
||||
*/
|
||||
input_unreadch(c);
|
||||
for(k=j-1; k>=0; k--)
|
||||
input_unreadch(m->seq[k]);
|
||||
for( k=j-1; k>=0; k-- )
|
||||
{
|
||||
input_unreadch( m->seq[k] );
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
2
input.h
2
input.h
@@ -44,6 +44,8 @@ enum
|
||||
R_HISTORY_TOKEN_SEARCH_BACKWARD,
|
||||
R_HISTORY_TOKEN_SEARCH_FORWARD,
|
||||
R_SELF_INSERT,
|
||||
R_VI_ARG_DIGIT,
|
||||
R_VI_DELETE_TO
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ Implementation file for the low level input library
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
@@ -34,7 +36,7 @@ Implementation file for the low level input library
|
||||
/**
|
||||
Characters that have been read and returned by the sequence matching code
|
||||
*/
|
||||
static wint_t lookahead_arr[32];
|
||||
static wint_t lookahead_arr[1024];
|
||||
|
||||
/**
|
||||
Number of entries in lookahead_arr
|
||||
|
||||
20
io.c
20
io.c
@@ -12,7 +12,15 @@ Utilities for io redirection.
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_TERMIOS_H
|
||||
#include <sys/termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
@@ -39,7 +47,7 @@ Utilities for io redirection.
|
||||
#include "exec.h"
|
||||
#include "common.h"
|
||||
#include "io.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "halloc.h"
|
||||
|
||||
|
||||
@@ -93,16 +101,17 @@ void io_buffer_read( io_data_t *d )
|
||||
}
|
||||
|
||||
|
||||
io_data_t *io_buffer_create()
|
||||
io_data_t *io_buffer_create( int is_input )
|
||||
{
|
||||
io_data_t *buffer_redirect = malloc( sizeof( io_data_t ));
|
||||
|
||||
buffer_redirect->io_mode=IO_BUFFER;
|
||||
buffer_redirect->next=0;
|
||||
buffer_redirect->param2.out_buffer= malloc( sizeof(buffer_t));
|
||||
buffer_redirect->param3.is_input = is_input;
|
||||
b_init( buffer_redirect->param2.out_buffer );
|
||||
buffer_redirect->fd=1;
|
||||
|
||||
buffer_redirect->fd=is_input?0:1;
|
||||
|
||||
if( exec_pipe( buffer_redirect->param1.pipe_fd ) == -1 )
|
||||
{
|
||||
debug( 1, PIPE_ERROR );
|
||||
@@ -221,8 +230,7 @@ void io_print( io_data_t *io )
|
||||
return;
|
||||
}
|
||||
|
||||
debug( 1, L"IO fd %d, type ",
|
||||
io->fd );
|
||||
debug( 1, L"IO fd %d, type ", io->fd );
|
||||
switch( io->io_mode )
|
||||
{
|
||||
case IO_PIPE:
|
||||
|
||||
20
io.h
20
io.h
@@ -44,6 +44,17 @@ typedef struct io_data
|
||||
|
||||
} param2
|
||||
;
|
||||
|
||||
union
|
||||
{
|
||||
/**
|
||||
This will be non-zero if this is a buffer of input, not
|
||||
output
|
||||
*/
|
||||
int is_input;
|
||||
}
|
||||
param3;
|
||||
|
||||
|
||||
/** Pointer to the next IO redirection */
|
||||
struct io_data *next;
|
||||
@@ -80,9 +91,14 @@ void io_buffer_destroy( io_data_t *io_buffer );
|
||||
|
||||
/**
|
||||
Create a IO_BUFFER type io redirection, complete with a pipe and a
|
||||
buffer_t for output.
|
||||
buffer_t for output. The default file descriptor used is 1 for
|
||||
output buffering and 0 for input buffering.
|
||||
|
||||
\param is_input set this parameter to zero if the buffer should be
|
||||
used to buffer the output of a command, or non-zero to buffer the
|
||||
input to a command.
|
||||
*/
|
||||
io_data_t *io_buffer_create();
|
||||
io_data_t *io_buffer_create( int is_input );
|
||||
|
||||
/**
|
||||
Close output pipe, and read from input pipe until eof.
|
||||
|
||||
4
kill.c
4
kill.c
@@ -6,6 +6,8 @@
|
||||
with the X clipboard.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -17,8 +19,6 @@
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
53
main.c
53
main.c
@@ -58,7 +58,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#include "exec.h"
|
||||
#include "event.h"
|
||||
#include "output.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "halloc_util.h"
|
||||
#include "history.h"
|
||||
|
||||
@@ -81,11 +81,9 @@ static int read_init()
|
||||
return 0;
|
||||
}
|
||||
|
||||
env_set( L"__fish_help_dir", DOCDIR, 0);
|
||||
|
||||
eval( L"builtin cd " DATADIR L"/fish 2>/dev/null; and . fish 2>/dev/null", 0, TOP );
|
||||
eval( L"builtin cd " SYSCONFDIR L" 2>/dev/null; and . fish 2>/dev/null", 0, TOP );
|
||||
eval( L"builtin cd 2>/dev/null; and . .fish 2>/dev/null", 0, TOP );
|
||||
eval( L"builtin cd " DATADIR L"/fish 2>/dev/null; and builtin . fish 2>/dev/null", 0, TOP );
|
||||
eval( L"builtin cd " SYSCONFDIR L" 2>/dev/null; and builtin . fish 2>/dev/null", 0, TOP );
|
||||
eval( L"builtin cd 2>/dev/null; and builtin . .fish 2>/dev/null", 0, TOP );
|
||||
|
||||
if( chdir( cwd ) == -1 )
|
||||
{
|
||||
@@ -186,13 +184,17 @@ int main( int argc, char **argv )
|
||||
switch( opt )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'c':
|
||||
{
|
||||
cmd = optarg;
|
||||
is_interactive_session = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'd':
|
||||
{
|
||||
char *end;
|
||||
@@ -210,35 +212,49 @@ int main( int argc, char **argv )
|
||||
}
|
||||
|
||||
case 'h':
|
||||
{
|
||||
cmd = "help";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'i':
|
||||
{
|
||||
force_interactive = 1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'l':
|
||||
{
|
||||
is_login=1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'n':
|
||||
{
|
||||
no_exec=1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'p':
|
||||
{
|
||||
profile = optarg;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'v':
|
||||
{
|
||||
fwprintf( stderr,
|
||||
_(L"%s, version %s\n"),
|
||||
PACKAGE_NAME,
|
||||
PACKAGE_VERSION );
|
||||
exit( 0 );
|
||||
|
||||
}
|
||||
|
||||
case '?':
|
||||
{
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +284,6 @@ int main( int argc, char **argv )
|
||||
builtin_init();
|
||||
function_init();
|
||||
env_init();
|
||||
complete_init();
|
||||
reader_init();
|
||||
history_init();
|
||||
|
||||
@@ -342,10 +357,9 @@ int main( int argc, char **argv )
|
||||
|
||||
proc_fire_event( L"PROCESS_EXIT", EVENT_EXIT, getpid(), res );
|
||||
|
||||
|
||||
history_destroy();
|
||||
complete_destroy();
|
||||
proc_destroy();
|
||||
env_destroy();
|
||||
builtin_destroy();
|
||||
function_destroy();
|
||||
reader_destroy();
|
||||
@@ -354,6 +368,9 @@ int main( int argc, char **argv )
|
||||
event_destroy();
|
||||
|
||||
halloc_util_destroy();
|
||||
|
||||
env_destroy();
|
||||
|
||||
intern_free_all();
|
||||
|
||||
|
||||
|
||||
19
output.c
19
output.c
@@ -11,7 +11,15 @@
|
||||
#include <termios.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_SYS_TERMIOS_H
|
||||
#include <sys/termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <wctype.h>
|
||||
@@ -279,8 +287,12 @@ void set_color( int c, int c2 )
|
||||
writembs( exit_attribute_mode );
|
||||
if( ( last_color != FISH_COLOR_NORMAL ) && fg )
|
||||
{
|
||||
writembs( tparm( fg, last_color ) );
|
||||
if( fg )
|
||||
{
|
||||
writembs( tparm( fg, last_color ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
was_bold=0;
|
||||
was_underline=0;
|
||||
@@ -303,7 +315,10 @@ void set_color( int c, int c2 )
|
||||
{
|
||||
if( is_bold && !was_bold )
|
||||
{
|
||||
writembs( tparm( enter_bold_mode ) );
|
||||
if( enter_bold_mode )
|
||||
{
|
||||
writembs( tparm( enter_bold_mode ) );
|
||||
}
|
||||
}
|
||||
was_bold = is_bold;
|
||||
}
|
||||
|
||||
10
parse_util.c
10
parse_util.c
@@ -29,7 +29,7 @@
|
||||
#include "intern.h"
|
||||
#include "exec.h"
|
||||
#include "env.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "wildcard.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
@@ -376,7 +376,6 @@ void parse_util_token_extent( const wchar_t *buff,
|
||||
CHECK( buff, );
|
||||
|
||||
assert( cursor_pos >= 0 );
|
||||
|
||||
|
||||
a = b = pa = pb = 0;
|
||||
|
||||
@@ -432,11 +431,11 @@ void parse_util_token_extent( const wchar_t *buff,
|
||||
If cursor is inside the token, this is the token we are
|
||||
looking for. If so, set a and b and break
|
||||
*/
|
||||
if( tok_end >= pos )
|
||||
{
|
||||
if( (tok_last_type( &tok ) == TOK_STRING) && (tok_end >= pos ) )
|
||||
{
|
||||
a = begin + tok_get_pos( &tok );
|
||||
b = a + wcslen(tok_last(&tok));
|
||||
|
||||
|
||||
// fwprintf( stderr, L"Whee %ls\n", *a );
|
||||
|
||||
break;
|
||||
@@ -499,6 +498,7 @@ static void clear_loaded_entry( void *key,
|
||||
&clear_hash_value,
|
||||
handler );
|
||||
hash_destroy( &loaded->load_time );
|
||||
hash_destroy( &loaded->is_loading );
|
||||
|
||||
free( loaded->old_path );
|
||||
free( loaded );
|
||||
|
||||
144
parser.c
144
parser.c
@@ -4,6 +4,8 @@ The fish parser. Contains functions for parsing code.
|
||||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -17,8 +19,6 @@ The fish parser. Contains functions for parsing code.
|
||||
#include <dirent.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -37,7 +37,7 @@ The fish parser. Contains functions for parsing code.
|
||||
#include "sanity.h"
|
||||
#include "env_universal.h"
|
||||
#include "event.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "intern.h"
|
||||
#include "parse_util.h"
|
||||
#include "halloc.h"
|
||||
@@ -140,7 +140,7 @@ The fish parser. Contains functions for parsing code.
|
||||
/**
|
||||
Error message for Posix-style assignment
|
||||
*/
|
||||
#define COMMAND_ASSIGN_ERR_MSG _( L"Unknown command '%ls'. Did you mean 'set VARIABLE VALUE'? For information on setting variable values, see the help section on the set command by typing 'help set'.")
|
||||
#define COMMAND_ASSIGN_ERR_MSG _( L"Unknown command '%ls'. Did you mean 'set %ls %ls'? For information on assigning values to variables, see the help section on the set command by typing 'help set'.")
|
||||
|
||||
/**
|
||||
Error for invalid redirection token
|
||||
@@ -1372,7 +1372,8 @@ wchar_t *parser_current_line()
|
||||
// lineno = current_tokenizer_pos;
|
||||
|
||||
|
||||
current_line_width=printed_width(whole_str+current_line_start, current_tokenizer_pos-current_line_start );
|
||||
current_line_width=printed_width( whole_str+current_line_start,
|
||||
current_tokenizer_pos-current_line_start );
|
||||
|
||||
if( (function_name = is_function()) )
|
||||
{
|
||||
@@ -1467,8 +1468,10 @@ int parser_is_help( wchar_t *s, int min_match )
|
||||
{
|
||||
int len = wcslen(s);
|
||||
|
||||
min_match = maxi( min_match, 3 );
|
||||
|
||||
return ( wcscmp( L"-h", s ) == 0 ) ||
|
||||
( len >= 3 && (wcsncmp( L"--help", s, len ) == 0) );
|
||||
( len >= min_match && (wcsncmp( L"--help", s, len ) == 0) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1696,8 +1699,9 @@ static void parse_job_main_loop( process_t *p,
|
||||
tok_last( tok ) );
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
error( SYNTAX_ERROR,
|
||||
tok_get_pos( tok ),
|
||||
@@ -1738,6 +1742,7 @@ static void parse_job_main_loop( process_t *p,
|
||||
break;
|
||||
|
||||
case TOK_REDIRECT_FD:
|
||||
{
|
||||
if( wcscmp( target, L"-" ) == 0 )
|
||||
{
|
||||
new_io->io_mode = IO_CLOSE;
|
||||
@@ -1760,6 +1765,8 @@ static void parse_job_main_loop( process_t *p,
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1820,6 +1827,7 @@ static void parse_job_main_loop( process_t *p,
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Fully parse a single job. Does not call exec on it, but any command substitutions in the job will be executed.
|
||||
|
||||
@@ -1855,7 +1863,7 @@ static int parse_job( process_t *p,
|
||||
{
|
||||
nxt = expand_one( j,
|
||||
wcsdup(tok_last( tok )),
|
||||
EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES);
|
||||
EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES);
|
||||
|
||||
if( nxt == 0 )
|
||||
{
|
||||
@@ -2065,7 +2073,7 @@ static int parse_job( process_t *p,
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if( use_function && !current_block->skip )
|
||||
{
|
||||
int nxt_forbidden;
|
||||
@@ -2161,7 +2169,7 @@ static int parse_job( process_t *p,
|
||||
wchar_t *cmd = (wchar_t *)al_get( args, 0 );
|
||||
|
||||
/*
|
||||
We couln't find the specified command.
|
||||
We couldn't find the specified command.
|
||||
|
||||
What we want to happen now is that the
|
||||
specified job won't get executed, and an
|
||||
@@ -2176,9 +2184,16 @@ static int parse_job( process_t *p,
|
||||
*/
|
||||
if( wcschr( cmd, L'=' ) )
|
||||
{
|
||||
wchar_t *cpy = halloc_wcsdup( j, cmd );
|
||||
wchar_t *valpart = wcschr( cpy, L'=' );
|
||||
*valpart++=0;
|
||||
|
||||
debug( 0,
|
||||
COMMAND_ASSIGN_ERR_MSG,
|
||||
(wchar_t *)al_get( args, 0 ) );
|
||||
cmd,
|
||||
cpy,
|
||||
valpart);
|
||||
|
||||
}
|
||||
else if(cmd[0]==L'$')
|
||||
{
|
||||
@@ -2732,7 +2747,7 @@ static int parser_get_block_type( const wchar_t *cmd )
|
||||
}
|
||||
|
||||
/**
|
||||
\return the block type created by the specified builtin, or -1 on error.
|
||||
\return the block command that createa the specified block type, or null on error.
|
||||
*/
|
||||
static const wchar_t *parser_get_block_command( int type )
|
||||
{
|
||||
@@ -2750,7 +2765,7 @@ static const wchar_t *parser_get_block_command( int type )
|
||||
|
||||
/**
|
||||
Test if this argument contains any errors. Detected errors include
|
||||
syntax errors in command substitutions, imporoper escaped
|
||||
syntax errors in command substitutions, improperly escaped
|
||||
characters and improper use of the variable expansion operator.
|
||||
*/
|
||||
static int parser_test_argument( const wchar_t *arg, string_buffer_t *out, const wchar_t *prefix, int offset )
|
||||
@@ -2785,7 +2800,7 @@ static int parser_test_argument( const wchar_t *arg, string_buffer_t *out, const
|
||||
}
|
||||
free( arg_cpy );
|
||||
return 1;
|
||||
|
||||
|
||||
case 0:
|
||||
do_loop = 0;
|
||||
break;
|
||||
@@ -2843,70 +2858,18 @@ static int parser_test_argument( const wchar_t *arg, string_buffer_t *out, const
|
||||
case VARIABLE_EXPAND:
|
||||
case VARIABLE_EXPAND_SINGLE:
|
||||
{
|
||||
switch( *(pos+1))
|
||||
wchar_t n = *(pos+1);
|
||||
|
||||
if( n != VARIABLE_EXPAND &&
|
||||
n != VARIABLE_EXPAND_SINGLE &&
|
||||
!wcsvarchr(n) )
|
||||
{
|
||||
case BRACKET_BEGIN:
|
||||
err=1;
|
||||
if( out )
|
||||
{
|
||||
err=1;
|
||||
if( out )
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
offset,
|
||||
COMPLETE_VAR_BRACKET_DESC );
|
||||
|
||||
print_errors( out, prefix);
|
||||
}
|
||||
break;
|
||||
expand_variable_error( unesc, pos-unesc, offset );
|
||||
print_errors( out, prefix);
|
||||
}
|
||||
|
||||
case INTERNAL_SEPARATOR:
|
||||
{
|
||||
err=1;
|
||||
if( out )
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
offset,
|
||||
COMPLETE_VAR_PARAN_DESC );
|
||||
print_errors( out, prefix);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 0:
|
||||
{
|
||||
err=1;
|
||||
if( out )
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
offset,
|
||||
COMPLETE_VAR_NULL_DESC );
|
||||
print_errors( out, prefix);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
wchar_t n = *(pos+1);
|
||||
|
||||
if( n != VARIABLE_EXPAND &&
|
||||
n != VARIABLE_EXPAND_SINGLE &&
|
||||
!wcsvarchr(n) )
|
||||
{
|
||||
err=1;
|
||||
if( out )
|
||||
{
|
||||
error( SYNTAX_ERROR,
|
||||
offset,
|
||||
COMPLETE_VAR_DESC,
|
||||
*(pos+1) );
|
||||
print_errors( out, prefix);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -3012,17 +2975,39 @@ int parser_test( const wchar_t * buff,
|
||||
int previous_pos=current_tokenizer_pos;
|
||||
static int block_pos[BLOCK_MAX_COUNT];
|
||||
static int block_type[BLOCK_MAX_COUNT];
|
||||
|
||||
/*
|
||||
Set to 1 if the current command is inside a pipeline
|
||||
*/
|
||||
int is_pipeline = 0;
|
||||
|
||||
/*
|
||||
Set to one if the currently specified process can not be used inside a pipeline
|
||||
*/
|
||||
int forbid_pipeline = 0;
|
||||
|
||||
/*
|
||||
Set to one if an additional process specification is needed
|
||||
*/
|
||||
int needs_cmd=0;
|
||||
|
||||
/*
|
||||
halloc context used for calls to expand() and other memory
|
||||
allocations. Free'd at end of this function.
|
||||
*/
|
||||
void *context;
|
||||
|
||||
/*
|
||||
Counter on the number of arguments this function has encountered
|
||||
so far. Is set to -1 when the count is unknown, i.e. after
|
||||
encountering an argument that contains substitutions that can
|
||||
expand to more/less arguemtns then 1.
|
||||
*/
|
||||
int arg_count=0;
|
||||
|
||||
/*
|
||||
The currently validated command.
|
||||
*/
|
||||
wchar_t *cmd=0;
|
||||
|
||||
CHECK( buff, 1 );
|
||||
@@ -3046,10 +3031,10 @@ int parser_test( const wchar_t * buff,
|
||||
int mark = tok_get_pos( &tok );
|
||||
had_cmd = 1;
|
||||
arg_count=0;
|
||||
|
||||
|
||||
if( !(cmd = expand_one( context,
|
||||
wcsdup( tok_last( &tok ) ),
|
||||
EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES ) ) )
|
||||
EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES ) ) )
|
||||
{
|
||||
err=1;
|
||||
if( out )
|
||||
@@ -3191,11 +3176,16 @@ int parser_test( const wchar_t * buff,
|
||||
|
||||
if( out )
|
||||
{
|
||||
char *h;
|
||||
|
||||
error( SYNTAX_ERROR,
|
||||
tok_get_pos( &tok ),
|
||||
INVALID_CASE_ERR_MSG );
|
||||
|
||||
print_errors( out, prefix);
|
||||
h = builtin_help_get( L"case" );
|
||||
if( h )
|
||||
sb_printf( out, L"%s", h );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6
parser.h
6
parser.h
@@ -179,9 +179,9 @@ enum parser_error
|
||||
*/
|
||||
EVAL_ERROR,
|
||||
/**
|
||||
Error while evaluating subshell
|
||||
Error while evaluating cmdsubst
|
||||
*/
|
||||
SUBSHELL_ERROR,
|
||||
CMDSUBST_ERROR,
|
||||
}
|
||||
;
|
||||
|
||||
@@ -217,7 +217,7 @@ wchar_t *parser_get_filename( void *context, const wchar_t *cmd );
|
||||
int eval( const wchar_t *cmd, io_data_t *io, int block_type );
|
||||
|
||||
/**
|
||||
Evaluate line as a list of parameters, i.e. tokenize it and perform parameter expansion and subshell execution on the tokens.
|
||||
Evaluate line as a list of parameters, i.e. tokenize it and perform parameter expansion and cmdsubst execution on the tokens.
|
||||
The output is inserted into output, and should be freed by the caller.
|
||||
|
||||
\param line Line to evaluate
|
||||
|
||||
21
proc.c
21
proc.c
@@ -20,7 +20,15 @@ Some of the code in this file is based on code from the Glibc manual.
|
||||
#include <termios.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_SYS_TERMIOS_H
|
||||
#include <sys/termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <dirent.h>
|
||||
@@ -42,6 +50,13 @@ Some of the code in this file is based on code from the Glibc manual.
|
||||
#include <ncurses/term.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SIGINFO_H
|
||||
#include <siginfo.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
@@ -55,7 +70,7 @@ Some of the code in this file is based on code from the Glibc manual.
|
||||
#include "parser.h"
|
||||
#include "signal.h"
|
||||
#include "event.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "halloc.h"
|
||||
#include "halloc_util.h"
|
||||
#include "output.h"
|
||||
@@ -1089,7 +1104,7 @@ void proc_sanity_check()
|
||||
void proc_push_interactive( int value )
|
||||
{
|
||||
int old = is_interactive;
|
||||
al_push( interactive_stack, (void *)(long)is_interactive );
|
||||
al_push_long( interactive_stack, (long)is_interactive );
|
||||
is_interactive = value;
|
||||
if( old != value )
|
||||
signal_set_handlers();
|
||||
@@ -1098,7 +1113,7 @@ void proc_push_interactive( int value )
|
||||
void proc_pop_interactive()
|
||||
{
|
||||
int old = is_interactive;
|
||||
is_interactive= (int)(long)al_pop(interactive_stack);
|
||||
is_interactive= (int)al_pop_long(interactive_stack);
|
||||
if( is_interactive != old )
|
||||
signal_set_handlers();
|
||||
}
|
||||
|
||||
17
proc.h
17
proc.h
@@ -45,6 +45,11 @@ enum
|
||||
The exec builtin
|
||||
*/
|
||||
INTERNAL_EXEC,
|
||||
/**
|
||||
A buffer
|
||||
*/
|
||||
INTERNAL_BUFFER,
|
||||
|
||||
}
|
||||
;
|
||||
|
||||
@@ -66,7 +71,7 @@ enum
|
||||
be the result of an exec command. The role of this process_t is
|
||||
determined by the type field, which can be one of EXTERNAL,
|
||||
INTERNAL_BUILTIN, INTERNAL_FUNCTION, INTERNAL_BLOCK and
|
||||
INTERNAL_EXEC.
|
||||
INTERNAL_EXEC, INTERNAL_BUFFER
|
||||
|
||||
The process_t contains information on how the process should be
|
||||
started, such as command name and arguments, as well as runtime
|
||||
@@ -79,13 +84,13 @@ enum
|
||||
argument array and actual_cmd is the absolute path of the command
|
||||
to execute.
|
||||
|
||||
If the process is of type ITERNAL_BUILTIN, argv is the argument
|
||||
If the process is of type INTERNAL_BUILTIN, argv is the argument
|
||||
vector, and argv[0] is the name of the builtin command.
|
||||
|
||||
If the process is of type ITERNAL_FUNCTION, argv is the argument
|
||||
If the process is of type INTERNAL_FUNCTION, argv is the argument
|
||||
vector, and argv[0] is the name of the shellscript function.
|
||||
|
||||
If the process is of type ITERNAL_BLOCK, argv has exactly one
|
||||
If the process is of type INTERNAL_BLOCK, argv has exactly one
|
||||
element, which is the block of commands to execute.
|
||||
|
||||
*/
|
||||
@@ -93,8 +98,8 @@ typedef struct process
|
||||
{
|
||||
/**
|
||||
Type of process. Can be one of \c EXTERNAL, \c
|
||||
INTERNAL_BUILTIN, \c INTERNAL_FUNCTION, \c INTERNAL_BLOCK or
|
||||
INTERNAL_EXEC
|
||||
INTERNAL_BUILTIN, \c INTERNAL_FUNCTION, \c INTERNAL_BLOCK,
|
||||
INTERNAL_EXEC, or INTERNAL_BUFFER
|
||||
*/
|
||||
int type;
|
||||
/** argv parameter for for execv, builtin_run, etc. */
|
||||
|
||||
70
reader.c
70
reader.c
@@ -28,7 +28,15 @@ commence.
|
||||
#include <termios.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_SYS_TERMIOS_H
|
||||
#include <sys/termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/poll.h>
|
||||
@@ -51,6 +59,14 @@ commence.
|
||||
#include <ncurses/term.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SIGINFO_H
|
||||
#include <siginfo.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
@@ -82,7 +98,7 @@ commence.
|
||||
#include "function.h"
|
||||
#include "output.h"
|
||||
#include "signal.h"
|
||||
#include "translate.h"
|
||||
|
||||
#include "parse_util.h"
|
||||
|
||||
/**
|
||||
@@ -633,7 +649,7 @@ void reader_write_title()
|
||||
as that of a virtual terminal, we assume it supports setting the
|
||||
title. Otherwise we check the ttyname.
|
||||
*/
|
||||
if( !term || !contains_str( term, L"xterm", L"screen", L"nxterm", L"rxvt", 0 ) )
|
||||
if( !term || !contains_str( term, L"xterm", L"screen", L"nxterm", L"rxvt", (wchar_t *)0 ) )
|
||||
{
|
||||
char *n = ttyname( STDIN_FILENO );
|
||||
if( strstr( n, "tty" ) || strstr( n, "/vc/") )
|
||||
@@ -651,12 +667,15 @@ void reader_write_title()
|
||||
if( exec_subshell( title, &l ) != -1 )
|
||||
{
|
||||
int i;
|
||||
writestr( L"\e]2;" );
|
||||
for( i=0; i<al_get_count( &l ); i++ )
|
||||
if( al_get_count( &l ) > 0 )
|
||||
{
|
||||
writestr( (wchar_t *)al_get( &l, i ) );
|
||||
writestr( L"\e]2;" );
|
||||
for( i=0; i<al_get_count( &l ); i++ )
|
||||
{
|
||||
writestr( (wchar_t *)al_get( &l, i ) );
|
||||
}
|
||||
writestr( L"\7" );
|
||||
}
|
||||
writestr( L"\7" );
|
||||
}
|
||||
proc_pop_interactive();
|
||||
|
||||
@@ -791,7 +810,13 @@ static int calc_prompt_width( array_list_t *arr )
|
||||
}
|
||||
else if( next[j] == L'\t' )
|
||||
{
|
||||
res=(res+8)&~7;
|
||||
/*
|
||||
Assume tab stops every 8 characters if undefined
|
||||
*/
|
||||
if( init_tabs <= 0 )
|
||||
init_tabs = 8;
|
||||
|
||||
res=( (res/init_tabs)+1 )*init_tabs;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -875,6 +900,7 @@ static void write_cmdline()
|
||||
|
||||
void reader_init()
|
||||
{
|
||||
|
||||
tcgetattr(0,&shell_modes); /* get the current terminal modes */
|
||||
memcpy( &saved_modes,
|
||||
&shell_modes,
|
||||
@@ -1443,7 +1469,9 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
|
||||
{
|
||||
int i;
|
||||
string_buffer_t cmd;
|
||||
string_buffer_t msg;
|
||||
wchar_t * prefix_esc;
|
||||
char *foo;
|
||||
|
||||
if( !prefix || (wcslen(prefix)==0))
|
||||
prefix_esc = wcsdup(L"\"\"");
|
||||
@@ -1451,6 +1479,7 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
|
||||
prefix_esc = escape( prefix,1);
|
||||
|
||||
sb_init( &cmd );
|
||||
sb_init( &msg );
|
||||
sb_printf( &cmd,
|
||||
L"fish_pager %d %ls",
|
||||
// L"valgrind --track-fds=yes --log-file=pager.txt --leak-check=full ./fish_pager %d %ls",
|
||||
@@ -1459,24 +1488,33 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
|
||||
|
||||
free( prefix_esc );
|
||||
|
||||
io_data_t *in= io_buffer_create( 1 );
|
||||
|
||||
for( i=0; i<al_get_count( comp); i++ )
|
||||
{
|
||||
wchar_t *el = escape( (wchar_t*)al_get( comp, i ),1);
|
||||
sb_printf( &cmd, L" %ls", el );
|
||||
free(el);
|
||||
wchar_t *el = escape((wchar_t*)al_get( comp, i ), 0);
|
||||
|
||||
sb_printf( &msg, L"%ls\n", el );
|
||||
free( el );
|
||||
}
|
||||
|
||||
|
||||
foo = wcs2str( (wchar_t *)msg.buff );
|
||||
b_append( in->param2.out_buffer, foo, strlen(foo) );
|
||||
free( foo );
|
||||
|
||||
term_donate();
|
||||
|
||||
io_data_t *out = io_buffer_create();
|
||||
|
||||
|
||||
io_data_t *out = io_buffer_create( 0 );
|
||||
out->next = in;
|
||||
out->fd = 1;
|
||||
|
||||
eval( (wchar_t *)cmd.buff, out, TOP);
|
||||
term_steal();
|
||||
|
||||
io_buffer_read( out );
|
||||
|
||||
sb_destroy( &cmd );
|
||||
|
||||
sb_destroy( &msg );
|
||||
|
||||
int nil=0;
|
||||
b_append( out->param2.out_buffer, &nil, 1 );
|
||||
@@ -1493,7 +1531,9 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
|
||||
free( str );
|
||||
}
|
||||
|
||||
|
||||
io_buffer_destroy( out);
|
||||
io_buffer_destroy( in);
|
||||
|
||||
}
|
||||
|
||||
|
||||
6
sanity.c
6
sanity.c
@@ -1,6 +1,8 @@
|
||||
/** \file sanity.c
|
||||
Functions for performing sanity checks on the program state
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
@@ -13,8 +15,6 @@
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "reader.h"
|
||||
#include "kill.h"
|
||||
#include "wutil.h"
|
||||
#include "translate.h"
|
||||
|
||||
|
||||
/**
|
||||
Status from earlier sanity checks
|
||||
|
||||
2
seq.in
2
seq.in
@@ -39,7 +39,7 @@ switch (count $argv)
|
||||
end
|
||||
|
||||
for i in $from $step $to
|
||||
if not echo $i | grep '^-\?[0-9]*\(\|.[0-9]\+\)$' >/dev/null
|
||||
if not echo $i | grep -E '^-?[0-9]*([0-9]*|\.[0-9]+)$' >/dev/null
|
||||
printf (_ "%s: '%s' is not a number\n") seq $i
|
||||
exit 1
|
||||
end
|
||||
|
||||
@@ -337,6 +337,9 @@ int main( int argc, char **argv )
|
||||
}
|
||||
}
|
||||
|
||||
del_curterm( cur_term );
|
||||
if( del_curterm( cur_term ) == ERR )
|
||||
{
|
||||
debug( 0, _(L"Error while closing terminfo") );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,28 +3,41 @@
|
||||
# common helper functions for the command completions. All actual
|
||||
# completions are located in the completions subdirectory.
|
||||
#
|
||||
# @configure_input@
|
||||
|
||||
#
|
||||
# Assign a temporary value here for performance reasons. The real value should be set in /etc/fish.
|
||||
#
|
||||
# Assign a temporary value here for performance reasons. The real
|
||||
# value should be set in /etc/fish.
|
||||
|
||||
set -g fish_function_path @datadir@/fish/functions/
|
||||
set __fish_help_dir @docdir@
|
||||
|
||||
# This is a Solaris-specific test to modify the PATH so that
|
||||
# Posix-conformant tools are used by default.
|
||||
|
||||
if test -d /usr/xpg4/bin
|
||||
if not contains /usr/xpg4/bin $PATH
|
||||
set PATH /usr/xpg4/bin $PATH
|
||||
end
|
||||
end
|
||||
|
||||
set -g fish_function_path $PWD/functions/
|
||||
|
||||
#
|
||||
# Make sure there are no invalid entries in the PATH
|
||||
#
|
||||
|
||||
set -l erase_idx
|
||||
for idx in (seq (count $PATH))
|
||||
set i $PATH[$idx]
|
||||
if not test -d $i
|
||||
set erase_idx $erase_idx $idx
|
||||
printf (_ '%s: Warning: The directory %s has been removed from your PATH because it does not exist\n') fish $i
|
||||
end
|
||||
end
|
||||
if status --is-interactive
|
||||
set -l erase_idx
|
||||
for idx in (seq (count $PATH))
|
||||
set i $PATH[$idx]
|
||||
if not test -d $i
|
||||
set erase_idx $erase_idx $idx
|
||||
printf (_ '%s: Warning: The directory %s has been removed from your PATH because it does not exist\n') fish $i
|
||||
end
|
||||
end
|
||||
|
||||
if count $erase_idx >/dev/null
|
||||
set -e PATH[(echo $erase_idx)]
|
||||
if count $erase_idx >/dev/null
|
||||
set -e PATH[(echo $erase_idx)]
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
@@ -33,7 +46,7 @@ end
|
||||
# want this even for text-only terminals.
|
||||
#
|
||||
|
||||
set -l path_list /bin /usr/bin /usr/X11R6/bin @PREFIX@/bin @optbindirs@
|
||||
set -l path_list /bin /usr/bin /usr/X11R6/bin @prefix@/bin @optbindirs@
|
||||
|
||||
# Root should also have the sbin directories in the path
|
||||
if test "$USER" = root
|
||||
@@ -41,12 +54,11 @@ if test "$USER" = root
|
||||
end
|
||||
|
||||
# Make a regular expression that matches any component in the PATH. A
|
||||
# trailing slash is ok. The sed call is to remove the last '\|'.
|
||||
# trailing slash is ok. The sed call is to remove the last '|'.
|
||||
set -l tmp (printf "%s" \^$PATH'/?$|')
|
||||
set -l path_regexp \((echo $tmp | sed -e "s/.\$//")\)
|
||||
|
||||
|
||||
set -l path_regexp \\\((printf "%s" \^$PATH'\(\|/\)$\|' | sed -e "s/..\$//")\\\)
|
||||
|
||||
for i in (printf "%s\n" $path_list|grep -v $path_regexp)
|
||||
for i in (printf "%s\n" $path_list|grep -E -v $path_regexp)
|
||||
if test -d $i
|
||||
set PATH $PATH $i
|
||||
end
|
||||
@@ -96,7 +108,7 @@ end
|
||||
# Completions for the shell and it's builtin commands and functions
|
||||
#
|
||||
|
||||
for i in (builtin -n|grep -v '\(while\|for\|if\|function\|switch\)' )
|
||||
for i in (builtin -n|grep -E -v '(while|for|if|function|switch)' )
|
||||
complete -c $i -s h -l help -d "Display help and exit"
|
||||
end
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
function __fish_complete_ls -d "Compleletions for ls and it's aliases"
|
||||
|
||||
set -l is_gnu
|
||||
ls --version >/dev/null ^/dev/null; and set is_gnu --is-gnu
|
||||
command ls --version >/dev/null ^/dev/null; and set is_gnu --is-gnu
|
||||
|
||||
set -l cmds -c $argv
|
||||
|
||||
|
||||
@@ -18,6 +18,12 @@ function help -d (N_ "Show help for the fish shell")
|
||||
set h $h expand-variable expand-home expand-brace expand-wildcard
|
||||
set -l help_topics $h expand-command-substitution expand-process
|
||||
|
||||
# 'help -h' should launch 'help help'
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
set argv help
|
||||
end
|
||||
|
||||
#
|
||||
# Find a suitable browser for viewing the help pages. This is needed
|
||||
# by the help function defined below.
|
||||
@@ -92,6 +98,16 @@ function help -d (N_ "Show help for the fish shell")
|
||||
end
|
||||
|
||||
if test $fish_browser_bg
|
||||
|
||||
switch $fish_browser
|
||||
case 'htmlview' 'x-www-browser'
|
||||
printf (_ 'help: Help is being displayed in your default browser\n')
|
||||
|
||||
case '*'
|
||||
printf (_ 'help: Help is being displayed in %s\n') $fish_browser
|
||||
|
||||
end
|
||||
|
||||
eval $fish_browser file://$__fish_help_dir/$fish_help_page \&
|
||||
else
|
||||
eval $fish_browser file://$__fish_help_dir/$fish_help_page
|
||||
|
||||
@@ -50,7 +50,7 @@ if command ls --version 1>/dev/null 2>/dev/null
|
||||
|
||||
else
|
||||
# BSD, OS X and a few more support colors through the -G switch instead
|
||||
if ls / -G 1>/dev/null 2>/dev/null
|
||||
if command ls / -G 1>/dev/null 2>/dev/null
|
||||
function ls -d (N_ "List contents of directory")
|
||||
command ls -G $argv
|
||||
end
|
||||
|
||||
8
signal.c
8
signal.c
@@ -15,6 +15,10 @@ The library for various signal related issues
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_SIGINFO_H
|
||||
#include <siginfo.h>
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
@@ -24,7 +28,7 @@ The library for various signal related issues
|
||||
#include "event.h"
|
||||
#include "reader.h"
|
||||
#include "proc.h"
|
||||
#include "translate.h"
|
||||
|
||||
|
||||
/**
|
||||
Struct describing an entry for the lookup table used to convert
|
||||
@@ -281,7 +285,7 @@ const static struct lookup_entry lookup[] =
|
||||
}
|
||||
,
|
||||
#endif
|
||||
#ifdef SIGWIO
|
||||
#ifdef SIGIO
|
||||
{
|
||||
SIGIO,
|
||||
L"SIGIO",
|
||||
|
||||
@@ -127,15 +127,3 @@ else
|
||||
end
|
||||
|
||||
|
||||
# Test universal variable erasing
|
||||
|
||||
set -e foo
|
||||
../fish -c "set -U foo bar"
|
||||
|
||||
if set -q foo
|
||||
echo Test 11 pass
|
||||
else
|
||||
echo Test 11 fail
|
||||
end
|
||||
|
||||
set -eU foo
|
||||
@@ -8,4 +8,3 @@ Test 7 pass
|
||||
Test 8 pass
|
||||
Test 9 pass
|
||||
Test 10 pass
|
||||
Test 11 pass
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "tokenizer.h"
|
||||
#include "common.h"
|
||||
#include "wildcard.h"
|
||||
#include "translate.h"
|
||||
|
||||
|
||||
/**
|
||||
Error string for unexpected end of string
|
||||
|
||||
144
translate.c
144
translate.c
@@ -1,144 +0,0 @@
|
||||
/** \file translate.c
|
||||
|
||||
Translation library, internally uses catgets
|
||||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#if HAVE_LIBINTL_H
|
||||
#include <libintl.h>
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "halloc_util.h"
|
||||
|
||||
#if HAVE_GETTEXT
|
||||
|
||||
/**
|
||||
Number of string_buffer_t in the ring of buffers
|
||||
*/
|
||||
#define BUFF_COUNT 64
|
||||
|
||||
/**
|
||||
The ring of string_buffer_t
|
||||
*/
|
||||
static string_buffer_t buff[BUFF_COUNT];
|
||||
/**
|
||||
Current position in the ring
|
||||
*/
|
||||
static int curr_buff=0;
|
||||
|
||||
/**
|
||||
Buffer used by translate_wcs2str
|
||||
*/
|
||||
static char *wcs2str_buff=0;
|
||||
/**
|
||||
Size of buffer used by translate_wcs2str
|
||||
*/
|
||||
static size_t wcs2str_buff_count=0;
|
||||
|
||||
/**
|
||||
Flag to tell whether the translation library has been initialized
|
||||
*/
|
||||
static int is_init = 0;
|
||||
|
||||
/**
|
||||
Internal shutdown function. Automatically called on shutdown if the library has been initialized.
|
||||
*/
|
||||
static void internal_destroy()
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !is_init )
|
||||
return;
|
||||
|
||||
is_init = 0;
|
||||
|
||||
for(i=0; i<BUFF_COUNT; i++ )
|
||||
sb_destroy( &buff[i] );
|
||||
|
||||
free( wcs2str_buff );
|
||||
}
|
||||
|
||||
/**
|
||||
Internal init function. Automatically called when a translation is first requested.
|
||||
*/
|
||||
static void internal_init()
|
||||
{
|
||||
int i;
|
||||
|
||||
is_init = 1;
|
||||
|
||||
for(i=0; i<BUFF_COUNT; i++ )
|
||||
{
|
||||
sb_init( &buff[i] );
|
||||
}
|
||||
halloc_register_function_void( global_context, &internal_destroy );
|
||||
|
||||
bindtextdomain( PACKAGE_NAME, LOCALEDIR );
|
||||
textdomain( PACKAGE_NAME );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Wide to narrow character conversion. Internal implementation that
|
||||
avoids exessive calls to malloc
|
||||
*/
|
||||
static char *translate_wcs2str( const wchar_t *in )
|
||||
{
|
||||
size_t len = MAX_UTF8_BYTES*wcslen(in)+1;
|
||||
if( len > wcs2str_buff_count )
|
||||
{
|
||||
wcs2str_buff = realloc( wcs2str_buff, len );
|
||||
if( wcs2str_buff == 0 )
|
||||
{
|
||||
DIE_MEM();
|
||||
}
|
||||
}
|
||||
|
||||
wcstombs( wcs2str_buff,
|
||||
in,
|
||||
MAX_UTF8_BYTES*wcslen(in)+1 );
|
||||
|
||||
return wcs2str_buff;
|
||||
}
|
||||
|
||||
const wchar_t *wgettext( const wchar_t *in )
|
||||
{
|
||||
if( !in )
|
||||
return in;
|
||||
|
||||
if( !is_init )
|
||||
internal_init();
|
||||
|
||||
char *mbs_in = translate_wcs2str( in );
|
||||
char *out = gettext( mbs_in );
|
||||
wchar_t *wres=0;
|
||||
|
||||
sb_clear( &buff[curr_buff] );
|
||||
|
||||
sb_printf( &buff[curr_buff], L"%s", out );
|
||||
wres = (wchar_t *)buff[curr_buff].buff;
|
||||
curr_buff = (curr_buff+1)%BUFF_COUNT;
|
||||
|
||||
return wres;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
const wchar_t *wgettext( const wchar_t *in )
|
||||
{
|
||||
return in;
|
||||
}
|
||||
|
||||
#endif
|
||||
21
translate.h
21
translate.h
@@ -1,21 +0,0 @@
|
||||
/** \file translate.h
|
||||
|
||||
Translation library, internally uses catgets
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
Shorthand for wgettext call
|
||||
*/
|
||||
#define _(wstr) wgettext(wstr)
|
||||
|
||||
/**
|
||||
Noop, used to tell xgettext that a string should be translated, even though it is not directly sent to wgettext.
|
||||
*/
|
||||
#define N_(wstr) wstr
|
||||
|
||||
/**
|
||||
Wide character wwrapper around the gettext function
|
||||
*/
|
||||
const wchar_t *wgettext( const wchar_t *in );
|
||||
|
||||
156
util.c
156
util.c
@@ -50,18 +50,6 @@
|
||||
*/
|
||||
#define SB_MAX_SIZE 32767
|
||||
|
||||
float minf( float a,
|
||||
float b )
|
||||
{
|
||||
return a<b?a:b;
|
||||
}
|
||||
|
||||
|
||||
float maxf( float a,
|
||||
float b )
|
||||
{
|
||||
return a>b?a:b;
|
||||
}
|
||||
|
||||
int mini( int a,
|
||||
int b )
|
||||
@@ -310,9 +298,14 @@ void *hash_get( hash_table_t *h,
|
||||
|
||||
int pos = hash_search( h, (void *)key );
|
||||
if( h->arr[pos].key == 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return h->arr[pos].data;
|
||||
{
|
||||
void *res =h->arr[pos].data;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
void *hash_get_key( hash_table_t *h,
|
||||
@@ -480,9 +473,9 @@ int hash_str_cmp( void *a, void *b )
|
||||
/**
|
||||
Helper function for hash_wcs_func
|
||||
*/
|
||||
static uint rotl5( uint in )
|
||||
static unsigned long rotl5( unsigned long in )
|
||||
{
|
||||
return (in<<5|in>>27);
|
||||
return ((in<<5|in>>27))&0xffffffff;
|
||||
}
|
||||
|
||||
|
||||
@@ -680,21 +673,43 @@ void al_destroy( array_list_t *l )
|
||||
free( l->arr );
|
||||
}
|
||||
|
||||
int al_push( array_list_t *l, const void *o )
|
||||
static int al_push_generic( array_list_t *l, anything_t o )
|
||||
{
|
||||
if( l->pos >= l->size )
|
||||
{
|
||||
int new_size = l->pos == 0 ? MIN_SIZE : 2 * l->pos;
|
||||
void *tmp = realloc( l->arr, sizeof( void *)*new_size );
|
||||
void *tmp = realloc( l->arr, sizeof( anything_t )*new_size );
|
||||
if( tmp == 0 )
|
||||
return 0;
|
||||
l->arr = tmp;
|
||||
l->size = new_size;
|
||||
}
|
||||
l->arr[l->pos++] = (void *)o;
|
||||
l->arr[l->pos++] = o;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int al_push( array_list_t *l, const void *o )
|
||||
{
|
||||
anything_t v;
|
||||
v.ptr_val = (void *)o;
|
||||
return al_push_generic( l, v );
|
||||
}
|
||||
|
||||
int al_push_long( array_list_t *l, long val )
|
||||
{
|
||||
anything_t v;
|
||||
v.long_val = val;
|
||||
return al_push_generic( l, v );
|
||||
}
|
||||
|
||||
int al_push_func( array_list_t *l, func_ptr_t f )
|
||||
{
|
||||
anything_t v;
|
||||
v.func_val = f;
|
||||
return al_push_generic( l, v );
|
||||
}
|
||||
|
||||
|
||||
int al_push_all( array_list_t *a, array_list_t *b )
|
||||
{
|
||||
int k;
|
||||
@@ -707,7 +722,7 @@ int al_push_all( array_list_t *a, array_list_t *b )
|
||||
}
|
||||
|
||||
|
||||
int al_set( array_list_t *l, int pos, const void *o )
|
||||
static int al_set_generic( array_list_t *l, int pos, anything_t v )
|
||||
{
|
||||
int old_pos;
|
||||
|
||||
@@ -715,48 +730,88 @@ int al_set( array_list_t *l, int pos, const void *o )
|
||||
return 0;
|
||||
if( pos < l->pos )
|
||||
{
|
||||
l->arr[pos] = (void *)o;
|
||||
l->arr[pos]=v;
|
||||
return 1;
|
||||
}
|
||||
old_pos=l->pos;
|
||||
|
||||
l->pos = pos;
|
||||
if( al_push( l, o ) )
|
||||
if( al_push_generic( l, v ) )
|
||||
{
|
||||
/* fwprintf( stderr, L"Clearing from index %d to index %d\n",
|
||||
old_pos, pos );
|
||||
*/
|
||||
memset( &l->arr[old_pos],
|
||||
0,
|
||||
sizeof(void *) * (pos - old_pos) );
|
||||
sizeof(anything_t) * (pos - old_pos) );
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int al_set( array_list_t *l, int pos, const void *o )
|
||||
{
|
||||
anything_t v;
|
||||
v.ptr_val = (void *)o;
|
||||
return al_set_generic( l, pos, v );
|
||||
}
|
||||
|
||||
int al_set_long( array_list_t *l, int pos, long o )
|
||||
{
|
||||
anything_t v;
|
||||
v.long_val = o;
|
||||
return al_set_generic( l, pos, v );
|
||||
}
|
||||
|
||||
int al_set_func( array_list_t *l, int pos, func_ptr_t o )
|
||||
{
|
||||
anything_t v;
|
||||
v.func_val = o;
|
||||
return al_set_generic( l, pos, v );
|
||||
}
|
||||
|
||||
static anything_t al_get_generic( array_list_t *l, int pos )
|
||||
{
|
||||
anything_t res;
|
||||
res.ptr_val=0;
|
||||
|
||||
if( (pos >= 0) && (pos < l->pos) )
|
||||
res = l->arr[pos];
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void *al_get( array_list_t *l, int pos )
|
||||
{
|
||||
if( pos < 0 )
|
||||
return 0;
|
||||
if( pos >= l->pos )
|
||||
return 0;
|
||||
return l->arr[pos];
|
||||
return al_get_generic(l,pos).ptr_val;
|
||||
}
|
||||
|
||||
long al_get_long( array_list_t *l, int pos )
|
||||
{
|
||||
return al_get_generic(l,pos).long_val;
|
||||
}
|
||||
|
||||
func_ptr_t al_get_func( array_list_t *l, int pos )
|
||||
{
|
||||
return al_get_generic(l,pos).func_val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void al_truncate( array_list_t *l, int new_sz )
|
||||
{
|
||||
l->pos = new_sz;
|
||||
}
|
||||
|
||||
void *al_pop( array_list_t *l )
|
||||
static anything_t al_pop_generic( array_list_t *l )
|
||||
{
|
||||
void *e = l->arr[--l->pos];
|
||||
anything_t e = l->arr[--l->pos];
|
||||
if( (l->pos*3 < l->size) && (l->size < MIN_SIZE) )
|
||||
{
|
||||
void ** old_arr = l->arr;
|
||||
anything_t *old_arr = l->arr;
|
||||
int old_size = l->size;
|
||||
l->size = l->size/2;
|
||||
l->arr = realloc( l->arr, sizeof(void*)*l->size );
|
||||
l->arr = realloc( l->arr, sizeof(anything_t)*l->size );
|
||||
if( l->arr == 0 )
|
||||
{
|
||||
l->arr = old_arr;
|
||||
@@ -766,10 +821,43 @@ void *al_pop( array_list_t *l )
|
||||
return e;
|
||||
}
|
||||
|
||||
void *al_pop( array_list_t *l )
|
||||
{
|
||||
return al_pop_generic(l).ptr_val;
|
||||
}
|
||||
|
||||
long al_pop_long( array_list_t *l )
|
||||
{
|
||||
return al_pop_generic(l).long_val;
|
||||
}
|
||||
|
||||
func_ptr_t al_pop_func( array_list_t *l )
|
||||
{
|
||||
return al_pop_generic(l).func_val;
|
||||
}
|
||||
|
||||
static anything_t al_peek_generic( array_list_t *l )
|
||||
{
|
||||
anything_t res;
|
||||
res.ptr_val=0;
|
||||
if( l->pos>0)
|
||||
res = l->arr[l->pos-1];
|
||||
return res;
|
||||
}
|
||||
|
||||
void *al_peek( array_list_t *l )
|
||||
{
|
||||
return al_peek_generic(l).ptr_val;
|
||||
}
|
||||
|
||||
return l->pos>0?l->arr[l->pos-1]:0;
|
||||
long al_peek_long( array_list_t *l )
|
||||
{
|
||||
return al_peek_generic(l).long_val;
|
||||
}
|
||||
|
||||
func_ptr_t al_peek_func( array_list_t *l )
|
||||
{
|
||||
return al_peek_generic(l).func_val;
|
||||
}
|
||||
|
||||
int al_empty( array_list_t *l )
|
||||
@@ -787,14 +875,14 @@ void al_foreach( array_list_t *l, void (*func)( void * ))
|
||||
{
|
||||
int i;
|
||||
for( i=0; i<l->pos; i++ )
|
||||
func( l->arr[i] );
|
||||
func( l->arr[i].ptr_val );
|
||||
}
|
||||
|
||||
void al_foreach2( array_list_t *l, void (*func)( void *, void *), void *aux)
|
||||
{
|
||||
int i;
|
||||
for( i=0; i<l->pos; i++ )
|
||||
func( l->arr[i], aux );
|
||||
func( l->arr[i].ptr_val, aux );
|
||||
}
|
||||
|
||||
int wcsfilecmp( const wchar_t *a, const wchar_t *b )
|
||||
|
||||
98
util.h
98
util.h
@@ -15,6 +15,17 @@
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
|
||||
typedef void (*func_ptr_t)();
|
||||
|
||||
typedef union
|
||||
{
|
||||
long long_val;
|
||||
void *ptr_val;
|
||||
func_ptr_t func_val;
|
||||
}
|
||||
anything_t;
|
||||
|
||||
|
||||
/**
|
||||
Data structure for an automatically resizing dynamically allocated queue,
|
||||
*/
|
||||
@@ -29,7 +40,7 @@ typedef struct dyn_queue
|
||||
/** Where to remove elements */
|
||||
void **get_pos;
|
||||
}
|
||||
dyn_queue_t;
|
||||
dyn_queue_t;
|
||||
|
||||
/**
|
||||
Internal struct used by hash_table_t.
|
||||
@@ -41,7 +52,7 @@ typedef struct
|
||||
/** Value */
|
||||
void *data;
|
||||
}
|
||||
hash_struct_t;
|
||||
hash_struct_t;
|
||||
|
||||
/**
|
||||
Data structure for the hash table implementaion. A hash table allows for
|
||||
@@ -71,7 +82,7 @@ typedef struct hash_table
|
||||
/** Comparison function */
|
||||
int (*compare_func)( void *key1, void *key2 );
|
||||
}
|
||||
hash_table_t;
|
||||
hash_table_t;
|
||||
|
||||
/**
|
||||
Data structure for an automatically resizing dynamically allocated
|
||||
@@ -99,7 +110,7 @@ priority_queue_t;
|
||||
typedef struct array_list
|
||||
{
|
||||
/** Array containing the data */
|
||||
void **arr;
|
||||
anything_t *arr;
|
||||
/** Position to append elements at*/
|
||||
int pos;
|
||||
/** Length of array */
|
||||
@@ -149,16 +160,6 @@ int maxi( int a, int b );
|
||||
*/
|
||||
int mini( int a, int b );
|
||||
|
||||
/**
|
||||
Returns the larger of two floats
|
||||
*/
|
||||
float maxf( float a, float b );
|
||||
|
||||
/**
|
||||
Returns the smaller of two floats
|
||||
*/
|
||||
float minf( float a, float b );
|
||||
|
||||
/*
|
||||
All the datastuctures below autoresize. The queue, stack and
|
||||
priority queue are all impemented using an array and are guaranteed
|
||||
@@ -361,7 +362,8 @@ int pq_get_count( priority_queue_t *q );
|
||||
void pq_destroy( priority_queue_t *q );
|
||||
|
||||
/**
|
||||
Allocate heap memory for creating a new list and initialize it
|
||||
Allocate heap memory for creating a new list and initialize
|
||||
it. Equivalent to calling malloc and al_init.
|
||||
*/
|
||||
array_list_t *al_new();
|
||||
|
||||
@@ -384,6 +386,24 @@ void al_destroy( array_list_t *l );
|
||||
\return 1 if succesfull, 0 otherwise
|
||||
*/
|
||||
int al_push( array_list_t *l, const void *o );
|
||||
/**
|
||||
Append element to list
|
||||
|
||||
\param l The list
|
||||
\param o The element
|
||||
\return
|
||||
\return 1 if succesfull, 0 otherwise
|
||||
*/
|
||||
int al_push_long( array_list_t *l, long o );
|
||||
/**
|
||||
Append element to list
|
||||
|
||||
\param l The list
|
||||
\param o The element
|
||||
\return
|
||||
\return 1 if succesfull, 0 otherwise
|
||||
*/
|
||||
int al_push_func( array_list_t *l, void (*f)() );
|
||||
|
||||
/**
|
||||
Append all elements of a list to another
|
||||
@@ -402,6 +422,22 @@ int al_push_all( array_list_t *a, array_list_t *b );
|
||||
\param o The element
|
||||
*/
|
||||
int al_set( array_list_t *l, int pos, const void *o );
|
||||
/**
|
||||
Sets the element at the specified index
|
||||
|
||||
\param l The array_list_t
|
||||
\param pos The index
|
||||
\param o The element
|
||||
*/
|
||||
int al_set_long( array_list_t *l, int pos, long v );
|
||||
/**
|
||||
Sets the element at the specified index
|
||||
|
||||
\param l The array_list_t
|
||||
\param pos The index
|
||||
\param o The element
|
||||
*/
|
||||
int al_set_func( array_list_t *l, int pos, void (*f)() );
|
||||
|
||||
/**
|
||||
Returns the element at the specified index
|
||||
@@ -411,6 +447,22 @@ int al_set( array_list_t *l, int pos, const void *o );
|
||||
\return The element
|
||||
*/
|
||||
void *al_get( array_list_t *l, int pos );
|
||||
/**
|
||||
Returns the element at the specified index
|
||||
|
||||
\param l The array_list_t
|
||||
\param pos The index
|
||||
\return The element
|
||||
*/
|
||||
long al_get_long( array_list_t *l, int pos );
|
||||
/**
|
||||
Returns the element at the specified index
|
||||
|
||||
\param l The array_list_t
|
||||
\param pos The index
|
||||
\return The element
|
||||
*/
|
||||
func_ptr_t al_get_func( array_list_t *l, int pos );
|
||||
|
||||
/**
|
||||
Truncates the list to new_sz items.
|
||||
@@ -421,6 +473,14 @@ void al_truncate( array_list_t *l, int new_sz );
|
||||
Removes and returns the last entry in the list
|
||||
*/
|
||||
void *al_pop( array_list_t *l );
|
||||
/**
|
||||
Removes and returns the last entry in the list
|
||||
*/
|
||||
long al_pop_long( array_list_t *l );
|
||||
/**
|
||||
Removes and returns the last entry in the list
|
||||
*/
|
||||
func_ptr_t al_pop_func( array_list_t *l );
|
||||
|
||||
/**
|
||||
Returns the number of elements in the list
|
||||
@@ -431,6 +491,14 @@ int al_get_count( array_list_t *l );
|
||||
Returns the last entry in the list witout removing it.
|
||||
*/
|
||||
void *al_peek( array_list_t *l );
|
||||
/**
|
||||
Returns the last entry in the list witout removing it.
|
||||
*/
|
||||
long al_peek_long( array_list_t *l );
|
||||
/**
|
||||
Returns the last entry in the list witout removing it.
|
||||
*/
|
||||
func_ptr_t al_peek_func( array_list_t *l );
|
||||
|
||||
/**
|
||||
Returns 1 if the list is empty, 0 otherwise
|
||||
|
||||
@@ -180,7 +180,7 @@ static char *posixly_correct;
|
||||
Use translation functions if available
|
||||
*/
|
||||
#ifdef HAVE_TRANSLATE_H
|
||||
#include "translate.h"
|
||||
|
||||
#define _(wstr) wgettext(wstr)
|
||||
#else
|
||||
#define _(wstr) wstr
|
||||
|
||||
@@ -29,7 +29,7 @@ wildcards using **.
|
||||
#include "complete.h"
|
||||
#include "reader.h"
|
||||
#include "expand.h"
|
||||
#include "translate.h"
|
||||
|
||||
|
||||
/**
|
||||
This flag is set in the flags parameter of wildcard_expand if the
|
||||
@@ -395,7 +395,7 @@ static int test_flags( wchar_t *filename,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( S_IFDIR & buf.st_mode )
|
||||
if( S_ISDIR( buf.st_mode ) )
|
||||
return 1;
|
||||
|
||||
if( flags & EXECUTABLES_ONLY )
|
||||
@@ -684,7 +684,7 @@ int wildcard_expand( const wchar_t *wc,
|
||||
|
||||
if( !stat_res )
|
||||
{
|
||||
if( buf.st_mode & S_IFDIR )
|
||||
if( S_ISDIR(buf.st_mode) )
|
||||
{
|
||||
new_len = wcslen( new_dir );
|
||||
new_dir[new_len] = L'/';
|
||||
|
||||
149
wutil.c
149
wutil.c
@@ -9,7 +9,6 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <wchar.h>
|
||||
@@ -20,6 +19,9 @@
|
||||
#include <limits.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#if HAVE_LIBINTL_H
|
||||
#include <libintl.h>
|
||||
#endif
|
||||
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
@@ -50,12 +52,14 @@
|
||||
the \c wutil_wcs2str() function.
|
||||
*/
|
||||
static char *tmp=0;
|
||||
|
||||
/**
|
||||
Buffer for converting narrow results to wide ones, used by the \c
|
||||
wutil_str2wcs() function. Avoid usign this without thinking about
|
||||
it, since sebseuent calls will overwrite previous values.
|
||||
it, since subsequent calls will overwrite previous values.
|
||||
*/
|
||||
static wchar_t *tmp2;
|
||||
|
||||
/**
|
||||
Length of the \c tmp buffer.
|
||||
*/
|
||||
@@ -76,6 +80,38 @@ static int wutil_calls = 0;
|
||||
*/
|
||||
static struct wdirent my_wdirent;
|
||||
|
||||
|
||||
/**
|
||||
For wgettext: Number of string_buffer_t in the ring of buffers
|
||||
*/
|
||||
#define BUFF_COUNT 64
|
||||
|
||||
/**
|
||||
For wgettext: The ring of string_buffer_t
|
||||
*/
|
||||
static string_buffer_t buff[BUFF_COUNT];
|
||||
/**
|
||||
For wgettext: Current position in the ring
|
||||
*/
|
||||
static int curr_buff=0;
|
||||
|
||||
/**
|
||||
For wgettext: Buffer used by translate_wcs2str
|
||||
*/
|
||||
static char *wcs2str_buff=0;
|
||||
/**
|
||||
For wgettext: Size of buffer used by translate_wcs2str
|
||||
*/
|
||||
static size_t wcs2str_buff_count=0;
|
||||
|
||||
/**
|
||||
For wgettext: Flag to tell whether the translation library has been initialized
|
||||
*/
|
||||
static int wgettext_is_init = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
void wutil_init()
|
||||
{
|
||||
}
|
||||
@@ -343,9 +379,9 @@ wchar_t *wrealpath(const wchar_t *pathname, wchar_t *resolved_path)
|
||||
|
||||
wchar_t *wrealpath(const wchar_t *pathname, wchar_t *resolved_path)
|
||||
{
|
||||
char *tmp =wutil_wcs2str(pathname);
|
||||
char narrow[PATH_MAX];
|
||||
char *narrow_res = realpath( tmp, narrow );
|
||||
char *tmp = wutil_wcs2str(pathname);
|
||||
char narrow_buff[PATH_MAX];
|
||||
char *narrow_res = realpath( tmp, narrow_buff );
|
||||
wchar_t *res;
|
||||
|
||||
if( !narrow_res )
|
||||
@@ -404,3 +440,106 @@ wchar_t *wbasename( const wchar_t *path )
|
||||
|
||||
|
||||
|
||||
/**
|
||||
For wgettext: Internal shutdown function. Automatically called on shutdown if the library has been initialized.
|
||||
*/
|
||||
static void wgettext_destroy()
|
||||
{
|
||||
int i;
|
||||
|
||||
if( !wgettext_is_init )
|
||||
return;
|
||||
|
||||
wgettext_is_init = 0;
|
||||
|
||||
for(i=0; i<BUFF_COUNT; i++ )
|
||||
sb_destroy( &buff[i] );
|
||||
|
||||
free( wcs2str_buff );
|
||||
}
|
||||
|
||||
/**
|
||||
For wgettext: Internal init function. Automatically called when a translation is first requested.
|
||||
*/
|
||||
static void wgettext_init()
|
||||
{
|
||||
int i;
|
||||
|
||||
wgettext_is_init = 1;
|
||||
|
||||
for( i=0; i<BUFF_COUNT; i++ )
|
||||
{
|
||||
sb_init( &buff[i] );
|
||||
}
|
||||
|
||||
halloc_register_function_void( global_context, &wgettext_destroy );
|
||||
|
||||
bindtextdomain( PACKAGE_NAME, LOCALEDIR );
|
||||
textdomain( PACKAGE_NAME );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
For wgettext: Wide to narrow character conversion. Internal implementation that
|
||||
avoids exessive calls to malloc
|
||||
*/
|
||||
static char *wgettext_wcs2str( const wchar_t *in )
|
||||
{
|
||||
size_t len = MAX_UTF8_BYTES*wcslen(in)+1;
|
||||
if( len > wcs2str_buff_count )
|
||||
{
|
||||
wcs2str_buff = realloc( wcs2str_buff, len );
|
||||
if( !wcs2str_buff )
|
||||
{
|
||||
DIE_MEM();
|
||||
}
|
||||
}
|
||||
|
||||
return wcs2str_internal( in, wcs2str_buff);
|
||||
}
|
||||
|
||||
const wchar_t *wgettext( const wchar_t *in )
|
||||
{
|
||||
if( !in )
|
||||
return in;
|
||||
|
||||
if( !wgettext_is_init )
|
||||
wgettext_init();
|
||||
|
||||
char *mbs_in = wgettext_wcs2str( in );
|
||||
char *out = gettext( mbs_in );
|
||||
wchar_t *wres=0;
|
||||
|
||||
sb_clear( &buff[curr_buff] );
|
||||
|
||||
sb_printf( &buff[curr_buff], L"%s", out );
|
||||
wres = (wchar_t *)buff[curr_buff].buff;
|
||||
curr_buff = (curr_buff+1)%BUFF_COUNT;
|
||||
|
||||
return wres;
|
||||
}
|
||||
|
||||
wchar_t *wgetenv( const wchar_t *name )
|
||||
{
|
||||
char *name_narrow =wutil_wcs2str(name);
|
||||
char *res_narrow = getenv( name_narrow );
|
||||
static string_buffer_t *out = 0;
|
||||
|
||||
if( !res_narrow )
|
||||
return 0;
|
||||
|
||||
if( !out )
|
||||
{
|
||||
out = sb_halloc( global_context );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_clear( out );
|
||||
}
|
||||
|
||||
sb_printf( out, L"%s", res_narrow );
|
||||
|
||||
return (wchar_t *)out->buff;
|
||||
|
||||
}
|
||||
|
||||
|
||||
15
wutil.h
15
wutil.h
@@ -118,5 +118,20 @@ wchar_t *wdirname( const wchar_t *path );
|
||||
*/
|
||||
wchar_t *wbasename( const wchar_t *path );
|
||||
|
||||
/**
|
||||
Wide character wrapper around the gettext function. For historic
|
||||
reasons, unlike the real gettext function, wgettext takes care of
|
||||
setting the correct domain, etc. using the textdomain and
|
||||
bindtextdomain functions. This should probably be moved out of
|
||||
wgettext, so that wgettext will be nothing more than a wrapper
|
||||
around gettext, like all other functions in this file.
|
||||
*/
|
||||
const wchar_t *wgettext( const wchar_t *in );
|
||||
|
||||
/**
|
||||
Wide character version of getenv
|
||||
*/
|
||||
wchar_t *wgetenv( const wchar_t *name );
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user