Minor improvements
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@248 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b198b70c5a
commit
840a4f83ff
2 changed files with 25 additions and 2 deletions
|
|
@ -142,10 +142,13 @@ int String_dump(DOH *so, DOH *out) {
|
||||||
* NewString(const char *c) - Create a new string
|
* NewString(const char *c) - Create a new string
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
DOH *
|
DOH *
|
||||||
NewString(char *s)
|
NewString(DOH *so)
|
||||||
{
|
{
|
||||||
int l = 0, max;
|
int l = 0, max;
|
||||||
String *str;
|
String *str;
|
||||||
|
char *s;
|
||||||
|
if (DohCheck(so)) s = Char(so);
|
||||||
|
else s = (char *) so;
|
||||||
str = (String *) DohObjMalloc(sizeof(String));
|
str = (String *) DohObjMalloc(sizeof(String));
|
||||||
str->objinfo = &StringType;
|
str->objinfo = &StringType;
|
||||||
DohXInit(str);
|
DohXInit(str);
|
||||||
|
|
@ -172,6 +175,24 @@ NewString(char *s)
|
||||||
return (DOH *) str;
|
return (DOH *) str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* NewStringf(DOH *fmt, ...)
|
||||||
|
*
|
||||||
|
* Create a new string from a list of objects.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
DOH *
|
||||||
|
NewStringf(DOH *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
DOH *r;
|
||||||
|
va_start(ap,fmt);
|
||||||
|
r = NewString("");
|
||||||
|
DohvPrintf(r,Char(fmt),ap);
|
||||||
|
va_end(ap);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* CopyString(DOH *s) - Copy a string
|
* CopyString(DOH *s) - Copy a string
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,9 @@ typedef struct {
|
||||||
* Strings.
|
* Strings.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
extern DOH *NewString(char *c);
|
extern DOH *NewString(DOH *c);
|
||||||
|
extern DOH *NewStringf(DOH *fmt, ...);
|
||||||
|
|
||||||
extern int String_check(DOH *s);
|
extern int String_check(DOH *s);
|
||||||
|
|
||||||
/* String replacement flags */
|
/* String replacement flags */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue