/* Work-alike for termcap, plus extra features.
- Copyright (C) 1985, 86, 93, 94, 95 Free Software Foundation, Inc.
+ Copyright (C) 1985, 86, 93, 94, 95, 2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
/* Emacs config.h may rename various library functions such as malloc. */
#ifdef HAVE_CONFIG_H
#ifdef emacs
+#include <lisp.h> /* xmalloc is here */
/* Get the O_* definitions for open et al. */
#include <sys/file.h>
-#ifdef USG5
+#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#else /* not emacs */
return tgetst1 (ptr, area);
}
+#ifdef IS_EBCDIC_HOST
+/* Table, indexed by a character in range 0200 to 0300 with 0200 subtracted,
+ gives meaning of character following \, or a space if no special meaning.
+ Sixteen characters per line within the string. */
+
+static char esctab[]
+ = " \057\026 \047\014 \
+ \025 \015 \
+ \005 \013 \
+ ";
+#else
/* Table, indexed by a character in range 0100 to 0140 with 0100 subtracted,
gives meaning of character following \, or a space if no special meaning.
Eight characters per line within the string. */
\012 \
\015 \011 \013 \
";
+#endif
/* PTR points to a string value inside a termcap entry.
Copy that value, processing \ and ^ abbreviations,
p++;
}
}
+#ifdef IS_EBCDIC_HOST
+ else if (c >= 0200 && c < 0360)
+ {
+ c1 = esctab[(c & ~0100) - 0200];
+ if (c1 != ' ')
+ c = c1;
+ }
+#else
else if (c >= 0100 && c < 0200)
{
c1 = esctab[(c & ~040) - 0100];
if (c1 != ' ')
c = c1;
}
+#endif
}
*r++ = c;
}
\f
/* Outputting a string with padding. */
-short ospeed;
/* If OSPEED is 0, we use this as the actual baud rate. */
int tputs_baud_rate;
char PC;
register int padcount = 0;
register int speed;
-#ifdef emacs
- extern baud_rate;
+ extern int baud_rate;
speed = baud_rate;
/* For quite high speeds, convert to the smaller
units to avoid overflow. */
if (speed > 10000)
speed = - speed / 100;
-#else
- if (ospeed == 0)
- speed = tputs_baud_rate;
- else if (ospeed > 0 && ospeed < (sizeof speeds / sizeof speeds[0]))
- speed = speeds[ospeed];
- else
- speed = 0;
-#endif
if (!str)
return;
\f
/* Finding the termcap entry in the termcap data base. */
-struct buffer
+struct termcap_buffer
{
char *beg;
int size;
{
register char *termcap_name;
register int fd;
- struct buffer buf;
+ struct termcap_buffer buf;
register char *bp1;
- char *bp2;
+ char *tc_search_point;
char *term;
int malloc_size = 0;
register int c;
- char *tcenv; /* TERMCAP value, if it contains :tc=. */
+ char *tcenv = NULL; /* TERMCAP value, if it contains :tc=. */
char *indirect = NULL; /* Terminal type in :tc= in TERMCAP value. */
int filep;
malloc_size = indirect ? strlen (tcenv) + 1 : buf.size;
bp = (char *) xmalloc (malloc_size);
}
- bp1 = bp;
+ tc_search_point = bp1 = bp;
if (indirect)
/* Copy the data from the environment variable. */
/* If BP is malloc'd by us, make sure it is big enough. */
if (malloc_size)
{
- malloc_size = bp1 - bp + buf.size;
- termcap_name = (char *) xrealloc (bp, malloc_size);
- bp1 += termcap_name - bp;
- bp = termcap_name;
+ int offset1 = bp1 - bp, offset2 = tc_search_point - bp;
+ malloc_size = offset1 + buf.size;
+ bp = termcap_name = (char *) xrealloc (bp, malloc_size);
+ bp1 = termcap_name + offset1;
+ tc_search_point = termcap_name + offset2;
}
- bp2 = bp1;
-
/* Copy the line of the entry from buf into bp. */
termcap_name = buf.ptr;
while ((*bp1++ = c = *termcap_name++) && c != '\n')
/* Does this entry refer to another terminal type's entry?
If something is found, copy it into heap and null-terminate it. */
- term = tgetst1 (find_capability (bp2, "tc"), (char **) 0);
+ tc_search_point = find_capability (tc_search_point, "tc");
+ term = tgetst1 (tc_search_point, (char **) 0);
}
close (fd);
scan_file (str, fd, bufp)
char *str;
int fd;
- register struct buffer *bufp;
+ register struct termcap_buffer *bufp;
{
register char *end;
static char *
gobble_line (fd, bufp, append_end)
int fd;
- register struct buffer *bufp;
+ register struct termcap_buffer *bufp;
char *append_end;
{
register char *end;
}
#endif /* TEST */
-