From 1820d1a2491b7b99f034ae6decb1ad8f60c6d35b Mon Sep 17 00:00:00 2001 From: arno Date: Sat, 13 May 2000 10:15:32 +0000 Subject: [PATCH] * src/parser/output.c src/parser/output.h: Moved these files to src/misc directory. * src/include/terminal.h src/misc/terminal.c src/misc/terminal.h: new home to output.[ch] files. * src/parser/Makefile.am src/misc/Makefile.am: Updated for move. --- src/include/terminal.h | 1 + src/misc/Makefile.am | 4 +- src/{parser/output.c => misc/terminal.c} | 126 +++++++++++------------ src/{parser/output.h => misc/terminal.h} | 13 +-- src/parser/Makefile.am | 2 - 5 files changed, 66 insertions(+), 80 deletions(-) create mode 100644 src/include/terminal.h rename src/{parser/output.c => misc/terminal.c} (90%) rename src/{parser/output.h => misc/terminal.h} (52%) diff --git a/src/include/terminal.h b/src/include/terminal.h new file mode 100644 index 000000000..554c69fb5 --- /dev/null +++ b/src/include/terminal.h @@ -0,0 +1 @@ +#include "../misc/terminal.h" diff --git a/src/misc/Makefile.am b/src/misc/Makefile.am index d3f96ba5a..cf15b9cae 100644 --- a/src/misc/Makefile.am +++ b/src/misc/Makefile.am @@ -17,9 +17,11 @@ libmisc_a_SOURCES = \ printnum.h \ string.c \ string.h \ + terminal.c \ + terminal.h \ tilde.c \ tilde.h \ - misc_time.c \ + misc_time.c \ misc_time.h diff --git a/src/parser/output.c b/src/misc/terminal.c similarity index 90% rename from src/parser/output.c rename to src/misc/terminal.c index 46f80f7ac..4ccb7a56e 100644 --- a/src/parser/output.c +++ b/src/misc/terminal.c @@ -8,18 +8,31 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group * dependencies in here, and it isn't clear that versions of this stuff * can be written for every possible machine... */ - #include -#include "ngspice.h" -#include "cpdefs.h" -#include "output.h" #ifdef HAVE_SGTTY_H #include #endif -static void bufputc(char c); -static int outfn(char c); +#if 0 +/* Bad interaction with bool type in bool.h because curses also + defines this symbol. */ +#ifdef HAVE_TERMCAP +#include +#include +#endif +#endif + +#include "ngspice.h" +#include "cpdefs.h" + + +#include "terminal.h" + +static char *motion_chars; +static char *clear_chars; +static char *home_chars; +static char *cleol_chars; #define DEF_SCRHEIGHT 24 @@ -32,11 +45,6 @@ static int xsize, ysize; static int xpos, ypos; static bool noprint, nopause; -static char *motion_chars; -static char *clear_chars; -static char *home_chars; -static char *cleol_chars; - /* out_printf doesn't handle double arguments correctly, so we sprintf into this buf and call out_send w/ it */ @@ -108,7 +116,7 @@ outbufputc(void) if (ourbuf.count != BUFSIZ) { fputs(staticbuf, cp_out); - bzero(staticbuf, BUFSIZ-ourbuf.count); + memset(staticbuf, 0, BUFSIZ-ourbuf.count); ourbuf.count = BUFSIZ; ourbuf.ptr = staticbuf; } @@ -129,28 +137,6 @@ bufputc(char c) } } -#ifdef NOTDEF -/* This tricky little macro + recursive routine was giving the Ultrix - * global optimizer serious fits, so it was nuked. - * The replacement above is not quite as fast, but somehow I don't think - * that will cause too many problems these days. - */ -#define bufputc(c) ( --ourbuf.count >= 0 ? ((int) \ - (*ourbuf.ptr++ = (unsigned)(c))) : fbufputc((unsigned) (c))) - -static int -fbufputc(c) -unsigned char c; -{ - - ourbuf.count = 0; - outbufputc(); - ourbuf.count = BUFSIZ; - ourbuf.ptr = staticbuf; - bufputc(c); - -} -#endif /* prompt for a return */ void @@ -255,46 +241,14 @@ out_printf(char *fmt, char *s1, char *s2, char *s3, char *s4, char *s5, char *s6 return; } -void -term_clear(void) -{ -#ifdef HAVE_TERMCAP - if (*clear_chars) - tputs(clear_chars, 1, outfn); - else - fputs("\n", stdout); -#endif -} - -void -term_home(void) -{ -#ifdef HAVE_TERMCAP - if (*home_chars) - tputs(home_chars, 1, outfn); - else if (*motion_chars) - tputs(tgoto(motion_chars, 1, 1), 1, outfn); - else - fputs("\n", stdout); -#endif -} - -void -term_cleol(void) -{ -#ifdef HAVE_TERMCAP - if (*cleol_chars) - tputs(cleol_chars, 1, outfn); -#endif -} - static int -outfn(char c) +outfn(int c) { putc(c, stdout); return c; } + void tcap_init(void) { @@ -334,3 +288,39 @@ tcap_init(void) ysize = 0; } } + + +void +term_clear(void) +{ +#ifdef HAVE_TERMCAP + if (*clear_chars) + tputs(clear_chars, 1, outfn); + else + fputs("\n", stdout); +#endif +} + + +void +term_home(void) +{ +#ifdef HAVE_TERMCAP + if (*home_chars) + tputs(home_chars, 1, outfn); + else if (*motion_chars) + tputs(tgoto(motion_chars, 1, 1), 1, outfn); + else + fputs("\n", stdout); +#endif +} + + +void +term_cleol(void) +{ +#ifdef HAVE_TERMCAP + if (*cleol_chars) + tputs(cleol_chars, 1, outfn); +#endif +} diff --git a/src/parser/output.h b/src/misc/terminal.h similarity index 52% rename from src/parser/output.h rename to src/misc/terminal.h index 2e709343a..a3890750c 100644 --- a/src/parser/output.h +++ b/src/misc/terminal.h @@ -1,21 +1,16 @@ -/************* - * Header file for output.c - * 1999 E. Rouat - ************/ - -#ifndef OUTPUT_H_INCLUDED -#define OUTPUT_H_INCLUDED +#ifndef _TERMINAL_H +#define _TERMINAL_H 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, +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); void term_clear(void); void term_home(void); void term_cleol(void); void tcap_init(void); - #endif diff --git a/src/parser/Makefile.am b/src/parser/Makefile.am index a92eaed35..f88f4083f 100644 --- a/src/parser/Makefile.am +++ b/src/parser/Makefile.am @@ -25,8 +25,6 @@ libparser_a_SOURCES = \ modify.h \ numparse.c \ numparse.h \ - output.c \ - output.h \ quote.c \ quote.h \ std.c \