Commit Graph

562 Commits

Author SHA1 Message Date
ridiculousfish
eb3ed2680b Fix macOS Xcode build
React to Solaris fixes (0019c12af3) by hiding some more
functions from macOS. The Xcode build uses special weak-linking
magic.
2016-12-10 20:48:54 -08:00
ridiculousfish
05a640b027 Increase test coverage and improve completion commenting 2016-12-09 12:14:35 -08:00
Kurtis Rader
0019c12af3 changes to allow building on Solaris 10
Fixes #3456
2016-12-08 19:15:11 -08:00
Kurtis Rader
9443a415bf time for another make style-all 2016-12-03 20:12:53 -08:00
Kurtis Rader
45d3a705be fix bug introduced by commit eaa37413
When I refactored the code to reduce redundancy and improve the error
messages when the config or data directories could not be used I botched
the customization of the $HOME based data path.
2016-12-03 18:38:00 -08:00
ridiculousfish
ed85393611 Restyle pager.cpp via make style 2016-12-03 13:38:50 -08:00
ridiculousfish
ffd4754cb2 Don't show the pager on terminals of height less than 4
Prevents some potential overflow bugs and janky UI
2016-12-03 13:35:24 -08:00
ridiculousfish
54dd4b7ed6 Untangle some pager code and fix some warnings
Fixes various warnings about implicit conversions
2016-12-03 13:29:16 -08:00
ridiculousfish
8041913e7a Stop including spacer width in width_by_column in pager
Additional refactoring to remove some sketchy-looking arithmetic
2016-12-03 13:29:16 -08:00
ridiculousfish
2d5ce72cb4 Remove the min_width parts of the pager
min_width dates back to the original full-screen pager.
After some careful inspection, the code path that uses min_width
is never executed and so the min_width machinery is useless.
Let's remove it!
2016-12-03 13:29:16 -08:00
ridiculousfish
d058d290be Factor pref_width into a function preferred_width()
Beginnings of some pager cleanup
2016-12-03 13:29:16 -08:00
ridiculousfish
85d697f13d Add some pager layout test cases
Helps ensure correct truncation logic
2016-12-03 13:29:16 -08:00
ridiculousfish
754b78a748 Suppress certain stderr-printing during tests
Tests that exercise error paths may result in output to
stderr. This may make it look like the test failed when it did
not. Introduce should_suppress_stderr_for_tests() to suppress
this output so the test output looks clean.
2016-12-03 13:27:50 -08:00
Radomír Bosák
254762f30f Fix status code when bad command name is entered
This commit fixes a bug which causes that

   fish -c ')'; echo $status

("Illegal command name" error) returns 0. This is inconsistent with
e.g. when trying to run non-existent command:

   fish -c 'invalid-command'; echo $status

("Unknown command" error) which correctly returns 127.

A new status code,

    STATUS_ILLEGAL_CMD = 123

is introduced - which is returned whenever the 'Illegal command name *'
message is printed.

This commit also adds a test which checks if valid commands return 0,
while commands with illegal name return status code 123.

Fixes #3606.
2016-12-03 13:14:40 -08:00
David Adam
bf53f39cdd cppcheck: warn on use of flock 2016-12-03 16:36:06 +08:00
David Adam
3289797248 flock fallback: remove noop path
"fail to no locking" is not an ideal strategy.
2016-12-03 16:36:06 +08:00
David Adam
2b7dddf342 add flock fallback
Import the flock compatibility wrapper from NetBSD.

Work on #3340.
2016-12-03 16:36:06 +08:00
David Adam
1293cd8b6a Check for functions in std namespace
On Solaris, some standard wide character functions are only contained in
the std:: namespace. The configure script now checks for these, enabling
the appropriate `uses` statements in src/common.h.

The checks are handwritten, because Autoconf's AC_CHECK_FUNC macro
always uses C linkage, but the problem only appears under C++ linkage.

Work on #3340.
2016-12-03 16:36:06 +08:00
Kurtis Rader
eaa3741336 improve error msg about invalid HOME/XDG_* var
This change increases the amount of useful information when fish is
unable to create or use its config or data directory. We now make it
clear when neither var is set or one is set to an unusable location.

Fixes #3545
2016-12-01 20:40:25 -08:00
Michael Steinert
e2ed561264 Fixes behavior of 'x' in normal mode
After 'x' is used to delete a character at the end of a line the cursor
should be repositioned at the last character, i.e. repeatedly pressing
'x' in normal mode should delete the entire string.
2016-12-01 16:23:59 -08:00
Aaron Gyes
6a5a1a8964 [[noreturn]] instead of __attribute__ ((noreturn))
C++11 does this, better to use a standard attribute than a compiler
extension.
2016-11-29 01:41:03 -08:00
Aaron Gyes
a8b2da8405 Use early returns throughout builtin_cd and fix my no-HOME output. 2016-11-28 23:59:37 -08:00
Kurtis Rader
7cfe028b9d fix functions --copy
Fixes #3601
2016-11-28 18:04:37 -08:00
Aaron Gyes
f47ebc4b1c builtin cd: Handle unset HOME. 2016-11-28 12:40:55 -08:00
Aaron Gyes
682af2f83f Remove 4 cppcheck suppressions reported unmatched. 2016-11-28 11:54:03 -08:00
Aaron Gyes
7c6527e9cf Fix segfault with bad USER and unset HOME
A couple things went wrong with `env -u HOME USER=x ./fish -c ''`
We failed to check that `pw` isn't NULL leading to a crash when USER is
bogus. After fixing that we were not left with both variables in a
correct state still.

We now go back and force fish to dig up a working USER when we notice
this and then get both set successfully. Fixes #3599
2016-11-28 09:34:56 -08:00
Aaron Gyes
121109ee4d Adds a --quiet/-q option for command -s (#3591)
devnull'ing this builtin to check presence is a common
enough chore that a --quiet option which works like it does on
`type` would be handy.
2016-11-28 07:26:01 -08:00
Kurtis Rader
54a76bb9e5 emit error message when test is given invalid int
This augments the previous change for issue #3346 by adding an error
message when an invalid integer is seen. This change is likely to be
controversial so I'm not going to squash it into the previous change.
2016-11-27 20:37:30 -08:00
Kurtis Rader
2f33c24a07 fix handling of odd strings by test builtin
The `test` builtin currently has unexpected behavior with respect to
expressions such as `'' -eq 0`. That currently evaluates to true with a
return status of zero. This change addresses that oddity while also
ensuring that other unusual strings (e.g., numbers with leading and
trailing whitespace) are handled consistently.

Fixes #3346
2016-11-27 20:37:21 -08:00
Aaron Gyes
d0146d7b6f builtin test: output correct program name on error
Only in one instance would test as `[` have the the errors formatted
as "[: foo". This fixes that. When trying to track down the source of
an error this could lead someone astray.
2016-11-27 20:28:38 -08:00
Fredrik Fornwall
df12ac24b2 Fix build on systems without shm_open()
Notably, this fixes building on Android.
2016-11-26 16:14:15 -05:00
Kurtis Rader
a928517e95 improve converting strings to ints/longs
The existing code is inconsistent, and in a couple of cases wrong, about
dealing with strings that are not valid ints. For example, there are
locations that call wcstol() and check errno without first setting errno
to zero. Normalize the code to a consistent pattern.  This is mostly to
deal with inconsistencies between BSD, GNU, and other UNIXes.

This does make some syntax more liberal. For example `echo $PATH[1 .. 3]`
is now valid due to uniformly allowing leading and trailing whitespace
around numbers. Whereas prior to this change you would get a "Invalid
index value" error. Contrast this with `echo $PATH[ 1.. 3 ]` which was
valid and still is.
2016-11-25 18:52:15 -08:00
Kurtis Rader
aad2848e80 use consistent mechanism to validate var names
Builtin commands that validate var names should use a consistent
mechanism. I noticed that builtin_read() had it's own custom code that
differed slightly from wcsvarname().

Fixes #3569
2016-11-22 16:18:20 -08:00
Kurtis Rader
320cb6857f an invalid flag to function is handled wrong
Specifically, an invalid flag keeps the function from being defined but
does not emit an error message.

Fixes #2827
2016-11-22 16:17:51 -08:00
Kurtis Rader
9ac78e06b4 fix builtin ulimit arg handling
Fixes #3570
2016-11-21 21:15:59 -08:00
Kurtis Rader
45c7836bec remove is_wchar_ucs2()
My previous change removed one place where is_wchar_ucs2() was used and
replaced it with compile time tests. This change does the same for the
other uses.
2016-11-20 18:25:49 -08:00
Kurtis Rader
b8778ba4a2 make fish_tests work on MS Windows with C++11
On Cygwin there are two narrowing conversions at line 931 in
src/fish_tests.cpp due to the code assuming a wchar_t is four bytes.
Obviously that's wrong but only became an issue with the pending change to
switch to C++11. The problematic values aren't actually used on Windows
because the tests that would use them are bypassed if is_wchar_ucs2()
returns true. This change predicates that code on a compile time rather
than a run time test.
2016-11-20 18:05:34 -08:00
Kurtis Rader
b16511344e fix incorrect pointer to int comparison
This came to my attention while testing the PR that switches us to the
C++11 standard and one of the compilers reported this error.
2016-11-20 15:04:51 -08:00
ridiculousfish
b86b84e2a9 L'\0' is not a pointer, don't compare it to one
Compare to NULL instead. Comparison with original code
shows this is what is intended.
2016-11-20 00:30:55 -08:00
ridiculousfish
52d1b6b97d Remove some dead functions
icompare_pred and icompare in history.cpp are unused
2016-11-19 23:12:49 -08:00
ridiculousfish
9b4310b10f Ensure we clear first_unwritten_new_item_index after history::merge
Prevents an issue where we think we've written out history items,
but we haven't, and so they get lost. Fixes #3496
2016-11-19 22:40:50 -08:00
Aaron Gyes
13a4ef80b3 Nuke spurious newline of shell exit.
Nobody has any idea why it's here, and it is mildy annoying to some
users, so let's remove it. Fixes #3502
2016-11-19 16:00:54 -08:00
ridiculousfish
0de2a1072f Fix a pair of implicit conversion warnings 2016-11-19 15:45:08 -08:00
Kurtis Rader
acd8363c38 allow complete -d ''
There isn't a good reason to disallow an explicitly empty completion
description. Since I'm touching the code also modify the argument
parsing the match the style of most of the builtins.

Fixes #3557.
2016-11-17 14:53:50 -08:00
Kurtis Rader
521546a986 fix some lint warnings
This fixes some of the IWYU and cppcheck lint warnings. And only on
macOS (formerly OS X). Fixing these types of warnings on a broader set
of platforms should be done but this is a baby step to making `make
lint-all` have few, if any, warnings. This reduces the number of lines
in the `make lint-all` output on macOS by over 500 lines.
2016-11-15 21:15:22 -08:00
Kurtis Rader
5284a133b0 silence "parameter 'notifier' is unused." 2016-11-11 21:07:30 -08:00
Kurtis Rader
5eb1ef4b4a use enum_map for parser enums
This simplifies the parsing code slightly and makes it more consistent
with how we deal with enums in the *builtin.cpp* module.
2016-11-11 18:56:56 -08:00
Kurtis Rader
5d6415b6bf use binary search for enum map lookups
Switch from a linear to a binary search when looking for a matching
string in an enum map. Testing shows this is a little more than twice as
fast when searching for keywords in the sixteen entry keyword_map array.
This speedup doesn't matter much when searching for subbcommands but any
slow down in the parser is unacceptable.
2016-11-11 18:02:43 -08:00
Kurtis Rader
6518b6c6b7 make subcommand lookups table driven
I'm going to use the same mechanism elsewhere such as token_type_map
in src/parse_tree.cpp. But this change only affects the recently
introduce subcommand handling for the history and status commands.
2016-11-08 15:30:52 -08:00
Kurtis Rader
609100c196 detect if the magic fish wide chars can be encoded
Verified on Cygwin on MS Windows 7 when invoked as
`env LANG=zh_CN.GBK@cjknarrow fish`. No regression seen
when run on other systems with UTF-8 locales.

Fixes #3503
2016-11-07 13:19:09 -08:00