cvsuser     02/03/21 20:12:43

  Modified:    .        string.c core.ops
  Log:
  Dan uses 1st of his 3 wishes.
  Implement set Sx, iy
  
  Revision  Changes    Path
  1.61      +30 -1     parrot/string.c
  
  Index: string.c
  ===================================================================
  RCS file: /cvs/public/parrot/string.c,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -w -r1.60 -r1.61
  --- string.c  21 Mar 2002 09:56:41 -0000      1.60
  +++ string.c  22 Mar 2002 04:12:43 -0000      1.61
  @@ -1,7 +1,7 @@
   /* string.c
    *  Copyright: (When this is determined...it will go here)
    *  CVS Info
  - *     $Id: string.c,v 1.60 2002/03/21 09:56:41 mrjoltcola Exp $
  + *     $Id: string.c,v 1.61 2002/03/22 04:12:43 mrjoltcola Exp $
    *  Overview:
    *     This is the api definitions for the string subsystem
    *  Data Structure and Algorithms:
  @@ -773,6 +773,35 @@
   
       return f;
   }
  +
  +STRING *
  +string_from_int(struct Parrot_Interp * interpreter, INTVAL i) {
  +    const char * digits = "0123456789";
  +    char buf[128];
  +    char *ptr = &buf[127];
  +    int neg = 0;
  +
  +    if(i < 0) {
  +        neg = 1;
  +        i = abs(i);
  +    }
  +
  +    /* Dangerous looking but no 32/64/128/.... bit int
  +     * would approach 128 characters in the buffer.
  +     */
  +    do {
  +        *--ptr = digits[i % 10];
  +        i /= 10;
  +    }
  +    while(i);
  +
  +    if(neg)
  +        *--ptr = '-';
  +
  +    return string_make(interpreter, ptr, (UINTVAL)(127 - (ptr - buf)),
  +                            NULL, 0, NULL);
  +}
  +
   
   /*
    * Local variables:
  
  
  
  1.112     +5 -0      parrot/core.ops
  
  Index: core.ops
  ===================================================================
  RCS file: /cvs/public/parrot/core.ops,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -w -r1.111 -r1.112
  --- core.ops  21 Mar 2002 22:01:50 -0000      1.111
  +++ core.ops  22 Mar 2002 04:12:43 -0000      1.112
  @@ -540,6 +540,11 @@
     goto NEXT();
   }
   
  +inline op set(out STR, in INT) {
  +  $1 = string_from_int(interpreter, $2);
  +  goto NEXT();
  +}
  +
   inline op set(out PMC, in INT) { 
     $1->vtable->set_integer_native(interpreter, $1, $2);
     goto NEXT();
  
  
  


Reply via email to