X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Freadtokens.c;h=e826c8daabf7ad7f2ef0c81e07b67093146de948;hb=dca1eba100e85c0bd42db59fc81dffa3390c7374;hp=74585a58693570d79821e9ae474b60d6ee32948e;hpb=40ea7eb653ee5210733a9c5abe0d4a5fd52bc703;p=gnulib.git diff --git a/lib/readtokens.c b/lib/readtokens.c index 74585a586..e826c8daa 100644 --- a/lib/readtokens.c +++ b/lib/readtokens.c @@ -1,5 +1,5 @@ /* readtokens.c -- Functions for reading tokens from an input stream. - Copyright (C) 1990-1991, 1999, 2001, 2003 Jim Meyering. + Copyright (C) 1990-1991, 1999, 2001, 2003 Free Software Foundation, Inc. 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 @@ -31,24 +31,12 @@ # include #endif -#include - -#ifdef STDC_HEADERS -# include -#endif +#include "readtokens.h" -#if defined (STDC_HEADERS) || defined(HAVE_STRING_H) -# include -/* An ANSI string.h and pre-ANSI memory.h might conflict. */ -# if !defined (STDC_HEADERS) && defined (HAVE_MEMORY_H) -# include -# endif /* not STDC_HEADERS and HAVE_MEMORY_H */ -#else /* not STDC_HEADERS and not HAVE_STRING_H */ -# include -/* memory.h and strings.h conflict on some systems. */ -#endif /* not STDC_HEADERS and not HAVE_STRING_H */ +#include +#include +#include -#include "readtokens.h" #include "unlocked-io.h" #include "xalloc.h" @@ -58,11 +46,10 @@ /* Initialize a tokenbuffer. */ void -init_tokenbuffer (tokenbuffer) - token_buffer *tokenbuffer; +init_tokenbuffer (token_buffer *tokenbuffer) { tokenbuffer->size = INITIAL_TOKEN_LENGTH; - tokenbuffer->buffer = ((char *) xmalloc (INITIAL_TOKEN_LENGTH)); + tokenbuffer->buffer = xmalloc (INITIAL_TOKEN_LENGTH); } /* Read a token from `stream' into `tokenbuffer'. @@ -184,8 +171,8 @@ readtokens (FILE *stream, else projected_n_tokens = 64; sz = projected_n_tokens; - tokens = (char **) xmalloc (sz * sizeof (char *)); - lengths = (long *) xmalloc (sz * sizeof (long)); + tokens = xmalloc (sz * sizeof (char *)); + lengths = xmalloc (sz * sizeof (long)); init_tokenbuffer (token); for (;;) @@ -195,8 +182,8 @@ readtokens (FILE *stream, if (n_tokens >= sz) { sz *= 2; - tokens = (char **) xrealloc (tokens, sz * sizeof (char *)); - lengths = (long *) xrealloc (lengths, sz * sizeof (long)); + tokens = xrealloc (tokens, sz * sizeof (char *)); + lengths = xrealloc (lengths, sz * sizeof (long)); } if (token_length < 0) @@ -206,7 +193,7 @@ readtokens (FILE *stream, lengths[n_tokens] = -1; break; } - tmp = (char *) xmalloc ((token_length + 1) * sizeof (char)); + tmp = xmalloc ((token_length + 1) * sizeof (char)); lengths[n_tokens] = token_length; tokens[n_tokens] = strncpy (tmp, token->buffer, (unsigned) (token_length + 1));