]> sjero.net Git - wget/commitdiff
[svn] Changes from <9t9pusol5a1.fsf@mraz.iskon.hr>.
authorhniksic <devnull@localhost>
Tue, 21 Mar 2000 15:47:45 +0000 (07:47 -0800)
committerhniksic <devnull@localhost>
Tue, 21 Mar 2000 15:47:45 +0000 (07:47 -0800)
src/ChangeLog
src/sysdep.h
src/wget.h

index 25b06058fb07eef2ca1b6f24444c24381d72f403..d12db61f16b9deef6f3f72cec1af2cf3a2c2ff5e 100644 (file)
@@ -1,3 +1,11 @@
+2000-03-21  Hrvoje Niksic  <hniksic@iskon.hr>
+
+       * wget.h (DO_REALLOC_FROM_ALLOCA): Ditto.
+
+       * sysdep.h (ISALNUM): New macro.
+       (TOLOWER): Ditto.
+       (TOUPPER): Ditto.
+
 2000-03-10  Dan Harkless  <dan-wget@dilvish.speed.net>
 
        * html.c (idmatch): Implemented checking of my new --follow-tags
index 97be28b5414cc6d0bbd890c10d8d5b6df9f6750a..1a837306204da16afe0f27382e7bf154089df732 100644 (file)
@@ -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
index ab37507ee6a12a256989409991a0283b007dca6d..1a1fdb4589f220abaf5a9b5ef4391170a0b29ea3 100644 (file)
@@ -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)