Skip to content

Fix cctz::format()/parse() to treat NULs like any other chars#338

Merged
derekmauro merged 1 commit intogoogle:masterfrom
devbww:format-parse-and-NULs
Mar 2, 2026
Merged

Fix cctz::format()/parse() to treat NULs like any other chars#338
derekmauro merged 1 commit intogoogle:masterfrom
devbww:format-parse-and-NULs

Conversation

@devbww
Copy link
Copy Markdown
Contributor

@devbww devbww commented Feb 19, 2026

The previous commit (PR #337) was couched in terms of parse() rejecting input strings containing NULs. Instead, we should treat NULs like other characters by allowing them in both the format and input strings.

Similarly, format() should allow NULs in its format string.

Also:

  • Simplify FormatTM() calls by handling an empty format string internally, rather than by guarding each invocation.
  • Utilize the std::string iterator-pair constructor and append().

The previous commit (PR google#337) was couched in terms of `parse()`
rejecting input strings containing NULs.  Instead, we should
treat NULs like other characters by allowing them in both the
format and input strings.

Similarly, `format()` should allow NULs in its format string.

Also:
 - Simplify `FormatTM()` calls by handling an empty format
   string internally, rather than by guarding each invocation.
 - Utilize the `std::string` iterator-pair constructor and
   `append()`.
Copy link
Copy Markdown
Member

@derekmauro derekmauro left a comment

Choose a reason for hiding this comment

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

Thank you. This is a more technically principled approach.

@derekmauro derekmauro merged commit 52f82e4 into google:master Mar 2, 2026
8 checks passed
@devbww devbww deleted the format-parse-and-NULs branch March 2, 2026 18:59
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.

2 participants