X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=builtins%2Fpushd.def;h=f47b2941ac909291db123824c248758e4037d8ad;hb=f73dda092b33638d2d5e9c35375f687a607b5403;hp=c80271ffa663c7088d48d3c5eee35aceb1db079b;hpb=b72432fdcc59300c6fe7c9d6c8a31ad3447933f5;p=platform%2Fupstream%2Fbash.git diff --git a/builtins/pushd.def b/builtins/pushd.def index c80271f..f47b294 100644 --- a/builtins/pushd.def +++ b/builtins/pushd.def @@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell. 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) any later +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 ANY @@ -17,7 +17,7 @@ for more details. 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. +Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. $PRODUCES pushd.c @@ -113,7 +113,7 @@ $END #include #include "../shell.h" -#include "../maxpath.h" +#include "maxpath.h" #include "common.h" #include "builtext.h" @@ -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;