Commit Graph

40 Commits

Author SHA1 Message Date
Peter Ammon
1c38677db0
Minor cleanup of path_normalize_for_cd 2024-08-03 12:27:05 -07:00
Xiretza
fd006e02da Fix cd .. to the root directory
The leading slash always needs to be present, even if there aren't any other
components. This was introduced by the Rust port.
2024-07-29 10:23:29 -07:00
Peter Ammon
3d816174fd
Wildcard tree walking to only rely on dev, inode to detect changes
When applying a wildcard, it's important to keep track of the files that have
been visited, to avoid symlink loops. Previously fish used a FileId for the
purpose. However FileId also includes richer information like modification time;
thus if a file is modified during wildcard expansion then fish may believe that
the file is different and visit it twice.

The richer information like modification time is important for atomic file
writes but should be ignored for wildcard expansion; just use the (dev, inode)
pair instead.

This also somewhat reduces our reliance on struct stat, but we still need it for
fstatat which Rust does not expose.
2024-07-28 09:48:24 -07:00
Peter Ammon
3dc3aed991
Adopt fstat in file_id_for_fd 2024-07-27 18:58:34 -07:00
Peter Ammon
1332d33025
Introduce fstat() and adopt it in reader
Begin to migrate to Rust "native" Metadata, as part of addressing #10634

This will be structured as a series of small commits to aid bisecting.
2024-07-27 18:49:46 -07:00
Peter Ammon
0651ca0d9b
Unify FileId structs
We had two of these! Just use one.
2024-07-27 18:48:51 -07:00
Mahmoud Al-Qudsi
32a5be52e1 Add note about non-ASCII decimal_sep length 2024-06-19 18:50:24 -05:00
Mahmoud Al-Qudsi
28a3ae7a8b Remove Clone bound on parse_dec_float()
It's not necessary to clone the character iterator at all.
Also move rarely used inf/nan parsing to own cold function.
2024-06-19 18:43:53 -05:00
ridiculousfish
20e9c9493c Rewrite float parsing to use Rust native parsing
Eliminates the fast-float dependency.
2024-06-09 15:52:13 -07:00
ridiculousfish
838ff86ae7 Rename printf crate to fish-printf
Preparing to publish to crates.io
2024-06-09 12:29:09 -07:00
Fabian Boehm
ad73dcc308 Update nix to 0.29 2024-06-06 16:47:52 +02:00
Fabian Boehm
90bd8cc02b Remove errant .rs2 file 2024-06-04 21:55:43 +02:00
Mahmoud Al-Qudsi
1d159277c6 Move Block fields specific to certain block types to separate enum
This has a few advantages,
* We now statically assert that all fields used by a particular block type are
  correctly initialized (i.e. you can't assign the function name but forget to
  assign its arguments),
* Conversely, we can match directly on `BlockData` and be guaranteed that the
  fields we want to access are initialized and present,
* We reduce the number of assertions, effectively "unwrapping" only once based
  off the block type instead of each time we try to access a conditional field,
* We reduce the size of the `Block` struct by coalescing fields that cannot
  co-exist, bringing it down from 104 bytes to 88 bytes.

It would be nice to make all of `Block` itself an enum, but it currently
requires `Copy` and we take advantage of that to copy it around everywhere.
Putting these fields directly in `Block` directly would mean a lot more memory
traffic just checking block types.
2024-06-01 11:15:19 -05:00
ridiculousfish
f16a1361c5 Adopt the new printf crate
This drops our usage of printf-compat.
2024-05-26 16:07:27 -04:00
Fabian Boehm
b9b7dc5f6c fmt 2024-05-26 10:50:45 +02:00
Fabian Boehm
52d1806e1f Apply some manual clippy lints
Mostly replacing std::<type>::MAX with <type>::MAX.

Surprising here is replacing

.expect(format!(...))

with

.unwrap_or_else(|_| panic!(...))

It explains that this is because the "format!" would always be called.
2024-05-26 10:45:46 +02:00
ridiculousfish
08f8983085 Adopt the new hex float parsing
This eliminates hexponent.
2024-05-25 18:39:45 -07:00
ridiculousfish
bed2ff2ea6 Add homegrown hex float parsing
Hex float parsing may come about through wcstod, for example:

    printf "%f" '0x8p2'

should output 32.0.

Currently we use a not-great fork of hexponent. Hexponent has been dormant for
years, and has some issues: doesn't round properly, allocates unnecessarily,
doesn't handle denormals, is more complicated than necessary.

Just rewrite hex float parsing, fixing those problems and getting us off of this
weird fork.
2024-05-25 18:31:38 -07:00
Mahmoud Al-Qudsi
0b5e41b268 Rework path_normalize_for_cd() to be less allocation trigger happy
Lots of resizing, splicing, and full-on allocating going on here.
2024-05-21 12:54:52 -05:00
Mahmoud Al-Qudsi
d14d8d5733 Remove wcstringutil::split_string()
It is short and simple enough to write yourself if you need it and it encourages
bad behavior by a) always returning owned strings, b) always allocating them in
a vector. If/where possible, it is better to a) use &wstr, b) use an iterator.

In rust, it's an anti-pattern to unnecessarily abstract over allocating
operations. Some of the call sites even called split_string(..).into_iter().
2024-05-21 12:54:52 -05:00
Mahmoud Al-Qudsi
96b979077c Add unit tests for path_normalize_for_cd() 2024-05-21 12:54:51 -05:00
Mahmoud Al-Qudsi
883bcbad83 Remove possible panic from wperror() 2024-05-09 11:20:09 -05:00
Mahmoud Al-Qudsi
5f8f799cf7 Replace C++ doc \return with "Return"
quick_replace '\\\\return(s)? ' 'Return$1 ' src/

Filtered to only lines beginning with //
2024-05-06 14:59:36 -05:00
Mahmoud Al-Qudsi
589639a87d Replace C++-style \p with Markdown backticks
quick_replace '\\\\p ([a-zA-Z0-9_]+)' '`$1`' src/

Filtered to only lines beginning with //
2024-05-06 14:59:23 -05:00
Mahmoud Al-Qudsi
6b43a96d09 fixup! Work around i586 wcstod test failure 2024-05-04 20:29:40 -05:00
Mahmoud Al-Qudsi
4d58a31670 Work around i586 wcstod test failure
As documented in #10474, there are issues with 64-bit floating point rounding
under x86 targets without SSE2 extensions, where x87 floating point math causes
imprecise results.

Document the shortcoming and provide some version of the test that passes
regardless of architecture.
2024-05-04 20:21:56 -05:00
Johannes Altmanninger
adb40149a3 Do not insert key's PUA encoding into the command line
If a key's codepoint is in the PUA1 range, it could
be either from our own named keys (like key::Space)
or from a CSI u key that we haven't assigned a name yet
https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions
(The latter can still be bound using the \u1234 or the equivalent \e[4660u
raw CSI u sequence.)

It doesn't make sense to insert a PUA character into the commandline when
the user presses PrintScreen; ignore them silently.

This partially reverts b77d1d0e2 (Stop crashing on invalid Unicode input,
2024-02-27). That commit did:
1. convert input byte sequences that map to a PUA codepoint into several
   characters, using our on-char-per-byte PUA encoding.
2. do the same for inputs that are codepoints outside the valid Unicode range.
3. render them as replacement character (one per input byte)

In future, we should probably remove these features altogether, and simply
ignore invalid Unicode code points.
2024-04-09 00:46:16 +02:00
Johannes Altmanninger
3cfa09d1bd Make test_init() return a scope guard
To be used in the next commit.
2024-03-24 16:33:35 +01:00
Mahmoud Al-Qudsi
6ed4d09c93 Switch more to File/BorrowedFd from OwnedFd/RawFd
More work in prep for having wopen_cloexec() return `File` directly.

This eliminates checking for an invalid fd and makes both ownership and
mutability clear (some more operations that involve changes to the underlying
state of the fd now require `&mut File` instead of just a `RawFd`).

Code that clearly does not use non-blocking IO is ported to use
`Write::write_all()` directly instead of our rusty port of the `write_loop()`
function (which handles EAGAIN/EWOULDBLOCK in addition to EINTR, while
`write_all()` only handles the latter).
2024-03-23 00:01:57 -05:00
Mahmoud Al-Qudsi
58a6eb6e45 Convert fish_mkstemp_cloexec() to return an OwnedFd 2024-03-09 15:21:47 -06:00
The0x539
4296c49a06 Remove unnecessary scoped #[allow] attributes 2024-03-09 13:49:25 +01:00
Mahmoud Al-Qudsi
50ff6b8a34 Remove using statements already imported by preludes 2024-02-28 09:41:51 -06:00
Johannes Altmanninger
a1ed63fd83 Make wcwidth an isize
Seems more consistent with the rest of our code.
2024-02-15 01:27:23 +01:00
Fabian Boehm
6877773fdd
Fix build on NetBSD (#10270)
* Fix build on NetBSD

Notably:

1. A typo in `f_flag` vs `f_flags` - this was probably never tested
2. Some pointless name differences  - `st_mtimensec` vs
`st_mtime_nsec`
3. The big one: This said that LC_GLOBAL_LOCALE() was -1 "everywhere".
   Well, not on NetBSD.

* ifdef for macos
2024-01-28 21:45:14 +01:00
PolyMeilex
f3e8272c5d Move from libc read/write to nix read/write
Replace std from_raw_fd/into_raw_fd dance with nix write

Fixup notifyd build
2024-01-21 11:49:40 -08:00
Johannes Altmanninger
f356e2d82f Remove redundant fallbacks for installation dir variables
They are redundant as of a5e35abeb (build.rs: Default variables, 2024-01-15).
2024-01-20 10:26:54 +01:00
Mahmoud Al-Qudsi
6e002b6d80 Use cfg directly instead of going through features
Features should be for user-specifiable build configurations but our dynamic,
target-based conditional compilation is something else.
2024-01-13 15:16:47 -06:00
Fabian Boehm
0a92d03498 Remove L! from sprintf calls
Remove unnecessary L!
2024-01-13 08:52:54 +01:00
Fabian Boehm
09cd7c7ad9 Remove widestring-suffix uses
This removes both the `#[widestrs]` annotation as well as all `"foo"L`
suffixes, and does a `cargo fmt` run on the result
2024-01-13 08:52:54 +01:00
Johannes Altmanninger
3ae20bdba0 Move fish-rust to project root 2024-01-13 03:58:33 +01:00