Merge branch 'master' into iwyu

This commit is contained in:
David Adam 2015-07-26 10:20:13 +08:00
commit 3929e9de0e
113 changed files with 734 additions and 762 deletions

1
.gitignore vendored
View file

@ -39,4 +39,5 @@ messages.pot
lexicon.txt
lexicon_filter
lexicon.log
DerivedData/

View file

@ -54,7 +54,7 @@ localedir = @localedir@
#
MACROS = -DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\" -DBINDIR=L\"$(bindir)\" -DDOCDIR=L\"$(docdir)\"
CXXFLAGS = @CXXFLAGS@ $(MACROS) $(EXTRA_CXXFLAGS)
CXXFLAGS = @CXXFLAGS@ -iquote. -iquote./src/ $(MACROS) $(EXTRA_CXXFLAGS)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
@ -72,43 +72,46 @@ HAVE_GETTEXT=@HAVE_GETTEXT@
HAVE_DOXYGEN=@HAVE_DOXYGEN@
#
#Additional .cpp files used by common.o. These also have a corresponding
#.h file.
#
COMMON_FILES := util.cpp fallback.cpp
#
# All objects that the system needs to build fish, except fish.o
#
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_common.o input_common.o event.o \
signal.o io.o parse_util.o common.o screen.o path.o autoload.o \
parser_keywords.o iothread.o color.o postfork.o \
builtin_test.o parse_tree.o parse_productions.o parse_execution.o \
pager.o utf8.o fish_version.o wcstringutil.o
FISH_OBJS := obj/function.o obj/builtin.o obj/complete.o obj/env.o obj/exec.o \
obj/expand.o obj/highlight.o obj/history.o obj/kill.o obj/parser.o \
obj/proc.o obj/reader.o obj/sanity.o obj/tokenizer.o obj/wildcard.o \
obj/wgetopt.o obj/wutil.o obj/input.o obj/output.o obj/intern.o \
obj/env_universal_common.o obj/input_common.o obj/event.o obj/signal.o \
obj/io.o obj/parse_util.o obj/common.o obj/screen.o obj/path.o \
obj/autoload.o obj/parser_keywords.o obj/iothread.o obj/color.o \
obj/postfork.o obj/builtin_test.o obj/parse_tree.o obj/parse_productions.o \
obj/parse_execution.o obj/pager.o obj/utf8.o obj/fish_version.o \
obj/wcstringutil.o
FISH_INDENT_OBJS := fish_indent.o print_help.o $(FISH_OBJS)
FISH_INDENT_OBJS := obj/fish_indent.o obj/print_help.o $(FISH_OBJS)
#
# Additional files used by builtin.o
#
BUILTIN_FILES := builtin_set.cpp builtin_commandline.cpp \
builtin_ulimit.cpp builtin_complete.cpp builtin_jobs.cpp \
builtin_set_color.cpp builtin_printf.cpp
BUILTIN_FILES := src/builtin_set.cpp src/builtin_commandline.cpp \
src/builtin_ulimit.cpp src/builtin_complete.cpp \
src/builtin_jobs.cpp src/builtin_set_color.cpp \
src/builtin_printf.cpp
#
# All objects that the system needs to build fish_tests
#
FISH_TESTS_OBJS := $(FISH_OBJS) fish_tests.o
FISH_TESTS_OBJS := $(FISH_OBJS) obj/fish_tests.o
#
# All of the sources that produce object files
# (that is, are not themselves #included in other source files)
#
FISH_ALL_OBJS := $(sort $(FISH_OBJS) $(FISH_INDENT_OBJS) $(FISH_TESTS_OBJS) \
obj/fish.o obj/key_reader.o)
#
@ -218,7 +221,7 @@ all: $(PROGRAMS) $(user_doc) $(share_man) $(TRANSLATIONS) fish.pc
FISH-BUILD-VERSION-FILE: FORCE
@./build_tools/git_version_gen.sh
-include FISH-BUILD-VERSION-FILE
CPPFLAGS += -DFISH_BUILD_VERSION=\"$(FISH_BUILD_VERSION)\"
CXXFLAGS += -DFISH_BUILD_VERSION=\"$(FISH_BUILD_VERSION)\"
.PHONY: FORCE
fish_version.o: FISH-BUILD-VERSION-FILE
@ -263,7 +266,7 @@ user_doc: $(HDR_FILES_SRC) Doxyfile.user $(HTML_SRC) $(HELP_SRC) doc.h $(HDR_FIL
# Source code documentation. Also includes user documentation.
#
doc: *.h *.cpp doc.h Doxyfile lexicon_filter
doc: src/*.h src/*.cpp doc.h Doxyfile lexicon_filter
(cat Doxyfile; echo INPUT_FILTER=./lexicon_filter; echo PROJECT_NUMBER=$(FISH_BUILD_VERSION)) | doxygen - ;
@ -465,14 +468,12 @@ doc.h: $(HDR_FILES)
# Create a template translation object
#
messages.pot: *.cpp *.h share/completions/*.fish share/functions/*.fish
xgettext -k_ -kN_ *.cpp *.h -o messages.pot
messages.pot: src/*.cpp src/*.h share/completions/*.fish share/functions/*.fish
xgettext -k_ -kN_ src/*.cpp src/*.h -o messages.pot
xgettext -j -k_ -kN_ -k--description -LShell --from-code=UTF-8 share/completions/*.fish share/functions/*.fish -o messages.pot
builtin.o: $(BUILTIN_FILES)
common.o: $(COMMON_FILES)
#
# Generate the internal help functions by making doxygen create
@ -761,12 +762,24 @@ uninstall-translations:
# The build rules for all the commands
#
#
# How basic files get compiled
#
obj/%.o: src/%.cpp | obj
$(CXX) $(CXXFLAGS) -c $< -o $@
#
# obj directory
#
obj:
mkdir obj
#
# Build the fish program.
#
fish: $(FISH_OBJS) fish.o
$(CXX) $(CXXFLAGS) $(LDFLAGS_FISH) $(FISH_OBJS) fish.o $(LIBS) -o $@
fish: $(FISH_OBJS) obj/fish.o
$(CXX) $(CXXFLAGS) $(LDFLAGS_FISH) $(FISH_OBJS) obj/fish.o $(LIBS) -o $@
#
@ -795,12 +808,27 @@ key_reader: $(FISH_OBJS) key_reader.o
#
# Update dependencies
# Unfortunately makedepend cannot handle source files in one directory
# and object files in another. So we have to cons up a fake directory
# tree and run it there. Note that some .cpp files do not result in
# objects because they are #include'd directly. In that case we need to
# leave them in the 'header' directory, so they get picked up by the
# dependencies. So we put everything in the header directory and move out
# exactly the files that result in objects, leaving the #include'd files
# behind.
#
depend:
makedepend -fMakefile.in -Y *.cpp
mkdir -p /tmp/fish_make_depend/src
cp src/*.cpp src/*.h /tmp/fish_make_depend/src
cp config.h /tmp/fish_make_depend/
mv $(subst obj/,/tmp/fish_make_depend/src/,$(FISH_ALL_OBJS:.o=.cpp)) /tmp/fish_make_depend/
cd /tmp/fish_make_depend && \
makedepend -f$(CURDIR)/Makefile.in -pobj/ -Y -Isrc *.cpp
rm -Rf /tmp/fish_make_depend
./config.status
.PHONY: depend
#
# Cleanup targets
#
@ -824,7 +852,7 @@ distclean: clean
# deleted we won't be able to regenerate them
clean:
rm -f *.o doc.h doc.tmp doc_src/*.doxygen doc_src/*.cpp doc_src/*.o doc_src/commands.hdr
rm -f obj/*.o *.o doc.h doc.tmp doc_src/*.doxygen doc_src/*.cpp doc_src/*.o doc_src/commands.hdr
rm -f tests/tmp.err tests/tmp.out tests/tmp.status tests/foo.txt
rm -f $(PROGRAMS) fish_tests key_reader
rm -f command_list.txt command_list_toc.txt toc.txt
@ -835,151 +863,191 @@ clean:
rm -rf doc user_doc share/man; \
fi
rm -f po/*.gmo
rm -rf obj
.PHONY: clean
# DO NOT DELETE THIS LINE -- make depend depends on it.
autoload.o: config.h autoload.h common.h fallback.h lru.h wutil.h signal.h
autoload.o: env.h exec.h
builtin.o: config.h signal.h fallback.h wutil.h common.h builtin.h io.h
builtin.o: function.h event.h env.h complete.h proc.h parse_tree.h
builtin.o: tokenizer.h parse_constants.h parser.h reader.h highlight.h
builtin.o: color.h wgetopt.h input.h input_common.h intern.h exec.h
builtin.o: parse_util.h parser_keywords.h expand.h path.h history.h
builtin.o: wcstringutil.h builtin_set.cpp util.h builtin_commandline.cpp
builtin.o: builtin_complete.cpp builtin_ulimit.cpp builtin_jobs.cpp
builtin.o: builtin_set_color.cpp output.h builtin_printf.cpp
builtin_commandline.o: config.h signal.h fallback.h util.h wutil.h common.h
builtin_commandline.o: builtin.h io.h wgetopt.h reader.h complete.h
builtin_commandline.o: highlight.h env.h color.h parse_constants.h proc.h
builtin_commandline.o: parse_tree.h tokenizer.h parser.h event.h
builtin_commandline.o: input_common.h input.h parse_util.h
builtin_complete.o: config.h signal.h fallback.h util.h wutil.h common.h
builtin_complete.o: builtin.h io.h complete.h wgetopt.h parser.h proc.h
builtin_complete.o: parse_tree.h tokenizer.h parse_constants.h event.h
builtin_complete.o: reader.h highlight.h env.h color.h
builtin_jobs.o: config.h fallback.h util.h wutil.h common.h builtin.h io.h
builtin_jobs.o: proc.h signal.h parse_tree.h tokenizer.h parse_constants.h
builtin_jobs.o: parser.h event.h wgetopt.h
builtin_printf.o: common.h config.h fallback.h
builtin_set.o: config.h signal.h fallback.h util.h wutil.h common.h builtin.h
builtin_set.o: io.h env.h expand.h parse_constants.h wgetopt.h proc.h
builtin_set.o: parse_tree.h tokenizer.h parser.h event.h
builtin_set_color.o: config.h builtin.h io.h common.h fallback.h color.h
builtin_set_color.o: output.h
builtin_test.o: config.h common.h fallback.h builtin.h io.h wutil.h proc.h
builtin_test.o: signal.h parse_tree.h tokenizer.h parse_constants.h
builtin_ulimit.o: config.h fallback.h util.h builtin.h io.h common.h
builtin_ulimit.o: wgetopt.h
color.o: color.h common.h config.h fallback.h
common.o: config.h signal.h fallback.h wutil.h common.h expand.h
common.o: parse_constants.h wildcard.h complete.h util.cpp util.h
common.o: fallback.cpp
complete.o: config.h fallback.h util.h wildcard.h common.h expand.h
complete.o: parse_constants.h complete.h proc.h signal.h io.h parse_tree.h
complete.o: tokenizer.h parser.h event.h function.h env.h builtin.h exec.h
complete.o: parse_util.h wutil.h path.h iothread.h autoload.h lru.h
env.o: config.h fallback.h wutil.h common.h proc.h signal.h io.h parse_tree.h
env.o: tokenizer.h parse_constants.h env.h sanity.h expand.h history.h
env.o: reader.h complete.h highlight.h color.h env_universal_common.h input.h
env.o: input_common.h event.h path.h fish_version.h
env_universal_common.o: config.h env_universal_common.h common.h fallback.h
env_universal_common.o: wutil.h env.h util.h utf8.h
event.o: config.h signal.h fallback.h wutil.h common.h input_common.h proc.h
event.o: io.h parse_tree.h tokenizer.h parse_constants.h parser.h event.h
exec.o: config.h signal.h fallback.h postfork.h io.h common.h wutil.h proc.h
exec.o: parse_tree.h tokenizer.h parse_constants.h exec.h parser.h event.h
exec.o: builtin.h function.h env.h parse_util.h
expand.o: config.h fallback.h util.h common.h wutil.h env.h proc.h signal.h
expand.o: io.h parse_tree.h tokenizer.h parse_constants.h parser.h event.h
expand.o: expand.h wildcard.h complete.h exec.h iothread.h parse_util.h
fallback.o: config.h fallback.h util.h
fish.o: config.h fallback.h common.h reader.h io.h complete.h highlight.h
fish.o: env.h color.h parse_constants.h builtin.h function.h event.h wutil.h
fish.o: proc.h signal.h parse_tree.h tokenizer.h parser.h expand.h intern.h
fish.o: history.h path.h input.h input_common.h fish_version.h
fish_indent.o: config.h color.h common.h fallback.h highlight.h env.h
fish_indent.o: parse_constants.h wutil.h output.h input.h input_common.h
fish_indent.o: parse_tree.h tokenizer.h print_help.h fish_version.h
fish_tests.o: config.h signal.h fallback.h util.h common.h proc.h io.h
fish_tests.o: parse_tree.h tokenizer.h parse_constants.h reader.h complete.h
fish_tests.o: highlight.h env.h color.h builtin.h function.h event.h
fish_tests.o: autoload.h lru.h wutil.h expand.h parser.h output.h exec.h
fish_tests.o: path.h history.h iothread.h postfork.h parse_util.h pager.h
fish_tests.o: screen.h input.h input_common.h utf8.h env_universal_common.h
fish_tests.o: wcstringutil.h
fish_version.o: fish_version.h
function.o: config.h wutil.h common.h fallback.h autoload.h lru.h function.h
function.o: event.h env.h intern.h reader.h io.h complete.h highlight.h
function.o: color.h parse_constants.h parser_keywords.h
highlight.o: config.h fallback.h wutil.h common.h highlight.h env.h color.h
highlight.o: tokenizer.h parse_util.h parse_constants.h builtin.h io.h
highlight.o: function.h event.h expand.h output.h wildcard.h complete.h
highlight.o: path.h history.h parse_tree.h
history.o: config.h fallback.h sanity.h reader.h io.h common.h complete.h
history.o: highlight.h env.h color.h parse_constants.h parse_tree.h
history.o: tokenizer.h wutil.h history.h path.h signal.h iothread.h lru.h
input.o: config.h fallback.h wutil.h common.h reader.h io.h complete.h
input.o: highlight.h env.h color.h parse_constants.h proc.h signal.h
input.o: parse_tree.h tokenizer.h input_common.h input.h parser.h event.h
input.o: output.h
input_common.o: config.h fallback.h util.h common.h input_common.h
input_common.o: env_universal_common.h wutil.h env.h iothread.h
intern.o: config.h fallback.h common.h intern.h
io.o: config.h fallback.h wutil.h common.h exec.h io.h
iothread.o: config.h iothread.h common.h fallback.h signal.h
key_reader.o: config.h common.h fallback.h input_common.h
kill.o: config.h fallback.h kill.h common.h env.h exec.h path.h
output.o: config.h fallback.h wutil.h common.h output.h color.h
pager.o: config.h util.h wutil.h common.h fallback.h pager.h complete.h
pager.o: screen.h highlight.h env.h color.h reader.h io.h parse_constants.h
parse_execution.o: parse_execution.h common.h config.h fallback.h io.h
parse_execution.o: parse_constants.h parse_tree.h tokenizer.h proc.h signal.h
parse_execution.o: env.h event.h util.h parse_util.h complete.h wildcard.h
parse_execution.o: expand.h parser.h reader.h highlight.h color.h wutil.h
parse_execution.o: path.h function.h builtin.h exec.h
parse_productions.o: parse_productions.h common.h config.h fallback.h
parse_productions.o: parse_constants.h parse_tree.h tokenizer.h
parse_tree.o: common.h config.h fallback.h parse_constants.h
parse_tree.o: parse_productions.h parse_tree.h tokenizer.h wutil.h proc.h
parse_tree.o: signal.h io.h
parse_util.o: config.h fallback.h util.h wutil.h common.h tokenizer.h
parse_util.o: parse_util.h parse_constants.h expand.h env.h wildcard.h
parse_util.o: complete.h parse_tree.h builtin.h io.h
parser.o: config.h fallback.h common.h wutil.h proc.h signal.h io.h
parser.o: parse_tree.h tokenizer.h parse_constants.h parser.h event.h
parser.o: function.h env.h expand.h reader.h complete.h highlight.h color.h
parser.o: sanity.h intern.h parse_util.h parse_execution.h
parser_keywords.o: config.h fallback.h common.h parser_keywords.h
path.o: config.h fallback.h common.h env.h wutil.h path.h expand.h
path.o: parse_constants.h
postfork.o: signal.h common.h config.h fallback.h proc.h io.h parse_tree.h
postfork.o: tokenizer.h parse_constants.h wutil.h postfork.h iothread.h
postfork.o: exec.h
print_help.o: print_help.h
proc.o: config.h signal.h fallback.h util.h wutil.h common.h proc.h io.h
proc.o: parse_tree.h tokenizer.h parse_constants.h reader.h complete.h
proc.o: highlight.h env.h color.h sanity.h parser.h event.h output.h
reader.o: config.h signal.h fallback.h util.h wutil.h common.h highlight.h
reader.o: env.h color.h reader.h io.h complete.h parse_constants.h proc.h
reader.o: parse_tree.h tokenizer.h parser.h event.h history.h sanity.h exec.h
reader.o: expand.h kill.h input_common.h input.h function.h output.h screen.h
reader.o: iothread.h intern.h parse_util.h pager.h
sanity.o: config.h fallback.h common.h sanity.h proc.h signal.h io.h
sanity.o: parse_tree.h tokenizer.h parse_constants.h history.h wutil.h
sanity.o: reader.h complete.h highlight.h env.h color.h kill.h
screen.o: config.h fallback.h common.h util.h output.h color.h highlight.h
screen.o: env.h screen.h pager.h complete.h reader.h io.h parse_constants.h
signal.o: config.h signal.h common.h fallback.h wutil.h event.h reader.h io.h
signal.o: complete.h highlight.h env.h color.h parse_constants.h proc.h
signal.o: parse_tree.h tokenizer.h
tokenizer.o: config.h fallback.h common.h wutil.h tokenizer.h
utf8.o: utf8.h
util.o: config.h fallback.h util.h common.h wutil.h
wcstringutil.o: config.h wcstringutil.h common.h fallback.h
wgetopt.o: config.h common.h fallback.h wgetopt.h wutil.h
wildcard.o: config.h fallback.h wutil.h common.h wildcard.h expand.h
wildcard.o: parse_constants.h complete.h reader.h io.h highlight.h env.h
wildcard.o: color.h
wutil.o: config.h fallback.h common.h wutil.h
obj/autoload.o: config.h src/autoload.h src/common.h src/fallback.h
obj/autoload.o: src/signal.h src/lru.h src/wutil.h src/env.h src/exec.h
obj/builtin.o: config.h src/signal.h src/fallback.h src/wutil.h src/common.h
obj/builtin.o: src/builtin.h src/io.h src/function.h src/event.h src/env.h
obj/builtin.o: src/complete.h src/proc.h src/parse_tree.h src/tokenizer.h
obj/builtin.o: src/parse_constants.h src/parser.h src/reader.h
obj/builtin.o: src/highlight.h src/color.h src/wgetopt.h src/input.h
obj/builtin.o: src/input_common.h src/intern.h src/exec.h src/parse_util.h
obj/builtin.o: src/parser_keywords.h src/expand.h src/path.h src/history.h
obj/builtin.o: src/wcstringutil.h src/builtin_set.cpp src/util.h
obj/builtin.o: src/builtin_commandline.cpp src/builtin_complete.cpp
obj/builtin.o: src/builtin_ulimit.cpp src/builtin_jobs.cpp
obj/builtin.o: src/builtin_set_color.cpp src/output.h src/builtin_printf.cpp
obj/builtin_test.o: config.h src/common.h src/fallback.h src/signal.h
obj/builtin_test.o: src/builtin.h src/io.h src/wutil.h src/proc.h
obj/builtin_test.o: src/parse_tree.h src/tokenizer.h src/parse_constants.h
obj/color.o: src/color.h src/common.h config.h src/fallback.h src/signal.h
obj/common.o: config.h src/signal.h src/fallback.h src/wutil.h src/common.h
obj/common.o: src/expand.h src/parse_constants.h src/wildcard.h
obj/common.o: src/complete.h src/util.cpp src/util.h src/fallback.cpp
obj/complete.o: config.h src/fallback.h src/signal.h src/util.h
obj/complete.o: src/wildcard.h src/common.h src/expand.h
obj/complete.o: src/parse_constants.h src/complete.h src/proc.h src/io.h
obj/complete.o: src/parse_tree.h src/tokenizer.h src/parser.h src/event.h
obj/complete.o: src/function.h src/env.h src/builtin.h src/exec.h
obj/complete.o: src/parse_util.h src/wutil.h src/path.h src/iothread.h
obj/complete.o: src/autoload.h src/lru.h
obj/env.o: config.h src/fallback.h src/signal.h src/wutil.h src/common.h
obj/env.o: src/proc.h src/io.h src/parse_tree.h src/tokenizer.h
obj/env.o: src/parse_constants.h src/env.h src/sanity.h src/expand.h
obj/env.o: src/history.h src/reader.h src/complete.h src/highlight.h
obj/env.o: src/color.h src/env_universal_common.h src/input.h
obj/env.o: src/input_common.h src/event.h src/path.h src/fish_version.h
obj/env_universal_common.o: config.h src/env_universal_common.h src/common.h
obj/env_universal_common.o: src/fallback.h src/signal.h src/wutil.h src/env.h
obj/env_universal_common.o: src/util.h src/utf8.h
obj/event.o: config.h src/signal.h src/fallback.h src/wutil.h src/common.h
obj/event.o: src/input_common.h src/proc.h src/io.h src/parse_tree.h
obj/event.o: src/tokenizer.h src/parse_constants.h src/parser.h src/event.h
obj/exec.o: config.h src/signal.h src/fallback.h src/postfork.h src/io.h
obj/exec.o: src/common.h src/wutil.h src/proc.h src/parse_tree.h
obj/exec.o: src/tokenizer.h src/parse_constants.h src/exec.h src/parser.h
obj/exec.o: src/event.h src/builtin.h src/function.h src/env.h
obj/exec.o: src/parse_util.h
obj/expand.o: config.h src/fallback.h src/signal.h src/util.h src/common.h
obj/expand.o: src/wutil.h src/env.h src/proc.h src/io.h src/parse_tree.h
obj/expand.o: src/tokenizer.h src/parse_constants.h src/parser.h src/event.h
obj/expand.o: src/expand.h src/wildcard.h src/complete.h src/exec.h
obj/expand.o: src/iothread.h src/parse_util.h
obj/fish.o: config.h src/fallback.h src/signal.h src/common.h src/reader.h
obj/fish.o: src/io.h src/complete.h src/highlight.h src/env.h src/color.h
obj/fish.o: src/parse_constants.h src/builtin.h src/function.h src/event.h
obj/fish.o: src/wutil.h src/proc.h src/parse_tree.h src/tokenizer.h
obj/fish.o: src/parser.h src/expand.h src/intern.h src/history.h src/path.h
obj/fish.o: src/input.h src/input_common.h src/fish_version.h
obj/fish_indent.o: config.h src/color.h src/common.h src/fallback.h
obj/fish_indent.o: src/signal.h src/highlight.h src/env.h
obj/fish_indent.o: src/parse_constants.h src/wutil.h src/output.h src/input.h
obj/fish_indent.o: src/input_common.h src/parse_tree.h src/tokenizer.h
obj/fish_indent.o: src/print_help.h src/fish_version.h
obj/fish_tests.o: config.h src/signal.h src/fallback.h src/util.h
obj/fish_tests.o: src/common.h src/proc.h src/io.h src/parse_tree.h
obj/fish_tests.o: src/tokenizer.h src/parse_constants.h src/reader.h
obj/fish_tests.o: src/complete.h src/highlight.h src/env.h src/color.h
obj/fish_tests.o: src/builtin.h src/function.h src/event.h src/autoload.h
obj/fish_tests.o: src/lru.h src/wutil.h src/expand.h src/parser.h
obj/fish_tests.o: src/output.h src/exec.h src/path.h src/history.h
obj/fish_tests.o: src/iothread.h src/postfork.h src/parse_util.h src/pager.h
obj/fish_tests.o: src/screen.h src/input.h src/input_common.h src/utf8.h
obj/fish_tests.o: src/env_universal_common.h src/wcstringutil.h
obj/fish_version.o: src/fish_version.h
obj/function.o: config.h src/wutil.h src/common.h src/fallback.h src/signal.h
obj/function.o: src/autoload.h src/lru.h src/function.h src/event.h src/env.h
obj/function.o: src/intern.h src/reader.h src/io.h src/complete.h
obj/function.o: src/highlight.h src/color.h src/parse_constants.h
obj/function.o: src/parser_keywords.h
obj/highlight.o: config.h src/fallback.h src/signal.h src/wutil.h
obj/highlight.o: src/common.h src/highlight.h src/env.h src/color.h
obj/highlight.o: src/tokenizer.h src/parse_util.h src/parse_constants.h
obj/highlight.o: src/builtin.h src/io.h src/function.h src/event.h
obj/highlight.o: src/expand.h src/output.h src/wildcard.h src/complete.h
obj/highlight.o: src/path.h src/history.h src/parse_tree.h
obj/history.o: config.h src/fallback.h src/signal.h src/sanity.h src/reader.h
obj/history.o: src/io.h src/common.h src/complete.h src/highlight.h src/env.h
obj/history.o: src/color.h src/parse_constants.h src/parse_tree.h
obj/history.o: src/tokenizer.h src/wutil.h src/history.h src/path.h
obj/history.o: src/iothread.h src/lru.h
obj/input.o: config.h src/fallback.h src/signal.h src/wutil.h src/common.h
obj/input.o: src/reader.h src/io.h src/complete.h src/highlight.h src/env.h
obj/input.o: src/color.h src/parse_constants.h src/proc.h src/parse_tree.h
obj/input.o: src/tokenizer.h src/input_common.h src/input.h src/parser.h
obj/input.o: src/event.h src/output.h
obj/input_common.o: config.h src/fallback.h src/signal.h src/util.h
obj/input_common.o: src/common.h src/input_common.h
obj/input_common.o: src/env_universal_common.h src/wutil.h src/env.h
obj/input_common.o: src/iothread.h
obj/intern.o: config.h src/fallback.h src/signal.h src/common.h src/intern.h
obj/io.o: config.h src/fallback.h src/signal.h src/wutil.h src/common.h
obj/io.o: src/exec.h src/io.h
obj/iothread.o: config.h src/iothread.h src/common.h src/fallback.h
obj/iothread.o: src/signal.h
obj/key_reader.o: config.h src/common.h src/fallback.h src/signal.h
obj/key_reader.o: src/input_common.h
obj/kill.o: config.h src/fallback.h src/signal.h src/kill.h src/common.h
obj/kill.o: src/env.h src/exec.h src/path.h
obj/output.o: config.h src/fallback.h src/signal.h src/wutil.h src/common.h
obj/output.o: src/output.h src/color.h
obj/pager.o: config.h src/util.h src/wutil.h src/common.h src/fallback.h
obj/pager.o: src/signal.h src/pager.h src/complete.h src/screen.h
obj/pager.o: src/highlight.h src/env.h src/color.h src/reader.h src/io.h
obj/pager.o: src/parse_constants.h
obj/parse_execution.o: src/parse_execution.h src/common.h config.h
obj/parse_execution.o: src/fallback.h src/signal.h src/io.h
obj/parse_execution.o: src/parse_constants.h src/parse_tree.h src/tokenizer.h
obj/parse_execution.o: src/proc.h src/env.h src/event.h src/util.h
obj/parse_execution.o: src/parse_util.h src/complete.h src/wildcard.h
obj/parse_execution.o: src/expand.h src/parser.h src/reader.h src/highlight.h
obj/parse_execution.o: src/color.h src/wutil.h src/path.h src/function.h
obj/parse_execution.o: src/builtin.h src/exec.h
obj/parse_productions.o: src/parse_productions.h src/common.h config.h
obj/parse_productions.o: src/fallback.h src/signal.h src/parse_constants.h
obj/parse_productions.o: src/parse_tree.h src/tokenizer.h
obj/parse_tree.o: src/common.h config.h src/fallback.h src/signal.h
obj/parse_tree.o: src/parse_constants.h src/parse_productions.h
obj/parse_tree.o: src/parse_tree.h src/tokenizer.h src/wutil.h src/proc.h
obj/parse_tree.o: src/io.h
obj/parse_util.o: config.h src/fallback.h src/signal.h src/util.h src/wutil.h
obj/parse_util.o: src/common.h src/tokenizer.h src/parse_util.h
obj/parse_util.o: src/parse_constants.h src/expand.h src/env.h src/wildcard.h
obj/parse_util.o: src/complete.h src/parse_tree.h src/builtin.h src/io.h
obj/parser.o: config.h src/fallback.h src/signal.h src/common.h src/wutil.h
obj/parser.o: src/proc.h src/io.h src/parse_tree.h src/tokenizer.h
obj/parser.o: src/parse_constants.h src/parser.h src/event.h src/function.h
obj/parser.o: src/env.h src/expand.h src/reader.h src/complete.h
obj/parser.o: src/highlight.h src/color.h src/sanity.h src/intern.h
obj/parser.o: src/parse_util.h src/parse_execution.h
obj/parser_keywords.o: config.h src/fallback.h src/signal.h src/common.h
obj/parser_keywords.o: src/parser_keywords.h
obj/path.o: config.h src/fallback.h src/signal.h src/common.h src/env.h
obj/path.o: src/wutil.h src/path.h src/expand.h src/parse_constants.h
obj/postfork.o: src/signal.h src/common.h config.h src/fallback.h src/proc.h
obj/postfork.o: src/io.h src/parse_tree.h src/tokenizer.h
obj/postfork.o: src/parse_constants.h src/wutil.h src/postfork.h
obj/postfork.o: src/iothread.h src/exec.h
obj/print_help.o: src/print_help.h
obj/proc.o: config.h src/signal.h src/fallback.h src/util.h src/wutil.h
obj/proc.o: src/common.h src/proc.h src/io.h src/parse_tree.h src/tokenizer.h
obj/proc.o: src/parse_constants.h src/reader.h src/complete.h src/highlight.h
obj/proc.o: src/env.h src/color.h src/sanity.h src/parser.h src/event.h
obj/proc.o: src/output.h
obj/reader.o: config.h src/signal.h src/fallback.h src/util.h src/wutil.h
obj/reader.o: src/common.h src/highlight.h src/env.h src/color.h src/reader.h
obj/reader.o: src/io.h src/complete.h src/parse_constants.h src/proc.h
obj/reader.o: src/parse_tree.h src/tokenizer.h src/parser.h src/event.h
obj/reader.o: src/history.h src/sanity.h src/exec.h src/expand.h src/kill.h
obj/reader.o: src/input_common.h src/input.h src/function.h src/output.h
obj/reader.o: src/screen.h src/iothread.h src/intern.h src/parse_util.h
obj/reader.o: src/pager.h
obj/sanity.o: config.h src/fallback.h src/signal.h src/common.h src/sanity.h
obj/sanity.o: src/proc.h src/io.h src/parse_tree.h src/tokenizer.h
obj/sanity.o: src/parse_constants.h src/history.h src/wutil.h src/reader.h
obj/sanity.o: src/complete.h src/highlight.h src/env.h src/color.h src/kill.h
obj/screen.o: config.h src/fallback.h src/signal.h src/common.h src/util.h
obj/screen.o: src/output.h src/color.h src/highlight.h src/env.h src/screen.h
obj/screen.o: src/pager.h src/complete.h src/reader.h src/io.h
obj/screen.o: src/parse_constants.h
obj/signal.o: config.h src/signal.h src/common.h src/fallback.h src/wutil.h
obj/signal.o: src/event.h src/reader.h src/io.h src/complete.h
obj/signal.o: src/highlight.h src/env.h src/color.h src/parse_constants.h
obj/signal.o: src/proc.h src/parse_tree.h src/tokenizer.h
obj/tokenizer.o: config.h src/fallback.h src/signal.h src/common.h
obj/tokenizer.o: src/wutil.h src/tokenizer.h
obj/utf8.o: src/utf8.h
obj/wcstringutil.o: config.h src/wcstringutil.h src/common.h src/fallback.h
obj/wcstringutil.o: src/signal.h
obj/wgetopt.o: config.h src/common.h src/fallback.h src/signal.h
obj/wgetopt.o: src/wgetopt.h src/wutil.h
obj/wildcard.o: config.h src/fallback.h src/signal.h src/wutil.h src/common.h
obj/wildcard.o: src/wildcard.h src/expand.h src/parse_constants.h
obj/wildcard.o: src/complete.h src/reader.h src/io.h src/highlight.h
obj/wildcard.o: src/env.h src/color.h
obj/wutil.o: config.h src/fallback.h src/signal.h src/common.h src/wutil.h

3
build_tools/cppcheck.sh Executable file
View file

@ -0,0 +1,3 @@
#!/usr/local/bin/fish
cppcheck --enable=all --std=posix --quiet .

View file

@ -361,7 +361,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
4E142D731B56B5D7008783C8 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = config.h; path = osx/config.h; sourceTree = "<group>"; };
4E142D731B56B5D7008783C8 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = config.h; path = ../osx/config.h; sourceTree = "<group>"; };
D00769421990137800CA4627 /* fish_tests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fish_tests; sourceTree = BUILT_PRODUCTS_DIR; };
D00F63F019137E9D00FCCDEC /* fish_version.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fish_version.cpp; sourceTree = "<group>"; };
D01A2D23169B730A00767098 /* man1 */ = {isa = PBXFileReference; lastKnownFileType = text; name = man1; path = pages_for_manpath/man1; sourceTree = BUILT_PRODUCTS_DIR; };
@ -675,6 +675,7 @@
D0A0856113B3ACEE0099B651 /* wutil.cpp */,
);
name = Sources;
path = src;
sourceTree = "<group>";
};
D0D02AAB15985C14008E62BD /* Resources */ = {
@ -809,7 +810,7 @@
D0A084F213B3AC130099B651 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0630;
LastUpgradeCheck = 0640;
};
buildConfigurationList = D0A084F513B3AC130099B651 /* Build configuration list for PBXProject "fish" */;
compatibilityVersion = "Xcode 3.2";

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View file

@ -47,4 +47,3 @@ complete -c grep -s x -l line-regexp --description "Only whole matching lines"
complete -c grep -s y --description "Obsolete synonym for -i"
complete -c grep -s z -l null-data --description 'treat input as a set of lines each terminated by a zero byte'
complete -c grep -s Z -l null --description "Output a zero byte after filename"
end

View file

@ -633,7 +633,7 @@ static int builtin_bind_erase(wchar_t **seq, int all, const wchar_t *mode, int u
*/
static int builtin_bind(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
enum
{
BIND_INSERT,
@ -654,7 +654,7 @@ static int builtin_bind(parser_t &parser, wchar_t **argv)
int use_terminfo = 0;
woptind=0;
w.woptind=0;
static const struct woption long_options[] =
{
@ -672,11 +672,11 @@ static int builtin_bind(parser_t &parser, wchar_t **argv)
while (1)
{
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"aehkKfM:m:",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"aehkKfM:m:",
long_options,
&opt_index);
if (opt == -1)
break;
@ -719,17 +719,17 @@ static int builtin_bind(parser_t &parser, wchar_t **argv)
break;
case 'M':
bind_mode = woptarg;
bind_mode = w.woptarg;
bind_mode_given = true;
break;
case 'm':
sets_bind_mode = woptarg;
sets_bind_mode = w.woptarg;
sets_bind_mode_given = true;
break;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
@ -749,7 +749,7 @@ static int builtin_bind(parser_t &parser, wchar_t **argv)
case BIND_ERASE:
{
if (builtin_bind_erase(&argv[woptind], all, bind_mode_given ? bind_mode : NULL, use_terminfo))
if (builtin_bind_erase(&argv[w.woptind], all, bind_mode_given ? bind_mode : NULL, use_terminfo))
{
res = STATUS_BUILTIN_ERROR;
}
@ -758,7 +758,7 @@ static int builtin_bind(parser_t &parser, wchar_t **argv)
case BIND_INSERT:
{
switch (argc-woptind)
switch (argc-w.woptind)
{
case 0:
{
@ -771,7 +771,7 @@ static int builtin_bind(parser_t &parser, wchar_t **argv)
wcstring seq;
if (use_terminfo)
{
if (!get_terminfo_sequence(argv[woptind], &seq))
if (!get_terminfo_sequence(argv[w.woptind], &seq))
{
res = STATUS_BUILTIN_ERROR;
// get_terminfo_sequence already printed the error
@ -780,12 +780,12 @@ static int builtin_bind(parser_t &parser, wchar_t **argv)
}
else
{
seq = argv[woptind];
seq = argv[w.woptind];
}
if (!builtin_bind_list_one(seq, bind_mode))
{
res = STATUS_BUILTIN_ERROR;
wcstring eseq = escape_string(argv[woptind], 0);
wcstring eseq = escape_string(argv[w.woptind], 0);
if (use_terminfo)
{
append_format(stderr_buffer, _(L"%ls: No binding found for key '%ls'\n"), argv[0], eseq.c_str());
@ -800,7 +800,7 @@ static int builtin_bind(parser_t &parser, wchar_t **argv)
default:
{
if (builtin_bind_add(argv[woptind], (const wchar_t **)argv + (woptind + 1), argc - (woptind + 1), bind_mode, sets_bind_mode, use_terminfo))
if (builtin_bind_add(argv[w.woptind], (const wchar_t **)argv + (w.woptind + 1), argc - (w.woptind + 1), bind_mode, sets_bind_mode, use_terminfo))
{
res = STATUS_BUILTIN_ERROR;
}
@ -842,6 +842,7 @@ static int builtin_bind(parser_t &parser, wchar_t **argv)
*/
static int builtin_block(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
enum
{
UNSET,
@ -854,7 +855,7 @@ static int builtin_block(parser_t &parser, wchar_t **argv)
int erase = 0;
int argc=builtin_count_args(argv);
woptind=0;
w.woptind=0;
static const struct woption
long_options[] =
@ -885,11 +886,11 @@ static int builtin_block(parser_t &parser, wchar_t **argv)
{
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"elgh",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"elgh",
long_options,
&opt_index);
if (opt == -1)
break;
@ -922,7 +923,7 @@ static int builtin_block(parser_t &parser, wchar_t **argv)
break;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
}
@ -1000,8 +1001,7 @@ static int builtin_builtin(parser_t &parser, wchar_t **argv)
{
int argc=builtin_count_args(argv);
int list=0;
woptind=0;
wgetopter_t w;
static const struct woption
long_options[] =
@ -1024,11 +1024,11 @@ static int builtin_builtin(parser_t &parser, wchar_t **argv)
{
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"nh",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"nh",
long_options,
&opt_index);
if (opt == -1)
break;
@ -1054,7 +1054,7 @@ static int builtin_builtin(parser_t &parser, wchar_t **argv)
break;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
}
@ -1082,10 +1082,9 @@ static int builtin_builtin(parser_t &parser, wchar_t **argv)
*/
static int builtin_emit(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
int argc=builtin_count_args(argv);
woptind=0;
static const struct woption
long_options[] =
{
@ -1103,11 +1102,11 @@ static int builtin_emit(parser_t &parser, wchar_t **argv)
{
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"h",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"h",
long_options,
&opt_index);
if (opt == -1)
break;
@ -1128,20 +1127,20 @@ static int builtin_emit(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_OK;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
}
}
if (!argv[woptind])
if (!argv[w.woptind])
{
append_format(stderr_buffer, L"%ls: expected event name\n", argv[0]);
return STATUS_BUILTIN_ERROR;
}
const wchar_t *eventname = argv[woptind];
wcstring_list_t args(argv + woptind + 1, argv + argc);
const wchar_t *eventname = argv[w.woptind];
wcstring_list_t args(argv + w.woptind + 1, argv + argc);
event_fire_generic(eventname, &args);
return STATUS_BUILTIN_OK;
@ -1154,10 +1153,11 @@ static int builtin_emit(parser_t &parser, wchar_t **argv)
*/
static int builtin_command(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
int argc=builtin_count_args(argv);
int print_path=0;
woptind=0;
w.woptind=0;
static const struct woption
long_options[] =
@ -1171,11 +1171,11 @@ static int builtin_command(parser_t &parser, wchar_t **argv)
{
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"svh",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"svh",
long_options,
&opt_index);
if (opt == -1)
break;
@ -1201,7 +1201,7 @@ static int builtin_command(parser_t &parser, wchar_t **argv)
break;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
}
@ -1216,7 +1216,7 @@ static int builtin_command(parser_t &parser, wchar_t **argv)
int found=0;
for (int idx = woptind; argv[idx]; ++idx)
for (int idx = w.woptind; argv[idx]; ++idx)
{
const wchar_t *command_name = argv[idx];
wcstring path;
@ -1236,6 +1236,7 @@ static int builtin_command(parser_t &parser, wchar_t **argv)
*/
static int builtin_generic(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
int argc=builtin_count_args(argv);
/* Hackish - if we have no arguments other than the command, we are a "naked invocation" and we just print help */
@ -1245,8 +1246,6 @@ static int builtin_generic(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_ERROR;
}
woptind=0;
static const struct woption
long_options[] =
{
@ -1258,11 +1257,11 @@ static int builtin_generic(parser_t &parser, wchar_t **argv)
{
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"h",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"h",
long_options,
&opt_index);
if (opt == -1)
break;
@ -1283,7 +1282,7 @@ static int builtin_generic(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_OK;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
}
@ -1432,6 +1431,7 @@ static void functions_def(const wcstring &name, wcstring &out)
*/
static int builtin_functions(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
int i;
int erase=0;
wchar_t *desc=0;
@ -1443,8 +1443,6 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
int query = 0;
int copy = 0;
woptind=0;
static const struct woption
long_options[] =
{
@ -1486,11 +1484,11 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
{
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"ed:nahqc",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"ed:nahqc",
long_options,
&opt_index);
if (opt == -1)
break;
@ -1513,7 +1511,7 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
break;
case 'd':
desc=woptarg;
desc=w.woptarg;
break;
case 'n':
@ -1537,7 +1535,7 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
break;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
}
@ -1561,7 +1559,7 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
if (erase)
{
int i;
for (i=woptind; i<argc; i++)
for (i=w.woptind; i<argc; i++)
function_remove(argv[i]);
return STATUS_BUILTIN_OK;
}
@ -1569,7 +1567,7 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
{
wchar_t *func;
if (argc-woptind != 1)
if (argc-w.woptind != 1)
{
append_format(stderr_buffer,
_(L"%ls: Expected exactly one function name\n"),
@ -1578,7 +1576,7 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_ERROR;
}
func = argv[woptind];
func = argv[w.woptind];
if (!function_exists(func))
{
append_format(stderr_buffer,
@ -1595,7 +1593,7 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_OK;
}
else if (list || (argc==woptind))
else if (list || (argc==w.woptind))
{
int is_screen = !builtin_out_redirect && isatty(1);
size_t i;
@ -1629,7 +1627,7 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
wcstring current_func;
wcstring new_func;
if (argc-woptind != 2)
if (argc-w.woptind != 2)
{
append_format(stderr_buffer,
_(L"%ls: Expected exactly two names (current function name, and new function name)\n"),
@ -1638,8 +1636,8 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_ERROR;
}
current_func = argv[woptind];
new_func = argv[woptind+1];
current_func = argv[w.woptind];
new_func = argv[w.woptind+1];
if (!function_exists(current_func))
{
@ -1680,7 +1678,7 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_ERROR;
}
for (i=woptind; i<argc; i++)
for (i=w.woptind; i<argc; i++)
{
if (!function_exists(argv[i]))
res++;
@ -1688,7 +1686,7 @@ static int builtin_functions(parser_t &parser, wchar_t **argv)
{
if (!query)
{
if (i != woptind)
if (i != w.woptind)
stdout_buffer.append(L"\n");
functions_def(argv[i], stdout_buffer);
@ -1984,6 +1982,7 @@ static int builtin_pwd(parser_t &parser, wchar_t **argv)
/** Adds a function to the function set. It calls into function.cpp to perform any heavy lifting. */
int define_function(parser_t &parser, const wcstring_list_t &c_args, const wcstring &contents, int definition_line_offset, wcstring *out_err)
{
wgetopter_t w;
assert(out_err != NULL);
/* wgetopt expects 'function' as the first argument. Make a new wcstring_list with that property. */
@ -2006,8 +2005,6 @@ int define_function(parser_t &parser, const wcstring_list_t &c_args, const wcstr
bool shadows = true;
woptind=0;
wcstring_list_t wrap_targets;
/* If -a/--argument-names is specified before the function name,
@ -2038,11 +2035,11 @@ int define_function(parser_t &parser, const wcstring_list_t &c_args, const wcstr
int opt_index = 0;
// The leading - here specifies RETURN_IN_ORDER
int opt = wgetopt_long(argc,
argv,
L"-d:s:j:p:v:e:haSV:",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"-d:s:j:p:v:e:haSV:",
long_options,
&opt_index);
if (opt == -1)
break;
@ -2063,19 +2060,19 @@ int define_function(parser_t &parser, const wcstring_list_t &c_args, const wcstr
break;
case 'd':
desc=woptarg;
desc=w.woptarg;
break;
case 's':
{
int sig = wcs2sig(woptarg);
int sig = wcs2sig(w.woptarg);
if (sig < 0)
{
append_format(*out_err,
_(L"%ls: Unknown signal '%ls'\n"),
argv[0],
woptarg);
w.woptarg);
res=1;
break;
}
@ -2085,24 +2082,24 @@ int define_function(parser_t &parser, const wcstring_list_t &c_args, const wcstr
case 'v':
{
if (wcsvarname(woptarg))
if (wcsvarname(w.woptarg))
{
append_format(*out_err,
_(L"%ls: Invalid variable name '%ls'\n"),
argv[0],
woptarg);
w.woptarg);
res=STATUS_BUILTIN_ERROR;
break;
}
events.push_back(event_t::variable_event(woptarg));
events.push_back(event_t::variable_event(w.woptarg));
break;
}
case 'e':
{
events.push_back(event_t::generic_event(woptarg));
events.push_back(event_t::generic_event(w.woptarg));
break;
}
@ -2114,7 +2111,7 @@ int define_function(parser_t &parser, const wcstring_list_t &c_args, const wcstr
event_t e(EVENT_ANY);
if ((opt == 'j') &&
(wcscasecmp(woptarg, L"caller") == 0))
(wcscasecmp(w.woptarg, L"caller") == 0))
{
int job_id = -1;
@ -2155,13 +2152,13 @@ int define_function(parser_t &parser, const wcstring_list_t &c_args, const wcstr
else
{
errno = 0;
pid = fish_wcstoi(woptarg, &end, 10);
pid = fish_wcstoi(w.woptarg, &end, 10);
if (errno || !end || *end)
{
append_format(*out_err,
_(L"%ls: Invalid process id %ls\n"),
argv[0],
woptarg);
w.woptarg);
res=1;
break;
}
@ -2192,19 +2189,19 @@ int define_function(parser_t &parser, const wcstring_list_t &c_args, const wcstr
break;
case 'w':
wrap_targets.push_back(woptarg);
wrap_targets.push_back(w.woptarg);
break;
case 'V':
{
if (wcsvarname(woptarg))
if (wcsvarname(w.woptarg))
{
append_format(*out_err, _(L"%ls: Invalid variable name '%ls'\n"), argv[0], woptarg);
append_format(*out_err, _(L"%ls: Invalid variable name '%ls'\n"), argv[0], w.woptarg);
res = STATUS_BUILTIN_ERROR;
break;
}
inherit_vars.push_back(woptarg);
inherit_vars.push_back(w.woptarg);
break;
}
@ -2213,12 +2210,12 @@ int define_function(parser_t &parser, const wcstring_list_t &c_args, const wcstr
return STATUS_BUILTIN_OK;
case 1:
assert(woptarg != NULL);
positionals.push_back(woptarg);
assert(w.woptarg != NULL);
positionals.push_back(w.woptarg);
break;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
res = 1;
break;
@ -2347,7 +2344,7 @@ static int builtin_random(parser_t &parser, wchar_t **argv)
int argc = builtin_count_args(argv);
woptind=0;
wgetopter_t w;
static const struct woption
long_options[] =
@ -2366,11 +2363,11 @@ static int builtin_random(parser_t &parser, wchar_t **argv)
{
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"h",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"h",
long_options,
&opt_index);
if (opt == -1)
break;
@ -2392,14 +2389,14 @@ static int builtin_random(parser_t &parser, wchar_t **argv)
break;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
}
}
switch (argc-woptind)
switch (argc-w.woptind)
{
case 0:
@ -2423,13 +2420,13 @@ static int builtin_random(parser_t &parser, wchar_t **argv)
wchar_t *end=0;
errno=0;
foo = wcstol(argv[woptind], &end, 10);
foo = wcstol(argv[w.woptind], &end, 10);
if (errno || *end)
{
append_format(stderr_buffer,
_(L"%ls: Seed value '%ls' is not a valid number\n"),
argv[0],
argv[woptind]);
argv[w.woptind]);
return STATUS_BUILTIN_ERROR;
}
@ -2443,7 +2440,7 @@ static int builtin_random(parser_t &parser, wchar_t **argv)
append_format(stderr_buffer,
_(L"%ls: Expected zero or one argument, got %d\n"),
argv[0],
argc-woptind);
argc-w.woptind);
builtin_print_help(parser, argv[0], stderr_buffer);
return STATUS_BUILTIN_ERROR;
}
@ -2457,6 +2454,7 @@ static int builtin_random(parser_t &parser, wchar_t **argv)
*/
static int builtin_read(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
wcstring buff;
int i, argc = builtin_count_args(argv);
int place = ENV_USER;
@ -2471,8 +2469,6 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
int array = 0;
bool split_null = false;
woptind=0;
while (1)
{
static const struct woption
@ -2542,11 +2538,11 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"xglUup:R:c:hm:n:saz",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"xglUup:R:c:hm:n:saz",
long_options,
&opt_index);
if (opt == -1)
break;
@ -2584,24 +2580,24 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
break;
case L'p':
prompt = woptarg;
prompt = w.woptarg;
break;
case L'R':
right_prompt = woptarg;
right_prompt = w.woptarg;
break;
case L'c':
commandline = woptarg;
commandline = w.woptarg;
break;
case L'm':
mode_name = woptarg;
mode_name = w.woptarg;
break;
case L'n':
errno = 0;
nchars = fish_wcstoi(woptarg, &end, 10);
nchars = fish_wcstoi(w.woptarg, &end, 10);
if (errno || *end != 0)
{
switch (errno)
@ -2610,7 +2606,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
append_format(stderr_buffer,
_(L"%ls: Argument '%ls' is out of range\n"),
argv[0],
woptarg);
w.woptarg);
builtin_print_help(parser, argv[0], stderr_buffer);
return STATUS_BUILTIN_ERROR;
@ -2618,7 +2614,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
append_format(stderr_buffer,
_(L"%ls: Argument '%ls' must be an integer\n"),
argv[0],
woptarg);
w.woptarg);
builtin_print_help(parser, argv[0], stderr_buffer);
return STATUS_BUILTIN_ERROR;
}
@ -2642,7 +2638,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_OK;
case L'?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
}
@ -2669,7 +2665,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_ERROR;
}
if (array && woptind+1 != argc)
if (array && w.woptind+1 != argc)
{
append_format(stderr_buffer, _(L"%ls: --array option requires a single variable name.\n"), argv[0]);
builtin_print_help(parser, argv[0], stderr_buffer);
@ -2680,7 +2676,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
/*
Verify all variable names
*/
for (i=woptind; i<argc; i++)
for (i=w.woptind; i<argc; i++)
{
wchar_t *src;
@ -2705,7 +2701,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
/*
The call to reader_readline may change woptind, so we save it away here
*/
i=woptind;
i=w.woptind;
/*
Check if we should read interactively using \c reader_readline()
@ -2901,7 +2897,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
*/
static int builtin_status(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
enum
{
NORMAL,
@ -2924,8 +2920,6 @@ static int builtin_status(parser_t &parser, wchar_t **argv)
int argc = builtin_count_args(argv);
int res=STATUS_BUILTIN_OK;
woptind=0;
const struct woption
long_options[] =
@ -2988,11 +2982,11 @@ static int builtin_status(parser_t &parser, wchar_t **argv)
{
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L":cbilfnhj:t",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L":cbilfnhj:t",
long_options,
&opt_index);
if (opt == -1)
break;
@ -3037,17 +3031,17 @@ static int builtin_status(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_OK;
case 'j':
if (wcscmp(woptarg, L"full") == 0)
if (wcscmp(w.woptarg, L"full") == 0)
job_control_mode = JOB_CONTROL_ALL;
else if (wcscmp(woptarg, L"interactive") == 0)
else if (wcscmp(w.woptarg, L"interactive") == 0)
job_control_mode = JOB_CONTROL_INTERACTIVE;
else if (wcscmp(woptarg, L"none") == 0)
else if (wcscmp(w.woptarg, L"none") == 0)
job_control_mode = JOB_CONTROL_NONE;
else
{
append_format(stderr_buffer,
L"%ls: Invalid job control mode '%ls'\n",
L"status", woptarg);
L"status", w.woptarg);
res = 1;
}
mode = DONE;
@ -3059,11 +3053,11 @@ static int builtin_status(parser_t &parser, wchar_t **argv)
case ':':
builtin_missing_argument(parser, argv[0], argv[woptind-1]);
builtin_missing_argument(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
}
@ -3320,13 +3314,12 @@ static int builtin_count(parser_t &parser, wchar_t ** argv)
*/
static int builtin_contains(parser_t &parser, wchar_t ** argv)
{
wgetopter_t w;
int argc;
argc = builtin_count_args(argv);
wchar_t *needle;
bool should_output_index = false;
woptind=0;
const struct woption long_options[] =
{
{ L"help", no_argument, 0, 'h' } ,
@ -3338,11 +3331,11 @@ static int builtin_contains(parser_t &parser, wchar_t ** argv)
{
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"+hi",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"+hi",
long_options,
&opt_index);
if (opt == -1)
break;
@ -3366,11 +3359,11 @@ static int builtin_contains(parser_t &parser, wchar_t ** argv)
case ':':
builtin_missing_argument(parser, argv[0], argv[woptind-1]);
builtin_missing_argument(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
case 'i':
@ -3380,19 +3373,19 @@ static int builtin_contains(parser_t &parser, wchar_t ** argv)
}
needle = argv[woptind];
needle = argv[w.woptind];
if (!needle)
{
append_format(stderr_buffer, _(L"%ls: Key not specified\n"), argv[0]);
}
for (int i=woptind+1; i<argc; i++)
for (int i=w.woptind+1; i<argc; i++)
{
if (!wcscmp(needle, argv[i]))
{
if (should_output_index) append_format(stdout_buffer, L"%d\n", i-woptind);
if (should_output_index) append_format(stdout_buffer, L"%d\n", i-w.woptind);
return 0;
}
}
@ -3905,14 +3898,15 @@ static int builtin_history(parser_t &parser, wchar_t **argv)
int opt = 0;
int opt_index = 0;
woptind = 0;
wgetopter_t w;
history_t *history = reader_get_history();
/* Use the default history if we have none (which happens if invoked non-interactively, e.g. from webconfig.py */
if (! history)
history = &history_t::history_with_name(L"fish");
while ((opt = wgetopt_long_only(argc, argv, L"pdscvl", long_options, &opt_index)) != EOF)
while ((opt = w.wgetopt_long_only(argc, argv, L"pdscvl", long_options, &opt_index)) != EOF)
{
switch (opt)
{
@ -3941,17 +3935,17 @@ static int builtin_history(parser_t &parser, wchar_t **argv)
return STATUS_BUILTIN_OK;
break;
case '?':
append_format(stderr_buffer, BUILTIN_ERR_UNKNOWN, argv[0], argv[woptind-1]);
append_format(stderr_buffer, BUILTIN_ERR_UNKNOWN, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
break;
default:
append_format(stderr_buffer, BUILTIN_ERR_UNKNOWN, argv[0], argv[woptind-1]);
append_format(stderr_buffer, BUILTIN_ERR_UNKNOWN, argv[0], argv[w.woptind-1]);
return STATUS_BUILTIN_ERROR;
}
}
/* Everything after is an argument */
const wcstring_list_t args(argv + woptind, argv + argc);
const wcstring_list_t args(argv + w.woptind, argv + argc);
if (argc == 1)
{
@ -4154,8 +4148,6 @@ static const builtin_data_t *builtin_lookup(const wcstring &name)
void builtin_init()
{
wopterr = 0;
for (size_t i=0; i < BUILTIN_COUNT; i++)
{
intern_static(builtin_datas[i].name);

View file

@ -247,7 +247,7 @@ static void write_part(const wchar_t *begin,
*/
static int builtin_commandline(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
int buffer_part=0;
int cut_at_cursor=0;
@ -298,7 +298,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
return 1;
}
woptind=0;
w.woptind=0;
while (1)
{
@ -327,11 +327,11 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"abijpctwforhI:CLSsP",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"abijpctwforhI:CLSsP",
long_options,
&opt_index);
if (opt == -1)
break;
@ -390,8 +390,8 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
break;
case 'I':
current_buffer = woptarg;
current_cursor_pos = wcslen(woptarg);
current_buffer = w.woptarg;
current_cursor_pos = wcslen(w.woptarg);
break;
case 'C':
@ -419,7 +419,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
return 0;
case L'?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return 1;
}
}
@ -442,7 +442,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
}
if (argc == woptind)
if (argc == w.woptind)
{
append_format(stderr_buffer,
BUILTIN_ERR_MISSING,
@ -451,7 +451,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
builtin_print_help(parser, argv[0], stderr_buffer);
return 1;
}
for (i=woptind; i<argc; i++)
for (i=w.woptind; i<argc; i++)
{
wchar_t c = input_function_get_code(argv[i]);
if (c != (wchar_t)(-1))
@ -491,7 +491,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
/*
Check for invalid switch combinations
*/
if ((search_mode || line_mode || cursor_mode || paging_mode) && (argc-woptind > 1))
if ((search_mode || line_mode || cursor_mode || paging_mode) && (argc-w.woptind > 1))
{
append_format(stderr_buffer,
@ -513,7 +513,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
}
if ((tokenize || cut_at_cursor) && (argc-woptind))
if ((tokenize || cut_at_cursor) && (argc-w.woptind))
{
append_format(stderr_buffer,
BUILTIN_ERR_COMBO2,
@ -525,7 +525,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
return 1;
}
if (append_mode && !(argc-woptind))
if (append_mode && !(argc-w.woptind))
{
append_format(stderr_buffer,
BUILTIN_ERR_COMBO2,
@ -551,19 +551,19 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
if (cursor_mode)
{
if (argc-woptind)
if (argc-w.woptind)
{
wchar_t *endptr;
long new_pos;
errno = 0;
new_pos = wcstol(argv[woptind], &endptr, 10);
new_pos = wcstol(argv[w.woptind], &endptr, 10);
if (*endptr || errno)
{
append_format(stderr_buffer,
BUILTIN_ERR_NOT_NUMBER,
argv[0],
argv[woptind]);
argv[w.woptind]);
builtin_print_help(parser, argv[0], stderr_buffer);
}
@ -639,7 +639,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
}
switch (argc-woptind)
switch (argc-w.woptind)
{
case 0:
{
@ -649,16 +649,16 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
case 1:
{
replace_part(begin, end, argv[woptind], append_mode);
replace_part(begin, end, argv[w.woptind], append_mode);
break;
}
default:
{
wcstring sb = argv[woptind];
wcstring sb = argv[w.woptind];
int i;
for (i=woptind+1; i<argc; i++)
for (i=w.woptind+1; i<argc; i++)
{
sb.push_back(L'\n');
sb.append(argv[i]);

View file

@ -287,6 +287,7 @@ static void builtin_complete_remove(const wcstring_list_t &cmd,
static int builtin_complete(parser_t &parser, wchar_t **argv)
{
ASSERT_IS_MAIN_THREAD();
wgetopter_t w;
bool res=false;
int argc=0;
int result_mode=SHARED;
@ -308,7 +309,7 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
argc = builtin_count_args(argv);
woptind=0;
w.woptind=0;
while (! res)
{
@ -337,11 +338,11 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"a:c:p:s:l:o:d:frxeuAn:C::w:h",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"a:c:p:s:l:o:d:frxeuAn:C::w:h",
long_options,
&opt_index);
if (opt == -1)
break;
@ -376,7 +377,7 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
case 'c':
{
wcstring tmp;
if (unescape_string(woptarg, &tmp, UNESCAPE_SPECIAL))
if (unescape_string(w.woptarg, &tmp, UNESCAPE_SPECIAL))
{
if (opt=='p')
path.push_back(tmp);
@ -385,14 +386,14 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
}
else
{
append_format(stderr_buffer, L"%ls: Invalid token '%ls'\n", argv[0], woptarg);
append_format(stderr_buffer, L"%ls: Invalid token '%ls'\n", argv[0], w.woptarg);
res = true;
}
break;
}
case 'd':
desc = woptarg;
desc = w.woptarg;
break;
case 'u':
@ -404,19 +405,19 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
break;
case 's':
short_opt.append(woptarg);
short_opt.append(w.woptarg);
break;
case 'l':
gnu_opt.push_back(woptarg);
gnu_opt.push_back(w.woptarg);
break;
case 'o':
old_opt.push_back(woptarg);
old_opt.push_back(w.woptarg);
break;
case 'a':
comp = woptarg;
comp = w.woptarg;
break;
case 'e':
@ -424,16 +425,16 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
break;
case 'n':
condition = woptarg;
condition = w.woptarg;
break;
case 'w':
wrap_targets.push_back(woptarg);
wrap_targets.push_back(w.woptarg);
break;
case 'C':
do_complete = true;
do_complete_param = woptarg ? woptarg : reader_get_buffer();
do_complete_param = w.woptarg ? w.woptarg : reader_get_buffer();
break;
case 'h':
@ -441,7 +442,7 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
return 0;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
res = true;
break;
@ -545,7 +546,7 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
recursion_level--;
}
}
else if (woptind != argc)
else if (w.woptind != argc)
{
append_format(stderr_buffer,
_(L"%ls: Too many arguments\n"),

View file

@ -160,13 +160,14 @@ static void builtin_jobs_print(const job_t *j, int mode, int header)
*/
static int builtin_jobs(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
int argc=0;
int found=0;
int mode=JOBS_DEFAULT;
int print_last = 0;
argc = builtin_count_args(argv);
woptind=0;
w.woptind=0;
while (1)
{
@ -201,11 +202,11 @@ static int builtin_jobs(parser_t &parser, wchar_t **argv)
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"pclgh",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"pclgh",
long_options,
&opt_index);
if (opt == -1)
break;
@ -248,7 +249,7 @@ static int builtin_jobs(parser_t &parser, wchar_t **argv)
return 0;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return 1;
}
@ -283,13 +284,13 @@ static int builtin_jobs(parser_t &parser, wchar_t **argv)
}
else
{
if (woptind < argc)
if (w.woptind < argc)
{
int i;
found = 1;
for (i=woptind; i<argc; i++)
for (i=w.woptind; i<argc; i++)
{
int pid;
wchar_t *end;

View file

@ -396,6 +396,7 @@ static void print_variables(int include_values, int esc, bool shorten_ok, int sc
*/
static int builtin_set(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
/** Variables used for parsing the argument list */
const struct woption long_options[] =
{
@ -439,10 +440,10 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
/* Parse options to obtain the requested operation and the modifiers */
woptind = 0;
w.woptind = 0;
while (1)
{
int c = wgetopt_long(argc, argv, short_options, long_options, 0);
int c = w.wgetopt_long(argc, argv, short_options, long_options, 0);
if (c == -1)
{
@ -498,7 +499,7 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
return 0;
case '?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return 1;
default:
@ -573,7 +574,7 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
out of the specified variables.
*/
int i;
for (i=woptind; i<argc; i++)
for (i=w.woptind; i<argc; i++)
{
wchar_t *arg = argv[i];
int slice=0;
@ -635,7 +636,7 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
return 0;
}
if (woptind == argc)
if (w.woptind == argc)
{
/*
Print values of variables
@ -658,7 +659,7 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
return retcode;
}
if (!(dest = wcsdup(argv[woptind])))
if (!(dest = wcsdup(argv[w.woptind])))
{
DIE_MEM();
}
@ -711,9 +712,9 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
if (!retcode)
{
for (; woptind<argc; woptind++)
for (; w.woptind<argc; w.woptind++)
{
if (!parse_index(indexes, argv[woptind], dest, result.size()))
if (!parse_index(indexes, argv[w.woptind], dest, result.size()))
{
builtin_print_help(parser, argv[0], stderr_buffer);
retcode = 1;
@ -721,7 +722,7 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
}
size_t idx_count = indexes.size();
size_t val_count = argc-woptind-1;
size_t val_count = argc-w.woptind-1;
if (!erase)
{
@ -734,7 +735,7 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
}
if (val_count == idx_count)
{
woptind++;
w.woptind++;
break;
}
}
@ -756,9 +757,9 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
{
wcstring_list_t value;
while (woptind < argc)
while (w.woptind < argc)
{
value.push_back(argv[woptind++]);
value.push_back(argv[w.woptind++]);
}
if (update_values(result,
@ -778,14 +779,14 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
}
else
{
woptind++;
w.woptind++;
/*
No slicing
*/
if (erase)
{
if (woptind != argc)
if (w.woptind != argc)
{
append_format(stderr_buffer,
_(L"%ls: Values cannot be specfied with erase\n"),
@ -801,7 +802,7 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
else
{
wcstring_list_t val;
for (i=woptind; i<argc; i++)
for (i=w.woptind; i<argc; i++)
val.push_back(argv[i]);
retcode = my_env_set(dest, val, scope);
}

View file

@ -67,6 +67,7 @@ static int set_color_builtin_outputter(char c)
*/
static int builtin_set_color(parser_t &parser, wchar_t **argv)
{
wgetopter_t w;
/** Variables used for parsing the argument list */
const struct woption long_options[] =
{
@ -94,10 +95,10 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
int errret;
/* Parse options to obtain the requested operation and the modifiers */
woptind = 0;
w.woptind = 0;
while (1)
{
int c = wgetopt_long(argc, argv, short_options, long_options, 0);
int c = w.wgetopt_long(argc, argv, short_options, long_options, 0);
if (c == -1)
{
@ -110,7 +111,7 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
break;
case 'b':
bgcolor = woptarg;
bgcolor = w.woptarg;
break;
case 'h':
@ -136,12 +137,12 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
/* Remaining arguments are foreground color */
std::vector<rgb_color_t> fgcolors;
for (; woptind < argc; woptind++)
for (; w.woptind < argc; w.woptind++)
{
rgb_color_t fg = rgb_color_t(argv[woptind]);
rgb_color_t fg = rgb_color_t(argv[w.woptind]);
if (fg.is_none() || fg.is_ignore())
{
append_format(stderr_buffer, _(L"%ls: Unknown color '%ls'\n"), argv[0], argv[woptind]);
append_format(stderr_buffer, _(L"%ls: Unknown color '%ls'\n"), argv[0], argv[w.woptind]);
return STATUS_BUILTIN_ERROR;
}
fgcolors.push_back(fg);

View file

@ -254,6 +254,7 @@ static int set(int resource, int hard, int soft, rlim_t value)
*/
static int builtin_ulimit(parser_t &parser, wchar_t ** argv)
{
wgetopter_t w;
int hard=0;
int soft=0;
@ -262,7 +263,7 @@ static int builtin_ulimit(parser_t &parser, wchar_t ** argv)
int argc = builtin_count_args(argv);
woptind=0;
w.woptind=0;
while (1)
{
@ -334,11 +335,11 @@ static int builtin_ulimit(parser_t &parser, wchar_t ** argv)
int opt_index = 0;
int opt = wgetopt_long(argc,
argv,
L"aHScdflmnstuvh",
long_options,
&opt_index);
int opt = w.wgetopt_long(argc,
argv,
L"aHScdflmnstuvh",
long_options,
&opt_index);
if (opt == -1)
break;
@ -419,14 +420,14 @@ static int builtin_ulimit(parser_t &parser, wchar_t ** argv)
return 0;
case L'?':
builtin_unknown_option(parser, argv[0], argv[woptind-1]);
builtin_unknown_option(parser, argv[0], argv[w.woptind-1]);
return 1;
}
}
if (report_all)
{
if (argc - woptind == 0)
if (argc - w.woptind == 0)
{
print_all(hard);
}
@ -441,7 +442,7 @@ static int builtin_ulimit(parser_t &parser, wchar_t ** argv)
return 0;
}
switch (argc - woptind)
switch (argc - w.woptind)
{
case 0:
{
@ -468,28 +469,28 @@ static int builtin_ulimit(parser_t &parser, wchar_t ** argv)
hard=soft=1;
}
if (wcscasecmp(argv[woptind], L"unlimited")==0)
if (wcscasecmp(argv[w.woptind], L"unlimited")==0)
{
new_limit = RLIM_INFINITY;
}
else if (wcscasecmp(argv[woptind], L"hard")==0)
else if (wcscasecmp(argv[w.woptind], L"hard")==0)
{
new_limit = get(what, 1);
}
else if (wcscasecmp(argv[woptind], L"soft")==0)
else if (wcscasecmp(argv[w.woptind], L"soft")==0)
{
new_limit = get(what, soft);
}
else
{
errno=0;
new_limit = wcstol(argv[woptind], &end, 10);
new_limit = wcstol(argv[w.woptind], &end, 10);
if (errno || *end)
{
append_format(stderr_buffer,
L"%ls: Invalid limit '%ls'\n",
argv[0],
argv[woptind]);
argv[w.woptind]);
builtin_print_help(parser, argv[0], stderr_buffer);
return 1;
}

View file

View file

View file

@ -861,21 +861,21 @@ static int wcsncasecmp_fallback(const wchar_t *a, const wchar_t *b, size_t count
/* Note parens avoid the macro expansion */
wchar_t *wcsdup_use_weak(const wchar_t *a)
{
if (wcsdup != NULL)
if (&wcsdup != NULL)
return (wcsdup)(a);
return wcsdup_fallback(a);
}
int wcscasecmp_use_weak(const wchar_t *a, const wchar_t *b)
{
if (wcscasecmp != NULL)
if (&wcscasecmp != NULL)
return (wcscasecmp)(a, b);
return wcscasecmp_fallback(a, b);
}
int wcsncasecmp_use_weak(const wchar_t *s1, const wchar_t *s2, size_t n)
{
if (wcsncasecmp != NULL)
if (&wcsncasecmp != NULL)
return (wcsncasecmp)(s1, s2, n);
return wcsncasecmp_fallback(s1, s2, n);
}

View file

View file

View file

View file

View file

View file

Some files were not shown because too many files have changed in this diff Show more