Skip to content

Format: fixes substring ends before the start of the string - #2669

Merged
CarterLi merged 3 commits into
fastfetch-cli:devfrom
Don-Yin:fix-negative-slice-end
Oct 26, 2026
Merged

CarterLi merged 3 commits into
fastfetch-cli:devfrom
Don-Yin:fix-negative-slice-end

Conversation

@Don-Yin

@Don-Yin Don-Yin commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Summary

I got the whole Command result back when I used {result~0,-12} on 12345 67890, rather than an empty slice.

Related issue (required for new logos for new distros)

Closes #2668

Changes

I excluded still-negative ends from the unsigned upper-bound check, leaving the existing end > start check to produce the empty slice. I added one regression case and the required changelog entry.

Screenshots

Output before and after the fix

Checklist

  • I have tested my changes locally.

I ran clang-format, the CMake build, CTest, the CLI reproduction, JSON output and the all-module preset.

Comment thread CHANGELOG.md Outdated
* Added an ALSA fallback to Sound on Linux, so a machine that runs no sound server reports its output device and volume instead of an error. (Sound, Linux)

Bugfixes:
* Fixed substring formatting returning the remaining string when a negative end index is before the start of the string. (General)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.70.0 has been released. You should add a new section Unreleased

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I moved the entry into a new Unreleased section above 2.70.0. I reran the CMake build and CTest successfully.

I moved the unreleased fix out of the 2.70.0 section.

Signed-off-by: Don Yin <[email protected]>
@CarterLi
CarterLi merged commit ad62e3d into fastfetch-cli:dev Oct 26, 2026
CarterLi added a commit that referenced this pull request Nov 6, 2026
* Logo (Builtin): add Tiny Core Linux (#2655)

* Logo (Builtin): add Tiny Core Linux

* Logo (Builtin): use only the TinyCore name for Tiny Core

---------

Co-authored-by: UnixUserDev <[email protected]>

* Display (Wayland): uses DisplayConfig on GNOME if available

* Logo: treat a "$" ending a line or the logo as a plain dollar (#2667)

Fixes #2666

* Uptime (SunOS): improves detection via kstat

* Format: fixes substring ends before the start of the string (#2669)

* Format: fix substring ends before the start of the string

Closes #2668

Signed-off-by: Don Yin <[email protected]>

* Doc: moves changelog entry to Unreleased [ci skip]

I moved the unreleased fix out of the 2.70.0 section.

Signed-off-by: Don Yin <[email protected]>

---------

Signed-off-by: Don Yin <[email protected]>

* IO (Unix): fixes blocking forever on incomplete terminal responses

ffGetTerminalResponse() polls only before the first read(). If the terminal
sends a response that is cut short (e.g. `\e[4;800` without the rest), the
following read() in the loop blocks forever because the tty is in
non-canonical mode with VMIN=1.

Wait with the same timeout before every subsequent read() as well.

* IO (Windows): fixes blocking forever on incomplete terminal responses

Same issue as on Unix: ffGetTerminalResponse() waits for input only before
the first ReadFile(). If the terminal answers only part of the request
(e.g. one of the two OSC 10/11 replies), the next ReadFile() blocks forever.

Wait with the same timeout before every subsequent ReadFile() as well, and
restore the console mode on that error path. While waiting, also skip
key-up records: ReadFile() returns no data for them, so one left alone in
the buffer would end the wait and the following ReadFile() would block.

* Wifi (macOS): adds comments

* Separator: rejects empty string

Fixes #2689 #2690

* GPU (Linux): pad device and revision IDs when querying amdgpu.ids

In libdrm/amdgpu.ids, device IDs are formatted with 4 hex digits and
revision IDs with 2 uppercase hex digits (e.g. `1681,\t0B,`). Using
`%04X,\t%02X,` ensures both fields match the file syntax even when
values have leading zeros.

* CI: pins musl amd64 builds to Ubuntu 24.04

* Doc: updates changelog [ci skip]

* Format: fixes skipping nested conditionals

When a `{?arg}` / `{/arg}` conditional is skipped, the end of the skipped part
was the next `{?}` / `{/}` in the format string, even if it closed a
conditional nested in it. The text after the nested conditional was printed
and the real closing `{?}` / `{/}` was reported as an invalid placeholder.
A literal `{{?}}` inside the skipped part also ended it.

Skip to the `{?}` / `{/}` that matches the opening one, like the printing path
already does.

* Format: fixes integer wraparound when parsing numbers

Numbers that don't fit in 32 bits were truncated, so `{4294967297}` was read
as `{1}`, `{4294967296}` as the next argument, and `{$4294967297}` as the
first constant. The same applied to the start, end and length of `~`, `:`, `<`,
`>` and `|`. Clamp them instead, so that they stay out of range.

Also avoid negating INT32_MIN for the ellipsis length of `{1:-2147483648}`,
which is a signed integer overflow.

* Format: fixes substring with an end index outside of the string

`{1~20,30}` printed the placeholder as is, because the `,end` part was only
checked when the start index was inside the string. `{1~20}` printed nothing.
Parse and check the whole range first, so that a valid range that lies outside
of the string gives an empty result.

* Logo (Builtin): adds AstrOS logo (#2582)

* Logo: add AstrOS

* Update ASCII art in astros.txt

---------

Co-authored-by: Carter Li <[email protected]>

* Logo (Builtin): adds ArmadaOS (#2649)

* Logo: add ArmadaOS builtin ASCII logo

Closes #2641

* Change logo name from 'armada' to 'Armada'

* Update ASCII art in armada.txt

---------

Co-authored-by: Abhipsita-coder <[email protected]>
Co-authored-by: Carter Li <[email protected]>

* CI: Bump the github-actions group across 1 directory with 6 updates

Bumps the github-actions group with 6 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `7.0.1` | `7.0.2` |
| [actions/download-artifact](https://github.com/actions/download-artifact) | `8.0.1` | `8.0.2` |
| [cross-platform-actions/action](https://github.com/cross-platform-actions/action) | `1.6.0` | `1.7.0` |
| [github/codeql-action/init](https://github.com/github/codeql-action) | `4.38.2` | `4.39.1` |
| [github/codeql-action/analyze](https://github.com/github/codeql-action) | `4.38.2` | `4.39.1` |
| [vmactions/solaris-vm](https://github.com/vmactions/solaris-vm) | `1.4.1` | `1.4.2` |



Updates `actions/upload-artifact` from 7.0.1 to 7.0.2
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@043fb46...cf430e0)

Updates `actions/download-artifact` from 8.0.1 to 8.0.2
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@3e5f45b...9000827)

Updates `cross-platform-actions/action` from 1.6.0 to 1.7.0
- [Release notes](https://github.com/cross-platform-actions/action/releases)
- [Changelog](https://github.com/cross-platform-actions/action/blob/master/changelog.md)
- [Commits](cross-platform-actions/action@e0b9770...82668f1)

Updates `github/codeql-action/init` from 4.38.2 to 4.39.1
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@2892aa5...9b32540)

Updates `github/codeql-action/analyze` from 4.38.2 to 4.39.1
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@2892aa5...9b32540)

Updates `vmactions/solaris-vm` from 1.4.1 to 1.4.2
- [Release notes](https://github.com/vmactions/solaris-vm/releases)
- [Commits](vmactions/solaris-vm@87d3c43...1c16697)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: actions/download-artifact
  dependency-version: 8.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: cross-platform-actions/action
  dependency-version: 1.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: github/codeql-action/init
  dependency-version: 4.39.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.39.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: vmactions/solaris-vm
  dependency-version: 1.4.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <[email protected]>

* Shell: skips mise when detecting shell

* CI (Haiku): fixes building

* CPU (Windows): reads AArch64 ID registers for march detection

Mirrors the Linux HWCAP based logic so both platforms report the same march.
Documents the CP xxxx registry encoding, the field offsets/minimums and how to extend the detection.

* Android (AppLabel): reuses ffStrbufAppendUtf32CodePoint

The resource table decoder carried its own UTF-8 encoder for the strings
of a UTF-16 pool. The shared helper does the same and additionally maps a
code point outside U+10FFFF to U+FFFD instead of emitting four bytes that
are not valid UTF-8.

* Logo (Spin): adds a logo that turns in step with --watch

The builtin logo, or a text file in logo syntax, drawn as an extruded slab:
the front is the art as it is, the back is the art mirrored, and the side
walls are shaded with block glyphs. Rendering is pure: no terminal, no
input, no timer.

`--logo-type spin` hands every frame to the normal logo pipeline, so the
modules are laid out beside it exactly as they are for any other type, and
the first frame without --watch is byte-identical to the same art printed
as a builtin logo.

The rotation is driven by the `--watch` loop: `ffSpinTick()` runs once per
refresh and `ffLogoPrint()` is called only when it reports a step, so the
logo and the modules can never drift apart, and a build that never uses the
type costs one comparison per refresh.

Speed is set either as degrees per frame (--logo-spin-speed-per-frame,
default 10) or as seconds per revolution (--logo-spin-speed-per-round,
read from the clock and winning over the former when both are given). Both
take negative values to turn the other way, and --logo-spin-angle picks the
frame to start from.

* Shell: ignores atuin

Fixes #2704

* CI: upgrades NetBSD & OpenBSD

* Doc: updates changelog

* Logo (Builtin): adds openSUSE Leap Micro

Fixes #2703

* CI (OpenBSD): fixes building

* Global (macOS): makes fastfetch compile and work on macOS Mojave (10.14)

Ref: #2697

* Release: v2.71.0

* Display (Linux): fixes comments

---------

Signed-off-by: Don Yin <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: UnixUserDev <[email protected]>
Co-authored-by: UnixUserDev <[email protected]>
Co-authored-by: berce <[email protected]>
Co-authored-by: Don Yin <[email protected]>
Co-authored-by: ihsandeniz <[email protected]>
Co-authored-by: Kushagra Kumar <[email protected]>
Co-authored-by: mishalshanavas <[email protected]>
Co-authored-by: arxhr007 <[email protected]>
Co-authored-by: linux-universe <[email protected]>
Co-authored-by: Mohd Quamar Tyagi <[email protected]>
Co-authored-by: Abhipsita-coder <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sripati Ujwal Mithra <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Out-of-range negative slice end returns the whole string

2 participants