[svn:parrot] r42248 - in trunk: compilers/imcc src/string
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Tue Nov 3 21:12:19 UTC 2009
Author: NotFound
Date: Tue Nov 3 21:12:18 2009
New Revision: 42248
URL: https://trac.parrot.org/parrot/changeset/42248
Log:
[cage] fix mistakes in char * constness manifested by g++ 4.4.1, TT #1110
Modified:
trunk/compilers/imcc/pbc.c
trunk/compilers/imcc/pbc.h
trunk/compilers/imcc/reg_alloc.c
trunk/src/string/api.c
Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c Tue Nov 3 20:24:16 2009 (r42247)
+++ trunk/compilers/imcc/pbc.c Tue Nov 3 21:12:18 2009 (r42248)
@@ -906,7 +906,7 @@
/*
-=item C<STRING * IMCC_string_from__STRINGC(PARROT_INTERP, const char *buf)>
+=item C<STRING * IMCC_string_from__STRINGC(PARROT_INTERP, char *buf)>
=cut
@@ -915,7 +915,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
STRING *
-IMCC_string_from__STRINGC(PARROT_INTERP, ARGIN(const char *buf))
+IMCC_string_from__STRINGC(PARROT_INTERP, ARGIN(char *buf))
{
ASSERT_ARGS(IMCC_string_from__STRINGC)
const int ascii = (*buf == '\'' || *buf == '"');
Modified: trunk/compilers/imcc/pbc.h
==============================================================================
--- trunk/compilers/imcc/pbc.h Tue Nov 3 20:24:16 2009 (r42247)
+++ trunk/compilers/imcc/pbc.h Tue Nov 3 21:12:18 2009 (r42248)
@@ -38,7 +38,7 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-STRING * IMCC_string_from__STRINGC(PARROT_INTERP, ARGIN(const char *buf))
+STRING * IMCC_string_from__STRINGC(PARROT_INTERP, ARGIN(char *buf))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
Modified: trunk/compilers/imcc/reg_alloc.c
==============================================================================
--- trunk/compilers/imcc/reg_alloc.c Tue Nov 3 20:24:16 2009 (r42247)
+++ trunk/compilers/imcc/reg_alloc.c Tue Nov 3 21:12:18 2009 (r42248)
@@ -725,7 +725,7 @@
for (i = count = unused = 0; i < unit->n_symbols; i++) {
SymReg * const r = unit->reglist[i];
- char *p;
+ const char *p;
int reg_set;
if (r->color == -1)
Modified: trunk/src/string/api.c
==============================================================================
--- trunk/src/string/api.c Tue Nov 3 20:24:16 2009 (r42247)
+++ trunk/src/string/api.c Tue Nov 3 21:12:18 2009 (r42248)
@@ -2787,7 +2787,7 @@
const char *enc_name = enc_char ? enc_char : "ascii";
/* does the encoding have a character set? */
- char *p = enc_char ? strchr(enc_char, ':') : NULL;
+ const char *p = enc_char ? strchr(enc_char, ':') : NULL;
size_t clength = strlen(cstring);
String_iter iter;
UINTVAL offs, d;
@@ -2800,8 +2800,15 @@
--clength;
if (p) {
- *p = '\0';
- encoding = Parrot_find_encoding(interp, enc_char);
+ #define MAX_ENCODING_NAME_ALLOWED 63
+ char buffer[MAX_ENCODING_NAME_ALLOWED + 1];
+ size_t l= p - enc_char;
+ charset = NULL;
+ if (l < MAX_ENCODING_NAME_ALLOWED) {
+ memcpy(buffer, enc_char, l);
+ buffer[l]= '\0';
+ encoding = Parrot_find_encoding(interp, buffer);
+ }
if (!encoding)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
"Can't make '%s' encoding strings", enc_char);
More information about the parrot-commits
mailing list