aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
Commit message (Collapse)AuthorAge
...
* Update usage of pcre2_substitute() for pcre2-10.21Gravatar Michael Steed2016-04-27
| | | | | | | - Set PCRE2_SUBSTITUTE_OVERFLOW_LENGTH to get the required buffer length from pcre2 instead of guessing - Set PCRE2_SUBSTITUTE_EXTENDED to enable extra goodies in the replacement string
* add better support for IWYU and fix thingsGravatar Kurtis Rader2016-04-26
| | | | | | | | | 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
* make comments Xcode friendlyGravatar Kurtis Rader2016-04-19
| | | | | | The OS X Xcode IDE has a weird requirement that block comments preceding a function or class definition must begin with three slashes rather than two if you want the comment displayed in the "Quick Help" window.
* restyle autoload module to match project styleGravatar Kurtis Rader2016-04-18
| | | | | | Reduces lint errors from 38 to 19 (-50%). Line count from 506 to 426 (-16%). Another step in resolving issue #2902.
* restyle builtin module to match project styleGravatar Kurtis Rader2016-04-18
| | | | | | Reduces lint errors from 271 to 215 (-21%). Line count from 4304 to 3242 (-25%). Another step in resolving issue #2902.
* restyle history code to match project styleGravatar Kurtis Rader2016-04-18
| | | | | | | | | | | | | | | | | | | | | | | Make the history code conform to the new style guide. Every change was produced by clang-format (e.g., `make style`) with the exception of comments which were manually reformatted. That has to be done by hand since clang-format leaves comments alone other than to reflow comment lines to get them below the allowed line length. The total number of lines is reduced by 313 lines (13%) in the two affected files. Line count is generally a poor metric but in this case it reflects an increase in information density without a loss in readability. Furthermore, the standardization of braces, whitespace, and comment style will make it easier for people to read the code. This reduces the number of warnings by `make lint` from 168 to 87 (a 48% decrease). Making it much easier to focus on the substantive lint issues. Further improvements are possible. For example, many comments are not very helpful (e.g., they point out the obvious) or provide insufficient detail. But those are beyond the scope of this change. This is the first step in resolving issue #2902.
* fix off by one errorGravatar Kurtis Rader2016-04-13
|
* fish handling of readlink()Gravatar Kurtis Rader2016-04-12
| | | | | | | | | | | | The readlink() function does not null terminate the path it returns. Remove the OS X code that deals with a path buffer that is too short. For one thing a loop isn't needed since we're told how big of a buffer is required if the first _NSGetExecutablePath() call fails. But more important it is so unlikely that the path will be longer than PATH_MAX that if it is we should just give up. Fixes 2931.
* revert inadvertent file inclusion in prior commitGravatar Kurtis Rader2016-04-12
| | | | | Commit 6431c0de16937622a2664c417f517d002220e017 was not meant to include changes to fish.cpp.
* fix bug in lint.fish helper scriptGravatar Kurtis Rader2016-04-12
| | | | | | | I just noticed that depending on the state of your working tree there can be one or more spaces after the modification token and the file name. If there is more than one space that causes the `string split` to produce unexpected output.
* another wcstring to wchar_t * changeGravatar Kurtis Rader2016-04-10
| | | | | | | | | | | In keeping with the change made by @ridiculousfish earlier today modify the `keyword_description()` function to return a const wchar_t pointer. Also, simplify the `token_type_description()` function to use the recently introduced mapping array. This changes the wording of many of the token type descriptions. However, I can't see this as being a problem since the original descriptions (e.g., "token_redirection") are no clearer to someone not acquainted with the implementation.
* enhance fish_indent to normalize keywordsGravatar Kurtis Rader2016-04-10
| | | | | | | | | | | Fish keywords can be quoted and split across lines. Prior to this change `fish_indent` would retain such odd, obfuscated, formatting. This change results in all keywords being converted to their canonical form. This required fixing a bug: the keyword member of parse_node_t wasn't being populated. This hadn't been noticed prior to now because it wasn't used. Fixes #2921
* Change parser_token_types from wcstring to const wchar_t *Gravatar ridiculousfish2016-04-10
| | | | Reduces allocations and startup time
* Fix #2919 by removing the entire block.Gravatar Aaron Gyes2016-04-09
| | | | | | | | | | | | | | This code represents only risk and does nothing useful for anything that can compile fish. In C++ situations where __STDC_VERSION__ is unset (as it should be), fish was assuming we are on < C99 and setting it to __FUNCTION__. Basically always, __PRETTY_FUNCTION__ ends up reaplaced by __FUNCTION__, this hurt error message usefulness and richness. __PRETTY_FUNCTION__: const thing::sub(int) __FUNCTION__: sub
* fix handling of line continuation in keywordsGravatar Jak Wings2016-04-08
| | | | | | | This behavior is more consistent with line continuation in strings other than keywords. Fixes #2897
* add missing special-case for ../Gravatar Kurtis Rader2016-04-08
| | | | | When I reviewed the fix for #952 I noted that "../" wasn't handled but in my haste to merge it forgot to augment the pull-request.
* Migrate PATH-completion logic from complete.cpp to expand.cppGravatar ridiculousfish2016-04-07
| | | | | | | | | | | | | | | | 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
* Implement an --invert/-v for string match, like grep -v.Gravatar Aaron Gyes2016-04-08
| | | | Only lines that do not match the pattern are shown.
* Complain less about "bogus" PATH entriesGravatar ridiculousfish2016-04-07
| | | | | | When determining the old path, get the existing value in any scope, not just the set scope. Also only complain about absolute paths: relative paths are expected to be invalid sometimes.
* Remove a dead function bool_from_env_varGravatar ridiculousfish2016-04-07
|
* fix setting of $argv for `source` w/no argsGravatar Kurtis Rader2016-04-06
| | | | Fixes #139
* change how redirections are formattedGravatar Kurtis Rader2016-04-05
| | | | | | | | Modify `fish_indent` to emit redirections without a space before the target of the redirection; e.g., "2>&1" rather than "2>& 1" as the former is clearer to humans. Fixes #2899
* don't try to use st_gen (inode generation) numberGravatar Aaron Gyes2016-04-04
| | | | | | | | | Per discussion in pull-request #2891, it's not available on Linux (we just fill it with zero), and unless run as root on OS X (or other BSD system) it will be zero. Remove it from file_id_t. Also fix the initialization of the file_id_t structure. Fixes #2891
* remove unused special color "ignore"Gravatar Kurtis Rader2016-04-04
| | | | | | Resolve lint warning about unused method "rgb_color_t::ignore()". Fixes #2893
* fixes for cppcheck lint warningsGravatar Kurtis Rader2016-04-04
| | | | | | Refine the linting behavior. Fix several of the, mostly trivial, lint errors.
* convert atypical env_universal_common loggingGravatar Kurtis Rader2016-04-03
| | | | | | | | | | This is a quick and dirty conversion of the atypical, and undocumented, logging done by env_universal_common.cpp to the usual `debug()` pattern. I didn't want to drop the messages because they could be useful when debugging future issues. So I simply converted them to the lowest debug level using the normal debug() function. Fixes #2887
* lint: remove or comment out unused functionsGravatar Kurtis Rader2016-04-03
| | | | | | Cppcheck has identified a lot of unused functions. This removes funcs that are unlikely to ever be used. Others that might be useful for debugging I've commented out with "#if 0".
* remove unused wgetopt() method found by lintingGravatar Kurtis Rader2016-04-02
|
* Remove an unnecessary c_str()Gravatar ridiculousfish2016-03-27
|
* Fix memory leaks at exit found in testsGravatar Andreas Nordal2016-03-27
| | | | | | | | | | 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.
* `fish --version` should write to stdoutGravatar Kurtis Rader2016-03-23
| | | | | | | | | When explicitly asking for the fish version string the information should go to stdout rather than stderr. Also, there is no reason to use exit_without_destructors() rather than exit() in that code path. We actually want the side-effects of exit() such as flushing stdout and there aren't any threads or other things that could cause a normal exit to fail when that function is run.
* Fix memory leak, error message when failing to open input fileGravatar Andreas Nordal2016-03-22
| | | | | | | | | | | | | The early return skipped all cleanup. This problem is a case for the classic "goto fail" paradigm, but this change instead makes a few adjustments to take advantage of a previously unused level of indentation to conditionally execute the success path. The error message now prints the filename instead of "open", which should be more idiomatic. Tip: This patch makes sense if viewed with `git show --ignore-space-change`.
* implement swap-selection-start-stop functionGravatar Federico Ferri2016-03-20
| | | | | | | | | The swap-selection-start-stop function goes to the other end of the highlighted text, the equivalent of `o' for vim visual mode. Add binding to the swap-selection-start-stop function, `o' when in visual mode. Document swap-selection-start-stop, begin-selection, end-selection, kill-selection.
* fix handling of non-ASCII chars in C localeGravatar Kurtis Rader2016-03-20
| | | | | | | | | | | | The relevant standards allow the mbtowc/mbrtowc functions to reject non-ASCII characters (i.e., chars with the high bit set) when the locale is C or POSIX. The BSD libraries (e.g., on OS X) don't do this but the GNU libraries (e.g., on Linux) do. Like most programs we need the C/POSIX locales to allow arbitrary bytes. So explicitly check if we're in a single-byte locale (which would also include ISO-8859 variants) and simply pass-thru the chars without encoding or decoding. Fixes #2802.
* env_universal_common: use uid_t in geteuid checksGravatar David Adam2016-03-18
| | | | | | | | | The u_int typedef fails to compile on all platforms (e.g. Windows). It is part of the code imported from tmux. Update it to the SUS-standard uid_t. Closes #2821.
* parse_execution.cpp: Remove line continuationsGravatar Andreas Nordal2016-03-17
| | | | My IDE (Kdevelop 4.7.3) didn't tackle them.
* Improve error handling around fchownGravatar Jeff Kowalski2016-03-12
| | | | | | | | | Address the feedback from the prior commit: - Change the sense of return value testing to match more common comparison idiom - Test result of fchmod as well as fchown - Change sense of return value testing around wrename as well - Include errno where possible in error message
* Handle return values from fchownGravatar Jeff Kowalski2016-03-12
| | | | | | | | | | | The function fchown is annotated with warn_unused_result. As formerly used in the code, it would emit a compiler warning ```warning: ignoring return value of ‘fchown’, declared with attribute warn_unused_result [-Wunused-result]``` This commit notes the return value and emits appropriate error/logging messages if the call fails, creating more traceable results and satisfying the compiler.
* assume getopt/getopt_long is availableGravatar Kurtis Rader2016-03-08
| | | | | | | | | | | There is no longer a good reason to detect whether or not getopt_long() is available. All UNIX implementations we're likely to run on have it. And if we ever find one that doesn't the right thing to do is not fallback to getopt() but to include the getopt_long() source in our package like we do with the pcre2 library. Since it's licensed under LGPL we can legally do so if it becomes necessary. This partially addresses issue #2790.
* expand_string should not return any results on errorGravatar ridiculousfish2016-03-05
| | | | Fixes #2796
* Save a few string allocations when importing environment variablesGravatar ridiculousfish2016-03-05
|
* Prefer the first, not last, of any env var duplicatesGravatar ridiculousfish2016-03-05
| | | | | If envp contains duplicate environment variables, use the first value, not the last value. Fixes #2784.
* A few fixes suggested by Coverity ScanGravatar ridiculousfish2016-03-03
|
* Tweak UTF8 decoding interfaceGravatar ridiculousfish2016-03-02
| | | | | | | | Previously, when decoding UTF-8, we would first run through the array to compute the correct size, then allocate a buffer of that size, then run through the array again to fill the buffer, and then copy it into a std::wstring. With this fix we can copy it into the string directly, reducing allocations and only requiring a single pass.
* reduce number of Unicode private-use charactersGravatar Kurtis Rader2016-02-28
| | | | | | | | | This narrows the range of Unicode codepoints fish reserves for its own use from U+E000 thru U+F8FE (6399 codepoints) to U+F600 thru U+F73F (320 codepoints). This is still not ideal since fish shouldn't be using any Unicode private-use codepoints but it's a step in the right direction. This partially addresses issue #2684.
* Eliminate narrow_string_rep_tGravatar ridiculousfish2016-02-28
| | | | | | | | | | This was used to cache a narrow string representation of commands, so that if certain system calls returned errors after fork, we could output error messages without allocating memory. But in practice these errors are very uncommon, as are commands that have wide characters. It is simpler to do a best-effort output of the wide string, instead of caching a narrow string unconditionally.
* Re-use the parse tree generated during error detection for executionGravatar ridiculousfish2016-02-28
| | | | | | | Prior to this fix, read_ni would use parse_util_detect_errors to lint the script to run, and then parser_t::eval() to execute it. Both functions would parse the script into a parse tree. This allows us to re-use the parse tree, improving perfomance.
* Allow parse_execution_context to take ownership of a parse treeGravatar ridiculousfish2016-02-28
| | | | | | Introduces a new template moved_ref which is like an rvalue reference. This allows passing around objects while being explicit that the receiver may acquire ownership. This will help reduce some allocations.
* Add missing #include guards in FISH_PAGER_HGravatar ridiculousfish2016-02-27
|
* Remove unused MESS_SIZE defineGravatar ridiculousfish2016-02-27
|