The patch below places the contents of argv into P0.  At the moment it
has the name of the script file in question in P0[0]; I haven't yet
decided if this is to be construed as a feature or a bug.  ;^)

A little test script to see that this is working right:

        set I0, P0
        set I1, 0

        print "start\n"

LOOP:
        ge I1, I0, OUT
        set S0, P0, I1

        print " "
        print I1
        print ": "
        print S0
        print "\n"

        inc I1
        branch LOOP

OUT:
        print "done\n"
        end

--Brent Dax
[EMAIL PROTECTED]
Parrot Configure pumpking and regex hacker
Check out the Parrot FAQ: http://www.panix.com/~ziggy/parrot.html (no,
it's not mine)

<obra> mmmm. hawt sysadmin chx0rs
<lathos> This is sad. I know of *a* hawt sysamin chx0r.
<obra> I know more than a few.
<lathos> obra: There are two? Are you sure it's not the same one?


--- /parrot-cvs/embed.c Wed Jan 30 06:41:34 2002
+++ /parrot/embed.c     Thu Jan 31 01:49:26 2002
@@ -139,6 +139,9 @@

 void
 Parrot_runcode(struct Parrot_Interp *interpreter, int argc, char
*argv[]) {
+    INTVAL i;
+    PMC* userargv;
+
     if(interpreter->flags & PARROT_DEBUG_FLAG) {
         fprintf(stderr, "Parrot VM: Debugging enabled.\n");

@@ -159,6 +162,24 @@
         exit(1);
     }
 #endif
+
+    if(interpreter->flags & PARROT_DEBUG_FLAG) {
+        fprintf(stderr, "Parrot VM: Setting up ARGV array in P0.
Current argc: %d\n", argc);
+    }
+
+    userargv=pmc_new(interpreter, enum_class_PerlArray);
+
+    for(i=0; i < argc; i++) {
+        if(interpreter->flags & PARROT_DEBUG_FLAG) {
+            fprintf(stderr, "\t%d: %s\n", i, argv[i]);
+        }
+
+        userargv->vtable->set_string_index(interpreter, userargv,
+            string_make(interpreter, argv[i], strlen(argv[i]), 0, 0,
0), i
+        );
+    }
+
+    interpreter->pmc_reg.registers[0]=userargv;

     runops(interpreter, interpreter->code, 0);

--- /parrot-cvs/test_main.c     Thu Jan 31 01:18:18 2002
+++ /parrot/test_main.c Thu Jan 31 01:45:20 2002
@@ -96,7 +96,7 @@
     }

 OUT:
-    (*argc)--;
+
     return (*(argv++))[0];
 }


Reply via email to