-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
split encoding.h #4909
Merged
Merged
split encoding.h #4909
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Why did they even exist?
My bad. The document is clearly broken. Maybe I pressed my delete key too much. [ci skip]
2,291 lines are too much! include/ruby/encoding.h became the biggest header file once it had doxygen comments. Let us split it into smaller parts, so that we can better organise their contents.
Less macros == huge win.
nobu
reviewed
Sep 29, 2021
nobu
reviewed
Sep 29, 2021
These functions assume ASCII compatibility. That has to be ensured in their caller.
Nobu doesn't like (char*) cast.
I meant diff --git a/string.c b/string.c
index 78e2ba923f3..7c2235450d6 100644
--- a/string.c
+++ b/string.c
@@ -5706,7 +5706,7 @@ rb_str_setbyte(VALUE str, VALUE index, VALUE value)
long pos = NUM2LONG(index);
long len = RSTRING_LEN(str);
char *head, *left = 0;
- unsigned char *ptr;
+ char *ptr;
rb_encoding *enc;
int cr = ENC_CODERANGE_UNKNOWN, width, nlen;
@@ -5717,18 +5717,18 @@ rb_str_setbyte(VALUE str, VALUE index, VALUE value)
VALUE v = rb_to_int(value);
VALUE w = rb_int_and(v, INT2FIX(0xff));
- unsigned char byte = NUM2INT(w) & 0xFF;
+ char byte = (char)(NUM2INT(w) & 0xFF);
if (!str_independent(str))
str_make_independent(str);
enc = STR_ENC_GET(str);
head = RSTRING_PTR(str);
- ptr = (unsigned char *)&head[pos];
+ ptr = &head[pos];
if (!STR_EMBED_P(str)) {
cr = ENC_CODERANGE(str);
switch (cr) {
case ENC_CODERANGE_7BIT:
- left = (char *)ptr;
+ left = ptr;
*ptr = byte;
if (ISASCII(byte)) goto end;
nlen = rb_enc_precise_mbclen(left, head+len, enc); |
@nobu That's also okay. But ultimately, |
But |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After I organise header files, this is the largest one now. I think it's a bit too large to read through. Why not split it into files.