[svn:parrot] r48837 - in trunk: compilers/imcc examples/compilers include/parrot lib/Parrot/Pmc2c src src/dynoplibs src/interp src/io src/ops src/pmc src/string src/string/encoding
nwellnhof at svn.parrot.org
nwellnhof at svn.parrot.org
Tue Sep 7 23:48:08 UTC 2010
Author: nwellnhof
Date: Tue Sep 7 23:48:07 2010
New Revision: 48837
URL: https://trac.parrot.org/parrot/changeset/48837
Log:
[str] Switch most users of string_make to Parrot_str_new_init
Modified:
trunk/compilers/imcc/parser_util.c
trunk/compilers/imcc/pbc.c
trunk/examples/compilers/japhc.c
trunk/include/parrot/misc.h
trunk/lib/Parrot/Pmc2c/PMCEmitter.pm
trunk/src/datatypes.c
trunk/src/debug.c
trunk/src/dynoplibs/sys.ops
trunk/src/embed.c
trunk/src/exceptions.c
trunk/src/interp/inter_misc.c
trunk/src/io/socket_unix.c
trunk/src/io/socket_win32.c
trunk/src/misc.c
trunk/src/ops/core_ops.c
trunk/src/ops/sys.ops
trunk/src/pbc_merge.c
trunk/src/pmc/nci.pmc
trunk/src/pmc/stringhandle.pmc
trunk/src/pmc/unmanagedstruct.pmc
trunk/src/spf_vtable.c
trunk/src/string/api.c
trunk/src/string/encoding/ascii.c
trunk/src/string/encoding/binary.c
trunk/src/string/encoding/latin1.c
trunk/src/string/encoding/shared.c
Modified: trunk/compilers/imcc/parser_util.c
==============================================================================
--- trunk/compilers/imcc/parser_util.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/compilers/imcc/parser_util.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -805,7 +805,8 @@
IMCC_INFO(interp) = imc_info;
}
- fs = string_make(interp, fullname, strlen(fullname), NULL, 0);
+ fs = Parrot_str_new_init(interp, fullname, strlen(fullname),
+ Parrot_default_encoding_ptr, 0);
if (Parrot_stat_info_intval(interp, fs, STAT_ISDIR))
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_EXTERNAL_ERROR,
Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/compilers/imcc/pbc.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -1048,12 +1048,13 @@
}
else if (*buf == '\'') { /* TODO handle python raw strings */
buf++;
- return string_make(interp, buf, strlen(buf) - 1, "ascii",
- PObj_constant_FLAG);
+ return Parrot_str_new_init(interp, buf, strlen(buf) - 1,
+ Parrot_ascii_encoding_ptr, PObj_constant_FLAG);
}
/* unquoted bare name - ASCII only don't unescape it */
- return string_make(interp, buf, strlen(buf), "ascii", PObj_constant_FLAG);
+ return Parrot_str_new_init(interp, buf, strlen(buf),
+ Parrot_ascii_encoding_ptr, PObj_constant_FLAG);
}
/*
@@ -1101,7 +1102,8 @@
}
else if (*buf == '\'') {
buf++;
- return string_make(interp, buf, strlen(buf) - 1, "ascii", PObj_constant_FLAG);
+ return Parrot_str_new_init(interp, buf, strlen(buf) - 1,
+ Parrot_ascii_encoding_ptr, PObj_constant_FLAG);
}
else {
IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR, "Unknown STRING format: '%s'\n", buf);
Modified: trunk/examples/compilers/japhc.c
==============================================================================
--- trunk/examples/compilers/japhc.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/examples/compilers/japhc.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -147,8 +147,8 @@
/* Allocate a new constant */
consts->constants[--k] = PackFile_Constant_new(interp);
consts->constants[k]->type = PFC_STRING;
- consts->constants[k]->u.string =
- string_make(interp, buf, (UINTVAL) l, "iso-8859-1", 0);
+ consts->constants[k]->u.string = Parrot_str_new_init(interp, buf,
+ (UINTVAL) l, Parrot_latin1_encoding_ptr, 0);
free(o);
return k;
}
Modified: trunk/include/parrot/misc.h
==============================================================================
--- trunk/include/parrot/misc.h Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/include/parrot/misc.h Tue Sep 7 23:48:07 2010 (r48837)
@@ -259,8 +259,10 @@
*/
# define PARROT_SPRINTF_MAX_PREC 3 * PARROT_SPRINTF_BUFFER_SIZE / 4
-# define cstr2pstr(cstr) string_make(interp, (cstr), strlen(cstr), "ascii", 0)
-# define char2pstr(ch) string_make(interp, &(ch), 1, "ascii", 0)
+# define cstr2pstr(cstr) Parrot_str_new_init(interp, (cstr), strlen(cstr), \
+ Parrot_ascii_encoding_ptr, 0)
+# define char2pstr(ch) Parrot_str_new_init(interp, &(ch), 1, \
+ Parrot_ascii_encoding_ptr, 0)
/* SPRINTF DATA STRUCTURE AND FLAGS */
Modified: trunk/lib/Parrot/Pmc2c/PMCEmitter.pm
==============================================================================
--- trunk/lib/Parrot/Pmc2c/PMCEmitter.pm Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/lib/Parrot/Pmc2c/PMCEmitter.pm Tue Sep 7 23:48:07 2010 (r48837)
@@ -569,10 +569,10 @@
if ( $self->is_dynamic ) {
$cout .= <<"EOC";
vt->base_type = entry;
- vt->whoami = string_make(interp, "$classname", @{[length($classname)]},
- "ascii", PObj_constant_FLAG|PObj_external_FLAG);
+ vt->whoami = Parrot_str_new_init(interp, "$classname", @{[length($classname)]},
+ Parrot_ascii_encoding_ptr, PObj_constant_FLAG|PObj_external_FLAG);
vt->provides_str = Parrot_str_concat(interp, vt->provides_str,
- string_make(interp, "$provides", @{[length($provides)]}, "ascii",
+ Parrot_str_new_init(interp, "$provides", @{[length($provides)]}, Parrot_ascii_encoding_ptr,
PObj_constant_FLAG|PObj_external_FLAG));
EOC
@@ -835,7 +835,8 @@
}
$get_mro
VTABLE_unshift_string(interp, mro,
- string_make(interp, "$classname", @{[length($classname)]}, NULL, 0));
+ Parrot_str_new_init(interp, "$classname", @{[length($classname)]},
+ Parrot_default_encoding_ptr, 0));
return mro;
}
Modified: trunk/src/datatypes.c
==============================================================================
--- trunk/src/datatypes.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/datatypes.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -78,7 +78,8 @@
? "illegal"
: data_types[type - enum_first_type].name;
- return string_make(interp, s, strlen(s), NULL, PObj_external_FLAG);
+ return Parrot_str_new_init(interp, s, strlen(s),
+ Parrot_default_encoding_ptr, PObj_external_FLAG);
}
/*
Modified: trunk/src/debug.c
==============================================================================
--- trunk/src/debug.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/debug.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -1415,8 +1415,8 @@
#if TRACE_DEBUGGER
fprintf(stderr, "PDB_break: '%s'\n", str);
#endif
- condition->value = string_make(interp, str, (UINTVAL)(i - 1),
- NULL, 0);
+ condition->value = Parrot_str_new_init(interp, str, (UINTVAL)(i - 1),
+ Parrot_default_encoding_ptr, 0);
condition->type |= PDB_cond_const;
}
Modified: trunk/src/dynoplibs/sys.ops
==============================================================================
--- trunk/src/dynoplibs/sys.ops Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/dynoplibs/sys.ops Tue Sep 7 23:48:07 2010 (r48837)
@@ -203,7 +203,8 @@
{
struct utsname info;
if (uname(&info) == 0) {
- $1 = string_make(interp, info.version, strlen(info.version), "ascii", 0);
+ $1 = Parrot_str_new_init(interp, info.version, strlen(info.version),
+ Parrot_ascii_encoding_ptr, 0);
}
}
break;
@@ -212,14 +213,16 @@
{
struct utsname info;
if (uname(&info) == 0) {
- $1 = string_make(interp, info.release, strlen(info.version), "ascii", 0);
+ $1 = Parrot_str_new_init(interp, info.release, strlen(info.version),
+ Parrot_ascii_encoding_ptr, 0);
}
}
break;
#endif
case CPU_ARCH:
- $1 = string_make(interp, PARROT_CPU_ARCH, sizeof (PARROT_CPU_ARCH) - 1, "ascii", 0);
+ $1 = Parrot_str_new_init(interp, PARROT_CPU_ARCH, sizeof (PARROT_CPU_ARCH) - 1,
+ Parrot_ascii_encoding_ptr, 0);
break;
case CPU_TYPE:
Modified: trunk/src/embed.c
==============================================================================
--- trunk/src/embed.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/embed.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -427,8 +427,8 @@
program_size = 0;
}
else {
- STRING * const fs = string_make(interp, fullname, strlen(fullname),
- NULL, 0);
+ STRING * const fs = Parrot_str_new_init(interp, fullname, strlen(fullname),
+ Parrot_default_encoding_ptr, 0);
/* can't read a file that doesn't exist */
if (!Parrot_stat_info_intval(interp, fs, STAT_EXISTS)) {
@@ -658,9 +658,8 @@
for (i = 0; i < argc; ++i) {
/* Run through argv, adding everything to @ARGS. */
- STRING * const arg =
- string_make(interp, argv[i], strlen(argv[i]), "unicode",
- PObj_external_FLAG);
+ STRING * const arg = Parrot_str_new_init(interp, argv[i], strlen(argv[i]),
+ Parrot_utf8_encoding_ptr, PObj_external_FLAG);
if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG))
Parrot_io_eprintf(interp, "\t%vd: %s\n", i, argv[i]);
Modified: trunk/src/exceptions.c
==============================================================================
--- trunk/src/exceptions.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/exceptions.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -300,7 +300,8 @@
STRING * const msg =
strchr(format, '%')
? Parrot_vsprintf_c(interp, format, arglist)
- : string_make(interp, format, strlen(format), NULL, 0);
+ : Parrot_str_new_init(interp, format, strlen(format),
+ Parrot_default_encoding_ptr, 0);
return Parrot_ex_build_exception(interp, EXCEPT_error, ex_type, msg);
}
Modified: trunk/src/interp/inter_misc.c
==============================================================================
--- trunk/src/interp/inter_misc.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/interp/inter_misc.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -48,13 +48,13 @@
{
ASSERT_ARGS(register_nci_method)
PMC * const method = Parrot_pmc_new(interp, enum_class_NCI);
- STRING * const method_name = string_make(interp, name, strlen(name),
- NULL, PObj_constant_FLAG|PObj_external_FLAG);
+ STRING * const method_name = Parrot_str_new_init(interp, name, strlen(name),
+ Parrot_default_encoding_ptr, PObj_constant_FLAG|PObj_external_FLAG);
/* create call func */
VTABLE_set_pointer_keyed_str(interp, method,
- string_make(interp, proto, strlen(proto), NULL,
- PObj_constant_FLAG|PObj_external_FLAG),
+ Parrot_str_new_init(interp, proto, strlen(proto),
+ Parrot_default_encoding_ptr, PObj_constant_FLAG|PObj_external_FLAG),
func);
/* insert it into namespace */
Modified: trunk/src/io/socket_unix.c
==============================================================================
--- trunk/src/io/socket_unix.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/io/socket_unix.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -352,7 +352,8 @@
/* The charset should probably be 'binary', but right now httpd.pir
* only works with 'ascii'
*/
- *s = string_make(interp, buf, bytesread, "ascii", 0);
+ *s = Parrot_str_new_init(interp, buf, bytesread,
+ Parrot_ascii_encoding_ptr, 0);
return bytesread;
}
else {
Modified: trunk/src/io/socket_win32.c
==============================================================================
--- trunk/src/io/socket_win32.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/io/socket_win32.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -302,7 +302,8 @@
/* The charset should probably be 'binary', but right now httpd.pir
* only works with 'ascii'
*/
- *s = string_make(interp, buf, bytesread, "ascii", 0);
+ *s = Parrot_str_new_init(interp, buf, bytesread,
+ Parrot_ascii_encoding_ptr, 0);
return bytesread;
}
else {
Modified: trunk/src/misc.c
==============================================================================
--- trunk/src/misc.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/misc.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -87,8 +87,8 @@
Parrot_vsprintf_c(PARROT_INTERP, ARGIN(const char *pat), va_list args)
{
ASSERT_ARGS(Parrot_vsprintf_c)
- STRING * const realpat = string_make(interp, pat, strlen(pat),
- NULL, PObj_external_FLAG);
+ STRING * const realpat = Parrot_str_new_init(interp, pat, strlen(pat),
+ Parrot_default_encoding_ptr, PObj_external_FLAG);
STRING * const ret = Parrot_vsprintf_s(interp, realpat, args);
Modified: trunk/src/ops/core_ops.c
==============================================================================
--- trunk/src/ops/core_ops.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/ops/core_ops.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -23597,7 +23597,8 @@
Parrot_err_s(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
const char * const tmp = strerror(errno);
- SREG(1) = string_make(interp, tmp, strlen(tmp), "ascii", 0);
+ SREG(1) = Parrot_str_new_init(interp, tmp, strlen(tmp),
+ Parrot_ascii_encoding_ptr, 0);
return (opcode_t *)cur_opcode + 2;}
@@ -23605,7 +23606,8 @@
Parrot_err_s_i(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
const char * const tmp = strerror(IREG(2));
- SREG(1) = string_make(interp, tmp, strlen(tmp), "ascii", 0);
+ SREG(1) = Parrot_str_new_init(interp, tmp, strlen(tmp),
+ Parrot_ascii_encoding_ptr, 0);
return (opcode_t *)cur_opcode + 3;}
@@ -23613,7 +23615,8 @@
Parrot_err_s_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
const char * const tmp = strerror(cur_opcode[2]);
- SREG(1) = string_make(interp, tmp, strlen(tmp), "ascii", 0);
+ SREG(1) = Parrot_str_new_init(interp, tmp, strlen(tmp),
+ Parrot_ascii_encoding_ptr, 0);
return (opcode_t *)cur_opcode + 3;}
Modified: trunk/src/ops/sys.ops
==============================================================================
--- trunk/src/ops/sys.ops Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/ops/sys.ops Tue Sep 7 23:48:07 2010 (r48837)
@@ -72,12 +72,14 @@
op err(out STR) {
const char * const tmp = strerror(errno);
- $1 = string_make(interp, tmp, strlen(tmp), "ascii", 0);
+ $1 = Parrot_str_new_init(interp, tmp, strlen(tmp),
+ Parrot_ascii_encoding_ptr, 0);
}
op err(out STR, in INT) {
const char * const tmp = strerror($2);
- $1 = string_make(interp, tmp, strlen(tmp), "ascii", 0);
+ $1 = Parrot_str_new_init(interp, tmp, strlen(tmp),
+ Parrot_ascii_encoding_ptr, 0);
}
Modified: trunk/src/pbc_merge.c
==============================================================================
--- trunk/src/pbc_merge.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/pbc_merge.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -232,8 +232,8 @@
INTVAL read_result;
/* Check the file exists. */
- STRING * const fs = string_make(interp, fullname,
- strlen(fullname), NULL, 0);
+ STRING * const fs = Parrot_str_new_init(interp, fullname,
+ strlen(fullname), Parrot_default_encoding_ptr, 0);
if (!Parrot_stat_info_intval(interp, fs, STAT_EXISTS)) {
Parrot_io_eprintf(interp, "PBC Merge: Can't stat %s, code %i.\n",
fullname, errno);
Modified: trunk/src/pmc/nci.pmc
==============================================================================
--- trunk/src/pmc/nci.pmc Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/pmc/nci.pmc Tue Sep 7 23:48:07 2010 (r48837)
@@ -257,8 +257,8 @@
if (!PObj_constant_TEST(key)) {
char * const key_c = Parrot_str_to_cstring(INTERP, key);
const size_t key_length = Parrot_str_byte_length(interp, key);
- key = string_make(interp, key_c, key_length,
- NULL, PObj_constant_FLAG);
+ key = Parrot_str_new_init(interp, key_c, key_length,
+ Parrot_default_encoding_ptr, PObj_constant_FLAG);
Parrot_str_free_cstring(key_c);
}
Modified: trunk/src/pmc/stringhandle.pmc
==============================================================================
--- trunk/src/pmc/stringhandle.pmc Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/pmc/stringhandle.pmc Tue Sep 7 23:48:07 2010 (r48837)
@@ -193,7 +193,8 @@
GET_ATTR_encoding(INTERP, SELF, encoding);
if (encoding_is_utf8(INTERP, encoding))
- new_string = string_make(INTERP, "", 0, "unicode", 0);
+ new_string = Parrot_str_new_init(INTERP, "", 0,
+ Parrot_utf8_encoding_ptr, 0);
else
new_string = CONST_STRING(INTERP, "");
@@ -313,7 +314,8 @@
STRING *encoding;
GET_ATTR_encoding(INTERP, SELF, encoding);
if (encoding_is_utf8(INTERP, encoding))
- string_result = string_make(INTERP, "", 0, "unicode", 0);
+ string_result = Parrot_str_new_init(INTERP, "", 0,
+ Parrot_utf8_encoding_ptr, 0);
else
string_result = CONST_STRING(INTERP, "");
}
Modified: trunk/src/pmc/unmanagedstruct.pmc
==============================================================================
--- trunk/src/pmc/unmanagedstruct.pmc Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/pmc/unmanagedstruct.pmc Tue Sep 7 23:48:07 2010 (r48837)
@@ -488,7 +488,8 @@
other type or flag must be added.
Need to provide some way to specify charset and encoding.
*/
- return string_make(interp, cstr, len, "iso-8859-1", 0);
+ return Parrot_str_new_init(interp, cstr, len,
+ Parrot_latin1_encoding_ptr, 0);
}
else
return NULL;
Modified: trunk/src/spf_vtable.c
==============================================================================
--- trunk/src/spf_vtable.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/spf_vtable.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -183,7 +183,7 @@
/* char promoted to int */
char ch = (char)va_arg(*arg, int);
- return string_make(interp, &ch, 1, "iso-8859-1", 0);
+ return Parrot_str_new_init(interp, &ch, 1, Parrot_latin1_encoding_ptr, 0);
}
/*
Modified: trunk/src/string/api.c
==============================================================================
--- trunk/src/string/api.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/string/api.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -3282,7 +3282,8 @@
if (minus)
*--p = '-';
- return string_make(interp, p, (UINTVAL)(tail - p), NULL, 0);
+ return Parrot_str_new_init(interp, p, (UINTVAL)(tail - p),
+ Parrot_default_encoding_ptr, 0);
}
Modified: trunk/src/string/encoding/ascii.c
==============================================================================
--- trunk/src/string/encoding/ascii.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/string/encoding/ascii.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -210,8 +210,8 @@
{
ASSERT_ARGS(ascii_chr)
char real_codepoint = (char)codepoint;
- STRING * const return_string = string_make(interp, &real_codepoint, 1, "ascii", 0);
- return return_string;
+ return Parrot_str_new_init(interp, &real_codepoint, 1,
+ Parrot_ascii_encoding_ptr, 0);
}
/*
Modified: trunk/src/string/encoding/binary.c
==============================================================================
--- trunk/src/string/encoding/binary.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/string/encoding/binary.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -121,7 +121,8 @@
{
ASSERT_ARGS(binary_chr)
char real_codepoint = (char)codepoint;
- return string_make(interp, &real_codepoint, 1, "binary", 0);
+ return Parrot_str_new_init(interp, &real_codepoint, 1,
+ Parrot_binary_encoding_ptr, 0);
}
Modified: trunk/src/string/encoding/latin1.c
==============================================================================
--- trunk/src/string/encoding/latin1.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/string/encoding/latin1.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -198,10 +198,9 @@
{
ASSERT_ARGS(latin1_chr)
char real_codepoint = (char)codepoint;
- STRING * const return_string = string_make(interp, &real_codepoint, 1,
- "iso-8859-1", 0);
PARROT_ASSERT(codepoint < 0x100);
- return return_string;
+ return Parrot_str_new_init(interp, &real_codepoint, 1,
+ Parrot_latin1_encoding_ptr, 0);
}
Modified: trunk/src/string/encoding/shared.c
==============================================================================
--- trunk/src/string/encoding/shared.c Tue Sep 7 23:44:11 2010 (r48836)
+++ trunk/src/string/encoding/shared.c Tue Sep 7 23:48:07 2010 (r48837)
@@ -968,7 +968,8 @@
{
ASSERT_ARGS(unicode_chr)
String_iter iter;
- STRING * const dest = string_make(interp, "", 1, "unicode", 0);
+ STRING * const dest = Parrot_str_new_init(interp, NULL, 4,
+ Parrot_utf8_encoding_ptr, 0);
dest->strlen = 1;
More information about the parrot-commits
mailing list