From af8a867c625d0ba45177795dea995a842b22e5f6 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 19 Mar 2011 15:46:50 -0700 Subject: [PATCH] Make tparam.h and terminfo.c consistent. * cm.c (tputs, tgoto, BC, UP): Remove extern decls. Include tparam.h instead, since it declares them. * cm.h (PC): Remove extern decl; tparam.h now does this. * deps.mk (cm.o, terminfo.o): Depend on tparam.h. * terminfo.c: Include tparam.h, to check interfaces. (tparm): Make 1st arg a const pointer in decl. Put it at top level. (tparam): Adjust signature to match interface in tparam.h; this removes some undefined behavior. Check that outstring and len are zero, which they always are with Emacs. * tparam.h (PC, BC, UP): New extern decls. --- src/ChangeLog | 12 ++++++++++++ src/cm.c | 10 +--------- src/cm.h | 2 -- src/deps.mk | 4 ++-- src/terminfo.c | 23 +++++++++++++---------- src/tparam.h | 4 ++++ 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 37534dc6c6..841f4ee69d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,17 @@ 2011-03-19 Paul Eggert + Make tparam.h and terminfo.c consistent. + * cm.c (tputs, tgoto, BC, UP): Remove extern decls. Include + tparam.h instead, since it declares them. + * cm.h (PC): Remove extern decl; tparam.h now does this. + * deps.mk (cm.o, terminfo.o): Depend on tparam.h. + * terminfo.c: Include tparam.h, to check interfaces. + (tparm): Make 1st arg a const pointer in decl. Put it at top level. + (tparam): Adjust signature to match interface in tparam.h; + this removes some undefined behavior. Check that outstring and len + are zero, which they always are with Emacs. + * tparam.h (PC, BC, UP): New extern decls. + * xftfont.c (xftfont_shape): Now static, and defined only if needed. (xftfont_open): Rename locals to avoid shadowing. diff --git a/src/cm.c b/src/cm.c index 108ee5720f..6379955b48 100644 --- a/src/cm.c +++ b/src/cm.c @@ -27,19 +27,11 @@ along with GNU Emacs. If not, see . */ #include "cm.h" #include "termhooks.h" #include "termchar.h" - - -/* For now, don't try to include termcap.h. On some systems, - configure finds a non-standard termcap.h that the main build - won't find. */ -extern void tputs (const char *, int, int (*)(int)); -extern char *tgoto (const char *, int, int); +#include "tparam.h" #define BIG 9999 /* 9999 good on VAXen. For 16 bit machines use about 2000.... */ -extern char *BC, *UP; - int cost; /* sums up costs */ /* ARGSUSED */ diff --git a/src/cm.h b/src/cm.h index 5d430598f0..8f23990ce5 100644 --- a/src/cm.h +++ b/src/cm.h @@ -96,8 +96,6 @@ struct cm int cc_vabs; }; -extern char PC; /* Pad character */ - /* Shorthand */ #ifndef NoCMShortHand #define curY(tty) (tty)->Wcm->cm_curY diff --git a/src/deps.mk b/src/deps.mk index 35754dfa7d..d84e80dca4 100644 --- a/src/deps.mk +++ b/src/deps.mk @@ -65,7 +65,7 @@ coding.o: coding.c coding.h ccl.h buffer.h character.h charset.h composite.h \ window.h dispextern.h msdos.h frame.h termhooks.h \ lisp.h globals.h $(config_h) cm.o: cm.c frame.h cm.h termhooks.h termchar.h dispextern.h msdos.h \ - lisp.h globals.h $(config_h) + tparam.h lisp.h globals.h $(config_h) cmds.o: cmds.c syntax.h buffer.h character.h commands.h window.h lisp.h \ globals.h $(config_h) msdos.h dispextern.h keyboard.h keymap.h systime.h \ coding.h frame.h composite.h @@ -196,7 +196,7 @@ termcap.o: termcap.c lisp.h tparam.h msdos.h $(config_h) terminal.o: terminal.c frame.h termchar.h termhooks.h charset.h coding.h \ keyboard.h lisp.h globals.h $(config_h) dispextern.h composite.h systime.h \ msdos.h -terminfo.o: terminfo.c lisp.h globals.h $(config_h) +terminfo.o: terminfo.c tparam.h lisp.h globals.h $(config_h) tparam.o: tparam.c tparam.h lisp.h $(config_h) undo.o: undo.c buffer.h commands.h window.h dispextern.h msdos.h \ lisp.h globals.h $(config_h) diff --git a/src/terminfo.c b/src/terminfo.c index 905a8edacc..c0418984ef 100644 --- a/src/terminfo.c +++ b/src/terminfo.c @@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ #include +#include "tparam.h" + #include #include "lisp.h" @@ -33,18 +35,19 @@ char *UP, *BC, PC; format is different too. */ +extern char *tparm (const char *str, ...); + + char * -tparam (char *string, char *outstring, - int len, int arg1, int arg2, int arg3, int arg4, - int arg5, int arg6, int arg7, int arg8, int arg9) +tparam (const char *string, char *outstring, int len, + int arg1, int arg2, int arg3, int arg4) { char *temp; - extern char *tparm (char *str, ...); - temp = tparm (string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - if (outstring == 0) - outstring = ((char *) (xmalloc ((strlen (temp)) + 1))); - strcpy (outstring, temp); - return outstring; -} + /* Emacs always should pass a null OUTSTRING and zero LEN. */ + if (outstring || len) + abort (); + temp = tparm (string, arg1, arg2, arg3, arg4); + return xstrdup (temp); +} diff --git a/src/tparam.h b/src/tparam.h index 3cd3e6053c..dc4cdfaa28 100644 --- a/src/tparam.h +++ b/src/tparam.h @@ -29,3 +29,7 @@ char *tgetstr (const char *, char **); char *tgoto (const char *, int, int); char *tparam (const char *, char *, int, int, int, int, int); + +extern char PC; +extern char *BC; +extern char *UP; -- 2.39.2