Skip to content

internal.h: shorten the mrb_str_valid_encoding_p comment - #7108

Merged
matz merged 1 commit into
mruby:masterfrom
takumin:internal-h-valid-encoding-comment
Aug 12, 2026
Merged

internal.h: shorten the mrb_str_valid_encoding_p comment#7108
matz merged 1 commit into
mruby:masterfrom
takumin:internal-h-valid-encoding-comment

Conversation

@takumin

@takumin takumin commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

The comment on the declaration of mrb_str_valid_encoding_p, added in #7105,
restated the one on the definition in string.c: which flag the walk declines to
read on the way in, why reading it would make the answer depend on whether the
string had been measured before, and which flag a string that walks to one byte
per character is left with.

A caller reading the header needs the answer the function gives, not how it
arrives at one. Keep the three answers it has to know, which are the two strings
the walk never touches and the one it rejects, and leave the rest at the
definition, where the code that does the walking is.

/* Whether a string's bytes read as the encoding it is taken to have: FALSE for
   one holding a byte that stands for no character, TRUE for a binary string
   whatever its bytes are, and TRUE throughout on a non-UTF-8 build. See the
   definition in string.c for what it reads and what it leaves behind. */
mrb_bool mrb_str_valid_encoding_p(mrb_state *mrb, mrb_value str);

Comment only; no code changes.

Verified

  • rake test on a full-core build: 2246 tests, all green
  • prek run --all-files passes, except that markdownlint could not install
    locally (npm engine mismatch); no Markdown is touched here

Summary by CodeRabbit

  • Documentation
    • Clarified documentation for string encoding validation, including behavior for binary strings and non-UTF-8 encodings.

The comment on the declaration restated the one on the definition: which
flag the walk declines to read on the way in, why reading it would make the
answer depend on whether the string had been measured before, and which flag
a string that walks to one byte per character is left with.

A caller reading the header needs the answer the function gives, not how it
arrives at one. Keep the three answers it has to know, which are the two
strings it never walks and the one it rejects, and leave the rest at the
definition, where the code that does the walking is.
@takumin
takumin requested a review from matz as a code owner August 12, 2026 08:39
@github-actions github-actions Bot added the core label Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8a19773c-d1b1-4c0d-a867-0f2faf36d297

📥 Commits

Reviewing files that changed from the base of the PR and between 6817857 and d8bb1ad.

📒 Files selected for processing (1)
  • include/mruby/internal.h

📝 Walkthrough

Walkthrough

The documentation for mrb_str_valid_encoding_p now describes its results for invalid-byte strings, binary strings, and non-UTF-8 builds. No public declarations changed.

Changes

String encoding documentation

Layer / File(s) Summary
Encoding result documentation
include/mruby/internal.h
The documentation now explains when mrb_str_valid_encoding_p returns true or false for relevant string encodings.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

  • mruby/mruby#7102: Introduces and implements mrb_str_valid_encoding_p, which this PR documents.

Suggested reviewers: matz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: shortening the mrb_str_valid_encoding_p comment in internal.h.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@matz
matz merged commit 592f029 into mruby:master Aug 12, 2026
21 checks passed
@takumin
takumin deleted the internal-h-valid-encoding-comment branch August 12, 2026 09:43
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.

2 participants