[svn:parrot] r43935 - in trunk/src: . string

cotto at svn.parrot.org cotto at svn.parrot.org
Sat Feb 13 09:48:29 UTC 2010


Author: cotto
Date: Sat Feb 13 09:48:29 2010
New Revision: 43935
URL: https://trac.parrot.org/parrot/changeset/43935

Log:
[string] add --hash-seed and -H to explicitly set the seed used for hashing

Modified:
   trunk/src/main.c
   trunk/src/string/api.c

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	Sat Feb 13 09:43:44 2010	(r43934)
+++ trunk/src/main.c	Sat Feb 13 09:48:29 2010	(r43935)
@@ -148,6 +148,7 @@
     { 'D', 'D', OPTION_optional_FLAG, { "--parrot-debug" } },
     { 'E', 'E', (OPTION_flags)0, { "--pre-process-only" } },
     { 'G', 'G', (OPTION_flags)0, { "--no-gc" } },
+    { 'H', 'H', OPTION_required_FLAG, { "--hash-seed" } },
     { 'I', 'I', OPTION_required_FLAG, { "--include" } },
     { 'L', 'L', OPTION_required_FLAG, { "--library" } },
     { 'O', 'O', OPTION_optional_FLAG, { "--optimize" } },
@@ -283,6 +284,7 @@
     "    -V --version\n"
     "    -I --include add path to include search\n"
     "    -L --library add path to library search\n"
+    "    -H --hash-seed F00F  specify hex value to use as hash seed\n"
     "    -X --dynext add path to dynamic extension search\n"
     "   <Run core options>\n"
     "    -R --runcore slow|bounds|fast|cgoto|cgp\n"
@@ -427,6 +429,12 @@
             else
                 SET_DEBUG(PARROT_MEM_STAT_DEBUG_FLAG);
             break;
+          case 'H':
+            if (opt.opt_arg && is_all_hex_digits(opt.opt_arg)) {
+                interp->hash_seed = strtoul(opt.opt_arg, NULL, 16);
+            }
+            break;
+
           case '.':  /* Give Windows Parrot hackers an opportunity to
                       * attach a debuggger. */
             fgetc(stdin);

Modified: trunk/src/string/api.c
==============================================================================
--- trunk/src/string/api.c	Sat Feb 13 09:43:44 2010	(r43934)
+++ trunk/src/string/api.c	Sat Feb 13 09:48:29 2010	(r43935)
@@ -276,7 +276,8 @@
     if (interp->parent_interpreter) {
         interp->hash_seed = interp->parent_interpreter->hash_seed;
     }
-    else {
+    /* interp is initialized from zeroed memory, so this is fine */
+    else if (interp->hash_seed == 0) {
         /* TT #64 - use an entropy source once available */
         Parrot_srand(Parrot_intval_time());
         interp->hash_seed = Parrot_uint_rand(0);


More information about the parrot-commits mailing list