aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile.in416
-rwxr-xr-xbuild_tools/cppcheck.sh3
-rw-r--r--fish.xcodeproj/project.pbxproj5
-rw-r--r--fish.xcodeproj/xcshareddata/xcschemes/Makefile.xcscheme2
-rw-r--r--fish.xcodeproj/xcshareddata/xcschemes/base.xcscheme2
-rw-r--r--fish.xcodeproj/xcshareddata/xcschemes/fish.app.xcscheme2
-rw-r--r--fish.xcodeproj/xcshareddata/xcschemes/fish_tests.xcscheme2
-rw-r--r--fish.xcodeproj/xcshareddata/xcschemes/install_tree.xcscheme2
-rw-r--r--share/completions/grep.fish1
-rw-r--r--src/autoload.cpp (renamed from autoload.cpp)0
-rw-r--r--src/autoload.h (renamed from autoload.h)0
-rw-r--r--src/builtin.cpp (renamed from builtin.cpp)316
-rw-r--r--src/builtin.h (renamed from builtin.h)0
-rw-r--r--src/builtin_commandline.cpp (renamed from builtin_commandline.cpp)44
-rw-r--r--src/builtin_complete.cpp (renamed from builtin_complete.cpp)37
-rw-r--r--src/builtin_jobs.cpp (renamed from builtin_jobs.cpp)19
-rw-r--r--src/builtin_printf.cpp (renamed from builtin_printf.cpp)0
-rw-r--r--src/builtin_set.cpp (renamed from builtin_set.cpp)31
-rw-r--r--src/builtin_set_color.cpp (renamed from builtin_set_color.cpp)13
-rw-r--r--src/builtin_test.cpp (renamed from builtin_test.cpp)0
-rw-r--r--src/builtin_ulimit.cpp (renamed from builtin_ulimit.cpp)29
-rw-r--r--src/color.cpp (renamed from color.cpp)0
-rw-r--r--src/color.h (renamed from color.h)0
-rw-r--r--src/common.cpp (renamed from common.cpp)0
-rw-r--r--src/common.h (renamed from common.h)0
-rw-r--r--src/complete.cpp (renamed from complete.cpp)0
-rw-r--r--src/complete.h (renamed from complete.h)0
-rw-r--r--src/env.cpp (renamed from env.cpp)0
-rw-r--r--src/env.h (renamed from env.h)0
-rw-r--r--src/env_universal_common.cpp (renamed from env_universal_common.cpp)0
-rw-r--r--src/env_universal_common.h (renamed from env_universal_common.h)0
-rw-r--r--src/event.cpp (renamed from event.cpp)0
-rw-r--r--src/event.h (renamed from event.h)0
-rw-r--r--src/exec.cpp (renamed from exec.cpp)0
-rw-r--r--src/exec.h (renamed from exec.h)0
-rw-r--r--src/expand.cpp (renamed from expand.cpp)0
-rw-r--r--src/expand.h (renamed from expand.h)0
-rw-r--r--src/fallback.cpp (renamed from fallback.cpp)6
-rw-r--r--src/fallback.h (renamed from fallback.h)0
-rw-r--r--src/fish.cpp (renamed from fish.cpp)0
-rw-r--r--src/fish_indent.cpp (renamed from fish_indent.cpp)0
-rw-r--r--src/fish_tests.cpp (renamed from fish_tests.cpp)0
-rw-r--r--src/fish_version.cpp (renamed from fish_version.cpp)0
-rw-r--r--src/fish_version.h (renamed from fish_version.h)0
-rw-r--r--src/function.cpp (renamed from function.cpp)0
-rw-r--r--src/function.h (renamed from function.h)0
-rw-r--r--src/highlight.cpp (renamed from highlight.cpp)0
-rw-r--r--src/highlight.h (renamed from highlight.h)0
-rw-r--r--src/history.cpp (renamed from history.cpp)0
-rw-r--r--src/history.h (renamed from history.h)0
-rw-r--r--src/input.cpp (renamed from input.cpp)0
-rw-r--r--src/input.h (renamed from input.h)0
-rw-r--r--src/input_common.cpp (renamed from input_common.cpp)0
-rw-r--r--src/input_common.h (renamed from input_common.h)0
-rw-r--r--src/intern.cpp (renamed from intern.cpp)0
-rw-r--r--src/intern.h (renamed from intern.h)0
-rw-r--r--src/io.cpp (renamed from io.cpp)0
-rw-r--r--src/io.h (renamed from io.h)0
-rw-r--r--src/iothread.cpp (renamed from iothread.cpp)0
-rw-r--r--src/iothread.h (renamed from iothread.h)0
-rw-r--r--src/key_reader.cpp (renamed from key_reader.cpp)0
-rw-r--r--src/kill.cpp (renamed from kill.cpp)0
-rw-r--r--src/kill.h (renamed from kill.h)0
-rw-r--r--src/lru.h (renamed from lru.h)0
-rw-r--r--src/output.cpp (renamed from output.cpp)0
-rw-r--r--src/output.h (renamed from output.h)0
-rw-r--r--src/pager.cpp (renamed from pager.cpp)0
-rw-r--r--src/pager.h (renamed from pager.h)0
-rw-r--r--src/parse_constants.h (renamed from parse_constants.h)0
-rw-r--r--src/parse_execution.cpp (renamed from parse_execution.cpp)0
-rw-r--r--src/parse_execution.h (renamed from parse_execution.h)0
-rw-r--r--src/parse_productions.cpp (renamed from parse_productions.cpp)0
-rw-r--r--src/parse_productions.h (renamed from parse_productions.h)0
-rw-r--r--src/parse_tree.cpp (renamed from parse_tree.cpp)0
-rw-r--r--src/parse_tree.h (renamed from parse_tree.h)0
-rw-r--r--src/parse_util.cpp (renamed from parse_util.cpp)0
-rw-r--r--src/parse_util.h (renamed from parse_util.h)0
-rw-r--r--src/parser.cpp (renamed from parser.cpp)0
-rw-r--r--src/parser.h (renamed from parser.h)0
-rw-r--r--src/parser_keywords.cpp (renamed from parser_keywords.cpp)0
-rw-r--r--src/parser_keywords.h (renamed from parser_keywords.h)0
-rw-r--r--src/path.cpp (renamed from path.cpp)0
-rw-r--r--src/path.h (renamed from path.h)0
-rw-r--r--src/postfork.cpp (renamed from postfork.cpp)0
-rw-r--r--src/postfork.h (renamed from postfork.h)0
-rw-r--r--src/print_help.cpp (renamed from print_help.cpp)0
-rw-r--r--src/print_help.h (renamed from print_help.h)0
-rw-r--r--src/proc.cpp (renamed from proc.cpp)0
-rw-r--r--src/proc.h (renamed from proc.h)0
-rw-r--r--src/reader.cpp (renamed from reader.cpp)0
-rw-r--r--src/reader.h (renamed from reader.h)0
-rw-r--r--src/sanity.cpp (renamed from sanity.cpp)0
-rw-r--r--src/sanity.h (renamed from sanity.h)0
-rw-r--r--src/screen.cpp (renamed from screen.cpp)0
-rw-r--r--src/screen.h (renamed from screen.h)0
-rw-r--r--src/signal.cpp (renamed from signal.cpp)0
-rw-r--r--src/signal.h (renamed from signal.h)0
-rw-r--r--src/tokenizer.cpp (renamed from tokenizer.cpp)0
-rw-r--r--src/tokenizer.h (renamed from tokenizer.h)0
-rw-r--r--src/utf8.cpp (renamed from utf8.cpp)0
-rw-r--r--src/utf8.h (renamed from utf8.h)0
-rw-r--r--src/util.cpp (renamed from util.cpp)0
-rw-r--r--src/util.h (renamed from util.h)0
-rw-r--r--src/wcstringutil.cpp (renamed from wcstringutil.cpp)0
-rw-r--r--src/wcstringutil.h (renamed from wcstringutil.h)0
-rw-r--r--src/wgetopt.cpp (renamed from wgetopt.cpp)122
-rw-r--r--src/wgetopt.h218
-rw-r--r--src/wildcard.cpp (renamed from wildcard.cpp)0
-rw-r--r--src/wildcard.h (renamed from wildcard.h)0
-rw-r--r--src/wutil.cpp (renamed from wutil.cpp)13
-rw-r--r--src/wutil.h (renamed from wutil.h)0
-rw-r--r--wgetopt.h210
113 files changed, 733 insertions, 761 deletions
diff --git a/.gitignore b/.gitignore
index 13d5ce32..e95e3b90 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,4 +39,5 @@ messages.pot
lexicon.txt
lexicon_filter
lexicon.log
+DerivedData/
diff --git a/Makefile.in b/Makefile.in
index ba315aa9..f6bc306d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -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@
@@ -73,42 +73,45 @@ HAVE_GETTEXT=@HAVE_GETTEXT@
HAVE_DOXYGEN=@HAVE_DOXYGEN@
#
-#Additional .cpp files used by common.o. These also have a corresponding
-#.h file.
+# All objects that the system needs to build fish, except fish.o
#
-COMMON_FILES := util.cpp fallback.cpp
+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 := obj/fish_indent.o obj/print_help.o $(FISH_OBJS)
#
-# All objects that the system needs to build fish, except fish.o
+# Additional files used by builtin.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
+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
-FISH_INDENT_OBJS := fish_indent.o print_help.o $(FISH_OBJS)
#
-# Additional files used by builtin.o
+# All objects that the system needs to build fish_tests
#
-BUILTIN_FILES := builtin_set.cpp builtin_commandline.cpp \
- builtin_ulimit.cpp builtin_complete.cpp builtin_jobs.cpp \
- builtin_set_color.cpp builtin_printf.cpp
+FISH_TESTS_OBJS := $(FISH_OBJS) obj/fish_tests.o
#
-# All objects that the system needs to build fish_tests
+# All of the sources that produce object files
+# (that is, are not themselves #included in other source files)
#
-
-FISH_TESTS_OBJS := $(FISH_OBJS) fish_tests.o
+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
@@ -762,11 +763,23 @@ uninstall-translations:
#
#
+# 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
diff --git a/build_tools/cppcheck.sh b/build_tools/cppcheck.sh
new file mode 100755
index 00000000..658f35c4
--- /dev/null
+++ b/build_tools/cppcheck.sh
@@ -0,0 +1,3 @@
+#!/usr/local/bin/fish
+
+cppcheck --enable=all --std=posix --quiet .
diff --git a/fish.xcodeproj/project.pbxproj b/fish.xcodeproj/project.pbxproj
index 9fac7d80..be2b8390 100644
--- a/fish.xcodeproj/project.pbxproj
+++ b/fish.xcodeproj/project.pbxproj
@@ -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";
diff --git a/fish.xcodeproj/xcshareddata/xcschemes/Makefile.xcscheme b/fish.xcodeproj/xcshareddata/xcschemes/Makefile.xcscheme
index ffcdc16a..489ced05 100644
--- a/fish.xcodeproj/xcshareddata/xcschemes/Makefile.xcscheme
+++ b/fish.xcodeproj/xcshareddata/xcschemes/Makefile.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0630"
+ LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/fish.xcodeproj/xcshareddata/xcschemes/base.xcscheme b/fish.xcodeproj/xcshareddata/xcschemes/base.xcscheme
index 37ccb910..5ffa4282 100644
--- a/fish.xcodeproj/xcshareddata/xcschemes/base.xcscheme
+++ b/fish.xcodeproj/xcshareddata/xcschemes/base.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0630"
+ LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/fish.xcodeproj/xcshareddata/xcschemes/fish.app.xcscheme b/fish.xcodeproj/xcshareddata/xcschemes/fish.app.xcscheme
index b3cdd927..e24ea7c6 100644
--- a/fish.xcodeproj/xcshareddata/xcschemes/fish.app.xcscheme
+++ b/fish.xcodeproj/xcshareddata/xcschemes/fish.app.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0630"
+ LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/fish.xcodeproj/xcshareddata/xcschemes/fish_tests.xcscheme b/fish.xcodeproj/xcshareddata/xcschemes/fish_tests.xcscheme
index eb544553..46b88891 100644
--- a/fish.xcodeproj/xcshareddata/xcschemes/fish_tests.xcscheme
+++ b/fish.xcodeproj/xcshareddata/xcschemes/fish_tests.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0630"
+ LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/fish.xcodeproj/xcshareddata/xcschemes/install_tree.xcscheme b/fish.xcodeproj/xcshareddata/xcschemes/install_tree.xcscheme
index 13050dae..cfeca409 100644
--- a/fish.xcodeproj/xcshareddata/xcschemes/install_tree.xcscheme
+++ b/fish.xcodeproj/xcshareddata/xcschemes/install_tree.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0630"
+ LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/share/completions/grep.fish b/share/completions/grep.fish
index bd52fc60..07172a91 100644
--- a/share/completions/grep.fish
+++ b/share/completions/grep.fish
@@ -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
diff --git a/autoload.cpp b/src/autoload.cpp
index 0028b184..0028b184 100644
--- a/autoload.cpp
+++ b/src/autoload.cpp
diff --git a/autoload.h b/src/autoload.h
index 610efed0..610efed0 100644
--- a/autoload.h
+++ b/src/autoload.h
diff --git a/builtin.cpp b/src/builtin.cpp
index e6b3c414..6a88ef5b 100644
--- a/builtin.cpp
+++ b/src/builtin.cpp
@@ -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);
diff --git a/builtin.h b/src/builtin.h
index ca0f4f30..ca0f4f30 100644
--- a/builtin.h
+++ b/src/builtin.h
diff --git a/builtin_commandline.cpp b/src/builtin_commandline.cpp
index 01bc123a..23aaaa52 100644
--- a/builtin_commandline.cpp
+++ b/src/builtin_commandline.cpp
@@ -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]);
diff --git a/builtin_complete.cpp b/src/builtin_complete.cpp
index b11ad7bf..6c4ccbcb 100644
--- a/builtin_complete.cpp
+++ b/src/builtin_complete.cpp
@@ -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"),
diff --git a/builtin_jobs.cpp b/src/builtin_jobs.cpp
index 02bf94f2..32079287 100644
--- a/builtin_jobs.cpp
+++ b/src/builtin_jobs.cpp
@@ -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;
diff --git a/builtin_printf.cpp b/src/builtin_printf.cpp
index 916166b0..916166b0 100644
--- a/builtin_printf.cpp
+++ b/src/builtin_printf.cpp
diff --git a/builtin_set.cpp b/src/builtin_set.cpp
index b1b6b0ea..c7bde4fb 100644
--- a/builtin_set.cpp
+++ b/src/builtin_set.cpp
@@ -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);
}
diff --git a/builtin_set_color.cpp b/src/builtin_set_color.cpp
index 36ad7080..7f400543 100644
--- a/builtin_set_color.cpp
+++ b/src/builtin_set_color.cpp
@@ -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);
diff --git a/builtin_test.cpp b/src/builtin_test.cpp
index 84d5fa9c..84d5fa9c 100644
--- a/builtin_test.cpp
+++ b/src/builtin_test.cpp
diff --git a/builtin_ulimit.cpp b/src/builtin_ulimit.cpp
index 23524543..64b126b7 100644
--- a/builtin_ulimit.cpp
+++ b/src/builtin_ulimit.cpp
@@ -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;
}
diff --git a/color.cpp b/src/color.cpp
index d076ea17..d076ea17 100644
--- a/color.cpp
+++ b/src/color.cpp
diff --git a/color.h b/src/color.h
index 988bfdb8..988bfdb8 100644
--- a/color.h
+++ b/src/color.h
diff --git a/common.cpp b/src/common.cpp
index ea1cc4e3..ea1cc4e3 100644
--- a/common.cpp
+++ b/src/common.cpp
diff --git a/common.h b/src/common.h
index e27968fd..e27968fd 100644
--- a/common.h
+++ b/src/common.h
diff --git a/complete.cpp b/src/complete.cpp
index 877ac984..877ac984 100644
--- a/complete.cpp
+++ b/src/complete.cpp
diff --git a/complete.h b/src/complete.h
index c1e156e1..c1e156e1 100644
--- a/complete.h
+++ b/src/complete.h
diff --git a/env.cpp b/src/env.cpp
index 649e0f2a..649e0f2a 100644
--- a/env.cpp
+++ b/src/env.cpp
diff --git a/env.h b/src/env.h
index 411b51ec..411b51ec 100644
--- a/env.h
+++ b/src/env.h
diff --git a/env_universal_common.cpp b/src/env_universal_common.cpp
index d29381f5..d29381f5 100644
--- a/env_universal_common.cpp
+++ b/src/env_universal_common.cpp
diff --git a/env_universal_common.h b/src/env_universal_common.h
index 7aca60df..7aca60df 100644
--- a/env_universal_common.h
+++ b/src/env_universal_common.h
diff --git a/event.cpp b/src/event.cpp
index eeff3eb5..eeff3eb5 100644
--- a/event.cpp
+++ b/src/event.cpp
diff --git a/event.h b/src/event.h
index 80737596..80737596 100644
--- a/event.h
+++ b/src/event.h
diff --git a/exec.cpp b/src/exec.cpp
index d6df94e6..d6df94e6 100644
--- a/exec.cpp
+++ b/src/exec.cpp
diff --git a/exec.h b/src/exec.h
index 41dc3193..41dc3193 100644
--- a/exec.h
+++ b/src/exec.h
diff --git a/expand.cpp b/src/expand.cpp
index 6d978582..6d978582 100644
--- a/expand.cpp
+++ b/src/expand.cpp
diff --git a/expand.h b/src/expand.h
index 8fe80b3b..8fe80b3b 100644
--- a/expand.h
+++ b/src/expand.h
diff --git a/fallback.cpp b/src/fallback.cpp
index 44019814..0f53e1a8 100644
--- a/fallback.cpp
+++ b/src/fallback.cpp
@@ -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);
}
diff --git a/fallback.h b/src/fallback.h
index 7d3afa13..7d3afa13 100644
--- a/fallback.h
+++ b/src/fallback.h
diff --git a/fish.cpp b/src/fish.cpp
index a50e0886..a50e0886 100644
--- a/fish.cpp
+++ b/src/fish.cpp
diff --git a/fish_indent.cpp b/src/fish_indent.cpp
index 59efbd1e..59efbd1e 100644
--- a/fish_indent.cpp
+++ b/src/fish_indent.cpp
diff --git a/fish_tests.cpp b/src/fish_tests.cpp
index c0b4a9f4..c0b4a9f4 100644
--- a/fish_tests.cpp
+++ b/src/fish_tests.cpp
diff --git a/fish_version.cpp b/src/fish_version.cpp
index e434c3c8..e434c3c8 100644
--- a/fish_version.cpp
+++ b/src/fish_version.cpp
diff --git a/fish_version.h b/src/fish_version.h
index 61938c16..61938c16 100644
--- a/fish_version.h
+++ b/src/fish_version.h
diff --git a/function.cpp b/src/function.cpp
index 2a8c20be..2a8c20be 100644
--- a/function.cpp
+++ b/src/function.cpp
diff --git a/function.h b/src/function.h
index cd3f6f5a..cd3f6f5a 100644
--- a/function.h
+++ b/src/function.h
diff --git a/highlight.cpp b/src/highlight.cpp
index e07c7040..e07c7040 100644
--- a/highlight.cpp
+++ b/src/highlight.cpp
diff --git a/highlight.h b/src/highlight.h
index 9b89c0f2..9b89c0f2 100644
--- a/highlight.h
+++ b/src/highlight.h
diff --git a/history.cpp b/src/history.cpp
index c526eb39..c526eb39 100644
--- a/history.cpp
+++ b/src/history.cpp
diff --git a/history.h b/src/history.h
index 7f04890e..7f04890e 100644
--- a/history.h
+++ b/src/history.h
diff --git a/input.cpp b/src/input.cpp
index 2629506f..2629506f 100644
--- a/input.cpp
+++ b/src/input.cpp
diff --git a/input.h b/src/input.h
index 38facddb..38facddb 100644
--- a/input.h
+++ b/src/input.h
diff --git a/input_common.cpp b/src/input_common.cpp
index 24fde6e2..24fde6e2 100644
--- a/input_common.cpp
+++ b/src/input_common.cpp
diff --git a/input_common.h b/src/input_common.h
index 5ec34b39..5ec34b39 100644
--- a/input_common.h
+++ b/src/input_common.h
diff --git a/intern.cpp b/src/intern.cpp
index 2ec0af8a..2ec0af8a 100644
--- a/intern.cpp
+++ b/src/intern.cpp
diff --git a/intern.h b/src/intern.h
index b9d07526..b9d07526 100644
--- a/intern.h
+++ b/src/intern.h
diff --git a/io.cpp b/src/io.cpp
index a013b9ef..a013b9ef 100644
--- a/io.cpp
+++ b/src/io.cpp
diff --git a/io.h b/src/io.h
index 86fc7962..86fc7962 100644
--- a/io.h
+++ b/src/io.h
diff --git a/iothread.cpp b/src/iothread.cpp
index 7a37b63b..7a37b63b 100644
--- a/iothread.cpp
+++ b/src/iothread.cpp
diff --git a/iothread.h b/src/iothread.h
index bdec2195..bdec2195 100644
--- a/iothread.h
+++ b/src/iothread.h
diff --git a/key_reader.cpp b/src/key_reader.cpp
index 382f4b22..382f4b22 100644
--- a/key_reader.cpp
+++ b/src/key_reader.cpp
diff --git a/kill.cpp b/src/kill.cpp
index 22f21475..22f21475 100644
--- a/kill.cpp
+++ b/src/kill.cpp
diff --git a/kill.h b/src/kill.h
index 686122a2..686122a2 100644
--- a/kill.h
+++ b/src/kill.h
diff --git a/lru.h b/src/lru.h
index 779c2edc..779c2edc 100644
--- a/lru.h
+++ b/src/lru.h
diff --git a/output.cpp b/src/output.cpp
index 8f97ce61..8f97ce61 100644
--- a/output.cpp
+++ b/src/output.cpp
diff --git a/output.h b/src/output.h
index a952d8a4..a952d8a4 100644
--- a/output.h
+++ b/src/output.h
diff --git a/pager.cpp b/src/pager.cpp
index a5cf0ecc..a5cf0ecc 100644
--- a/pager.cpp
+++ b/src/pager.cpp
diff --git a/pager.h b/src/pager.h
index 61c37ce6..61c37ce6 100644
--- a/pager.h
+++ b/src/pager.h
diff --git a/parse_constants.h b/src/parse_constants.h
index 552085f8..552085f8 100644
--- a/parse_constants.h
+++ b/src/parse_constants.h
diff --git a/parse_execution.cpp b/src/parse_execution.cpp
index 8381958f..8381958f 100644
--- a/parse_execution.cpp
+++ b/src/parse_execution.cpp
diff --git a/parse_execution.h b/src/parse_execution.h
index 7e1c1f46..7e1c1f46 100644
--- a/parse_execution.h
+++ b/src/parse_execution.h
diff --git a/parse_productions.cpp b/src/parse_productions.cpp
index 0d28c6a1..0d28c6a1 100644
--- a/parse_productions.cpp
+++ b/src/parse_productions.cpp
diff --git a/parse_productions.h b/src/parse_productions.h
index 1d64ccfc..1d64ccfc 100644
--- a/parse_productions.h
+++ b/src/parse_productions.h
diff --git a/parse_tree.cpp b/src/parse_tree.cpp
index f357d5ff..f357d5ff 100644
--- a/parse_tree.cpp
+++ b/src/parse_tree.cpp
diff --git a/parse_tree.h b/src/parse_tree.h
index e4d4eb36..e4d4eb36 100644
--- a/parse_tree.h
+++ b/src/parse_tree.h
diff --git a/parse_util.cpp b/src/parse_util.cpp
index 10388cb7..10388cb7 100644
--- a/parse_util.cpp
+++ b/src/parse_util.cpp
diff --git a/parse_util.h b/src/parse_util.h
index 760d4477..760d4477 100644
--- a/parse_util.h
+++ b/src/parse_util.h
diff --git a/parser.cpp b/src/parser.cpp
index 2e5ebe75..2e5ebe75 100644
--- a/parser.cpp
+++ b/src/parser.cpp
diff --git a/parser.h b/src/parser.h
index ba0edd6a..ba0edd6a 100644
--- a/parser.h
+++ b/src/parser.h
diff --git a/parser_keywords.cpp b/src/parser_keywords.cpp
index adf9c40c..adf9c40c 100644
--- a/parser_keywords.cpp
+++ b/src/parser_keywords.cpp
diff --git a/parser_keywords.h b/src/parser_keywords.h
index 94cd0eb7..94cd0eb7 100644
--- a/parser_keywords.h
+++ b/src/parser_keywords.h
diff --git a/path.cpp b/src/path.cpp
index 62a31a63..62a31a63 100644
--- a/path.cpp
+++ b/src/path.cpp
diff --git a/path.h b/src/path.h
index eb79ee8a..eb79ee8a 100644
--- a/path.h
+++ b/src/path.h
diff --git a/postfork.cpp b/src/postfork.cpp
index 9416b35d..9416b35d 100644
--- a/postfork.cpp
+++ b/src/postfork.cpp
diff --git a/postfork.h b/src/postfork.h
index c277da52..c277da52 100644
--- a/postfork.h
+++ b/src/postfork.h
diff --git a/print_help.cpp b/src/print_help.cpp
index da401134..da401134 100644
--- a/print_help.cpp
+++ b/src/print_help.cpp
diff --git a/print_help.h b/src/print_help.h
index 005800b1..005800b1 100644
--- a/print_help.h
+++ b/src/print_help.h
diff --git a/proc.cpp b/src/proc.cpp
index 0a0da0a8..0a0da0a8 100644
--- a/proc.cpp
+++ b/src/proc.cpp
diff --git a/proc.h b/src/proc.h
index 8dd66c7c..8dd66c7c 100644
--- a/proc.h
+++ b/src/proc.h
diff --git a/reader.cpp b/src/reader.cpp
index eaf5829f..eaf5829f 100644
--- a/reader.cpp
+++ b/src/reader.cpp
diff --git a/reader.h b/src/reader.h
index b4a159be..b4a159be 100644
--- a/reader.h
+++ b/src/reader.h
diff --git a/sanity.cpp b/src/sanity.cpp
index e918c805..e918c805 100644
--- a/sanity.cpp
+++ b/src/sanity.cpp
diff --git a/sanity.h b/src/sanity.h
index 7480c403..7480c403 100644
--- a/sanity.h
+++ b/src/sanity.h
diff --git a/screen.cpp b/src/screen.cpp
index 1971bb57..1971bb57 100644
--- a/screen.cpp
+++ b/src/screen.cpp
diff --git a/screen.h b/src/screen.h
index e84d8497..e84d8497 100644
--- a/screen.h
+++ b/src/screen.h
diff --git a/signal.cpp b/src/signal.cpp
index b13f0c01..b13f0c01 100644
--- a/signal.cpp
+++ b/src/signal.cpp
diff --git a/signal.h b/src/signal.h
index fc3e7e73..fc3e7e73 100644
--- a/signal.h
+++ b/src/signal.h
diff --git a/tokenizer.cpp b/src/tokenizer.cpp
index 319eb2d9..319eb2d9 100644
--- a/tokenizer.cpp
+++ b/src/tokenizer.cpp
diff --git a/tokenizer.h b/src/tokenizer.h
index 09a49509..09a49509 100644
--- a/tokenizer.h
+++ b/src/tokenizer.h
diff --git a/utf8.cpp b/src/utf8.cpp
index 62453be4..62453be4 100644
--- a/utf8.cpp
+++ b/src/utf8.cpp
diff --git a/utf8.h b/src/utf8.h
index 1c9923db..1c9923db 100644
--- a/utf8.h
+++ b/src/utf8.h
diff --git a/util.cpp b/src/util.cpp
index 85b9d8d7..85b9d8d7 100644
--- a/util.cpp
+++ b/src/util.cpp
diff --git a/util.h b/src/util.h
index ee7142be..ee7142be 100644
--- a/util.h
+++ b/src/util.h
diff --git a/wcstringutil.cpp b/src/wcstringutil.cpp
index e61e331b..e61e331b 100644
--- a/wcstringutil.cpp
+++ b/src/wcstringutil.cpp
diff --git a/wcstringutil.h b/src/wcstringutil.h
index 4d19fc0b..4d19fc0b 100644
--- a/wcstringutil.h
+++ b/src/wcstringutil.h
diff --git a/wgetopt.cpp b/src/wgetopt.cpp
index 4e4a7241..9cbe5418 100644
--- a/wgetopt.cpp
+++ b/src/wgetopt.cpp
@@ -79,9 +79,6 @@
when it is done, all the options precede everything else. Thus
all application programs are extended to handle flexible argument order.
- Setting the environment variable POSIXLY_CORRECT disables permutation.
- Then the behavior is completely standard.
-
GNU application programs can use a third alternative mode in which
they can distinguish the relative order of options and other arguments. */
@@ -90,87 +87,6 @@
#include "fallback.h" // IWYU pragma: keep
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-wchar_t *woptarg = NULL;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `woptind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-/* XXX 1003.2 says this must be 1 before any call. */
-int woptind = 0;
-
-/* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
-
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
-
-static wchar_t *nextchar;
-
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int wopterr = 1;
-
-/* Set to an option character which was unrecognized.
- This must be initialized on some systems to avoid linking in the
- system's own getopt implementation. */
-
-int woptopt = '?';
-
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
-If the caller did not specify anything,
-the default is REQUIRE_ORDER if the environment variable
-POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
-REQUIRE_ORDER means don't recognize them as options;
-stop option processing when the first non-option is seen.
-This is what Unix does.
-This mode of operation is selected by either setting the environment
-variable POSIXLY_CORRECT, or using `+' as the first character
-of the list of option characters.
-
-PERMUTE is the default. We permute the contents of ARGV as we scan,
-so that eventually all the non-options are at the end. This allows options
-to be given in any order, even with programs that were not written to
-expect this.
-
-RETURN_IN_ORDER is an option available to programs that were written
-to expect options and other ARGV-elements in any order and that care about
-the ordering of the two. We describe each non-option ARGV-element
-as if it were the argument of an option with character code 1.
-Using `-' as the first character of the list of option characters
-selects this mode of operation.
-
-The special argument `--' forces an end of option-scanning regardless
-of the value of `ordering'. In the case of RETURN_IN_ORDER, only
-`--' can cause `getopt' to return EOF with `woptind' != ARGC. */
-
-static enum
-{
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-/* Value of POSIXLY_CORRECT environment variable. */
-static char *posixly_correct;
-
/**
Use translation functions if available
*/
@@ -228,14 +144,6 @@ extern int wcslen(const wchar_t *);
#endif /* not __GNU_LIBRARY__ */
-/* Handle permutation of arguments. */
-
-/* Describe the part of ARGV that contains non-options that have
- been skipped. `first_nonopt' is the index in ARGV of the first of them;
- `last_nonopt' is the index after the last of them. */
-
-static int first_nonopt;
-static int last_nonopt;
/* Exchange two adjacent subsequences of ARGV.
One subsequence is elements [first_nonopt,last_nonopt)
@@ -246,8 +154,7 @@ static int last_nonopt;
`first_nonopt' and `last_nonopt' are relocated so that they describe
the new indices of the non-options in ARGV after they are moved. */
-static void
-exchange(wchar_t **argv)
+void wgetopter_t::exchange(wchar_t **argv)
{
int bottom = first_nonopt;
int middle = last_nonopt;
@@ -303,8 +210,7 @@ exchange(wchar_t **argv)
/* Initialize the internal data when the first call is made. */
-static const wchar_t *
-_wgetopt_initialize(const wchar_t *optstring)
+const wchar_t * wgetopter_t::_wgetopt_initialize(const wchar_t *optstring)
{
/* Start processing options with ARGV-element 1 (since ARGV-element 0
is the program name); the sequence of previously skipped
@@ -314,8 +220,6 @@ _wgetopt_initialize(const wchar_t *optstring)
nextchar = NULL;
- posixly_correct = getenv("POSIXLY_CORRECT");
-
/* Determine how to handle the ordering of options and nonoptions. */
if (optstring[0] == '-')
@@ -328,8 +232,6 @@ _wgetopt_initialize(const wchar_t *optstring)
ordering = REQUIRE_ORDER;
++optstring;
}
- else if (posixly_correct != NULL)
- ordering = REQUIRE_ORDER;
else
ordering = PERMUTE;
@@ -363,7 +265,7 @@ _wgetopt_initialize(const wchar_t *optstring)
so the following text in the same ARGV-element, or the text of the following
ARGV-element, is returned in `optarg'. Two colons mean an option that
wants an optional arg; if there is text in the current ARGV-element,
- it is returned in `woptarg', otherwise `woptarg' is set to zero.
+ it is returned in `w.woptarg', otherwise `w.woptarg' is set to zero.
If OPTSTRING starts with `-' or `+', it requests different methods of
handling the non-option ARGV-elements.
@@ -392,8 +294,7 @@ _wgetopt_initialize(const wchar_t *optstring)
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
long-named options. */
-int
-_wgetopt_internal(int argc, wchar_t *const *argv, const wchar_t *optstring, const struct woption *longopts, int *longind, int long_only)
+int wgetopter_t::_wgetopt_internal(int argc, wchar_t *const *argv, const wchar_t *optstring, const struct woption *longopts, int *longind, int long_only)
{
woptarg = NULL;
@@ -626,11 +527,7 @@ _wgetopt_internal(int argc, wchar_t *const *argv, const wchar_t *optstring, cons
{
if (wopterr)
{
- if (posixly_correct)
- /* 1003.2 specifies the format of this message. */
- fwprintf(stderr, _(L"%ls: Illegal option -- %lc\n"), argv[0], c);
- else
- fwprintf(stderr, _(L"%ls: Invalid option -- %lc\n"), argv[0], c);
+ fwprintf(stderr, _(L"%ls: Invalid option -- %lc\n"), argv[0], c);
}
woptopt = c;
@@ -688,8 +585,7 @@ _wgetopt_internal(int argc, wchar_t *const *argv, const wchar_t *optstring, cons
}
}
-int
-wgetopt(int argc, wchar_t *const *argv, const wchar_t *optstring)
+int wgetopter_t::wgetopt(int argc, wchar_t *const *argv, const wchar_t *optstring)
{
return _wgetopt_internal(argc, argv, optstring,
(const struct woption *) 0,
@@ -697,14 +593,12 @@ wgetopt(int argc, wchar_t *const *argv, const wchar_t *optstring)
0);
}
-int
-wgetopt_long(int argc, wchar_t *const *argv, const wchar_t *options, const struct woption *long_options, int *opt_index)
+int wgetopter_t::wgetopt_long(int argc, wchar_t *const *argv, const wchar_t *options, const struct woption *long_options, int *opt_index)
{
return _wgetopt_internal(argc, argv, options, long_options, opt_index, 0);
}
-int
-wgetopt_long_only(int argc, wchar_t *const *argv, const wchar_t *options, const struct woption *long_options, int *opt_index)
+int wgetopter_t::wgetopt_long_only(int argc, wchar_t *const *argv, const wchar_t *options, const struct woption *long_options, int *opt_index)
{
return _wgetopt_internal(argc, argv, options, long_options, opt_index, 1);
}
diff --git a/src/wgetopt.h b/src/wgetopt.h
new file mode 100644
index 00000000..91d50489
--- /dev/null
+++ b/src/wgetopt.h
@@ -0,0 +1,218 @@
+/** \file wgetopt.h
+ A version of the getopt library for use with wide character strings.
+
+ This is simply the gnu getopt library, but converted for use with
+ wchar_t instead of char. This is not usually useful since the argv
+ array is always defined to be of type char**, but in fish, all
+ internal commands use wide characters and hence this library is
+ useful.
+
+ If you want to use this version of getopt in your program,
+ download the fish sourcecode, available at <a
+ href='http://fishshell.com'>the fish homepage</a>. Extract
+ the sourcode, copy wgetopt.c and wgetopt.h into your program
+ directory, include wgetopt.h in your program, and use all the
+ regular getopt functions, prefixing every function, global
+ variable and structure with a 'w', and use only wide character
+ strings. There are no other functional changes in this version of
+ getopt besides using wide character strings.
+
+ For examples of how to use wgetopt, see the fish builtin
+ functions, many of which are defined in builtin.c.
+
+*/
+
+
+/* Declarations for getopt.
+ Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
+
+This file is part of the GNU C Library. Its master source is NOT part of
+the C library, however. The master source lives in /gd/gnu/lib.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#ifndef FISH_WGETOPT_H
+#define FISH_WGETOPT_H
+
+#include <wchar.h>
+
+class wgetopter_t
+{
+private:
+ void exchange(wchar_t **argv);
+ const wchar_t * _wgetopt_initialize(const wchar_t *optstring);
+ int _wgetopt_internal(int argc, wchar_t *const *argv, const wchar_t *optstring, const struct woption *longopts, int *longind, int long_only);
+
+public:
+ /* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+ wchar_t *woptarg;
+
+ /* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns EOF, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `woptind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+ /* XXX 1003.2 says this must be 1 before any call. */
+ int woptind;
+
+
+ /* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
+
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+
+ wchar_t *nextchar;
+
+ /* Callers store zero here to inhibit the error message
+ for unrecognized options. */
+
+ int wopterr;
+
+ /* Set to an option character which was unrecognized.
+ This must be initialized on some systems to avoid linking in the
+ system's own getopt implementation. */
+
+ int woptopt;
+
+ /* Describe how to deal with options that follow non-option ARGV-elements.
+
+ If the caller did not specify anything,
+ the default is PERMUTE.
+
+ REQUIRE_ORDER means don't recognize them as options;
+ stop option processing when the first non-option is seen.
+ This is what Unix does.
+ This mode of operation is selected by using `+' as the first
+ character of the list of option characters.
+
+ PERMUTE is the default. We permute the contents of ARGV as we scan,
+ so that eventually all the non-options are at the end. This allows options
+ to be given in any order, even with programs that were not written to
+ expect this.
+
+ RETURN_IN_ORDER is an option available to programs that were written
+ to expect options and other ARGV-elements in any order and that care about
+ the ordering of the two. We describe each non-option ARGV-element
+ as if it were the argument of an option with character code 1.
+ Using `-' as the first character of the list of option characters
+ selects this mode of operation.
+
+ The special argument `--' forces an end of option-scanning regardless
+ of the value of `ordering'. In the case of RETURN_IN_ORDER, only
+ `--' can cause `getopt' to return EOF with `woptind' != ARGC. */
+
+ enum
+ {
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+ } ordering;
+
+ /* Handle permutation of arguments. */
+
+ /* Describe the part of ARGV that contains non-options that have
+ been skipped. `first_nonopt' is the index in ARGV of the first of them;
+ `last_nonopt' is the index after the last of them. */
+
+ int first_nonopt;
+ int last_nonopt;
+
+
+ wgetopter_t() : woptarg(NULL), woptind(0), nextchar(0), wopterr(0), woptopt('?'), first_nonopt(0), last_nonopt(0)
+ {
+ }
+
+ int wgetopt(int argc, wchar_t *const *argv, const wchar_t *optstring);
+ int wgetopt_long(int argc, wchar_t *const *argv, const wchar_t *options, const struct woption *long_options, int *opt_index);
+ int wgetopt_long_only(int argc, wchar_t *const *argv, const wchar_t *options, const struct woption *long_options, int *opt_index);
+};
+
+/** Describe the long-named options requested by the application.
+ The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+ of `struct option' terminated by an element containing a name which is
+ zero.
+
+ The field `has_arg' is:
+ no_argument (or 0) if the option does not take an argument,
+ required_argument (or 1) if the option requires an argument,
+ optional_argument (or 2) if the option takes an optional argument.
+
+ If the field `flag' is not NULL, it points to a variable that is set
+ to the value given in the field `val' when the option is found, but
+ left unchanged if the option is not found.
+
+ To have a long-named option do something other than set an `int' to
+ a compiled-in constant, such as set a value from `optarg', set the
+ option's `flag' field to zero and its `val' field to a nonzero
+ value (the equivalent single-letter option character, if there is
+ one). For long options that have a zero `flag' field, `getopt'
+ returns the contents of the `val' field. */
+
+struct woption
+{
+ /**
+ long name for switch
+ */
+ const wchar_t *name;
+ /**
+ Must be one of no_argument, required_argument and
+ optional_argument.
+
+ has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int.
+ */
+ int has_arg;
+
+ /**
+ If non-null, the flag whose value should be set if this switch is encountered
+ */
+ int *flag;
+
+ /**
+ If \c flag is non-null, this is the value that flag will be set
+ to. Otherwise, this is the return-value of the function call.
+ */
+ int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'. */
+
+/**
+ Specifies that a switch does not accept an argument
+*/
+#define no_argument 0
+/**
+ Specifies that a switch requires an argument
+*/
+#define required_argument 1
+/**
+ Specifies that a switch accepts an optional argument
+*/
+#define optional_argument 2
+
+#endif /* FISH_WGETOPT_H */
diff --git a/wildcard.cpp b/src/wildcard.cpp
index 22672f60..22672f60 100644
--- a/wildcard.cpp
+++ b/src/wildcard.cpp
diff --git a/wildcard.h b/src/wildcard.h
index 9e70f4aa..9e70f4aa 100644
--- a/wildcard.h
+++ b/src/wildcard.h
diff --git a/wutil.cpp b/src/wutil.cpp
index 9b95d3b4..e5127720 100644
--- a/wutil.cpp
+++ b/src/wutil.cpp
@@ -50,9 +50,9 @@ const file_id_t kInvalidFileID = {(dev_t)-1LL, (ino_t)-1LL, (uint64_t)-1LL, -1,
/* Lock to protect wgettext */
static pthread_mutex_t wgettext_lock;
-/* Maps string keys to (immortal) pointers to string values */
-typedef std::map<wcstring, wcstring *> wgettext_map_t;
-static std::map<wcstring, wcstring *> wgettext_map;
+/* Maps string keys to (immortal) pointers to string values. */
+typedef std::map<wcstring, const wchar_t *> wgettext_map_t;
+static wgettext_map_t wgettext_map;
void wutil_init()
{
@@ -475,15 +475,16 @@ const wchar_t *wgettext(const wchar_t *in)
wcstring key = in;
scoped_lock lock(wgettext_lock);
- wcstring *& val = wgettext_map[key];
+ // Reference to pointer to string
+ const wchar_t *& val = wgettext_map[key];
if (val == NULL)
{
cstring mbs_in = wcs2string(key);
char *out = fish_gettext(mbs_in.c_str());
- val = new wcstring(format_string(L"%s", out)); //note that this writes into the map!
+ val = wcsdup(format_string(L"%s", out).c_str()); //note that this writes into the map!
}
errno = err;
- return val->c_str(); //looks dangerous but is safe, since the string is stored in the map
+ return val; //looks dangerous but is safe, since the string is stored in the map
}
int wmkdir(const wcstring &name, int mode)
diff --git a/wutil.h b/src/wutil.h
index 011f3477..011f3477 100644
--- a/wutil.h
+++ b/src/wutil.h
diff --git a/wgetopt.h b/wgetopt.h
deleted file mode 100644
index 75c790d9..00000000
--- a/wgetopt.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/** \file wgetopt.h
- A version of the getopt library for use with wide character strings.
-
- This is simply the gnu getopt library, but converted for use with
- wchar_t instead of char. This is not usually useful since the argv
- array is always defined to be of type char**, but in fish, all
- internal commands use wide characters and hence this library is
- useful.
-
- If you want to use this version of getopt in your program,
- download the fish sourcecode, available at <a
- href='http://fishshell.com'>the fish homepage</a>. Extract
- the sourcode, copy wgetopt.c and wgetopt.h into your program
- directory, include wgetopt.h in your program, and use all the
- regular getopt functions, prefixing every function, global
- variable and structure with a 'w', and use only wide character
- strings. There are no other functional changes in this version of
- getopt besides using wide character strings.
-
- For examples of how to use wgetopt, see the fish builtin
- functions, many of which are defined in builtin.c.
-
-*/
-
-
-/* Declarations for getopt.
- Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
-
-This file is part of the GNU C Library. Its master source is NOT part of
-the C library, however. The master source lives in /gd/gnu/lib.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#ifndef FISH_WGETOPT_H
-#define FISH_WGETOPT_H
-
-#include <features.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /** For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
- extern wchar_t *woptarg;
-
- /** Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `woptind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
- extern int woptind;
-
- /** Callers store zero here to inhibit the error message `getopt' prints
- for unrecognized options. */
-
- extern int wopterr;
-
- /** Set to an option character which was unrecognized. */
-
- extern int woptopt;
-
- /** Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
- of `struct option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `getopt'
- returns the contents of the `val' field. */
-
- struct woption
- {
- /**
- long name for switch
- */
-#if defined (__STDC__) && __STDC__
- const wchar_t *name;
-#else
- wchar_t *name;
-#endif
- /**
- Must be one of no_argument, required_argument and
- optional_argument.
-
- has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int.
- */
- int has_arg;
-
- /**
- If non-null, the flag whose value should be set if this switch is encountered
- */
- int *flag;
-
- /**
- If \c flag is non-null, this is the value that flag will be set
- to. Otherwise, this is the return-value of the function call.
- */
- int val;
- };
-
- /* Names for the values of the `has_arg' field of `struct option'. */
-
- /**
- Specifies that a switch does not accept an argument
- */
-#define no_argument 0
- /**
- Specifies that a switch requires an argument
- */
-#define required_argument 1
- /**
- Specifies that a switch accepts an optional argument
- */
-#define optional_argument 2
-
-#if defined (__STDC__) && __STDC__
-#ifdef __GNU_LIBRARY__
- /**
- Get options from argument list. See the glibc manual for information on how to use this function.
- */
- extern int wgetopt(int argc, wchar_t *const *argv, const wchar_t *shortopts);
-#else /* not __GNU_LIBRARY__ */
-
- extern int wgetopt();
-#endif /* __GNU_LIBRARY__ */
- /**
- Get options from argument list. See the glibc manual for information on how to use this function.
- */
- extern int wgetopt_long(int argc, wchar_t *const *argv, const wchar_t *shortopts,
- const struct woption *longopts, int *longind);
- /**
- Get options from argument list. See the glibc manual for information on how to use this function.
- */
- extern int wgetopt_long_only(int argc, wchar_t *const *argv,
- const wchar_t *shortopts,
- const struct woption *longopts, int *longind);
-
- /**
- Internal only. Users should not call this directly.
- */
- extern int _wgetopt_internal(int argc, wchar_t *const *argv,
- const wchar_t *shortopts,
- const struct woption *longopts, int *longind,
- int long_only);
-#else /* not __STDC__ */
-
- /**
- Get options from argument list. See the glibc manual for information on how to use this function.
- */
- extern int wgetopt();
-
- /**
- Get options from argument list. See the glibc manual for information on how to use this function.
- */
- extern int wgetopt_long();
-
- /**
- Get options from argument list. See the glibc manual for information on how to use this function.
- */
- extern int wgetopt_long_only();
-
- /**
- Internal only. Users should not call this directly.
- */
- extern int _wgetopt_internal();
-#endif /* __STDC__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* FISH_WGETOPT_H */