From 8b2070268a79d71403a7dd7ce178552327cdc1c2 Mon Sep 17 00:00:00 2001 From: Kevin Ruland Date: Sat, 31 Dec 2005 03:15:12 +0000 Subject: [PATCH] Made string typemaps handle strings with embedded nulls. Changed to use cstring::data() instead of c_str() to avoid a possible copy. (Ollie Betts) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8147 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Lib/php4/std_string.i | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SWIG/Lib/php4/std_string.i b/SWIG/Lib/php4/std_string.i index 94759a448..4a875e522 100644 --- a/SWIG/Lib/php4/std_string.i +++ b/SWIG/Lib/php4/std_string.i @@ -25,21 +25,21 @@ namespace std { %typemap(in) string { convert_to_string_ex($input); - $1 = std::string(Z_STRVAL_PP($input)); + $1 = std::string(Z_STRVAL_PP($input),Z_STRLEN_PP($input)); } %typemap(in) const string & (std::string temp) { convert_to_string_ex($input); - temp = std::string(Z_STRVAL_PP($input)); + temp = std::string(Z_STRVAL_PP($input),Z_STRLEN_PP($input)); $1 = &temp; } %typemap(out) string { - ZVAL_STRINGL($result,const_cast($1.c_str()),$1.length(),1); + ZVAL_STRINGL($result,const_cast($1.data()),$1.length(),1); } %typemap(out) const string & { - ZVAL_STRINGL($result,const_cast($1->c_str()),$1->length(),1); + ZVAL_STRINGL($result,const_cast($1->data()),$1->length(),1); } %typemap(throws) string %{