This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / readline / tilde.c
index 777b6559223798df6b1c1a5073d5f5f495614afa..d1853bd63d62326fb82724264ff72a807821aeff 100644 (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 2, or (at your option) any
+   Free Software Foundation; either version 1, 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, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 #if defined (HAVE_CONFIG_H)
 #  include <config.h>
 
 #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
@@ -77,11 +67,17 @@ 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 __P((void));
-extern char *get_env_value __P((char *));
+extern char *get_home_dir ();
+extern char *get_env_value ();
 
 /* The default value of tilde_additional_prefixes.  This is set to
    whitespace preceding a tilde so that simple programs which do not
@@ -126,9 +122,7 @@ tilde_find_prefix (string, len)
      int *len;
 {
   register int i, j, string_len;
-  register char **prefixes;
-
-  prefixes = tilde_additional_prefixes;
+  register char **prefixes = tilde_additional_prefixes;
 
   string_len = strlen (string);
   *len = 0;
@@ -167,11 +161,7 @@ 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++)
@@ -235,18 +225,11 @@ tilde_expand (string)
       free (tilde_word);
 
       len = strlen (expansion);
-#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)));
+      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);
     }
 
@@ -267,11 +250,7 @@ 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)
@@ -292,7 +271,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
   plen = (prefix && *prefix) ? strlen (prefix) : 0;
   slen = strlen (suffix + suffind);
   ret = xmalloc (plen + slen + 1);
-  if (plen)
+  if (prefix && *prefix)
     strcpy (ret, prefix);
   strcpy (ret + plen, suffix + suffind);
   return ret;
This page took 0.03523 seconds and 4 git commands to generate.