HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(fix_submap_inheritance, get_keyelt, store_in_keymap,
[bpt/emacs.git]
/
src
/
termcap.c
diff --git
a/src/termcap.c
b/src/termcap.c
index
be5d039
..
f41f24f
100644
(file)
--- a/
src/termcap.c
+++ b/
src/termcap.c
@@
-1,5
+1,5
@@
/* Work-alike for termcap, plus extra features.
/* Work-alike for termcap, plus extra features.
- Copyright (C) 1985,
1986, 1993, 1994
Free Software Foundation, Inc.
+ Copyright (C) 1985,
86, 93, 94, 95
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
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
@@
-13,12
+13,15
@@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
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
/* Emacs config.h may rename various library functions such as malloc. */
#ifdef HAVE_CONFIG_H
-
#include <config.h>
#include <config.h>
+#endif
+
+#ifdef emacs
/* Get the O_* definitions for open et al. */
#include <sys/file.h>
/* Get the O_* definitions for open et al. */
#include <sys/file.h>
@@
-26,11
+29,7
@@
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <fcntl.h>
#endif
#include <fcntl.h>
#endif
-#else /* not HAVE_CONFIG_H */
-
-#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
-#define bcopy(s, d, n) memcpy ((d), (s), (n))
-#endif
+#else /* not emacs */
#ifdef STDC_HEADERS
#include <stdlib.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
@@
-41,6
+40,11
@@
char *malloc ();
char *realloc ();
#endif
char *realloc ();
#endif
+/* Do this after the include, in case string.h prototypes bcopy. */
+#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy)
+#define bcopy(s, d, n) memcpy ((d), (s), (n))
+#endif
+
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@
-48,7
+52,7
@@
char *realloc ();
#include <fcntl.h>
#endif
#include <fcntl.h>
#endif
-#endif /* not
HAVE_CONFIG_H
*/
+#endif /* not
emacs
*/
#ifndef NULL
#define NULL (char *) 0
#ifndef NULL
#define NULL (char *) 0
@@
-75,8
+79,8
@@
int bufsize = 128;
#endif
#endif
#endif
#endif
-#ifndef TERMCAP_
NAM
E
-#define TERMCAP_
NAM
E "/etc/termcap"
+#ifndef TERMCAP_
FIL
E
+#define TERMCAP_
FIL
E "/etc/termcap"
#endif
#ifndef emacs
#endif
#ifndef emacs
@@
-297,8
+301,10
@@
tputs (str, nlines, outfun)
#else
if (ospeed == 0)
speed = tputs_baud_rate;
#else
if (ospeed == 0)
speed = tputs_baud_rate;
- else
+ else
if (ospeed > 0 && ospeed < (sizeof speeds / sizeof speeds[0]))
speed = speeds[ospeed];
speed = speeds[ospeed];
+ else
+ speed = 0;
#endif
if (!str)
#endif
if (!str)
@@
-418,7
+424,7
@@
tgetent (bp, name)
register int fd;
struct buffer buf;
register char *bp1;
register int fd;
struct buffer buf;
register char *bp1;
- char *
bp2
;
+ char *
tc_search_point
;
char *term;
int malloc_size = 0;
register int c;
char *term;
int malloc_size = 0;
register int c;
@@
-442,6
+448,11
@@
tgetent (bp, name)
}
#endif /* INTERNAL_TERMINAL */
}
#endif /* INTERNAL_TERMINAL */
+ /* For compatibility with programs like `less' that want to
+ put data in the termcap buffer themselves as a fallback. */
+ if (bp)
+ term_entry = bp;
+
termcap_name = getenv ("TERMCAP");
if (termcap_name && *termcap_name == '\0')
termcap_name = NULL;
termcap_name = getenv ("TERMCAP");
if (termcap_name && *termcap_name == '\0')
termcap_name = NULL;
@@
-479,7
+490,7
@@
tgetent (bp, name)
}
if (!termcap_name || !filep)
}
if (!termcap_name || !filep)
- termcap_name = TERMCAP_
NAM
E;
+ termcap_name = TERMCAP_
FIL
E;
/* Here we know we must search a file and termcap_name has its name. */
/* Here we know we must search a file and termcap_name has its name. */
@@
-501,7
+512,7
@@
tgetent (bp, name)
malloc_size = indirect ? strlen (tcenv) + 1 : buf.size;
bp = (char *) xmalloc (malloc_size);
}
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 (indirect)
/* Copy the data from the environment variable. */
@@
-532,11
+543,10
@@
tgetent (bp, name)
malloc_size = bp1 - bp + buf.size;
termcap_name = (char *) xrealloc (bp, malloc_size);
bp1 += termcap_name - bp;
malloc_size = bp1 - bp + buf.size;
termcap_name = (char *) xrealloc (bp, malloc_size);
bp1 += termcap_name - bp;
+ tc_search_point += termcap_name - bp;
bp = termcap_name;
}
bp = termcap_name;
}
- bp2 = bp1;
-
/* Copy the line of the entry from buf into bp. */
termcap_name = buf.ptr;
while ((*bp1++ = c = *termcap_name++) && c != '\n')
/* Copy the line of the entry from buf into bp. */
termcap_name = buf.ptr;
while ((*bp1++ = c = *termcap_name++) && c != '\n')
@@
-550,7
+560,8
@@
tgetent (bp, name)
/* Does this entry refer to another terminal type's entry?
If something is found, copy it into heap and null-terminate it. */
/* 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);
}
close (fd);
@@
-561,8
+572,6
@@
tgetent (bp, name)
ret:
term_entry = bp;
ret:
term_entry = bp;
- if (malloc_size)
- return (int) bp;
return 1;
}
return 1;
}
@@
-773,4
+782,3
@@
tprint (cap)
}
#endif /* TEST */
}
#endif /* TEST */
-