Skip to content

Add checked parsing, BtechTextBuilder, and modernize string/file/event handling - #1

Closed
gtaylor wants to merge 1 commit into
mainfrom
codex/find-usage-of-mux.command-in-codebase
Closed

Add checked parsing, BtechTextBuilder, and modernize string/file/event handling#1
gtaylor wants to merge 1 commit into
mainfrom
codex/find-usage-of-mux.command-in-codebase

Conversation

@gtaylor

@gtaylor gtaylor commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Replace ad-hoc, unsafe numeric parsing and legacy file shelling with robust checked parsers and direct file I/O to avoid overflow, trailing-text, and shell-exec issues.
  • Provide a small bounded text builder API to simplify safe incremental formatted output and avoid repeated manual buffer manipulation.
  • Normalize string utilities and event failure handling so repair events can be persisted and restored deterministically.

Description

  • Added checked parsing helpers in mux/support/stringutil.{c,h}: parse_int_checked, parse_long_checked, parse_float_checked, plus supporting helpers and improved string_* APIs and matches_exit_from_list implementation; exported new prototypes in the header.
  • Introduced BtechTextBuilder with btech_text_builder.{h,c} and replaced many ad-hoc strcat/snprintf manipulations with builder calls in multiple UI files (mech_status_summary.c, mech_status_weapons_format.c, etc.).
  • Replaced legacy compressed-file helpers (my_open_file/my_close_file/template_file.c/mechfile_api.h) with plain fopen/fclose usage and removed the generated mech file API.
  • Added a persistent marker for failed repair events: renamed/added mech_event_failure_marker and replaced prior very_fake_func usages and prototypes across event/repair persistence and dispatch code.
  • Updated many callsites to use parse_*_checked instead of atoi/atof/strtol, added #include "mux/support/stringutil.h" where needed, and adjusted function names for stagger modifiers to clearer identifiers.
  • Build/test integration: added core/btech_text_builder.c to BTECH_SOURCES, added tests/btech_safe_helpers.c and a btech_safe_helpers_test executable and test entry in CMakeLists.txt (with -ffunction-sections/--gc-sections for test linking).

Testing

  • Added and executed the unit test btech_safe_helpers (registered in CTest as btech_safe_helpers) which exercises checked parsing and BtechTextBuilder; the test passed.
  • Performed a CMake build of the modified targets including the new test executable; build completed and the new test was run via ctest -R btech_safe_helpers successfully.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant