cvsuser 02/12/26 03:28:52
Modified: . string.c
docs strings.pod
Log:
#19357
Revision Changes Path
1.120 +2 -2 parrot/string.c
Index: string.c
===================================================================
RCS file: /cvs/public/parrot/string.c,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -w -r1.119 -r1.120
--- string.c 21 Dec 2002 13:36:24 -0000 1.119
+++ string.c 26 Dec 2002 11:28:50 -0000 1.120
@@ -1,7 +1,7 @@
/* string.c
* Copyright: (When this is determined...it will go here)
* CVS Info
- * $Id: string.c,v 1.119 2002/12/21 13:36:24 leo Exp $
+ * $Id: string.c,v 1.120 2002/12/26 11:28:50 leo Exp $
* Overview:
* This is the api definitions for the string subsystem
* Data Structure and Algorithms:
@@ -532,7 +532,7 @@
if (a != NULL) {
/* XXX
* string_transcode may here be used as string_copy, which is
- * the only case, where string_transcodes STRING isn't
+ * the only case, where string_transcode STRING isn't
* const */
return string_transcode(interpreter, b, a->encoding, a->type,
NULL);
1.12 +40 -24 parrot/docs/strings.pod
Index: strings.pod
===================================================================
RCS file: /cvs/public/parrot/docs/strings.pod,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -r1.11 -r1.12
--- strings.pod 21 Dec 2002 13:36:21 -0000 1.11
+++ strings.pod 26 Dec 2002 11:28:52 -0000 1.12
@@ -25,7 +25,7 @@
The most basic way of creating a string is through the function
C<string_make>:
- STRING* string_make(void *buffer, INTVAL buflen, INTVAL encoding, INTVAL flags,
INTVAL type)
+ STRING* string_make(struct Parrot_Interp *, const void *buffer, INTVAL buflen,
INTVAL encoding, INTVAL flags, INTVAL type)
In here you pass a pointer to a buffer of a given encoding, and the
number of bytes in that buffer to examine, the encoding, (see below for
@@ -40,20 +40,16 @@
I<Hint>: Nothing stops you doing
- string_make(NULL, 0, ...
+ string_make(interpreter, NULL, 0, ...
=back
If you already have a string, you can make a copy of it by calling
- STRING* string_copy(STRING* s)
+ STRING* string_copy(struct Parrot_Interp *, STRING* s)
This is itself implemented in terms of C<string_make>.
-When a string is done with, it can be destroyed using the destroyer
-
- void string_destroy(STRING *s)
-
=head2 String Manipulation Functions
Unless otherwise stated, all lengths, offsets, and so on, are given in
@@ -62,7 +58,7 @@
To find out the length of a string, use
- INTVAL string_length(STRING *s)
+ INTVAL string_length(const STRING *s)
You I<may> explicitly use C<< s->strlen >> for this since it is such a
useful operation.
@@ -70,7 +66,7 @@
To concatenate two strings - that is, to add the contents of string
C<b> to the end of string C<a>, use:
- STRING* string_concat(STRING* a, STRING *b, INTVAL flag)
+ STRING* string_concat(struct Parrot_Interp *, STRING* a, STRING *b, INTVAL flag)
C<a> is updated, and is also returned as a convenience. If the flag is
set to a non-zero value, then C<b> will be transcoded to C<a>'s encoding
@@ -80,7 +76,7 @@
To repeat a string, (ie, turn 'xyz' into 'xyzxyzxyz') use:
- STRING* string_repeat(struct Parrot_Interp *, STRING* s, INTVAL n, STRING** d)
+ STRING* string_repeat(struct Parrot_Interp *, const STRING* s, UINTVAL n,
STRING** d)
Which will repeat string I<s> n times and store the result into I<d>, which it
also returns. If I<*d> or I<**d> is NULL, a new string will be allocated
@@ -103,7 +99,7 @@
To retrieve a single character of the string, call
- INTVAL string_ord(STRING* s, INTVAL n)
+ INTVAL string_ord(const STRING* s, INTVAL n)
The result will be returned from the function. It checks for the existence of
C<s>, and tests for C<n> being out of range. Currently it applies the method
@@ -127,7 +123,7 @@
To test a string for truth, use:
- BOOLVAL string_bool(struct Parrot_Interp *, STRING* s);
+ BOOLVAL string_bool(STRING* s);
A string is false if it
@@ -262,7 +258,7 @@
string vtables to create encoding abstraction; here's an example of one:
STRING*
- string_concat(STRING* a, STRING* b, INTVAL flags) {
+ string_concat(struct Parrot_Interp *interpreter, STRING* a, STRING* b, INTVAL
flags) {
return (ENC_VTABLE(a).concat)(a, b, flags);
}
@@ -367,7 +363,7 @@
To grow a string to a specified size, use
- void string_grow(STRING *s, INTVAL newsize)
+ void string_grow(struct Parrot_Interp *, STRING *s, INTVAL newsize)
The size is given in characters; C<string_max_bytes> is called to turn
this into a size in bytes, and then the buffer is grown to accomodate
@@ -405,3 +401,23 @@
Fill this in later; if anyone wants to implement new encodings at this
stage they must be mad.
+=head1 Work In Progress
+
+The transcoding section is out of sync with the code.
+
+Should the following functions be mentioned?
+C<string_append>,
+C<string_from_c_string>,
+C<string_from_int>,
+C<string_from_num>,
+C<string_index>,
+C<string_replace>,
+C<string_set>,
+C<string_str_index>,
+C<string_to_cstring>,
+C<string_to_int>,
+C<string_to_num>,
+C<string_transcode>.
+
+C<string_bool> is here said to return C<BOOLVAL>. But the code is
+returning C<INTVAL> (2002Dec). Which is the right thing?