Skip to content

Commit

Permalink
Autotools: conditionally compile inih
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghabry committed Jan 8, 2025
1 parent 8a5bfb2 commit cff9265
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ liblcf_la_SOURCES = \
src/dbarray.cpp \
src/dbstring_struct.cpp \
src/encoder.cpp \
src/inireader.cpp \
src/ldb_equipment.cpp \
src/ldb_eventcommand.cpp \
src/ldb_parameters.cpp \
Expand Down Expand Up @@ -219,7 +218,6 @@ lcfinclude_HEADERS = \
src/lcf/encoder.h \
src/lcf/enum_tags.h \
src/lcf/flag_set.h \
src/lcf/inireader.h \
src/lcf/log_handler.h \
src/lcf/reader_lcf.h \
src/lcf/reader_util.h \
Expand All @@ -231,6 +229,11 @@ lcfinclude_HEADERS = \
src/lcf/writer_lcf.h \
src/lcf/writer_xml.h

if SUPPORT_INI
liblcf_la_SOURCES += src/inireader.cpp
lcfinclude_HEADERS += src/lcf/inireader.h
endif

lcfldbinclude_HEADERS = \
src/lcf/ldb/reader.h \
src/generated/lcf/ldb/chunks.h
Expand Down
4 changes: 2 additions & 2 deletions builds/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
/* Enable XML reading support (expat) */
#define LCF_SUPPORT_XML @LCF_SUPPORT_XML@

/* Enable INI reading support (INIH ) */
#define LCF_SUPPORT_INI @LCF_SUPPORT_INI@
/* Enable INI reading support (INIH) */
#define LCF_SUPPORT_INI @LCF_SUPPORT_INI@
4 changes: 1 addition & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ LT_INIT([win32-dll])
AM_CONDITIONAL(CROSS_COMPILING,[test "x$cross_compiling" = "xyes"])

# Checks for libraries.
AX_PKG_CHECK_MODULES([INIH],[],[inih],[])

AC_SUBST([LCF_SUPPORT_ICU],[0])
AC_ARG_ENABLE([icu],[AS_HELP_STRING([--disable-icu],[Disable ICU encoding handling (only windows-1252 supported) [default=no]])])
AS_IF([test "x$enable_icu" != "xno"],[
Expand All @@ -39,7 +37,7 @@ AM_CONDITIONAL(SUPPORT_XML,[test $LCF_SUPPORT_XML == 1])
AC_SUBST([LCF_SUPPORT_INI],[0])
AC_ARG_ENABLE([ini],[AS_HELP_STRING([--disable-ini],[Disable INI reading support (inih) [default=no]])])
AS_IF([test "x$enable_ini" != "xno"],[
AX_PKG_CHECK_MODULES([EXPAT],[],[ini >= 2.1],[LCF_SUPPORT_INI=1])
AX_PKG_CHECK_MODULES([INIH],[],[inih],[LCF_SUPPORT_INI=1])
])
AM_CONDITIONAL(SUPPORT_INI,[test $LCF_SUPPORT_INI == 1])

Expand Down
5 changes: 3 additions & 2 deletions tools/lcf2xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int main(int argc, char** argv)
std::cerr << "Usage: " << argv[0] << "[--2k] [--2k3] file1 [... fileN]" << std::endl;
std::cerr << "\t--2k: Treat files as RPG 2000" << std::endl;
std::cerr << "\t--2k3: Treat files as RPG 2003 (default)" << std::endl;
std::cerr << "\t--encoding N: Use encoding N as the file encoding" << std::endl;
std::cerr << "\t--encoding N: Use encoding N as the file encoding" << std::endl;

return 1;
}
Expand Down Expand Up @@ -250,6 +250,7 @@ void PrintReaderError(const std::string data)
int ReaderWriteToFile(const std::string& in, const std::string& out, FileTypes in_type, lcf::EngineVersion engine, std::string encoding)
{
std::string path = GetPath(in) + "/";

if (encoding.empty()) {
#ifdef _WIN32
encoding = lcf::ReaderUtil::GetEncoding(path + "RPG_RT.ini");
Expand All @@ -275,7 +276,7 @@ int ReaderWriteToFile(const std::string& in, const std::string& out, FileTypes i
}
#endif
}

if (encoding.empty()) {
encoding = lcf::ReaderUtil::GetLocaleEncoding();
}
Expand Down

0 comments on commit cff9265

Please sign in to comment.