Use DOH String instead of static char buffers.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9339 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c9cfd2f800
commit
8904cc86c1
5 changed files with 49 additions and 52 deletions
|
|
@ -681,7 +681,7 @@ public:
|
|||
ParmList *l = Getattr(n,"parms");
|
||||
Parm *p;
|
||||
String *proc_name = 0;
|
||||
char source[256], target[256];
|
||||
char source[256];
|
||||
Wrapper *f = NewWrapper();;
|
||||
String *cleanup = NewString("");
|
||||
String *outarg = NewString("");
|
||||
|
|
@ -769,7 +769,6 @@ public:
|
|||
}
|
||||
|
||||
SwigType *pt = Getattr(p,"type");
|
||||
String *ln = Getattr(p,"lname");
|
||||
int opt_p = (i >= numreq);
|
||||
|
||||
// Produce names of source and target
|
||||
|
|
@ -777,7 +776,7 @@ public:
|
|||
sprintf(source, "argv[%d]", i);
|
||||
else
|
||||
sprintf(source,"s_%d",i);
|
||||
sprintf(target,"%s", Char(ln));
|
||||
String *target = Getattr(p,"lname");
|
||||
|
||||
if (!args_passed_as_array) {
|
||||
if (i!=0) Printf(f->def,", ");
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ public:
|
|||
Parm *p;
|
||||
int i;
|
||||
Wrapper *f;
|
||||
char source[256],target[256],temp[256];
|
||||
char source[256],temp[256];
|
||||
String *tm;
|
||||
String *cleanup, *outarg;
|
||||
int num_saved = 0;
|
||||
|
|
@ -567,11 +567,10 @@ public:
|
|||
}
|
||||
|
||||
SwigType *pt = Getattr(p,"type");
|
||||
String *ln = Getattr(p,"lname");
|
||||
|
||||
/* Produce string representation of source and target arguments */
|
||||
sprintf(source,"ST(%d)",i);
|
||||
sprintf(target,"%s", Char(ln));
|
||||
String *target = Getattr(p,"lname");
|
||||
|
||||
if (i >= num_required) {
|
||||
Printf(f->code," if (items > %d) {\n", i);
|
||||
|
|
|
|||
|
|
@ -170,8 +170,8 @@ public:
|
|||
|
||||
/* If shadow classing is enabled, we're going to change the module name to "_module" */
|
||||
if (itcl) {
|
||||
char filen[256];
|
||||
sprintf(filen,"%s%s.itcl", Swig_file_dirname(outfile), Char(module));
|
||||
String *filen;
|
||||
filen = NewStringf("%s%s.itcl", Swig_file_dirname(outfile), module);
|
||||
|
||||
Insert( module,0,"_" );
|
||||
|
||||
|
|
@ -190,7 +190,8 @@ public:
|
|||
NIL);
|
||||
|
||||
Printv(f_shadow,"\npackage require Itcl\n\n", NIL);
|
||||
};
|
||||
Delete(filen);
|
||||
}
|
||||
|
||||
/* Generate some macros used throughout code generation */
|
||||
|
||||
|
|
|
|||
|
|
@ -71,17 +71,13 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
|
|||
|
||||
out = NewStringEmpty();
|
||||
vPrintf(out,fmt,ap);
|
||||
{
|
||||
char temp[64], *t;
|
||||
t = temp;
|
||||
msg = Char(out);
|
||||
while (isdigit((int) *msg)) {
|
||||
*(t++) = *(msg++);
|
||||
}
|
||||
if (t != temp) {
|
||||
|
||||
msg = Char(out);
|
||||
if (isdigit((unsigned char)*msg)) {
|
||||
unsigned long result = strtoul(msg, &msg, 10);
|
||||
if (msg != Char(out)) {
|
||||
msg++;
|
||||
*t = 0;
|
||||
wnum = atoi(temp);
|
||||
wnum = result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ Swig_require(const char *ns, Node *n, ...) {
|
|||
va_list ap;
|
||||
char *name;
|
||||
DOH *obj;
|
||||
char temp[512];
|
||||
String *temp = NewStringEmpty();
|
||||
|
||||
va_start(ap, n);
|
||||
name = va_arg(ap, char *);
|
||||
|
|
@ -292,10 +292,9 @@ Swig_require(const char *ns, Node *n, ...) {
|
|||
if (!obj) obj = DohNone;
|
||||
if (newref) {
|
||||
/* Save a copy of the attribute */
|
||||
strcpy(temp,ns);
|
||||
strcat(temp,":");
|
||||
strcat(temp,name);
|
||||
Printf(temp, "%s:%s", ns, name);
|
||||
Setattr(n,temp,obj);
|
||||
Clear(temp);
|
||||
}
|
||||
name = va_arg(ap, char *);
|
||||
}
|
||||
|
|
@ -306,16 +305,18 @@ Swig_require(const char *ns, Node *n, ...) {
|
|||
String *view = Getattr(n,k_view);
|
||||
if (view) {
|
||||
if (Strcmp(view,ns) != 0) {
|
||||
strcpy(temp,ns);
|
||||
strcat(temp,":view");
|
||||
Printf(temp, "%s:view", ns);
|
||||
Setattr(n,temp,view);
|
||||
Setattr(n,k_view,ns);
|
||||
Clear(temp);
|
||||
}
|
||||
} else {
|
||||
Setattr(n,k_view,ns);
|
||||
}
|
||||
}
|
||||
|
||||
Delete(temp);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -331,7 +332,7 @@ Swig_save(const char *ns, Node *n, ...) {
|
|||
va_list ap;
|
||||
char *name;
|
||||
DOH *obj;
|
||||
char temp[512];
|
||||
String *temp = NewStringEmpty();
|
||||
|
||||
va_start(ap, n);
|
||||
name = va_arg(ap, char *);
|
||||
|
|
@ -345,13 +346,12 @@ Swig_save(const char *ns, Node *n, ...) {
|
|||
if (!obj) obj = DohNone;
|
||||
|
||||
/* Save a copy of the attribute */
|
||||
strcpy(temp,ns);
|
||||
strcat(temp,":");
|
||||
strcat(temp,name);
|
||||
Printf(temp, "%s:%s", ns, name);
|
||||
if (Setattr(n,temp,obj)) {
|
||||
Printf(stderr,"Swig_save('%s','%s'): Warning, attribute '%s' was already saved.\n", ns, nodeType(n), name);
|
||||
Printf(stderr,"Swig_save('%s','%s'): Warning, attribute '%s' was already saved. [%s]\n", ns, nodeType(n), name);
|
||||
}
|
||||
name = va_arg(ap, char *);
|
||||
Clear(temp);
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
|
|
@ -360,16 +360,18 @@ Swig_save(const char *ns, Node *n, ...) {
|
|||
String *view = Getattr(n,k_view);
|
||||
if (view) {
|
||||
if (Strcmp(view,ns) != 0) {
|
||||
strcpy(temp,ns);
|
||||
strcat(temp,":view");
|
||||
Printf(temp, "%s:view", ns);
|
||||
Setattr(n,temp,view);
|
||||
Setattr(n,k_view,ns);
|
||||
Clear(temp);
|
||||
}
|
||||
} else {
|
||||
Setattr(n,k_view,ns);
|
||||
}
|
||||
}
|
||||
|
||||
Delete(temp);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -380,7 +382,7 @@ Swig_save(const char *ns, Node *n, ...) {
|
|||
|
||||
void
|
||||
Swig_restore(Node *n) {
|
||||
char temp[512];
|
||||
String *temp;
|
||||
int len;
|
||||
List *l;
|
||||
String *ns;
|
||||
|
|
@ -391,12 +393,11 @@ Swig_restore(Node *n) {
|
|||
|
||||
l = NewList();
|
||||
|
||||
strcpy(temp,Char(ns));
|
||||
strcat(temp,":");
|
||||
len = strlen(temp);
|
||||
temp = NewStringf("%s:", ns);
|
||||
len = Len(temp);
|
||||
|
||||
for (ki = First(n); ki.key; ki = Next(ki)) {
|
||||
if (strncmp(temp,Char(ki.key),len) == 0) {
|
||||
if (strncmp(Char(temp),Char(ki.key),len) == 0) {
|
||||
Append(l,ki.key);
|
||||
}
|
||||
}
|
||||
|
|
@ -406,6 +407,7 @@ Swig_restore(Node *n) {
|
|||
Delattr(n,ki.item);
|
||||
}
|
||||
Delete(l);
|
||||
Delete(temp);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue