Make tparam.h and terminfo.c consistent.
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 19 Mar 2011 22:46:50 +0000 (15:46 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 19 Mar 2011 22:46:50 +0000 (15:46 -0700)
* 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
src/cm.c
src/cm.h
src/deps.mk
src/terminfo.c
src/tparam.h

index 37534dc..841f4ee 100644 (file)
@@ -1,5 +1,17 @@
 2011-03-19  Paul Eggert  <eggert@cs.ucla.edu>
 
+       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.
 
index 108ee57..6379955 100644 (file)
--- a/src/cm.c
+++ b/src/cm.c
@@ -27,19 +27,11 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #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 */
index 5d43059..8f23990 100644 (file)
--- 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
index 35754df..d84e80d 100644 (file)
@@ -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)
index 905a8ed..c041898 100644 (file)
@@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
+#include "tparam.h"
+
 #include <setjmp.h>
 #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);
+}
index 3cd3e60..dc4cdfa 100644 (file)
@@ -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;