Imported from ../bash-2.04.tar.gz.

This commit is contained in:
Jari Aalto 2000-03-17 21:46:59 +00:00
commit bb70624e96
387 changed files with 28522 additions and 9334 deletions

View file

@ -7,7 +7,7 @@
Readline is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 1, or (at your option) any
Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
@ -47,12 +47,22 @@
#include "tilde.h"
#if defined (TEST) || defined (STATIC_MALLOC)
static char *xmalloc (), *xrealloc ();
#else
# if defined __STDC__
extern char *xmalloc (int);
extern char *xrealloc (void *, int);
# else
extern char *xmalloc (), *xrealloc ();
# endif /* !__STDC__ */
#endif /* TEST || STATIC_MALLOC */
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid (), *getpwnam ();
#endif /* !HAVE_GETPW_DECLS */
#if !defined (savestring)
extern char *xmalloc ();
# ifndef strcpy
extern char *strcpy ();
# endif
@ -67,17 +77,11 @@ extern char *strcpy ();
# endif /* !__STDC__ */
#endif /* !NULL */
#if defined (TEST) || defined (STATIC_MALLOC)
static char *xmalloc (), *xrealloc ();
#else
extern char *xmalloc (), *xrealloc ();
#endif /* TEST || STATIC_MALLOC */
/* If being compiled as part of bash, these will be satisfied from
variables.o. If being compiled as part of readline, they will
be satisfied from shell.o. */
extern char *get_home_dir ();
extern char *get_env_value ();
extern char *get_home_dir __P((void));
extern char *get_env_value __P((char *));
/* The default value of tilde_additional_prefixes. This is set to
whitespace preceding a tilde so that simple programs which do not
@ -122,7 +126,9 @@ tilde_find_prefix (string, len)
int *len;
{
register int i, j, string_len;
register char **prefixes = tilde_additional_prefixes;
register char **prefixes;
prefixes = tilde_additional_prefixes;
string_len = strlen (string);
*len = 0;
@ -161,7 +167,11 @@ tilde_find_suffix (string)
for (i = 0; i < string_len; i++)
{
#if defined (__MSDOS__)
if (string[i] == '/' || string[i] == '\\' /* || !string[i] */)
#else
if (string[i] == '/' /* || !string[i] */)
#endif
break;
for (j = 0; suffixes && suffixes[j]; j++)
@ -225,11 +235,18 @@ tilde_expand (string)
free (tilde_word);
len = strlen (expansion);
if ((result_index + len + 1) > result_size)
result = xrealloc (result, 1 + (result_size += (len + 20)));
#ifdef __CYGWIN32__
/* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when
$HOME for `user' is /. On cygwin, // denotes a network drive. */
if (len > 1 || *expansion != '/' || *string != '/')
#endif
{
if ((result_index + len + 1) > result_size)
result = xrealloc (result, 1 + (result_size += (len + 20)));
strcpy (result + result_index, expansion);
result_index += len;
strcpy (result + result_index, expansion);
result_index += len;
}
free (expansion);
}
@ -250,7 +267,11 @@ isolate_tilde_prefix (fname, lenp)
int i;
ret = xmalloc (strlen (fname));
#if defined (__MSDOS__)
for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
#else
for (i = 1; fname[i] && fname[i] != '/'; i++)
#endif
ret[i - 1] = fname[i];
ret[i - 1] = '\0';
if (lenp)
@ -271,7 +292,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
plen = (prefix && *prefix) ? strlen (prefix) : 0;
slen = strlen (suffix + suffind);
ret = xmalloc (plen + slen + 1);
if (prefix && *prefix)
if (plen)
strcpy (ret, prefix);
strcpy (ret + plen, suffix + suffind);
return ret;