diff options
Diffstat (limited to 'lib/nextelem.c')
-rw-r--r-- | lib/nextelem.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/nextelem.c b/lib/nextelem.c index a4bd8dd6..4b9ddc1f 100644 --- a/lib/nextelem.c +++ b/lib/nextelem.c @@ -1,28 +1,29 @@ /* Return the next element of a path. - Copyright (C) 1992,2005 Free Software Foundation, Inc. + Copyright (C) 1992 Free Software Foundation, Inc. - This program is free software: you can redistribute it and/or modify + This program 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 3 of the License, or - (at your option) any later version. - + the Free Software Foundation; either version 2, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* Written by David MacKenzie <djm@gnu.org>, +/* Written by David MacKenzie <djm@gnu.ai.mit.edu>, inspired by John P. Rouillard <rouilj@cs.umb.edu>. */ +#ifdef HAVE_CONFIG_H #include <config.h> - +#endif #include <stdio.h> -#if defined HAVE_STRING_H || defined STDC_HEADERS +#if defined(HAVE_STRING_H) || defined(STDC_HEADERS) #include <string.h> #else #include <strings.h> @@ -30,12 +31,9 @@ #define strchr index #endif #endif -#if defined STDC_HEADERS -#include <stdlib.h> -#endif - -#include "nextelem.h" +char *strdup (); +void free (); /* Return the next element of a colon-separated path. A null entry in the path is equivalent to "." (the current directory). @@ -45,7 +43,8 @@ return NULL if there are no more elements. */ char * -next_element (const char *new_path, int curdir_ok) +next_element (new_path) + char *new_path; { static char *path = NULL; /* Freshly allocated copy of NEW_PATH. */ static char *end; /* Start of next element to return. */ @@ -66,7 +65,7 @@ next_element (const char *new_path, int curdir_ok) if (final_colon) { final_colon = 0; - return curdir_ok ? "." : ""; + return "."; } return NULL; } @@ -79,7 +78,7 @@ next_element (const char *new_path, int curdir_ok) { /* An empty path element. */ *end++ = '\0'; - return curdir_ok ? "." : ""; + return "."; } else if (end == NULL) { |