Skip to content

Fix internal command {} arguments: Comment "" and {fu}/{ou} NAME (#141)#159

Merged
midwan merged 2 commits into
masterfrom
issue-141-internal-command-args
Jun 3, 2026
Merged

Fix internal command {} arguments: Comment "" and {fu}/{ou} NAME (#141)#159
midwan merged 2 commits into
masterfrom
issue-141-internal-command-args

Conversation

@midwan

@midwan midwan commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Fixes #141.

Two independent problems with the internal Protect/Comment commands.

Problem 3 — Comment COMMENT="" could not clear a filenote

An empty (or quoted-empty ""/'', whitespace-only) Comment argument now clears the
filenote. A shared helper function_change_arg_empty() detects these cases; the
DateStamp path reuses it.

Problem 1 — Protect NAME={fu} / NAME={ou} did nothing (or misbehaved)

For an internal command, a {fu}/{ou} (no-unselect) NAME now means "operate on the
current selection and keep it selected"
:

  • function_drop_brace_name_arg() clears the argument so function_build_list() gathers
    the live selection (with real lister entries) instead of the resolved control-byte
    string. The old approach routed a bare filename ({ou}) through find_entry() but a
    full path ({fu}) into the lock-file branch, losing the lister-entry link and the
    source-lister association.
  • After argument expansion (which consumes entries while expanding the code),
    function_run_instruction() rewinds the entry list and flags every entry
    FUNCENTF_NO_UNSELECT, so the whole selection is processed and stays selected.
  • function_change() reselects the replacement entry (FCF_SELECT) — a
    protection/comment/date change replaces the lister entry, which would otherwise drop
    the selection on redraw.

The gate is scoped to the no-unselect codes, so commands not invoked with {fu}/{ou}
are byte-for-byte unaffected.

Problem 2 from the issue (Protect with nothing ticked affecting all selected files) is
intentionally left out of scope.

Verification

  • Runtime-confirmed on AmigaOS 3: {fu} and {ou} apply +s, the lister
    auto-refreshes, and the selection is preserved; Comment "" clears the filenote.
  • Builds cleanly on all 5 targets: os3 (m68k), os4 (PPC AmigaOS 4), MorphOS (PPC),
    i386-AROS (ABIv0), x86_64-AROS (ABIv11).
  • Static regression tests: 109/109 pass.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b53cc43825

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread source/Program/function_files.c Outdated
…on (#141)

An internal command (Protect/Comment/...) invoked with NAME={fu} or NAME={ou}
previously did nothing or, for one code, mangled the result: the {} code was
resolved to a string and fed back to function_build_list(), which routes a bare
filename ({ou}) through find_entry() but a full path ({fu}) through the lock-file
branch, losing the lister-entry link and the source-lister association.

Treat such a NAME as 'operate on the current selection, keep it selected':
- function_drop_brace_name_arg() clears the argument so function_build_list() gathers
  the live selection (with real lister entries);
- function_run_instruction() rewinds the entry list and flags every entry
  FUNCENTF_NO_UNSELECT after argument expansion has consumed entries;
- function_change() reselects the replacement entry (FCF_SELECT) when the no-unselect
  intent applies, since changing protection/comment/date replaces the lister entry and
  would otherwise clear its selected state.

This makes {fu} and {ou} behave identically and matches the normal Protect/Comment flow,
so the lister refreshes and the selection is preserved. The special handling fires only
for a standalone {fu}/{ou} NAME - not an embedded form such as {fu}.info, which names
specific files, nor commands invoked without such a NAME - so all other cases are
byte-for-byte unaffected.
@midwan
midwan force-pushed the issue-141-internal-command-args branch from b53cc43 to 1bb305f Compare June 3, 2026 16:40
@midwan
midwan merged commit 7f1311a into master Jun 3, 2026
16 checks passed
@midwan
midwan deleted the issue-141-internal-command-args branch June 3, 2026 16:43
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.

Internal commands and {} arguments not working

1 participant