Ticket #407: tt407-post1.0-pf-logic.patch

File tt407-post1.0-pf-logic.patch, 2.4 KB (added by rurban, 13 years ago)

updated

  • src/packfile.c

    old new  
    954954        return 0; 
    955955    } 
    956956 
    957     /* Ensure the bytecode version is one we can read. Currently, we only 
    958      * support bytecode versions matching the current one. 
     957    /* Ensure the bytecode version is one we can read. pre-1.0 we only 
     958     * supported bytecode versions matching the current one. 
     959     * From 1.0 on we at least try to read older pbc's because we 
     960     * changed our pmc and ops renumbering policy, but removed pmc/ops are 
     961     * unsupported. 
    959962     * 
    960      * tools/dev/pbc_header.pl --upd t/native_pbc/ *.pbc 
    961      * stamps version and fingerprint in the native tests. */ 
     963     * With tools/dev/pbc_header.pl --upd t/native_pbc/ *.pbc 
     964     * we can update the parrot version and fingerprint in the native tests */ 
    962965    if (header->bc_major != PARROT_PBC_MAJOR 
    963966    ||  header->bc_minor != PARROT_PBC_MINOR) { 
    964         Parrot_io_eprintf(NULL, "PackFile_unpack: This Parrot cannot read " 
    965             "bytecode files with version %d.%d.\n", 
    966             header->bc_major, header->bc_minor); 
    967         if (!(self->options & PFOPT_UTILS)) 
     967        const char *failmsg = "PackFile_unpack: This Parrot cannot read " 
     968            "bytecode files %s version %d.%d.\n"; 
     969        if (header->major < 1) { 
     970            Parrot_io_eprintf(NULL, failmsg, "with", 
     971                              header->bc_major, header->bc_minor); 
    968972            return 0; 
     973        } 
     974        else { 
     975            if (header->bc_major << 0xff + header->bc_minor 
     976                > PARROT_PBC_MAJOR << 0xff + PARROT_PBC_MINOR) { 
     977                Parrot_io_eprintf(NULL, failmsg, "newer than", 
     978                                  PARROT_PBC_MAJOR, PARROT_PBC_MINOR); 
     979                return 0; 
     980            } 
     981            /* Read older, but refuse to read pre-1.0 bytecode as the 
     982             * pmc and ops numbering changed randomly. post-1.0 the 
     983             * earlier ops and pmc indices are kept. 
     984             * See F<lib/Parrot/OpsRenumber.pm> 
     985             */ 
     986            if (header->bc_major << 0xff + header->bc_minor < 338) { 
     987                Parrot_io_eprintf(NULL, failmsg, "older than", 3, 38); 
     988                return 0; 
     989            } 
     990        } 
    969991    } 
    970992 
    971993    /* Check wordsize, byte order and floating point number type are valid. */