1
0
mirror of https://git.code.sf.net/p/fuse-emulator/fuse-utils synced 2025-04-19 08:42:15 +03:00

Support the de-facto standard Windows-1252 charset in TZX text.

Legacy-ID: 4144
This commit is contained in:
Fredrick Meunier 2010-08-06 13:44:35 +00:00
parent 9b065fd75d
commit 45f084b5a6
7 changed files with 889 additions and 22 deletions

View File

@ -49,7 +49,7 @@ endif
EXTRA_PROGRAMS = rzxcheck audio2tape tape2wav
INCLUDES = @LIBSPEC_CFLAGS@ @AUDIOFILE_CFLAGS@ `pkg-config --cflags glib-2.0`
INCLUDES = @LIBSPEC_CFLAGS@ @AUDIOFILE_CFLAGS@ @GLIB_CFLAGS@
createhdf_SOURCES = ide.c createhdf.c
@ -82,7 +82,7 @@ tapeconv_SOURCES = tapeconv.c utils.c
tapeconv_LDADD = @LIBSPEC_LIBS@ compat/@COMPAT_OSNAME@/libcompatos.a
tzxlist_SOURCES = tzxlist.c utils.c
tzxlist_LDADD = @LIBSPEC_LIBS@ compat/@COMPAT_OSNAME@/libcompatos.a
tzxlist_LDADD = @LIBSPEC_LIBS@ @LTLIBICONV@ compat/@COMPAT_OSNAME@/libcompatos.a
audio2tape_SOURCES = audio2tape.cc importer/soundfile.cc importer/trigger.cc \
converter/findpilot.cc converter/findsync1.cc \

View File

@ -591,3 +591,218 @@ END
AC_SUBST(AUDIOFILE_LIBS)
rm -f conf.audiofiletest
])
# iconv.m4 serial 11 (gettext-0.18.1)
dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
[
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([iconv])
])
AC_DEFUN([AM_ICONV_LINK],
[
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
dnl those with the standalone portable GNU libiconv installed).
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
dnl Add $INCICONV to CPPFLAGS before performing the following checks,
dnl because if the user has installed libiconv and not disabled its use
dnl via --without-libiconv-prefix, he wants to use it. The first
dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
am_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
[am_cv_func_iconv=yes])
if test "$am_cv_func_iconv" != yes; then
am_save_LIBS="$LIBS"
LIBS="$LIBS $LIBICONV"
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
[am_cv_lib_iconv=yes]
[am_cv_func_iconv=yes])
LIBS="$am_save_LIBS"
fi
])
if test "$am_cv_func_iconv" = yes; then
AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
dnl This tests against bugs in AIX 5.1, HP-UX 11.11, Solaris 10.
am_save_LIBS="$LIBS"
if test $am_cv_lib_iconv = yes; then
LIBS="$LIBS $LIBICONV"
fi
AC_TRY_RUN([
#include <iconv.h>
#include <string.h>
int main ()
{
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
returns. */
{
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
if (cd_utf8_to_88591 != (iconv_t)(-1))
{
static const char input[] = "\342\202\254"; /* EURO SIGN */
char buf[10];
const char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_utf8_to_88591,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res == 0)
return 1;
}
}
/* Test against Solaris 10 bug: Failures are not distinguishable from
successful returns. */
{
iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
if (cd_ascii_to_88591 != (iconv_t)(-1))
{
static const char input[] = "\263";
char buf[10];
const char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_ascii_to_88591,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res == 0)
return 1;
}
}
#if 0 /* This bug could be worked around by the caller. */
/* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
{
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
if (cd_88591_to_utf8 != (iconv_t)(-1))
{
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
char buf[50];
const char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_88591_to_utf8,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
if ((int)res > 0)
return 1;
}
}
#endif
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
provided. */
if (/* Try standardized names. */
iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
/* Try IRIX, OSF/1 names. */
&& iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
/* Try AIX names. */
&& iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
/* Try HP-UX names. */
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
return 1;
return 0;
}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no],
[case "$host_os" in
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
*) am_cv_func_iconv_works="guessing yes" ;;
esac])
LIBS="$am_save_LIBS"
])
case "$am_cv_func_iconv_works" in
*no) am_func_iconv=no am_cv_lib_iconv=no ;;
*) am_func_iconv=yes ;;
esac
else
am_func_iconv=no am_cv_lib_iconv=no
fi
if test "$am_func_iconv" = yes; then
AC_DEFINE([HAVE_ICONV], [1],
[Define if you have the iconv() function and it works.])
fi
if test "$am_cv_lib_iconv" = yes; then
AC_MSG_CHECKING([how to link with libiconv])
AC_MSG_RESULT([$LIBICONV])
else
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
dnl either.
CPPFLAGS="$am_save_CPPFLAGS"
LIBICONV=
LTLIBICONV=
fi
AC_SUBST([LIBICONV])
AC_SUBST([LTLIBICONV])
])
dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
dnl avoid warnings like
dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
dnl This is tricky because of the way 'aclocal' is implemented:
dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
dnl Otherwise aclocal's initial scan pass would miss the macro definition.
dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
dnl warnings.
m4_define([gl_iconv_AC_DEFUN],
m4_version_prereq([2.64],
[[AC_DEFUN_ONCE(
[$1], [$2])]],
[[AC_DEFUN(
[$1], [$2])]]))
gl_iconv_AC_DEFUN([AM_ICONV],
[
AM_ICONV_LINK
if test "$am_cv_func_iconv" = yes; then
AC_MSG_CHECKING([for iconv declaration])
AC_CACHE_VAL([am_cv_proto_iconv], [
AC_TRY_COMPILE([
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"])
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
AC_MSG_RESULT([
$am_cv_proto_iconv])
AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
[Define as const if the declaration of iconv() needs const.])
fi
])

548
config.rpath Executable file
View File

@ -0,0 +1,548 @@
#! /bin/sh
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
# Copyright 1996-2003 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
#
# The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
# should be set by the caller.
#
# The set of defined variables is at the end of this script.
# Known limitations:
# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
# than 256 bytes, otherwise the compiler driver will dump core. The only
# known workaround is to choose shorter directory names for the build
# directory and/or the installation directory.
# All known linkers require a `.a' archive for static linking (except M$VC,
# which needs '.lib').
libext=a
shrext=.so
host="$1"
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
wl=
if test "$GCC" = yes; then
wl='-Wl,'
else
case "$host_os" in
aix*)
wl='-Wl,'
;;
mingw* | pw32* | os2*)
;;
hpux9* | hpux10* | hpux11*)
wl='-Wl,'
;;
irix5* | irix6* | nonstopux*)
wl='-Wl,'
;;
newsos6)
;;
linux*)
case $CC in
icc|ecc)
wl='-Wl,'
;;
ccc)
wl='-Wl,'
;;
esac
;;
osf3* | osf4* | osf5*)
wl='-Wl,'
;;
sco3.2v5*)
;;
solaris*)
wl='-Wl,'
;;
sunos4*)
wl='-Qoption ld '
;;
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
wl='-Wl,'
;;
sysv4*MP*)
;;
uts4*)
;;
esac
fi
# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
hardcode_libdir_flag_spec=
hardcode_libdir_separator=
hardcode_direct=no
hardcode_minus_L=no
case "$host_os" in
cygwin* | mingw* | pw32*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
if test "$GCC" != yes; then
with_gnu_ld=no
fi
;;
openbsd*)
with_gnu_ld=no
;;
esac
ld_shlibs=yes
if test "$with_gnu_ld" = yes; then
case "$host_os" in
aix3* | aix4* | aix5*)
# On AIX/PPC, the GNU linker is very broken
if test "$host_cpu" != ia64; then
ld_shlibs=no
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
# that the semantics of dynamic libraries on AmigaOS, at least up
# to version 4, is to share data among multiple programs linked
# with the same dynamic library. Since this doesn't match the
# behavior of shared libraries on other platforms, we can use
# them.
ld_shlibs=no
;;
beos*)
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
cygwin* | mingw* | pw32*)
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec='-L$libdir'
if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
netbsd*)
;;
solaris* | sysv5*)
if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
ld_shlibs=no
elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
sunos4*)
hardcode_direct=yes
;;
*)
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
esac
if test "$ld_shlibs" = yes; then
# Unlike libtool, we use -rpath here, not --rpath, since the documented
# option of GNU ld is called -rpath, not --rpath.
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
fi
else
case "$host_os" in
aix3*)
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
hardcode_minus_L=yes
if test "$GCC" = yes; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
hardcode_direct=unsupported
fi
;;
aix4* | aix5*)
if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking.
case $host_os in aix4.[23]|aix4.[23].*|aix5*)
for ld_flag in $LDFLAGS; do
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
aix_use_runtimelinking=yes
break
fi
done
esac
fi
hardcode_direct=yes
hardcode_libdir_separator=':'
if test "$GCC" = yes; then
case $host_os in aix4.[012]|aix4.[012].*)
collect2name=`${CC} -print-prog-name=collect2`
if test -f "$collect2name" && \
strings "$collect2name" | grep resolve_lib_name >/dev/null
then
# We have reworked collect2
hardcode_direct=yes
else
# We have old collect2
hardcode_direct=unsupported
hardcode_minus_L=yes
hardcode_libdir_flag_spec='-L$libdir'
hardcode_libdir_separator=
fi
esac
fi
# Begin _LT_AC_SYS_LIBPATH_AIX.
echo 'int main () { return 0; }' > conftest.c
${CC} ${LDFLAGS} conftest.c -o conftest
aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
if test -z "$aix_libpath"; then
aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
fi
if test -z "$aix_libpath"; then
aix_libpath="/usr/lib:/lib"
fi
rm -f conftest.c conftest
# End _LT_AC_SYS_LIBPATH_AIX.
if test "$aix_use_runtimelinking" = yes; then
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
else
if test "$host_cpu" = ia64; then
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
else
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
fi
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# see comment about different semantics on the GNU ld section
ld_shlibs=no
;;
bsdi4*)
;;
cygwin* | mingw* | pw32*)
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec=' '
libext=lib
;;
darwin* | rhapsody*)
if $CC -v 2>&1 | grep 'Apple' >/dev/null ; then
hardcode_direct=no
fi
;;
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
freebsd1*)
ld_shlibs=no
;;
freebsd2.2*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
freebsd2*)
hardcode_direct=yes
hardcode_minus_L=yes
;;
freebsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
hpux9*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
hpux10* | hpux11*)
if test "$with_gnu_ld" = no; then
case "$host_cpu" in
hppa*64*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=no
;;
ia64*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=no
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
esac
fi
;;
irix5* | irix6* | nonstopux*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
netbsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
newsos6)
hardcode_direct=yes
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
openbsd*)
hardcode_direct=yes
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
else
case "$host_os" in
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
hardcode_libdir_flag_spec='-R$libdir'
;;
*)
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
esac
fi
;;
os2*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
osf3*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
osf4* | osf5*)
if test "$GCC" = yes; then
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
else
# Both cc and cxx compiler support -rpath directly
hardcode_libdir_flag_spec='-rpath $libdir'
fi
hardcode_libdir_separator=:
;;
sco3.2v5*)
;;
solaris*)
hardcode_libdir_flag_spec='-R$libdir'
;;
sunos4*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=yes
hardcode_minus_L=yes
;;
sysv4)
case $host_vendor in
sni)
hardcode_direct=yes # is this really true???
;;
siemens)
hardcode_direct=no
;;
motorola)
hardcode_direct=no #Motorola manual says yes, but my tests say they lie
;;
esac
;;
sysv4.3*)
;;
sysv4*MP*)
if test -d /usr/nec; then
ld_shlibs=yes
fi
;;
sysv4.2uw2*)
hardcode_direct=yes
hardcode_minus_L=no
;;
sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
;;
sysv5*)
hardcode_libdir_flag_spec=
;;
uts4*)
hardcode_libdir_flag_spec='-L$libdir'
;;
*)
ld_shlibs=no
;;
esac
fi
# Check dynamic linker characteristics
# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
libname_spec='lib$name'
case "$host_os" in
aix3*)
;;
aix4* | aix5*)
;;
amigaos*)
;;
beos*)
;;
bsdi4*)
;;
cygwin* | mingw* | pw32*)
shrext=.dll
;;
darwin* | rhapsody*)
shrext=.dylib
;;
dgux*)
;;
freebsd1*)
;;
freebsd*)
;;
gnu*)
;;
hpux9* | hpux10* | hpux11*)
case "$host_cpu" in
ia64*)
shrext=.so
;;
hppa*64*)
shrext=.sl
;;
*)
shrext=.sl
;;
esac
;;
irix5* | irix6* | nonstopux*)
case "$host_os" in
irix5* | nonstopux*)
libsuff= shlibsuff=
;;
*)
case $LD in
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
*) libsuff= shlibsuff= ;;
esac
;;
esac
;;
linux*oldld* | linux*aout* | linux*coff*)
;;
linux*)
;;
netbsd*)
;;
newsos6)
;;
nto-qnx)
;;
openbsd*)
;;
os2*)
libname_spec='$name'
shrext=.dll
;;
osf3* | osf4* | osf5*)
;;
sco3.2v5*)
;;
solaris*)
;;
sunos4*)
;;
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
;;
sysv4*MP*)
;;
uts4*)
;;
esac
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
# How to pass a linker flag through the compiler.
wl="$escaped_wl"
# Static library suffix (normally "a").
libext="$libext"
# Shared library suffix (normally "so").
shlibext="$shlibext"
# Flag to hardcode \$libdir into a binary during linking.
# This must work even if \$libdir does not exist.
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
# Whether we need a single -rpath flag with a separated argument.
hardcode_libdir_separator="$hardcode_libdir_separator"
# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
# resulting binary.
hardcode_direct="$hardcode_direct"
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
# resulting binary.
hardcode_minus_L="$hardcode_minus_L"
EOF

View File

@ -57,19 +57,6 @@ AC_CHECK_LIB(gcrypt,gcry_check_version,
AC_SUBST(GCRYPT_LIBS)
AM_CONDITIONAL(BUILD_RZXCHECK, test "$gcrypt" = yes)
dnl Check that libspectrum is available
AC_ARG_WITH(libspectrum-prefix,
[ --with-libspectrum-prefix=PFX where libspectrum is installed (optional)],
LIBSPEC_CFLAGS=-I$withval/include; LIBSPEC_LIBS=-L$withval/lib,
LIBSPEC_CFLAGS=""; LIBSPEC_LIBS="")
ac_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CFLAGS $LIBSPEC_CFLAGS $GLIB_CFLAGS"
AC_CHECK_HEADERS(libspectrum.h,LIBSPEC_LIBS="$LIBSPEC_LIBS -lspectrum",
AC_MSG_ERROR(Sorry - I need libspectrum to be available))
CPPFLAGS="$ac_save_CPPFLAGS"
AC_SUBST(LIBSPEC_CFLAGS)
AC_SUBST(LIBSPEC_LIBS)
dnl Do we want lots of warning messages?
AC_MSG_CHECKING(whether lots of warnings requested)
AC_ARG_ENABLE(warnings,
@ -105,18 +92,31 @@ if test "$glib" = yes; then
2.0.0,
glib2=yes
AC_DEFINE([HAVE_LIB_GLIB], 1, [Defined if we've got glib])
LIBS="$LIBS `pkg-config --libs glib-2.0`",
GLIBS="`pkg-config --libs glib-2.0`",
)
if test "$glib2" = no; then
AM_PATH_GLIB(
1.2.0,
AC_DEFINE([HAVE_LIB_GLIB], 1, [Defined if we've got glib])
LIBS="$LIBS `glib-config --libs`",
GLIBS="`glib-config --libs`",
AC_MSG_WARN(glib not found - using libspectrum's replacement)
)
fi
fi
dnl Check that libspectrum is available
AC_ARG_WITH(libspectrum-prefix,
[ --with-libspectrum-prefix=PFX where libspectrum is installed (optional)],
LIBSPEC_CFLAGS=-I$withval/include; LIBSPEC_LIBS=-L$withval/lib,
LIBSPEC_CFLAGS=""; LIBSPEC_LIBS="")
ac_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CFLAGS $LIBSPEC_CFLAGS $GLIB_CFLAGS"
AC_CHECK_HEADERS(libspectrum.h,LIBSPEC_LIBS="$LIBSPEC_LIBS -lspectrum $GLIBS",
AC_MSG_ERROR(Sorry - I need libspectrum to be available))
CPPFLAGS="$ac_save_CPPFLAGS"
AC_SUBST(LIBSPEC_CFLAGS)
AC_SUBST(LIBSPEC_LIBS)
# Look for audiofile (default=yes)
AC_MSG_CHECKING(whether to use audiofile)
AC_ARG_WITH(audiofile,
@ -133,6 +133,20 @@ if test "$audiofile" = yes; then
fi
AM_CONDITIONAL(BUILD_AUDIOTOOLS, test "$audiofile" = yes)
# Look for iconv (default=yes)
AC_MSG_CHECKING(whether to use iconv)
AC_ARG_WITH(iconv,
[ --without-iconv don't use iconv],
if test "$withval" = no; then iconv=no; else iconv=yes; fi,
iconv=yes)
AC_MSG_RESULT($iconv)
if test "$iconv" = yes; then
AC_CHECK_HEADERS(locale.h)
AC_CHECK_FUNCS(setlocale)
AM_ICONV()
fi
AC_SUBST(LTLIBICONV)
dnl Work out which compatibility routines to use
AC_MSG_CHECKING(which compatibility routines to use)
case "$target_os" in

View File

@ -302,3 +302,6 @@
(Fred).
20100722 converter/romloader.cc: fix header printing (Fred).
20100722 tzxlist.c: add ROM block header printing (Fred).
20100806 Makefile.am,acinclude.m4,config.rpath,configure.in,man/tzxlist.1,
tzxlist.c: support the de-facto standard Windows-1252 charset in TZX
text (Fred).

View File

@ -43,6 +43,11 @@ tzxlist \- Sinclair ZX Spectrum "real" tape file lister
.SH DESCRIPTION
tzxlist outputs a description of the contents of TZX, TAP and Warajevo
TAP tape files.
.P
On supported systems it attempts to handle conversions of the
de-facto standard TZX Windows-1252 character encoding to the charset
used on the current system. If a problem with conversion is
encountered any applicable strings will be output as-is.
.\"
.\"------------------------------------------------------------------
.\"

View File

@ -27,6 +27,12 @@
#include <errno.h>
#include <fcntl.h>
#ifdef HAVE_ICONV
#include <iconv.h>
#endif /* #ifdef HAVE_ICONV */
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif /* #ifdef HAVE_LOCALE_H */
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
@ -40,6 +46,10 @@
const char *progname;
#ifdef HAVE_ICONV
static iconv_t conversion_descriptor;
#endif /* #ifdef HAVE_ICONV */
static void
dump_symbol_table( libspectrum_tape_generalised_data_symbol_table *table )
{
@ -117,6 +127,55 @@ hardware_desc( int type, int id )
}
}
/* A simple routine to convert the input text to another character encoding.
We really are only thinking about simple conversions of accented characters,
the pound and Euro signs so just reserve 3x the input buffer size to give
"plenty" of space for the most common encondings and let any failure in
conversion fall back to just returning the source string unmodified */
static char *
convert_charset( char *input )
{
#ifdef HAVE_ICONV
const int expansion_factor = 3;
static char *output = NULL;
static size_t output_size = 0;
char* output_ptr = output;
size_t output_left = output_size;
ICONV_CONST char* input_ptr = input;
size_t input_left = strlen( input ) + 1;
size_t min_output_size = input_left * expansion_factor;
if( conversion_descriptor == (iconv_t)(-1) ) return input;
if( output_size == 0 || output_size < min_output_size ) {
output = realloc( output, min_output_size );
if( output == NULL ) {
output_size = 0;
return input;
}
output_ptr = output;
output_size = input_left * expansion_factor;
output_left = output_size;
*output = '\0';
}
if( (size_t)(-1) == iconv( conversion_descriptor, &input_ptr, &input_left,
&output_ptr, &output_left ) ) {
return input;
}
/* Write the byte sequence to get into the initial state if required. */
if( (size_t)(-1) == iconv( conversion_descriptor, NULL, NULL, &output_ptr,
&output_left ) ) {
return input;
}
return output;
#else /* #ifdef HAVE_ICONV */
return input;
#endif /* #ifdef HAVE_ICONV */
}
static void
check_checksum(unsigned long length, libspectrum_byte * data)
{
@ -288,7 +347,8 @@ process_tape( char *filename )
break;
case LIBSPECTRUM_TAPE_BLOCK_GROUP_START:
printf(" Name: %s\n", libspectrum_tape_block_text( block ) );
printf(" Name: %s\n",
convert_charset( libspectrum_tape_block_text( block ) ) );
break;
case LIBSPECTRUM_TAPE_BLOCK_GROUP_END:
@ -310,7 +370,7 @@ process_tape( char *filename )
for( i = 0; i < libspectrum_tape_block_count( block ); i++ ) {
printf(" Choice %2ld: Offset %d: %s\n", (unsigned long)i,
libspectrum_tape_block_offsets( block, i ),
libspectrum_tape_block_texts( block, i ) );
convert_charset( libspectrum_tape_block_texts( block, i ) ) );
}
break;
@ -321,7 +381,8 @@ process_tape( char *filename )
/* Fall through */
case LIBSPECTRUM_TAPE_BLOCK_COMMENT:
printf(" Comment: %s\n", libspectrum_tape_block_text( block ) );
printf(" Comment: %s\n",
convert_charset( libspectrum_tape_block_text( block ) ) );
break;
case LIBSPECTRUM_TAPE_BLOCK_ARCHIVE_INFO:
@ -340,7 +401,8 @@ process_tape( char *filename )
case 255: printf(" Comment:"); break;
default: printf("(Unknown string): "); break;
}
printf(" %s\n", libspectrum_tape_block_texts( block, i ) );
printf(" %s\n",
convert_charset( libspectrum_tape_block_texts( block, i ) ));
}
break;
@ -362,7 +424,8 @@ process_tape( char *filename )
break;
case LIBSPECTRUM_TAPE_BLOCK_CUSTOM:
printf( " Description: %s\n", libspectrum_tape_block_text( block ) );
printf( " Description: %s\n",
convert_charset( libspectrum_tape_block_text( block ) ) );
printf( " Length: %ld bytes\n",
(unsigned long)libspectrum_tape_block_data_length( block ) );
break;
@ -401,8 +464,27 @@ main( int argc, char **argv )
error = init_libspectrum(); if( error ) return error;
#ifdef HAVE_ICONV
/* Looks like GNU libc iconv needs to have the character type locale set
to do the current locale target thing (but oddly GNU libiconv doesn't) */
#ifdef HAVE_SETLOCALE
setlocale(LC_CTYPE, "");
#endif /* #ifdef HAVE_SETLOCALE */
/* Convert from Windows code page 1252 to our current locale.
CP1252 is a valid name of the Windows-1252 charset used by WoS, Tapir and
ZX-Blockeditor on at least Linux, MacOS X and Solaris 9. If we need to use
another string on another OS we will need to do a little more */
conversion_descriptor = iconv_open("", "CP1252");
#endif /* #ifdef HAVE_ICONV */
while( ++arg < argc )
ret |= process_tape( argv[arg] );
#ifdef HAVE_ICONV
if( conversion_descriptor != (iconv_t)(-1) ) {
error = iconv_close( conversion_descriptor ); if( error ) return error;
}
#endif /* #ifdef HAVE_ICONV */
return ret;
}