summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c108
1 files changed, 54 insertions, 54 deletions
diff --git a/src/string.c b/src/string.c
index 4ef5461c4..d5a849cec 100644
--- a/src/string.c
+++ b/src/string.c
@@ -914,7 +914,7 @@ static mrb_value
mrb_str_capitalize_bang(mrb_state *mrb, mrb_value str)
{
char *p, *pend;
- int modify = 0;
+ mrb_bool modify = FALSE;
struct RString *s = mrb_str_ptr(str);
mrb_str_modify(mrb, s);
@@ -922,12 +922,12 @@ mrb_str_capitalize_bang(mrb_state *mrb, mrb_value str)
p = STR_PTR(s); pend = STR_PTR(s) + STR_LEN(s);
if (ISLOWER(*p)) {
*p = TOUPPER(*p);
- modify = 1;
+ modify = TRUE;
}
while (++p < pend) {
if (ISUPPER(*p)) {
*p = TOLOWER(*p);
- modify = 1;
+ modify = TRUE;
}
}
if (modify) return str;
@@ -1128,7 +1128,7 @@ static mrb_value
mrb_str_downcase_bang(mrb_state *mrb, mrb_value str)
{
char *p, *pend;
- int modify = 0;
+ mrb_bool modify = FALSE;
struct RString *s = mrb_str_ptr(str);
mrb_str_modify(mrb, s);
@@ -1137,7 +1137,7 @@ mrb_str_downcase_bang(mrb_state *mrb, mrb_value str)
while (p < pend) {
if (ISUPPER(*p)) {
*p = TOLOWER(*p);
- modify = 1;
+ modify = TRUE;
}
p++;
}
@@ -1846,7 +1846,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
char *ptr = RSTRING_PTR(str);
char *eptr = RSTRING_END(str);
char *bptr = ptr;
- int skip = 1;
+ mrb_bool skip = TRUE;
unsigned int c;
end = beg;
@@ -1859,14 +1859,14 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
}
else {
end = ptr - bptr;
- skip = 0;
+ skip = FALSE;
if (lim_p && lim <= i) break;
}
}
else if (ascii_isspace(c)) {
mrb_ary_push(mrb, result, mrb_str_subseq(mrb, str, beg, end-beg));
mrb_gc_arena_restore(mrb, ai);
- skip = 1;
+ skip = TRUE;
beg = ptr - bptr;
if (lim_p) ++i;
}
@@ -2280,7 +2280,7 @@ mrb_str_upcase_bang(mrb_state *mrb, mrb_value str)
{
struct RString *s = mrb_str_ptr(str);
char *p, *pend;
- int modify = 0;
+ mrb_bool modify = FALSE;
mrb_str_modify(mrb, s);
p = RSTRING_PTR(str);
@@ -2288,7 +2288,7 @@ mrb_str_upcase_bang(mrb_state *mrb, mrb_value str)
while (p < pend) {
if (ISLOWER(*p)) {
*p = TOUPPER(*p);
- modify = 1;
+ modify = TRUE;
}
p++;
}
@@ -2479,54 +2479,54 @@ mrb_str_append(mrb_state *mrb, mrb_value str, mrb_value str2)
mrb_value
mrb_str_inspect(mrb_state *mrb, mrb_value str)
{
- const char *p, *pend;
- char buf[CHAR_ESC_LEN + 1];
- mrb_value result = mrb_str_new_lit(mrb, "\"");
+ const char *p, *pend;
+ char buf[CHAR_ESC_LEN + 1];
+ mrb_value result = mrb_str_new_lit(mrb, "\"");
- p = RSTRING_PTR(str); pend = RSTRING_END(str);
- for (;p < pend; p++) {
- unsigned char c, cc;
+ p = RSTRING_PTR(str); pend = RSTRING_END(str);
+ for (;p < pend; p++) {
+ unsigned char c, cc;
- c = *p;
- if (c == '"'|| c == '\\' || (c == '#' && IS_EVSTR(p, pend))) {
- buf[0] = '\\'; buf[1] = c;
- mrb_str_cat(mrb, result, buf, 2);
- continue;
- }
- if (ISPRINT(c)) {
- buf[0] = c;
- mrb_str_cat(mrb, result, buf, 1);
- continue;
- }
- switch (c) {
- case '\n': cc = 'n'; break;
- case '\r': cc = 'r'; break;
- case '\t': cc = 't'; break;
- case '\f': cc = 'f'; break;
- case '\013': cc = 'v'; break;
- case '\010': cc = 'b'; break;
- case '\007': cc = 'a'; break;
- case 033: cc = 'e'; break;
- default: cc = 0; break;
- }
- if (cc) {
- buf[0] = '\\';
- buf[1] = (char)cc;
- mrb_str_cat(mrb, result, buf, 2);
- continue;
- }
- else {
- buf[0] = '\\';
- buf[3] = '0' + c % 8; c /= 8;
- buf[2] = '0' + c % 8; c /= 8;
- buf[1] = '0' + c % 8;
- mrb_str_cat(mrb, result, buf, 4);
- continue;
- }
+ c = *p;
+ if (c == '"'|| c == '\\' || (c == '#' && IS_EVSTR(p, pend))) {
+ buf[0] = '\\'; buf[1] = c;
+ mrb_str_cat(mrb, result, buf, 2);
+ continue;
+ }
+ if (ISPRINT(c)) {
+ buf[0] = c;
+ mrb_str_cat(mrb, result, buf, 1);
+ continue;
+ }
+ switch (c) {
+ case '\n': cc = 'n'; break;
+ case '\r': cc = 'r'; break;
+ case '\t': cc = 't'; break;
+ case '\f': cc = 'f'; break;
+ case '\013': cc = 'v'; break;
+ case '\010': cc = 'b'; break;
+ case '\007': cc = 'a'; break;
+ case 033: cc = 'e'; break;
+ default: cc = 0; break;
+ }
+ if (cc) {
+ buf[0] = '\\';
+ buf[1] = (char)cc;
+ mrb_str_cat(mrb, result, buf, 2);
+ continue;
}
- mrb_str_cat_lit(mrb, result, "\"");
+ else {
+ buf[0] = '\\';
+ buf[3] = '0' + c % 8; c /= 8;
+ buf[2] = '0' + c % 8; c /= 8;
+ buf[1] = '0' + c % 8;
+ mrb_str_cat(mrb, result, buf, 4);
+ continue;
+ }
+ }
+ mrb_str_cat_lit(mrb, result, "\"");
- return result;
+ return result;
}
/*