aboutsummaryrefslogtreecommitdiffstats
path: root/src/termcap.c
diff options
context:
space:
mode:
authorJoakim Verona2010-08-27 10:58:44 +0200
committerJoakim Verona2010-08-27 10:58:44 +0200
commit362120833bcbbaea94976b6701633e2ed75f6051 (patch)
tree632690a24a934bb51a32303add5172d63b6b9e00 /src/termcap.c
parent1800c4865b15a9e1154bf1f03d87d1aaf750a527 (diff)
parent1a868076f51b5d6f1cf78117463e6f9c614551ec (diff)
downloademacs-362120833bcbbaea94976b6701633e2ed75f6051.tar.gz
emacs-362120833bcbbaea94976b6701633e2ed75f6051.zip
merge from trunk, fix conflicts
Diffstat (limited to 'src/termcap.c')
-rw-r--r--src/termcap.c116
1 files changed, 18 insertions, 98 deletions
diff --git a/src/termcap.c b/src/termcap.c
index 9b4a7f657f6..ea4ef244f64 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -18,12 +18,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18Boston, MA 02110-1301, USA. */ 18Boston, MA 02110-1301, USA. */
19 19
20/* Emacs config.h may rename various library functions such as malloc. */ 20/* Emacs config.h may rename various library functions such as malloc. */
21#ifdef HAVE_CONFIG_H
22#include <config.h> 21#include <config.h>
23#endif
24
25#ifdef emacs
26
27#include <setjmp.h> 22#include <setjmp.h>
28#include <lisp.h> /* xmalloc is here */ 23#include <lisp.h> /* xmalloc is here */
29/* Get the O_* definitions for open et al. */ 24/* Get the O_* definitions for open et al. */
@@ -35,31 +30,6 @@ Boston, MA 02110-1301, USA. */
35#include <unistd.h> 30#include <unistd.h>
36#endif 31#endif
37 32
38#else /* not emacs */
39
40#ifdef STDC_HEADERS
41#include <stdlib.h>
42#include <string.h>
43#else
44char *getenv ();
45char *malloc ();
46char *realloc ();
47#endif
48
49/* Do this after the include, in case string.h prototypes bcopy. */
50#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy)
51#define bcopy(s, d, n) memcpy ((d), (s), (n))
52#endif
53
54#ifdef HAVE_UNISTD_H
55#include <unistd.h>
56#endif
57#ifdef HAVE_FCNTL_H
58#include <fcntl.h>
59#endif
60
61#endif /* not emacs */
62
63#ifndef NULL 33#ifndef NULL
64#define NULL (char *) 0 34#define NULL (char *) 0
65#endif 35#endif
@@ -89,37 +59,6 @@ int bufsize = 128;
89#define TERMCAP_FILE "/etc/termcap" 59#define TERMCAP_FILE "/etc/termcap"
90#endif 60#endif
91 61
92#ifndef emacs
93static void
94memory_out ()
95{
96 write (2, "virtual memory exhausted\n", 25);
97 exit (1);
98}
99
100static char *
101xmalloc (size)
102 unsigned size;
103{
104 register char *tem = malloc (size);
105
106 if (!tem)
107 memory_out ();
108 return tem;
109}
110
111static char *
112xrealloc (ptr, size)
113 char *ptr;
114 unsigned size;
115{
116 register char *tem = realloc (ptr, size);
117
118 if (!tem)
119 memory_out ();
120 return tem;
121}
122#endif /* not emacs */
123 62
124/* Looking up capabilities in the entry already found. */ 63/* Looking up capabilities in the entry already found. */
125 64
@@ -127,15 +66,14 @@ xrealloc (ptr, size)
127 for tgetnum, tgetflag and tgetstr to find. */ 66 for tgetnum, tgetflag and tgetstr to find. */
128static char *term_entry; 67static char *term_entry;
129 68
130static char *tgetst1 (); 69static char *tgetst1 (char *ptr, char **area);
131 70
132/* Search entry BP for capability CAP. 71/* Search entry BP for capability CAP.
133 Return a pointer to the capability (in BP) if found, 72 Return a pointer to the capability (in BP) if found,
134 0 if not found. */ 73 0 if not found. */
135 74
136static char * 75static char *
137find_capability (bp, cap) 76find_capability (register char *bp, register char *cap)
138 register char *bp, *cap;
139{ 77{
140 for (; *bp; bp++) 78 for (; *bp; bp++)
141 if (bp[0] == ':' 79 if (bp[0] == ':'
@@ -146,8 +84,7 @@ find_capability (bp, cap)
146} 84}
147 85
148int 86int
149tgetnum (cap) 87tgetnum (char *cap)
150 char *cap;
151{ 88{
152 register char *ptr = find_capability (term_entry, cap); 89 register char *ptr = find_capability (term_entry, cap);
153 if (!ptr || ptr[-1] != '#') 90 if (!ptr || ptr[-1] != '#')
@@ -156,8 +93,7 @@ tgetnum (cap)
156} 93}
157 94
158int 95int
159tgetflag (cap) 96tgetflag (char *cap)
160 char *cap;
161{ 97{
162 register char *ptr = find_capability (term_entry, cap); 98 register char *ptr = find_capability (term_entry, cap);
163 return ptr && ptr[-1] == ':'; 99 return ptr && ptr[-1] == ':';
@@ -169,9 +105,7 @@ tgetflag (cap)
169 If AREA is null, space is allocated with `malloc'. */ 105 If AREA is null, space is allocated with `malloc'. */
170 106
171char * 107char *
172tgetstr (cap, area) 108tgetstr (char *cap, char **area)
173 char *cap;
174 char **area;
175{ 109{
176 register char *ptr = find_capability (term_entry, cap); 110 register char *ptr = find_capability (term_entry, cap);
177 if (!ptr || (ptr[-1] != '=' && ptr[-1] != '~')) 111 if (!ptr || (ptr[-1] != '=' && ptr[-1] != '~'))
@@ -209,9 +143,7 @@ static const char esctab[]
209 or NULL if PTR is NULL. */ 143 or NULL if PTR is NULL. */
210 144
211static char * 145static char *
212tgetst1 (ptr, area) 146tgetst1 (char *ptr, char **area)
213 char *ptr;
214 char **area;
215{ 147{
216 register char *p, *r; 148 register char *p, *r;
217 register int c; 149 register int c;
@@ -322,7 +254,7 @@ tgetst1 (ptr, area)
322 254
323 cut[last_p_param].len = r - cut[last_p_param].beg; 255 cut[last_p_param].len = r - cut[last_p_param].beg;
324 for (i = 0, wp = ret; i <= last_p_param; wp += cut[i++].len) 256 for (i = 0, wp = ret; i <= last_p_param; wp += cut[i++].len)
325 bcopy (cut[i].beg, wp, cut[i].len); 257 memcpy (wp, cut[i].beg, cut[i].len);
326 r = wp; 258 r = wp;
327 } 259 }
328 } 260 }
@@ -357,10 +289,7 @@ static const int speeds[] =
357#endif /* not emacs */ 289#endif /* not emacs */
358 290
359void 291void
360tputs (str, nlines, outfun) 292tputs (register char *str, int nlines, register int (*outfun) (/* ??? */))
361 register char *str;
362 int nlines;
363 register int (*outfun) ();
364{ 293{
365 register int padcount = 0; 294 register int padcount = 0;
366 register int speed; 295 register int speed;
@@ -432,10 +361,10 @@ struct termcap_buffer
432 361
433/* Forward declarations of static functions. */ 362/* Forward declarations of static functions. */
434 363
435static int scan_file (); 364static int scan_file (char *str, int fd, register struct termcap_buffer *bufp);
436static char *gobble_line (); 365static char *gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end);
437static int compare_contin (); 366static int compare_contin (register char *str1, register char *str2);
438static int name_match (); 367static int name_match (char *line, char *name);
439 368
440#ifdef MSDOS /* MW, May 1993 */ 369#ifdef MSDOS /* MW, May 1993 */
441static int 370static int
@@ -460,8 +389,7 @@ valid_filename_p (fn)
460 in it, and some other value otherwise. */ 389 in it, and some other value otherwise. */
461 390
462int 391int
463tgetent (bp, name) 392tgetent (char *bp, char *name)
464 char *bp, *name;
465{ 393{
466 register char *termcap_name; 394 register char *termcap_name;
467 register int fd; 395 register int fd;
@@ -625,10 +553,7 @@ tgetent (bp, name)
625 or 0 if no entry is found in the file. */ 553 or 0 if no entry is found in the file. */
626 554
627static int 555static int
628scan_file (str, fd, bufp) 556scan_file (char *str, int fd, register struct termcap_buffer *bufp)
629 char *str;
630 int fd;
631 register struct termcap_buffer *bufp;
632{ 557{
633 register char *end; 558 register char *end;
634 559
@@ -665,8 +590,7 @@ scan_file (str, fd, bufp)
665 by termcap entry LINE. */ 590 by termcap entry LINE. */
666 591
667static int 592static int
668name_match (line, name) 593name_match (char *line, char *name)
669 char *line, *name;
670{ 594{
671 register char *tem; 595 register char *tem;
672 596
@@ -681,8 +605,7 @@ name_match (line, name)
681} 605}
682 606
683static int 607static int
684compare_contin (str1, str2) 608compare_contin (register char *str1, register char *str2)
685 register char *str1, *str2;
686{ 609{
687 register int c1, c2; 610 register int c1, c2;
688 while (1) 611 while (1)
@@ -722,10 +645,7 @@ compare_contin (str1, str2)
722 thing as one line. The caller decides when a line is continued. */ 645 thing as one line. The caller decides when a line is continued. */
723 646
724static char * 647static char *
725gobble_line (fd, bufp, append_end) 648gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end)
726 int fd;
727 register struct termcap_buffer *bufp;
728 char *append_end;
729{ 649{
730 register char *end; 650 register char *end;
731 register int nread; 651 register int nread;
@@ -758,7 +678,7 @@ gobble_line (fd, bufp, append_end)
758 else 678 else
759 { 679 {
760 append_end -= bufp->ptr - buf; 680 append_end -= bufp->ptr - buf;
761 bcopy (bufp->ptr, buf, bufp->full -= bufp->ptr - buf); 681 memcpy (buf, bufp->ptr, bufp->full -= bufp->ptr - buf);
762 bufp->ptr = buf; 682 bufp->ptr = buf;
763 } 683 }
764 if (!(nread = read (fd, buf + bufp->full, bufp->size - bufp->full))) 684 if (!(nread = read (fd, buf + bufp->full, bufp->size - bufp->full)))