Author: petdance
Date: Sat Jun  2 20:02:33 2007
New Revision: 18772

Modified:
   trunk/include/parrot/string_funcs.h
   trunk/src/string.c

Log:
In the progress of NN-ing and NULLOK-ing string.c

Modified: trunk/include/parrot/string_funcs.h
==============================================================================
--- trunk/include/parrot/string_funcs.h (original)
+++ trunk/include/parrot/string_funcs.h Sat Jun  2 20:02:33 2007
@@ -40,7 +40,7 @@
 
 PARROT_API INTVAL Parrot_string_find_not_cclass( Interp *interp,
     INTVAL flags,
-    STRING *s,
+    STRING *s /*NULLOK*/,
     UINTVAL offset,
     UINTVAL count );
 
@@ -50,14 +50,14 @@
     UINTVAL offset );
 
 PARROT_API STRING* Parrot_string_trans_charset( Interp *interp,
-    STRING *src,
+    STRING *src /*NULLOK*/,
     INTVAL charset_nr,
-    STRING *dest );
+    STRING *dest /*NULLOK*/ );
 
 PARROT_API STRING* Parrot_string_trans_encoding( Interp *interp,
-    STRING *src,
+    STRING *src /*NULLOK*/,
     INTVAL encoding_nr,
-    STRING *dest );
+    STRING *dest /*NULLOK*/ );
 
 PARROT_API void Parrot_unmake_COW( Interp *interp, STRING *s /*NN*/ )
         __attribute__nonnull__(2);
@@ -76,39 +76,39 @@
     STRING *b /*NULLOK*/ );
 
 PARROT_API STRING * string_bitwise_and( Interp *interp,
-    STRING *s1,
-    STRING *s2,
-    STRING **dest );
+    STRING *s1 /*NULLOK*/,
+    STRING *s2 /*NULLOK*/,
+    STRING **dest /*NULLOK*/ );
 
 PARROT_API STRING * string_bitwise_not( Interp *interp,
-    STRING *s,
-    STRING **dest );
+    STRING *s /*NULLOK*/,
+    STRING **dest /*NULLOK*/ );
 
 PARROT_API STRING * string_bitwise_or( Interp *interp,
-    STRING *s1,
-    STRING *s2,
-    STRING **dest );
+    STRING *s1 /*NULLOK*/,
+    STRING *s2 /*NULLOK*/,
+    STRING **dest /*NULLOK*/ );
 
 PARROT_API STRING * string_bitwise_xor( Interp *interp,
-    STRING *s1,
-    STRING *s2,
-    STRING **dest );
+    STRING *s1 /*NULLOK*/,
+    STRING *s2 /*NULLOK*/,
+    STRING **dest /*NULLOK*/ );
 
-PARROT_API INTVAL string_bool( Interp *interp, const STRING *s );
+PARROT_API INTVAL string_bool( Interp *interp, const STRING *s /*NULLOK*/ );
 PARROT_API UINTVAL string_capacity( Interp *interp, const STRING *s /*NN*/ )
         __attribute__nonnull__(2);
 
 PARROT_API STRING * string_chopn( Interp *interp,
-    STRING *s,
+    STRING *s /*NULLOK*/,
     INTVAL n,
     int in_place );
 
 PARROT_API STRING * string_chr( Interp *interp, UINTVAL character );
 PARROT_API INTVAL string_compare( Interp *interp,
-    const STRING *s1,
-    const STRING *s2 );
+    const STRING *s1 /*NULLOK*/,
+    const STRING *s2 /*NULLOK*/ );
 
-PARROT_API STRING * string_compose( Interp *interp, STRING *src );
+PARROT_API STRING * string_compose( Interp *interp, STRING *src /*NULLOK*/ );
 PARROT_API INTVAL string_compute_strlen( Interp *interp, STRING *s /*NN*/ )
         __attribute__nonnull__(2);
 
@@ -118,19 +118,23 @@
     UINTVAL Uflags );
 
 PARROT_API STRING * string_copy( Interp *interp, STRING *s /*NULLOK*/ );
-PARROT_API void string_cstring_free( char *p );
+PARROT_API void string_cstring_free( char *p /*NULLOK*/ );
 PARROT_API void string_deinit( Parrot_Interp interp );
-PARROT_API STRING * string_downcase( Interp *interp, const STRING *s );
+PARROT_API STRING * string_downcase( Interp *interp,
+    const STRING *s /*NULLOK*/ );
+
 PARROT_API void string_downcase_inplace( Interp *interp,
     STRING *s /*NULLOK*/ );
 
 PARROT_API INTVAL string_equal( Interp *interp,
-    const STRING *s1,
-    const STRING *s2 );
+    const STRING *s1 /*NULLOK*/,
+    const STRING *s2 /*NULLOK*/ );
+
+PARROT_API STRING * string_escape_string( Interp *interp,
+    const STRING *src /*NULLOK*/ );
 
-PARROT_API STRING * string_escape_string( Interp *interp, const STRING *src );
 PARROT_API STRING * string_escape_string_delimited( Interp *interp,
-    const STRING *src,
+    const STRING *src /*NULLOK*/,
     UINTVAL limit );
 
 PARROT_API STRING * string_from_const_cstring( Interp *interp,
@@ -148,46 +152,67 @@
     INTVAL addlen )
         __attribute__nonnull__(2);
 
-PARROT_API size_t string_hash( Interp *interp, STRING *s, size_t seed );
-PARROT_API STRING * string_increment( Interp *interp, const STRING *s );
-PARROT_API INTVAL string_index( Interp *interp, const STRING *s, UINTVAL idx );
+PARROT_API size_t string_hash( Interp *interp,
+    STRING *s /*NULLOK*/,
+    size_t seed );
+
+PARROT_API STRING * string_increment( Interp *interp,
+    const STRING *s /*NULLOK*/ );
+
+PARROT_API INTVAL string_index( Interp *interp,
+    const STRING *s /*NN*/,
+    UINTVAL idx )
+        __attribute__nonnull__(2);
+
 PARROT_API void string_init( Parrot_Interp interp );
 PARROT_API STRING* string_join( Interp *interp, STRING *j, PMC *ar );
 PARROT_API UINTVAL string_length( Interp *interp, const STRING *s /*NULLOK*/ );
 PARROT_API STRING * string_make( Interp *interp,
-    const char *buffer /*NN*/,
+    const char *buffer /*NULLOK*/,
     UINTVAL len,
     const char *charset_name /*NULLOK*/,
-    UINTVAL flags )
-        __attribute__nonnull__(2);
+    UINTVAL flags );
 
 PARROT_API STRING * string_make_direct( Interp *interp,
     const char *buffer /*NULLOK*/,
     UINTVAL len,
-    ENCODING *encoding,
-    CHARSET *charset,
-    UINTVAL flags );
+    ENCODING *encoding /*NN*/,
+    CHARSET *charset /*NN*/,
+    UINTVAL flags )
+        __attribute__nonnull__(4)
+        __attribute__nonnull__(5);
 
 PARROT_API STRING * string_make_empty( Interp *interp,
     parrot_string_representation_t representation,
     UINTVAL capacity );
 
 PARROT_API INTVAL string_max_bytes( Interp *interp,
-    const STRING *s,
-    INTVAL nchars );
+    const STRING *s /*NN*/,
+    INTVAL nchars )
+        __attribute__nonnull__(2);
 
 PARROT_API STRING* string_nprintf( Interp *interp,
     STRING *dest,
     INTVAL bytelen,
-    const char *format,
-    ... );
+    const char *format /*NN*/,
+    ... )
+        __attribute__nonnull__(4);
+
+PARROT_API INTVAL string_ord( Interp *interp,
+    const STRING *s /*NULLOK*/,
+    INTVAL idx );
+
+PARROT_API void string_pin( Interp *interp, STRING *s /*NN*/ )
+        __attribute__nonnull__(2);
 
-PARROT_API INTVAL string_ord( Interp *interp, const STRING *s, INTVAL idx );
-PARROT_API void string_pin( Interp *interp, STRING * s );
 PARROT_API const char* string_primary_encoding_for_representation( Interp 
*interp,
     parrot_string_representation_t representation );
 
-PARROT_API STRING* string_printf( Interp *interp, const char *format, ... );
+PARROT_API STRING* string_printf( Interp *interp,
+    const char *format /*NN*/,
+    ... )
+        __attribute__nonnull__(2);
+
 PARROT_API CHARSET * string_rep_compatible( Interp *interp,
     const STRING *a /*NN*/,
     const STRING *b /*NN*/,
@@ -197,16 +222,17 @@
         __attribute__nonnull__(4);
 
 PARROT_API STRING * string_repeat( Interp *interp,
-    const STRING *s,
+    const STRING *s /*NN*/,
     UINTVAL num,
-    STRING **d );
+    STRING **d /*NULLOK*/ )
+        __attribute__nonnull__(2);
 
 PARROT_API STRING * string_replace( Interp *interp,
     STRING *src /*NULLOK*/,
     INTVAL offset,
     INTVAL length,
     STRING *rep /*NULLOK*/,
-    STRING **d );
+    STRING **d /*NULLOK*/ );
 
 PARROT_API STRING * string_set( Interp *interp,
     STRING *dest /*NULLOK*/,
@@ -214,32 +240,46 @@
 
 PARROT_API PMC* string_split( Interp *interp, STRING *delim, STRING *str );
 PARROT_API INTVAL string_str_index( Interp *interp,
-    const STRING *s,
-    const STRING *s2,
-    INTVAL start );
+    const STRING *s /*NN*/,
+    const STRING *s2 /*NN*/,
+    INTVAL start )
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
 
 PARROT_API STRING * string_substr( Interp *interp,
-    STRING *src,
+    STRING *src /*NN*/,
     INTVAL offset,
     INTVAL length,
-    STRING **d,
-    int replace_dest );
+    STRING **d /*NULLOK*/,
+    int replace_dest )
+        __attribute__nonnull__(2);
+
+PARROT_API STRING * string_titlecase( Interp *interp,
+    const STRING *s /*NULLOK*/ );
+
+PARROT_API void string_titlecase_inplace( Interp *interp,
+    STRING *s /*NULLOK*/ );
 
-PARROT_API STRING * string_titlecase( Interp *interp, const STRING *s );
-PARROT_API void string_titlecase_inplace( Interp *interp, STRING *s );
 PARROT_API char * string_to_cstring( Interp *interp,
     const STRING * const s /* NULLOK */ );
 
-PARROT_API INTVAL string_to_int( Interp *interp, const STRING *s );
-PARROT_API FLOATVAL string_to_num( Interp *interp, const STRING *s );
+PARROT_API INTVAL string_to_int( Interp *interp, const STRING *s /*NULLOK*/ );
+PARROT_API FLOATVAL string_to_num( Interp *interp,
+    const STRING *s /*NULLOK*/ );
+
 PARROT_API STRING * string_unescape_cstring( Interp *interp,
-    const char *cstring,
+    const char *cstring /*NN*/,
     char delimiter,
-    const char *enc_char );
+    const char *enc_char /*NULLOK*/ )
+        __attribute__nonnull__(2);
+
+PARROT_API void string_unpin( Interp *interp, STRING *s /*NN*/ )
+        __attribute__nonnull__(2);
+
+PARROT_API STRING * string_upcase( Interp *interp,
+    const STRING *s /*NULLOK*/ );
 
-PARROT_API void string_unpin( Interp *interp, STRING * s );
-PARROT_API STRING * string_upcase( Interp *interp, const STRING *s );
-PARROT_API void string_upcase_inplace( Interp *interp, STRING *s );
+PARROT_API void string_upcase_inplace( Interp *interp, STRING *s /*NULLOK*/ );
 PARROT_API STRING* uint_to_str( Interp *interp,
     char *tc /*NN*/,
     UHUGEINTVAL num,

Modified: trunk/src/string.c
==============================================================================
--- trunk/src/string.c  (original)
+++ trunk/src/string.c  Sat Jun  2 20:02:33 2007
@@ -575,7 +575,7 @@
 */
 
 STRING *
-string_make(Interp *interp, const char *buffer /*NN*/,
+string_make(Interp *interp, const char *buffer /*NULLOK*/,
     UINTVAL len, const char *charset_name /*NULLOK*/, UINTVAL flags)
 {
     ENCODING *encoding;
@@ -596,8 +596,8 @@
 }
 
 STRING *
-string_make_direct(Interp *interp, const char *buffer /*NULLOK*/,
-        UINTVAL len, ENCODING *encoding, CHARSET *charset, UINTVAL flags)
+string_make_direct(Interp *interp, const char *buffer /*NULLOK*/, UINTVAL len,
+        ENCODING *encoding /*NN*/, CHARSET *charset /*NN*/, UINTVAL flags)
 {
     STRING * const s = new_string_header(interp, flags);
     DECL_CONST_CAST;
@@ -691,7 +691,7 @@
 */
 
 INTVAL
-string_index(Interp *interp, const STRING *s, UINTVAL idx)
+string_index(Interp *interp, const STRING *s /*NN*/, UINTVAL idx)
 {
     saneify_string(s);
     return (INTVAL)CHARSET_GET_CODEPOINT(interp, s, idx);
@@ -708,8 +708,8 @@
 */
 
 INTVAL
-string_str_index(Interp *interp, const STRING *s,
-        const STRING *s2, INTVAL start)
+string_str_index(Interp *interp, const STRING *s /*NN*/,
+        const STRING *s2 /*NN*/, INTVAL start)
 {
     STRING *src, *search;
     UINTVAL len;
@@ -740,7 +740,7 @@
 */
 
 INTVAL
-string_ord(Interp *interp, const STRING *s, INTVAL idx)
+string_ord(Interp *interp, const STRING *s /*NULLOK*/, INTVAL idx)
 {
     const UINTVAL len = string_length(interp, s);
 
@@ -835,7 +835,7 @@
 */
 
 INTVAL
-string_max_bytes(Interp *interp, const STRING *s, INTVAL nchars)
+string_max_bytes(Interp *interp, const STRING *s /*NN*/, INTVAL nchars)
 {
     assert(s->encoding);
     return ENCODING_MAX_BYTES_PER_CODEPOINT(interp, s) * nchars;
@@ -900,8 +900,8 @@
 */
 
 STRING *
-string_repeat(Interp *interp, const STRING *s,
-    UINTVAL num, STRING **d)
+string_repeat(Interp *interp, const STRING *s /*NN*/,
+    UINTVAL num, STRING **d /*NULLOK*/)
 {
     UINTVAL i;
 
@@ -938,8 +938,8 @@
 */
 
 STRING *
-string_substr(Interp *interp, STRING *src,
-    INTVAL offset, INTVAL length, STRING **d, int replace_dest)
+string_substr(Interp *interp, STRING *src /*NN*/, INTVAL offset, INTVAL length,
+        STRING **d /*NULLOK*/, int replace_dest)
 {
     STRING *dest;
     UINTVAL true_offset;
@@ -968,7 +968,7 @@
     }
 
     /* do in-place i.e. reuse existing header if one */
-    if (replace_dest && *d) {
+    if (replace_dest && d && *d) {
         assert(src->encoding == Parrot_fixed_8_encoding_ptr);
         dest = *d;
         dest->encoding = src->encoding;
@@ -1013,7 +1013,7 @@
 
 STRING *
 string_replace(Interp *interp, STRING *src /*NULLOK*/,
-    INTVAL offset, INTVAL length, STRING *rep /*NULLOK*/, STRING **d)
+    INTVAL offset, INTVAL length, STRING *rep /*NULLOK*/, STRING **d 
/*NULLOK*/)
 {
     STRING *dest = NULL;
     UINTVAL start_byte, end_byte;
@@ -1152,7 +1152,7 @@
 */
 
 STRING *
-string_chopn(Interp *interp, STRING *s, INTVAL n, int in_place)
+string_chopn(Interp *interp, STRING *s /*NULLOK*/, INTVAL n, int in_place)
 {
     UINTVAL new_length, uchar_size;
     String_iter iter;
@@ -1203,7 +1203,7 @@
 
 
 INTVAL
-string_compare(Interp *interp, const STRING *s1, const STRING *s2)
+string_compare(Interp *interp, const STRING *s1 /*NULLOK*/, const STRING *s2 
/*NULLOK*/)
 {
     if (!s1 && !s2) {
         return 0;
@@ -1234,7 +1234,7 @@
 */
 
 INTVAL
-string_equal(Interp *interp, const STRING *s1, const STRING *s2)
+string_equal(Interp *interp, const STRING *s1 /*NULLOK*/, const STRING *s2 
/*NULLOK*/)
 {
     if ((s1 == s2) || (!s1 && !s2)) {
         return 0;
@@ -1310,7 +1310,8 @@
 */
 
 STRING *
-string_bitwise_and(Interp *interp, STRING *s1, STRING *s2, STRING **dest)
+string_bitwise_and(Interp *interp, STRING *s1 /*NULLOK*/,
+        STRING *s2 /*NULLOK*/, STRING **dest /*NULLOK*/)
 {
     STRING *res = NULL;
     size_t minlen;
@@ -1412,7 +1413,8 @@
 */
 
 STRING *
-string_bitwise_or(Interp *interp, STRING *s1, STRING *s2, STRING **dest)
+string_bitwise_or(Interp *interp, STRING *s1 /*NULLOK*/,
+        STRING *s2 /*NULLOK*/, STRING **dest /*NULLOK*/)
 {
     STRING *res;
     size_t maxlen = 0;
@@ -1481,7 +1483,8 @@
 */
 
 STRING *
-string_bitwise_xor(Interp *interp, STRING *s1, STRING *s2, STRING **dest)
+string_bitwise_xor(Interp *interp, STRING *s1 /*NULLOK*/,
+        STRING *s2 /*NULLOK*/, STRING **dest /*NULLOK*/)
 {
     STRING *res;
     size_t maxlen = 0;
@@ -1561,7 +1564,7 @@
 */
 
 STRING *
-string_bitwise_not(Interp *interp, STRING *s, STRING **dest)
+string_bitwise_not(Interp *interp, STRING *s /*NULLOK*/, STRING **dest 
/*NULLOK*/)
 {
     STRING *res;
     size_t len;
@@ -1619,7 +1622,7 @@
 */
 
 INTVAL
-string_bool(Interp *interp, const STRING *s)
+string_bool(Interp *interp, const STRING *s /*NULLOK*/)
 {
     const INTVAL len = string_length(interp, s);
 
@@ -1656,7 +1659,7 @@
 
 STRING*
 string_nprintf(Interp *interp,
-    STRING *dest, INTVAL bytelen, const char *format, ...)
+    STRING *dest, INTVAL bytelen, const char *format /*NN*/, ...)
 {
     STRING *output;
     va_list args;
@@ -1691,7 +1694,7 @@
 */
 
 STRING*
-string_printf(Interp *interp, const char *format, ...)
+string_printf(Interp *interp, const char *format /*NN*/, ...)
 {
     STRING *output;
     va_list args;
@@ -1726,7 +1729,7 @@
 */
 
 INTVAL
-string_to_int(Interp *interp, const STRING *s)
+string_to_int(Interp *interp, const STRING *s /*NULLOK*/)
 {
 #if 1
     INTVAL i = 0;
@@ -1781,7 +1784,7 @@
 */
 
 FLOATVAL
-string_to_num(Interp *interp, const STRING *s)
+string_to_num(Interp *interp, const STRING *s /*NULLOK*/)
 {
     FLOATVAL f = 0.0;
     DECL_CONST_CAST;
@@ -1879,7 +1882,7 @@
 */
 
 void
-string_cstring_free(char *p)
+string_cstring_free(char *p /*NULLOK*/)
 {
     DECL_CONST_CAST;
     mem_sys_free((void *)const_cast(p));
@@ -1894,7 +1897,7 @@
 */
 
 void
-string_pin(Interp *interp, STRING * s)
+string_pin(Interp *interp, STRING *s /*NN*/)
 {
     char *memory;
     INTVAL size;
@@ -1922,7 +1925,7 @@
 */
 
 void
-string_unpin(Interp *interp, STRING * s)
+string_unpin(Interp *interp, STRING *s /*NN*/)
 {
     void *memory;
     INTVAL size;
@@ -1963,7 +1966,7 @@
 */
 
 size_t
-string_hash(Interp *interp, STRING *s, size_t seed)
+string_hash(Interp *interp, STRING *s /*NULLOK*/, size_t seed)
 {
     register size_t h;
 
@@ -1991,7 +1994,7 @@
 */
 
 STRING *
-string_escape_string(Interp *interp, const STRING *src)
+string_escape_string(Interp *interp, const STRING *src /*NULLOK*/)
 {
     return string_escape_string_delimited(interp, src,
             (UINTVAL) ~0);
@@ -2007,7 +2010,7 @@
 
 STRING *
 string_escape_string_delimited(Interp *interp,
-        const STRING *src, UINTVAL limit)
+        const STRING *src /*NULLOK*/, UINTVAL limit)
 {
     STRING *result, *hex;
     UINTVAL i, len, charlen;
@@ -2118,7 +2121,7 @@
 
 STRING *
 string_unescape_cstring(Interp *interp,
-    const char *cstring, char delimiter, const char *enc_char)
+    const char *cstring /*NN*/, char delimiter, const char *enc_char 
/*NULLOK*/)
 {
     size_t clength = strlen(cstring);
     STRING *result;
@@ -2212,7 +2215,7 @@
 
 
 STRING *
-string_upcase(Interp *interp, const STRING *s)
+string_upcase(Interp *interp, const STRING *s /*NULLOK*/)
 {
     DECL_CONST_CAST;
     STRING * const dest = string_copy(interp, (STRING *)const_cast(s));
@@ -2228,7 +2231,7 @@
 */
 
 void
-string_upcase_inplace(Interp *interp, STRING *s)
+string_upcase_inplace(Interp *interp, STRING *s /*NULLOK*/)
 {
     if (!s)
         return;
@@ -2245,7 +2248,7 @@
 */
 
 STRING *
-string_downcase(Interp *interp, const STRING *s)
+string_downcase(Interp *interp, const STRING *s /*NULLOK*/)
 {
     DECL_CONST_CAST;
     STRING * const dest = string_copy(interp, (STRING *)const_cast(s));
@@ -2284,7 +2287,7 @@
 */
 
 STRING *
-string_titlecase(Interp *interp, const STRING *s)
+string_titlecase(Interp *interp, const STRING *s /*NULLOK*/)
 {
     DECL_CONST_CAST;
     STRING * const dest = string_copy(interp, (STRING *)const_cast(s));
@@ -2300,7 +2303,7 @@
 */
 
 void
-string_titlecase_inplace(Interp *interp, STRING *s)
+string_titlecase_inplace(Interp *interp, STRING *s /*NULLOK*/)
 {
     if (!s)
         return;
@@ -2316,7 +2319,7 @@
 */
 
 STRING *
-string_increment(Interp *interp, const STRING *s)
+string_increment(Interp *interp, const STRING *s /*NULLOK*/)
 {
     INTVAL o;
 
@@ -2377,7 +2380,7 @@
 }
 
 INTVAL
-Parrot_string_find_not_cclass(Interp *interp, INTVAL flags, STRING *s,
+Parrot_string_find_not_cclass(Interp *interp, INTVAL flags, STRING *s 
/*NULLOK*/,
                               UINTVAL offset, UINTVAL count)
 {
     if (!s)
@@ -2394,8 +2397,8 @@
 */
 
 STRING*
-Parrot_string_trans_charset(Interp *interp, STRING *src,
-        INTVAL charset_nr, STRING *dest)
+Parrot_string_trans_charset(Interp *interp, STRING *src /*NULLOK*/,
+        INTVAL charset_nr, STRING *dest /*NULLOK*/)
 {
     CHARSET *new_charset;
 
@@ -2438,8 +2441,8 @@
 */
 
 STRING*
-Parrot_string_trans_encoding(Interp *interp, STRING *src,
-        INTVAL encoding_nr, STRING *dest)
+Parrot_string_trans_encoding(Interp *interp, STRING *src /*NULLOK*/,
+        INTVAL encoding_nr, STRING *dest /*NULLOK*/)
 {
     ENCODING *new_encoding;
 
@@ -2470,7 +2473,7 @@
 }
 
 STRING *
-string_compose(Interp *interp, STRING *src)
+string_compose(Interp *interp, STRING *src /*NULLOK*/)
 {
     if (!src)
         return NULL;

Reply via email to