diff options
author | Elena Zannoni <ezannoni@kwikemart.cygnus.com> | 2000-07-09 17:20:00 +0000 |
---|---|---|
committer | Elena Zannoni <ezannoni@kwikemart.cygnus.com> | 2000-07-09 17:20:00 +0000 |
commit | 1b17e766659d93d1e7bd6633bf78132e1abb3568 (patch) | |
tree | 6fa61b8b0140bca0772cdf39390405ca20fec949 /readline/tilde.c | |
parent | d0352a18a504a4e7b761f6b3264cf11347d8d056 (diff) | |
download | gdb-1b17e766659d93d1e7bd6633bf78132e1abb3568.zip gdb-1b17e766659d93d1e7bd6633bf78132e1abb3568.tar.gz gdb-1b17e766659d93d1e7bd6633bf78132e1abb3568.tar.bz2 |
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
Diffstat (limited to 'readline/tilde.c')
-rw-r--r-- | readline/tilde.c | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/readline/tilde.c b/readline/tilde.c index d1853bd..777b655 100644 --- a/readline/tilde.c +++ b/readline/tilde.c @@ -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; |