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

32
alias.c
View file

@ -7,7 +7,7 @@
Bash 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)
the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Bash; 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. */
#include "config.h"
@ -37,6 +37,10 @@
#include "externs.h"
#include "alias.h"
#if defined (PROGRAMMABLE_COMPLETION)
# include "pcomplete.h"
#endif
static int qsort_alias_compare ();
/* Non-zero means expand all words on the line. Otherwise, expand
@ -121,6 +125,9 @@ add_alias (name, value)
elt = add_hash_item (savestring (name), aliases);
elt->data = (char *)temp;
#if defined (PROGRAMMABLE_COMPLETION)
set_itemlist_dirty (&it_aliases);
#endif
}
}
@ -155,6 +162,9 @@ remove_alias (name)
free_alias_data (elt->data);
free (elt->key); /* alias name */
free (elt); /* XXX */
#if defined (PROGRAMMABLE_COMPLETION)
set_itemlist_dirty (&it_aliases);
#endif
return (aliases->nentries);
}
return (-1);
@ -170,6 +180,9 @@ delete_all_aliases ()
flush_hash_table (aliases, free_alias_data);
dispose_hash_table (aliases);
aliases = (HASH_TABLE *)NULL;
#if defined (PROGRAMMABLE_COMPLETION)
set_itemlist_dirty (&it_aliases);
#endif
}
/* Return an array of aliases that satisfy the conditions tested by FUNCTION.
@ -433,21 +446,22 @@ char *
alias_expand (string)
char *string;
{
int line_len = 1 + strlen (string);
char *line = (char *)xmalloc (line_len);
register int i, j, start;
char *token = xmalloc (line_len);
int tl, real_start, expand_next, expand_this_token;
char *line, *token;
int line_len, tl, real_start, expand_next, expand_this_token;
alias_t *alias;
line_len = strlen (string) + 1;
line = xmalloc (line_len);
token = xmalloc (line_len);
line[0] = i = 0;
expand_next = 0;
command_word = 1; /* initialized to expand the first word on the line */
/* Each time through the loop we find the next word in line. If it
has an alias, substitute
the alias value. If the value ends in ` ', then try again
with the next word. Else, if there is no value, or if
has an alias, substitute the alias value. If the value ends in ` ',
then try again with the next word. Else, if there is no value, or if
the value does not end in space, we are done. */
for (;;)