Add a function itoa10 and use it
instead of non-standard itoa.
This commit is contained in:
parent
4aa5d784ec
commit
7703c2d370
|
|
@ -1242,7 +1242,7 @@ static int setallvsources(struct card *tmpcard, NGHASHPTR instances, char *instn
|
|||
sadd(&BVrefline, "Vref ");
|
||||
sadd(&BVrefline, instname);
|
||||
sadd(&BVrefline, "Vref 0 V = 1/");
|
||||
sadd(&BVrefline, _itoa(numnodes, numbuf, 10));
|
||||
sadd(&BVrefline, itoa10(numnodes, numbuf));
|
||||
sadd(&BVrefline, "*(");
|
||||
/* For example: Bq1power q1:power 0 V = */
|
||||
cadd(&Bpowerline, 'B');
|
||||
|
|
@ -1278,7 +1278,7 @@ static int setallvsources(struct card *tmpcard, NGHASHPTR instances, char *instn
|
|||
char* strnode1 = gettok(&instline);
|
||||
char* newnode = tprintf("int_%s_%s_%d", strnode1, instname, nodenum);
|
||||
char nodenumstr[3];
|
||||
char *nodename1 = get_terminal_name(instname, _itoa(nodenum, nodenumstr, 10), instances);
|
||||
char *nodename1 = get_terminal_name(instname, itoa10(nodenum, nodenumstr), instances);
|
||||
|
||||
newline = tprintf("%s %s %s", begstr, newnode, instline);
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ int substring_n(size_t n_char_pattern, const char *p_pattern,
|
|||
size_t n_char_str, const char *p_str);
|
||||
char *tprintf(const char *fmt, ...) ATTR_TPRINTF;
|
||||
char *tvprintf(const char *fmt, va_list args);
|
||||
|
||||
char* itoa10(int val, char* buf);
|
||||
|
||||
|
||||
/* Allocate and create a copy of a string if the argument is not null or
|
||||
|
|
|
|||
|
|
@ -1403,3 +1403,29 @@ bool has_escape_or_quote(size_t n, const char *str)
|
|||
return FALSE;
|
||||
} /* end of function may_have_eq */
|
||||
|
||||
/* Converts integer to string.
|
||||
Return the result string.
|
||||
Only 10 radix is supported */
|
||||
char *itoa10(int n, char s[])
|
||||
{
|
||||
int i, j, sign;
|
||||
char c;
|
||||
|
||||
if ((sign = n) < 0) /* record sign */
|
||||
n = -n; /* make n positive */
|
||||
i = 0;
|
||||
do { /* generate digits in reverse order */
|
||||
s[i++] = n % 10 + '0'; /* get next digit */
|
||||
} while ((n /= 10) > 0); /* delete it */
|
||||
if (sign < 0)
|
||||
s[i++] = '-';
|
||||
s[i] = '\0';
|
||||
/* revert string */
|
||||
for (i = 0, j = (int)strlen(s) - 1; i < j; i++, j--) {
|
||||
c = s[i];
|
||||
s[i] = s[j];
|
||||
s[j] = c;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue