Commit graph

9333 commits

Author SHA1 Message Date
Fabian Homborg
e9ad88d4b0 Don't set the title on NetBSD's wscon
We might want to check the terminfo "XT" capability here, but for now
let's do the quick fix.
2018-12-31 14:24:23 +01:00
Fabian Homborg
b77a909a4f Make a few variables const
These are then passed to tparm, but we explicitly cast the const
away.
2018-12-31 14:24:23 +01:00
Fabian Homborg
58ceb00781 Make a few methods const
This helps on netbsd, because enter_standout_mode et al are const
there.

These methods don't alter their argument, so they should have been
const to begin with.
2018-12-31 14:24:23 +01:00
Fabian Homborg
c5f9f59555 Always cast to non-const for tparm
This is non-const on macOS, but some of the args we pass are always
const on netbsd.

I have no idea why you'd ever want this to modify its argument, but whatever.
2018-12-31 14:24:23 +01:00
Fabian Homborg
a608e5d581 cmake: Check for TPARM_VARARGS 2018-12-31 14:24:22 +01:00
Fabian Homborg
3e03625113 Don't try to use fstatfs on netbsd
I can find a man page for it, but it doesn't seem to work.
2018-12-31 14:24:22 +01:00
Fabian Homborg
e4b6007f33 Check for dirfd in autoconf build
This commit via
https://anonhg.netbsd.org/pkgsrc/file/tip/shells/fish/patches/patch-configure.ac,
credit to jklos@pkgsrc.org.
2018-12-31 14:24:22 +01:00
Fabian Homborg
ee5e4cf8e2 Use int tputs_arg_t on netbsd 2018-12-31 14:24:22 +01:00
Fabian Homborg
a3085a3059 Use varargs tparm on netbsd
This needs to be defined _early_.
2018-12-31 14:24:21 +01:00
Fabian Homborg
aaee5dd32d Rename "lines" for netbsd's benefit
Netbsd's curses does a bit of a landgrab, and takes the names "lines"
and "newline" and a few others for itself.
2018-12-31 14:24:21 +01:00
Fabian Homborg
a615151d91 Revert "tinyexpr: Make te_expr a class"
Turns out this crashes on musl when doing te_expr::parameter.push_back(). For some reason.

This reverts commit 2e11e6c692.
2018-12-31 10:37:13 +01:00
Fabian Homborg
7078aa4642 cmake: Add missing HAVE_WCSTOD_L #cmakedefine
Turns out we've been using the fallback everywhere.

See #5453.
2018-12-31 10:09:47 +01:00
Mahmoud Al-Qudsi
a8eb02f9f5 Fix wcstod_l detection under FreeBSD 2018-12-31 02:31:48 -06:00
Mahmoud Al-Qudsi
803619b19b Convert some old-school int booleans to bool 2018-12-31 00:46:31 -06:00
Mahmoud Al-Qudsi
0337588979 fixup! Do not use up the ~WNOHANG waitpid call on completed processes 2018-12-30 21:44:14 -06:00
Mahmoud Al-Qudsi
2ebdcf82ee Do not use up the ~WNOHANG waitpid call on completed processes
This is the more correct fix for #5447, as regardless of which process
in the job (be it the first or the last) finished first, once we have
waited on a process without ~WNOHANG we don't do that for any subsequent
processes in the job.

It is also a waste to call into the kernel to wait for a process we
already know is completed!
2018-12-30 20:53:25 -06:00
Mahmoud Al-Qudsi
bfe08a471d Remove fish_mutex_t wrapper around std::mutex
@ridiculousfish had introduced this in 3a45cad12e
to work around an issue with Coverity Scan where it couldn't tell the
mutex was correctly locked, but even with the `fish_mutex_t` hack, it
still emits the same warnings, so there's no pointing in keeping it.
2018-12-30 20:37:36 -06:00
Mahmoud Al-Qudsi
077d656b87 Allow redeclaration of main process via setup_fork_guards()
This is necessary for the history race condition test to succeed.

(That test is permanently disabled under WSL (as it always fails) so I
didn't catch this on my end.)
2018-12-30 20:23:39 -06:00
Mahmoud Al-Qudsi
b4301ff54f Drop initial_pid and optimize debug_shared() fast case
If we are running on the main thread, don't call `getpid()`
unnecessarily from `debug_shared()`.
2018-12-30 19:55:24 -06:00
Mahmoud Al-Qudsi
8dddc62aeb Optimize ASSERT_IS_NOT_FORKED_CHILD()
Use `pthread_atfork()` to mark child processes as dirty when `fork()` is
invoked rather than needing to call into the kernel each time
`ASSERT_IS_NOT_FORKED_CHILD()` is called.

This makes simple test cases that hit `ASSERT_IS_NOT_FORKED_CHILD()` 1.8x faster.

                        ------------------------

With a7998c4829 reverted but before this optimization:

```
mqudsi@ZBOOK ~/r/fish-shell> hyperfine -S build/fish 'for i in (seq 100000); test 1 = 1; end'
Benchmark #1: for i in (seq 100000); test 1 = 1; end

  Time (mean ± σ):     717.8 ms ±  14.9 ms    [User: 503.4 ms, System: 216.2 ms]
  Range (min … max):   692.3 ms … 740.2 ms
```

With a7998c4829 reverted and with this optimization:

```
mqudsi@ZBOOK ~/r/fish-shell> hyperfine -S build/fish 'for i in (seq 100000); test 1 = 1; end'
Benchmark #1: for i in (seq 100000); test 1 = 1; end

  Time (mean ± σ):     397.2 ms ±  22.3 ms    [User: 322.1 ms, System: 79.3 ms]
  Range (min … max):   376.0 ms … 444.0 ms
```

Without a7998c4829 reverted and with this optimization:

mqudsi@ZBOOK ~/r/fish-shell> hyperfine -S build/fish 'for i in (seq 100000); test 1 = 1; end'
Benchmark #1: for i in (seq 100000); test 1 = 1; end

  Time (mean ± σ):     423.4 ms ±  51.6 ms    [User: 363.2 ms, System: 61.3 ms]
  Range (min … max):   378.4 ms … 541.1 ms
```
2018-12-30 19:55:24 -06:00
Mahmoud Al-Qudsi
840619197e Optimize ASSERT_IS_MAIN_THREAD()
By using a user-land thread-local integer and lock-free (at least under
x86/x64) atomics, we can implement a safe `assert_is_main_thread()`
without calling into the kernel. Thread-local variables are part of
C++11.

This is called a lot in some performance-sensitive areas, so it is worth
optimizing.
2018-12-30 19:25:50 -06:00
Mahmoud Al-Qudsi
259cf02aac Wait on individual processes in a job in reverse order
This fixes #5438 by having fish block while waiting on a foreground job
via its individual processes by enumerating the procs in reverse order,
such that we hang waiting for the last job in the IO chain to terminate,
rather than the first.
2018-12-30 19:02:38 -06:00
Fabian Homborg
b0072482e4 Only warn on exec for background jobs
If it's a foreground job, it is related to the currently running exec.

This fixes exec in functions, i.e.

    function reload
        exec fish
    end

would previously always ask about the "function reload" job.

Fixes #5449.

Fixes oh-my-fish/oh-my-fish#664.
2018-12-30 22:32:07 +01:00
Fabian Homborg
e33d29a5d8 tinyexpr: Reserve arity parameters
This somehow fixes heap-buffer-overflow? I thought this was supposed
to be safe.
2018-12-30 20:34:13 +01:00
Fabian Homborg
2e11e6c692 tinyexpr: Make te_expr a class
Removes some #define weirdness.
2018-12-30 19:34:46 +01:00
Fabian Homborg
b8697e7795 tinyexpr: Rename te_variable to te_builtin
Variables aren't a thing here anymore.
2018-12-30 19:34:46 +01:00
Fabian Homborg
a433868363 tinyexpr: Make parameters te_expr* instead of void* 2018-12-30 19:34:46 +01:00
Fabian Homborg
e504faeb38 tinyexpr: Add Comments 2018-12-30 19:34:46 +01:00
Fabian Homborg
c3c1ae18c6 tinyexpr: C++ify find_builtin 2018-12-30 19:34:45 +01:00
Fabian Homborg
b193df8b42 tinyexpr: Move enums together and stop explicit numbering
We should _not_ be doing bit-fiddling with these, so there's no reason
to care about the number.

This also removes the unused "TE_VARIABLE" symbol.
2018-12-30 19:34:45 +01:00
Fabian Homborg
3bbec871e4 tinyexpr: Free all parameters again
This used implicit fallthrough to free all.

We still iterate back-to-front (i--) because maybe that's important?
2018-12-30 19:34:45 +01:00
Fabian Homborg
4674784a0b Make autotools build use tinyexpr.cpp 2018-12-30 19:34:45 +01:00
Fabian Homborg
26dfca67e5 Fix cmake build
Screwed up a rebase there!
2018-12-30 19:34:45 +01:00
Fabian Homborg
84ca265b48 tinyexpr: Unfiddle the bits
Mainly this removes the "TYPE_MASK" macro that just masks off the
higher bits, which I don't think were ever actually used.

Much of this seems like anticipation of future direction, but we're
going somewhere else.
2018-12-30 19:34:44 +01:00
Fabian Homborg
61e7f84e29 tinyexpr: Remove PURE flag
This was unused because all functions were marked as pure. We don't
have any plans to add any that aren't, and if we did we'd still have
this in git.
2018-12-30 19:34:41 +01:00
Fabian Homborg
cbc25d7829 [tinyexpr] Port to C++
This removes the need to run c-compilation on one file, and allows us
to in future c++-ify this a bit.

There's a lot of bit-fiddling here that is quite unnecessary, better
error-handling would be nice...

So far this removes a few more unused things (because I would have had
to port them), including:

- Functions with ARITY > 3 (even 3 isn't used, but just so we don't
get complacent)

- Variables

- Most functions moved out of the header, because only te_interp is used.

- The te_print function
2018-12-30 19:34:06 +01:00
Fabian Homborg
dabd05f2e3 Remove string fallback function
We already have a fallback here, and upgrading from 2.3.0 to 3.X will be rare.

This costs every shell on every start.

See #5279.
2018-12-30 19:24:03 +01:00
Fabian Homborg
a7998c4829 Don't ASSERT_IS_NOT_FORKED_CHILD so much
This is hammered sooo much that it actually hurts performance.

    for i in (seq 100000); test 1 = 1; end

is about 40% (!) slower with it.
2018-12-30 18:59:41 +01:00
Mahmoud Al-Qudsi
040d921fa1 Fix check for valid disowned pgids
The function `add_disowned_pgid` adds process *group* ids and not
process ids. It multiplies the value by negative 1 to indicate a wait
on a process group, so the original value must be positive.
2018-12-30 10:15:07 -06:00
Fabian Homborg
4a3ac6e91e Don't wait for disowned pgids if they are special
If a job is disowned that, for some reason, has a pgid that is special
to waitpid, like 0 (process with pgid of the calling process), -1 (any
process), or our actual pgid, that would lead to us waiting for too
many processes when we later try to reap the disowned processes (to
stop zombies from appearing).

And that means we'd snag away the processes we actually do want to
wait for, which would end with us in a waiting loop.

This is tough to reproduce, the easiest I've found was

    fish -ic 'sleep 5 &; disown; set -g __fish_git_prompt_showupstream auto; __fish_git_prompt'

in a git repo.

What we do is to not allow special pgids in the disowned_pids list.
That means we might leave a zombie around (though we probably wait on
0 somewhere), but that's preferable to infinitely looping.

See #5426.
2018-12-30 16:04:57 +01:00
David Adam
32e6bf6f64 debian packaging/fish.spec: drop bc dependency 2018-12-29 23:16:09 +08:00
David Adam
8261eb18d2 pcre2: add maintainer mode and disable by default 2018-12-29 22:54:54 +08:00
David Adam
b60a9d8c4a pcre2: move to PCRE2 10.32
Closes #5353.
2018-12-29 22:54:40 +08:00
Fabian Homborg
742fde0dd6 Don't use less in highlighting test
It doesn't have to be installed.

`cat` is in our dependencies, so we can assume it's there.

Fixes #5436.
2018-12-28 17:57:53 +01:00
David Adam
9e4ece8d89 CHANGELOG: next-minor updates, up to 05222a055a
[ci skip]
2018-12-28 22:18:35 +08:00
David Adam
05222a055a Merge branch 'Integration_3.0.0' 2018-12-28 22:10:49 +08:00
David Adam
938ce48d25 Bump version for 3.0.0 2018-12-28 21:01:03 +08:00
David Adam
0c25d7a49c CHANGELOG: 3.0.0 updates 2018-12-28 20:56:17 +08:00
hrvoj3e
69a1c5a3a1 Fix typos in anchor to fish_opt 2018-12-27 14:45:14 +01:00
Mahmoud Al-Qudsi
fb679ac9c3 Add completions for pkg [info|show|list] 2018-12-23 20:06:25 -06:00