summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-16 09:05:54 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-16 09:05:54 +0000
commitf84f4aa6b375290386c0456ac02fe8f6cc2cdd2d (patch)
treefba985cc67803c80f7761462f79cf988cbf6507b /string.c
parent59d82a928a617889c18f4da6152f11c0eb6fde06 (diff)
* array.c (rb_ary_and): should not push frozen key string.
* array.c (rb_ary_or): ditto. * eval.c (rb_thread_schedule): should save context before raising deadlock, saved context for current thread might be obsolete. * time.c (make_time_t): non DST timezone shift supported (hopefully). * time.c (make_time_t): strict range detection for negative time_t. * signal.c: SIGINFO added. * eval.c (rb_ensure): should not SEGV when prot_tag is NULL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/string.c b/string.c
index 0706318361..660fa0c509 100644
--- a/string.c
+++ b/string.c
@@ -428,14 +428,16 @@ rb_str_resize(str, len)
VALUE str;
long len;
{
- rb_str_modify(str);
+ if (len != RSTRING(str)->len) {
+ rb_str_modify(str);
- if (len >= 0) {
- if (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) {
- REALLOC_N(RSTRING(str)->ptr, char, len + 1);
+ if (len >= 0) {
+ if (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) {
+ REALLOC_N(RSTRING(str)->ptr, char, len + 1);
+ }
+ RSTRING(str)->len = len;
+ RSTRING(str)->ptr[len] = '\0'; /* sentinel */
}
- RSTRING(str)->len = len;
- RSTRING(str)->ptr[len] = '\0'; /* sentinel */
}
return str;
}
@@ -956,7 +958,7 @@ rb_str_aref_m(argc, argv, str)
return rb_str_aref(str, argv[0]);
}
-static void
+void
rb_str_update(str, beg, len, val)
VALUE str;
long beg;
@@ -1515,9 +1517,7 @@ VALUE
rb_str_inspect(str)
VALUE str;
{
- long len;
char *p, *pend;
- char *q, *qend;
VALUE result = rb_str_new2("\"");
char s[5];