]> sjero.net Git - wget/blobdiff - src/res.c
[svn] Remove K&R support.
[wget] / src / res.c
index 6e3da1441a4ad049df1f352c9a3b6d7b62885d36..f704d429850dc27c134fba90c10d0aa3c26bd93b 100644 (file)
--- a/src/res.c
+++ b/src/res.c
@@ -73,11 +73,7 @@ so, delete this exception statement from your version.  */
 
 #include <stdio.h>
 #include <stdlib.h>
-#ifdef HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif /* HAVE_STRING_H */
+#include <string.h>
 #include <errno.h>
 #include <assert.h>
 
@@ -167,7 +163,7 @@ prune_non_exact (struct robot_specs *specs)
   for (i = 0; i < specs->count; i++)
     if (specs->paths[i].user_agent_exact_p)
       ++cnt;
-  newpaths = xmalloc (cnt * sizeof (struct path_info));
+  newpaths = xnew_array (struct path_info, cnt);
   for (i = 0, j = 0; i < specs->count; i++)
     if (specs->paths[i].user_agent_exact_p)
       newpaths[j++] = specs->paths[i];
@@ -240,8 +236,7 @@ res_parse (const char *source, int length)
      the last `user-agent' instructions.  */
   int record_count = 0;
 
-  struct robot_specs *specs = xmalloc (sizeof (struct robot_specs));
-  memset (specs, '\0', sizeof (struct robot_specs));
+  struct robot_specs *specs = xnew0 (struct robot_specs);
 
   while (1)
     {
@@ -392,7 +387,7 @@ res_parse_from_file (const char *filename)
   struct file_memory *fm = read_file (filename);
   if (!fm)
     {
-      logprintf (LOG_NOTQUIET, "Cannot open %s: %s",
+      logprintf (LOG_NOTQUIET, _("Cannot open %s: %s"),
                 filename, strerror (errno));
       return NULL;
     }
@@ -407,7 +402,7 @@ free_specs (struct robot_specs *specs)
   int i;
   for (i = 0; i < specs->count; i++)
     xfree (specs->paths[i].path);
-  FREE_MAYBE (specs->paths);
+  xfree_null (specs->paths);
   xfree (specs);
 }
 \f
@@ -417,17 +412,16 @@ free_specs (struct robot_specs *specs)
    that number is not a numerical representation of '/', decode C and
    advance the pointer.  */
 
-#define DECODE_MAYBE(c, ptr) do {                                      \
-  if (c == '%' && ISXDIGIT (ptr[1]) && ISXDIGIT (ptr[2]))              \
-    {                                                                  \
-      char decoded                                                     \
-       = (XCHAR_TO_XDIGIT (ptr[1]) << 4) + XCHAR_TO_XDIGIT (ptr[2]);   \
-      if (decoded != '/')                                              \
-       {                                                               \
-         c = decoded;                                                  \
-         ptr += 2;                                                     \
-       }                                                               \
-    }                                                                  \
+#define DECODE_MAYBE(c, ptr) do {                              \
+  if (c == '%' && ISXDIGIT (ptr[1]) && ISXDIGIT (ptr[2]))      \
+    {                                                          \
+      char decoded = X2DIGITS_TO_NUM (ptr[1], ptr[2]);         \
+      if (decoded != '/')                                      \
+       {                                                       \
+         c = decoded;                                          \
+         ptr += 2;                                             \
+       }                                                       \
+    }                                                          \
 } while (0)
 
 /* The inner matching engine: return non-zero if RECORD_PATH matches
@@ -503,11 +497,7 @@ res_register_specs (const char *host, int port, struct robot_specs *specs)
   if (!registered_specs)
     registered_specs = make_nocase_string_hash_table (0);
 
-  /* Required to shut up the compiler. */
-  old    = NULL;
-  hp_old = NULL;
-
-  if (hash_table_get_pair (registered_specs, hp, hp_old, old))
+  if (hash_table_get_pair (registered_specs, hp, &hp_old, &old))
     {
       if (old)
        free_specs (old);