Author: petdance
Date: Sat Jun  2 13:01:55 2007
New Revision: 18766

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

Log:
Moved int_to_str and uint_to_str to src/string.c, from src/spf_render.c.  Made 
uint_to_str visible, instead of static

Modified: trunk/include/parrot/string_funcs.h
==============================================================================
--- trunk/include/parrot/string_funcs.h (original)
+++ trunk/include/parrot/string_funcs.h Sat Jun  2 13:01:55 2007
@@ -145,6 +145,9 @@
         ENCODING**);
 PARROT_API STRING* string_join(Interp *, STRING *j, PMC *ar);
 PARROT_API PMC* string_split(Interp *, STRING *del, STRING *s);
+PARROT_API STRING* uint_to_str(Interp *interp, char *tc /*NN*/,
+        UHUGEINTVAL num, char base, int minus);
+PARROT_API STRING* int_to_str(Interp *interp, char *tc /*NN*/, HUGEINTVAL num, 
char base);
 /* HEADERIZER END: src/string.c */
 
 #endif /* PARROT_IN_CORE */

Modified: trunk/src/spf_render.c
==============================================================================
--- trunk/src/spf_render.c      (original)
+++ trunk/src/spf_render.c      Sat Jun  2 13:01:55 2007
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2001-2003, The Perl Foundation.
+Copyright (C) 2001-2007, The Perl Foundation.
 $Id$
 
 =head1 NAME
@@ -22,6 +22,7 @@
 #define IN_SPF_SYSTEM
 
 #include "parrot/parrot.h"
+#include "parrot/string_funcs.h"
 #include "spf_render.str"
 #include <assert.h>
 
@@ -34,76 +35,6 @@
 
 /*
 
-=item C<static STRING*
-uint_to_str(Interp *interp,
-            char *tc, UHUGEINTVAL num, char base, int minus)>
-
-Returns C<num> converted to a Parrot C<STRING>.
-
-Note that C<base> must be defined, a default of 10 is not assumed. The
-caller has to verify that C<< base >= 2 && base <= 36 >>
-The buffer C<tc> must be at least C<sizeof (UHUGEINTVAL)*8 + 1> chars big.
-
-If C<minus> is true then C<-> is prepended to the string representation.
-
-=cut
-
-*/
-
-static STRING*
-uint_to_str(Interp *interp,
-            char *tc, UHUGEINTVAL num, char base, int minus)
-{
-    /* the buffer must be at least as long as this */
-    char *p = tc + sizeof (UHUGEINTVAL)*8 + 1;
-    const char * const tail = p;
-
-    assert(base >= 2 && base <= 36);
-    do {
-        const char cur = (char)(num % base);
-        if (cur < 10) {
-            *--p = (char)('0' + cur);
-        }
-        else {
-            *--p = (char)('a' + cur - 10);
-        }
-    } while (num /= base);
-    if (minus)
-        *--p = '-';
-    return string_make(interp, p, tail - p, "ascii", 0);
-}
-
-/*
-
-=item C<STRING *
-int_to_str(Interp *interp,
-           char *tc, HUGEINTVAL num, char base)>
-
-Returns C<num> converted to a Parrot C<STRING>.
-
-Note that C<base> must be defined, a default of 10 is not assumed.
-
-If C<num < 0> then C<-> is prepended to the string representation.
-
-=cut
-
-*/
-
-STRING *
-int_to_str(Interp *interp,
-           char *tc, HUGEINTVAL num, char base)
-{
-    int minus = 0;
-
-    if (num < 0) {
-        minus = 1;
-        num = -num;
-    }
-    return uint_to_str(interp, tc, (UHUGEINTVAL) num, base, minus);
-}
-
-/*
-
 =item C<static STRING *
 handle_flags(Interp *interp,
              SpfInfo info, STRING *str, INTVAL is_int_type, const char 
*prefix)>

Modified: trunk/src/string.c
==============================================================================
--- trunk/src/string.c  (original)
+++ trunk/src/string.c  Sat Jun  2 13:01:55 2007
@@ -22,8 +22,8 @@
 
 #include "parrot/parrot.h"
 #include "parrot/compiler.h"
-#include "string_private_cstring.h"
 #include "parrot/string_funcs.h"
+#include "string_private_cstring.h"
 #include <assert.h>
 
 /*
@@ -2543,6 +2543,64 @@
 
 /*
 
+FUNCDOC: uint_to_str
+
+Returns C<num> converted to a Parrot C<STRING>.
+
+Note that C<base> must be defined, a default of 10 is not assumed. The
+caller has to verify that C<< base >= 2 && base <= 36 >>
+The buffer C<tc> must be at least C<sizeof (UHUGEINTVAL)*8 + 1> chars big.
+
+If C<minus> is true then C<-> is prepended to the string representation.
+
+*/
+
+STRING*
+uint_to_str(Interp *interp,
+            char *tc /*NN*/, UHUGEINTVAL num, char base, int minus)
+{
+    /* the buffer must be at least as long as this */
+    char *p = tc + sizeof (UHUGEINTVAL)*8 + 1;
+    const char * const tail = p;
+
+    assert(base >= 2 && base <= 36);
+    do {
+        const char cur = (char)(num % base);
+        if (cur < 10) {
+            *--p = (char)('0' + cur);
+        }
+        else {
+            *--p = (char)('a' + cur - 10);
+        }
+    } while (num /= base);
+    if (minus)
+        *--p = '-';
+    return string_make(interp, p, tail - p, "ascii", 0);
+}
+
+/*
+
+FUNCDOC: int_to_str
+
+Returns C<num> converted to a Parrot C<STRING>.
+
+Note that C<base> must be defined, a default of 10 is not assumed.
+
+If C<< num < 0 >> then C<-> is prepended to the string representation.
+
+*/
+
+STRING *
+int_to_str(Interp *interp, char *tc /*NN*/, HUGEINTVAL num, char base)
+{
+    const int minus = (num<0);
+    if (minus)
+        num = -num;
+    return uint_to_str(interp, tc, (UHUGEINTVAL) num, base, minus);
+}
+
+/*
+
 =head1 SEE ALSO
 
 =over

Modified: trunk/src/string_primitives.c
==============================================================================
--- trunk/src/string_primitives.c       (original)
+++ trunk/src/string_primitives.c       Sat Jun  2 13:01:55 2007
@@ -19,6 +19,8 @@
 
 */
 
+/* HEADER: include/parrot/string_funcs.h */
+
 #include "parrot/parrot.h"
 #if PARROT_HAS_ICU
 #  include <unicode/ucnv.h>

Reply via email to