[svn:parrot] r42026 - trunk/src/string
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Thu Oct 22 22:10:37 UTC 2009
Author: chromatic
Date: Thu Oct 22 22:10:36 2009
New Revision: 42026
URL: https://trac.parrot.org/parrot/changeset/42026
Log:
[string] Worked around C++-foiling constness-losing assignment in
Parrot_str_unescape(), visible in TT #1110 (Michael Hind).
Modified:
trunk/src/string/api.c
Modified: trunk/src/string/api.c
==============================================================================
--- trunk/src/string/api.c Thu Oct 22 21:42:07 2009 (r42025)
+++ trunk/src/string/api.c Thu Oct 22 22:10:36 2009 (r42026)
@@ -2778,14 +2778,20 @@
ARGIN(const char *cstring), char delimiter, ARGIN_NULLOK(const char *enc_char))
{
ASSERT_ARGS(Parrot_str_unescape)
- size_t clength = strlen(cstring);
- Parrot_UInt4 r;
- String_iter iter;
+
STRING *result;
const ENCODING *encoding;
const CHARSET *charset;
- char *p;
- UINTVAL offs, d;
+
+ /* the default encoding is ascii */
+ const char *enc_name = enc_char ? enc_char : "ascii";
+
+ /* does the encoding have a character set? */
+ char *p = enc_char ? strchr(enc_char, ':') : NULL;
+ size_t clength = strlen(cstring);
+ String_iter iter;
+ INTVAL offs, d;
+ Parrot_UInt4 r;
/* we are constructing const table strings here */
const UINTVAL flags = PObj_constant_FLAG;
@@ -2793,13 +2799,6 @@
if (delimiter && clength)
--clength;
- /* default is ascii */
- if (!enc_char)
- enc_char = "ascii";
-
- /* check for encoding: */
- p = strchr(enc_char, ':');
-
if (p) {
*p = '\0';
encoding = Parrot_find_encoding(interp, enc_char);
More information about the parrot-commits
mailing list