Ticket #1576: str-consting.patch

File str-consting.patch, 3.4 KB (added by tcurtis, 12 years ago)

A patch to const Parrot_str_change_charset, Parrot_str_change_encoding, and Parrot_str_split.

  • src/string/api.c

     
    28452845 
    28462846/* 
    28472847 
    2848 =item C<STRING* Parrot_str_change_charset(PARROT_INTERP, STRING *src, INTVAL 
    2849 charset_nr)> 
     2848=item C<STRING* Parrot_str_change_charset(PARROT_INTERP, const STRING *src, 
     2849INTVAL charset_nr)> 
    28502850 
    28512851Converts C<src> to the given charset or encoding and returns the result as a 
    28522852new string. 
     
    28592859PARROT_WARN_UNUSED_RESULT 
    28602860PARROT_CAN_RETURN_NULL 
    28612861STRING* 
    2862 Parrot_str_change_charset(PARROT_INTERP, ARGMOD_NULLOK(STRING *src), 
     2862Parrot_str_change_charset(PARROT_INTERP, ARGIN_NULLOK(const STRING *src), 
    28632863        INTVAL charset_nr) 
    28642864{ 
    28652865    ASSERT_ARGS(Parrot_str_change_charset) 
     
    28752875                "charset #%d not found", (int) charset_nr); 
    28762876 
    28772877    if (new_charset == src->charset) 
    2878         return src; 
     2878        return (STRING *)src; 
    28792879 
    28802880    return new_charset->to_charset(interp, src); 
    28812881} 
     
    28832883 
    28842884/* 
    28852885 
    2886 =item C<STRING* Parrot_str_change_encoding(PARROT_INTERP, STRING *src, INTVAL 
    2887 encoding_nr)> 
     2886=item C<STRING* Parrot_str_change_encoding(PARROT_INTERP, const STRING *src, 
     2887INTVAL encoding_nr)> 
    28882888 
    28892889Converts C<src> to the given charset or encoding and returns the result as a 
    28902890new string. 
     
    28972897PARROT_WARN_UNUSED_RESULT 
    28982898PARROT_CAN_RETURN_NULL 
    28992899STRING* 
    2900 Parrot_str_change_encoding(PARROT_INTERP, ARGMOD_NULLOK(STRING *src), 
     2900Parrot_str_change_encoding(PARROT_INTERP, ARGIN_NULLOK(const STRING *src), 
    29012901        INTVAL encoding_nr) 
    29022902{ 
    29032903    ASSERT_ARGS(Parrot_str_change_encoding) 
     
    29132913            "encoding #%d not found", (int) encoding_nr); 
    29142914 
    29152915    if (new_encoding == src->encoding) 
    2916         return src; 
     2916        return (STRING *)src; 
    29172917 
    29182918    return new_encoding->to_encoding(interp, src); 
    29192919} 
     
    30703070 
    30713071/* 
    30723072 
    3073 =item C<PMC* Parrot_str_split(PARROT_INTERP, const STRING *delim, STRING *str)> 
     3073=item C<PMC* Parrot_str_split(PARROT_INTERP, const STRING *delim, const STRING 
     3074*str)> 
    30743075 
    30753076Splits the string C<str> at the delimiter C<delim>, returning a 
    30763077C<ResizableStringArray>, or his mapped type in the current HLL, of results. 
     
    30853086PARROT_CAN_RETURN_NULL 
    30863087PMC* 
    30873088Parrot_str_split(PARROT_INTERP, 
    3088     ARGIN_NULLOK(const STRING *delim), ARGIN_NULLOK(STRING *str)) 
     3089    ARGIN_NULLOK(const STRING *delim), ARGIN_NULLOK(const STRING *str)) 
    30893090{ 
    30903091    ASSERT_ARGS(Parrot_str_split) 
    30913092    PMC    *res; 
  • include/parrot/string_funcs.h

     
    6666PARROT_WARN_UNUSED_RESULT 
    6767PARROT_CAN_RETURN_NULL 
    6868STRING* Parrot_str_change_charset(PARROT_INTERP, 
    69     ARGMOD_NULLOK(STRING *src), 
     69    ARGIN_NULLOK(const STRING *src), 
    7070    INTVAL charset_nr) 
    7171        __attribute__nonnull__(1) 
    7272        FUNC_MODIFIES(*src); 
     
    7575PARROT_WARN_UNUSED_RESULT 
    7676PARROT_CAN_RETURN_NULL 
    7777STRING* Parrot_str_change_encoding(PARROT_INTERP, 
    78     ARGMOD_NULLOK(STRING *src), 
     78    ARGIN_NULLOK(const STRING *src), 
    7979    INTVAL encoding_nr) 
    8080        __attribute__nonnull__(1) 
    8181        FUNC_MODIFIES(*src); 
     
    322322PARROT_CAN_RETURN_NULL 
    323323PMC* Parrot_str_split(PARROT_INTERP, 
    324324    ARGIN_NULLOK(const STRING *delim), 
    325     ARGIN_NULLOK(STRING *str)) 
     325    ARGIN_NULLOK(const STRING *str)) 
    326326        __attribute__nonnull__(1); 
    327327 
    328328PARROT_EXPORT