From 92fc0e864b51876c3ed08225266c58cf7003b4b6 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 14 Jun 2020 15:31:28 +0200
Subject: C89 fix


diff --git a/src/bitio.c b/src/bitio.c
index ac4e61b..1c3e1de 100644
--- a/src/bitio.c
+++ b/src/bitio.c
@@ -19,8 +19,8 @@ fillbuf(n)          /* Shift bitbuf n bits left, read n bits */
         n -= bitcount;
         bitbuf = (bitbuf << bitcount) + (subbitbuf >> (CHAR_BIT - bitcount));
         if (compsize != 0) {
-            compsize--;
             int c = getc(infile);
+            compsize--;
             if (c == EOF) {
                 fatal_error("cannot read stream");
             }
-- 
2.26.0


From b351c0c172434d1597d57853258a999c0c2b3610 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 14 Jun 2020 15:57:59 +0200
Subject: Fix detection of libiconv


diff --git a/configure.ac b/configure.ac
index eac9205..6558bd1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,7 +106,7 @@ AC_CHECK_FUNCS(strchr strdup memcpy memset memmove strcasecmp)
 AC_CHECK_FUNCS(mktime timelocal tzset ftime gettimeofday utime)
 AC_CHECK_FUNCS(ftruncate chsize lchown mkstemp ftello)
 AC_CHECK_FUNCS(getpwuid getgrgid getpwnam getgrnam)
-AC_CHECK_FUNCS(iconv basename)
+AC_CHECK_FUNCS(libiconv iconv basename)
 AC_REPLACE_FUNCS(vsnprintf fnmatch)
 
 if test $ac_header_dirent = no; then
diff --git a/src/header.c b/src/header.c
index 523f2b5..3284000 100644
--- a/src/header.c
+++ b/src/header.c
@@ -2000,7 +2000,7 @@ ConvertUTF8ToEncoding(const char* inUTF8Buf,
     return cfResult;
 }
 
-#elif HAVE_ICONV
+#elif defined(HAVE_ICONV) || defined(HAVE_LIBICONV)
 #include <iconv.h>
 
 static int
@@ -2055,7 +2055,7 @@ sjis_to_utf8(char *dst, const char *src, size_t dstsize)
   if (ConvertEncodingByIconv(src, dst, dstsize, "SJIS", "UTF-8-MAC") != -1)
       return dst;
 #endif
-#elif HAVE_ICONV
+#elif defined(HAVE_ICONV) || defined(HAVE_LIBICONV)
   if (ConvertEncodingByIconv(src, dst, dstsize, "SJIS", "UTF-8") != -1)
       return dst;
 #else
@@ -2084,7 +2084,7 @@ utf8_to_sjis(char *dst, const char *src, size_t dstsize)
   if (ConvertEncodingByIconv(src, dst, dstsize, "UTF-8-MAC", "SJIS") != -1)
       return dst;
 #endif
-#elif HAVE_ICONV
+#elif defined(HAVE_ICONV) || defined(HAVE_LIBICONV)
   if (ConvertEncodingByIconv(src, dst, dstsize, "UTF-8", "SJIS") != -1)
       return dst;
 #else
-- 
2.26.0

