summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-22 07:38:50 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-22 07:38:50 +0000
commit64bffee8d630d2a18244cfa641bdbf3bc3958b7c (patch)
tree8f8aa9a42775fa07d46e34c310ca098345fc57f0 /ruby.c
parentaffa7430b70336b53cd496496d889c2544d41322 (diff)
* ruby.c (set_arg0): support RSTRING_LEN on HP-UX. a patch from
WATANABE Tetsuya <Tetsuya.WATANABE AT nifty.com>. [ruby-dev:30806] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/ruby.c b/ruby.c
index 6dec7a2c8c..61ba65baa9 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1092,18 +1092,18 @@ set_arg0(VALUE val, ID id)
s = RSTRING_PTR(val);
i = RSTRING_LEN(val);
#if defined(PSTAT_SETCMD)
- if (i >= PST_CLEN) {
- union pstun j;
- j.pst_command = s;
- i = PST_CLEN;
- RSTRING_LEN(val) = i;
- *(s + i) = '\0';
- pstat(PSTAT_SETCMD, j, PST_CLEN, 0, 0);
+ if (i > PST_CLEN) {
+ union pstun un;
+ char buf[PST_CLEN + 1]; /* PST_CLEN is 64 (HP-UX 11.23) */
+ strncpy(buf, s, PST_CLEN);
+ buf[PST_CLEN] = '\0';
+ un.pst_command = buf;
+ pstat(PSTAT_SETCMD, un, PST_CLEN, 0, 0);
}
else {
- union pstun j;
- j.pst_command = s;
- pstat(PSTAT_SETCMD, j, i, 0, 0);
+ union pstun un;
+ un.pst_command = s;
+ pstat(PSTAT_SETCMD, un, i, 0, 0);
}
rb_progname = rb_tainted_str_new(s, i);
#elif defined(HAVE_SETPROCTITLE)