diff options
| author | Paul Eggert | 2011-03-08 10:26:34 -0800 |
|---|---|---|
| committer | Paul Eggert | 2011-03-08 10:26:34 -0800 |
| commit | 50938595880fd87c7dcd39a607cba1b0a7598baf (patch) | |
| tree | e505cffa90ab1c25e1f15c931e6e47c7575b4e2d /src | |
| parent | 75f8807fe6cc437f58845ec21621614d1dbb7f36 (diff) | |
| download | emacs-50938595880fd87c7dcd39a607cba1b0a7598baf.tar.gz emacs-50938595880fd87c7dcd39a607cba1b0a7598baf.zip | |
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/deps.mk | 4 | ||||
| -rw-r--r-- | src/term.c | 25 | ||||
| -rw-r--r-- | src/tparam.c | 16 | ||||
| -rw-r--r-- | src/tparam.h | 31 |
5 files changed, 60 insertions, 27 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 107d7d663da..350f01953d4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -87,6 +87,17 @@ | |||
| 87 | 87 | ||
| 88 | * term.c (encode_terminal_code): Now static. Remove unused local. | 88 | * term.c (encode_terminal_code): Now static. Remove unused local. |
| 89 | 89 | ||
| 90 | * tparam.h: New file. | ||
| 91 | * term.c, tparam.h: Include it. | ||
| 92 | * deps.mk (term.o, tparam.o): Depend on tparam.h. | ||
| 93 | * term.c (tputs, tgetent, tgetflag, tgetnum, tparam, tgetstr): | ||
| 94 | Move these decls to tparam.h, and make them agree with what | ||
| 95 | is actually in tparam.c. The previous trick of using incompatible | ||
| 96 | decls in different modules does not conform to the C standard. | ||
| 97 | All callers of tparam changed to use tparam's actual API. | ||
| 98 | * tparam.c (tparam1, tparam, tgoto): | ||
| 99 | Use const pointers where appropriate. | ||
| 100 | |||
| 90 | 2011-03-06 Chong Yidong <cyd@stupidchicken.com> | 101 | 2011-03-06 Chong Yidong <cyd@stupidchicken.com> |
| 91 | 102 | ||
| 92 | * xdisp.c (redisplay_window): Revert incorrect logic in 2011-03-06 | 103 | * xdisp.c (redisplay_window): Revert incorrect logic in 2011-03-06 |
diff --git a/src/deps.mk b/src/deps.mk index 77994bcaadb..2b162b07bb8 100644 --- a/src/deps.mk +++ b/src/deps.mk | |||
| @@ -190,13 +190,13 @@ sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \ | |||
| 190 | term.o: term.c termchar.h termhooks.h termopts.h lisp.h globals.h $(config_h) \ | 190 | term.o: term.c termchar.h termhooks.h termopts.h lisp.h globals.h $(config_h) \ |
| 191 | cm.h frame.h disptab.h keyboard.h character.h charset.h coding.h ccl.h \ | 191 | cm.h frame.h disptab.h keyboard.h character.h charset.h coding.h ccl.h \ |
| 192 | xterm.h msdos.h window.h keymap.h blockinput.h atimer.h systime.h \ | 192 | xterm.h msdos.h window.h keymap.h blockinput.h atimer.h systime.h \ |
| 193 | systty.h syssignal.h $(INTERVALS_H) buffer.h ../lib/unistd.h | 193 | systty.h syssignal.h tparam.h $(INTERVALS_H) buffer.h ../lib/unistd.h |
| 194 | termcap.o: termcap.c lisp.h $(config_h) | 194 | termcap.o: termcap.c lisp.h $(config_h) |
| 195 | terminal.o: terminal.c frame.h termchar.h termhooks.h charset.h coding.h \ | 195 | terminal.o: terminal.c frame.h termchar.h termhooks.h charset.h coding.h \ |
| 196 | keyboard.h lisp.h globals.h $(config_h) dispextern.h composite.h systime.h \ | 196 | keyboard.h lisp.h globals.h $(config_h) dispextern.h composite.h systime.h \ |
| 197 | msdos.h | 197 | msdos.h |
| 198 | terminfo.o: terminfo.c lisp.h globals.h $(config_h) | 198 | terminfo.o: terminfo.c lisp.h globals.h $(config_h) |
| 199 | tparam.o: tparam.c lisp.h $(config_h) | 199 | tparam.o: tparam.c tparam.h lisp.h $(config_h) |
| 200 | undo.o: undo.c buffer.h commands.h window.h dispextern.h msdos.h \ | 200 | undo.o: undo.c buffer.h commands.h window.h dispextern.h msdos.h \ |
| 201 | lisp.h globals.h $(config_h) | 201 | lisp.h globals.h $(config_h) |
| 202 | unexaix.o: unexaix.c lisp.h $(config_h) | 202 | unexaix.o: unexaix.c lisp.h $(config_h) |
diff --git a/src/term.c b/src/term.c index 80db7fbeb17..19d7d893069 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -32,6 +32,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 32 | #include "lisp.h" | 32 | #include "lisp.h" |
| 33 | #include "termchar.h" | 33 | #include "termchar.h" |
| 34 | #include "termopts.h" | 34 | #include "termopts.h" |
| 35 | #include "tparam.h" | ||
| 35 | #include "buffer.h" | 36 | #include "buffer.h" |
| 36 | #include "character.h" | 37 | #include "character.h" |
| 37 | #include "charset.h" | 38 | #include "charset.h" |
| @@ -53,18 +54,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 53 | static int been_here = -1; | 54 | static int been_here = -1; |
| 54 | #endif | 55 | #endif |
| 55 | 56 | ||
| 56 | /* For now, don't try to include termcap.h. On some systems, | ||
| 57 | configure finds a non-standard termcap.h that the main build | ||
| 58 | won't find. */ | ||
| 59 | extern void tputs (const char *, int, int (*)(int)); | ||
| 60 | extern int tgetent (char *, const char *); | ||
| 61 | extern int tgetflag (char *id); | ||
| 62 | extern int tgetnum (char *id); | ||
| 63 | |||
| 64 | char *tparam (char *, char *, int, int, ...); | ||
| 65 | |||
| 66 | extern char *tgetstr (char *, char **); | ||
| 67 | |||
| 68 | #include "cm.h" | 57 | #include "cm.h" |
| 69 | #ifdef HAVE_X_WINDOWS | 58 | #ifdef HAVE_X_WINDOWS |
| 70 | #include "xterm.h" | 59 | #include "xterm.h" |
| @@ -262,7 +251,7 @@ tty_set_scroll_region (struct frame *f, int start, int stop) | |||
| 262 | struct tty_display_info *tty = FRAME_TTY (f); | 251 | struct tty_display_info *tty = FRAME_TTY (f); |
| 263 | 252 | ||
| 264 | if (tty->TS_set_scroll_region) | 253 | if (tty->TS_set_scroll_region) |
| 265 | buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1); | 254 | buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1, 0, 0); |
| 266 | else if (tty->TS_set_scroll_region_1) | 255 | else if (tty->TS_set_scroll_region_1) |
| 267 | buf = tparam (tty->TS_set_scroll_region_1, 0, 0, | 256 | buf = tparam (tty->TS_set_scroll_region_1, 0, 0, |
| 268 | FRAME_LINES (f), start, | 257 | FRAME_LINES (f), start, |
| @@ -859,7 +848,7 @@ tty_insert_glyphs (struct frame *f, struct glyph *start, int len) | |||
| 859 | 848 | ||
| 860 | if (tty->TS_ins_multi_chars) | 849 | if (tty->TS_ins_multi_chars) |
| 861 | { | 850 | { |
| 862 | buf = tparam (tty->TS_ins_multi_chars, 0, 0, len); | 851 | buf = tparam (tty->TS_ins_multi_chars, 0, 0, len, 0, 0, 0); |
| 863 | OUTPUT1 (tty, buf); | 852 | OUTPUT1 (tty, buf); |
| 864 | xfree (buf); | 853 | xfree (buf); |
| 865 | if (start) | 854 | if (start) |
| @@ -955,7 +944,7 @@ tty_delete_glyphs (struct frame *f, int n) | |||
| 955 | 944 | ||
| 956 | if (tty->TS_del_multi_chars) | 945 | if (tty->TS_del_multi_chars) |
| 957 | { | 946 | { |
| 958 | buf = tparam (tty->TS_del_multi_chars, 0, 0, n); | 947 | buf = tparam (tty->TS_del_multi_chars, 0, 0, n, 0, 0, 0); |
| 959 | OUTPUT1 (tty, buf); | 948 | OUTPUT1 (tty, buf); |
| 960 | xfree (buf); | 949 | xfree (buf); |
| 961 | } | 950 | } |
| @@ -997,7 +986,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n) | |||
| 997 | { | 986 | { |
| 998 | raw_cursor_to (f, vpos, 0); | 987 | raw_cursor_to (f, vpos, 0); |
| 999 | tty_background_highlight (tty); | 988 | tty_background_highlight (tty); |
| 1000 | buf = tparam (multi, 0, 0, i); | 989 | buf = tparam (multi, 0, 0, i, 0, 0, 0); |
| 1001 | OUTPUT (tty, buf); | 990 | OUTPUT (tty, buf); |
| 1002 | xfree (buf); | 991 | xfree (buf); |
| 1003 | } | 992 | } |
| @@ -2125,7 +2114,7 @@ turn_on_face (struct frame *f, int face_id) | |||
| 2125 | ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; | 2114 | ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; |
| 2126 | if (fg >= 0 && ts) | 2115 | if (fg >= 0 && ts) |
| 2127 | { | 2116 | { |
| 2128 | p = tparam (ts, NULL, 0, (int) fg); | 2117 | p = tparam (ts, NULL, 0, (int) fg, 0, 0, 0); |
| 2129 | OUTPUT (tty, p); | 2118 | OUTPUT (tty, p); |
| 2130 | xfree (p); | 2119 | xfree (p); |
| 2131 | } | 2120 | } |
| @@ -2133,7 +2122,7 @@ turn_on_face (struct frame *f, int face_id) | |||
| 2133 | ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; | 2122 | ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; |
| 2134 | if (bg >= 0 && ts) | 2123 | if (bg >= 0 && ts) |
| 2135 | { | 2124 | { |
| 2136 | p = tparam (ts, NULL, 0, (int) bg); | 2125 | p = tparam (ts, NULL, 0, (int) bg, 0, 0, 0); |
| 2137 | OUTPUT (tty, p); | 2126 | OUTPUT (tty, p); |
| 2138 | xfree (p); | 2127 | xfree (p); |
| 2139 | } | 2128 | } |
diff --git a/src/tparam.c b/src/tparam.c index fcbb63881e6..6aae0b97db9 100644 --- a/src/tparam.c +++ b/src/tparam.c | |||
| @@ -21,6 +21,7 @@ Boston, MA 02110-1301, USA. */ | |||
| 21 | #include <config.h> | 21 | #include <config.h> |
| 22 | #include <setjmp.h> | 22 | #include <setjmp.h> |
| 23 | #include "lisp.h" /* for xmalloc */ | 23 | #include "lisp.h" /* for xmalloc */ |
| 24 | #include "tparam.h" | ||
| 24 | 25 | ||
| 25 | #ifndef NULL | 26 | #ifndef NULL |
| 26 | #define NULL (char *) 0 | 27 | #define NULL (char *) 0 |
| @@ -38,11 +39,12 @@ Boston, MA 02110-1301, USA. */ | |||
| 38 | 39 | ||
| 39 | The fourth and following args to tparam serve as the parameter values. */ | 40 | The fourth and following args to tparam serve as the parameter values. */ |
| 40 | 41 | ||
| 41 | static char *tparam1 (char *string, char *outstring, int len, char *up, char *left, register int *argp); | 42 | static char *tparam1 (char const *string, char *outstring, int len, |
| 43 | char *up, char *left, int *argp); | ||
| 42 | 44 | ||
| 43 | /* VARARGS 2 */ | ||
| 44 | char * | 45 | char * |
| 45 | tparam (char *string, char *outstring, int len, int arg0, int arg1, int arg2, int arg3) | 46 | tparam (const char *string, char *outstring, int len, |
| 47 | int arg0, int arg1, int arg2, int arg3) | ||
| 46 | { | 48 | { |
| 47 | int arg[4]; | 49 | int arg[4]; |
| 48 | 50 | ||
| @@ -59,7 +61,7 @@ char *UP; | |||
| 59 | static char tgoto_buf[50]; | 61 | static char tgoto_buf[50]; |
| 60 | 62 | ||
| 61 | char * | 63 | char * |
| 62 | tgoto (char *cm, int hpos, int vpos) | 64 | tgoto (const char *cm, int hpos, int vpos) |
| 63 | { | 65 | { |
| 64 | int args[2]; | 66 | int args[2]; |
| 65 | if (!cm) | 67 | if (!cm) |
| @@ -70,10 +72,11 @@ tgoto (char *cm, int hpos, int vpos) | |||
| 70 | } | 72 | } |
| 71 | 73 | ||
| 72 | static char * | 74 | static char * |
| 73 | tparam1 (char *string, char *outstring, int len, char *up, char *left, register int *argp) | 75 | tparam1 (const char *string, char *outstring, int len, |
| 76 | char *up, char *left, register int *argp) | ||
| 74 | { | 77 | { |
| 75 | register int c; | 78 | register int c; |
| 76 | register char *p = string; | 79 | register const char *p = string; |
| 77 | register char *op = outstring; | 80 | register char *op = outstring; |
| 78 | char *outend; | 81 | char *outend; |
| 79 | int outlen = 0; | 82 | int outlen = 0; |
| @@ -277,4 +280,3 @@ main (argc, argv) | |||
| 277 | } | 280 | } |
| 278 | 281 | ||
| 279 | #endif /* DEBUG */ | 282 | #endif /* DEBUG */ |
| 280 | |||
diff --git a/src/tparam.h b/src/tparam.h new file mode 100644 index 00000000000..11c9ae68aad --- /dev/null +++ b/src/tparam.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | /* Interface definitions for termcap entries. | ||
| 2 | |||
| 3 | Copyright (C) 2011 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | |||
| 21 | /* Don't try to include termcap.h. On some systems, configure finds a | ||
| 22 | non-standard termcap.h that the main build won't find. */ | ||
| 23 | |||
| 24 | void tputs (const char *, int, int (*) (int)); | ||
| 25 | int tgetent (char *, const char *); | ||
| 26 | int tgetflag (char *id); | ||
| 27 | int tgetnum (char *id); | ||
| 28 | char *tgetstr (char *, char **); | ||
| 29 | char *tgoto (const char *, int, int); | ||
| 30 | |||
| 31 | char *tparam (const char *, char *, int, int, int, int, int); | ||