From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Make tparam.h and terminfo.c consistent. Date: Sat, 19 Mar 2011 15:49:25 -0700 Organization: UCLA Computer Science Department Message-ID: <4D8532F5.8050909@cs.ucla.edu> References: <4D767635.5070700@cs.ucla.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1300574985 10705 80.91.229.12 (19 Mar 2011 22:49:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 19 Mar 2011 22:49:45 +0000 (UTC) To: Emacs-Devel devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 19 23:49:41 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q14xo-0003Hi-CU for ged-emacs-devel@m.gmane.org; Sat, 19 Mar 2011 23:49:40 +0100 Original-Received: from localhost ([127.0.0.1]:41414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q14xn-0004zP-Qs for ged-emacs-devel@m.gmane.org; Sat, 19 Mar 2011 18:49:39 -0400 Original-Received: from [140.186.70.92] (port=54604 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q14xh-0004yE-Rt for emacs-devel@gnu.org; Sat, 19 Mar 2011 18:49:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q14xc-00032O-Qe for emacs-devel@gnu.org; Sat, 19 Mar 2011 18:49:33 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:57089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q14xc-00032F-FB for emacs-devel@gnu.org; Sat, 19 Mar 2011 18:49:28 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 6C46A39E8116 for ; Sat, 19 Mar 2011 15:49:27 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9b+8uSdzDO2v for ; Sat, 19 Mar 2011 15:49:26 -0700 (PDT) Original-Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 100C139E80F2 for ; Sat, 19 Mar 2011 15:49:26 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: <4D767635.5070700@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 131.179.128.62 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:137435 Archived-At: 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 . */ #include +#include "tparam.h" + #include #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;