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: new file tparam.h to fix Emacs API glitch Date: Tue, 08 Mar 2011 10:32:21 -0800 Organization: UCLA Computer Science Department Message-ID: <4D767635.5070700@cs.ucla.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1299609164 7975 80.91.229.12 (8 Mar 2011 18:32:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 8 Mar 2011 18:32:44 +0000 (UTC) To: Emacs-Devel devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 08 19:32:39 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 1Px1hy-0003EK-H6 for ged-emacs-devel@m.gmane.org; Tue, 08 Mar 2011 19:32:39 +0100 Original-Received: from localhost ([127.0.0.1]:37814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Px1hx-0003SA-7a for ged-emacs-devel@m.gmane.org; Tue, 08 Mar 2011 13:32:33 -0500 Original-Received: from [140.186.70.92] (port=58547 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Px1hq-0003S5-Ea for emacs-devel@gnu.org; Tue, 08 Mar 2011 13:32:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Px1ho-0008Ne-Q5 for emacs-devel@gnu.org; Tue, 08 Mar 2011 13:32:26 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:40697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Px1ho-0008NT-6N for emacs-devel@gnu.org; Tue, 08 Mar 2011 13:32:24 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id B554239E80E1 for ; Tue, 8 Mar 2011 10:32:22 -0800 (PST) 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 rbtdY1HpQpns for ; Tue, 8 Mar 2011 10:32:21 -0800 (PST) Original-Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id AA92D39E80DF for ; Tue, 8 Mar 2011 10:32:21 -0800 (PST) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7 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:136899 Archived-At: term.c declares and uses a function tparam, but its definition in tparam.c uses an incompatible API. This violates the C standard, and possibly can cause runtime problems. I plan to fix the problem in the trunk with the following patch, which adds a new file tparam.h that contains the API so that any future incompatibilities are caught. I thought I'd give a heads-up as this may require a change to the dependencies in the Windows build process. * tparam.h: New file. * term.c, tparam.h: Include it. * deps.mk (term.o, tparam.o): Depend on tparam.h. * term.c (tputs, tgetent, tgetflag, tgetnum, tparam, tgetstr): Move these decls to tparam.h, and make them agree with what is actually in tparam.c. The previous trick of using incompatible decls in different modules does not conform to the C standard. All callers of tparam changed to use tparam's actual API. * tparam.c (tparam1, tparam, tgoto): Use const pointers where appropriate. === modified file 'src/deps.mk' --- src/deps.mk 2011-02-20 10:53:22 +0000 +++ src/deps.mk 2011-03-08 18:04:33 +0000 @@ -190,13 +190,13 @@ term.o: term.c termchar.h termhooks.h termopts.h lisp.h globals.h $(config_h) \ cm.h frame.h disptab.h keyboard.h character.h charset.h coding.h ccl.h \ xterm.h msdos.h window.h keymap.h blockinput.h atimer.h systime.h \ - systty.h syssignal.h $(INTERVALS_H) buffer.h ../lib/unistd.h + systty.h syssignal.h tparam.h $(INTERVALS_H) buffer.h ../lib/unistd.h termcap.o: termcap.c lisp.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) -tparam.o: tparam.c lisp.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) unexaix.o: unexaix.c lisp.h $(config_h) === modified file 'src/term.c' --- src/term.c 2011-03-08 17:31:51 +0000 +++ src/term.c 2011-03-08 18:18:03 +0000 @@ -32,6 +32,7 @@ #include "lisp.h" #include "termchar.h" #include "termopts.h" +#include "tparam.h" #include "buffer.h" #include "character.h" #include "charset.h" @@ -53,18 +54,6 @@ static int been_here = -1; #endif -/* 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 int tgetent (char *, const char *); -extern int tgetflag (char *id); -extern int tgetnum (char *id); - -char *tparam (char *, char *, int, int, ...); - -extern char *tgetstr (char *, char **); - #include "cm.h" #ifdef HAVE_X_WINDOWS #include "xterm.h" @@ -262,7 +251,7 @@ struct tty_display_info *tty = FRAME_TTY (f); if (tty->TS_set_scroll_region) - buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1); + buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1, 0, 0); else if (tty->TS_set_scroll_region_1) buf = tparam (tty->TS_set_scroll_region_1, 0, 0, FRAME_LINES (f), start, @@ -859,7 +848,7 @@ if (tty->TS_ins_multi_chars) { - buf = tparam (tty->TS_ins_multi_chars, 0, 0, len); + buf = tparam (tty->TS_ins_multi_chars, 0, 0, len, 0, 0, 0); OUTPUT1 (tty, buf); xfree (buf); if (start) @@ -955,7 +944,7 @@ if (tty->TS_del_multi_chars) { - buf = tparam (tty->TS_del_multi_chars, 0, 0, n); + buf = tparam (tty->TS_del_multi_chars, 0, 0, n, 0, 0, 0); OUTPUT1 (tty, buf); xfree (buf); } @@ -997,7 +986,7 @@ { raw_cursor_to (f, vpos, 0); tty_background_highlight (tty); - buf = tparam (multi, 0, 0, i); + buf = tparam (multi, 0, 0, i, 0, 0, 0); OUTPUT (tty, buf); xfree (buf); } @@ -2125,7 +2114,7 @@ ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; if (fg >= 0 && ts) { - p = tparam (ts, NULL, 0, (int) fg); + p = tparam (ts, NULL, 0, (int) fg, 0, 0, 0); OUTPUT (tty, p); xfree (p); } @@ -2133,7 +2122,7 @@ ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; if (bg >= 0 && ts) { - p = tparam (ts, NULL, 0, (int) bg); + p = tparam (ts, NULL, 0, (int) bg, 0, 0, 0); OUTPUT (tty, p); xfree (p); } === modified file 'src/tparam.c' --- src/tparam.c 2011-01-15 23:16:57 +0000 +++ src/tparam.c 2011-03-08 18:16:15 +0000 @@ -21,6 +21,7 @@ #include #include #include "lisp.h" /* for xmalloc */ +#include "tparam.h" #ifndef NULL #define NULL (char *) 0 @@ -38,11 +39,12 @@ The fourth and following args to tparam serve as the parameter values. */ -static char *tparam1 (char *string, char *outstring, int len, char *up, char *left, register int *argp); +static char *tparam1 (char const *string, char *outstring, int len, + char *up, char *left, int *argp); -/* VARARGS 2 */ char * -tparam (char *string, char *outstring, int len, int arg0, int arg1, int arg2, int arg3) +tparam (const char *string, char *outstring, int len, + int arg0, int arg1, int arg2, int arg3) { int arg[4]; @@ -59,7 +61,7 @@ static char tgoto_buf[50]; char * -tgoto (char *cm, int hpos, int vpos) +tgoto (const char *cm, int hpos, int vpos) { int args[2]; if (!cm) @@ -70,10 +72,11 @@ } static char * -tparam1 (char *string, char *outstring, int len, char *up, char *left, register int *argp) +tparam1 (const char *string, char *outstring, int len, + char *up, char *left, register int *argp) { register int c; - register char *p = string; + register const char *p = string; register char *op = outstring; char *outend; int outlen = 0; @@ -277,4 +280,3 @@ } #endif /* DEBUG */ - === added file 'src/tparam.h' --- src/tparam.h 1970-01-01 00:00:00 +0000 +++ src/tparam.h 2011-03-08 18:16:45 +0000 @@ -0,0 +1,31 @@ +/* Interface definitions for termcap entries. + +Copyright (C) 2011 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see . */ + + +/* Don't try to include termcap.h. On some systems, configure finds a + non-standard termcap.h that the main build won't find. */ + +void tputs (const char *, int, int (*) (int)); +int tgetent (char *, const char *); +int tgetflag (char *id); +int tgetnum (char *id); +char *tgetstr (char *, char **); +char *tgoto (const char *, int, int); + +char *tparam (const char *, char *, int, int, int, int, int);