Re: [Safer] rb_class_path

From: nobu.nokada@...
Date: 2002-08-28 09:29:41 UTC
List: ruby-core #380
Hi,

At Wed, 28 Aug 2002 17:25:02 +0900,
Michal Rokos wrote:
> >   +	RSTRING(str)->len = strlen(RSTRING(str)->ptr);
> 
> 	How about:
> 
> 
> +	long len;
>  
> +	len = snprintf(RSTRING(str)->ptr, RSTRING(str)->len, "#<%s:0x%lx>", s, klass);
> +	if (len != -1) {
> +	    RSTRING(str)->len = len;
> +	}

It's better.

I thought older systems' sprintf() returned char*, but here was
snprintf() and such systems must not have it.

BTW, since snprintf() returns int not long, it's unnecessary to
be long?

-- 
Nobu Nakada

In This Thread