summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-05-31 19:14:17 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-05-31 19:14:17 -0700
commit93a13ccd3838a1f9646b92b3fb8785f48885ac6e (patch)
treed6413f31d22ae813e01d3d64b46caebe15014e14 /parser.c
parent9d02e5e1120d36fb2c4284187de99e19d434dc98 (diff)
downloadtxr-93a13ccd3838a1f9646b92b3fb8785f48885ac6e.tar.gz
txr-93a13ccd3838a1f9646b92b3fb8785f48885ac6e.tar.bz2
txr-93a13ccd3838a1f9646b92b3fb8785f48885ac6e.zip
build: fix broken build when we don't HAVE_ZLIB.
* parser.c (open_txr_file): Use liberal heaps of #if HAVE_ZLIB. If there is no Zlib, and the caller explicitly requests a .tlo.gz file to be loaded, then throw. Do not implicitly look for a .tlo.gz file. * stream.c (open_file): #if HAVE_ZLIB around a goto label that is only used out of HAVE_ZLIB code, to eliminate unused label warning.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/parser.c b/parser.c
index 17aed2b1..60fd0655 100644
--- a/parser.c
+++ b/parser.c
@@ -523,7 +523,9 @@ void open_txr_file(val first_try_path, val *txr_lisp_p,
val search_dirs, val self)
{
enum { none, tl, tlo, tlz, txr } suffix;
+#if HAVE_ZLIB
struct stdio_mode m_r = stdio_mode_init_r;
+#endif
if (match_str(first_try_path, lit(".txr"), negone))
suffix = txr;
@@ -538,19 +540,32 @@ void open_txr_file(val first_try_path, val *txr_lisp_p,
else
suffix = none;
+#if !HAVE_ZLIB
+ if (suffix == tlz)
+ uw_ethrowf(file_error_s, lit("~s: cannot open ~s files: "
+ "not built with zlib support"),
+ self, nao);
+#endif
+
errno = 0;
{
val try_path = nil;
FILE *in = 0;
+#if HAVE_ZLIB
gzFile zin = 0;
+#else
+ const int zin = 0;
+#endif
{
try_path = first_try_path;
errno = 0;
+#if HAVE_ZLIB
if (suffix == tlz)
zin = w_gzopen_mode(c_str(try_path, self), L"r", m_r, self);
else
+#endif
in = w_fopen(c_str(try_path, self), L"r");
if (in != 0 || zin != 0) {
@@ -599,6 +614,7 @@ void open_txr_file(val first_try_path, val *txr_lisp_p,
goto except;
#endif
}
+#if HAVE_ZLIB
{
try_path = scat(lit("."), first_try_path, lit("tlo.gz"), nao);
errno = 0;
@@ -611,6 +627,7 @@ void open_txr_file(val first_try_path, val *txr_lisp_p,
goto except;
#endif
}
+#endif
{
try_path = scat(lit("."), first_try_path, lit("tl"), nao);
errno = 0;
@@ -651,8 +668,10 @@ except:
found:
if (in != 0)
*stream = make_stdio_stream(in, try_path);
+#if HAVE_ZLIB
else
*stream = make_gzio_stream(zin, -1, try_path, 0);
+#endif
*orig_in_resolved_out = try_path;
}
}