From 8c8506401822a0384a0b786a2628c93b5e8f1f0a Mon Sep 17 00:00:00 2001 From: h_vogt Date: Tue, 3 Sep 2013 16:39:12 +0200 Subject: [PATCH] inperrc.c: new function `INPstrCat()' to concatenate two strings --- src/include/ngspice/inpdefs.h | 1 + src/spicelib/parser/inperrc.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/include/ngspice/inpdefs.h b/src/include/ngspice/inpdefs.h index fc077a059..b4623f77b 100644 --- a/src/include/ngspice/inpdefs.h +++ b/src/include/ngspice/inpdefs.h @@ -95,6 +95,7 @@ char *INPdevParse(char **, CKTcircuit *, int, GENinstance *, double *, int *, IN char *INPdomodel(CKTcircuit *, card *, INPtables *); void INPdoOpts(CKTcircuit *, JOB *, card *, INPtables *); char *INPerrCat(char *, char *); +char *INPstrCat(char *, char *, char *); char *INPerror(int); double INPevaluate(char **, int *, int); char *INPfindLev(char *, int *); diff --git a/src/spicelib/parser/inperrc.c b/src/spicelib/parser/inperrc.c index 31ae5c5a5..b56b51912 100644 --- a/src/spicelib/parser/inperrc.c +++ b/src/spicelib/parser/inperrc.c @@ -34,3 +34,24 @@ char *INPerrCat(char *a, char *b) } else /* a null, so return b */ return (b); } + + +char *INPstrCat(char *a, char *b, char *c) +{ + if (a != NULL) { + if (b == NULL) { /* a valid, b null, return a */ + return (a); + } else { /* both valid - hard work... */ + register char *strtmp; + strtmp = + TMALLOC(char, strlen(a) + strlen(b) + 2); + (void) strcpy(strtmp, a); + (void) strcat(strtmp, c); /* single character only! */ + (void) strcat(strtmp, b); + FREE(a); + FREE(b); + return (strtmp); + } + } else /* a null, so return b */ + return (b); +}