Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rename _rb_u_aref_char_validated to _rb_u_dref

  • Loading branch information...
commit ab3a89edc4109cb4e8bf19882ca1867adf4f3bb4 1 parent 7e11742
Nikolai Weibull authored
View
2  ext/u/rb_private.h
@@ -2,7 +2,7 @@ void need_at_least_n_arguments(int argc, int n);
void need_m_to_n_arguments(int argc, int m, int n);
-uint32_t _rb_u_aref_char_validated(const char *str, const char *end);
+uint32_t _rb_u_dref(const char *str, const char *end);
char *rb_u_prev_validated(const char *begin, const char *p);
View
4 ext/u/rb_u.c
@@ -30,7 +30,7 @@ need_m_to_n_arguments(int argc, int m, int n)
}
uint32_t
-_rb_u_aref_char_validated(const char *str, const char *end)
+_rb_u_dref(const char *str, const char *end)
{
if (str >= end)
rb_u_raise(rb_eArgError, "String is empty");
@@ -93,7 +93,7 @@ _rb_u_character_test(VALUE self, bool (*test)(uint32_t))
const char *p = USTRING_STR(string);
const char *end = USTRING_END(string);
while (p < end) {
- if (!test(_rb_u_aref_char_validated(p, end)))
+ if (!test(_rb_u_dref(p, end)))
return Qfalse;
p = u_next(p);
View
2  ext/u/rb_u_string_chomp.c
@@ -12,7 +12,7 @@ rb_u_string_chomp_default(VALUE self)
if (last == NULL)
return self;
- if (_rb_u_aref_char_validated(last, end) == '\n') {
+ if (_rb_u_dref(last, end) == '\n') {
const char *last_but_one = u_find_prev(begin, last);
if (last_but_one != NULL && *last_but_one == '\r')
View
2  ext/u/rb_u_string_chop.c
@@ -27,7 +27,7 @@ rb_u_string_chop(VALUE self)
if (last == NULL)
return self;
- if (_rb_u_aref_char_validated(last, end) == '\n') {
+ if (_rb_u_dref(last, end) == '\n') {
const char *last_but_one = u_find_prev(begin, last);
if (last_but_one != NULL && *last_but_one == '\r')
View
2  ext/u/rb_u_string_count.c
@@ -32,7 +32,7 @@ rb_u_string_count(int argc, VALUE *argv, VALUE self)
long count = 0;
const char *end = USTRING_END(string);
for (char const *p = USTRING_STR(string); p < end; p = u_next(p))
- if (tr_table_lookup(&table, _rb_u_aref_char_validated(p, end)))
+ if (tr_table_lookup(&table, _rb_u_dref(p, end)))
count++;
return LONG2NUM(count);
View
2  ext/u/rb_u_string_each_codepoint.c
@@ -19,7 +19,7 @@ rb_u_string_each_codepoint(VALUE self)
const char *p = USTRING_STR(string);
const char *end = USTRING_END(string);
while (p < end) {
- rb_yield(UINT2NUM(_rb_u_aref_char_validated(p, end)));
+ rb_yield(UINT2NUM(_rb_u_dref(p, end)));
p = u_next(p);
}
View
8 ext/u/rb_u_string_each_line.c
@@ -34,7 +34,7 @@ rb_u_string_each_line_separator(VALUE self, const struct rb_u_string *separator)
long separator_length = USTRING_LENGTH(separator);
uint32_t first = (separator_length == 0) ?
- '\n' : _rb_u_aref_char_validated(USTRING_STR(separator), USTRING_END(separator));
+ '\n' : _rb_u_dref(USTRING_STR(separator), USTRING_END(separator));
const char *begin = USTRING_STR(string);
const char *base = begin;
@@ -42,19 +42,19 @@ rb_u_string_each_line_separator(VALUE self, const struct rb_u_string *separator)
const char *end = USTRING_END(string);
while (p < end) {
- uint32_t c = _rb_u_aref_char_validated(p, end);
+ uint32_t c = _rb_u_dref(p, end);
again:
if (separator_length == 0 && c == first) {
p = u_next(p);
if (p < end) {
- c = _rb_u_aref_char_validated(p, end);
+ c = _rb_u_dref(p, end);
if (c != first)
goto again;
}
while (p < end) {
- if (_rb_u_aref_char_validated(p, end) != first)
+ if (_rb_u_dref(p, end) != first)
break;
p = u_next(p);
View
14 ext/u/rb_u_string_format.c
@@ -104,7 +104,7 @@ directive_parse_int(const char **p, const char *end, const char *type)
int n = 0;
while (q < end) {
- uint32_t c = _rb_u_aref_char_validated(q, end);
+ uint32_t c = _rb_u_dref(q, end);
if (!u_char_isdigit(c)) {
*p = q;
@@ -265,7 +265,7 @@ directive_flags(const char **p, const char *end,
ID argument_id = 0;
while (*p < end) {
- uint32_t c = _rb_u_aref_char_validated(*p, end);
+ uint32_t c = _rb_u_dref(*p, end);
int flag;
@@ -345,7 +345,7 @@ directive_width(const char **p, const char *end,
if (*p == end)
return 0;
- uint32_t c = _rb_u_aref_char_validated(*p, end);
+ uint32_t c = _rb_u_dref(*p, end);
if (c != '*')
return directive_parse_int(p, end, "field width");
@@ -373,7 +373,7 @@ directive_precision(const char **p, const char *end)
if (*p == end)
return -1;
- uint32_t c = _rb_u_aref_char_validated(*p, end);
+ uint32_t c = _rb_u_dref(*p, end);
if (c != '.')
return -1;
@@ -475,7 +475,7 @@ directive_character(UNUSED(uint32_t directive), int flags, int width, UNUSED(int
if (!NIL_P(tmp)) {
const struct rb_u_string *string = RVAL2USTRING_ANY(tmp);
p = USTRING_STR(string);
- c = _rb_u_aref_char_validated(p, USTRING_END(string));
+ c = _rb_u_dref(p, USTRING_END(string));
length = (int)(u_next(p) - p);
} else {
char buf[U_CHAR_MAX_BYTE_LENGTH];
@@ -509,7 +509,7 @@ directive_string(UNUSED(uint32_t directive), int flags, int width, int precision
int i = 0;
const char *q = p, *end = p + length;
while (i < precision && q < end) {
- i += (int)u_char_width(_rb_u_aref_char_validated(q, end));
+ i += (int)u_char_width(_rb_u_dref(q, end));
q = u_next(q);
}
length = q - p;
@@ -1007,7 +1007,7 @@ directive(const char **p, const char *end, struct format_arguments *arguments, V
uint32_t c = '\0';
if (*p < end) {
- c = _rb_u_aref_char_validated(*p, end);
+ c = _rb_u_dref(*p, end);
*p = u_next(*p);
}
switch (c) {
View
6 ext/u/rb_u_string_internal_tr.c
@@ -26,7 +26,7 @@ tr_next_char(struct tr *t)
if (t->p == t->end)
return TR_FINISHED;
- if (_rb_u_aref_char_validated(t->p, t->end) == '\\') {
+ if (_rb_u_dref(t->p, t->end) == '\\') {
const char *next = u_find_next(t->p, t->end);
if (next == NULL) {
@@ -38,7 +38,7 @@ tr_next_char(struct tr *t)
t->p = next;
}
- t->now = _rb_u_aref_char_validated(t->p, t->end);
+ t->now = _rb_u_dref(t->p, t->end);
const char *next = u_find_next(t->p, t->end);
if (next == NULL) {
@@ -47,7 +47,7 @@ tr_next_char(struct tr *t)
}
t->p = next;
- if (_rb_u_aref_char_validated(t->p, t->end) == '-') {
+ if (_rb_u_dref(t->p, t->end) == '-') {
next = u_find_next(t->p, t->end);
/* TODO: Make this simpler. Perhaps we don’t need
* TR_READ_ANOTHER, as we advance it here ourselves. I got to
View
4 ext/u/rb_u_string_justify.c
@@ -14,7 +14,7 @@ rb_u_string_justify_one_side(char *p, const struct rb_u_string *padding, long pa
const char *q = padding_str;
const char *end = padding_str + padding_size;
while (i < n) {
- i += u_char_width(_rb_u_aref_char_validated(q, end));
+ i += u_char_width(_rb_u_dref(q, end));
q = u_next(q);
}
memcpy(p, padding_str, q - padding_str);
@@ -31,7 +31,7 @@ rounding_size(const struct rb_u_string *padding, long padding_width, long n)
long r = n % padding_width;
long i = 0;
while (i < r && q < end) {
- i += u_char_width(_rb_u_aref_char_validated(q, end));
+ i += u_char_width(_rb_u_dref(q, end));
q = u_next(q);
}
// NOTE I think i ≮ r is guaranteed, but I can’t seem to prove it, so
View
2  ext/u/rb_u_string_lstrip.c
@@ -15,7 +15,7 @@ rb_u_string_lstrip(VALUE self)
const char *end = USTRING_END(string);
const char *p = begin;
- while (p < end && u_char_isspace(_rb_u_aref_char_validated(p, end)))
+ while (p < end && u_char_isspace(_rb_u_dref(p, end)))
p = u_next(p);
if (p == begin)
return self;
View
4 ext/u/rb_u_string_ord.c
@@ -5,8 +5,8 @@ VALUE
rb_u_string_ord(VALUE self)
{
const struct rb_u_string *string = RVAL2USTRING(self);
- uint32_t c = _rb_u_aref_char_validated(USTRING_STR(string),
- USTRING_END(string));
+ uint32_t c = _rb_u_dref(USTRING_STR(string),
+ USTRING_END(string));
return UINT2NUM(c);
}
View
4 ext/u/rb_u_string_split.c
@@ -43,7 +43,7 @@ rb_u_string_split_awk(VALUE self, bool limit_given, int limit)
const char *end = USTRING_END(string);
int i = 1;
while (p < end) {
- while (p < end && u_char_isspace(_rb_u_aref_char_validated(p, end)))
+ while (p < end && u_char_isspace(_rb_u_dref(p, end)))
p = u_next(p);
if (p == end || (limit_given && i >= limit))
@@ -51,7 +51,7 @@ rb_u_string_split_awk(VALUE self, bool limit_given, int limit)
i++;
const char *q = p;
- while (q < end && !u_char_isspace(_rb_u_aref_char_validated(q, end)))
+ while (q < end && !u_char_isspace(_rb_u_dref(q, end)))
q = u_next(q);
rb_ary_push(result,
View
2  ext/u/rb_u_string_squeeze.c
@@ -13,7 +13,7 @@ rb_u_string_squeeze_loop(const struct rb_u_string *string, struct tr_table *tabl
uint32_t previous = U_N_CODEPOINTS;
char *base = result;
while (p < end) {
- uint32_t c = _rb_u_aref_char_validated(p, end);
+ uint32_t c = _rb_u_dref(p, end);
const char *next = u_next(p);
if (c != previous ||
View
2  ext/u/rb_u_string_strip.c
@@ -15,7 +15,7 @@ rb_u_string_strip(VALUE self)
const char *end = USTRING_END(string);
const char *s = begin;
- while (s < end && u_char_isspace(_rb_u_aref_char_validated(s, end)))
+ while (s < end && u_char_isspace(_rb_u_dref(s, end)))
s = u_next(s);
const char *t = end;
Please sign in to comment.
Something went wrong with that request. Please try again.