]> sjero.net Git - wget/blobdiff - src/cmpt.c
[svn] Convert URLs in <form action=...>.
[wget] / src / cmpt.c
index 542151315174cd1d5b8c036e6840fc8532457116..81502d779d689988dd3f05640031ea306ff43bf1 100644 (file)
@@ -1209,8 +1209,10 @@ strptime (buf, format, tm)
 
 
 #ifndef HAVE_USLEEP
-/* A simple usleep implementation based on select().  This will
-   probably not work on Windows.  */
+#ifndef WINDOWS
+
+/* A simple usleep implementation based on select().  For Unix and
+   Unix-like systems.  */
 
 int
 usleep (unsigned long usec)
@@ -1221,39 +1223,26 @@ usleep (unsigned long usec)
   select (0, NULL, NULL, NULL, &tm);
   return 0;
 }
-#endif /* not HAVE_USLEEP */
-
-
-#ifndef HAVE_RANDOM
-/* For the systems without random: a really simple congruential RNG,
-   only good enough for what Wget uses it for.  Before you panic: this
-   is not used for any kind of cryptography.  */
-
-static long random_seed;
 
-#define RANDOM_A 9301
-#define RANDOM_C 49297
-#define RANDOM_M 233280
+#endif /* not WINDOWS */
+#endif /* not HAVE_USLEEP */
 
-static int
-random_1 (void)
-{
-  if (!random_seed)
-    random_seed = time (NULL);
-  random_seed = (random_seed * RANDOM_A + RANDOM_C) % RANDOM_M;
-  return random_seed;
-}
 
-long
-random (void)
+#ifndef HAVE_MEMMOVE
+void *
+memmove (char *dest, const char *source, unsigned length)
 {
-  /* Upper bits of random() are a bit more random.  Compose random()
-     from higher bits of three call to random().  */
-  unsigned r1 = random_1 () >> 8;
-  unsigned r2 = random_1 () >> 4;
-  unsigned r3 = random_1 ();
-  long result = r1 ^ r2 ^ r3;
-
-  return result;
+  char *d0 = dest;
+  if (source < dest)
+    /* Moving from low mem to hi mem; start at end.  */
+    for (source += length, dest += length; length; --length)
+      *--dest = *--source;
+  else if (source != dest)
+    {
+      /* Moving from hi mem to low mem; start at beginning.  */
+      for (; length; --length)
+       *dest++ = *source++;
+    }
+  return (void *) d0;
 }
-#endif /* not HAVE_RANDOM */
+#endif /* not HAVE_MEMMOVE */