Skip to content

Commit

Permalink
Merge pull request #21 from JanMarvin/compat
Browse files Browse the repository at this point in the history
Parser: read optional PROJECTCOMPATVERSION Record.
  • Loading branch information
tim-weis authored Dec 19, 2024
2 parents 41290a1 + d0e3e1a commit d2ea066
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ pub enum Reference {
pub struct Information {
/// Specifies the platform for which the VBA project is created.
pub sys_kind: SysKind,
compat: Option<u32>,
lcid: u32,
lcid_invoke: u32,
/// Specifies the code page for the VBA project.
Expand Down
11 changes: 11 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ fn parse_syskind(i: &[u8]) -> IResult<&[u8], SysKind, FormatError<&[u8]>> {
}
}

fn parse_compat(i: &[u8]) -> IResult<&[u8], Option<u32>, FormatError<&[u8]>> {
const COMPAT_SIGNATURE: &[u8] = &[0x4A, 0x00];
let (i, compat) = opt(preceded(
tuple((tag(COMPAT_SIGNATURE), tag(U32_FIXED_SIZE_4))),
le_u32,
))(i)?;
Ok((i, compat))
}

fn parse_lcid(i: &[u8]) -> IResult<&[u8], u32, FormatError<&[u8]>> {
const LCID_SIGNATURE: &[u8] = &[0x02, 0x00];
let (i, lcid) = preceded(tuple((tag(LCID_SIGNATURE), tag(U32_FIXED_SIZE_4))), le_u32)(i)?;
Expand Down Expand Up @@ -562,6 +571,7 @@ pub(crate) fn parse_project_information(
i: &[u8],
) -> IResult<&[u8], ProjectInformation, FormatError<&[u8]>> {
let (i, sys_kind) = parse_syskind(i)?;
let (i, compat) = parse_compat(i)?;
let (i, lcid) = parse_lcid(i)?;
let (i, lcid_invoke) = parse_lcid_invoke(i)?;
let (i, code_page) = parse_code_page(i)?;
Expand Down Expand Up @@ -619,6 +629,7 @@ pub(crate) fn parse_project_information(
ProjectInformation {
information: Information {
sys_kind,
compat,
lcid,
lcid_invoke,
code_page,
Expand Down

0 comments on commit d2ea066

Please sign in to comment.