[svn:parrot] r34613 - branches/pdd22io_part3/src/pmc

chromatic chromatic at wgz.org
Tue Dec 30 05:39:41 UTC 2008


On Monday 29 December 2008 21:28:44 allison at cvs.perl.org wrote:

> Log:
> [pdd22io] Store full set of options for buffer_type.
>
>
> Modified: branches/pdd22io_part3/src/pmc/stringhandle.pmc
> ===========================================================================
>=== --- branches/pdd22io_part3/src/pmc/stringhandle.pmc	(original)
> +++ branches/pdd22io_part3/src/pmc/stringhandle.pmc	Mon Dec 29 21:28:43
> 2008 @@ -411,14 +411,42 @@
>
>  =item C<METHOD buffer_type(STRING *new_type :optional)>
>
> -StringHandles are always unbuffered.
> +Set or retrieve the buffering attribute for the stringhandle. This
> attribute is +ignored, but stored for mocking.
>
>  =cut
>
>  */
>
>      METHOD buffer_type(STRING *new_type :optional, INTVAL got_type
> :opt_flag) { -        STRING *nobuffer_string = const_string(INTERP,
> "unbuffered"); +        INTVAL flags;
> +        STRING *nobuffer_string   = CONST_STRING(INTERP, "unbuffered");
> +        STRING *linebuffer_string = CONST_STRING(INTERP, "line-buffered");
> +        STRING *fullbuffer_string = CONST_STRING(INTERP, "full-buffered");

...

> +        if (flags & PIO_F_LINEBUF)
> +            RETURN(STRING *linebuffer_string);
> +        else if (flags & PIO_F_BLKBUF)
> +            RETURN(STRING *fullbuffer_string);
>          RETURN(STRING *nobuffer_string);
>      }

If there's a chance someone might modify these STRINGs in the caller, you 
don't want to return them directly here.  CONST_STRING means that we know 
their contents at Parrot compile time, not that you can't modify them without 
making a COW copy.

Arguably that should be fixed.

-- c


More information about the parrot-dev mailing list