Commit graph

71 commits

Author SHA1 Message Date
Michael Steed
8abb19aaca Prefix errors with 'string:', not 'string string:' 2015-09-24 19:21:09 -06:00
ridiculousfish
c1bd3b5824 Eliminate global variables associated with builtin IO
This change eliminates global variables like stdout_buffer. Instead we wrap up
the IO information into a new struct io_streams_t, and thread that through
every builtin. This makes the intent clearer, gives us a place to hang new IO
data, and eliminates the ugly global state management like builtin_push_io.
2015-09-22 18:08:00 -07:00
ridiculousfish
1883e051ba Apply some care regarding overflow in string sub 2015-09-21 16:41:26 -07:00
ridiculousfish
4825afbf58 Include headers needed on Linux 2015-09-21 16:41:26 -07:00
ridiculousfish
ad8c7b9d0b Clarify string split implementation
Use some template magic to handle the forward and reverse
string split cases uniformly
2015-09-21 16:41:26 -07:00
ridiculousfish
7eb88ed7dc Take advantage of find_first_not_of and friends
Simplifies some of the logic in string_trim
2015-09-21 16:41:26 -07:00
ridiculousfish
6afd0d8add pcre2_strerror should use wcstring instead of static wchar_t 2015-09-21 16:41:26 -07:00
ridiculousfish
bfe142fef0 Use append_formatv in string_error 2015-09-21 16:41:26 -07:00
ridiculousfish
54e626f665 Fix some type conversion warnings in builtin_string
Also pass around a wcstring for storage, instead of using a static
2015-09-21 16:41:26 -07:00
ridiculousfish
b2e8967e94 Migrate builtin_string.cpp to its own object file
This keeps the architecture a little less surprising
2015-09-21 16:41:25 -07:00
Michael Steed
d83ef07ca7 Merge new string builtin
This adds the new builtin 'string' which supports various string
manipulation and matching algorithms, including PCRE based regular
expressions.

Fixes #2296

Squashed commit of the following:

commit 4c3eaeb6e57d76463e9683c327142b0aeafb92b8
Author: ridiculousfish <corydoras@ridiculousfish.com>
Date:   Sat Sep 12 12:51:30 2015 -0700

    Remove testdata and doc dirs from pcre2 source

commit b2a8b4b50f2398b204fb72cfe4b5ba77ece2e1ab
Merge: 11c8a47 7974aab
Author: ridiculousfish <corydoras@ridiculousfish.com>
Date:   Sat Sep 12 12:32:40 2015 -0700

    Merge branch 'string' of git://github.com/msteed/fish-shell into string-test

commit 7974aab6d3
Author: Michael Steed <msteed@saltstack.com>
Date:   Fri Sep 11 13:00:02 2015 -0600

    build pcre2 lib only, no docs

commit eb20b43d2d
Merge: 1a09e70 5f519cb
Author: Michael Steed <msteed68@gmail.com>
Date:   Thu Sep 10 20:00:47 2015 -0600

    Merge branch 'string' of github.com:msteed/fish-shell into string

commit 1a09e709d0
Author: Michael Steed <msteed68@gmail.com>
Date:   Thu Sep 10 19:58:24 2015 -0600

    rebase on master & address the fallout

commit a0ec9772cd
Author: Michael Steed <msteed68@gmail.com>
Date:   Thu Sep 10 19:26:45 2015 -0600

    use fish's wildcard_match() for glob matching

commit 64c25a01e3
Author: Michael Steed <msteed68@gmail.com>
Date:   Thu Aug 27 08:19:23 2015 -0600

    some fixes from review

    - string_get_arg_stdin(): simplify and don't discard the argument when
      the trailing newline is absent
    - fix calls to pcre2 for e.g. string match -r -a 'a*' 'b'
    - correct test for args coming from stdin

commit ece7f35ec5
Author: Michael Steed <msteed68@gmail.com>
Date:   Sat Aug 22 19:35:56 2015 -0600

    fixes from review

    - Makefile.in: restore iwyu target
    - regex_replacer_t::replace_matches(): correct size passed to realloc()

commit 9ff7477a92
Author: Michael Steed <msteed68@gmail.com>
Date:   Thu Aug 20 13:08:33 2015 -0600

    Minor doc improvements

commit baf4e096b2
Author: Michael Steed <msteed68@gmail.com>
Date:   Wed Aug 19 18:29:02 2015 -0600

    another attempt to fix the ci build

commit 896a2c2b27
Author: Michael Steed <msteed68@gmail.com>
Date:   Wed Aug 19 18:03:49 2015 -0600

    Updates after review comments

    - make match/replace without -a operate on the first match on each
      argument
    - use different exit codes for "no operation performed" and errors, as
      grep does
    - refactor regex compile code
    - use human-friendly error messages from pcre2
    - improve error handling & reporting elsewhere
    - add a few tests
    - make some doc fixes
    - some simplification & cleanup
    - fix ci build failure (I hope)

commit efd47dcbda
Author: Michael Steed <msteed68@gmail.com>
Date:   Wed Aug 12 00:26:07 2015 -0600

    fix dependencies for parallel make

commit ed0850e2db
Author: Michael Steed <msteed68@gmail.com>
Date:   Tue Aug 11 23:37:22 2015 -0600

    Add missing pcre2 files + .gitignore

commit 9492e7a7e9
Author: Michael Steed <msteed68@gmail.com>
Date:   Tue Aug 11 22:44:05 2015 -0600

    add pcre2-10.20 and update license.hdr

commit 1a60b93371
Author: Michael Steed <msteed68@gmail.com>
Date:   Tue Aug 11 22:41:19 2015 -0600

    add string builtin files

    - string builtin source, tests, & docs
    - changes to configure.ac & Makefile.in

commit 5f519cb2a2
Author: Michael Steed <msteed68@gmail.com>
Date:   Thu Sep 10 19:26:45 2015 -0600

    use fish's wildcard_match() for glob matching

commit 2ecd24f795
Author: Michael Steed <msteed68@gmail.com>
Date:   Thu Aug 27 08:19:23 2015 -0600

    some fixes from review

    - string_get_arg_stdin(): simplify and don't discard the argument when
      the trailing newline is absent
    - fix calls to pcre2 for e.g. string match -r -a 'a*' 'b'
    - correct test for args coming from stdin

commit 45b777e4dc
Author: Michael Steed <msteed68@gmail.com>
Date:   Sat Aug 22 19:35:56 2015 -0600

    fixes from review

    - Makefile.in: restore iwyu target
    - regex_replacer_t::replace_matches(): correct size passed to realloc()

commit 981cbb6ddf
Author: Michael Steed <msteed68@gmail.com>
Date:   Thu Aug 20 13:08:33 2015 -0600

    Minor doc improvements

commit ddb6a2a8fd
Author: Michael Steed <msteed68@gmail.com>
Date:   Wed Aug 19 18:29:02 2015 -0600

    another attempt to fix the ci build

commit 1e34e3191b
Author: Michael Steed <msteed68@gmail.com>
Date:   Wed Aug 19 18:03:49 2015 -0600

    Updates after review comments

    - make match/replace without -a operate on the first match on each
      argument
    - use different exit codes for "no operation performed" and errors, as
      grep does
    - refactor regex compile code
    - use human-friendly error messages from pcre2
    - improve error handling & reporting elsewhere
    - add a few tests
    - make some doc fixes
    - some simplification & cleanup
    - fix ci build failure (I hope)

commit 34232e152d
Author: Michael Steed <msteed68@gmail.com>
Date:   Wed Aug 12 00:26:07 2015 -0600

    fix dependencies for parallel make

commit 00d7e78169
Author: Michael Steed <msteed68@gmail.com>
Date:   Tue Aug 11 23:37:22 2015 -0600

    Add missing pcre2 files + .gitignore

commit 4498aa5f57
Author: Michael Steed <msteed68@gmail.com>
Date:   Tue Aug 11 22:44:05 2015 -0600

    add pcre2-10.20 and update license.hdr

commit 290c58c72e
Author: Michael Steed <msteed68@gmail.com>
Date:   Tue Aug 11 22:41:19 2015 -0600

    add string builtin files

    - string builtin source, tests, & docs
    - changes to configure.ac & Makefile.in
2015-09-21 16:41:25 -07:00
ridiculousfish
fa4ec55c96 Fix process expansion on OS X
Puts back sys/sysctl.h header, so we know to use BSD style process
expansion
2015-09-15 11:40:20 -07:00
ridiculousfish
f5093f1625 Fix tests under certain vswprintf calls
Work around an issue where vswprintf may not append
ANY_STRING from a format specifier
2015-09-12 16:32:52 -07:00
ridiculousfish
025b45b91e Don't crash on complete -C in non-interactive mode
Fixes #2361
2015-09-10 18:08:42 -07:00
David Adam
a66d44054c reader.cpp: send smkx/rmkx when entering/leaving interactive mode
Closes #2139.
2015-09-10 16:22:39 +08:00
ridiculousfish
babc6f0f9c Stop exporting fish configuration directories (argh) 2015-09-09 16:50:05 -07:00
Fabian Homborg
b85a8bbbfe Rename sgrep to __fish_sgrep
Makes it harder to cause issues with aliases, see fish-shell#2245
2015-09-09 20:55:04 +02:00
Chris Pick
c5bc221b27 Use the $TERM value from fish's computed environment for ncurses setup
Previously, the process's inherited $TERM value would be used.
This prevented users from being able to set $TERM in their config.fish files.

To make matters worse, the error message would print the computed $TERM value,
giving the mistaken impression that it was being used.

Signed-off-by: David Adam <zanchey@ucc.gu.uwa.edu.au>
2015-09-09 17:06:13 +08:00
Corey Ford
54b6a1c08e Fix error message for variable used as command 2015-09-03 21:42:42 -07:00
David Adam
b0504f7739 env_universal_common: always pick shmem strategy on Cygwin
Cygwin FIFOs do not support more than one reader, so avoid them on this
platform. An autoconf feature test would be helpful but is tricky to
write.

Closes #2152.
2015-08-24 18:45:57 +08:00
ridiculousfish
b59904632d Rewrite parse_util_unescape_wildcards
Make it simpler, and use wcstring instead of wcsdup
2015-08-19 11:35:24 -07:00
ridiculousfish
c1b9b27f86 Remove unused original_pid variable 2015-08-18 11:22:05 -07:00
ridiculousfish
e2f16ec20e Define a constant for function-not-found in input.cpp
Avoids differences in widths of wchar_t, hopefully addressing
issue #2284
2015-08-16 18:45:42 -07:00
ridiculousfish
93d57bd73a Factor function environment preparation into its own function 2015-08-15 13:37:17 -07:00
ridiculousfish
871a822379 Remove some dead #defines 2015-08-11 01:00:05 -07:00
ridiculousfish
b9b6b6108e Dead macro cleanup
Enable -Wunused-macros, and remove said unused macros
2015-08-10 22:01:50 -07:00
ridiculousfish
3a2ba60b70 Use ++iter, not iter++ in input.cpp 2015-08-10 22:01:33 -07:00
ridiculousfish
aa76f64a94 Correct the caret position for unbalanced square brackets 2015-08-10 19:30:21 -07:00
ridiculousfish
e34a8da5d7 Correct the positioning of the error caret
When an error occurs midway through a token, like abc(def,
make the caret point at the location of the error (i.e. the paren)
instead of at the beginning of the token.
2015-08-10 18:31:20 -07:00
ridiculousfish
3bd6eab88f Make expansion test robust against different filesystem orders
Should make the tests pass on Linux
2015-08-08 15:25:07 -07:00
ridiculousfish
3a3a9f5cc1 Add wreaddir_for_dirs function
Eliminates some stat calls, speeding up wildcard expansion
2015-08-08 14:52:04 -07:00
ridiculousfish
f87268e2ac Remove a bogus function declaration 2015-08-08 14:32:10 -07:00
ridiculousfish
6347988e0a Eliminate wildcard_expand function 2015-08-08 13:55:51 -07:00
ridiculousfish
b92acd3cf2 Initial implementation of intermediate fuzzy completion
e.g. /u/l/b<tab> may be expanded to /usr/local/bin
2015-08-08 13:55:51 -07:00
ridiculousfish
fd96bafbc8 Experiment to rework wildcard matching
Preparation for zsh-style intermediate component
tab completion
2015-08-08 13:55:51 -07:00
ridiculousfish
b7e16cb0dd Tweak try_add_completion_result logic
Preparation for zsh-style intermediate fuzzy matching
2015-08-08 13:55:51 -07:00
ridiculousfish
459df23931 Migrate the prepend_token_prefix logic into the expander 2015-08-08 13:55:50 -07:00
ridiculousfish
e7b22a7ed2 Factor the expander class a bit more 2015-08-08 13:55:50 -07:00
ridiculousfish
bcbe91461e Move the "wildcard_complete" test into wildcard_test_flags_then_complete
Simplifies code yet further
2015-08-08 13:55:50 -07:00
ridiculousfish
b68410d619 Eliminate the wildcard_expand_internal function 2015-08-08 13:55:50 -07:00
ridiculousfish
602e9cebd9 rename FOR_COMPLETIONS to EXPAND_FOR_COMPLETIONS
This is yet clearer
2015-08-08 13:55:50 -07:00
ridiculousfish
d2049edcab Slight refactoring of expander's return code implementation 2015-08-08 13:55:49 -07:00
ridiculousfish
83322f63c6 Rewrite wildcard_complete_internal to be easier to follow 2015-08-08 13:55:49 -07:00
ridiculousfish
f0a2f24701 Remove some dead code 2015-08-08 13:55:49 -07:00
ridiculousfish
97f1a8fe91 Factor the completion prefix behavior into its own function
In a few places, we need to add a prefix to completions that
replace the token. This change factors that logic into its
own function prepend_token_prefix.
2015-08-08 13:55:49 -07:00
ridiculousfish
0ac9f159d6 Eliminate recurse_to_subdirectories function 2015-08-08 13:55:49 -07:00
ridiculousfish
a3f8e27bf8 rename ACCEPT_INCOMPLETE to FOR_COMPLETIONS, which is clearer 2015-08-08 13:55:49 -07:00
ridiculousfish
b55c13f275 Turn on the new wildcard expander 2015-08-08 13:55:48 -07:00
ridiculousfish
761651d410 Add some expansion tests 2015-08-08 13:55:48 -07:00
ridiculousfish
70548f7cc7 Initial implementation of wildcard match refactoring
Not yet turned on.
2015-08-08 13:55:43 -07:00