mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-04 10:50:50 +02:00
fix for invalid brace sequence expressions; cosmetic fix to help builtin; documentation and copyright updates; bump version to bash-5.3-rc1; cosmetic locale fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* complete.c -- filename completion for readline. */
|
||||
|
||||
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2025 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* display.c -- readline redisplay facility. */
|
||||
|
||||
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2025 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* histfile.c - functions to manipulate the history file. */
|
||||
|
||||
/* Copyright (C) 1989-2019,2023-2024 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2019,2023-2025 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (History), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
||||
+20
-20
@@ -148,26 +148,26 @@ _rl_wcwidth (WCHAR_T wc)
|
||||
{
|
||||
switch (wc)
|
||||
{
|
||||
case ' ': case '!': case '"': case '#': case '%':
|
||||
case '&': case '\'': case '(': case ')': case '*':
|
||||
case '+': case ',': case '-': case '.': case '/':
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case ':': case ';': case '<': case '=': case '>':
|
||||
case '?':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E':
|
||||
case 'F': case 'G': case 'H': case 'I': case 'J':
|
||||
case 'K': case 'L': case 'M': case 'N': case 'O':
|
||||
case 'P': case 'Q': case 'R': case 'S': case 'T':
|
||||
case 'U': case 'V': case 'W': case 'X': case 'Y':
|
||||
case 'Z':
|
||||
case '[': case '\\': case ']': case '^': case '_':
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e':
|
||||
case 'f': case 'g': case 'h': case 'i': case 'j':
|
||||
case 'k': case 'l': case 'm': case 'n': case 'o':
|
||||
case 'p': case 'q': case 'r': case 's': case 't':
|
||||
case 'u': case 'v': case 'w': case 'x': case 'y':
|
||||
case 'z': case '{': case '|': case '}': case '~':
|
||||
case L' ': case L'!': case L'"': case L'#': case L'%':
|
||||
case L'&': case L'\'': case L'(': case L')': case L'*':
|
||||
case L'+': case L',': case L'-': case L'.': case L'/':
|
||||
case L'0': case L'1': case L'2': case L'3': case L'4':
|
||||
case L'5': case L'6': case L'7': case L'8': case L'9':
|
||||
case L':': case L';': case L'<': case L'=': case L'>':
|
||||
case L'?':
|
||||
case L'A': case L'B': case L'C': case L'D': case L'E':
|
||||
case L'F': case L'G': case L'H': case L'I': case L'J':
|
||||
case L'K': case L'L': case L'M': case L'N': case L'O':
|
||||
case L'P': case L'Q': case L'R': case L'S': case L'T':
|
||||
case L'U': case L'V': case L'W': case L'X': case L'Y':
|
||||
case L'Z':
|
||||
case L'[': case L'\\': case L']': case L'^': case L'_':
|
||||
case L'a': case L'b': case L'c': case L'd': case L'e':
|
||||
case L'f': case L'g': case L'h': case L'i': case L'j':
|
||||
case L'k': case L'l': case L'm': case L'n': case L'o':
|
||||
case L'p': case L'q': case L'r': case L's': case L't':
|
||||
case L'u': case L'v': case L'w': case L'x': case L'y':
|
||||
case L'z': case L'{': case L'|': case L'}': case L'~':
|
||||
return 1;
|
||||
default:
|
||||
return wcwidth (wc);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* rlprivate.h -- functions and variables global to the readline library,
|
||||
but not intended for use by applications. */
|
||||
|
||||
/* Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1999-2025 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* signals.c -- signal handling support for readline. */
|
||||
|
||||
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2025 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
+207
-48
@@ -17,11 +17,15 @@
|
||||
* For VMS dates, add VMS_EXT.
|
||||
* For complete POSIX semantics, add POSIX_SEMANTICS.
|
||||
*
|
||||
* The code for %c, %x, and %X follows the C99 specification for
|
||||
* The code for %X follows the C99 specification for
|
||||
* the "C" locale.
|
||||
*
|
||||
* This version ignores LOCALE information.
|
||||
* It also doesn't worry about multi-byte characters.
|
||||
* The code for %c, and %x follows the C11 specification for
|
||||
* the "C" locale.
|
||||
*
|
||||
* With HAVE_NL_LANGINFO defined, locale-based values are used.
|
||||
*
|
||||
* This version doesn't worry about multi-byte characters.
|
||||
* So there.
|
||||
*
|
||||
* Arnold Robbins
|
||||
@@ -39,6 +43,8 @@
|
||||
* Updated December, 2001
|
||||
* Updated January, 2011
|
||||
* Updated April, 2012
|
||||
* Updated March, 2015
|
||||
* Updated June, 2015
|
||||
*
|
||||
* Fixes from ado@elsie.nci.nih.gov,
|
||||
* February 1991, May 1992
|
||||
@@ -61,6 +67,10 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(TM_IN_SYS_TIME)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <posixtime.h>
|
||||
@@ -82,6 +92,10 @@
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NL_LANGINFO
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
|
||||
#if defined (SHELL)
|
||||
extern char *get_string_value (const char *);
|
||||
#endif
|
||||
@@ -165,6 +179,146 @@ iso_8601_2000_year(char *buf, int year, size_t fw)
|
||||
}
|
||||
#endif /* POSIX_2008 */
|
||||
|
||||
/* days_a --- return the short name for the day of the week */
|
||||
|
||||
static const char *
|
||||
days_a(int index)
|
||||
{
|
||||
#ifdef HAVE_NL_LANGINFO
|
||||
static const nl_item data[] = {
|
||||
ABDAY_1,
|
||||
ABDAY_2,
|
||||
ABDAY_3,
|
||||
ABDAY_4,
|
||||
ABDAY_5,
|
||||
ABDAY_6,
|
||||
ABDAY_7,
|
||||
};
|
||||
|
||||
return nl_langinfo(data[index]);
|
||||
#else
|
||||
static const char *data[] = {
|
||||
"Sun", "Mon", "Tue", "Wed",
|
||||
"Thu", "Fri", "Sat",
|
||||
};
|
||||
|
||||
return data[index];
|
||||
#endif
|
||||
}
|
||||
|
||||
/* days_l --- return the long name for the day of the week */
|
||||
|
||||
static const char *
|
||||
days_l(int index)
|
||||
{
|
||||
#ifdef HAVE_NL_LANGINFO
|
||||
static const nl_item data[] = {
|
||||
DAY_1,
|
||||
DAY_2,
|
||||
DAY_3,
|
||||
DAY_4,
|
||||
DAY_5,
|
||||
DAY_6,
|
||||
DAY_7,
|
||||
};
|
||||
|
||||
return nl_langinfo(data[index]);
|
||||
#else
|
||||
static const char *data[] = {
|
||||
"Sunday", "Monday", "Tuesday", "Wednesday",
|
||||
"Thursday", "Friday", "Saturday",
|
||||
};
|
||||
|
||||
return data[index];
|
||||
#endif
|
||||
}
|
||||
|
||||
/* months_a --- return the short name for the month */
|
||||
|
||||
static const char *
|
||||
months_a(int index)
|
||||
{
|
||||
#ifdef HAVE_NL_LANGINFO
|
||||
static const nl_item data[] = {
|
||||
ABMON_1,
|
||||
ABMON_2,
|
||||
ABMON_3,
|
||||
ABMON_4,
|
||||
ABMON_5,
|
||||
ABMON_6,
|
||||
ABMON_7,
|
||||
ABMON_8,
|
||||
ABMON_9,
|
||||
ABMON_10,
|
||||
ABMON_11,
|
||||
ABMON_12,
|
||||
};
|
||||
|
||||
return nl_langinfo(data[index]);
|
||||
#else
|
||||
static const char *data[] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
||||
};
|
||||
|
||||
return data[index];
|
||||
#endif
|
||||
}
|
||||
|
||||
/* months_l --- return the short name for the month */
|
||||
|
||||
static const char *
|
||||
months_l(int index)
|
||||
{
|
||||
#ifdef HAVE_NL_LANGINFO
|
||||
static const nl_item data[] = {
|
||||
MON_1,
|
||||
MON_2,
|
||||
MON_3,
|
||||
MON_4,
|
||||
MON_5,
|
||||
MON_6,
|
||||
MON_7,
|
||||
MON_8,
|
||||
MON_9,
|
||||
MON_10,
|
||||
MON_11,
|
||||
MON_12,
|
||||
};
|
||||
|
||||
return nl_langinfo(data[index]);
|
||||
#else
|
||||
static const char *data[] = {
|
||||
"January", "February", "March", "April",
|
||||
"May", "June", "July", "August", "September",
|
||||
"October", "November", "December",
|
||||
};
|
||||
|
||||
return data[index];
|
||||
#endif
|
||||
}
|
||||
|
||||
/* days_a --- return am/pm string */
|
||||
|
||||
static const char *
|
||||
ampm(int index)
|
||||
{
|
||||
#ifdef HAVE_NL_LANGINFO
|
||||
static const nl_item data[] = {
|
||||
AM_STR,
|
||||
PM_STR,
|
||||
};
|
||||
|
||||
return nl_langinfo(data[index]);
|
||||
#else
|
||||
static const char *data[] = {
|
||||
"AM", "PM",
|
||||
};
|
||||
|
||||
return data[index];
|
||||
#endif
|
||||
}
|
||||
|
||||
/* strftime --- produce formatted time */
|
||||
|
||||
size_t
|
||||
@@ -199,27 +353,6 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
char flag;
|
||||
#endif /* POSIX_2008 */
|
||||
|
||||
/* various tables, useful in North America */
|
||||
static const char *days_a[] = {
|
||||
"Sun", "Mon", "Tue", "Wed",
|
||||
"Thu", "Fri", "Sat",
|
||||
};
|
||||
static const char *days_l[] = {
|
||||
"Sunday", "Monday", "Tuesday", "Wednesday",
|
||||
"Thursday", "Friday", "Saturday",
|
||||
};
|
||||
static const char *months_a[] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
||||
};
|
||||
static const char *months_l[] = {
|
||||
"January", "February", "March", "April",
|
||||
"May", "June", "July", "August", "September",
|
||||
"October", "November", "December",
|
||||
};
|
||||
static const char *ampm[] = { "AM", "PM", };
|
||||
|
||||
oerrno = errno;
|
||||
|
||||
if (s == NULL || format == NULL || timeptr == NULL || maxsize == 0)
|
||||
return 0;
|
||||
@@ -228,6 +361,8 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
if (strchr(format, '%') == NULL && strlen(format) + 1 >= maxsize)
|
||||
return 0;
|
||||
|
||||
oerrno = errno;
|
||||
|
||||
#ifndef POSIX_SEMANTICS
|
||||
if (first) {
|
||||
tzset();
|
||||
@@ -321,14 +456,14 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6)
|
||||
strcpy(tbuf, "?");
|
||||
else
|
||||
strcpy(tbuf, days_a[timeptr->tm_wday]);
|
||||
strcpy(tbuf, days_a(timeptr->tm_wday));
|
||||
break;
|
||||
|
||||
case 'A': /* full weekday name */
|
||||
if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6)
|
||||
strcpy(tbuf, "?");
|
||||
else
|
||||
strcpy(tbuf, days_l[timeptr->tm_wday]);
|
||||
strcpy(tbuf, days_l(timeptr->tm_wday));
|
||||
break;
|
||||
|
||||
case 'b': /* abbreviated month name */
|
||||
@@ -336,14 +471,14 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11)
|
||||
strcpy(tbuf, "?");
|
||||
else
|
||||
strcpy(tbuf, months_a[timeptr->tm_mon]);
|
||||
strcpy(tbuf, months_a(timeptr->tm_mon));
|
||||
break;
|
||||
|
||||
case 'B': /* full month name */
|
||||
if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11)
|
||||
strcpy(tbuf, "?");
|
||||
else
|
||||
strcpy(tbuf, months_l[timeptr->tm_mon]);
|
||||
strcpy(tbuf, months_l(timeptr->tm_mon));
|
||||
break;
|
||||
|
||||
case 'c': /* appropriate date and time representation */
|
||||
@@ -352,9 +487,16 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
*
|
||||
* strftime(tbuf, sizeof tbuf, "%a %b %e %H:%M:%S %Y", timeptr);
|
||||
*
|
||||
* Now, per the ISO 1999 C standard, it this:
|
||||
* Per the ISO 1999 C standard, it was this:
|
||||
* strftime(tbuf, sizeof tbuf, "%A %B %d %T %Y", timeptr);
|
||||
*
|
||||
* Per the ISO 2011 C standard, it is now this:
|
||||
*/
|
||||
strftime(tbuf, sizeof tbuf, "%A %B %d %T %Y", timeptr);
|
||||
#ifdef HAVE_NL_LANGINFO
|
||||
strftime(tbuf, sizeof tbuf, nl_langinfo(D_T_FMT), timeptr);
|
||||
#else
|
||||
strftime(tbuf, sizeof tbuf, "%a %b %e %T %Y", timeptr);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
@@ -497,9 +639,9 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
case 'p': /* am or pm based on 12-hour clock */
|
||||
i = range(0, timeptr->tm_hour, 23);
|
||||
if (i < 12)
|
||||
strcpy(tbuf, ampm[0]);
|
||||
strcpy(tbuf, ampm(0));
|
||||
else
|
||||
strcpy(tbuf, ampm[1]);
|
||||
strcpy(tbuf, ampm(1));
|
||||
break;
|
||||
|
||||
case 'r': /* time as %I:%M:%S %p */
|
||||
@@ -560,11 +702,25 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
break;
|
||||
|
||||
case 'x': /* appropriate date representation */
|
||||
strftime(tbuf, sizeof tbuf, "%A %B %d %Y", timeptr);
|
||||
/*
|
||||
* Up to the 2011 standard, this code used:
|
||||
* strftime(tbuf, sizeof tbuf, "%A %B %d %Y", timeptr);
|
||||
*
|
||||
* Now, per the 2011 C standard, this is:
|
||||
*/
|
||||
#ifdef HAVE_NL_LANGINFO
|
||||
strftime(tbuf, sizeof tbuf, nl_langinfo(D_FMT), timeptr);
|
||||
#else
|
||||
strftime(tbuf, sizeof tbuf, "%m/%d/%y", timeptr);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'X': /* appropriate time representation */
|
||||
#ifdef HAVE_NL_LANGINFO
|
||||
strftime(tbuf, sizeof tbuf, nl_langinfo(T_FMT), timeptr);
|
||||
#else
|
||||
goto the_time;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'y': /* year without a century, 00 - 99 */
|
||||
@@ -625,12 +781,12 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
* Systems with tzname[] probably have timezone as
|
||||
* secs west of GMT. Convert to mins east of GMT.
|
||||
*/
|
||||
# if defined(__hpux) || defined (HPUX) || defined(__CYGWIN__)
|
||||
#if defined(__hpux) || defined (HPUX) || defined(__CYGWIN__)
|
||||
off = -timezone / 60;
|
||||
# else
|
||||
#else
|
||||
/* ADR: 4 August 2001, fixed this per gazelle@interaccess.com */
|
||||
off = -(daylight ? altzone : timezone) / 60;
|
||||
# endif
|
||||
#endif
|
||||
#else /* !HAVE_TZNAME */
|
||||
gettimeofday(& tv, & zone);
|
||||
off = -zone.tz_minuteswest;
|
||||
@@ -682,8 +838,12 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
|
||||
#ifdef HPUX_EXT
|
||||
case 'N': /* Emperor/Era name */
|
||||
#ifdef HAVE_NL_LANGINFO
|
||||
strftime(tbuf, sizeof tbuf, nl_langinfo(ERA), timeptr);
|
||||
#else
|
||||
/* this is essentially the same as the century */
|
||||
goto century; /* %C */
|
||||
#endif
|
||||
|
||||
case 'o': /* Emperor/Era year */
|
||||
goto year; /* %y */
|
||||
@@ -694,7 +854,7 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
case 'v': /* date as dd-bbb-YYYY */
|
||||
sprintf(tbuf, "%2d-%3.3s-%4ld",
|
||||
range(1, timeptr->tm_mday, 31),
|
||||
months_a[range(0, timeptr->tm_mon, 11)],
|
||||
months_a(range(0, timeptr->tm_mon, 11)),
|
||||
timeptr->tm_year + 1900L);
|
||||
for (i = 3; i < 6; i++)
|
||||
if (islower(tbuf[i]))
|
||||
@@ -925,6 +1085,7 @@ How nicer it depends on a compiler, of course, but always a tiny bit.
|
||||
#ifndef NULL
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include <locale.h>
|
||||
#include <sys/time.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -941,11 +1102,11 @@ static char *array[] =
|
||||
"(%%C) Century %C",
|
||||
"(%%D) date (%%m/%%d/%%y) %D",
|
||||
"(%%E) Locale extensions (ignored) %E",
|
||||
"(%%F) full month name, var length (January..December) %F",
|
||||
"(%%F) year-month-day (YYYY-MM-DD) %F",
|
||||
"(%%H) hour (24-hour clock, 00..23) %H",
|
||||
"(%%I) hour (12-hour clock, 01..12) %I",
|
||||
"(%%M) minute (00..59) %M",
|
||||
"(%%N) Emperor/Era Name %N",
|
||||
"(%%N) Emporer/Era Name %N",
|
||||
"(%%O) Locale extensions (ignored) %O",
|
||||
"(%%R) time, 24-hour (%%H:%%M) %R",
|
||||
"(%%S) second (00..60) %S",
|
||||
@@ -953,12 +1114,12 @@ static char *array[] =
|
||||
"(%%U) week of year, Sunday as first day of week (00..53) %U",
|
||||
"(%%V) week of year according to ISO 8601 %V",
|
||||
"(%%W) week of year, Monday as first day of week (00..53) %W",
|
||||
"(%%X) appropriate locale time representation (%H:%M:%S) %X",
|
||||
"(%%X) appropriate locale time representation (%%H:%%M:%%S) %X",
|
||||
"(%%Y) year with century (1970...) %Y",
|
||||
"(%%Z) timezone (EDT), or blank if timezone not determinable %Z",
|
||||
"(%%a) locale's abbreviated weekday name (Sun..Sat) %a",
|
||||
"(%%b) locale's abbreviated month name (Jan..Dec) %b",
|
||||
"(%%c) full date (Sat Nov 4 12:02:33 1989)%n%t%t%t %c",
|
||||
"(%%c) full date + newline (Sat Nov 4 12:02:33 1989)%n%t%t%t %c",
|
||||
"(%%d) day of the month (01..31) %d",
|
||||
"(%%e) day of the month, blank-padded ( 1..31) %e",
|
||||
"(%%h) should be same as (%%b) %h",
|
||||
@@ -966,7 +1127,7 @@ static char *array[] =
|
||||
"(%%k) hour, 24-hour clock, blank pad ( 0..23) %k",
|
||||
"(%%l) hour, 12-hour clock, blank pad ( 0..12) %l",
|
||||
"(%%m) month (01..12) %m",
|
||||
"(%%o) Emperor/Era Year %o",
|
||||
"(%%o) Emporer/Era Year %o",
|
||||
"(%%p) locale's AM or PM based on 12-hour clock %p",
|
||||
"(%%r) time, 12-hour (same as %%I:%%M:%%S %%p) %r",
|
||||
"(%%u) ISO 8601: Weekday as decimal number [1 (Monday) - 7] %u",
|
||||
@@ -981,12 +1142,8 @@ static char *array[] =
|
||||
/* main routine. */
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
long time();
|
||||
|
||||
char *next;
|
||||
char string[MAXTIME];
|
||||
|
||||
@@ -997,6 +1154,8 @@ char **argv;
|
||||
|
||||
long clock;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
/* Call the function. */
|
||||
|
||||
clock = time((long *) 0);
|
||||
@@ -1007,6 +1166,6 @@ char **argv;
|
||||
printf("%s\n", string);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
#endif /* TEST_STRFTIME */
|
||||
|
||||
+32
-60
@@ -46,10 +46,6 @@ extern char *realloc ();
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_BCOPY) && (defined (HAVE_STRING_H) || defined (STDC_HEADERS))
|
||||
# define bcopy(s, d, n) memcpy ((d), (s), (n))
|
||||
#endif
|
||||
|
||||
#else /* not HAVE_CONFIG_H */
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
@@ -64,17 +60,11 @@ char *realloc ();
|
||||
#include <string.h>
|
||||
#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 _POSIX_VERSION
|
||||
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#endif /* not HAVE_CONFIG_H */
|
||||
|
||||
@@ -110,30 +100,31 @@ int bufsize = 128;
|
||||
#endif
|
||||
|
||||
#ifndef emacs
|
||||
static void memory_out (void);
|
||||
static void *xmalloc (size_t);
|
||||
static void *xrealloc (void *, size_t);
|
||||
|
||||
static void
|
||||
memory_out ()
|
||||
memory_out (void)
|
||||
{
|
||||
write (2, "virtual memory exhausted\n", 25);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static char *
|
||||
xmalloc (size)
|
||||
unsigned size;
|
||||
static void *
|
||||
xmalloc (size_t size)
|
||||
{
|
||||
register char *tem = malloc (size);
|
||||
register void *tem = malloc (size);
|
||||
|
||||
if (!tem)
|
||||
memory_out ();
|
||||
return tem;
|
||||
}
|
||||
|
||||
static char *
|
||||
xrealloc (ptr, size)
|
||||
char *ptr;
|
||||
unsigned size;
|
||||
static void *
|
||||
xrealloc (void *ptr, size_t size)
|
||||
{
|
||||
register char *tem = realloc (ptr, size);
|
||||
register void *tem = realloc (ptr, size);
|
||||
|
||||
if (!tem)
|
||||
memory_out ();
|
||||
@@ -147,15 +138,15 @@ xrealloc (ptr, size)
|
||||
for tgetnum, tgetflag and tgetstr to find. */
|
||||
static char *term_entry;
|
||||
|
||||
static char *tgetst1 ();
|
||||
static char *find_capability (char *, char *);
|
||||
static char *tgetst1 (char *, char **);
|
||||
|
||||
/* Search entry BP for capability CAP.
|
||||
Return a pointer to the capability (in BP) if found,
|
||||
0 if not found. */
|
||||
|
||||
static char *
|
||||
find_capability (bp, cap)
|
||||
register char *bp, *cap;
|
||||
find_capability (char *bp, char *cap)
|
||||
{
|
||||
for (; *bp; bp++)
|
||||
if (bp[0] == ':'
|
||||
@@ -167,8 +158,7 @@ find_capability (bp, cap)
|
||||
|
||||
__private_extern__
|
||||
int
|
||||
tgetnum (cap)
|
||||
char *cap;
|
||||
tgetnum (char *cap)
|
||||
{
|
||||
register char *ptr = find_capability (term_entry, cap);
|
||||
if (!ptr || ptr[-1] != '#')
|
||||
@@ -178,8 +168,7 @@ tgetnum (cap)
|
||||
|
||||
__private_extern__
|
||||
int
|
||||
tgetflag (cap)
|
||||
char *cap;
|
||||
tgetflag (char *cap)
|
||||
{
|
||||
register char *ptr = find_capability (term_entry, cap);
|
||||
return ptr && ptr[-1] == ':';
|
||||
@@ -192,9 +181,7 @@ tgetflag (cap)
|
||||
|
||||
__private_extern__
|
||||
char *
|
||||
tgetstr (cap, area)
|
||||
char *cap;
|
||||
char **area;
|
||||
tgetstr (char *cap, char **area)
|
||||
{
|
||||
register char *ptr = find_capability (term_entry, cap);
|
||||
if (!ptr || (ptr[-1] != '=' && ptr[-1] != '~'))
|
||||
@@ -220,9 +207,7 @@ static char esctab[]
|
||||
or NULL if PTR is NULL. */
|
||||
|
||||
static char *
|
||||
tgetst1 (ptr, area)
|
||||
char *ptr;
|
||||
char **area;
|
||||
tgetst1 (char *ptr, char **area)
|
||||
{
|
||||
register char *p, *r;
|
||||
register int c;
|
||||
@@ -313,10 +298,7 @@ static int speeds[] =
|
||||
|
||||
__private_extern__
|
||||
int
|
||||
tputs (str, nlines, outfun)
|
||||
register char *str;
|
||||
int nlines;
|
||||
register int (*outfun) ();
|
||||
tputs (char *str, int nlines, int (*outfun)(int))
|
||||
{
|
||||
register int padcount = 0;
|
||||
register int speed;
|
||||
@@ -392,10 +374,10 @@ struct buffer
|
||||
|
||||
/* Forward declarations of static functions. */
|
||||
|
||||
static int scan_file ();
|
||||
static char *gobble_line ();
|
||||
static int compare_contin ();
|
||||
static int name_match ();
|
||||
static int scan_file (char *, int, struct buffer *);
|
||||
static char *gobble_line (int, struct buffer *, char *);
|
||||
static int compare_contin (char *, char *);
|
||||
static int name_match (char *, char *);
|
||||
|
||||
#ifdef VMS
|
||||
|
||||
@@ -451,8 +433,7 @@ valid_filename_p (fn)
|
||||
|
||||
__private_extern__
|
||||
int
|
||||
tgetent (bp, name)
|
||||
char *bp, *name;
|
||||
tgetent (char *bp, char *name)
|
||||
{
|
||||
register char *termcap_name;
|
||||
register int fd;
|
||||
@@ -462,7 +443,7 @@ tgetent (bp, name)
|
||||
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;
|
||||
|
||||
@@ -621,10 +602,7 @@ tgetent (bp, name)
|
||||
or 0 if no entry is found in the file. */
|
||||
|
||||
static int
|
||||
scan_file (str, fd, bufp)
|
||||
char *str;
|
||||
int fd;
|
||||
register struct buffer *bufp;
|
||||
scan_file (char *str, int fd, struct buffer *bufp)
|
||||
{
|
||||
register char *end;
|
||||
|
||||
@@ -661,8 +639,7 @@ scan_file (str, fd, bufp)
|
||||
by termcap entry LINE. */
|
||||
|
||||
static int
|
||||
name_match (line, name)
|
||||
char *line, *name;
|
||||
name_match (char *line, char *name)
|
||||
{
|
||||
register char *tem;
|
||||
|
||||
@@ -677,8 +654,7 @@ name_match (line, name)
|
||||
}
|
||||
|
||||
static int
|
||||
compare_contin (str1, str2)
|
||||
register char *str1, *str2;
|
||||
compare_contin (char *str1, char *str2)
|
||||
{
|
||||
register int c1, c2;
|
||||
while (1)
|
||||
@@ -718,10 +694,7 @@ compare_contin (str1, str2)
|
||||
thing as one line. The caller decides when a line is continued. */
|
||||
|
||||
static char *
|
||||
gobble_line (fd, bufp, append_end)
|
||||
int fd;
|
||||
register struct buffer *bufp;
|
||||
char *append_end;
|
||||
gobble_line (int fd, struct buffer *bufp, char *append_end)
|
||||
{
|
||||
register char *end;
|
||||
register int nread;
|
||||
@@ -754,7 +727,7 @@ gobble_line (fd, bufp, append_end)
|
||||
else
|
||||
{
|
||||
append_end -= bufp->ptr - buf;
|
||||
bcopy (bufp->ptr, buf, bufp->full -= bufp->ptr - buf);
|
||||
memcpy (buf, bufp->ptr, bufp->full -= bufp->ptr - buf);
|
||||
bufp->ptr = buf;
|
||||
}
|
||||
if (!(nread = read (fd, buf + bufp->full, bufp->size - bufp->full)))
|
||||
@@ -799,8 +772,7 @@ main (argc, argv)
|
||||
printf ("am: %d\n", tgetflag ("am"));
|
||||
}
|
||||
|
||||
tprint (cap)
|
||||
char *cap;
|
||||
tprint (char *cap)
|
||||
{
|
||||
char *x = tgetstr (cap, 0);
|
||||
register char *y;
|
||||
|
||||
+15
-37
@@ -38,16 +38,8 @@ extern char *realloc ();
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_BCOPY) && (defined (HAVE_STRING_H) || defined (STDC_HEADERS))
|
||||
# define bcopy(s, d, n) memcpy ((d), (s), (n))
|
||||
#endif
|
||||
|
||||
#else /* not HAVE_CONFIG_H */
|
||||
|
||||
#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
|
||||
#define bcopy(s, d, n) memcpy ((d), (s), (n))
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -72,23 +64,20 @@ memory_out ()
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static char *
|
||||
xmalloc (size)
|
||||
unsigned size;
|
||||
static void *
|
||||
xmalloc (size_t size)
|
||||
{
|
||||
register char *tem = malloc (size);
|
||||
register void *tem = malloc (size);
|
||||
|
||||
if (!tem)
|
||||
memory_out ();
|
||||
return tem;
|
||||
}
|
||||
|
||||
static char *
|
||||
xrealloc (ptr, size)
|
||||
char *ptr;
|
||||
unsigned size;
|
||||
static void *
|
||||
xrealloc (void *ptr, size_t size)
|
||||
{
|
||||
register char *tem = realloc (ptr, size);
|
||||
register void *tem = realloc (ptr, size);
|
||||
|
||||
if (!tem)
|
||||
memory_out ();
|
||||
@@ -108,15 +97,11 @@ xrealloc (ptr, size)
|
||||
|
||||
The fourth and following args to tparam serve as the parameter values. */
|
||||
|
||||
static char *tparam1 ();
|
||||
static char *tparam1 (char *, char *, int, char *, char *, int *);
|
||||
|
||||
/* VARARGS 2 */
|
||||
char *
|
||||
tparam (string, outstring, len, arg0, arg1, arg2, arg3)
|
||||
char *string;
|
||||
char *outstring;
|
||||
int len;
|
||||
int arg0, arg1, arg2, arg3;
|
||||
tparam (char *string, char *outstring, int len, int arg0, int arg1, int arg2, int arg3)
|
||||
{
|
||||
int arg[4];
|
||||
|
||||
@@ -134,9 +119,7 @@ static char tgoto_buf[50];
|
||||
|
||||
__private_extern__
|
||||
char *
|
||||
tgoto (cm, hpos, vpos)
|
||||
char *cm;
|
||||
int hpos, vpos;
|
||||
tgoto (char *cm, int hpos, int vpos)
|
||||
{
|
||||
int args[2];
|
||||
if (!cm)
|
||||
@@ -147,12 +130,7 @@ tgoto (cm, hpos, vpos)
|
||||
}
|
||||
|
||||
static char *
|
||||
tparam1 (string, outstring, len, up, left, argp)
|
||||
char *string;
|
||||
char *outstring;
|
||||
int len;
|
||||
char *up, *left;
|
||||
register int *argp;
|
||||
tparam1 (char *string, char *outstring, int len, char *up, char *left, int *argp)
|
||||
{
|
||||
register int c;
|
||||
register char *p = string;
|
||||
@@ -173,21 +151,21 @@ tparam1 (string, outstring, len, up, left, argp)
|
||||
if (op + 5 >= outend)
|
||||
{
|
||||
register char *new;
|
||||
int offset = op - outstring;
|
||||
|
||||
if (outlen == 0)
|
||||
{
|
||||
outlen = len + 40;
|
||||
new = (char *) xmalloc (outlen);
|
||||
outend += 40;
|
||||
bcopy (outstring, new, op - outstring);
|
||||
memcpy (new, outstring, offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
outend += outlen;
|
||||
outlen *= 2;
|
||||
new = (char *) xrealloc (outstring, outlen);
|
||||
}
|
||||
op += new - outstring;
|
||||
outend += new - outstring;
|
||||
op = new + offset;
|
||||
outend = new + outlen;
|
||||
outstring = new;
|
||||
}
|
||||
c = *p++;
|
||||
|
||||
Reference in New Issue
Block a user