aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tilde
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>2001-11-13 17:56:06 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:54 +0000
commitf73dda092b33638d2d5e9c35375f687a607b5403 (patch)
treef21584e70a444d6a1ecba0fb5e2cf79e8cce91db /lib/tilde
parent28ef6c316f1aff914bb95ac09787a3c83c1815fd (diff)
downloadandroid_external_bash-f73dda092b33638d2d5e9c35375f687a607b5403.tar.gz
android_external_bash-f73dda092b33638d2d5e9c35375f687a607b5403.tar.bz2
android_external_bash-f73dda092b33638d2d5e9c35375f687a607b5403.zip
Imported from ../bash-2.05a.tar.gz.
Diffstat (limited to 'lib/tilde')
-rw-r--r--lib/tilde/ChangeLog6
-rw-r--r--lib/tilde/Makefile.in4
-rw-r--r--lib/tilde/tilde.c59
-rw-r--r--lib/tilde/tilde.h30
4 files changed, 45 insertions, 54 deletions
diff --git a/lib/tilde/ChangeLog b/lib/tilde/ChangeLog
deleted file mode 100644
index 986db67..0000000
--- a/lib/tilde/ChangeLog
+++ /dev/null
@@ -1,6 +0,0 @@
-Mon Jul 13 12:01:51 1992 Brian Fox (bfox@cubit)
-
- * tilde.c: (tilde_expand_word) If there is no variable $HOME, then
- look up the user's home directory in the password database.
-
-
diff --git a/lib/tilde/Makefile.in b/lib/tilde/Makefile.in
index 35543b5..f53c5d7 100644
--- a/lib/tilde/Makefile.in
+++ b/lib/tilde/Makefile.in
@@ -97,8 +97,8 @@ force:
# always returns TRUE unless there really was an error installing the
# include files.
install:
- $(INSTALL_DATA) -c -m 644 $(LIBRARY_NAME) $(bindir)/$(LIBRARY_NAME)
- -test -n "$(RANLIB)" && $(RANLIB) -t $(bindir)/$(LIBRARY_NAME)
+ $(INSTALL_DATA) -c -m 644 $(LIBRARY_NAME) $(libdir)/$(LIBRARY_NAME)
+ -test -n "$(RANLIB)" && $(RANLIB) -t $(libdir)/$(LIBRARY_NAME)
clean:
$(RM) -f $(OBJECTS) $(LIBRARY_NAME)
diff --git a/lib/tilde/tilde.c b/lib/tilde/tilde.c
index 7f33db4..6e4f116 100644
--- a/lib/tilde/tilde.c
+++ b/lib/tilde/tilde.c
@@ -48,22 +48,21 @@
#include "tilde.h"
#if defined (TEST) || defined (STATIC_MALLOC)
-static char *xmalloc (), *xrealloc ();
+static void *xmalloc (), *xrealloc ();
#else
-extern char *xmalloc __P((int));
-extern char *xrealloc __P((void *, int));
+# include "xmalloc.h"
#endif /* TEST || STATIC_MALLOC */
#if !defined (HAVE_GETPW_DECLS)
-extern struct passwd *getpwuid __P((uid_t));
-extern struct passwd *getpwnam __P((const char *));
+extern struct passwd *getpwuid PARAMS((uid_t));
+extern struct passwd *getpwnam PARAMS((const char *));
#endif /* !HAVE_GETPW_DECLS */
#if !defined (savestring)
# ifndef strcpy
extern char *strcpy ();
# endif
-#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
+#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
#endif /* !savestring */
#if !defined (NULL)
@@ -77,8 +76,8 @@ extern char *strcpy ();
/* 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 *sh_get_home_dir __P((void));
-extern char *sh_get_env_value __P((const char *));
+extern char *sh_get_home_dir PARAMS((void));
+extern char *sh_get_env_value PARAMS((const char *));
/* The default value of tilde_additional_prefixes. This is set to
whitespace preceding a tilde so that simple programs which do not
@@ -114,12 +113,17 @@ char **tilde_additional_prefixes = (char **)default_prefixes;
`:' and `=~'. */
char **tilde_additional_suffixes = (char **)default_suffixes;
+static int tilde_find_prefix PARAMS((const char *, int *));
+static int tilde_find_suffix PARAMS((const char *));
+static char *isolate_tilde_prefix PARAMS((const char *, int *));
+static char *glue_prefix_and_suffix PARAMS((char *, const char *, int));
+
/* Find the start of a tilde expansion in STRING, and return the index of
the tilde which starts the expansion. Place the length of the text
which identified this tilde starter in LEN, excluding the tilde itself. */
static int
tilde_find_prefix (string, len)
- char *string;
+ const char *string;
int *len;
{
register int i, j, string_len;
@@ -154,7 +158,7 @@ tilde_find_prefix (string, len)
the character which ends the tilde definition. */
static int
tilde_find_suffix (string)
- char *string;
+ const char *string;
{
register int i, j, string_len;
register char **suffixes;
@@ -190,9 +194,9 @@ tilde_expand (string)
result_index = result_size = 0;
if (result = strchr (string, '~'))
- result = xmalloc (result_size = (strlen (string) + 16));
+ result = (char *)xmalloc (result_size = (strlen (string) + 16));
else
- result = xmalloc (result_size = (strlen (string) + 1));
+ result = (char *)xmalloc (result_size = (strlen (string) + 1));
/* Scan through STRING expanding tildes as we come to them. */
while (1)
@@ -206,7 +210,7 @@ tilde_expand (string)
/* Copy the skipped text into the result. */
if ((result_index + start + 1) > result_size)
- result = xrealloc (result, 1 + (result_size += (start + 20)));
+ result = (char *)xrealloc (result, 1 + (result_size += (start + 20)));
strncpy (result + result_index, string, start);
result_index += start;
@@ -223,7 +227,7 @@ tilde_expand (string)
break;
/* Expand the entire tilde word, and copy it into RESULT. */
- tilde_word = xmalloc (1 + end);
+ tilde_word = (char *)xmalloc (1 + end);
strncpy (tilde_word, string, end);
tilde_word[end] = '\0';
string += end;
@@ -239,7 +243,7 @@ tilde_expand (string)
#endif
{
if ((result_index + len + 1) > result_size)
- result = xrealloc (result, 1 + (result_size += (len + 20)));
+ result = (char *)xrealloc (result, 1 + (result_size += (len + 20)));
strcpy (result + result_index, expansion);
result_index += len;
@@ -257,13 +261,13 @@ tilde_expand (string)
the location it points to. */
static char *
isolate_tilde_prefix (fname, lenp)
- char *fname;
+ const char *fname;
int *lenp;
{
char *ret;
int i;
- ret = xmalloc (strlen (fname));
+ ret = (char *)xmalloc (strlen (fname));
#if defined (__MSDOS__)
for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
#else
@@ -280,7 +284,8 @@ isolate_tilde_prefix (fname, lenp)
SUFFIND. */
static char *
glue_prefix_and_suffix (prefix, suffix, suffind)
- char *prefix, *suffix;
+ char *prefix;
+ const char *suffix;
int suffind;
{
char *ret;
@@ -288,7 +293,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
plen = (prefix && *prefix) ? strlen (prefix) : 0;
slen = strlen (suffix + suffind);
- ret = xmalloc (plen + slen + 1);
+ ret = (char *)xmalloc (plen + slen + 1);
if (plen)
strcpy (ret, prefix);
strcpy (ret + plen, suffix + suffind);
@@ -412,28 +417,28 @@ main (argc, argv)
static void memory_error_and_abort ();
-static char *
+static void *
xmalloc (bytes)
- int bytes;
+ size_t bytes;
{
- char *temp = (char *)malloc (bytes);
+ void *temp = (char *)malloc (bytes);
if (!temp)
memory_error_and_abort ();
return (temp);
}
-static char *
+static void *
xrealloc (pointer, bytes)
- char *pointer;
+ void *pointer;
int bytes;
{
- char *temp;
+ void *temp;
if (!pointer)
- temp = (char *)malloc (bytes);
+ temp = malloc (bytes);
else
- temp = (char *)realloc (pointer, bytes);
+ temp = realloc (pointer, bytes);
if (!temp)
memory_error_and_abort ();
diff --git a/lib/tilde/tilde.h b/lib/tilde/tilde.h
index d3966a6..0df608b 100644
--- a/lib/tilde/tilde.h
+++ b/lib/tilde/tilde.h
@@ -24,35 +24,27 @@
#if !defined (_TILDE_H_)
# define _TILDE_H_
+#if defined (HAVE_CONFIG_H)
+# include <config.h>
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
/* A function can be defined using prototypes and compile on both ANSI C
and traditional C compilers with something like this:
- extern char *func __P((char *, char *, int)); */
+ extern char *func PARAMS((char *, char *, int)); */
-#if !defined (__P)
+#if !defined (PARAMS)
# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
-# define __P(protos) protos
+# define PARAMS(protos) protos
# else
-# define __P(protos) ()
+# define PARAMS(protos) ()
# endif
#endif
-#if !defined (__STDC__) && !defined (__cplusplus)
-# if defined (__GNUC__) /* gcc with -traditional */
-# if !defined (const)
-# define const __const
-# endif /* !const */
-# else /* !__GNUC__ */
-# if !defined (const)
-# define const
-# endif /* !const */
-# endif /* !__GNUC__ */
-#endif /* !__STDC__ && !__cplusplus */
-
-typedef char *tilde_hook_func_t __P((char *));
+typedef char *tilde_hook_func_t PARAMS((char *));
/* If non-null, this contains the address of a function that the application
wants called before trying the standard tilde expansions. The function
@@ -77,11 +69,11 @@ extern char **tilde_additional_prefixes;
extern char **tilde_additional_suffixes;
/* Return a new string which is the result of tilde expanding STRING. */
-extern char *tilde_expand __P((const char *));
+extern char *tilde_expand PARAMS((const char *));
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
tilde. If there is no expansion, call tilde_expansion_failure_hook. */
-extern char *tilde_expand_word __P((const char *));
+extern char *tilde_expand_word PARAMS((const char *));
#ifdef __cplusplus
}