emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Make tparam.h and terminfo.c consistent.


From: Paul Eggert
Subject: Make tparam.h and terminfo.c consistent.
Date: Sat, 19 Mar 2011 15:49:25 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8

On 03/08/2011 10:32 AM, Paul Eggert wrote:
> term.c declares and uses a function tparam, but its definition in
> tparam.c uses an incompatible API.

Following up on that previous email of mine, I found another
incompatible-API declaration and use for tparam, this time in terminfo.c.
I plan to install the following patch to work around this problem.

I'm giving a heads-up now as this probably requires
a change to the dependencies in the MS-DOS and MS-Windows
build processes.

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.
=== modified file 'src/cm.c'
--- src/cm.c    2011-03-09 02:12:00 +0000
+++ src/cm.c    2011-03-19 06:24:24 +0000
@@ -27,19 +27,11 @@
 #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 */

=== modified file 'src/cm.h'
--- src/cm.h    2011-03-09 02:12:00 +0000
+++ src/cm.h    2011-03-19 06:28:37 +0000
@@ -96,8 +96,6 @@
     int cc_vabs;
   };

-extern char PC;                        /* Pad character */
-
 /* Shorthand */
 #ifndef NoCMShortHand
 #define curY(tty)              (tty)->Wcm->cm_curY

=== modified file 'src/deps.mk'
--- src/deps.mk 2011-03-17 00:22:09 +0000
+++ src/deps.mk 2011-03-19 22:02:47 +0000
@@ -65,7 +65,7 @@
    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 @@
 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)

=== modified file 'src/terminfo.c'
--- src/terminfo.c      2011-01-25 04:08:28 +0000
+++ src/terminfo.c      2011-03-19 22:32:45 +0000
@@ -17,6 +17,8 @@
 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 @@
    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);
 }
-

=== modified file 'src/tparam.h'
--- src/tparam.h        2011-03-09 05:46:35 +0000
+++ src/tparam.h        2011-03-19 06:32:29 +0000
@@ -29,3 +29,7 @@
 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;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]