From 43403682772d0dac1781ad6560a43631e1ac50fb Mon Sep 17 00:00:00 2001 From: Marc Joliet Date: Tue, 24 Sep 2013 15:42:32 +0200 Subject: Support bzip2 and lzma/xz compressed man pages Add support for bzip2 and lzma/xz compressed man pages. Support for bzip2 is part of the Python standard library (at least for 2.7 and >=3.2), while lzma/xz is only in Python >=3.3; however, there is a backports module for Python 2.7 and 3.2. --- share/tools/create_manpage_completions.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py index 14bf13ee..b568a97d 100755 --- a/share/tools/create_manpage_completions.py +++ b/share/tools/create_manpage_completions.py @@ -17,9 +17,14 @@ Redistributions in binary form must reproduce the above copyright notice, this l THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ -import string, sys, re, os.path, gzip, traceback, getopt, errno, codecs +import string, sys, re, os.path, bz2, gzip, traceback, getopt, errno, codecs from deroff import Deroffer +try: + import backports.lzma as lzma +except: + import lzma + # Whether we're Python 3 IS_PY3 = sys.version_info[0] >= 3 @@ -717,6 +722,14 @@ def parse_manpage_at_path(manpage_path, output_directory): fd = gzip.open(manpage_path, 'r') manpage = fd.read() if IS_PY3: manpage = manpage.decode('latin-1') + if manpage_path.endswith('.bz2'): + fd = bz2.BZ2File(manpage_path, 'r') + manpage = fd.read() + if IS_PY3: manpage = manpage.decode('latin-1') + elif manpage_path.endswith('.xz') or manpage_path.endswith('.lzma'): + fd = lzma.LZMAFile(str(manpage_path), 'r') + manpage = fd.read() + if IS_PY3: manpage = manpage.decode('latin-1') else: if IS_PY3: fd = open(manpage_path, 'r', encoding='latin-1') -- cgit v1.2.3 From 7d0722bc1850e47cc8d83aa21450aa142fbb683e Mon Sep 17 00:00:00 2001 From: Marc Joliet Date: Wed, 25 Sep 2013 01:35:32 +0200 Subject: Change an "if" to more appropriate "elif" I overlooked an "if" that should have been an "elif". Oops. --- share/tools/create_manpage_completions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py index b568a97d..b5ff43d2 100755 --- a/share/tools/create_manpage_completions.py +++ b/share/tools/create_manpage_completions.py @@ -722,7 +722,7 @@ def parse_manpage_at_path(manpage_path, output_directory): fd = gzip.open(manpage_path, 'r') manpage = fd.read() if IS_PY3: manpage = manpage.decode('latin-1') - if manpage_path.endswith('.bz2'): + elif manpage_path.endswith('.bz2'): fd = bz2.BZ2File(manpage_path, 'r') manpage = fd.read() if IS_PY3: manpage = manpage.decode('latin-1') -- cgit v1.2.3 From 4856567a2aaf55f98a8f2ab621b3767ca45d565d Mon Sep 17 00:00:00 2001 From: Marc Joliet Date: Wed, 25 Sep 2013 14:35:11 +0200 Subject: Only try "lzma" module on ImportError --- share/tools/create_manpage_completions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py index b5ff43d2..e1b7ccaa 100755 --- a/share/tools/create_manpage_completions.py +++ b/share/tools/create_manpage_completions.py @@ -22,7 +22,7 @@ from deroff import Deroffer try: import backports.lzma as lzma -except: +except ImportError: import lzma # Whether we're Python 3 -- cgit v1.2.3 From fc7c489ab68d1fbc399b11f3a03db10cd95704f8 Mon Sep 17 00:00:00 2001 From: Marc Joliet Date: Wed, 25 Sep 2013 14:36:42 +0200 Subject: Skip lzma/xz manpages if lzma module not available Skip man pages compressed with lzma/xz if the lzma module is not available; also print a corresponding diagnostic message. --- share/tools/create_manpage_completions.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py index e1b7ccaa..4b9ad88f 100755 --- a/share/tools/create_manpage_completions.py +++ b/share/tools/create_manpage_completions.py @@ -20,10 +20,14 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND import string, sys, re, os.path, bz2, gzip, traceback, getopt, errno, codecs from deroff import Deroffer +lzma_available = True try: - import backports.lzma as lzma + try: + import backports.lzma as lzma + except ImportError: + import lzma except ImportError: - import lzma + lzma_available = False # Whether we're Python 3 IS_PY3 = sys.version_info[0] >= 3 @@ -727,6 +731,8 @@ def parse_manpage_at_path(manpage_path, output_directory): manpage = fd.read() if IS_PY3: manpage = manpage.decode('latin-1') elif manpage_path.endswith('.xz') or manpage_path.endswith('.lzma'): + if not lzma_available: + return fd = lzma.LZMAFile(str(manpage_path), 'r') manpage = fd.read() if IS_PY3: manpage = manpage.decode('latin-1') @@ -829,6 +835,8 @@ def parse_and_output_man_pages(paths, output_directory, show_progress): last_progress_string_length = 0 if show_progress and not WRITE_TO_STDOUT: print("Parsing man pages and writing completions to {0}".format(output_directory)) + if not lzma_available and not WRITE_TO_STDOUT: + print('"lzma" module not available, cannot parse man pages compressed with xz or lzma') for manpage_path in paths: index += 1 -- cgit v1.2.3 From 1c8c9a10b5d7d42731befa6ef2eb9ba60b4c7f1d Mon Sep 17 00:00:00 2001 From: Marc Joliet Date: Wed, 25 Sep 2013 18:09:23 +0200 Subject: Only print an error when an lzma/xz manpage occurs Only print an error when an lzma/xz compressed man page occurs. Also, use add_diagnostic instead of print. --- share/tools/create_manpage_completions.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py index 4b9ad88f..f12d5c14 100755 --- a/share/tools/create_manpage_completions.py +++ b/share/tools/create_manpage_completions.py @@ -20,6 +20,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND import string, sys, re, os.path, bz2, gzip, traceback, getopt, errno, codecs from deroff import Deroffer +lzma_printed_msg = False lzma_available = True try: try: @@ -714,7 +715,7 @@ def parse_manpage_at_path(manpage_path, output_directory): filename = os.path.basename(manpage_path) # Clear diagnostics - global diagnostic_indent + global diagnostic_indent, lzma_printed_msg diagnostic_output[:] = [] diagnostic_indent = 0 @@ -732,6 +733,11 @@ def parse_manpage_at_path(manpage_path, output_directory): if IS_PY3: manpage = manpage.decode('latin-1') elif manpage_path.endswith('.xz') or manpage_path.endswith('.lzma'): if not lzma_available: + if not lzma_printed_msg: + add_diagnostic('A man page is compressed with lzma or xz, but the "lzma" module is not available.' + ' Skipping. (This message is only printed on the first occurrence.)', + NOT_VERBOSE) + lzma_printed_msg = True return fd = lzma.LZMAFile(str(manpage_path), 'r') manpage = fd.read() @@ -835,8 +841,6 @@ def parse_and_output_man_pages(paths, output_directory, show_progress): last_progress_string_length = 0 if show_progress and not WRITE_TO_STDOUT: print("Parsing man pages and writing completions to {0}".format(output_directory)) - if not lzma_available and not WRITE_TO_STDOUT: - print('"lzma" module not available, cannot parse man pages compressed with xz or lzma') for manpage_path in paths: index += 1 -- cgit v1.2.3 From 6de9a9258207ca38d320cc0bc3c3653deef12d7d Mon Sep 17 00:00:00 2001 From: Marc Joliet Date: Thu, 26 Sep 2013 17:15:53 +0200 Subject: Change the way xz/lzma man pages are detected This avoids the use of the global and puts the diagnostic message in a self-contained location. --- share/tools/create_manpage_completions.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py index f12d5c14..41fae2ed 100755 --- a/share/tools/create_manpage_completions.py +++ b/share/tools/create_manpage_completions.py @@ -20,7 +20,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND import string, sys, re, os.path, bz2, gzip, traceback, getopt, errno, codecs from deroff import Deroffer -lzma_printed_msg = False lzma_available = True try: try: @@ -715,7 +714,7 @@ def parse_manpage_at_path(manpage_path, output_directory): filename = os.path.basename(manpage_path) # Clear diagnostics - global diagnostic_indent, lzma_printed_msg + global diagnostic_indent diagnostic_output[:] = [] diagnostic_indent = 0 @@ -733,11 +732,6 @@ def parse_manpage_at_path(manpage_path, output_directory): if IS_PY3: manpage = manpage.decode('latin-1') elif manpage_path.endswith('.xz') or manpage_path.endswith('.lzma'): if not lzma_available: - if not lzma_printed_msg: - add_diagnostic('A man page is compressed with lzma or xz, but the "lzma" module is not available.' - ' Skipping. (This message is only printed on the first occurrence.)', - NOT_VERBOSE) - lzma_printed_msg = True return fd = lzma.LZMAFile(str(manpage_path), 'r') manpage = fd.read() @@ -841,6 +835,15 @@ def parse_and_output_man_pages(paths, output_directory, show_progress): last_progress_string_length = 0 if show_progress and not WRITE_TO_STDOUT: print("Parsing man pages and writing completions to {0}".format(output_directory)) + + man_page_suffixes = set([os.path.splitext(m)[1][1:] for m in paths]) + lzma_xz_occurs = "xz" in man_page_suffixes or "lzma" in man_page_suffixes + if lzma_xz_occurs and not lzma_available: + add_diagnostic('At least one man page is compressed with lzma or xz, but the "lzma" module is not available.' + ' Any man page compressed with either will be skipped.', + NOT_VERBOSE) + flush_diagnostics(sys.stderr) + for manpage_path in paths: index += 1 -- cgit v1.2.3 From f4f36e356fdfc73d52409efa5b9bd35a5218041b Mon Sep 17 00:00:00 2001 From: Marc Joliet Date: Thu, 26 Sep 2013 20:00:01 +0200 Subject: Document the optional dependency to backports.lzma. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index c7462465..522b0d91 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,12 @@ To switch your default shell back, you can run: Substitute /bin/bash with /bin/tcsh or /bin/zsh as appropriate. +## Optional Dependencies + +In order to generate completions from man pages compressed with either lzma or xz, you may need to install an extra Python package. + +Python versions prior to 2.6 are not supported. For Python versions 2.6 to 3.2 you need to install the module `backports.lzma`. How to install it depends on your system and how you installed Python. Most Linux distributions should include it as a package named `backports-lzma` (or similar). From version 3.3 onwards, Python already includes the required module. + ## Contact Us Questions, comments, rants and raves can be posted to the official fish mailing list at or join us on our IRC channel [#fish at irc.oftc.net](https://webchat.oftc.net/?channels=fish). -- cgit v1.2.3 From 2520019fb8212af13621af16a1648a30b33afc1a Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Thu, 17 Oct 2013 19:01:04 +0200 Subject: Remove useless duplicate comparisons. --- fallback.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/fallback.cpp b/fallback.cpp index 5e4b3e1b..6bfe413f 100644 --- a/fallback.cpp +++ b/fallback.cpp @@ -98,8 +98,6 @@ char *tparm_solaris_kludge(char *str, ...) || (enter_reverse_mode && ! strcmp(str, enter_reverse_mode)) || (enter_shadow_mode && ! strcmp(str, enter_shadow_mode)) || (exit_shadow_mode && ! strcmp(str, exit_shadow_mode)) - || (enter_standout_mode && ! strcmp(str, enter_standout_mode)) - || (exit_standout_mode && ! strcmp(str, exit_standout_mode)) || (enter_secure_mode && ! strcmp(str, enter_secure_mode)) || (enter_bold_mode && ! strcmp(str, enter_bold_mode))) { -- cgit v1.2.3 From ef99a110018201a5f2e50de8e98be660f3f24812 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Thu, 17 Oct 2013 19:01:20 +0200 Subject: Remove unused values in builtin_set. --- builtin_set.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin_set.cpp b/builtin_set.cpp index bf0ea008..eb2a70e9 100644 --- a/builtin_set.cpp +++ b/builtin_set.cpp @@ -698,7 +698,6 @@ static int builtin_set(parser_t &parser, wchar_t **argv) Slice mode */ size_t idx_count, val_count; - wcstring_list_t values; std::vector indexes; wcstring_list_t result; -- cgit v1.2.3 From fd25a6425c7bafff2746b5c349e7313b0110c041 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Sat, 19 Oct 2013 22:10:26 +0200 Subject: Fix two memory leaks. --- env_universal_common.cpp | 3 +++ xdgmimemagic.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/env_universal_common.cpp b/env_universal_common.cpp index f600e70a..e82333a7 100644 --- a/env_universal_common.cpp +++ b/env_universal_common.cpp @@ -398,6 +398,9 @@ start_conversion: { debug(0, L"%d %d", in_len, out_len); debug(0, L"Error while converting from to string"); + + /* Terminate the output string. */ + free(out); return 0; } diff --git a/xdgmimemagic.cpp b/xdgmimemagic.cpp index 3f67b290..8bcca948 100644 --- a/xdgmimemagic.cpp +++ b/xdgmimemagic.cpp @@ -276,7 +276,10 @@ _xdg_mime_magic_parse_header(FILE *magic_file, XdgMimeMagicMatch *match) buffer = _xdg_mime_magic_read_to_newline(magic_file, &end_of_file); if (end_of_file) + { + free(buffer); return XDG_MIME_MAGIC_EOF; + } end_ptr = buffer; while (*end_ptr != ']' && *end_ptr != '\000' && *end_ptr != '\n') -- cgit v1.2.3 From b6529205002ae10059986105e34bc1c19b7a310f Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Mon, 21 Oct 2013 12:08:43 -0400 Subject: git_prompt: optionally show upstream branch name Adds a "name" option to __fish_git_prompt_showupstream that shows an abbreviated branch name when the upstream type is verbose. Based on git.git 1f6806c: git-prompt.sh: optionally show upstream branch name --- share/functions/__fish_git_prompt.fish | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish index 4ca32c6e..08552e21 100644 --- a/share/functions/__fish_git_prompt.fish +++ b/share/functions/__fish_git_prompt.fish @@ -51,6 +51,7 @@ # __fish_git_prompt_showupstream to a space-separated list of values: # # verbose show number of commits ahead/behind (+/-) upstream +# name if verbose, then also show the upstream abbrev name # informative similar to verbose, but shows nothing when equal (fish only) # legacy don't use the '--count' option available in recent versions # of git-rev-list @@ -178,6 +179,7 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi set -l upstream git set -l legacy set -l verbose + set -l name # Default to informative if show_informative_status is set if test -n "$__fish_git_prompt_show_informative_status" @@ -222,6 +224,8 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi case legacy set legacy 1 set -e informative + case name + set name 1 case none return end @@ -303,6 +307,9 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi case '*' # diverged from upstream echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind" end + if test -n "$count" -a -n "$name" + echo " "(command git rev-parse --abbrev-ref "$upstream" ^/dev/null) + end else if test -n "$informative" echo $count | read -l behind ahead switch "$count" -- cgit v1.2.3 From 137463dc6d356b16f2238ffa00da494a97bbbc05 Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Mon, 21 Oct 2013 12:16:51 -0400 Subject: git_prompt: Add upstream_prefix when verbose git.git's git-prompt may not contain a configurable prefix, but it does display a space before the upstream information when displaying verbose information. Rather than using a space always or never, default to a space whenever verbose is in showupstream. --- share/functions/__fish_git_prompt.fish | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish index 08552e21..026c20cb 100644 --- a/share/functions/__fish_git_prompt.fish +++ b/share/functions/__fish_git_prompt.fish @@ -156,7 +156,8 @@ # # The separator before the upstream information can be customized via # __fish_git_prompt_char_upstream_prefix. It is colored like the rest of -# the upstream information. It defaults to nothing (). +# the upstream information. It normally defaults to nothing () and defaults +# to a space ( ) when __fish_git_prompt_showupstream contains verbose. # # # Turning on __fish_git_prompt_showcolorhints changes the colors as follows to @@ -295,17 +296,24 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi # calculate the result if test -n "$verbose" + # Verbose has a space by default + set -l prefix "$___fish_git_prompt_char_upstream_prefix" + # Using two underscore version to check if user explicitly set to nothing + if not set -q __fish_git_prompt_char_upstream_prefix + set -l prefix " " + end + echo $count | read -l behind ahead switch "$count" case '' # no upstream case "0 0" # equal to upstream - echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_equal" + echo "$prefix$___fish_git_prompt_char_upstream_equal" case "0 *" # ahead of upstream - echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead" + echo "$prefix$___fish_git_prompt_char_upstream_ahead$ahead" case "* 0" # behind upstream - echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind" + echo "$prefix$___fish_git_prompt_char_upstream_behind$behind" case '*' # diverged from upstream - echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind" + echo "$prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind" end if test -n "$count" -a -n "$name" echo " "(command git rev-parse --abbrev-ref "$upstream" ^/dev/null) -- cgit v1.2.3 From 59dd6678c3dff58f778494641682188f006dae88 Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Mon, 21 Oct 2013 12:34:22 -0400 Subject: git_prompt: Allow all set_color arguments There is no need to explicitly check for two arguments and set --bold. Instead the user can simply "set __fish_git_prompt_color_flags --bold red". The current check violates the expectation set by the documentation that you can use any set_color argument as the current code interprets "--bold red" as "--bold --bold" instead. Plus, by passing the full contents of the variable directly, the user can do more adventurous things like set the background as well. --- share/functions/__fish_git_prompt.fish | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish index 026c20cb..e6647284 100644 --- a/share/functions/__fish_git_prompt.fish +++ b/share/functions/__fish_git_prompt.fish @@ -672,21 +672,12 @@ function __fish_git_prompt_set_color set default_done "$argv[3]" end - if test (count $user_variable) -eq 2 - set user_variable_bright $user_variable[2] - set user_variable $user_variable[1] - end - set -l variable _$user_variable_name set -l variable_done "$variable"_done if not set -q $variable if test -n "$user_variable" - if test -n "$user_variable_bright" - set -g $variable (set_color --bold $user_variable) - else - set -g $variable (set_color $user_variable) - end + set -g $variable (set_color $user_variable) set -g $variable_done (set_color normal) else set -g $variable $default -- cgit v1.2.3 From e204ced1aef4381c74787680b8653f049d125094 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Fri, 25 Oct 2013 19:36:10 +0200 Subject: Disallow package names with dots. They cannot be used as arguments (Perl thinks it's version check, but version checks are pointless for oneliners), and Debian puts path containing version depending directories (like 5.14.2) in Perl path. --- share/completions/perl.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/completions/perl.fish b/share/completions/perl.fish index 6266981d..cb4a543f 100644 --- a/share/completions/perl.fish +++ b/share/completions/perl.fish @@ -2,7 +2,7 @@ begin set -l unicode 'commandline | sgrep -qe "-[a-zA-Z]*C[a-zA-Z]*\$"' set -l noopt 'commandline | not sgrep -qe "-[a-zA-Z]*C[a-zA-Z]*\$"' set -l modules "(find (perl -lE'print for @INC') -name '*.pm' -printf '%P\n' \ - | awk '{ gsub(\"/\", \"::\") } !/-/' RS=.pm\n | sort | uniq)" + | awk '{ gsub(\"/\", \"::\") } /[^-.]/' RS=.pm\n | sort | uniq)" complete -c perl -s 0 -n $noopt --description 'Specify record separator' complete -c perl -s a -n $noopt --description 'Turn on autosplit mode' complete -c perl -s c -n $noopt --description 'Check syntax' -- cgit v1.2.3 From e05743d0ba1201745d40c5ebc1c8ee336ff43b64 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 26 Oct 2013 15:22:20 -0700 Subject: Fix for errant SIGHUPs due to child fish shells messing with the term. Fixes https://github.com/fish-shell/fish-shell/issues/1002 --- fish.cpp | 8 +++++++- reader.cpp | 10 +++++++++- reader.h | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/fish.cpp b/fish.cpp index 24499c75..8235c529 100644 --- a/fish.cpp +++ b/fish.cpp @@ -389,7 +389,6 @@ int main(int argc, char **argv) set_main_thread(); setup_fork_guards(); - save_term_foreground_process_group(); wsetlocale(LC_ALL, L""); is_interactive_session=1; @@ -410,6 +409,12 @@ int main(int argc, char **argv) no_exec = 0; } + /* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */ + if (is_interactive_session) + { + save_term_foreground_process_group(); + } + const struct config_paths_t paths = determine_config_directory_paths(argv[0]); proc_init(); @@ -511,6 +516,7 @@ int main(int argc, char **argv) proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res); + restore_term_mode(); restore_term_foreground_process_group(); history_destroy(); proc_destroy(); diff --git a/reader.cpp b/reader.cpp index 228fa918..3bd40d01 100644 --- a/reader.cpp +++ b/reader.cpp @@ -993,10 +993,18 @@ void reader_init() void reader_destroy() { - tcsetattr(0, TCSANOW, &terminal_mode_on_startup); pthread_key_delete(generation_count_key); } +void restore_term_mode() +{ + // Restore the term mode if we own the terminal + // It's important we do this before restore_foreground_process_group, otherwise we won't think we own the terminal + if (getpid() == tcgetpgrp(STDIN_FILENO)) + { + tcsetattr(STDIN_FILENO, TCSANOW, &terminal_mode_on_startup); + } +} void reader_exit(int do_exit, int forced) { diff --git a/reader.h b/reader.h index 28340ad7..0d7a58f1 100644 --- a/reader.h +++ b/reader.h @@ -46,6 +46,9 @@ void reader_init(); */ void reader_destroy(); +/** Restore the term mode at startup */ +void restore_term_mode(); + /** Returns the filename of the file currently read */ -- cgit v1.2.3 From 03c65d7a96c9cadc9feff339ca0af7f43eb7391e Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 26 Oct 2013 15:24:49 -0700 Subject: Clean up interactive session test --- fish.cpp | 22 ++++++++-------------- fishd.cpp | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/fish.cpp b/fish.cpp index 8235c529..4f2a3ca6 100644 --- a/fish.cpp +++ b/fish.cpp @@ -365,18 +365,12 @@ static int fish_parse_opt(int argc, char **argv, std::vector *out_c is_login |= (strcmp(argv[0], "-fish") == 0); - /* - We are an interactive session if we have not been given an - explicit command to execute, _and_ stdin is a tty. - */ - is_interactive_session &= ! has_cmd; - is_interactive_session &= (my_optind == argc); - is_interactive_session &= isatty(STDIN_FILENO); - - /* - We are also an interactive session if we have are forced- - */ - is_interactive_session |= force_interactive; + /* We are an interactive session if we are either forced, or have not been given an explicit command to execute and stdin is a tty. */ + if (force_interactive) { + is_interactive_session = true; + } else if (is_interactive_session) { + is_interactive_session = ! has_cmd && (my_optind == argc) && isatty(STDIN_FILENO); + } return my_optind; } @@ -408,7 +402,7 @@ int main(int argc, char **argv) debug(1, _(L"Can not use the no-execute mode when running an interactive session")); no_exec = 0; } - + /* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */ if (is_interactive_session) { @@ -515,7 +509,7 @@ int main(int argc, char **argv) } proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res); - + restore_term_mode(); restore_term_foreground_process_group(); history_destroy(); diff --git a/fishd.cpp b/fishd.cpp index edb79c22..5e2a3648 100644 --- a/fishd.cpp +++ b/fishd.cpp @@ -694,7 +694,7 @@ static void daemonize() } /* - Put ourself in out own processing group + Put ourself in our own process group */ setsid(); -- cgit v1.2.3 From cf766b55cca979745f6c218d78f9cdcc297b3f20 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 26 Oct 2013 15:27:39 -0700 Subject: Fix formatting --- builtin.cpp | 10 +++++----- builtin_commandline.cpp | 2 +- builtin_printf.cpp | 2 +- complete.cpp | 4 ++-- complete.h | 2 +- exec.cpp | 22 +++++++++++----------- expand.cpp | 6 +++--- fallback.cpp | 2 +- fish.cpp | 11 +++++++---- fish_tests.cpp | 6 +++--- history.cpp | 8 ++++---- parse_util.cpp | 10 +++++----- parser.cpp | 10 +++++----- path.cpp | 16 ++++++++-------- proc.h | 5 ++++- reader.cpp | 20 ++++++++++---------- screen.cpp | 34 +++++++++++++++++----------------- screen.h | 4 ++-- tokenizer.cpp | 6 +++--- wildcard.cpp | 2 +- 20 files changed, 94 insertions(+), 88 deletions(-) diff --git a/builtin.cpp b/builtin.cpp index 379d5290..c1281a52 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -1617,24 +1617,24 @@ static int builtin_echo(parser_t &parser, wchar_t **argv) { case L'n': print_newline = false; - break; + break; case L'e': interpret_special_chars = true; - break; + break; case L's': // fish-specific extension, // which we should try to nix print_spaces = false; - break; + break; case L'E': interpret_special_chars = false; - break; + break; } } } else { - invalid_echo_option: +invalid_echo_option: break; } argv++; diff --git a/builtin_commandline.cpp b/builtin_commandline.cpp index 5564d05b..f6dc2b03 100644 --- a/builtin_commandline.cpp +++ b/builtin_commandline.cpp @@ -169,7 +169,7 @@ static void write_part(const wchar_t *begin, out.push_back(L'\n'); break; } - + default: { break; diff --git a/builtin_printf.cpp b/builtin_printf.cpp index efe4a211..b7df7fa8 100644 --- a/builtin_printf.cpp +++ b/builtin_printf.cpp @@ -632,7 +632,7 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch } break; } - + modify_allowed_format_specifiers(ok, "aAcdeEfFgGiosuxX", true); for (;; f++, direc_length++) diff --git a/complete.cpp b/complete.cpp index 8df02b35..97605527 100644 --- a/complete.cpp +++ b/complete.cpp @@ -1627,7 +1627,7 @@ void completer_t::complete_param_expand(const wcstring &sstr, bool do_file) if (expand_string(comp_str, this->completions, - flags ) == EXPAND_ERROR) + flags) == EXPAND_ERROR) { debug(3, L"Error while expanding string '%ls'", comp_str); } @@ -1911,7 +1911,7 @@ void complete(const wcstring &cmd, std::vector &comps, completion_ end_loop=1; break; } - + default: { break; diff --git a/complete.h b/complete.h index 84b84482..72d5a721 100644 --- a/complete.h +++ b/complete.h @@ -127,7 +127,7 @@ public: completion_t(const wcstring &comp, const wcstring &desc = L"", string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact), int flags_val = 0); completion_t(const completion_t &); completion_t &operator=(const completion_t &); - + /* Compare two completions. No operating overlaoding to make this always explicit (there's potentially multiple ways to compare completions). */ static bool is_alphabetically_less_than(const completion_t &a, const completion_t &b); static bool is_alphabetically_equal_to(const completion_t &a, const completion_t &b); diff --git a/exec.cpp b/exec.cpp index daad09f7..6317b653 100644 --- a/exec.cpp +++ b/exec.cpp @@ -551,7 +551,7 @@ static bool can_use_posix_spawn_for_job(const job_t *job, const process_t *proce return false; } } - + /* Now see if we have a redirection involving a file. The only one we allow is /dev/null, which we assume will not fail. */ bool result = true; if (chain_contains_redirection_to_real_file(job->block_io_chain()) || chain_contains_redirection_to_real_file(process->io_chain())) @@ -790,11 +790,11 @@ void exec_job(parser_t &parser, job_t *j) echo alpha | cat < beta.txt Should cat output alpha or beta? bash and ksh output 'beta', tcsh gets it right and complains about ambiguity, and zsh outputs both (!). No shells appear to output 'alpha', so we match bash here. That would mean putting the pipe first, so that it gets trumped by the file redirection. - + However, eval does this: - + echo "begin; $argv "\n" ;end eval2_inner <&3 3<&-" | source 3<&0 - + which depends on the redirection being evaluated before the pipe. So the write end of the pipe comes first, the read pipe of the pipe comes last. See issue #966. */ @@ -811,7 +811,7 @@ void exec_job(parser_t &parser, job_t *j) /* The explicit IO redirections associated with the process */ process_net_io_chain.append(p->io_chain()); - + /* Read pipe goes last */ if (p != j->first_process) { @@ -820,7 +820,7 @@ void exec_job(parser_t &parser, job_t *j) pipe_read->pipe_fd[0] = pipe_current_read; process_net_io_chain.push_back(pipe_read); } - + /* This call is used so the global environment variable array @@ -1241,16 +1241,16 @@ void exec_job(parser_t &parser, job_t *j) forking is expensive, fish tries to avoid it when possible. */ - + bool fork_was_skipped = false; - + const shared_ptr stdout_io = process_net_io_chain.get_io_for_fd(STDOUT_FILENO); const shared_ptr stderr_io = process_net_io_chain.get_io_for_fd(STDERR_FILENO); - + /* If we are outputting to a file, we have to actually do it, even if we have no output, so that we can truncate the file. Does not apply to /dev/null. */ bool must_fork = redirection_is_to_real_file(stdout_io.get()) || redirection_is_to_real_file(stderr_io.get()); if (! must_fork) - { + { if (p->next == NULL) { const bool stdout_is_to_buffer = stdout_io && stdout_io->io_mode == IO_BUFFER; @@ -1299,7 +1299,7 @@ void exec_job(parser_t &parser, job_t *j) } } } - + if (fork_was_skipped) { diff --git a/expand.cpp b/expand.cpp index 45d29249..5b4a0a7f 100644 --- a/expand.cpp +++ b/expand.cpp @@ -1752,15 +1752,15 @@ int expand_string(const wcstring &input, std::vector &output, expa remove_internal_separator(next_str, (EXPAND_SKIP_WILDCARDS & flags) ? true : false); const wchar_t *next = next_str.c_str(); - + const bool has_wildcard = wildcard_has(next, 1); - + if (has_wildcard && (flags & EXECUTABLES_ONLY)) { // Don't do wildcard expansion for executables. See #785. So do nothing here. } else if (((flags & ACCEPT_INCOMPLETE) && (!(flags & EXPAND_SKIP_WILDCARDS))) || - has_wildcard) + has_wildcard) { const wchar_t *start, *rest; diff --git a/fallback.cpp b/fallback.cpp index 6bfe413f..d26907e2 100644 --- a/fallback.cpp +++ b/fallback.cpp @@ -1506,7 +1506,7 @@ static int mk_wcswidth(const wchar_t *pwcs, size_t n) { if (pwcs[i] == L'\0') break; - + int w = mk_wcwidth(pwcs[i]); if (w < 0) { diff --git a/fish.cpp b/fish.cpp index 4f2a3ca6..c61eb582 100644 --- a/fish.cpp +++ b/fish.cpp @@ -366,9 +366,12 @@ static int fish_parse_opt(int argc, char **argv, std::vector *out_c is_login |= (strcmp(argv[0], "-fish") == 0); /* We are an interactive session if we are either forced, or have not been given an explicit command to execute and stdin is a tty. */ - if (force_interactive) { + if (force_interactive) + { is_interactive_session = true; - } else if (is_interactive_session) { + } + else if (is_interactive_session) + { is_interactive_session = ! has_cmd && (my_optind == argc) && isatty(STDIN_FILENO); } @@ -402,7 +405,7 @@ int main(int argc, char **argv) debug(1, _(L"Can not use the no-execute mode when running an interactive session")); no_exec = 0; } - + /* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */ if (is_interactive_session) { @@ -509,7 +512,7 @@ int main(int argc, char **argv) } proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res); - + restore_term_mode(); restore_term_foreground_process_group(); history_destroy(); diff --git a/fish_tests.cpp b/fish_tests.cpp index 8b79ef3a..6b9ec452 100644 --- a/fish_tests.cpp +++ b/fish_tests.cpp @@ -532,7 +532,7 @@ static void test_utils() { say(L"Testing utils"); const wchar_t *a = L"echo (echo (echo hi"; - + const wchar_t *begin = NULL, *end = NULL; parse_util_cmdsubst_extent(a, 0, &begin, &end); if (begin != a || end != begin + wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__); @@ -542,7 +542,7 @@ static void test_utils() if (begin != a || end != begin + wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__); parse_util_cmdsubst_extent(a, 3, &begin, &end); if (begin != a || end != begin + wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__); - + parse_util_cmdsubst_extent(a, 8, &begin, &end); if (begin != a + wcslen(L"echo (")) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__); @@ -788,7 +788,7 @@ static void test_path() { err(L"Bug in canonical PATH code"); } - + if (paths_are_equivalent(L"/foo/bar/baz", L"foo/bar/baz")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__); if (! paths_are_equivalent(L"///foo///bar/baz", L"/foo/bar////baz//")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__); if (! paths_are_equivalent(L"/foo/bar/baz", L"/foo/bar/baz")) err(L"Bug in canonical PATH code on line %ld", (long)__LINE__); diff --git a/history.cpp b/history.cpp index f167f6e4..57689ad4 100644 --- a/history.cpp +++ b/history.cpp @@ -629,7 +629,7 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa scoped_lock locker(lock); bool first = true; - + std::set seen; /* Append new items. Note that in principle we could use const_reverse_iterator, but we do not because reverse_iterator is not convertible to const_reverse_iterator ( http://github.com/fish-shell/fish-shell/issues/431 ) */ @@ -638,7 +638,7 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa /* Skip duplicates */ if (! seen.insert(iter->str()).second) continue; - + if (! first) result.append(separator); result.append(iter->str()); @@ -651,11 +651,11 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa { size_t offset = *iter; const history_item_t item = history_t::decode_item(mmap_start + offset, mmap_length - offset, mmap_type); - + /* Skip duplicates */ if (! seen.insert(item.str()).second) continue; - + if (! first) result.append(separator); result.append(item.str()); diff --git a/parse_util.cpp b/parse_util.cpp index 5d8a1b1d..3cf407d1 100644 --- a/parse_util.cpp +++ b/parse_util.cpp @@ -245,10 +245,10 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc const wchar_t * const cursor = buff + cursor_pos; CHECK(buff,); - + const size_t bufflen = wcslen(buff); assert(cursor_pos <= bufflen); - + /* ap and bp are the beginning and end of the tightest command substitition found so far */ const wchar_t *ap = buff, *bp = buff + bufflen; const wchar_t *pos = buff; @@ -265,7 +265,7 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc { end = const_cast(buff) + bufflen; } - + if (begin < cursor && end >= cursor) { /* This command substitution surrounds the cursor, so it's a tighter fit */ @@ -290,7 +290,7 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc assert(pos <= buff + bufflen); } } - + if (a != NULL) *a = ap; if (b != NULL) *b = bp; } @@ -383,7 +383,7 @@ static void job_or_process_extent(const wchar_t *buff, break; } - + default: { break; diff --git a/parser.cpp b/parser.cpp index 72b46c9f..1228fb2c 100644 --- a/parser.cpp +++ b/parser.cpp @@ -2013,7 +2013,7 @@ int parser_t::parse_job(process_t *p, { const wchar_t *cmd = args.at(0).completion.c_str(); - + /* We couldn't find the specified command. @@ -2036,20 +2036,20 @@ int parser_t::parse_job(process_t *p, if (equals_ptr != NULL) { /* Try to figure out if this is a pure variable assignment (foo=bar), or if this appears to be running a command (foo=bar ruby...) */ - + const wcstring name_str = wcstring(cmd, equals_ptr - cmd); //variable name, up to the = const wcstring val_str = wcstring(equals_ptr + 1); //variable value, past the = - + wcstring next_str; if (tok_peek_next(tok, &next_str) == TOK_STRING && ! next_str.empty()) { wcstring ellipsis_str = wcstring(1, ellipsis_char); if (ellipsis_str == L"$") ellipsis_str = L"..."; - + /* Looks like a command */ debug(0, - _( L"Unknown command '%ls'. Did you mean to run %ls with a modified environment? Try 'env %ls=%ls %ls%ls'. See the help section on the set command by typing 'help set'."), + _(L"Unknown command '%ls'. Did you mean to run %ls with a modified environment? Try 'env %ls=%ls %ls%ls'. See the help section on the set command by typing 'help set'."), cmd, next_str.c_str(), name_str.c_str(), diff --git a/path.cpp b/path.cpp index 4649e805..a2912f7b 100644 --- a/path.cpp +++ b/path.cpp @@ -400,7 +400,7 @@ void path_make_canonical(wcstring &path) path.at(trailing++) = c; } prev_was_slash = is_slash; - } + } assert(trailing <= len); if (trailing < len) path.resize(trailing); @@ -410,32 +410,32 @@ bool paths_are_equivalent(const wcstring &p1, const wcstring &p2) { if (p1 == p2) return true; - + size_t len1 = p1.size(), len2 = p2.size(); - + // Ignore trailing slashes after the first character while (len1 > 1 && p1.at(len1 - 1) == L'/') len1--; while (len2 > 1 && p2.at(len2 - 1) == L'/') len2--; - + // Start walking size_t idx1 = 0, idx2 = 0; while (idx1 < len1 && idx2 < len2) { wchar_t c1 = p1.at(idx1), c2 = p2.at(idx2); - + // If the characters are different, the strings are not equivalent if (c1 != c2) break; - + idx1++; idx2++; - + // If the character was a slash, walk forwards until we hit the end of the string, or a non-slash // Note the first condition is invariant within the loop while (c1 == L'/' && idx1 < len1 && p1.at(idx1) == L'/') idx1++; while (c2 == L'/' && idx2 < len2 && p2.at(idx2) == L'/') idx2++; } - + // We matched if we consumed all of the characters in both strings return idx1 == len1 && idx2 == len2; } diff --git a/proc.h b/proc.h index 5e702a91..b1661b80 100644 --- a/proc.h +++ b/proc.h @@ -373,7 +373,10 @@ public: unsigned int flags; /* Returns the block IO redirections associated with the job. These are things like the IO redirections associated with the begin...end statement. */ - const io_chain_t &block_io_chain() const { return this->block_io; } + const io_chain_t &block_io_chain() const + { + return this->block_io; + } /* Fetch all the IO redirections associated with the job */ io_chain_t all_io_redirections() const; diff --git a/reader.cpp b/reader.cpp index 3bd40d01..5b2a5e0a 100644 --- a/reader.cpp +++ b/reader.cpp @@ -984,9 +984,9 @@ void reader_init() // PCA disable VDSUSP (typically control-Y), which is a funny job control // function available only on OS X and BSD systems // This lets us use control-Y for yank instead - #ifdef VDSUSP +#ifdef VDSUSP shell_modes.c_cc[VDSUSP] = _POSIX_VDISABLE; - #endif +#endif #endif } @@ -1723,7 +1723,7 @@ static const completion_t *cycle_competions(const std::vector &com // note start_idx will be set to -1 initially, so that when it gets incremented we start at 0 const size_t start_idx = *inout_idx; size_t idx = start_idx; - + const completion_t *result = NULL; size_t remaining = comp.size(); while (remaining--) @@ -2340,7 +2340,7 @@ static void handle_token_history(int forward, int reset) } } break; - + default: { break; @@ -3814,34 +3814,34 @@ const wchar_t *reader_readline(void) } break; } - + case R_UPCASE_WORD: case R_DOWNCASE_WORD: case R_CAPITALIZE_WORD: { // For capitalize_word, whether we've capitalized a character so far bool capitalized_first = false; - + // We apply the operation from the current location to the end of the word size_t pos = data->buff_pos; move_word(MOVE_DIR_RIGHT, false, move_word_style_punctuation, false); for (; pos < data->buff_pos; pos++) { wchar_t chr = data->command_line.at(pos); - + // We always change the case; this decides whether we go uppercase (true) or lowercase (false) bool make_uppercase; if (c == R_CAPITALIZE_WORD) make_uppercase = ! capitalized_first && iswalnum(chr); else make_uppercase = (c == R_UPCASE_WORD); - + // Apply the operation and then record what we did if (make_uppercase) chr = towupper(chr); else chr = towlower(chr); - + data->command_line.at(pos) = chr; capitalized_first = capitalized_first || make_uppercase; } @@ -3850,7 +3850,7 @@ const wchar_t *reader_readline(void) reader_repaint(); break; } - + /* Other, if a normal character, we add it to the command */ default: { diff --git a/screen.cpp b/screen.cpp index 5ebe8605..8955059c 100644 --- a/screen.cpp +++ b/screen.cpp @@ -137,14 +137,14 @@ static bool allow_soft_wrap(void) size_t escape_code_length(const wchar_t *code) { assert(code != NULL); - + /* The only escape codes we recognize start with \x1b */ if (code[0] != L'\x1b') return 0; - + size_t resulting_length = 0; bool found = false; - + if (cur_term != NULL) { /* @@ -158,12 +158,12 @@ size_t escape_code_length(const wchar_t *code) set_foreground, set_background, }; - + for (size_t p=0; p < sizeof esc / sizeof *esc && !found; p++) { if (!esc[p]) continue; - + for (size_t k=0; k<8; k++) { size_t len = try_sequence(tparm(esc[p],k), code); @@ -176,7 +176,7 @@ size_t escape_code_length(const wchar_t *code) } } } - + if (cur_term != NULL) { /* @@ -206,9 +206,9 @@ size_t escape_code_length(const wchar_t *code) exit_standout_mode, enter_secure_mode }; - - - + + + for (size_t p=0; p < sizeof esc2 / sizeof *esc2 && !found; p++) { if (!esc2[p]) @@ -226,7 +226,7 @@ size_t escape_code_length(const wchar_t *code) } } } - + if (!found) { if (code[1] == L'k') @@ -251,7 +251,7 @@ size_t escape_code_length(const wchar_t *code) } } } - + if (! found) { /* Generic VT100 one byte sequence: CSI followed by something in the range @ through _ */ @@ -261,7 +261,7 @@ size_t escape_code_length(const wchar_t *code) found = true; } } - + if (! found) { /* Generic VT100 CSI-style sequence. , followed by zero or more ASCII characters NOT in the range [@,_], followed by one character in that range */ @@ -273,11 +273,11 @@ size_t escape_code_length(const wchar_t *code) { /* Consume a sequence of ASCII characters not in the range [@, ~] */ wchar_t c = code[cursor]; - + /* If we're not in ASCII, just stop */ if (c > 127) break; - + /* If we're the end character, then consume it and then stop */ if (c >= L'@' && c <= L'~') { @@ -290,7 +290,7 @@ size_t escape_code_length(const wchar_t *code) resulting_length = cursor; } } - + if (! found) { /* Generic VT100 two byte sequence: followed by something in the range @ through _ */ @@ -300,7 +300,7 @@ size_t escape_code_length(const wchar_t *code) found = true; } } - + return resulting_length; } @@ -1060,7 +1060,7 @@ struct screen_layout_t wcstring autosuggestion; /* Whether the prompts get their own line or not */ - bool prompts_get_own_line; + bool prompts_get_own_line; }; /* Given a vector whose indexes are offsets and whose values are the widths of the string if truncated at that offset, return the offset that fits in the given width. Returns width_by_offset.size() - 1 if they all fit. The first value in width_by_offset is assumed to be 0. */ diff --git a/screen.h b/screen.h index 1d9fde2c..ef74383d 100644 --- a/screen.h +++ b/screen.h @@ -140,7 +140,7 @@ public: /** If we support soft wrapping, we can output to this location without any cursor motion. */ screen_data_t::cursor_t soft_wrap_location; - + /** Whether the last-drawn autosuggestion (if any) is truncated, or hidden entirely */ bool autosuggestion_is_truncated; @@ -158,7 +158,7 @@ public: /** If we need to clear, this is how many lines the actual screen had, before we reset it. This is used when resizing the window larger: if the cursor jumps to the line above, we need to remember to clear the subsequent lines. */ size_t actual_lines_before_reset; - + /** These status buffers are used to check if any output has occurred other than from fish's main loop, in which case we need to redraw. diff --git a/tokenizer.cpp b/tokenizer.cpp index 567b03dc..90c8b703 100644 --- a/tokenizer.cpp +++ b/tokenizer.cpp @@ -647,20 +647,20 @@ enum token_type tok_peek_next(tokenizer_t *tok, wcstring *out_next_string) { out_next_string->clear(); } - + enum token_type result = TOK_END; if (tok_has_next(tok)) { int saved = tok_get_pos(tok); tok_next(tok); result = tok_last_type(tok); - + if (out_next_string != NULL) { const wchar_t *last = tok_last(tok); out_next_string->assign(last ? last : L""); } - + tok_set_pos(tok, saved); } return result; diff --git a/wildcard.cpp b/wildcard.cpp index 621ece72..2b93561b 100644 --- a/wildcard.cpp +++ b/wildcard.cpp @@ -317,7 +317,7 @@ static bool wildcard_complete_internal(const wcstring &orig, if (wildcard_complete_internal(orig, str + i, wc+1, false, desc, desc_func, out, expand_flags, flags)) { res = true; - + /* #929: if the recursive call gives us a prefix match, just stop. This is sloppy - what we really want to do is say, once we've seen a match of a particular type, ignore all matches of that type further down the string, such that the wildcard produces the "minimal match." */ bool has_prefix_match = false; const size_t after_count = out.size(); -- cgit v1.2.3