From c71f174ed60b39565797048fe9c8e24f0ececa09 Mon Sep 17 00:00:00 2001 From: hniksic Date: Tue, 21 Mar 2000 07:47:45 -0800 Subject: [PATCH] [svn] Changes from <9t9pusol5a1.fsf@mraz.iskon.hr>. --- src/ChangeLog | 8 ++++++++ src/sysdep.h | 3 +++ src/wget.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 25b06058..d12db61f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2000-03-21 Hrvoje Niksic + + * wget.h (DO_REALLOC_FROM_ALLOCA): Ditto. + + * sysdep.h (ISALNUM): New macro. + (TOLOWER): Ditto. + (TOUPPER): Ditto. + 2000-03-10 Dan Harkless * html.c (idmatch): Implemented checking of my new --follow-tags diff --git a/src/sysdep.h b/src/sysdep.h index 97be28b5..1a837306 100644 --- a/src/sysdep.h +++ b/src/sysdep.h @@ -110,9 +110,12 @@ do { \ versions are used consistently across the code. */ #define ISASCII(x) isascii ((unsigned char)(x)) #define ISALPHA(x) isalpha ((unsigned char)(x)) +#define ISALNUM(x) isalnum ((unsigned char)(x)) #define ISSPACE(x) isspace ((unsigned char)(x)) #define ISDIGIT(x) isdigit ((unsigned char)(x)) #define ISXDIGIT(x) isxdigit ((unsigned char)(x)) +#define TOUPPER(x) toupper ((unsigned char)(x)) +#define TOLOWER(x) tolower ((unsigned char)(x)) /* Defined in cmpt.c: */ #ifndef HAVE_STRERROR diff --git a/src/wget.h b/src/wget.h index ab37507e..1a1fdb45 100644 --- a/src/wget.h +++ b/src/wget.h @@ -160,6 +160,35 @@ char *xstrdup PARAMS ((const char *)); XREALLOC_ARRAY (basevar, type, do_realloc_newsize); \ } while (0) +/* Use this for small stack-allocated memory chunks that might grow. + The initial array is created using alloca(), and this macro + requests it to grow. If the needed size is larger than the array, + this macro will use malloc to allocate it to new size, and copy the + old contents. After that, successive invocations behave just like + DO_REALLOC. */ +#define DO_REALLOC_FROM_ALLOCA(basevar, sizevar, needed_size, allocap, type) do \ +{ \ + /* Avoid side-effectualness. */ \ + long do_realloc_needed_size = (needed_size); \ + long do_realloc_newsize = 0; \ + while ((sizevar) < (do_realloc_needed_size)) { \ + do_realloc_newsize = 2*(sizevar); \ + if (do_realloc_newsize < 16) \ + do_realloc_newsize = 16; \ + (sizevar) = do_realloc_newsize; \ + } \ + if (do_realloc_newsize) \ + if (!allocap) \ + XREALLOC_ARRAY (basevar, type, do_realloc_newsize); \ + else \ + { \ + void *drfa_new_basevar = xmalloc (do_realloc_newsize); \ + memcpy (drfa_new_basevar, basevar, sizevar); \ + (basevar) = drfa_new_basevar; \ + allocap = 0; \ + } \ +} while (0) + /* Free FOO if it is non-NULL. */ #define FREE_MAYBE(foo) do { if (foo) free (foo); } while (0) -- 2.39.2