Skip to content

Commit

Permalink
unzip: do not use getenv() and setenv() in test_I.c
Browse files Browse the repository at this point in the history
Use the env command to run in modified environment instead.
  • Loading branch information
mmatuska committed May 10, 2024
1 parent eac15e2 commit 62960b1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions unzip/test/test_I.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
DEFINE_TEST(test_I)
{
const char *reffile = "test_I.zip";
const char *lang;
#if !defined(_WIN32) || defined(__CYGWIN__)
const char *envstr = "env LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 "
"LC_CTYPE=en_US.UTF-8";
#else
const char *envstr = "";
#endif
int r;

#if HAVE_SETLOCALE
Expand All @@ -45,18 +50,12 @@ DEFINE_TEST(test_I)
skipping("setlocale() not available on this system.");
#endif

lang = getenv("LANG");
setenv("LANG", "en_US.UTF-8", 1);
extract_reference_file(reffile);
r = systemf("%s -I UTF-8 %s >test.out 2>test.err", testprog, reffile);
r = systemf("%s %s -I UTF-8 %s >test.out 2>test.err", envstr, testprog,
reffile);
assertEqualInt(0, r);
assertNonEmptyFile("test.out");
assertEmptyFile("test.err");

assertTextFileContents("Hello, World!\n", "Γειά σου Κόσμε.txt");

if (lang == NULL)
unsetenv("LANG");
else
setenv("LANG", lang, 1);
}

0 comments on commit 62960b1

Please sign in to comment.