[svn:parrot] r46064 - in trunk: include/parrot src/string/charset

petdance at svn.parrot.org petdance at svn.parrot.org
Tue Apr 27 14:55:25 UTC 2010


Author: petdance
Date: Tue Apr 27 14:55:24 2010
New Revision: 46064
URL: https://trac.parrot.org/parrot/changeset/46064

Log:
all charset virt funcs now take const STRING *

Modified:
   trunk/include/parrot/charset.h
   trunk/src/string/charset/ascii.c
   trunk/src/string/charset/ascii.h
   trunk/src/string/charset/binary.c
   trunk/src/string/charset/iso-8859-1.c
   trunk/src/string/charset/iso-8859-1.h
   trunk/src/string/charset/unicode.c

Modified: trunk/include/parrot/charset.h
==============================================================================
--- trunk/include/parrot/charset.h	Tue Apr 27 14:20:28 2010	(r46063)
+++ trunk/include/parrot/charset.h	Tue Apr 27 14:55:24 2010	(r46064)
@@ -30,43 +30,43 @@
 #define PARROT_UNICODE_CHARSET Parrot_unicode_charset_ptr
 
 typedef STRING * (*charset_get_graphemes_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset, UINTVAL count);
-typedef STRING * (*charset_to_charset_t)(PARROT_INTERP, STRING *src);
-typedef STRING * (*charset_from_unicode_t)(PARROT_INTERP, STRING *src);
+typedef STRING * (*charset_to_charset_t)(PARROT_INTERP, ARGIN(const STRING *src));
+typedef STRING * (*charset_from_unicode_t)(PARROT_INTERP, ARGIN(const STRING *src));
 typedef STRING * (*charset_compose_t)(PARROT_INTERP, ARGIN(const STRING *src));
 typedef STRING * (*charset_decompose_t)(PARROT_INTERP, ARGIN(const STRING *src));
-typedef STRING * (*charset_upcase_t)(PARROT_INTERP, const STRING *src);
-typedef STRING * (*charset_downcase_t)(PARROT_INTERP, const STRING *src);
-typedef STRING * (*charset_titlecase_t)(PARROT_INTERP, const STRING *src);
-typedef STRING * (*charset_upcase_first_t)(PARROT_INTERP, const STRING *src);
-typedef STRING * (*charset_downcase_first_t)(PARROT_INTERP, const STRING *src);
-typedef STRING * (*charset_titlecase_first_t)(PARROT_INTERP, const STRING *src);
-typedef INTVAL   (*charset_compare_t)(PARROT_INTERP, const STRING *lhs, const STRING *rhs);
-typedef INTVAL   (*charset_index_t)(PARROT_INTERP, STRING *src, STRING *search_string, UINTVAL offset);
-typedef INTVAL   (*charset_rindex_t)(PARROT_INTERP, STRING *src, STRING *search_string, UINTVAL offset);
-typedef UINTVAL  (*charset_validate_t)(PARROT_INTERP, STRING *src);
-typedef INTVAL   (*charset_is_cclass_t)(PARROT_INTERP, INTVAL, const STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_cclass_t)(PARROT_INTERP, INTVAL, STRING *src, UINTVAL offset, UINTVAL count);
-typedef INTVAL   (*charset_find_not_cclass_t)(PARROT_INTERP, INTVAL, STRING *src, UINTVAL offset, UINTVAL count);
-typedef INTVAL   (*charset_is_wordchar_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_wordchar_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_not_wordchar_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_is_whitespace_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_whitespace_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_not_whitespace_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_is_digit_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_digit_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_not_digit_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_is_punctuation_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_punctuation_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_not_punctuation_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_is_newline_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_newline_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_not_newline_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
-typedef INTVAL   (*charset_find_word_boundary_t)(PARROT_INTERP, STRING *src, UINTVAL offset);
+typedef STRING * (*charset_upcase_t)(PARROT_INTERP, ARGIN(const STRING *src));
+typedef STRING * (*charset_downcase_t)(PARROT_INTERP, ARGIN(const STRING *src));
+typedef STRING * (*charset_titlecase_t)(PARROT_INTERP, ARGIN(const STRING *src));
+typedef STRING * (*charset_upcase_first_t)(PARROT_INTERP, ARGIN(const STRING *src));
+typedef STRING * (*charset_downcase_first_t)(PARROT_INTERP, ARGIN(const STRING *src));
+typedef STRING * (*charset_titlecase_first_t)(PARROT_INTERP, ARGIN(const STRING *src));
+typedef INTVAL   (*charset_compare_t)(PARROT_INTERP, ARGIN(const STRING *lhs), ARGIN(const STRING *rhs));
+typedef INTVAL   (*charset_index_t)(PARROT_INTERP, ARGIN(const STRING *src), ARGIN(const STRING *search_string), UINTVAL offset);
+typedef INTVAL   (*charset_rindex_t)(PARROT_INTERP, ARGIN(const STRING *src), ARGIN(const STRING *search_string), UINTVAL offset);
+typedef UINTVAL  (*charset_validate_t)(PARROT_INTERP, ARGIN(const STRING *src));
+typedef INTVAL   (*charset_is_cclass_t)(PARROT_INTERP, INTVAL, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_cclass_t)(PARROT_INTERP, INTVAL, ARGIN(const STRING *src), UINTVAL offset, UINTVAL count);
+typedef INTVAL   (*charset_find_not_cclass_t)(PARROT_INTERP, INTVAL, ARGIN(const STRING *src), UINTVAL offset, UINTVAL count);
+typedef INTVAL   (*charset_is_wordchar_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_wordchar_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_not_wordchar_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_is_whitespace_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_whitespace_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_not_whitespace_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_is_digit_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_digit_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_not_digit_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_is_punctuation_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_punctuation_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_not_punctuation_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_is_newline_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_newline_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_not_newline_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
+typedef INTVAL   (*charset_find_word_boundary_t)(PARROT_INTERP, ARGIN(const STRING *src), UINTVAL offset);
 typedef STRING * (*charset_string_from_codepoint_t)(PARROT_INTERP, UINTVAL codepoint);
-typedef size_t   (*charset_compute_hash_t)(PARROT_INTERP, const STRING *, size_t seed);
+typedef size_t   (*charset_compute_hash_t)(PARROT_INTERP, ARGIN(const STRING *src), size_t seed);
 
-typedef STRING* (*charset_converter_t)(PARROT_INTERP, STRING *src);
+typedef STRING * (*charset_converter_t)(PARROT_INTERP, ARGIN(const STRING *src));
 
 /* HEADERIZER BEGIN: src/string/charset.c */
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */

Modified: trunk/src/string/charset/ascii.c
==============================================================================
--- trunk/src/string/charset/ascii.c	Tue Apr 27 14:20:28 2010	(r46063)
+++ trunk/src/string/charset/ascii.c	Tue Apr 27 14:55:24 2010	(r46064)
@@ -54,7 +54,7 @@
 PARROT_WARN_UNUSED_RESULT
 static INTVAL find_cclass(PARROT_INTERP,
     INTVAL flags,
-    ARGIN(STRING *src),
+    ARGIN(const STRING *src),
     UINTVAL offset,
     UINTVAL count)
         __attribute__nonnull__(1)
@@ -62,7 +62,7 @@
 
 static INTVAL find_not_cclass(PARROT_INTERP,
     INTVAL flags,
-    ARGIN(STRING *src),
+    ARGIN(const STRING *src),
     UINTVAL offset,
     UINTVAL count)
         __attribute__nonnull__(1)
@@ -92,12 +92,12 @@
         __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
-static STRING * to_ascii(PARROT_INTERP, ARGIN(STRING *src))
+static STRING * to_ascii(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
-static STRING * to_charset(PARROT_INTERP, ARGIN(STRING *src))
+static STRING * to_charset(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -112,7 +112,7 @@
         __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
-static UINTVAL validate(PARROT_INTERP, ARGIN(STRING *src))
+static UINTVAL validate(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -186,7 +186,7 @@
 
 /*
 
-=item C<static STRING * to_ascii(PARROT_INTERP, STRING *src)>
+=item C<static STRING * to_ascii(PARROT_INTERP, const STRING *src)>
 
 Attempts to convert STRING C<src> to ASCII in STRING C<dest>. Throws
 an exception if unconvertable UNICODE characters are involved.
@@ -197,7 +197,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING *
-to_ascii(PARROT_INTERP, ARGIN(STRING *src))
+to_ascii(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(to_ascii)
     String_iter iter;
@@ -206,7 +206,7 @@
     const UINTVAL len = src->strlen;
 
     /* the string can't grow. Just clone it */
-    STRING * dest = Parrot_str_clone(interp, src);
+    STRING * const dest = Parrot_str_clone(interp, src);
 
     p = (unsigned char *)dest->strstart;
     ENCODING_ITER_INIT(interp, src, &iter);
@@ -226,7 +226,7 @@
 
 /*
 
-=item C<static STRING * to_charset(PARROT_INTERP, STRING *src)>
+=item C<static STRING * to_charset(PARROT_INTERP, const STRING *src)>
 
 Converts STRING C<src> to ASCII charset STRING C<dest>.
 
@@ -236,7 +236,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING *
-to_charset(PARROT_INTERP, ARGIN(STRING *src))
+to_charset(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(to_charset)
     const charset_converter_t conversion_func =
@@ -403,9 +403,9 @@
 upcase_first(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(upcase_first)
-    STRING *result = Parrot_str_clone(interp, src);
+    STRING * const result = Parrot_str_clone(interp, src);
 
-    if (result->strlen) {
+    if (result->strlen > 0) {
         char * const buffer = result->strstart;
         buffer[0] = (char)toupper((unsigned char)buffer[0]);
     }
@@ -429,9 +429,9 @@
 downcase_first(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(downcase_first)
-    STRING *result = Parrot_str_clone(interp, src);
+    STRING * const result = Parrot_str_clone(interp, src);
 
-    if (result->strlen) {
+    if (result->strlen > 0) {
         char * const buffer = result->strstart;
         buffer[0] = (char)tolower((unsigned char)buffer[0]);
     }
@@ -457,7 +457,7 @@
     ASSERT_ARGS(titlecase_first)
     STRING * const result = Parrot_str_clone(interp, src);
 
-    if (result->strlen) {
+    if (result->strlen > 0) {
         char * const buffer = result->strstart;
         buffer[0] = (char)toupper((unsigned char)buffer[0]);
     }
@@ -513,8 +513,8 @@
 
 /*
 
-=item C<INTVAL mixed_cs_index(PARROT_INTERP, STRING *src, STRING *search,
-UINTVAL offs)>
+=item C<INTVAL mixed_cs_index(PARROT_INTERP, const STRING *src, const STRING
+*search, UINTVAL offs)>
 
 Searches for the first instance of STRING C<search> in STRING C<src>.
 returns the position where the substring is found if it is indeed found.
@@ -527,7 +527,7 @@
 
 PARROT_WARN_UNUSED_RESULT
 INTVAL
-mixed_cs_index(PARROT_INTERP, ARGIN(STRING *src), ARGIN(STRING *search),
+mixed_cs_index(PARROT_INTERP, ARGIN(const STRING *src), ARGIN(const STRING *search),
     UINTVAL offs)
 {
     ASSERT_ARGS(mixed_cs_index)
@@ -573,8 +573,8 @@
 
 /*
 
-=item C<INTVAL ascii_cs_index(PARROT_INTERP, STRING *src, STRING *search_string,
-UINTVAL offset)>
+=item C<INTVAL ascii_cs_index(PARROT_INTERP, const STRING *src, const STRING
+*search_string, UINTVAL offset)>
 
 Searches for the first instance of STRING C<search> in STRING C<src>.
 returns the position where the substring is found if it is indeed found.
@@ -586,8 +586,8 @@
 
 PARROT_WARN_UNUSED_RESULT
 INTVAL
-ascii_cs_index(PARROT_INTERP, ARGIN(STRING *src),
-        ARGIN(STRING *search_string), UINTVAL offset)
+ascii_cs_index(PARROT_INTERP, ARGIN(const STRING *src),
+        ARGIN(const STRING *search_string), UINTVAL offset)
 {
     ASSERT_ARGS(ascii_cs_index)
     INTVAL retval;
@@ -603,7 +603,7 @@
 
 /*
 
-=item C<INTVAL ascii_cs_rindex(PARROT_INTERP, STRING *src, STRING
+=item C<INTVAL ascii_cs_rindex(PARROT_INTERP, const STRING *src, const STRING
 *search_string, UINTVAL offset)>
 
 Searches for the last instance of STRING C<search_string> in STRING
@@ -615,8 +615,8 @@
 
 PARROT_WARN_UNUSED_RESULT
 INTVAL
-ascii_cs_rindex(PARROT_INTERP, ARGIN(STRING *src),
-        ARGIN(STRING *search_string), UINTVAL offset)
+ascii_cs_rindex(PARROT_INTERP, ARGIN(const STRING *src),
+        ARGIN(const STRING *search_string), UINTVAL offset)
 {
     ASSERT_ARGS(ascii_cs_rindex)
     INTVAL retval;
@@ -633,7 +633,7 @@
 
 /*
 
-=item C<static UINTVAL validate(PARROT_INTERP, STRING *src)>
+=item C<static UINTVAL validate(PARROT_INTERP, const STRING *src)>
 
 Verifies that the given string is valid ASCII. Returns 1 if it is ASCII,
 returns 0 otherwise.
@@ -644,7 +644,7 @@
 
 PARROT_WARN_UNUSED_RESULT
 static UINTVAL
-validate(PARROT_INTERP, ARGIN(STRING *src))
+validate(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(validate)
     UINTVAL offset;
@@ -701,8 +701,7 @@
         return 0;
     codepoint = ENCODING_GET_CODEPOINT(interp, src, offset);
 
-    if (codepoint >= sizeof (Parrot_ascii_typetable) /
-            sizeof (Parrot_ascii_typetable[0])) {
+    if (codepoint >= sizeof (Parrot_ascii_typetable) / sizeof (Parrot_ascii_typetable[0])) {
         return 0;
     }
     return (Parrot_ascii_typetable[codepoint] & flags) ? 1 : 0;
@@ -710,8 +709,8 @@
 
 /*
 
-=item C<static INTVAL find_cclass(PARROT_INTERP, INTVAL flags, STRING *src,
-UINTVAL offset, UINTVAL count)>
+=item C<static INTVAL find_cclass(PARROT_INTERP, INTVAL flags, const STRING
+*src, UINTVAL offset, UINTVAL count)>
 
 Find a character in the given character class.  Delegates to the find_cclass
 method of the encoding plugin.
@@ -722,8 +721,7 @@
 
 PARROT_WARN_UNUSED_RESULT
 static INTVAL
-find_cclass(PARROT_INTERP, INTVAL flags, ARGIN(STRING *src),
-            UINTVAL offset, UINTVAL count)
+find_cclass(PARROT_INTERP, INTVAL flags, ARGIN(const STRING *src), UINTVAL offset, UINTVAL count)
 {
     ASSERT_ARGS(find_cclass)
     UINTVAL pos = offset;
@@ -736,15 +734,15 @@
 
 /*
 
-=item C<static INTVAL find_not_cclass(PARROT_INTERP, INTVAL flags, STRING *src,
-UINTVAL offset, UINTVAL count)>
+=item C<static INTVAL find_not_cclass(PARROT_INTERP, INTVAL flags, const STRING
+*src, UINTVAL offset, UINTVAL count)>
 
 =cut
 
 */
 
 static INTVAL
-find_not_cclass(PARROT_INTERP, INTVAL flags, ARGIN(STRING *src), UINTVAL offset, UINTVAL count)
+find_not_cclass(PARROT_INTERP, INTVAL flags, ARGIN(const STRING *src), UINTVAL offset, UINTVAL count)
 {
     ASSERT_ARGS(find_not_cclass)
     UINTVAL pos = offset;
@@ -838,7 +836,7 @@
 
 /*
 
-=item C<STRING * charset_cvt_ascii_to_binary(PARROT_INTERP, STRING *src)>
+=item C<STRING * charset_cvt_ascii_to_binary(PARROT_INTERP, const STRING *src)>
 
 Converts an ASCII STRING C<src> to a binary STRING C<dest>.
 
@@ -848,7 +846,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 STRING *
-charset_cvt_ascii_to_binary(PARROT_INTERP, ARGIN(STRING *src))
+charset_cvt_ascii_to_binary(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(charset_cvt_ascii_to_binary)
     STRING * const dest = Parrot_str_clone(interp, src);
@@ -865,7 +863,8 @@
 
 /*
 
-=item C<STRING * charset_cvt_ascii_to_iso_8859_1(PARROT_INTERP, STRING *src)>
+=item C<STRING * charset_cvt_ascii_to_iso_8859_1(PARROT_INTERP, const STRING
+*src)>
 
 Converts ASCII STRING C<src> to ISO8859-1 STRING C<dest>.
 
@@ -875,7 +874,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 STRING *
-charset_cvt_ascii_to_iso_8859_1(PARROT_INTERP, ARGIN(STRING *src))
+charset_cvt_ascii_to_iso_8859_1(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(charset_cvt_ascii_to_iso_8859_1)
     STRING * const dest = Parrot_str_clone(interp, src);

Modified: trunk/src/string/charset/ascii.h
==============================================================================
--- trunk/src/string/charset/ascii.h	Tue Apr 27 14:20:28 2010	(r46063)
+++ trunk/src/string/charset/ascii.h	Tue Apr 27 14:55:24 2010	(r46064)
@@ -36,8 +36,8 @@
 
 PARROT_WARN_UNUSED_RESULT
 INTVAL ascii_cs_index(PARROT_INTERP,
-    ARGIN(STRING *src),
-    ARGIN(STRING *search_string),
+    ARGIN(const STRING *src),
+    ARGIN(const STRING *search_string),
     UINTVAL offset)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -45,8 +45,8 @@
 
 PARROT_WARN_UNUSED_RESULT
 INTVAL ascii_cs_rindex(PARROT_INTERP,
-    ARGIN(STRING *src),
-    ARGIN(STRING *search_string),
+    ARGIN(const STRING *src),
+    ARGIN(const STRING *search_string),
     UINTVAL offset)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -62,19 +62,21 @@
         __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
-STRING * charset_cvt_ascii_to_binary(PARROT_INTERP, ARGIN(STRING *src))
+STRING * charset_cvt_ascii_to_binary(PARROT_INTERP,
+    ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
-STRING * charset_cvt_ascii_to_iso_8859_1(PARROT_INTERP, ARGIN(STRING *src))
+STRING * charset_cvt_ascii_to_iso_8859_1(PARROT_INTERP,
+    ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
 INTVAL mixed_cs_index(PARROT_INTERP,
-    ARGIN(STRING *src),
-    ARGIN(STRING *search),
+    ARGIN(const STRING *src),
+    ARGIN(const STRING *search),
     UINTVAL offs)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)

Modified: trunk/src/string/charset/binary.c
==============================================================================
--- trunk/src/string/charset/binary.c	Tue Apr 27 14:20:28 2010	(r46063)
+++ trunk/src/string/charset/binary.c	Tue Apr 27 14:55:24 2010	(r46064)
@@ -38,13 +38,13 @@
         __attribute__nonnull__(1);
 
 static INTVAL cs_index(SHIM_INTERP,
-    SHIM(STRING *src),
-    SHIM(STRING *search_string),
+    SHIM(const STRING *src),
+    SHIM(const STRING *search_string),
     SHIM(UINTVAL offset));
 
 static INTVAL cs_rindex(SHIM_INTERP,
-    SHIM(STRING *src),
-    SHIM(STRING *search_string),
+    SHIM(const STRING *src),
+    SHIM(const STRING *search_string),
     SHIM(UINTVAL offset));
 
 PARROT_CANNOT_RETURN_NULL
@@ -61,13 +61,13 @@
 
 static INTVAL find_cclass(SHIM_INTERP,
     SHIM(INTVAL flags),
-    SHIM(STRING *src),
+    SHIM(const STRING *src),
     UINTVAL offset,
     UINTVAL count);
 
 static INTVAL find_not_cclass(SHIM_INTERP,
     SHIM(INTVAL flags),
-    SHIM(STRING *src),
+    SHIM(const STRING *src),
     UINTVAL offset,
     UINTVAL count);
 
@@ -89,7 +89,7 @@
         __attribute__nonnull__(1);
 
 PARROT_CANNOT_RETURN_NULL
-static STRING* to_charset(PARROT_INTERP, ARGIN(STRING *src))
+static STRING* to_charset(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -101,7 +101,7 @@
 static STRING* upcase_first(PARROT_INTERP, SHIM(const STRING *src))
         __attribute__nonnull__(1);
 
-static UINTVAL validate(SHIM_INTERP, SHIM(STRING *src));
+static UINTVAL validate(SHIM_INTERP, SHIM(const STRING *src));
 #define ASSERT_ARGS_compare __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(lhs) \
     , PARROT_ASSERT_ARG(rhs))
@@ -145,7 +145,7 @@
 
 /*
 
-=item C<static STRING* to_charset(PARROT_INTERP, STRING *src)>
+=item C<static STRING* to_charset(PARROT_INTERP, const STRING *src)>
 
 Converts the STRING C<src> to STRING C<dest> in binary mode. Throws
 an exception if a suitable conversion function is not found.
@@ -156,7 +156,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING*
-to_charset(PARROT_INTERP, ARGIN(STRING *src))
+to_charset(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(to_charset)
     charset_converter_t conversion_func =
@@ -346,7 +346,7 @@
 
 /*
 
-=item C<static INTVAL cs_index(PARROT_INTERP, STRING *src, STRING
+=item C<static INTVAL cs_index(PARROT_INTERP, const STRING *src, const STRING
 *search_string, UINTVAL offset)>
 
 Returns -1. It makes no sense to try and search for a substring in
@@ -357,8 +357,8 @@
 */
 
 static INTVAL
-cs_index(SHIM_INTERP, SHIM(STRING *src),
-        SHIM(STRING *search_string), SHIM(UINTVAL offset))
+cs_index(SHIM_INTERP, SHIM(const STRING *src),
+        SHIM(const STRING *search_string), SHIM(UINTVAL offset))
 {
     ASSERT_ARGS(cs_index)
     return -1;
@@ -366,7 +366,7 @@
 
 /*
 
-=item C<static INTVAL cs_rindex(PARROT_INTERP, STRING *src, STRING
+=item C<static INTVAL cs_rindex(PARROT_INTERP, const STRING *src, const STRING
 *search_string, UINTVAL offset)>
 
 Returns -1. It makes no sense to search for the last substring match
@@ -377,8 +377,8 @@
 */
 
 static INTVAL
-cs_rindex(SHIM_INTERP, SHIM(STRING *src),
-        SHIM(STRING *search_string), SHIM(UINTVAL offset))
+cs_rindex(SHIM_INTERP, SHIM(const STRING *src),
+        SHIM(const STRING *search_string), SHIM(UINTVAL offset))
 {
     ASSERT_ARGS(cs_rindex)
     return -1;
@@ -386,7 +386,7 @@
 
 /*
 
-=item C<static UINTVAL validate(PARROT_INTERP, STRING *src)>
+=item C<static UINTVAL validate(PARROT_INTERP, const STRING *src)>
 
 Returns 1. All sequential data is valid binary data.
 
@@ -396,7 +396,7 @@
 
 /* Binary's always valid */
 static UINTVAL
-validate(SHIM_INTERP, SHIM(STRING *src))
+validate(SHIM_INTERP, SHIM(const STRING *src))
 {
     ASSERT_ARGS(validate)
     return 1;
@@ -420,8 +420,8 @@
 
 /*
 
-=item C<static INTVAL find_cclass(PARROT_INTERP, INTVAL flags, STRING *src,
-UINTVAL offset, UINTVAL count)>
+=item C<static INTVAL find_cclass(PARROT_INTERP, INTVAL flags, const STRING
+*src, UINTVAL offset, UINTVAL count)>
 
 =cut
 
@@ -429,7 +429,7 @@
 
 static INTVAL
 find_cclass(SHIM_INTERP, SHIM(INTVAL flags),
-            SHIM(STRING *src), UINTVAL offset, UINTVAL count)
+            SHIM(const STRING *src), UINTVAL offset, UINTVAL count)
 {
     ASSERT_ARGS(find_cclass)
     return offset + count;
@@ -437,8 +437,8 @@
 
 /*
 
-=item C<static INTVAL find_not_cclass(PARROT_INTERP, INTVAL flags, STRING *src,
-UINTVAL offset, UINTVAL count)>
+=item C<static INTVAL find_not_cclass(PARROT_INTERP, INTVAL flags, const STRING
+*src, UINTVAL offset, UINTVAL count)>
 
 =cut
 
@@ -446,7 +446,7 @@
 
 static INTVAL
 find_not_cclass(SHIM_INTERP, SHIM(INTVAL flags),
-               SHIM(STRING *src), UINTVAL offset, UINTVAL count)
+               SHIM(const STRING *src), UINTVAL offset, UINTVAL count)
 {
     ASSERT_ARGS(find_not_cclass)
     return offset + count;

Modified: trunk/src/string/charset/iso-8859-1.c
==============================================================================
--- trunk/src/string/charset/iso-8859-1.c	Tue Apr 27 14:20:28 2010	(r46063)
+++ trunk/src/string/charset/iso-8859-1.c	Tue Apr 27 14:55:24 2010	(r46064)
@@ -47,7 +47,7 @@
 
 static INTVAL find_cclass(PARROT_INTERP,
     INTVAL flags,
-    ARGIN(STRING *src),
+    ARGIN(const STRING *src),
     UINTVAL offset,
     UINTVAL count)
         __attribute__nonnull__(1)
@@ -55,7 +55,7 @@
 
 static INTVAL find_not_cclass(PARROT_INTERP,
     INTVAL flags,
-    ARGIN(STRING *src),
+    ARGIN(const STRING *src),
     UINTVAL offset,
     UINTVAL count)
         __attribute__nonnull__(1)
@@ -84,17 +84,17 @@
 
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
-static STRING * to_charset(PARROT_INTERP, ARGIN(STRING *src))
+static STRING * to_charset(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
-static STRING * to_iso_8859_1(PARROT_INTERP, ARGIN(STRING *src))
+static STRING * to_iso_8859_1(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
-static STRING * to_unicode(PARROT_INTERP, ARGIN(STRING *src))
+static STRING * to_unicode(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -108,7 +108,7 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
-static UINTVAL validate(PARROT_INTERP, ARGIN(STRING *src))
+static UINTVAL validate(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -165,7 +165,7 @@
 
 /*
 
-=item C<static STRING * to_iso_8859_1(PARROT_INTERP, STRING *src)>
+=item C<static STRING * to_iso_8859_1(PARROT_INTERP, const STRING *src)>
 
 Converts STRING C<src> to iso-8859-1 in STRING C<dest>.
 
@@ -175,7 +175,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING *
-to_iso_8859_1(PARROT_INTERP, ARGIN(STRING *src))
+to_iso_8859_1(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(to_iso_8859_1)
     UINTVAL offs, src_len;
@@ -201,7 +201,7 @@
 
 /*
 
-=item C<static STRING * to_unicode(PARROT_INTERP, STRING *src)>
+=item C<static STRING * to_unicode(PARROT_INTERP, const STRING *src)>
 
 Converts STRING C<src> to unicode STRING C<dest>.
 
@@ -211,7 +211,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING *
-to_unicode(PARROT_INTERP, ARGIN(STRING *src))
+to_unicode(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(to_unicode)
     STRING * dest = Parrot_str_clone(interp, src);
@@ -241,7 +241,7 @@
 
 /*
 
-=item C<static STRING * to_charset(PARROT_INTERP, STRING *src)>
+=item C<static STRING * to_charset(PARROT_INTERP, const STRING *src)>
 
 Converts the STRING C<src> to an ISO-8859-1 STRING C<dest>.
 
@@ -252,7 +252,7 @@
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 static STRING *
-to_charset(PARROT_INTERP, ARGIN(STRING *src))
+to_charset(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(to_charset)
     const charset_converter_t conversion_func =
@@ -513,7 +513,7 @@
 
 /*
 
-=item C<static UINTVAL validate(PARROT_INTERP, STRING *src)>
+=item C<static UINTVAL validate(PARROT_INTERP, const STRING *src)>
 
 Returns 1 if the STRING C<src> is a valid ISO-8859-1 STRING. Returns 0 otherwise.
 
@@ -522,7 +522,7 @@
 */
 
 static UINTVAL
-validate(PARROT_INTERP, ARGIN(STRING *src))
+validate(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(validate)
     UINTVAL offset;
@@ -562,8 +562,8 @@
 
 /*
 
-=item C<static INTVAL find_cclass(PARROT_INTERP, INTVAL flags, STRING *src,
-UINTVAL offset, UINTVAL count)>
+=item C<static INTVAL find_cclass(PARROT_INTERP, INTVAL flags, const STRING
+*src, UINTVAL offset, UINTVAL count)>
 
 Find a character in the given character class.  Delegates to the find_cclass
 method of the encoding plugin.
@@ -574,10 +574,10 @@
 
 static INTVAL
 find_cclass(PARROT_INTERP, INTVAL flags,
-            ARGIN(STRING *src), UINTVAL offset, UINTVAL count)
+                ARGIN(const STRING *src), UINTVAL offset, UINTVAL count)
 {
     ASSERT_ARGS(find_cclass)
-    UINTVAL pos = offset;
+    const UINTVAL pos = offset;
     UINTVAL end = offset + count;
 
     end = src->strlen < end ? src->strlen : end;
@@ -587,8 +587,8 @@
 
 /*
 
-=item C<static INTVAL find_not_cclass(PARROT_INTERP, INTVAL flags, STRING *src,
-UINTVAL offset, UINTVAL count)>
+=item C<static INTVAL find_not_cclass(PARROT_INTERP, INTVAL flags, const STRING
+*src, UINTVAL offset, UINTVAL count)>
 
 =cut
 
@@ -596,7 +596,7 @@
 
 static INTVAL
 find_not_cclass(PARROT_INTERP, INTVAL flags,
-                ARGIN(STRING *src), UINTVAL offset, UINTVAL count)
+                ARGIN(const STRING *src), UINTVAL offset, UINTVAL count)
 {
     ASSERT_ARGS(find_not_cclass)
     UINTVAL pos = offset;
@@ -682,7 +682,8 @@
 
 /*
 
-=item C<STRING * charset_cvt_iso_8859_1_to_ascii(PARROT_INTERP, STRING *src)>
+=item C<STRING * charset_cvt_iso_8859_1_to_ascii(PARROT_INTERP, const STRING
+*src)>
 
 Converts STRING C<src> in ISO-8859-1 to ASCII STRING C<dest>.
 
@@ -693,7 +694,7 @@
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 STRING *
-charset_cvt_iso_8859_1_to_ascii(PARROT_INTERP, ARGIN(STRING *src))
+charset_cvt_iso_8859_1_to_ascii(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(charset_cvt_iso_8859_1_to_ascii)
     UINTVAL offs;

Modified: trunk/src/string/charset/iso-8859-1.h
==============================================================================
--- trunk/src/string/charset/iso-8859-1.h	Tue Apr 27 14:20:28 2010	(r46063)
+++ trunk/src/string/charset/iso-8859-1.h	Tue Apr 27 14:55:24 2010	(r46064)
@@ -18,7 +18,8 @@
 
 PARROT_CANNOT_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
-STRING * charset_cvt_iso_8859_1_to_ascii(PARROT_INTERP, ARGIN(STRING *src))
+STRING * charset_cvt_iso_8859_1_to_ascii(PARROT_INTERP,
+    ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 

Modified: trunk/src/string/charset/unicode.c
==============================================================================
--- trunk/src/string/charset/unicode.c	Tue Apr 27 14:20:28 2010	(r46063)
+++ trunk/src/string/charset/unicode.c	Tue Apr 27 14:55:24 2010	(r46064)
@@ -45,8 +45,8 @@
         __attribute__nonnull__(2);
 
 static INTVAL cs_rindex(PARROT_INTERP,
-    SHIM(STRING *src),
-    SHIM(STRING *search_string),
+    SHIM(const STRING *src),
+    SHIM(const STRING *search_string),
     SHIM(UINTVAL offset))
         __attribute__nonnull__(1);
 
@@ -65,7 +65,7 @@
 
 static INTVAL find_cclass(PARROT_INTERP,
     INTVAL flags,
-    ARGIN(STRING *src),
+    ARGIN(const STRING *src),
     UINTVAL offset,
     UINTVAL count)
         __attribute__nonnull__(1)
@@ -73,7 +73,7 @@
 
 static INTVAL find_not_cclass(PARROT_INTERP,
     INTVAL flags,
-    ARGIN(STRING *src),
+    ARGIN(const STRING *src),
     UINTVAL offset,
     UINTVAL count)
         __attribute__nonnull__(1)
@@ -108,7 +108,7 @@
         __attribute__nonnull__(1);
 
 PARROT_CANNOT_RETURN_NULL
-static STRING* to_charset(PARROT_INTERP, ARGIN(STRING *src))
+static STRING* to_charset(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -124,7 +124,7 @@
 static STRING* upcase_first(PARROT_INTERP, SHIM(const STRING *src))
         __attribute__nonnull__(1);
 
-static UINTVAL validate(PARROT_INTERP, ARGIN(STRING *src))
+static UINTVAL validate(PARROT_INTERP, ARGIN(const STRING *src))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
@@ -222,7 +222,7 @@
 
 /*
 
-=item C<static STRING* to_charset(PARROT_INTERP, STRING *src)>
+=item C<static STRING* to_charset(PARROT_INTERP, const STRING *src)>
 
 Converts input STRING C<src> to unicode STRING C<dest>.
 
@@ -232,7 +232,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 static STRING*
-to_charset(PARROT_INTERP, ARGIN(STRING *src))
+to_charset(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(to_charset)
     const charset_converter_t conversion_func =
@@ -682,7 +682,7 @@
 
 /*
 
-=item C<static INTVAL cs_rindex(PARROT_INTERP, STRING *src, STRING
+=item C<static INTVAL cs_rindex(PARROT_INTERP, const STRING *src, const STRING
 *search_string, UINTVAL offset)>
 
 Finds the last index of substring C<search_string> in STRING C<src>,
@@ -693,7 +693,8 @@
 */
 
 static INTVAL
-cs_rindex(PARROT_INTERP, SHIM(STRING *src), SHIM(STRING *search_string), SHIM(UINTVAL offset))
+cs_rindex(PARROT_INTERP, SHIM(const STRING *src),
+        SHIM(const STRING *search_string), SHIM(UINTVAL offset))
 {
     ASSERT_ARGS(cs_rindex)
     /* TODO: https://trac.parrot.org/parrot/wiki/StringsTasklist Implement this. */
@@ -703,7 +704,7 @@
 
 /*
 
-=item C<static UINTVAL validate(PARROT_INTERP, STRING *src)>
+=item C<static UINTVAL validate(PARROT_INTERP, const STRING *src)>
 
 Returns 1 if the STRING C<src> is a valid unicode string, returns 0 otherwise.
 
@@ -712,7 +713,7 @@
 */
 
 static UINTVAL
-validate(PARROT_INTERP, ARGIN(STRING *src))
+validate(PARROT_INTERP, ARGIN(const STRING *src))
 {
     ASSERT_ARGS(validate)
     UINTVAL     offset;
@@ -856,15 +857,15 @@
 
 /*
 
-=item C<static INTVAL find_cclass(PARROT_INTERP, INTVAL flags, STRING *src,
-UINTVAL offset, UINTVAL count)>
+=item C<static INTVAL find_cclass(PARROT_INTERP, INTVAL flags, const STRING
+*src, UINTVAL offset, UINTVAL count)>
 
 =cut
 
 */
 
 static INTVAL
-find_cclass(PARROT_INTERP, INTVAL flags, ARGIN(STRING *src), UINTVAL offset, UINTVAL count)
+find_cclass(PARROT_INTERP, INTVAL flags, ARGIN(const STRING *src), UINTVAL offset, UINTVAL count)
 {
     ASSERT_ARGS(find_cclass)
     String_iter iter;
@@ -896,15 +897,16 @@
 
 /*
 
-=item C<static INTVAL find_not_cclass(PARROT_INTERP, INTVAL flags, STRING *src,
-UINTVAL offset, UINTVAL count)>
+=item C<static INTVAL find_not_cclass(PARROT_INTERP, INTVAL flags, const STRING
+*src, UINTVAL offset, UINTVAL count)>
 
 =cut
 
 */
 
 static INTVAL
-find_not_cclass(PARROT_INTERP, INTVAL flags, ARGIN(STRING *src), UINTVAL offset, UINTVAL count)
+find_not_cclass(PARROT_INTERP, INTVAL flags, ARGIN(const STRING *src),
+        UINTVAL offset, UINTVAL count)
 {
     ASSERT_ARGS(find_not_cclass)
     String_iter iter;


More information about the parrot-commits mailing list