Skip to content

More strings#73

Merged
mdbergmann merged 9 commits into
masterfrom
more-strings
Feb 12, 2026
Merged

More strings#73
mdbergmann merged 9 commits into
masterfrom
more-strings

Conversation

@mdbergmann
Copy link
Copy Markdown
Owner

No description provided.

mdbergmann and others added 9 commits February 12, 2026 15:22
New string functions to remove whitespace from strings:
- TRIM$(str$) removes leading and trailing spaces/tabs
- LTRIM$(str$) removes leading spaces/tabs only
- RTRIM$(str$) removes trailing spaces/tabs only

Implementation: 3 new enum symbols, rword[] entries, code gen cases
in basfun.c, and 68000 assembly runtime in new string2.s module.
Verified on emulator: all 7 ASSERT tests pass.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
New functions for string searching and matching:
- STARTSWITH(str$, prefix$) returns -1 if str$ begins with prefix$
- ENDSWITH(str$, suffix$) returns -1 if str$ ends with suffix$
- RINSTR([offset,] str$, find$) reverse search, returns last position

All return LONG type. Assembly runtime in string2.s.
Verified on emulator: all ASSERT tests pass (Phase 1 trim + Phase 2 search).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
New string transformation functions:
- REPLACE$(str$, find$, repl$) replaces all occurrences of find$ with repl$
- REVERSE$(str$) reverses a string
- REPEAT$(str$, count) repeats a string N times

Assembly runtime in string2.s with MAXSTRINGSIZE bounds checking.
Verified on emulator: all ASSERT tests pass (Phases 1-3).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
New string padding functions:
- LPAD$(str$, width, pad$) left-pads to target width with pad character
- RPAD$(str$, width, pad$) right-pads to target width with pad character

Both use first character of pad$ string. If str$ is already >= width,
returns str$ unchanged. Assembly runtime in string2.s.
Verified on emulator: all ASSERT tests pass (Phases 1-4).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
FMT$(format$, arg1, arg2, ...) supports up to 8 arguments:
- %d/%ld for decimal integers
- %x/%lx for hexadecimal (uppercase on Amiga platform)
- %s for string interpolation
- %c for single character
- %% for literal percent
- Width/padding modifiers (e.g., %08x)

Implementation: special varargs codegen stores args in BSS buffer,
assembly state machine in string2.s walks format string, delegates
integer formatting to _sprintf.
Verified on emulator: all 8 ASSERT tests pass.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Extends existing MID$ function with a statement form: MID$(x$, pos[, len]) = rhs$
that overwrites bytes in a string variable in-place, matching standard BASIC dialects.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
37 new assertions covering: LTRIM$/RTRIM$ empty/whitespace/tabs,
STARTSWITH/ENDSWITH exact match and empty strings, RINSTR edge cases,
REPEAT$ empty source, REPLACE$ start/end/consecutive, REVERSE$ two chars,
LPAD$/RPAD$ empty strings, FMT$ negative int/multi strings/empty format,
MID$ statement pos=1/capped rhs/empty rhs/pos beyond end.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…tegory

Add ref.txt entries for ENDSWITH, FMT$, LPAD$, LTRIM$, REPEAT$, REPLACE$,
REVERSE$, RINSTR, RPAD$, RTRIM$, STARTSWITH, TRIM$, and update MID$ with
statement form. Add corresponding quickref.txt entries.

Move 9 string-related test files from syntax/ to strings/ category:
case_convert, fmt_func, lcase, mid_stmt, pad_funcs, search_funcs,
transform_funcs, trim, ucase.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@mdbergmann mdbergmann merged commit 459fecf into master Feb 12, 2026
@mdbergmann mdbergmann deleted the more-strings branch February 19, 2026 19:55
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.

1 participant