Adjust types to rb_enc_left_char_head
I dislike unnatural casts.
This commit is contained in:
parent
a15996c752
commit
cd182c5ee1
@ -694,7 +694,7 @@ rb_enc_prev_char(const char *s, const char *p, const char *e, const rb_encoding
|
|||||||
* @return Pointer to the head of the character that contains `p`.
|
* @return Pointer to the head of the character that contains `p`.
|
||||||
*/
|
*/
|
||||||
static inline char *
|
static inline char *
|
||||||
rb_enc_left_char_head(const char *s, const void *p, const char *e, const rb_encoding *enc)
|
rb_enc_left_char_head(const char *s, const char *p, const char *e, const rb_encoding *enc)
|
||||||
{
|
{
|
||||||
const OnigUChar *us = RBIMPL_CAST((const OnigUChar *)s);
|
const OnigUChar *us = RBIMPL_CAST((const OnigUChar *)s);
|
||||||
const OnigUChar *up = RBIMPL_CAST((const OnigUChar *)p);
|
const OnigUChar *up = RBIMPL_CAST((const OnigUChar *)p);
|
||||||
|
9
string.c
9
string.c
@ -5705,8 +5705,7 @@ rb_str_setbyte(VALUE str, VALUE index, VALUE value)
|
|||||||
{
|
{
|
||||||
long pos = NUM2LONG(index);
|
long pos = NUM2LONG(index);
|
||||||
long len = RSTRING_LEN(str);
|
long len = RSTRING_LEN(str);
|
||||||
char *head, *left = 0;
|
char *ptr, *head, *left = 0;
|
||||||
unsigned char *ptr;
|
|
||||||
rb_encoding *enc;
|
rb_encoding *enc;
|
||||||
int cr = ENC_CODERANGE_UNKNOWN, width, nlen;
|
int cr = ENC_CODERANGE_UNKNOWN, width, nlen;
|
||||||
|
|
||||||
@ -5717,18 +5716,18 @@ rb_str_setbyte(VALUE str, VALUE index, VALUE value)
|
|||||||
|
|
||||||
VALUE v = rb_to_int(value);
|
VALUE v = rb_to_int(value);
|
||||||
VALUE w = rb_int_and(v, INT2FIX(0xff));
|
VALUE w = rb_int_and(v, INT2FIX(0xff));
|
||||||
unsigned char byte = NUM2INT(w) & 0xFF;
|
char byte = (char)(NUM2INT(w) & 0xFF);
|
||||||
|
|
||||||
if (!str_independent(str))
|
if (!str_independent(str))
|
||||||
str_make_independent(str);
|
str_make_independent(str);
|
||||||
enc = STR_ENC_GET(str);
|
enc = STR_ENC_GET(str);
|
||||||
head = RSTRING_PTR(str);
|
head = RSTRING_PTR(str);
|
||||||
ptr = (unsigned char *)&head[pos];
|
ptr = &head[pos];
|
||||||
if (!STR_EMBED_P(str)) {
|
if (!STR_EMBED_P(str)) {
|
||||||
cr = ENC_CODERANGE(str);
|
cr = ENC_CODERANGE(str);
|
||||||
switch (cr) {
|
switch (cr) {
|
||||||
case ENC_CODERANGE_7BIT:
|
case ENC_CODERANGE_7BIT:
|
||||||
left = (char *)ptr;
|
left = ptr;
|
||||||
*ptr = byte;
|
*ptr = byte;
|
||||||
if (ISASCII(byte)) goto end;
|
if (ISASCII(byte)) goto end;
|
||||||
nlen = rb_enc_precise_mbclen(left, head+len, enc);
|
nlen = rb_enc_precise_mbclen(left, head+len, enc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user