Another place which can use std::string::assign() which I failed to check in
with the others. Also use std::string::data() instead of std::string::c_str() where we don't need the trailing '\0'. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9988 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
32acb4c43e
commit
b1b889059d
1 changed files with 3 additions and 3 deletions
|
|
@ -38,7 +38,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
Tcl_Obj* SwigString_FromString(std::string s) {
|
Tcl_Obj* SwigString_FromString(std::string s) {
|
||||||
return Tcl_NewStringObj(s.c_str(), s.length());
|
return Tcl_NewStringObj(s.data(), s.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Tcl_GetBoolFromObj(Tcl_Interp *interp, Tcl_Obj *o, bool *val) {
|
int Tcl_GetBoolFromObj(Tcl_Interp *interp, Tcl_Obj *o, bool *val) {
|
||||||
|
|
@ -53,9 +53,9 @@ int Tcl_GetBoolFromObj(Tcl_Interp *interp, Tcl_Obj *o, bool *val) {
|
||||||
int SwigString_AsString(Tcl_Interp *interp, Tcl_Obj *o, std::string *val) {
|
int SwigString_AsString(Tcl_Interp *interp, Tcl_Obj *o, std::string *val) {
|
||||||
int len;
|
int len;
|
||||||
const char* temp = Tcl_GetStringFromObj(o, &len);
|
const char* temp = Tcl_GetStringFromObj(o, &len);
|
||||||
if(temp == NULL)
|
if (temp == NULL)
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
*val = temp;
|
val->assign(temp, len);
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue