comparison src/termcap.c @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents abe6d1db359e
children 804517e16990
comparison
equal deleted inserted replaced
770:336a418893b5 771:943eaba38521
1 /* Work-alike for termcap, plus extra features. 1 /* Work-alike for termcap, plus extra features.
2 Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
3 Copyright (C) 2001 Ben Wing.
3 4
4 This file is part of XEmacs. 5 This file is part of XEmacs.
5 6
6 XEmacs is free software; you can redistribute it and/or modify it 7 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the 8 under the terms of the GNU General Public License as published by the
58 59
59 #ifndef emacs 60 #ifndef emacs
60 static void 61 static void
61 memory_out () 62 memory_out ()
62 { 63 {
63 write (2, "virtual memory exhausted\n", 25); 64 retry_write (2, "virtual memory exhausted\n", 25);
64 exit (1); 65 exit (1);
65 } 66 }
66 67
67 static char * 68 static char *
68 xmalloc (size) 69 xmalloc (size)
342 int malloc_size = 0; 343 int malloc_size = 0;
343 int c; 344 int c;
344 char *tcenv; /* TERMCAP value, if it contains :tc=. */ 345 char *tcenv; /* TERMCAP value, if it contains :tc=. */
345 const char *indirect = 0; /* Terminal type in :tc= in TERMCAP value. */ 346 const char *indirect = 0; /* Terminal type in :tc= in TERMCAP value. */
346 347
347 tem = getenv ("TERMCAP"); 348 tem = egetenv ("TERMCAP");
348 if (tem && *tem == 0) tem = 0; 349 if (tem && *tem == 0) tem = 0;
349 350
350 351
351 /* If tem is non-null and starts with / (in the un*x case, that is), 352 /* If tem is non-null and starts with / (in the un*x case, that is),
352 it is a file name to use instead of /etc/termcap. 353 it is a file name to use instead of /etc/termcap.
353 If it is non-null and does not start with /, 354 If it is non-null and does not start with /,
354 it is the entry itself, but only if 355 it is the entry itself, but only if
355 the name the caller requested matches the TERM variable. */ 356 the name the caller requested matches the TERM variable. */
356 357
357 if (tem && !IS_DIRECTORY_SEP (*tem) && !strcmp (name, getenv ("TERM"))) 358 if (tem && !IS_DIRECTORY_SEP (*tem) && !strcmp (name, egetenv ("TERM")))
358 { 359 {
359 indirect = tgetst1 (find_capability (tem, "tc"), 0); 360 indirect = tgetst1 (find_capability (tem, "tc"), 0);
360 if (!indirect) 361 if (!indirect)
361 { 362 {
362 if (!bp) 363 if (!bp)
377 if (!tem) 378 if (!tem)
378 tem = "/etc/termcap"; 379 tem = "/etc/termcap";
379 380
380 /* Here we know we must search a file and tem has its name. */ 381 /* Here we know we must search a file and tem has its name. */
381 382
382 fd = open (tem, 0, 0); 383 fd = qxe_open ((Intbyte *) tem, 0, 0);
383 if (fd < 0) 384 if (fd < 0)
384 return -1; 385 return -1;
385 386
386 buf.size = BUFSIZE; 387 buf.size = BUFSIZE;
387 /* Add 1 to size to ensure room for terminating null. */ 388 /* Add 1 to size to ensure room for terminating null. */
437 /* Does this entry refer to another terminal type's entry? 438 /* Does this entry refer to another terminal type's entry?
438 If something is found, copy it into heap and null-terminate it. */ 439 If something is found, copy it into heap and null-terminate it. */
439 term = tgetst1 (find_capability (bp2, "tc"), 0); 440 term = tgetst1 (find_capability (bp2, "tc"), 0);
440 } 441 }
441 442
442 close (fd); 443 retry_close (fd);
443 xfree (buf.beg); 444 xfree (buf.beg);
444 445
445 if (malloc_size) 446 if (malloc_size)
446 { 447 {
447 bp = (char *) xrealloc (bp, bp1 - bp + 1); 448 bp = (char *) xrealloc (bp, bp1 - bp + 1);
596 { 597 {
597 append_end -= bufp->ptr - buf; 598 append_end -= bufp->ptr - buf;
598 memcpy (buf, bufp->ptr, bufp->full -= bufp->ptr - buf); 599 memcpy (buf, bufp->ptr, bufp->full -= bufp->ptr - buf);
599 bufp->ptr = buf; 600 bufp->ptr = buf;
600 } 601 }
601 if (!(nread = read (fd, buf + bufp->full, bufp->size - bufp->full))) 602 if (!(nread = retry_read (fd, buf + bufp->full, bufp->size - bufp->full)))
602 bufp->ateof = 1; 603 bufp->ateof = 1;
603 bufp->full += nread; 604 bufp->full += nread;
604 buf[bufp->full] = 0; 605 buf[bufp->full] = 0;
605 } 606 }
606 return end + 1; 607 return end + 1;