diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-05 10:21:22 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-05 10:21:22 +0000 |
commit | e58ec3372190b0f9e294351a4e1ca603da01ca72 (patch) | |
tree | 77f96e3934ec787fe621cdc95ef689c80db24e60 | |
parent | 5b13036fce91d8970448e565e4319939b27cdc00 (diff) |
* process.c (rb_exec_fillarg): bail out a loop eagerly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | process.c | 6 |
2 files changed, 8 insertions, 2 deletions
@@ -1,3 +1,7 @@ +Tue Jun 5 19:21:10 2012 Tanaka Akira <akr@fsij.org> + + * process.c (rb_exec_fillarg): bail out a loop eagerly. + Tue Jun 5 19:15:14 2012 Tanaka Akira <akr@fsij.org> * process.c: add comments about async-signal-safe. @@ -1805,10 +1805,12 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, str int has_meta = 0; int has_nonspace = 0; for (p = RSTRING_PTR(prog); *p; p++) { - if (*p != ' ' && *p != '\t') + if (!has_nonspace && *p != ' ' && *p != '\t') has_nonspace = 1; - if (strchr("*?{}[]<>()~&|\\$;'`\"\n", *p)) + if (!has_meta && strchr("*?{}[]<>()~&|\\$;'`\"\n", *p)) has_meta = 1; + if (has_nonspace && has_meta) + break; } if (has_nonspace && !has_meta) { /* avoid shell since no shell meta charactor found. */ |