mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_lstrip_bang): strip NUL along with white
spaces. [ruby-talk:76659] * string.c (rb_str_rstrip_bang): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cabf75ae6a
commit
2436525ed8
3 changed files with 11 additions and 6 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Wed Jul 23 15:49:01 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (rb_str_lstrip_bang): strip NUL along with white
|
||||||
|
spaces. [ruby-talk:76659]
|
||||||
|
|
||||||
|
* string.c (rb_str_rstrip_bang): ditto.
|
||||||
|
|
||||||
Wed Jul 23 14:19:17 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
Wed Jul 23 14:19:17 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* lib/mkmf.rb (log_src, checking_for, create_header):
|
* lib/mkmf.rb (log_src, checking_for, create_header):
|
||||||
|
|
2
file.c
2
file.c
|
@ -1536,7 +1536,7 @@ file_expand_path(fname, dname, result)
|
||||||
long buflen;
|
long buflen;
|
||||||
int tainted;
|
int tainted;
|
||||||
|
|
||||||
s = StringValueCStr(fname);
|
s = StringValuePtr(fname);
|
||||||
BUFINIT();
|
BUFINIT();
|
||||||
tainted = OBJ_TAINTED(fname);
|
tainted = OBJ_TAINTED(fname);
|
||||||
|
|
||||||
|
|
8
string.c
8
string.c
|
@ -1643,6 +1643,7 @@ str_gsub(argc, argv, str, bang)
|
||||||
bp += len;
|
bp += len;
|
||||||
memcpy(bp, RSTRING(val)->ptr, RSTRING(val)->len);
|
memcpy(bp, RSTRING(val)->ptr, RSTRING(val)->len);
|
||||||
bp += RSTRING(val)->len;
|
bp += RSTRING(val)->len;
|
||||||
|
offset = END(0);
|
||||||
if (BEG(0) == END(0)) {
|
if (BEG(0) == END(0)) {
|
||||||
/*
|
/*
|
||||||
* Always consume at least one character of the input string
|
* Always consume at least one character of the input string
|
||||||
|
@ -1654,9 +1655,6 @@ str_gsub(argc, argv, str, bang)
|
||||||
bp += len;
|
bp += len;
|
||||||
offset = END(0) + len;
|
offset = END(0) + len;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
offset = END(0);
|
|
||||||
}
|
|
||||||
cp = RSTRING(str)->ptr + offset;
|
cp = RSTRING(str)->ptr + offset;
|
||||||
if (offset > RSTRING(str)->len) break;
|
if (offset > RSTRING(str)->len) break;
|
||||||
beg = rb_reg_search(pat, str, offset, 0);
|
beg = rb_reg_search(pat, str, offset, 0);
|
||||||
|
@ -2924,7 +2922,7 @@ rb_str_lstrip_bang(str)
|
||||||
if (!s || RSTRING(str)->len == 0) return Qnil;
|
if (!s || RSTRING(str)->len == 0) return Qnil;
|
||||||
e = t = s + RSTRING(str)->len;
|
e = t = s + RSTRING(str)->len;
|
||||||
/* remove spaces at head */
|
/* remove spaces at head */
|
||||||
while (s < t && ISSPACE(*s)) s++;
|
while (s < t && (ISSPACE(*s) || !*s)) s++;
|
||||||
|
|
||||||
RSTRING(str)->len = t-s;
|
RSTRING(str)->len = t-s;
|
||||||
if (s > RSTRING(str)->ptr) {
|
if (s > RSTRING(str)->ptr) {
|
||||||
|
@ -2956,7 +2954,7 @@ rb_str_rstrip_bang(str)
|
||||||
e = t = s + RSTRING(str)->len;
|
e = t = s + RSTRING(str)->len;
|
||||||
|
|
||||||
/* remove trailing spaces */
|
/* remove trailing spaces */
|
||||||
while (s < t && ISSPACE(*(t-1))) t--;
|
while (s < t && (ISSPACE(*(t-1)) || !*(t-1))) t--;
|
||||||
|
|
||||||
RSTRING(str)->len = t-s;
|
RSTRING(str)->len = t-s;
|
||||||
if (t < e) {
|
if (t < e) {
|
||||||
|
|
Loading…
Reference in a new issue