Skip to content

Issue with .db directive parsing strings containing single quotes #73

@dylanh333

Description

@dylanh333

avra appears to have a strange bug when parsing strings in .db expression lists, where:
(1) if that expression list contains a string enclosed in double-quotes, and
(2) that string contains a single quote anywhere inside, then
all subsequent expressions in the list (after the string) are ignored and are not emitted in the assembled hex file.

This means that you potentially lose any line-feeds, null terminators, etc. from the end of the .db expression list.
The string that contains the single quote, however, is still emitted in its entirety.

I've tested this using the latest build of avra from the master branch, as of the 1st of September 2024 (1.4.2), and also on 1.3.0 Build 1 (from the Ubuntu 22.04.4 LTS repos).

Please see the example below:

.org 0xb
; Incorrectly only outputs "It's broken", with a \0 appended to pad it to the next word
str_broken: .db "It's broken", "!", 0x0a, 0

; For readability in hexdump
str_delim1: .db "---", 0

; Correctly outputs "It's broken!\n\0"
str_workaround: .db "It", 0x27, "s broken", "!", 0x0a, 0

; For readability in hexdump
str_delim2: .db "---", 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions