awk: octal and hexadecimal constants in the program are not recognised

Offen
#176 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
68/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
rust
Bereich
cli

Rechercherichtung

Start by reading the Rust source lexer or parser that handles numeric constants; the issue does not name a file or entry point. Compare how it tokenizes the reproduction BEGIN { print 017, 0X10, 019, 0 } with the GNU awk results, and use the supplied test as the completion check: octal and hexadecimal constants should match GNU awk while invalid octal 019 remains decimal.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug gnu-compat good first issue

gawk (outside --posix / --traditional) reads 010 as octal 8 and 0x1f
as hexadecimal 31 in the program source. uutils awk reads 010 as 10 and
lexes 0x1f as 0 followed by the variable x1f, so it prints 0. 018
is not valid octal and stays 18 in gawk.

Reproduction

Rust (incorrect)

$ ./target/release/awk 'BEGIN { print 010, 0x1f, 018 }'
10 0 18

GNU (correct)

$ gawk 'BEGIN { print 010, 0x1f, 018 }'
8 31 18
$ gawk --posix 'BEGIN { print 010, 0x1f }'
10 0

Test

#[test]
fn octal_and_hex_source_constants() {
    ucmd()
        .arg("BEGIN { print 017, 0X10, 019, 0 }")
        .succeeds()
        .stdout_only("15 16 19 0\n");
}

Exposed by the GNU awk test suite: nondec, octdec.

Vorherrschende Sprache
Rust
Sterne
31
Forks
13
Ø Merge
23 Std. 42 Min.
Gemergte PRs (30 T.)
29

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus uutils/awk

Alle Issues in uutils/awk

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.