X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=builtins%2Fpushd.def;h=f47b2941ac909291db123824c248758e4037d8ad;hb=f73dda092b33638d2d5e9c35375f687a607b5403;hp=4866f41cdbc724874b3f67af106c27d293434a5b;hpb=bb70624e964126b7ac4ff085ba163a9c35ffa18f;p=platform%2Fupstream%2Fbash.git diff --git a/builtins/pushd.def b/builtins/pushd.def index 4866f41..f47b294 100644 --- a/builtins/pushd.def +++ b/builtins/pushd.def @@ -136,12 +136,12 @@ static int directory_list_size; /* Offset to the end of the list. */ static int directory_list_offset; -static void pushd_error (); -static void clear_directory_stack (); -static int cd_to_string (); -static int change_to_temp (); -static int get_dirstack_index (); -static void add_dirstack_element (); +static void pushd_error __P((int, char *)); +static void clear_directory_stack __P((void)); +static int cd_to_string __P((char *)); +static int change_to_temp __P((char *)); +static void add_dirstack_element __P((char *)); +static int get_dirstack_index __P((long, int, int *)); #define NOCD 0x01 #define ROTATE 0x02 @@ -186,10 +186,10 @@ pushd_builtin (list) flags |= NOCD; } else if (ISOPTION (list->word->word, '-')) - { - list = list->next; - break; - } + { + list = list->next; + break; + } else if (list->word->word[0] == '-' && list->word->word[1] == '\0') /* Let `pushd -' work like it used to. */ break; @@ -293,17 +293,17 @@ popd_builtin (list) char *which_word; which_word = (char *)NULL; - for (flags = 0, which = 0L, direction = '+'; list; list = list->next) + for (flags = 0, which = 0, direction = '+'; list; list = list->next) { if (ISOPTION (list->word->word, 'n')) - { - flags |= NOCD; - } + { + flags |= NOCD; + } else if (ISOPTION (list->word->word, '-')) - { - list = list->next; - break; - } + { + list = list->next; + break; + } else if (((direction = list->word->word[0]) == '+') || direction == '-') { if (legal_number (list->word->word + 1, &which) == 0) @@ -335,7 +335,7 @@ popd_builtin (list) (direction == '-' && which == directory_list_offset)) { i = ((flags & NOCD) == 0) ? cd_to_string (pushd_directory_list[directory_list_offset - 1]) - : EXECUTION_SUCCESS; + : EXECUTION_SUCCESS; if (i != EXECUTION_SUCCESS) return (i); free (pushd_directory_list[--directory_list_offset]); @@ -386,14 +386,14 @@ dirs_builtin (list) vflag |= 1; } else if (ISOPTION (list->word->word, '-')) - { - list = list->next; - break; - } + { + list = list->next; + break; + } else if (*list->word->word == '+' || *list->word->word == '-') - { - int sign; - if (legal_number (w = list->word->word + 1, &i) == 0) + { + int sign; + if (legal_number (w = list->word->word + 1, &i) == 0) { builtin_error (m_badarg, list->word->word); builtin_usage (); @@ -537,7 +537,8 @@ add_dirstack_element (dir) static int get_dirstack_index (ind, sign, indexp) - int ind, sign, *indexp; + long ind; + int sign, *indexp; { if (indexp) *indexp = sign > 0 ? 1 : 2; @@ -552,8 +553,10 @@ get_dirstack_index (ind, sign, indexp) *indexp = sign > 0 ? 2 : 1; return 0; } - else + else if (ind >= 0 && ind <= directory_list_offset) return (sign > 0 ? directory_list_offset - ind : ind); + else + return -1; } /* Used by the tilde expansion code. */ @@ -586,7 +589,8 @@ get_dirstack_from_string (string) #ifdef INCLUDE_UNUSED char * get_dirstack_element (ind, sign) - int ind, sign; + long ind; + int sign; { int i; @@ -598,7 +602,8 @@ get_dirstack_element (ind, sign) void set_dirstack_element (ind, sign, value) - int ind, sign; + long ind; + int sign; char *value; { int i;