Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use C.UTF-8 as locale when invoking external awk program #226

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

guilherme-puida
Copy link
Contributor

The en_US.UTF-8 locale is not guaranteed to be installed, and it quite often isn't by default.

The C.UTF-8 locale was introduced as a Debian-specific locale, but was later upstreamed into glibc 2.35 [1].

This patch fixes failures when running interpreter tests on systems where the en_US.UTF-8 locale is not present. It also changes the locale on goawk_test.go, similar to !174 [2].

1: https://sourceware.org/bugzilla/show_bug.cgi?id=17318
2: #174


I ran into some test failures when packaging goawk for Debian. I also ran the
test suite on a fresh Arch container, which failed for the same reason. This
seems like a reasonable fix :^)

The en_US.UTF-8 locale is not guaranteed to be installed, and it quite
often isn't by default.

The C.UTF-8 locale was introduced as a Debian-specific locale, but was
later upstreamed into glibc 2.35 [1].

This patch fixes failures when running interpreter tests on systems
where the en_US.UTF-8 locale is not present. It also changes the locale
on goawk_test.go, similar to !174 [2].

MacOS does not support the C.UTF-8 locale, so we keep using en_US.UTF-8
in that case.

1: https://sourceware.org/bugzilla/show_bug.cgi?id=17318
2: benhoyt#174
@guilherme-puida
Copy link
Contributor Author

I think MacOS does not support C.UTF-8 :(

I changed the commit to use en_US.UTF-8 when running the test on darwin.

@benhoyt
Copy link
Owner

benhoyt commented Apr 7, 2024

Thanks for this. These locale environment variables are all a bit messy, aren't they? I'm okay with this fix, however, let's hide the messiness inside a function so it's easy to update in one place (later we could use locale -a to see if it's present, for example). Perhaps a func awkLocale() string which returns "" on Windows, and the correct locale on others.

@guilherme-puida
Copy link
Contributor Author

Sure! I'm not too sure where this awkLocale function should reside, though. Stuffing it into interp looks wrong, and I feel like it should be somewhere in internal.

@benhoyt
Copy link
Owner

benhoyt commented Apr 7, 2024

Just at the bottom of interp_test.go below normalizeNewlines is fine.

@guilherme-puida
Copy link
Contributor Author

If it is in interp_test then goawk_test can't import it :(

@benhoyt
Copy link
Owner

benhoyt commented Apr 8, 2024

Oops, I'd missed the fact that the first one was in goawk_test.go. In that case, I think what you have is reasonable. Let's do it.

@benhoyt benhoyt merged commit 3e8ce70 into benhoyt:master Apr 8, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants