From d7d5a385832e5b805e02eaf2c358f4a9140af4e0 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Mon, 8 Feb 2010 21:15:17 +0000 Subject: [PATCH] patches by R. Larice --- ChangeLog | 2 ++ src/frontend/terminal.c | 29 ++++++++++++++++++++++------- src/frontend/terminal.h | 10 +++++++--- src/include/cpextern.h | 12 +++++++++++- src/ngsconvert.c | 2 +- src/spicelib/parser/inpgmod.c | 2 +- src/xspice/ipc/ipcsockets.c | 2 +- 7 files changed, 45 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 421b86505..79aacc780 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2010-02-08 Holger Vogt * com_sysinfo.c: 64 bit support enabled + * terminal.c, terminal.h, cpextern.h, ngsconvert.c, inpgmod.c, ipcsockets.c: patches by + R. Larice from Feb. 8th, 2010 2010-02-07 Dietmar Warning * cpl/cplload.c, cplsetup.c, /txl/txlload.c, txlsetup.c, include/swec.h, multi_line.h, diff --git a/src/frontend/terminal.c b/src/frontend/terminal.c index bd2015663..f8bb3aa33 100644 --- a/src/frontend/terminal.c +++ b/src/frontend/terminal.c @@ -9,8 +9,11 @@ $Id$ * dependencies in here, and it isn't clear that versions of this stuff * can be written for every possible machine... */ +#include "ngspice.h" #include "config.h" +#include + #ifdef HAVE_SGTTY_H #include #endif @@ -248,18 +251,27 @@ out_send(char *string) /* Printf some stuff using more mode. */ void -out_printf(char *fmt, char *s1, char *s2, char *s3, char *s4, char *s5, char *s6, char *s7, char *s8, char *s9, char *s10) +out_printf(char *fmt, ...) { #if defined(HAVE_ASPRINTF) /* seems the best solution */ char * tbuf; - asprintf(&tbuf, fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10); + va_list ap; + va_start (ap, fmt); + vasprintf(&tbuf, fmt, ap); + va_end (ap); out_send(tbuf); FREE(tbuf); #elif defined(HAVE_SNPRINTF) /* the second best */ - snprintf(out_pbuf, sizeof(out_pbuf), fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10); + va_list ap; + va_start (ap, fmt); + vsnprintf(out_pbuf, sizeof(out_pbuf), fmt, ap); + va_end (ap); out_send(out_pbuf); #else /* guaranteed a bug for long messages */ - sprintf(out_pbuf, fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10); + va_list ap; + va_start (ap, fmt); + vsprintf(out_pbuf, fmt, ap); + va_end (ap); out_send(out_pbuf); #endif return; @@ -363,9 +375,12 @@ void tcap_init(void) {} void out_send(char *string) {fprintf(cp_out,string);} void -out_printf(char *fmt, char *s1, char *s2, char *s3, char *s4, char *s5, - char *s6, char *s7, char *s8, char *s9, char *s10) { - fprintf(cp_out,fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10); +out_printf(char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + vfprintf(cp_out, fmt, ap); + va_end (ap); } #endif /* TCL_MODULE */ diff --git a/src/frontend/terminal.h b/src/frontend/terminal.h index bf045a59f..93c420ab8 100644 --- a/src/frontend/terminal.h +++ b/src/frontend/terminal.h @@ -7,9 +7,13 @@ void out_init(void); void outbufputc(void); void promptreturn(void); void out_send(char *string); -void out_printf(char *fmt, char *s1, char *s2, char *s3, - char *s4, char *s5, char *s6, - char *s7, char *s8, char *s9, char *s10); + +#ifdef __GNUC__ +extern void out_printf(char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +#else +extern void out_printf(char *fmt, ...); +#endif + void term_clear(void); void term_home(void); void term_cleol(void); diff --git a/src/include/cpextern.h b/src/include/cpextern.h index f2c9839d5..e39b29c73 100644 --- a/src/include/cpextern.h +++ b/src/include/cpextern.h @@ -133,8 +133,18 @@ extern bool out_isatty; extern void out_init(); #ifndef out_printf /* don't want to declare it if we have #define'ed it */ +#ifdef __GNUC__ +#ifdef HAS_WINDOWS +#undef printf +#endif +extern void out_printf(char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +#ifdef HAS_WINDOWS +#define printf p_r_i_n_t_f +#endif +#else +extern void out_printf(char *fmt, ...); +#endif -extern void out_printf(); #endif extern void out_send(); diff --git a/src/ngsconvert.c b/src/ngsconvert.c index ae43df9c8..92235a72e 100644 --- a/src/ngsconvert.c +++ b/src/ngsconvert.c @@ -442,7 +442,7 @@ int cp_evloop(char *s) { return (0); } void cp_ccon(bool o) { } char *if_errstring(int c) { return ("error"); } #ifndef out_printf -void out_printf(char *fmt, int args) { } +void out_printf(char *fmt, ...) { } #endif void out_send(char *string) {} struct variable * cp_enqvar(char *word) { return (NULL); } diff --git a/src/spicelib/parser/inpgmod.c b/src/spicelib/parser/inpgmod.c index 8e4d11382..28acf0ad7 100644 --- a/src/spicelib/parser/inpgmod.c +++ b/src/spicelib/parser/inpgmod.c @@ -367,7 +367,7 @@ INPparseNumMod( void* ckt, INPmodel *model, INPtables *tab, char **errMessage ) if (cardType >= 0) { /* Add card structure to model */ info = INPcardTab[cardType]; - error = (*(info->newCard))( (void *)&tmpCard, + error = (*(info->newCard))( (void **)&tmpCard, model->INPmodfast ); if (error) return(error); /* Handle parameter-less cards */ diff --git a/src/xspice/ipc/ipcsockets.c b/src/xspice/ipc/ipcsockets.c index 429ffa553..9f2977119 100755 --- a/src/xspice/ipc/ipcsockets.c +++ b/src/xspice/ipc/ipcsockets.c @@ -576,7 +576,7 @@ Ipc_Status_t ipc_transport_get_line (str, len, wait) /* we must get the body. */ *len = message_length; - count = read_sock (msg_stream, str, message_length); + count = read_sock (msg_stream, str, message_length, IPC_WAIT, 0); if (count == 0) { /* EOF, will this ever happen? */ /* fprintf (stderr, */