Commit Graph

108 Commits

Author SHA1 Message Date
Kurtis Rader
f6047f02d6 lint: constant conditional operator 2016-11-01 21:19:34 -07:00
Kurtis Rader
71e69b6d75 lint: empty if statement 2016-11-01 20:42:02 -07:00
Kurtis Rader
3bd24ddb17 lint: Use early exit/continue 2016-10-31 18:14:57 -07:00
Kurtis Rader
f382fa8e8a lint: multiple unary operator 2016-10-27 21:21:54 -07:00
Kurtis Rader
42458ff7ab lint: "collapsible if statements" warnings 2016-10-22 19:09:40 -07:00
Kurtis Rader
6e6b294a3f lint: deal with "double negative" warnings 2016-10-20 21:14:40 -07:00
Fredrik Fornwall
fe8727fb71 Fix building on Android by avoiding getpwent() (#3441)
* Fix building on Android by avoiding getpwent() if missing with autoconf check

The getpwent() function does not link when building for Android,
and user names on that platform are not interesting anyway.
2016-10-15 17:20:53 -07:00
Kurtis Rader
d389b22afc make style-all C++ style cleanup
It's time once again to run `make style-all` to fix some style bogosities
that have crept in.
2016-10-04 20:06:14 -07:00
Aaron Gyes
b17ebb4551 Merge branch 'master' of https://github.com/fish-shell/fish-shell 2016-09-10 14:52:15 -07:00
Aaron Gyes
9b5625a66b Some doc omissions in complete.cpp
And undo a couple unrelated changes that came along.
2016-08-16 18:43:00 -07:00
Aaron Gyes
6f53709b65 Complete.cpp docs omissions
Missed a few. Add back an assert we didn't intend to remove
2016-08-16 18:34:42 -07:00
Aaron Gyes
9daffc7080 HeaderDoc code documentation improvements
Some cleanup too, move things to builtin.h from builtin.cpp that seem
to belong there.
2016-08-16 18:00:07 -07:00
Kurtis Rader
10ae6d8b26 fix some style problems that have crept in 2016-07-21 19:36:32 -07:00
Kurtis Rader
1d2fff9686 simplify oclint error suppression for scoped_lock 2016-07-20 22:30:58 -07:00
ridiculousfish
f08ac969e9 Correctly handle trailing escaped spaces when completing
Fixes #2447
2016-07-11 14:03:53 -07:00
Aaron Gyes
0d6bdb38e6 Style fixes. 2016-06-23 22:48:45 -07:00
Aaron Gyes
fa78a7101c Make IWYU output in lint.cpp less messy
And re-run IWYU, adjust #includes.
2016-06-23 17:26:08 -07:00
Aaron Gyes
1357f5a364 Repair various invalid HeaderDoc comments.
Enable build setting to allow Xcode to complain about invalid
comments.
2016-06-05 18:57:45 -07:00
Kurtis Rader
db1ec847f9 fix lint error in wgettext()
Cppcheck was complaining about the `return val.c_str()` at the end of the
`wgettext()` function. That would normally a bug since the lifetime of
`val` ends when the function returns. In this particular case that's not
true because the string is interned in a cache. Nonetheless, rather than
suppress the lint warning I decided to modify the API to be more idiomatic.

In the process of fixing the aforementioned lint warning I fixed several other
lint errors in that module.

This required making our copy of `wgetopt()` compatible with the rest of
the fish code. Specifically, by removing its local definitions of the
"_" macro so it uses the same macro used everywhere else in the fish
code. The sooner we kill the use of wide chars the better.
2016-06-01 22:19:03 -07:00
Kurtis Rader
5bf1b0e5f5 fix random lint issues
This only eliminates errors reported by `make lint`. It shouldn't cause any
functional changes.

This change does remove several functions that are unused. It also removes the
`desc_arr` variable which is both unused and out of date with reality.
2016-05-29 22:24:29 -07:00
Kurtis Rader
9ad3488b5d fix some style bogosities that crept in 2016-05-27 14:44:30 -07:00
David Adam
9225b16d12 add (or restore) config.h to all files
The autoconf-generated config.h contains a number of directives which
may alter the behaviour of system headers on certain platforms. Always
include it in every C++ file as the first include.

Closes #2993.
2016-05-18 22:30:21 +00:00
Kurtis Rader
79f342b954 lint cleanup: eliminate "redundant" errors
This removes some pointless parentheses but the primary focus is removing
redundancies like unnecessary "else" clauses.
2016-05-04 15:32:04 -07:00
Kurtis Rader
fc44cffac5 restyle switch blocks to match project style
I missed restyling a few "switch" blocks to make them consistent with the rest
of the code base. This fixes that oversight. This should be the final step in
restyling the C++ code to have a consistent style. This also includes a few
trivial cleanups elsewhere.

I also missed restyling the "complete" module when working my way from a to z
so this final change includes restyling that module.

Total lint errors decreased 36%. Cppcheck errors went from 47 to 24. Oclint P2
errors went from 819 to 778. Oclint P3 errors went from 3252 to 1842.

Resolves #2902.
2016-05-03 17:14:56 -07:00
Kurtis Rader
1f06e5f0b9 add better support for IWYU and fix things
Remove the "make iwyu" build target. Move the functionality into the
recently introduced lint.fish script. Fix a lot, but not all, of the
include-what-you-use errors. Specifically, it fixes all of the IWYU errors
on my OS X server but only removes some of them on my Ubuntu 14.04 server.

Fixes #2957
2016-04-26 15:02:22 -07:00
ridiculousfish
e395a0eb69 Migrate PATH-completion logic from complete.cpp to expand.cpp
Prior to this fix, when completing a command that doesn't have a /, we
would prepend each component of PATH and then expand the whole thing. So
any special characters in the PATH would be interpreted when performing
tab completion.

With this fix, we pull the PATH resolution out of complete.cpp and
migrate it to expand.cpp. This unifies nicely with the CDPATH resolution
already in that file. This requires introducing a new expand flag
EXPAND_SPECIAL_FOR_COMMAND, which is analogous to EXPAND_SPECIAL_CD
(which is renamed to EXPAND_SPECIAL_FOR_CD). This flag tells expand to
resolve paths against PATH instead of the working directory.

Fixes #952
2016-04-07 20:15:32 -07:00
Andreas Nordal
6495bd470d Fix memory leaks at exit found in tests
This fixes all memory leaks found by compiling with
clang++ -g -fsanitize=address and running the tests.

Method:
Ensure that memory is freed by the destructor of its respective container,
either by storing objects directly instead of by pointer, or implementing
the required destructor.
2016-03-27 17:40:48 -07:00
ridiculousfish
88a785e321 Make expand_argument_list a static function
It doesn't use any properties of parser_t
2016-02-27 18:40:54 -08:00
ridiculousfish
d628fe0dea Eliminate parser_t::show_errors
Errors are now unconditionally shown
2016-02-27 18:37:59 -08:00
ridiculousfish
cbd3fa6b01 Eliminate parser_type_t
It was never fully implemented and wasn't used for anything
2016-02-27 18:25:58 -08:00
ridiculousfish
6cb48c6380 Allow variable completion from just a $
Previously there had to be some variable text, now you can
tab complete from just a naked $.
2016-02-27 16:51:44 -08:00
ridiculousfish
35160db268 Remove an unused variable 2016-02-22 03:37:03 -08:00
ridiculousfish
99e18d9cef Remove autosuggest_suggest_special 2016-02-18 17:00:26 -08:00
ridiculousfish
1907323afc Additional work on unifying cd autosuggestions with complete 2016-02-18 17:00:26 -08:00
ridiculousfish
c39b94949b Complete to take a pointer to output completions, not a mutable ref 2016-02-18 17:00:26 -08:00
ridiculousfish
31bc88d16f Migrate sort_and_prioritize to complete.cpp 2016-02-18 17:00:26 -08:00
ridiculousfish
2d68b25025 Early work towards moving the cd special autosuggestion into completions
This will simplify some code and make the cd autosuggestion smarter
2016-02-18 17:00:25 -08:00
ridiculousfish
766176443d Clean up completion removal
Rather than passing a triple of short, long, is_old, pass an option
as a string and then a type
2016-01-16 22:42:14 -08:00
ridiculousfish
3552d073f6 Mark a bit of code as unreachable 2016-01-16 16:03:09 -08:00
ridiculousfish
49d3042bd3 Simplify locking in complete.cpp 2016-01-16 16:00:57 -08:00
ridiculousfish
701d141109 Clean up complete_entry_opt_t
Rather than storing short and long options separately, using
a complicated set of invariants, store them in a single string
and use an explicit type complete_option_type_t to track how they
are interpreted.
2016-01-16 15:46:43 -08:00
ridiculousfish
870593e345 Remove short_opt_str from completion_entry_t
This was a "cache" of dubious value that was also very confusing.
The idea was to express in one place all of the short options that
were allowed for a command, in a big string.  But it's simpler to
just construct that on-demand by walking the list of
complete_entry_opt_t.
Also remove some other dead code as part of cleanup.
2016-01-15 17:27:02 -08:00
ridiculousfish
5cf0e918b0 Clean up short_ok in completions
Preparing to remove short_opt_string
2016-01-15 17:14:44 -08:00
ridiculousfish
d9d2f61ba6 When autoloading a completion, also autoload the function
Fixes a case where a --wraps declaration would be missed
because the function would not be loaded. Fixes #2466.
2015-10-07 18:59:41 -07:00
ridiculousfish
aeaacedf75 Don't do intermediate fuzzy directory matching with $PATH
When expanding an executable with $PATH, don't attempt to
interpret the directories in PATH as fuzzy matching. Fixes #2413.
2015-10-03 15:44:57 -07: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
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
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
b9b6b6108e Dead macro cleanup
Enable -Wunused-macros, and remove said unused macros
2015-08-10 22:01: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
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
a3f8e27bf8 rename ACCEPT_INCOMPLETE to FOR_COMPLETIONS, which is clearer 2015-08-08 13:55:49 -07:00
David Adam
a6a16808e3 Merge branch 'iwyu'
http://include-what-you-use.org/
2015-07-29 09:30:19 +08:00
ridiculousfish
6e3231a9d7 Stop passing mutable references to completions around
Replace uses of vector<completion_t>& with vector<completion_t>*
This makes it clear at the call site that the object may be mutated.
2015-07-27 18:45:47 -07:00
ridiculousfish
85dad6913e Support file tab completion after = and : separators
For example, env VAR=/usr<tab> will now work as expected

Fixes #2178
2015-07-27 13:43:20 -07:00
ridiculousfish
deacec07bf Fix a warning with g++ about an unused function result 2015-07-26 10:55:19 -07:00
David Adam
3929e9de0e Merge branch 'master' into iwyu 2015-07-26 10:20:13 +08:00
ridiculousfish
b4f53143b0 Migrate source files into src/ directory
This change moves source files into a src/ directory,
and puts object files into an obj/ directory. The Makefile
and xcode project are updated accordingly.

Fixes #1866
2015-07-24 00:59:27 -07:00