diff options
| author | Paul Eggert | 2013-07-10 19:17:47 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-07-10 19:17:47 -0700 |
| commit | 653d4f43a7280d8fb84173be37b0c4c518cf7a88 (patch) | |
| tree | d6d744fca51f03d46fabc65a85e3f1bc84f3f23d /src | |
| parent | d77974bfcacb720419e6fcbe3d6f5c37c5a790d6 (diff) | |
| download | emacs-653d4f43a7280d8fb84173be37b0c4c518cf7a88.tar.gz emacs-653d4f43a7280d8fb84173be37b0c4c518cf7a88.zip | |
* 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')
| -rw-r--r-- | src/ChangeLog | 21 | ||||
| -rw-r--r-- | src/dispextern.h | 7 | ||||
| -rw-r--r-- | src/sysdep.c | 56 | ||||
| -rw-r--r-- | src/term.c | 47 | ||||
| -rw-r--r-- | src/termcap.c | 104 | ||||
| -rw-r--r-- | src/termhooks.h | 2 | ||||
| -rw-r--r-- | src/terminal.c | 4 |
7 files changed, 105 insertions, 136 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1231c1adc14..cd109c17f18 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,24 @@ | |||
| 1 | 2013-07-11 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * sysdep.c, term.c, termcap.c, terminal.c: Integer-related minor fixes. | ||
| 4 | * sysdep.c (emacs_get_tty): Return void, since nobody uses the value. | ||
| 5 | (emacs_set_tty): Now static. | ||
| 6 | * sysdep.c (emacs_set_tty, tabs_safe_p, emacs_close): | ||
| 7 | * term.c (tty_capable_p, tty_default_color_capabilities) | ||
| 8 | (get_tty_terminal, term_mouse_movement) | ||
| 9 | (handle_one_term_event, init_tty, maybe_fatal): | ||
| 10 | * termcap.c (tgetst1, struct termcap_buffer, valid_filename_p) | ||
| 11 | (tgetent, scan_file, name_match, compare_contin): | ||
| 12 | * terminal.c (get_terminal): | ||
| 13 | Use bool for boolean. | ||
| 14 | * sysdep.c (init_system_name): Don't overflow stack on huge hostname. | ||
| 15 | Prefer char to unsigned char if either will do. | ||
| 16 | * term.c (OUTPUT, turn_on_face): Omit unnecessary casts to int. | ||
| 17 | (tty_write_glyphs): Prefer int to unsigned. | ||
| 18 | (produce_glyphless_glyph): Remove 2nd (unused) int arg. | ||
| 19 | All callers changed. | ||
| 20 | * termcap.c (tprint, main) [TEST]: Remove non-working test. | ||
| 21 | |||
| 1 | 2013-07-10 Paul Eggert <eggert@cs.ucla.edu> | 22 | 2013-07-10 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 23 | ||
| 3 | Port to C89. | 24 | Port to C89. |
diff --git a/src/dispextern.h b/src/dispextern.h index 1dd96c6638d..e0d04231d3a 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -3298,7 +3298,7 @@ int image_ascent (struct image *, struct face *, struct glyph_slice *); | |||
| 3298 | void get_tty_size (int, int *, int *); | 3298 | void get_tty_size (int, int *, int *); |
| 3299 | void request_sigio (void); | 3299 | void request_sigio (void); |
| 3300 | void unrequest_sigio (void); | 3300 | void unrequest_sigio (void); |
| 3301 | int tabs_safe_p (int); | 3301 | bool tabs_safe_p (int); |
| 3302 | void init_baud_rate (int); | 3302 | void init_baud_rate (int); |
| 3303 | void init_sigio (int); | 3303 | void init_sigio (int); |
| 3304 | void ignore_sigio (void); | 3304 | void ignore_sigio (void); |
| @@ -3470,11 +3470,12 @@ extern int string_cost (const char *); | |||
| 3470 | extern int per_line_cost (const char *); | 3470 | extern int per_line_cost (const char *); |
| 3471 | extern void calculate_costs (struct frame *); | 3471 | extern void calculate_costs (struct frame *); |
| 3472 | extern void produce_glyphs (struct it *); | 3472 | extern void produce_glyphs (struct it *); |
| 3473 | extern int tty_capable_p (struct tty_display_info *, unsigned, unsigned long, unsigned long); | 3473 | extern bool tty_capable_p (struct tty_display_info *, unsigned, |
| 3474 | unsigned long, unsigned long); | ||
| 3474 | extern void set_tty_color_mode (struct tty_display_info *, struct frame *); | 3475 | extern void set_tty_color_mode (struct tty_display_info *, struct frame *); |
| 3475 | extern struct terminal *get_named_tty (const char *); | 3476 | extern struct terminal *get_named_tty (const char *); |
| 3476 | extern void create_tty_output (struct frame *); | 3477 | extern void create_tty_output (struct frame *); |
| 3477 | extern struct terminal *init_tty (const char *, const char *, int); | 3478 | extern struct terminal *init_tty (const char *, const char *, bool); |
| 3478 | extern void tty_append_glyph (struct it *); | 3479 | extern void tty_append_glyph (struct it *); |
| 3479 | 3480 | ||
| 3480 | 3481 | ||
diff --git a/src/sysdep.c b/src/sysdep.c index 2f86b1f8bd5..653cf22b078 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -102,8 +102,8 @@ int _cdecl _getpid (void); | |||
| 102 | #include "syssignal.h" | 102 | #include "syssignal.h" |
| 103 | #include "systime.h" | 103 | #include "systime.h" |
| 104 | 104 | ||
| 105 | static int emacs_get_tty (int, struct emacs_tty *); | 105 | static void emacs_get_tty (int, struct emacs_tty *); |
| 106 | static int emacs_set_tty (int, struct emacs_tty *, int); | 106 | static int emacs_set_tty (int, struct emacs_tty *, bool); |
| 107 | 107 | ||
| 108 | /* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ | 108 | /* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ |
| 109 | #ifndef ULLONG_MAX | 109 | #ifndef ULLONG_MAX |
| @@ -769,31 +769,26 @@ widen_foreground_group (int fd) | |||
| 769 | 769 | ||
| 770 | /* Getting and setting emacs_tty structures. */ | 770 | /* Getting and setting emacs_tty structures. */ |
| 771 | 771 | ||
| 772 | /* Set *TC to the parameters associated with the terminal FD. | 772 | /* Set *TC to the parameters associated with the terminal FD, |
| 773 | Return zero if all's well, or -1 if we ran into an error we | 773 | or clear it if the parameters are not available. */ |
| 774 | couldn't deal with. */ | 774 | static void |
| 775 | int | ||
| 776 | emacs_get_tty (int fd, struct emacs_tty *settings) | 775 | emacs_get_tty (int fd, struct emacs_tty *settings) |
| 777 | { | 776 | { |
| 778 | /* Retrieve the primary parameters - baud rate, character size, etcetera. */ | 777 | /* Retrieve the primary parameters - baud rate, character size, etcetera. */ |
| 779 | #ifndef DOS_NT | 778 | #ifndef DOS_NT |
| 780 | /* We have those nifty POSIX tcmumbleattr functions. */ | 779 | /* We have those nifty POSIX tcmumbleattr functions. */ |
| 781 | memset (&settings->main, 0, sizeof (settings->main)); | 780 | memset (&settings->main, 0, sizeof (settings->main)); |
| 782 | if (tcgetattr (fd, &settings->main) < 0) | 781 | tcgetattr (fd, &settings->main); |
| 783 | return -1; | ||
| 784 | #endif | 782 | #endif |
| 785 | |||
| 786 | /* We have survived the tempest. */ | ||
| 787 | return 0; | ||
| 788 | } | 783 | } |
| 789 | 784 | ||
| 790 | 785 | ||
| 791 | /* Set the parameters of the tty on FD according to the contents of | 786 | /* Set the parameters of the tty on FD according to the contents of |
| 792 | *SETTINGS. If FLUSHP is non-zero, we discard input. | 787 | *SETTINGS. If FLUSHP, discard input. |
| 793 | Return 0 if all went well, and -1 if anything failed. */ | 788 | Return 0 if all went well, and -1 (setting errno) if anything failed. */ |
| 794 | 789 | ||
| 795 | int | 790 | static int |
| 796 | emacs_set_tty (int fd, struct emacs_tty *settings, int flushp) | 791 | emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp) |
| 797 | { | 792 | { |
| 798 | /* Set the primary parameters - baud rate, character size, etcetera. */ | 793 | /* Set the primary parameters - baud rate, character size, etcetera. */ |
| 799 | #ifndef DOS_NT | 794 | #ifndef DOS_NT |
| @@ -1118,10 +1113,10 @@ init_sys_modes (struct tty_display_info *tty_out) | |||
| 1118 | tty_out->term_initted = 1; | 1113 | tty_out->term_initted = 1; |
| 1119 | } | 1114 | } |
| 1120 | 1115 | ||
| 1121 | /* Return nonzero if safe to use tabs in output. | 1116 | /* Return true if safe to use tabs in output. |
| 1122 | At the time this is called, init_sys_modes has not been done yet. */ | 1117 | At the time this is called, init_sys_modes has not been done yet. */ |
| 1123 | 1118 | ||
| 1124 | int | 1119 | bool |
| 1125 | tabs_safe_p (int fd) | 1120 | tabs_safe_p (int fd) |
| 1126 | { | 1121 | { |
| 1127 | struct emacs_tty etty; | 1122 | struct emacs_tty etty; |
| @@ -1375,8 +1370,10 @@ init_system_name (void) | |||
| 1375 | uname (&uts); | 1370 | uname (&uts); |
| 1376 | Vsystem_name = build_string (uts.nodename); | 1371 | Vsystem_name = build_string (uts.nodename); |
| 1377 | #else /* HAVE_GETHOSTNAME */ | 1372 | #else /* HAVE_GETHOSTNAME */ |
| 1378 | unsigned int hostname_size = 256; | 1373 | char *hostname_alloc = NULL; |
| 1379 | char *hostname = alloca (hostname_size); | 1374 | char hostname_buf[256]; |
| 1375 | ptrdiff_t hostname_size = sizeof hostname_buf; | ||
| 1376 | char *hostname = hostname_buf; | ||
| 1380 | 1377 | ||
| 1381 | /* Try to get the host name; if the buffer is too short, try | 1378 | /* Try to get the host name; if the buffer is too short, try |
| 1382 | again. Apparently, the only indication gethostname gives of | 1379 | again. Apparently, the only indication gethostname gives of |
| @@ -1391,8 +1388,8 @@ init_system_name (void) | |||
| 1391 | if (strlen (hostname) < hostname_size - 1) | 1388 | if (strlen (hostname) < hostname_size - 1) |
| 1392 | break; | 1389 | break; |
| 1393 | 1390 | ||
| 1394 | hostname_size <<= 1; | 1391 | hostname = hostname_alloc = xpalloc (hostname_alloc, &hostname_size, 1, |
| 1395 | hostname = alloca (hostname_size); | 1392 | min (PTRDIFF_MAX, SIZE_MAX), 1); |
| 1396 | } | 1393 | } |
| 1397 | #ifdef HAVE_SOCKETS | 1394 | #ifdef HAVE_SOCKETS |
| 1398 | /* Turn the hostname into the official, fully-qualified hostname. | 1395 | /* Turn the hostname into the official, fully-qualified hostname. |
| @@ -1437,7 +1434,13 @@ init_system_name (void) | |||
| 1437 | } | 1434 | } |
| 1438 | if (it) | 1435 | if (it) |
| 1439 | { | 1436 | { |
| 1440 | hostname = alloca (strlen (it->ai_canonname) + 1); | 1437 | ptrdiff_t len = strlen (it->ai_canonname); |
| 1438 | if (hostname_size <= len) | ||
| 1439 | { | ||
| 1440 | hostname_size = len + 1; | ||
| 1441 | hostname = hostname_alloc = xrealloc (hostname_alloc, | ||
| 1442 | hostname_size); | ||
| 1443 | } | ||
| 1441 | strcpy (hostname, it->ai_canonname); | 1444 | strcpy (hostname, it->ai_canonname); |
| 1442 | } | 1445 | } |
| 1443 | freeaddrinfo (res); | 1446 | freeaddrinfo (res); |
| @@ -1484,10 +1487,11 @@ init_system_name (void) | |||
| 1484 | } | 1487 | } |
| 1485 | #endif /* HAVE_SOCKETS */ | 1488 | #endif /* HAVE_SOCKETS */ |
| 1486 | Vsystem_name = build_string (hostname); | 1489 | Vsystem_name = build_string (hostname); |
| 1490 | xfree (hostname_alloc); | ||
| 1487 | #endif /* HAVE_GETHOSTNAME */ | 1491 | #endif /* HAVE_GETHOSTNAME */ |
| 1488 | { | 1492 | { |
| 1489 | unsigned char *p; | 1493 | char *p; |
| 1490 | for (p = SDATA (Vsystem_name); *p; p++) | 1494 | for (p = SSDATA (Vsystem_name); *p; p++) |
| 1491 | if (*p == ' ' || *p == '\t') | 1495 | if (*p == ' ' || *p == '\t') |
| 1492 | *p = '-'; | 1496 | *p = '-'; |
| 1493 | } | 1497 | } |
| @@ -2200,8 +2204,8 @@ emacs_fopen (char const *file, char const *mode) | |||
| 2200 | int | 2204 | int |
| 2201 | emacs_close (int fd) | 2205 | emacs_close (int fd) |
| 2202 | { | 2206 | { |
| 2203 | int did_retry = 0; | 2207 | bool did_retry = 0; |
| 2204 | register int rtnval; | 2208 | int rtnval; |
| 2205 | 2209 | ||
| 2206 | while ((rtnval = close (fd)) == -1 | 2210 | while ((rtnval = close (fd)) == -1 |
| 2207 | && (errno == EINTR)) | 2211 | && (errno == EINTR)) |
diff --git a/src/term.c b/src/term.c index 39d143564c6..00a3f6837ee 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -71,13 +71,13 @@ static void tty_turn_off_highlight (struct tty_display_info *); | |||
| 71 | static void tty_show_cursor (struct tty_display_info *); | 71 | static void tty_show_cursor (struct tty_display_info *); |
| 72 | static void tty_hide_cursor (struct tty_display_info *); | 72 | static void tty_hide_cursor (struct tty_display_info *); |
| 73 | static void tty_background_highlight (struct tty_display_info *tty); | 73 | static void tty_background_highlight (struct tty_display_info *tty); |
| 74 | static struct terminal *get_tty_terminal (Lisp_Object, int); | 74 | static struct terminal *get_tty_terminal (Lisp_Object, bool); |
| 75 | static void clear_tty_hooks (struct terminal *terminal); | 75 | static void clear_tty_hooks (struct terminal *terminal); |
| 76 | static void set_tty_hooks (struct terminal *terminal); | 76 | static void set_tty_hooks (struct terminal *terminal); |
| 77 | static void dissociate_if_controlling_tty (int fd); | 77 | static void dissociate_if_controlling_tty (int fd); |
| 78 | static void delete_tty (struct terminal *); | 78 | static void delete_tty (struct terminal *); |
| 79 | static _Noreturn void maybe_fatal (int must_succeed, struct terminal *terminal, | 79 | static _Noreturn void maybe_fatal (bool, struct terminal *, |
| 80 | const char *str1, const char *str2, ...) | 80 | const char *, const char *, ...) |
| 81 | ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5); | 81 | ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5); |
| 82 | static _Noreturn void vfatal (const char *str, va_list ap) | 82 | static _Noreturn void vfatal (const char *str, va_list ap) |
| 83 | ATTRIBUTE_FORMAT_PRINTF (1, 0); | 83 | ATTRIBUTE_FORMAT_PRINTF (1, 0); |
| @@ -85,8 +85,7 @@ static _Noreturn void vfatal (const char *str, va_list ap) | |||
| 85 | 85 | ||
| 86 | #define OUTPUT(tty, a) \ | 86 | #define OUTPUT(tty, a) \ |
| 87 | emacs_tputs ((tty), a, \ | 87 | emacs_tputs ((tty), a, \ |
| 88 | (int) (FRAME_LINES (XFRAME (selected_frame)) \ | 88 | FRAME_LINES (XFRAME (selected_frame)) - curY (tty), \ |
| 89 | - curY (tty)), \ | ||
| 90 | cmputc) | 89 | cmputc) |
| 91 | 90 | ||
| 92 | #define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc) | 91 | #define OUTPUT1(tty, a) emacs_tputs ((tty), a, 1, cmputc) |
| @@ -695,7 +694,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) | |||
| 695 | { | 694 | { |
| 696 | unsigned char *conversion_buffer; | 695 | unsigned char *conversion_buffer; |
| 697 | struct coding_system *coding; | 696 | struct coding_system *coding; |
| 698 | size_t n, stringlen; | 697 | int n, stringlen; |
| 699 | 698 | ||
| 700 | struct tty_display_info *tty = FRAME_TTY (f); | 699 | struct tty_display_info *tty = FRAME_TTY (f); |
| 701 | 700 | ||
| @@ -1431,7 +1430,7 @@ static void append_glyph (struct it *); | |||
| 1431 | static void append_composite_glyph (struct it *); | 1430 | static void append_composite_glyph (struct it *); |
| 1432 | static void produce_composite_glyph (struct it *); | 1431 | static void produce_composite_glyph (struct it *); |
| 1433 | static void append_glyphless_glyph (struct it *, int, const char *); | 1432 | static void append_glyphless_glyph (struct it *, int, const char *); |
| 1434 | static void produce_glyphless_glyph (struct it *, int, Lisp_Object); | 1433 | static void produce_glyphless_glyph (struct it *, Lisp_Object); |
| 1435 | 1434 | ||
| 1436 | /* Append glyphs to IT's glyph_row. Called from produce_glyphs for | 1435 | /* Append glyphs to IT's glyph_row. Called from produce_glyphs for |
| 1437 | terminal frames if IT->glyph_row != NULL. IT->char_to_display is | 1436 | terminal frames if IT->glyph_row != NULL. IT->char_to_display is |
| @@ -1551,7 +1550,7 @@ produce_glyphs (struct it *it) | |||
| 1551 | 1550 | ||
| 1552 | if (it->what == IT_GLYPHLESS) | 1551 | if (it->what == IT_GLYPHLESS) |
| 1553 | { | 1552 | { |
| 1554 | produce_glyphless_glyph (it, 0, Qnil); | 1553 | produce_glyphless_glyph (it, Qnil); |
| 1555 | goto done; | 1554 | goto done; |
| 1556 | } | 1555 | } |
| 1557 | 1556 | ||
| @@ -1620,7 +1619,7 @@ produce_glyphs (struct it *it) | |||
| 1620 | Lisp_Object acronym = lookup_glyphless_char_display (-1, it); | 1619 | Lisp_Object acronym = lookup_glyphless_char_display (-1, it); |
| 1621 | 1620 | ||
| 1622 | eassert (it->what == IT_GLYPHLESS); | 1621 | eassert (it->what == IT_GLYPHLESS); |
| 1623 | produce_glyphless_glyph (it, 1, acronym); | 1622 | produce_glyphless_glyph (it, acronym); |
| 1624 | } | 1623 | } |
| 1625 | } | 1624 | } |
| 1626 | 1625 | ||
| @@ -1794,14 +1793,12 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str) | |||
| 1794 | the character. See the description of enum | 1793 | the character. See the description of enum |
| 1795 | glyphless_display_method in dispextern.h for the details. | 1794 | glyphless_display_method in dispextern.h for the details. |
| 1796 | 1795 | ||
| 1797 | FOR_NO_FONT is nonzero if and only if this is for a character that | 1796 | ACRONYM, if non-nil, is an acronym string for the character. |
| 1798 | is not supported by the coding system of the terminal. ACRONYM, if | ||
| 1799 | non-nil, is an acronym string for the character. | ||
| 1800 | 1797 | ||
| 1801 | The glyphs actually produced are of type CHAR_GLYPH. */ | 1798 | The glyphs actually produced are of type CHAR_GLYPH. */ |
| 1802 | 1799 | ||
| 1803 | static void | 1800 | static void |
| 1804 | produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) | 1801 | produce_glyphless_glyph (struct it *it, Lisp_Object acronym) |
| 1805 | { | 1802 | { |
| 1806 | int face_id; | 1803 | int face_id; |
| 1807 | int len; | 1804 | int len; |
| @@ -1968,7 +1965,7 @@ turn_on_face (struct frame *f, int face_id) | |||
| 1968 | ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; | 1965 | ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground; |
| 1969 | if (fg >= 0 && ts) | 1966 | if (fg >= 0 && ts) |
| 1970 | { | 1967 | { |
| 1971 | p = tparam (ts, NULL, 0, (int) fg, 0, 0, 0); | 1968 | p = tparam (ts, NULL, 0, fg, 0, 0, 0); |
| 1972 | OUTPUT (tty, p); | 1969 | OUTPUT (tty, p); |
| 1973 | xfree (p); | 1970 | xfree (p); |
| 1974 | } | 1971 | } |
| @@ -1976,7 +1973,7 @@ turn_on_face (struct frame *f, int face_id) | |||
| 1976 | ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; | 1973 | ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background; |
| 1977 | if (bg >= 0 && ts) | 1974 | if (bg >= 0 && ts) |
| 1978 | { | 1975 | { |
| 1979 | p = tparam (ts, NULL, 0, (int) bg, 0, 0, 0); | 1976 | p = tparam (ts, NULL, 0, bg, 0, 0, 0); |
| 1980 | OUTPUT (tty, p); | 1977 | OUTPUT (tty, p); |
| 1981 | xfree (p); | 1978 | xfree (p); |
| 1982 | } | 1979 | } |
| @@ -2027,11 +2024,11 @@ turn_off_face (struct frame *f, int face_id) | |||
| 2027 | } | 2024 | } |
| 2028 | 2025 | ||
| 2029 | 2026 | ||
| 2030 | /* Return non-zero if the terminal on frame F supports all of the | 2027 | /* Return true if the terminal on frame F supports all of the |
| 2031 | capabilities in CAPS simultaneously, with foreground and background | 2028 | capabilities in CAPS simultaneously, with foreground and background |
| 2032 | colors FG and BG. */ | 2029 | colors FG and BG. */ |
| 2033 | 2030 | ||
| 2034 | int | 2031 | bool |
| 2035 | tty_capable_p (struct tty_display_info *tty, unsigned int caps, | 2032 | tty_capable_p (struct tty_display_info *tty, unsigned int caps, |
| 2036 | unsigned long fg, unsigned long bg) | 2033 | unsigned long fg, unsigned long bg) |
| 2037 | { | 2034 | { |
| @@ -2099,7 +2096,7 @@ static char *default_set_background; | |||
| 2099 | /* Save or restore the default color-related capabilities of this | 2096 | /* Save or restore the default color-related capabilities of this |
| 2100 | terminal. */ | 2097 | terminal. */ |
| 2101 | static void | 2098 | static void |
| 2102 | tty_default_color_capabilities (struct tty_display_info *tty, int save) | 2099 | tty_default_color_capabilities (struct tty_display_info *tty, bool save) |
| 2103 | { | 2100 | { |
| 2104 | 2101 | ||
| 2105 | if (save) | 2102 | if (save) |
| @@ -2209,7 +2206,7 @@ set_tty_color_mode (struct tty_display_info *tty, struct frame *f) | |||
| 2209 | /* Return the tty display object specified by TERMINAL. */ | 2206 | /* Return the tty display object specified by TERMINAL. */ |
| 2210 | 2207 | ||
| 2211 | static struct terminal * | 2208 | static struct terminal * |
| 2212 | get_tty_terminal (Lisp_Object terminal, int throw) | 2209 | get_tty_terminal (Lisp_Object terminal, bool throw) |
| 2213 | { | 2210 | { |
| 2214 | struct terminal *t = get_terminal (terminal, throw); | 2211 | struct terminal *t = get_terminal (terminal, throw); |
| 2215 | 2212 | ||
| @@ -2519,7 +2516,7 @@ tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row, | |||
| 2519 | cursor_to (f, save_y, save_x); | 2516 | cursor_to (f, save_y, save_x); |
| 2520 | } | 2517 | } |
| 2521 | 2518 | ||
| 2522 | static int | 2519 | static bool |
| 2523 | term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) | 2520 | term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) |
| 2524 | { | 2521 | { |
| 2525 | /* Has the mouse moved off the glyph it was on at the last sighting? */ | 2522 | /* Has the mouse moved off the glyph it was on at the last sighting? */ |
| @@ -2649,7 +2646,7 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event, struct in | |||
| 2649 | { | 2646 | { |
| 2650 | struct frame *f = XFRAME (tty->top_frame); | 2647 | struct frame *f = XFRAME (tty->top_frame); |
| 2651 | struct input_event ie; | 2648 | struct input_event ie; |
| 2652 | int do_help = 0; | 2649 | bool do_help = 0; |
| 2653 | int count = 0; | 2650 | int count = 0; |
| 2654 | 2651 | ||
| 2655 | EVENT_INIT (ie); | 2652 | EVENT_INIT (ie); |
| @@ -2934,7 +2931,7 @@ dissociate_if_controlling_tty (int fd) | |||
| 2934 | If MUST_SUCCEED is true, then all errors are fatal. */ | 2931 | If MUST_SUCCEED is true, then all errors are fatal. */ |
| 2935 | 2932 | ||
| 2936 | struct terminal * | 2933 | struct terminal * |
| 2937 | init_tty (const char *name, const char *terminal_type, int must_succeed) | 2934 | init_tty (const char *name, const char *terminal_type, bool must_succeed) |
| 2938 | { | 2935 | { |
| 2939 | char *area = NULL; | 2936 | char *area = NULL; |
| 2940 | char **address = &area; | 2937 | char **address = &area; |
| @@ -2942,7 +2939,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 2942 | int status; | 2939 | int status; |
| 2943 | struct tty_display_info *tty = NULL; | 2940 | struct tty_display_info *tty = NULL; |
| 2944 | struct terminal *terminal = NULL; | 2941 | struct terminal *terminal = NULL; |
| 2945 | int ctty = 0; /* 1 if asked to open controlling tty. */ | 2942 | bool ctty = 0; /* True if asked to open controlling tty. */ |
| 2946 | 2943 | ||
| 2947 | if (!terminal_type) | 2944 | if (!terminal_type) |
| 2948 | maybe_fatal (must_succeed, 0, | 2945 | maybe_fatal (must_succeed, 0, |
| @@ -3412,10 +3409,10 @@ vfatal (const char *str, va_list ap) | |||
| 3412 | 3409 | ||
| 3413 | /* Auxiliary error-handling function for init_tty. | 3410 | /* Auxiliary error-handling function for init_tty. |
| 3414 | Delete TERMINAL, then call error or fatal with str1 or str2, | 3411 | Delete TERMINAL, then call error or fatal with str1 or str2, |
| 3415 | respectively, according to whether MUST_SUCCEED is zero or not. */ | 3412 | respectively, according to whether MUST_SUCCEED is true. */ |
| 3416 | 3413 | ||
| 3417 | static void | 3414 | static void |
| 3418 | maybe_fatal (int must_succeed, struct terminal *terminal, | 3415 | maybe_fatal (bool must_succeed, struct terminal *terminal, |
| 3419 | const char *str1, const char *str2, ...) | 3416 | const char *str1, const char *str2, ...) |
| 3420 | { | 3417 | { |
| 3421 | va_list ap; | 3418 | va_list ap; |
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) | |||
| 213 | abbreviation expansion makes that effort a little more hairy than | 213 | abbreviation expansion makes that effort a little more hairy than |
| 214 | its worth; this is cleaner. */ | 214 | its worth; this is cleaner. */ |
| 215 | { | 215 | { |
| 216 | register int last_p_param = 0; | 216 | int last_p_param = 0; |
| 217 | int remove_p_params = 1; | 217 | bool remove_p_params = 1; |
| 218 | struct { char *beg; int len; } cut[11]; | 218 | struct { char *beg; int len; } cut[11]; |
| 219 | 219 | ||
| 220 | for (cut[0].beg = p = ret; p < r - 3; p++) | 220 | for (cut[0].beg = p = ret; p < r - 3; p++) |
| @@ -318,26 +318,26 @@ struct termcap_buffer | |||
| 318 | char *beg; | 318 | char *beg; |
| 319 | ptrdiff_t size; | 319 | ptrdiff_t size; |
| 320 | char *ptr; | 320 | char *ptr; |
| 321 | int ateof; | 321 | bool ateof; |
| 322 | ptrdiff_t full; | 322 | ptrdiff_t full; |
| 323 | }; | 323 | }; |
| 324 | 324 | ||
| 325 | /* Forward declarations of static functions. */ | 325 | /* Forward declarations of static functions. */ |
| 326 | 326 | ||
| 327 | static int scan_file (char *str, int fd, register struct termcap_buffer *bufp); | 327 | static bool scan_file (char *, int, struct termcap_buffer *); |
| 328 | static char *gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end); | 328 | static char *gobble_line (int, struct termcap_buffer *, char *); |
| 329 | static int compare_contin (register char *str1, register char *str2); | 329 | static bool compare_contin (char *, char *); |
| 330 | static int name_match (char *line, char *name); | 330 | static bool name_match (char *, char *); |
| 331 | 331 | ||
| 332 | #ifdef MSDOS /* MW, May 1993 */ | 332 | static bool |
| 333 | static int | ||
| 334 | valid_filename_p (char *fn) | 333 | valid_filename_p (char *fn) |
| 335 | { | 334 | { |
| 335 | #ifdef MSDOS | ||
| 336 | return *fn == '/' || fn[1] == ':'; | 336 | return *fn == '/' || fn[1] == ':'; |
| 337 | } | ||
| 338 | #else | 337 | #else |
| 339 | #define valid_filename_p(fn) (*(fn) == '/') | 338 | return *fn == '/'; |
| 340 | #endif | 339 | #endif |
| 340 | } | ||
| 341 | 341 | ||
| 342 | /* Find the termcap entry data for terminal type NAME | 342 | /* Find the termcap entry data for terminal type NAME |
| 343 | and store it in the block that BP points to. | 343 | and store it in the block that BP points to. |
| @@ -360,10 +360,10 @@ tgetent (char *bp, const char *name) | |||
| 360 | char *tc_search_point; | 360 | char *tc_search_point; |
| 361 | char *term; | 361 | char *term; |
| 362 | ptrdiff_t malloc_size = 0; | 362 | ptrdiff_t malloc_size = 0; |
| 363 | register int c; | 363 | int c; |
| 364 | char *tcenv = NULL; /* TERMCAP value, if it contains :tc=. */ | 364 | char *tcenv = NULL; /* TERMCAP value, if it contains :tc=. */ |
| 365 | char *indirect = NULL; /* Terminal type in :tc= in TERMCAP value. */ | 365 | char *indirect = NULL; /* Terminal type in :tc= in TERMCAP value. */ |
| 366 | int filep; | 366 | bool filep; |
| 367 | 367 | ||
| 368 | #ifdef INTERNAL_TERMINAL | 368 | #ifdef INTERNAL_TERMINAL |
| 369 | /* For the internal terminal we don't want to read any termcap file, | 369 | /* For the internal terminal we don't want to read any termcap file, |
| @@ -510,10 +510,10 @@ tgetent (char *bp, const char *name) | |||
| 510 | Return 1 if successful, with that line in BUFP, | 510 | Return 1 if successful, with that line in BUFP, |
| 511 | or 0 if no entry is found in the file. */ | 511 | or 0 if no entry is found in the file. */ |
| 512 | 512 | ||
| 513 | static int | 513 | static bool |
| 514 | scan_file (char *str, int fd, register struct termcap_buffer *bufp) | 514 | scan_file (char *str, int fd, struct termcap_buffer *bufp) |
| 515 | { | 515 | { |
| 516 | register char *end; | 516 | char *end; |
| 517 | 517 | ||
| 518 | bufp->ptr = bufp->beg; | 518 | bufp->ptr = bufp->beg; |
| 519 | bufp->full = 0; | 519 | bufp->full = 0; |
| @@ -544,13 +544,13 @@ scan_file (char *str, int fd, register struct termcap_buffer *bufp) | |||
| 544 | return 0; | 544 | return 0; |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | /* Return nonzero if NAME is one of the names specified | 547 | /* Return true if NAME is one of the names specified |
| 548 | by termcap entry LINE. */ | 548 | by termcap entry LINE. */ |
| 549 | 549 | ||
| 550 | static int | 550 | static bool |
| 551 | name_match (char *line, char *name) | 551 | name_match (char *line, char *name) |
| 552 | { | 552 | { |
| 553 | register char *tem; | 553 | char *tem; |
| 554 | 554 | ||
| 555 | if (!compare_contin (line, name)) | 555 | if (!compare_contin (line, name)) |
| 556 | return 1; | 556 | return 1; |
| @@ -562,18 +562,18 @@ name_match (char *line, char *name) | |||
| 562 | return 0; | 562 | return 0; |
| 563 | } | 563 | } |
| 564 | 564 | ||
| 565 | static int | 565 | static bool |
| 566 | compare_contin (register char *str1, register char *str2) | 566 | compare_contin (char *str1, char *str2) |
| 567 | { | 567 | { |
| 568 | register int c1, c2; | ||
| 569 | while (1) | 568 | while (1) |
| 570 | { | 569 | { |
| 571 | c1 = *str1++; | 570 | int c1 = *str1++; |
| 572 | c2 = *str2++; | 571 | int c2 = *str2++; |
| 573 | while (c1 == '\\' && *str1 == '\n') | 572 | while (c1 == '\\' && *str1 == '\n') |
| 574 | { | 573 | { |
| 575 | str1++; | 574 | str1++; |
| 576 | while ((c1 = *str1++) == ' ' || c1 == '\t'); | 575 | while ((c1 = *str1++) == ' ' || c1 == '\t') |
| 576 | continue; | ||
| 577 | } | 577 | } |
| 578 | if (c2 == '\0') | 578 | if (c2 == '\0') |
| 579 | { | 579 | { |
| @@ -647,57 +647,3 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end) | |||
| 647 | } | 647 | } |
| 648 | return end + 1; | 648 | return end + 1; |
| 649 | } | 649 | } |
| 650 | |||
| 651 | #ifdef TEST | ||
| 652 | |||
| 653 | #include <stdio.h> | ||
| 654 | |||
| 655 | static void | ||
| 656 | tprint (char *cap) | ||
| 657 | { | ||
| 658 | char *x = tgetstr (cap, 0); | ||
| 659 | register char *y; | ||
| 660 | |||
| 661 | printf ("%s: ", cap); | ||
| 662 | if (x) | ||
| 663 | { | ||
| 664 | for (y = x; *y; y++) | ||
| 665 | if (*y <= ' ' || *y == 0177) | ||
| 666 | printf ("\\%0o", *y); | ||
| 667 | else | ||
| 668 | putchar (*y); | ||
| 669 | free (x); | ||
| 670 | } | ||
| 671 | else | ||
| 672 | printf ("none"); | ||
| 673 | putchar ('\n'); | ||
| 674 | } | ||
| 675 | |||
| 676 | int | ||
| 677 | main (int argc, char **argv) | ||
| 678 | { | ||
| 679 | char *term; | ||
| 680 | char *buf; | ||
| 681 | |||
| 682 | term = argv[1]; | ||
| 683 | printf ("TERM: %s\n", term); | ||
| 684 | |||
| 685 | buf = (char *) tgetent (0, term); | ||
| 686 | if ((int) buf <= 0) | ||
| 687 | { | ||
| 688 | printf ("No entry.\n"); | ||
| 689 | return 0; | ||
| 690 | } | ||
| 691 | |||
| 692 | printf ("Entry: %s\n", buf); | ||
| 693 | |||
| 694 | tprint ("cm"); | ||
| 695 | tprint ("AL"); | ||
| 696 | |||
| 697 | printf ("co: %d\n", tgetnum ("co")); | ||
| 698 | printf ("am: %d\n", tgetflag ("am")); | ||
| 699 | |||
| 700 | return 0; | ||
| 701 | } | ||
| 702 | |||
| 703 | #endif /* TEST */ | ||
diff --git a/src/termhooks.h b/src/termhooks.h index 4f3fa9cb47f..0190478c254 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -643,7 +643,7 @@ extern struct terminal *terminal_list; | |||
| 643 | (((d)->type != output_termcap && (d)->type != output_msdos_raw) \ | 643 | (((d)->type != output_termcap && (d)->type != output_msdos_raw) \ |
| 644 | || (d)->display_info.tty->input) | 644 | || (d)->display_info.tty->input) |
| 645 | 645 | ||
| 646 | extern struct terminal *get_terminal (Lisp_Object terminal, int); | 646 | extern struct terminal *get_terminal (Lisp_Object terminal, bool); |
| 647 | extern struct terminal *create_terminal (void); | 647 | extern struct terminal *create_terminal (void); |
| 648 | extern void delete_terminal (struct terminal *); | 648 | extern void delete_terminal (struct terminal *); |
| 649 | 649 | ||
diff --git a/src/terminal.c b/src/terminal.c index c99c39c64ae..c55fd4eb077 100644 --- a/src/terminal.c +++ b/src/terminal.c | |||
| @@ -199,11 +199,11 @@ ins_del_lines (struct frame *f, int vpos, int n) | |||
| 199 | 199 | ||
| 200 | /* Return the terminal object specified by TERMINAL. TERMINAL may be | 200 | /* Return the terminal object specified by TERMINAL. TERMINAL may be |
| 201 | a terminal object, a frame, or nil for the terminal device of the | 201 | a terminal object, a frame, or nil for the terminal device of the |
| 202 | current frame. If THROW is zero, return NULL for failure, | 202 | current frame. If THROW is false, return NULL for failure, |
| 203 | otherwise throw an error. */ | 203 | otherwise throw an error. */ |
| 204 | 204 | ||
| 205 | struct terminal * | 205 | struct terminal * |
| 206 | get_terminal (Lisp_Object terminal, int throw) | 206 | get_terminal (Lisp_Object terminal, bool throw) |
| 207 | { | 207 | { |
| 208 | struct terminal *result = NULL; | 208 | struct terminal *result = NULL; |
| 209 | 209 | ||