From 86202a88c389c972b5ade21f87b9a8ab8019ec34 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 22 May 2007 07:38:50 +0000 Subject: * ruby.c (set_arg0): support RSTRING_LEN on HP-UX. a patch from WATANABE Tetsuya . [ruby-dev:30806] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index 6dec7a2c8..61ba65baa 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) -- cgit