cvsuser     04/02/26 00:13:22

  Modified:    pf       pf_items.c
               src      packfile.c
  Log:
  cstring and string fetch fixes; packfile patch by Jarkko
  
  Revision  Changes    Path
  1.11      +8 -8      parrot/pf/pf_items.c
  
  Index: pf_items.c
  ===================================================================
  RCS file: /cvs/public/parrot/pf/pf_items.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -w -r1.10 -r1.11
  --- pf_items.c        25 Feb 2004 15:40:41 -0000      1.10
  +++ pf_items.c        26 Feb 2004 08:13:20 -0000      1.11
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: pf_items.c,v 1.10 2004/02/25 15:40:41 leo Exp $
  +$Id: pf_items.c,v 1.11 2004/02/26 08:13:20 leo Exp $
   
   =head1 NAME
   
  @@ -441,8 +441,8 @@
                                  flags,
                                  chartype_lookup_index(type));
   
  -    size = ROUND_UP_B(size, wordsize) / sizeof(opcode_t);
  -    *cursor += size;
  +    size = ROUND_UP_B(size, wordsize);
  +    *((unsigned char **) (cursor)) += size;
       return s;
   }
   
  @@ -536,7 +536,7 @@
       int wordsize = pf->header->wordsize;
   
       strcpy(p, (char*) (*cursor));
  -    (*cursor) += ROUND_UP_B(str_len, wordsize) / sizeof(opcode_t);
  +    *((unsigned char **) (cursor)) += ROUND_UP_B(str_len, wordsize);
       return p;
   }
   
  
  
  
  1.146     +46 -18    parrot/src/packfile.c
  
  Index: packfile.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/packfile.c,v
  retrieving revision 1.145
  retrieving revision 1.146
  diff -u -w -r1.145 -r1.146
  --- packfile.c        25 Feb 2004 15:08:23 -0000      1.145
  +++ packfile.c        26 Feb 2004 08:13:22 -0000      1.146
  @@ -2,7 +2,7 @@
   Copyright (C) 2001-2002 Gregor N. Purdy. All rights reserved.
   This program is free software. It is subject to the same license as
   Parrot itself.
  -$Id: packfile.c,v 1.145 2004/02/25 15:08:23 leo Exp $
  +$Id: packfile.c,v 1.146 2004/02/26 08:13:22 leo Exp $
   
   =head1 NAME
   
  @@ -489,8 +489,9 @@
       PackFile_assign_transforms(self);
   
   #if TRACE_PACKFILE
  -    PIO_eprintf(NULL, "wordsize: %d\n", header->wordsize);
  -    PIO_eprintf(NULL, "byteorder: %d\n", header->byteorder);
  +    PIO_eprintf(NULL, "PackFile_unpack: Wordsize %d.\n", header->wordsize);
  +    PIO_eprintf(NULL, "PackFile_unpack: Byteorder %d (%sendian).\n",
  +                header->byteorder, header->byteorder ? "big " : "little-");
   #endif
   
   #if 0
  @@ -522,32 +523,51 @@
        */
       if (header->magic != PARROT_MAGIC) {
           PIO_eprintf(NULL, "PackFile_unpack: Not a Parrot PackFile!\n");
  -        PIO_eprintf(NULL, "Magic number was [0x%08x] not [0x%08x]\n",
  +        PIO_eprintf(NULL, "Magic number was 0x%08x not 0x%08x\n",
                   header->magic, PARROT_MAGIC);
           return 0;
       }
   
  +#if TRACE_PACKFILE
  +    PIO_eprintf(NULL, "PackFile_unpack: Magic 0x%08x.\n",
  +                header->magic);
  +#endif
  +
       header->opcodetype = PF_fetch_opcode(self, &cursor);
   
   #if TRACE_PACKFILE
  -    PIO_eprintf(NULL, "PackFile_unpack(): Magic verified.\n");
  +    PIO_eprintf(NULL, "PackFile_unpack: Opcodetype 0x%x.\n",
  +                header->opcodetype);
   #endif
   
       /*
        * Unpack the dir_format
        */
   
  +#if TRACE_PACKFILE
  +    PIO_eprintf(NULL, "PackFile_unpack: Directory, offset %d.\n",
  +                (INTVAL)cursor - (INTVAL)packed);
  +#endif
       header->dir_format = PF_fetch_opcode(self, &cursor);
   
       /* dir_format 1 use directory */
       if (header->dir_format != PF_DIR_FORMAT ) {
           PIO_eprintf(NULL,
  -                "PackFile_unpack: Unknown dir format found %d!\n",
  -                (int)header->dir_format);
  +                "PackFile_unpack: Dir format was %d not %d\n",
  +                    header->dir_format, PF_DIR_FORMAT);
           return 0;
       }
  -    (void)PF_fetch_opcode(self, &cursor); /* pad */
  -    self->directory.base.file_offset = (size_t)(cursor - self->src);
  +#if TRACE_PACKFILE
  +    PIO_eprintf(NULL, "PackFile_unpack: Dirformat %d.\n", header->dir_format);
  +#endif
  +
  +    (void)PF_fetch_opcode(self, &cursor); /* padding */
  +#if TRACE_PACKFILE
  +    PIO_eprintf(NULL, "PackFile_unpack: Directory read, offset %d.\n",
  +                (INTVAL)cursor - (INTVAL)packed);
  +#endif
  +
  +    self->directory.base.file_offset = (INTVAL)cursor - (INTVAL)self->src;
       /*
        * now unpack dir, which unpacks its contents ...
        */
  @@ -1277,12 +1297,20 @@
           size_t tmp;
           UINTVAL type;
           char *name;
  +
  +        /* get type */
           type = PF_fetch_opcode (pf, &cursor);
  +        if (type >= PF_MAX_SEG)
  +            type = PF_UNKNOWN_SEG;
  +#if TRACE_PACKFILE
  +        PIO_eprintf(NULL, "Segment type %d.\n", type);
  +#endif
           /* get name */
           name = PF_fetch_cstring(pf, &cursor);
  +#if TRACE_PACKFILE
  +        PIO_eprintf(NULL, "Segment name \"%s\".\n", name);
  +#endif
   
  -        if (type >= PF_MAX_SEG)
  -            type = PF_UNKNOWN_SEG;
           /* create it */
           seg = PackFile_Segment_new_seg(dir, type, name, 0);
           mem_sys_free(name);
  
  
  

Reply via email to