Commit e2bffe43 authored by Michael Hanus 's avatar Michael Hanus

Setting of UTF-8 encoding environment in generated executables (saved states) improved

parent 6b68ca68
......@@ -6,16 +6,35 @@ Installation Instructions
The current version of PAKCS runs on Unix-based platforms
and has been developed and tested under Linux (Debian/Ubuntu).
However, it should also run on similar platforms like Mac OS X or SunOS.
However, it should also run on similar platforms like macOS.
If you want to install and run the complete system
on your computer, you need the following software:
* [SICStus-Prolog](http://www.sics.se/sicstus.html)
(Version 4.0 or higher) (recommended)
(Version 4.0 or higher) (recommended), or
* [SWI-Prolog](http://www.swi-prolog.org)
(if you do not have SICStus-Prolog, but then the execution is less
efficient)
If you install PAKCS from the source code distribution,
you need also the Haskell build tool
[Stack](https://docs.haskellstack.org/)
to compile the front end of PAKCS.
A note on encoding source files
-------------------------------
PAKCS assumes that non-ASCII characters in source files are UTF-8 encoded.
Therefore, the locale environment variable `LC_ALL` must be
set to some UTF-8 encoding which will be used by the interactive
environment, the compiler, and in generated executables.
For instance, this can be achieved by setting
> export LC_ALL=C.UTF-8
before installing PAKCS.
How to generate and install the PAKCS kernel:
---------------------------------------------
......
......@@ -12,8 +12,8 @@ RUN apt-get --assume-yes install swi-prolog
RUN rm -rf /var/lib/apt/lists/*
# just to be sure
ENV LANG C.UTF-8
# ensure UTF-8 encoding
ENV LC_ALL C.UTF-8
# copy, unpack and install pakcs
WORKDIR /pakcs
......
......@@ -15,8 +15,8 @@ RUN apt-get --assume-yes install swi-prolog
RUN rm -rf /var/lib/apt/lists/*
# just to be sure
ENV LANG C.UTF-8
# ensure UTF-8 encoding
ENV LC_ALL C.UTF-8
# copy, unpack and install pakcs
WORKDIR /pakcs
......
......@@ -15,8 +15,8 @@ RUN apt-get --assume-yes install swi-prolog
RUN rm -rf /var/lib/apt/lists/*
# just to be sure
ENV LANG C.UTF-8
# ensure UTF-8 encoding
ENV LC_ALL C.UTF-8
# copy, unpack and install pakcs
WORKDIR /pakcs
......
......@@ -29,7 +29,7 @@ $\alpha$ \sor{} $\beta$ & alternative \\
\end{table}
\noindent
The Curry files are expected to be encoded in UTF8.
The Curry files are expected to be encoded in UTF-8.
However, source programs are biased towards ASCII for compatibility reasons.
\subsection{Lexicon}
......
......@@ -5,6 +5,23 @@
# PAKCSHOME/bin/sicstusprolog (if SICStus-Prolog is available)
# PAKCSHOME/bin/swiprolog (if SWI-Prolog is available)
# Check LC_ALL, LC_CTYPE, or LANG for UTF-8 encoding:
if [ -n "$LC_ALL" ] ; then
LCALL=$LC_ALL
elif [ -n "$LC_CTYPE" ] ; then
LCALL=$LC_CTYPE
else
LCALL=$LANG
fi
case "$LCALL" in
*UTF-8 | *UTF8 | *utf-8 | *utf8 ) ;;
* ) echo "WARNING: locale/LC_ALL has no UTF-8 encoding but value '$LCALL'"
echo "Since PAKCS might not work correctly with non-ASCII files,"
echo "LC_ALL is set to 'C.UTF-8' in generated executables."
echo "If this does not work, please set LC_ALL to another UTF-8 value."
LCALL=C.UTF-8 ;;
esac
# Compute home of PAKCS installation:
PAKCSHOME=`(cd "\`dirname \"$0\"\`" > /dev/null ; pwd)`/..
......@@ -62,6 +79,7 @@ if [ -z "$SICSTUSPROLOG" -a -z "$SWIPROLOG" ] ; then
exit 1
fi
# Configure `scripts/makesavedstate` which is used to generate executables:
ORGMAKESTATE=scripts/pakcs-makesavedstate.sh
MAKESTATE=scripts/makesavedstate
# Create symbolic links in PAKCSHOME/bin and create scripts/makesavedstate:
......@@ -70,13 +88,17 @@ if [ -n "$SICSTUSPROLOG" ] ; then
ln -s "$SICSTUSPROLOG" bin/sicstusprolog
SICSTUSBINDIR=`expr $SICSTUSPROLOG : '\(.*\)/sicstus'`
# store the value of SICSTUSBINDIR in script scripts/makesavedstate :
sed "s|^SICSTUSBINDIR=.*$|SICSTUSBINDIR=$SICSTUSBINDIR|" < $ORGMAKESTATE > $MAKESTATE
cat $ORGMAKESTATE |
sed "s|^LCALL=.*$|LCALL=$LCALL|" |
sed "s|^SICSTUSBINDIR=.*$|SICSTUSBINDIR=$SICSTUSBINDIR|" > $MAKESTATE
chmod 755 $MAKESTATE
fi
if [ -n "$SWIPROLOG" ] ; then
ln -s "$SWIPROLOG" bin/swiprolog
# store the value of SWIPROLOG in script scripts/makesavedstate :
sed "s|^SWIPROLOG=.*$|SWIPROLOG=$SWIPROLOG|" < $ORGMAKESTATE > $MAKESTATE
cat $ORGMAKESTATE |
sed "s|^LCALL=.*$|LCALL=$LCALL|" |
sed "s|^SWIPROLOG=.*$|SWIPROLOG=$SWIPROLOG|" > $MAKESTATE
chmod 755 $MAKESTATE
fi
......
......@@ -4,11 +4,16 @@
# a saved state that is executable independent of the
# generation environment, i.e.,
# - add path information to the saved state
# - add locale information (LANG, LC_ALL) to the saved state
# - add locale information (LC_ALL) to the saved state
##############################################################################
# Global settings:
# The value of the locale environment variable LC_ALL when PAKCS is
# configured. It must be a UTF-8 encoding and will be set in generated
# executables (see below).
LCALL=
# bin directory of the SICStus-Prolog installation, i.e.,
# $SICSTUSBINDIR/sicstus should be the name of the interpreter executable:
SICSTUSBINDIR=
......@@ -114,14 +119,11 @@ fi
TMPFILE=TMPSAVEDSTATE$$
echo "#!/bin/sh" > $TMPFILE
if test -n "$LANG" ; then
echo "LANG=$LANG" >> $TMPFILE
echo "export LANG" >> $TMPFILE
fi
if test -n "$LC_ALL" ; then
echo "LC_ALL=$LC_ALL" >> $TMPFILE
echo "export LC_ALL" >> $TMPFILE
fi
# Set LC_ALL in saved states to the installation value of LC_ALL.
# When PAKCS is installed, LC_ALL should be UTF-8 encoding to ensure
# the correct reading of source programs with UTF-8 encoding.
echo "LC_ALL=$LCALL" >> $TMPFILE
echo "export LC_ALL" >> $TMPFILE
if [ -n "$SICSTUSBINDIR" ] ; then
# add SICSTUSBINDIR to path so that SICStus can find its binary:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment