Skip to content

Commit

Permalink
Replace coretest with binxml package
Browse files Browse the repository at this point in the history
  • Loading branch information
Vojtech Bocek committed Feb 16, 2016
1 parent 24497f4 commit 4d6ab85
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 13 additions & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ func (x *binXmlParseInfo) parseTagStart(r *io.LimitedReader) error {
}

var attrData [attrValuesCount]uint32
hasName := false
for i := uint32(0); i < attrCnt; i++ {
if err := binary.Read(r, binary.LittleEndian, &attrData); err != nil {
return fmt.Errorf("error reading attrData: %s", err.Error())
Expand All @@ -365,14 +366,25 @@ func (x *binXmlParseInfo) parseTagStart(r *io.LimitedReader) error {
if err != nil {
return fmt.Errorf("error decoding attrStringIdx: %s", err.Error())
}

// apparently, the attribute names do not have to be there? Make it
// easier for the encoder.
if !hasName {
switch attrName {
case "", ":":
attr.Name.Local = "name"
hasName = true
case "name":
hasName = true
}
}
case attrTypeIntBool:
attr.Value = strconv.FormatBool(attrData[attrIdxData] != 0)
case attrTypeIntHex:
attr.Value = fmt.Sprintf("0x%x", attrData[attrIdxData])
default:
attr.Value = strconv.FormatInt(int64(attrData[attrIdxData]), 10)
}

tok.Attr = append(tok.Attr, attr)
}

Expand Down
10 changes: 5 additions & 5 deletions zipreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ func (zr *ZipReaderFile) Open() error {
var err error
zr.internalReader, err = zr.zipEntry.Open()
return err
} else {
zr.curEntry = -1
}

return nil
}

Expand Down Expand Up @@ -88,9 +91,6 @@ func (zr *ZipReaderFile) Close() error {
zr.internalReader.Close()
}
zr.internalReader = nil

// prevent reopen
zr.curEntry = len(zr.entries)
}
return nil
}
Expand Down Expand Up @@ -185,10 +185,10 @@ func OpenZip(path string) (zr *ZipReader, err error) {
zr.File[fileName] = zrf
}

zrf.entries = append(zrf.entries, zipReaderFileSubEntry{
zrf.entries = append([]zipReaderFileSubEntry{ zipReaderFileSubEntry{
offset: fileOffset,
method: method,
})
}}, zrf.entries...)

f.Seek(off+4, 0)
}
Expand Down

0 comments on commit 4d6ab85

Please sign in to comment.