diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2013-07-10 19:17:47 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2013-07-10 19:17:47 -0700 |
commit | 653d4f43a7280d8fb84173be37b0c4c518cf7a88 (patch) | |
tree | d6d744fca51f03d46fabc65a85e3f1bc84f3f23d /src/termcap.c | |
parent | d77974bfcacb720419e6fcbe3d6f5c37c5a790d6 (diff) | |
download | emacs-653d4f43a7280d8fb84173be37b0c4c518cf7a88.tar.gz |
* sysdep.c, term.c, termcap.c, terminal.c: Integer-related minor fixes.
* sysdep.c (emacs_get_tty): Return void, since nobody uses the value.
(emacs_set_tty): Now static.
* sysdep.c (emacs_set_tty, tabs_safe_p, emacs_close):
* term.c (tty_capable_p, tty_default_color_capabilities)
(get_tty_terminal, term_mouse_movement)
(handle_one_term_event, init_tty, maybe_fatal):
* termcap.c (tgetst1, struct termcap_buffer, valid_filename_p)
(tgetent, scan_file, name_match, compare_contin):
* terminal.c (get_terminal):
Use bool for boolean.
* sysdep.c (init_system_name): Don't overflow stack on huge hostname.
Prefer char to unsigned char if either will do.
* term.c (OUTPUT, turn_on_face): Omit unnecessary casts to int.
(tty_write_glyphs): Prefer int to unsigned.
(produce_glyphless_glyph): Remove 2nd (unused) int arg.
All callers changed.
* termcap.c (tprint, main) [TEST]: Remove non-working test.
Diffstat (limited to 'src/termcap.c')
-rw-r--r-- | src/termcap.c | 104 |
1 files changed, 25 insertions, 79 deletions
diff --git a/src/termcap.c b/src/termcap.c index 7256eef9e81..5f731077463 100644 --- a/src/termcap.c +++ b/src/termcap.c @@ -213,8 +213,8 @@ tgetst1 (char *ptr, char **area) abbreviation expansion makes that effort a little more hairy than its worth; this is cleaner. */ { - register int last_p_param = 0; - int remove_p_params = 1; + int last_p_param = 0; + bool remove_p_params = 1; struct { char *beg; int len; } cut[11]; for (cut[0].beg = p = ret; p < r - 3; p++) @@ -318,26 +318,26 @@ struct termcap_buffer char *beg; ptrdiff_t size; char *ptr; - int ateof; + bool ateof; ptrdiff_t full; }; /* Forward declarations of static functions. */ -static int scan_file (char *str, int fd, register struct termcap_buffer *bufp); -static char *gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end); -static int compare_contin (register char *str1, register char *str2); -static int name_match (char *line, char *name); +static bool scan_file (char *, int, struct termcap_buffer *); +static char *gobble_line (int, struct termcap_buffer *, char *); +static bool compare_contin (char *, char *); +static bool name_match (char *, char *); -#ifdef MSDOS /* MW, May 1993 */ -static int +static bool valid_filename_p (char *fn) { +#ifdef MSDOS return *fn == '/' || fn[1] == ':'; -} #else -#define valid_filename_p(fn) (*(fn) == '/') + return *fn == '/'; #endif +} /* Find the termcap entry data for terminal type NAME and store it in the block that BP points to. @@ -360,10 +360,10 @@ tgetent (char *bp, const char *name) char *tc_search_point; char *term; ptrdiff_t malloc_size = 0; - register int c; + int c; char *tcenv = NULL; /* TERMCAP value, if it contains :tc=. */ char *indirect = NULL; /* Terminal type in :tc= in TERMCAP value. */ - int filep; + bool filep; #ifdef INTERNAL_TERMINAL /* For the internal terminal we don't want to read any termcap file, @@ -510,10 +510,10 @@ tgetent (char *bp, const char *name) Return 1 if successful, with that line in BUFP, or 0 if no entry is found in the file. */ -static int -scan_file (char *str, int fd, register struct termcap_buffer *bufp) +static bool +scan_file (char *str, int fd, struct termcap_buffer *bufp) { - register char *end; + char *end; bufp->ptr = bufp->beg; bufp->full = 0; @@ -544,13 +544,13 @@ scan_file (char *str, int fd, register struct termcap_buffer *bufp) return 0; } -/* Return nonzero if NAME is one of the names specified +/* Return true if NAME is one of the names specified by termcap entry LINE. */ -static int +static bool name_match (char *line, char *name) { - register char *tem; + char *tem; if (!compare_contin (line, name)) return 1; @@ -562,18 +562,18 @@ name_match (char *line, char *name) return 0; } -static int -compare_contin (register char *str1, register char *str2) +static bool +compare_contin (char *str1, char *str2) { - register int c1, c2; while (1) { - c1 = *str1++; - c2 = *str2++; + int c1 = *str1++; + int c2 = *str2++; while (c1 == '\\' && *str1 == '\n') { str1++; - while ((c1 = *str1++) == ' ' || c1 == '\t'); + while ((c1 = *str1++) == ' ' || c1 == '\t') + continue; } if (c2 == '\0') { @@ -647,57 +647,3 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end) } return end + 1; } - -#ifdef TEST - -#include <stdio.h> - -static void -tprint (char *cap) -{ - char *x = tgetstr (cap, 0); - register char *y; - - printf ("%s: ", cap); - if (x) - { - for (y = x; *y; y++) - if (*y <= ' ' || *y == 0177) - printf ("\\%0o", *y); - else - putchar (*y); - free (x); - } - else - printf ("none"); - putchar ('\n'); -} - -int -main (int argc, char **argv) -{ - char *term; - char *buf; - - term = argv[1]; - printf ("TERM: %s\n", term); - - buf = (char *) tgetent (0, term); - if ((int) buf <= 0) - { - printf ("No entry.\n"); - return 0; - } - - printf ("Entry: %s\n", buf); - - tprint ("cm"); - tprint ("AL"); - - printf ("co: %d\n", tgetnum ("co")); - printf ("am: %d\n", tgetflag ("am")); - - return 0; -} - -#endif /* TEST */ |