summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-10-09 21:45:51 -0700
committerKaz Kylheku <kaz@kylheku.com>2011-10-09 21:45:51 -0700
commit889501071aeae561b026fc298e0442d2ef4e433f (patch)
tree21441698c9bfa98d227790c5ec5ec0b0c9fdd29a
parentc318e1c4bc5dbdb1dbec46bd8962e20d5654de54 (diff)
downloadtxr-889501071aeae561b026fc298e0442d2ef4e433f.tar.gz
txr-889501071aeae561b026fc298e0442d2ef4e433f.tar.bz2
txr-889501071aeae561b026fc298e0442d2ef4e433f.zip
Ported to Cygwin.
TODO: there should be some type safety with the new wli macro so that if it is forgotten, there will be a diagnostic. * configure (lit_align): New configuration variable and configuration test. Generates LIT_ALIGN in config.h. Fixed the integer-holds-pointer test for the different output from the nm program on Cygwin. The arrays become common symbols marked C which do not show an offset attribute, only size: one less column. * filter.c (to_html_table, from_html_table): wrap wide string literals with the wli macro. This must be done from now on for all literals and initializes of arrays that are going to be directly converted to type tagged val-s. * lib.h (wli): New macro. (auto_str, static_str, litptr, lit_noex): Handle wide literals on platforms where they are aligned to only two bytes, such that we don't have two bits in the pointer. We can still add our 11 bit type tag, but then when recovering the pointer to the data, we have may have to fix up the pointer. * parser.l: Another portability issue here. Flex generates a scanner which has #include <unistd.h> in the middle, after the source file's own #includes which can introduce macros. On Cygwin, there is some hygiene problem whereby our "noreturn" macro causes the <unistd.h> header to generate bad syntax and fail to compile. Stupid Cygwin and even stupider flex! The workaround is to include <unistd.h> at the top in the flex source. * stream.c (string_out_put_char): This is one more place where the string literal handling hack spreads. * txr.c (version): Wrap string in wli.
-rw-r--r--ChangeLog39
-rwxr-xr-xconfigure85
-rw-r--r--filter.c516
-rw-r--r--lib.h24
-rw-r--r--parser.l1
-rw-r--r--stream.c7
-rw-r--r--txr.c2
7 files changed, 414 insertions, 260 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ec1a1f9..53cca13c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,44 @@
2011-10-09 Kaz Kylheku <kaz@kylheku.com>
+ Ported to Cygwin.
+
+ TODO: there should be some type safety with the new wli macro
+ so that if it is forgotten, there will be a diagnostic.
+
+ * configure (lit_align): New configuration variable
+ and configuration test. Generates LIT_ALIGN in config.h.
+ Fixed the integer-holds-pointer test for the different output
+ from the nm program on Cygwin. The arrays become common symbols
+ marked C which do not show an offset attribute, only size:
+ one less column.
+
+ * filter.c (to_html_table, from_html_table): wrap wide string
+ literals with the wli macro. This must be done from now on for
+ all literals and initializes of arrays that are going to be
+ directly converted to type tagged val-s.
+
+ * lib.h (wli): New macro.
+ (auto_str, static_str, litptr, lit_noex): Handle wide literals on
+ platforms where they are aligned to only two bytes, such that we don't
+ have two bits in the pointer. We can still add our 11 bit type tag, but
+ then when recovering the pointer to the data, we have may have
+ to fix up the pointer.
+
+ * parser.l: Another portability issue here. Flex generates a scanner
+ which has #include <unistd.h> in the middle, after the source file's
+ own #includes which can introduce macros. On Cygwin, there is some
+ hygiene problem whereby our "noreturn" macro causes the <unistd.h>
+ header to generate bad syntax and fail to compile. Stupid Cygwin
+ and even stupider flex! The workaround is to include <unistd.h>
+ at the top in the flex source.
+
+ * stream.c (string_out_put_char): This is one more place where
+ the string literal handling hack spreads.
+
+ * txr.c (version): Wrap string in wli.
+
+2011-10-09 Kaz Kylheku <kaz@kylheku.com>
+
* dep.mk: Regenerated. Too easy to neglect this file.
2011-10-09 Kaz Kylheku <kaz@kylheku.com>
diff --git a/configure b/configure
index 8524f720..70b03de5 100755
--- a/configure
+++ b/configure
@@ -230,6 +230,15 @@ intptr [$intptr]
value can be converted to it. If this is blank, the configure script
will try to auto detect it.
+lit_align [$lit_align]
+
+ Specifies alignment for wide string literals. This is guessed
+ from the size of the wchar_t type. If your wchar_t type is two byte wide, but
+ wide literals are aligned to four bytes, then you should specify this. This
+ will eliminate some kludges in the program. There is no easy way to check
+ for this withut generating and running a C program, which is unfriendly
+ for cross-compiling!
+
inline [$inline]
Specifies the syntax for defining an inline function, in such
@@ -620,7 +629,15 @@ char sizeof_longlong_t[sizeof (longlong_t)];
while read symbol type offset size ; do
eval "size=$(( 0$size + 0 ))"
- eval $(printf "%s=%d\n" "$symbol" "$size")
+ symbol=${symbol#_}
+ if [ $type == "C" ] ; then
+ size=$offset
+ fi
+ case "$symbol" in
+ sizeof* )
+ eval $(printf "%s=%d\n" "$symbol" "$size")
+ ;;
+ esac
done < conftest.syms
rm -f conftest.syms conftest.o
@@ -652,6 +669,68 @@ intptr_max_expr="((((($intptr) 1 << $((sizeof_ptr * 8 - 2))) - 1) << 1) + 1)"
printf "#define INT_PTR_MAX %s\n" "$intptr_max_expr" >> config.h
printf "#define INT_PTR_MIN (-INT_PTR_MAX)\n" >> config.h
+#
+# Alignment of wchar_t
+#
+# What we really want to know is the alignment of wide string literals
+# like L"wide literal".
+#
+# We make pessimistic assumption that the size of the wchar_t type is this
+# alignment.
+#
+# There is no easy way to get the information without running a compiled
+# program.
+#
+
+printf "Conservatively guessing the alignment of wide literals ... "
+
+if [ -z "$lit_align" ] ; then
+ cat > conftest.c <<!
+#include <wchar.h>
+char sizeof_wchar_t[sizeof (wchar_t)];
+!
+ rm -f conftest.o conftest.syms
+
+ if ! make conftest.syms > conftest.err 2>&1 ; then
+ printf "failed\n\n"
+
+ printf "Errors from compilation: \n\n"
+ cat conftest.err
+ exit 1
+ fi
+
+ sizeof_wchar_t=0
+
+ while read symbol type offset size ; do
+ eval "size=$(( 0$size + 0 ))"
+ symbol=${symbol#_}
+ if [ $type == "C" ] ; then
+ size=$offset
+ fi
+ case "$symbol" in
+ sizeof* )
+ eval $(printf "%s=%d\n" "$symbol" "$size")
+ ;;
+ esac
+ done < conftest.syms
+
+ rm -f conftest.syms conftest.o
+
+ if [ $sizeof_wchar_t -eq 0 ] ; then
+ printf "failed\n"
+ exit 1
+ fi
+
+ lit_align=$sizeof_wchar_t
+fi
+
+printf "%d\n" "$lit_align"
+printf "#define LIT_ALIGN %d\n" "$lit_align" >> config.h
+
+#
+# Inline functions
+#
+
printf "Checking how to declare inline functions ... "
if [ -z "$inline" ] ; then
@@ -687,6 +766,10 @@ fi
printf '"%s"\n' "$inline"
printf "#define INLINE $inline\n" >> config.h
+#
+# Valgrind
+#
+
if [ -n "$valgrind" ] ; then
printf "Checking valgrind API availability ... "
diff --git a/filter.c b/filter.c
index 6b873b14..776a9113 100644
--- a/filter.c
+++ b/filter.c
@@ -218,268 +218,268 @@ val register_filter(val sym, val table)
}
static struct filter_pair to_html_table[] = {
- { L"<", L"&lt;" },
- { L">", L"&gt;" },
- { L"&", L"&amp;" },
- { L"\"", L"&quot;" },
+ { wli("<"), wli("&lt;") },
+ { wli(">"), wli("&gt;") },
+ { wli("&"), wli("&amp;") },
+ { wli("\""), wli("&quot;") },
{ 0, 0 }
};
static struct filter_pair from_html_table[] = {
- { L"&quot;", L"\"" },
- { L"&amp;", L"&" },
- { L"&apos;", L"'" },
- { L"&lt;", L"<" },
- { L"&gt;", L">" },
- { L"&nbsp;", L"\x00A0" },
- { L"&iexcl;", L"\x00A1" },
- { L"&cent;", L"\x00A2" },
- { L"&pound;", L"\x00A3" },
- { L"&curren;", L"\x00A4" },
- { L"&yen;", L"\x00A5" },
- { L"&brvbar;", L"\x00A6" },
- { L"&sect;", L"\x00A7" },
- { L"&uml;", L"\x00A8" },
- { L"&copy;", L"\x00A9" },
- { L"&ordf;", L"\x00AA" },
- { L"&laquo;", L"\x00AB" },
- { L"&not;", L"\x00AC" },
- { L"&shy;", L"\x00AD" },
- { L"&reg;", L"\x00AE" },
- { L"&macr;", L"\x00AF" },
- { L"&deg;", L"\x00B0" },
- { L"&plusmn;", L"\x00B1" },
- { L"&sup2;", L"\x00B2" },
- { L"&sup3;", L"\x00B3" },
- { L"&acute;", L"\x00B4" },
- { L"&micro;", L"\x00B5" },
- { L"&para;", L"\x00B6" },
- { L"&middot;", L"\x00B7" },
- { L"&cedil;", L"\x00B8" },
- { L"&sup1;", L"\x00B9" },
- { L"&ordm;", L"\x00BA" },
- { L"&raquo;", L"\x00BB" },
- { L"&frac14;", L"\x00BC" },
- { L"&frac12;", L"\x00BD" },
- { L"&frac34;", L"\x00BE" },
- { L"&iquest;", L"\x00BF" },
- { L"&Agrave;", L"\x00C0" },
- { L"&Aacute;", L"\x00C1" },
- { L"&Acirc;", L"\x00C2" },
- { L"&Atilde;", L"\x00C3" },
- { L"&Auml;", L"\x00C4" },
- { L"&Aring;", L"\x00C5" },
- { L"&AElig;", L"\x00C6" },
- { L"&Ccedil;", L"\x00C7" },
- { L"&Egrave;", L"\x00C8" },
- { L"&Eacute;", L"\x00C9" },
- { L"&Ecirc;", L"\x00CA" },
- { L"&Euml;", L"\x00CB" },
- { L"&Igrave;", L"\x00CC" },
- { L"&Iacute;", L"\x00CD" },
- { L"&Icirc;", L"\x00CE" },
- { L"&Iuml;", L"\x00CF" },
- { L"&ETH;", L"\x00D0" },
- { L"&Ntilde;", L"\x00D1" },
- { L"&Ograve;", L"\x00D2" },
- { L"&Oacute;", L"\x00D3" },
- { L"&Ocirc;", L"\x00D4" },
- { L"&Otilde;", L"\x00D5" },
- { L"&Ouml;", L"\x00D6" },
- { L"&times;", L"\x00D7" },
- { L"&Oslash;", L"\x00D8" },
- { L"&Ugrave;", L"\x00D9" },
- { L"&Uacute;", L"\x00DA" },
- { L"&Ucirc;", L"\x00DB" },
- { L"&Uuml;", L"\x00DC" },
- { L"&Yacute;", L"\x00DD" },
- { L"&THORN;", L"\x00DE" },
- { L"&szlig;", L"\x00DF" },
- { L"&agrave;", L"\x00E0" },
- { L"&aacute;", L"\x00E1" },
- { L"&acirc;", L"\x00E2" },
- { L"&atilde;", L"\x00E3" },
- { L"&auml;", L"\x00E4" },
- { L"&aring;", L"\x00E5" },
- { L"&aelig;", L"\x00E6" },
- { L"&ccedil;", L"\x00E7" },
- { L"&egrave;", L"\x00E8" },
- { L"&eacute;", L"\x00E9" },
- { L"&ecirc;", L"\x00EA" },
- { L"&euml;", L"\x00EB" },
- { L"&igrave;", L"\x00EC" },
- { L"&iacute;", L"\x00ED" },
- { L"&icirc;", L"\x00EE" },
- { L"&iuml;", L"\x00EF" },
- { L"&eth;", L"\x00F0" },
- { L"&ntilde;", L"\x00F1" },
- { L"&ograve;", L"\x00F2" },
- { L"&oacute;", L"\x00F3" },
- { L"&ocirc;", L"\x00F4" },
- { L"&otilde;", L"\x00F5" },
- { L"&ouml;", L"\x00F6" },
- { L"&divide;", L"\x00F7" },
- { L"&oslash;", L"\x00F8" },
- { L"&ugrave;", L"\x00F9" },
- { L"&uacute;", L"\x00FA" },
- { L"&ucirc;", L"\x00FB" },
- { L"&uuml;", L"\x00FC" },
- { L"&yacute;", L"\x00FD" },
- { L"&thorn;", L"\x00FE" },
- { L"&yuml;", L"\x00FF" },
- { L"&OElig;", L"\x0152" },
- { L"&oelig;", L"\x0153" },
- { L"&Scaron;", L"\x0160" },
- { L"&scaron;", L"\x0161" },
- { L"&Yuml;", L"\x0178" },
- { L"&fnof;", L"\x0192" },
- { L"&circ;", L"\x02C6" },
- { L"&tilde;", L"\x02DC" },
- { L"&Alpha;", L"\x0391" },
- { L"&Beta;", L"\x0392" },
- { L"&Gamma;", L"\x0393" },
- { L"&Delta;", L"\x0394" },
- { L"&Epsilon;", L"\x0395" },
- { L"&Zeta;", L"\x0396" },
- { L"&Eta;", L"\x0397" },
- { L"&Theta;", L"\x0398" },
- { L"&Iota;", L"\x0399" },
- { L"&Kappa;", L"\x039A" },
- { L"&Lambda;", L"\x039B" },
- { L"&Mu;", L"\x039C" },
- { L"&Nu;", L"\x039D" },
- { L"&Xi;", L"\x039E" },
- { L"&Omicron;", L"\x039F" },
- { L"&Pi;", L"\x03A0" },
- { L"&Rho;", L"\x03A1" },
- { L"&Sigma;", L"\x03A3" },
- { L"&Tau;", L"\x03A4" },
- { L"&Upsilon;", L"\x03A5" },
- { L"&Phi;", L"\x03A6" },
- { L"&Chi;", L"\x03A7" },
- { L"&Psi;", L"\x03A8" },
- { L"&Omega;", L"\x03A9" },
- { L"&alpha;", L"\x03B1" },
- { L"&beta;", L"\x03B2" },
- { L"&gamma;", L"\x03B3" },
- { L"&delta;", L"\x03B4" },
- { L"&epsilon;", L"\x03B5" },
- { L"&zeta;", L"\x03B6" },
- { L"&eta;", L"\x03B7" },
- { L"&theta;", L"\x03B8" },
- { L"&iota;", L"\x03B9" },
- { L"&kappa;", L"\x03BA" },
- { L"&lambda;", L"\x03BB" },
- { L"&mu;", L"\x03BC" },
- { L"&nu;", L"\x03BD" },
- { L"&xi;", L"\x03BE" },
- { L"&omicron;", L"\x03BF" },
- { L"&pi;", L"\x03C0" },
- { L"&rho;", L"\x03C1" },
- { L"&sigmaf;", L"\x03C2" },
- { L"&sigma;", L"\x03C3" },
- { L"&tau;", L"\x03C4" },
- { L"&upsilon;", L"\x03C5" },
- { L"&phi;", L"\x03C6" },
- { L"&chi;", L"\x03C7" },
- { L"&psi;", L"\x03C8" },
- { L"&omega;", L"\x03C9" },
- { L"&thetasym;", L"\x03D1" },
- { L"&upsih;", L"\x03D2" },
- { L"&piv;", L"\x03D6" },
- { L"&ensp;", L"\x2002" },
- { L"&emsp;", L"\x2003" },
- { L"&thinsp;", L"\x2009" },
- { L"&zwnj;", L"\x200C" },
- { L"&zwj;", L"\x200D" },
- { L"&lrm;", L"\x200E" },
- { L"&rlm;", L"\x200F" },
- { L"&ndash;", L"\x2013" },
- { L"&mdash;", L"\x2014" },
- { L"&lsquo;", L"\x2018" },
- { L"&rsquo;", L"\x2019" },
- { L"&sbquo;", L"\x201A" },
- { L"&ldquo;", L"\x201C" },
- { L"&rdquo;", L"\x201D" },
- { L"&bdquo;", L"\x201E" },
- { L"&dagger;", L"\x2020" },
- { L"&Dagger;", L"\x2021" },
- { L"&bull;", L"\x2022" },
- { L"&hellip;", L"\x2026" },
- { L"&permil;", L"\x2030" },
- { L"&prime;", L"\x2032" },
- { L"&Prime;", L"\x2033" },
- { L"&lsaquo;", L"\x2039" },
- { L"&rsaquo;", L"\x203A" },
- { L"&oline;", L"\x203E" },
- { L"&frasl;", L"\x2044" },
- { L"&euro;", L"\x20AC" },
- { L"&image;", L"\x2111" },
- { L"&weierp;", L"\x2118" },
- { L"&real;", L"\x211C" },
- { L"&trade;", L"\x2122" },
- { L"&alefsym;", L"\x2135" },
- { L"&larr;", L"\x2190" },
- { L"&uarr;", L"\x2191" },
- { L"&rarr;", L"\x2192" },
- { L"&darr;", L"\x2193" },
- { L"&harr;", L"\x2194" },
- { L"&crarr;", L"\x21B5" },
- { L"&lArr;", L"\x21D0" },
- { L"&uArr;", L"\x21D1" },
- { L"&rArr;", L"\x21D2" },
- { L"&dArr;", L"\x21D3" },
- { L"&hArr;", L"\x21D4" },
- { L"&forall;", L"\x2200" },
- { L"&part;", L"\x2202" },
- { L"&exist;", L"\x2203" },
- { L"&empty;", L"\x2205" },
- { L"&nabla;", L"\x2207" },
- { L"&isin;", L"\x2208" },
- { L"&notin;", L"\x2209" },
- { L"&ni;", L"\x220B" },
- { L"&prod;", L"\x220F" },
- { L"&sum;", L"\x2211" },
- { L"&minus;", L"\x2212" },
- { L"&lowast;", L"\x2217" },
- { L"&radic;", L"\x221A" },
- { L"&prop;", L"\x221D" },
- { L"&infin;", L"\x221E" },
- { L"&ang;", L"\x2220" },
- { L"&and;", L"\x2227" },
- { L"&or;", L"\x2228" },
- { L"&cap;", L"\x2229" },
- { L"&cup;", L"\x222A" },
- { L"&int;", L"\x222B" },
- { L"&there4;", L"\x2234" },
- { L"&sim;", L"\x223C" },
- { L"&cong;", L"\x2245" },
- { L"&asymp;", L"\x2248" },
- { L"&ne;", L"\x2260" },
- { L"&equiv;", L"\x2261" },
- { L"&le;", L"\x2264" },
- { L"&ge;", L"\x2265" },
- { L"&sub;", L"\x2282" },
- { L"&sup;", L"\x2283" },
- { L"&nsub;", L"\x2284" },
- { L"&sube;", L"\x2286" },
- { L"&supe;", L"\x2287" },
- { L"&oplus;", L"\x2295" },
- { L"&otimes;", L"\x2297" },
- { L"&perp;", L"\x22A5" },
- { L"&sdot;", L"\x22C5" },
- { L"&lceil;", L"\x2308" },
- { L"&rceil;", L"\x2309" },
- { L"&lfloor;", L"\x230A" },
- { L"&rfloor;", L"\x230B" },
- { L"&lang;", L"\x2329" },
- { L"&rang;", L"\x232A" },
- { L"&loz;", L"\x25CA" },
- { L"&spades;", L"\x2660" },
- { L"&clubs;", L"\x2663" },
- { L"&hearts;", L"\x2665" },
- { L"&diams;", L"\x2666" },
- { 0, 0 }
+ { wli("&quot;"), wli("\"") },
+ { wli("&amp;"), wli("&") },
+ { wli("&apos;"), wli("'") },
+ { wli("&lt;"), wli("<") },
+ { wli("&gt;"), wli(">") },
+ { wli("&nbsp;"), wli("\x00A0") },
+ { wli("&iexcl;"), wli("\x00A1") },
+ { wli("&cent;"), wli("\x00A2") },
+ { wli("&pound;"), wli("\x00A3") },
+ { wli("&curren;"), wli("\x00A4") },
+ { wli("&yen;"), wli("\x00A5") },
+ { wli("&brvbar;"), wli("\x00A6") },
+ { wli("&sect;"), wli("\x00A7") },
+ { wli("&uml;"), wli("\x00A8") },
+ { wli("&copy;"), wli("\x00A9") },
+ { wli("&ordf;"), wli("\x00AA") },
+ { wli("&laquo;"), wli("\x00AB") },
+ { wli("&not;"), wli("\x00AC") },
+ { wli("&shy;"), wli("\x00AD") },
+ { wli("&reg;"), wli("\x00AE") },
+ { wli("&macr;"), wli("\x00AF") },
+ { wli("&deg;"), wli("\x00B0") },
+ { wli("&plusmn;"), wli("\x00B1") },
+ { wli("&sup2;"), wli("\x00B2") },
+ { wli("&sup3;"), wli("\x00B3") },
+ { wli("&acute;"), wli("\x00B4") },
+ { wli("&micro;"), wli("\x00B5") },
+ { wli("&para;"), wli("\x00B6") },
+ { wli("&middot;"), wli("\x00B7") },
+ { wli("&cedil;"), wli("\x00B8") },
+ { wli("&sup1;"), wli("\x00B9") },
+ { wli("&ordm;"), wli("\x00BA") },
+ { wli("&raquo;"), wli("\x00BB") },
+ { wli("&frac14;"), wli("\x00BC") },
+ { wli("&frac12;"), wli("\x00BD") },
+ { wli("&frac34;"), wli("\x00BE") },
+ { wli("&iquest;"), wli("\x00BF") },
+ { wli("&Agrave;"), wli("\x00C0") },
+ { wli("&Aacute;"), wli("\x00C1") },
+ { wli("&Acirc;"), wli("\x00C2") },
+ { wli("&Atilde;"), wli("\x00C3") },
+ { wli("&Auml;"), wli("\x00C4") },
+ { wli("&Aring;"), wli("\x00C5") },
+ { wli("&AElig;"), wli("\x00C6") },
+ { wli("&Ccedil;"), wli("\x00C7") },
+ { wli("&Egrave;"), wli("\x00C8") },
+ { wli("&Eacute;"), wli("\x00C9") },
+ { wli("&Ecirc;"), wli("\x00CA") },
+ { wli("&Euml;"), wli("\x00CB") },
+ { wli("&Igrave;"), wli("\x00CC") },
+ { wli("&Iacute;"), wli("\x00CD") },
+ { wli("&Icirc;"), wli("\x00CE") },
+ { wli("&Iuml;"), wli("\x00CF") },
+ { wli("&ETH;"), wli("\x00D0") },
+ { wli("&Ntilde;"), wli("\x00D1") },
+ { wli("&Ograve;"), wli("\x00D2") },
+ { wli("&Oacute;"), wli("\x00D3") },
+ { wli("&Ocirc;"), wli("\x00D4") },
+ { wli("&Otilde;"), wli("\x00D5") },
+ { wli("&Ouml;"), wli("\x00D6") },
+ { wli("&times;"), wli("\x00D7") },
+ { wli("&Oslash;"), wli("\x00D8") },
+ { wli("&Ugrave;"), wli("\x00D9") },
+ { wli("&Uacute;"), wli("\x00DA") },
+ { wli("&Ucirc;"), wli("\x00DB") },
+ { wli("&Uuml;"), wli("\x00DC") },
+ { wli("&Yacute;"), wli("\x00DD") },
+ { wli("&THORN;"), wli("\x00DE") },
+ { wli("&szlig;"), wli("\x00DF") },
+ { wli("&agrave;"), wli("\x00E0") },
+ { wli("&aacute;"), wli("\x00E1") },
+ { wli("&acirc;"), wli("\x00E2") },
+ { wli("&atilde;"), wli("\x00E3") },
+ { wli("&auml;"), wli("\x00E4") },
+ { wli("&aring;"), wli("\x00E5") },
+ { wli("&aelig;"), wli("\x00E6") },
+ { wli("&ccedil;"), wli("\x00E7") },
+ { wli("&egrave;"), wli("\x00E8") },
+ { wli("&eacute;"), wli("\x00E9") },
+ { wli("&ecirc;"), wli("\x00EA") },
+ { wli("&euml;"), wli("\x00EB") },
+ { wli("&igrave;"), wli("\x00EC") },
+ { wli("&iacute;"), wli("\x00ED") },
+ { wli("&icirc;"), wli("\x00EE") },
+ { wli("&iuml;"), wli("\x00EF") },
+ { wli("&eth;"), wli("\x00F0") },
+ { wli("&ntilde;"), wli("\x00F1") },
+ { wli("&ograve;"), wli("\x00F2") },
+ { wli("&oacute;"), wli("\x00F3") },
+ { wli("&ocirc;"), wli("\x00F4") },
+ { wli("&otilde;"), wli("\x00F5") },
+ { wli("&ouml;"), wli("\x00F6") },
+ { wli("&divide;"), wli("\x00F7") },
+ { wli("&oslash;"), wli("\x00F8") },
+ { wli("&ugrave;"), wli("\x00F9") },
+ { wli("&uacute;"), wli("\x00FA") },
+ { wli("&ucirc;"), wli("\x00FB") },
+ { wli("&uuml;"), wli("\x00FC") },
+ { wli("&yacute;"), wli("\x00FD") },
+ { wli("&thorn;"), wli("\x00FE") },
+ { wli("&yuml;"), wli("\x00FF") },
+ { wli("&OElig;"), wli("\x0152") },
+ { wli("&oelig;"), wli("\x0153") },
+ { wli("&Scaron;"), wli("\x0160") },
+ { wli("&scaron;"), wli("\x0161") },
+ { wli("&Yuml;"), wli("\x0178") },
+ { wli("&fnof;"), wli("\x0192") },
+ { wli("&circ;"), wli("\x02C6") },
+ { wli("&tilde;"), wli("\x02DC") },
+ { wli("&Alpha;"), wli("\x0391") },
+ { wli("&Beta;"), wli("\x0392") },
+ { wli("&Gamma;"), wli("\x0393") },
+ { wli("&Delta;"), wli("\x0394") },
+ { wli("&Epsilon;"), wli("\x0395") },
+ { wli("&Zeta;"), wli("\x0396") },
+ { wli("&Eta;"), wli("\x0397") },
+ { wli("&Theta;"), wli("\x0398") },
+ { wli("&Iota;"), wli("\x0399") },
+ { wli("&Kappa;"), wli("\x039A") },
+ { wli("&Lambda;"), wli("\x039B") },
+ { wli("&Mu;"), wli("\x039C") },
+ { wli("&Nu;"), wli("\x039D") },
+ { wli("&Xi;"), wli("\x039E") },
+ { wli("&Omicron;"), wli("\x039F") },
+ { wli("&Pi;"), wli("\x03A0") },
+ { wli("&Rho;"), wli("\x03A1") },
+ { wli("&Sigma;"), wli("\x03A3") },
+ { wli("&Tau;"), wli("\x03A4") },
+ { wli("&Upsilon;"), wli("\x03A5") },
+ { wli("&Phi;"), wli("\x03A6") },
+ { wli("&Chi;"), wli("\x03A7") },
+ { wli("&Psi;"), wli("\x03A8") },
+ { wli("&Omega;"), wli("\x03A9") },
+ { wli("&alpha;"), wli("\x03B1") },
+ { wli("&beta;"), wli("\x03B2") },
+ { wli("&gamma;"), wli("\x03B3") },
+ { wli("&delta;"), wli("\x03B4") },
+ { wli("&epsilon;"), wli("\x03B5") },
+ { wli("&zeta;"), wli("\x03B6") },
+ { wli("&eta;"), wli("\x03B7") },
+ { wli("&theta;"), wli("\x03B8") },
+ { wli("&iota;"), wli("\x03B9") },
+ { wli("&kappa;"), wli("\x03BA") },
+ { wli("&lambda;"), wli("\x03BB") },
+ { wli("&mu;"), wli("\x03BC") },
+ { wli("&nu;"), wli("\x03BD") },
+ { wli("&xi;"), wli("\x03BE") },
+ { wli("&omicron;"), wli("\x03BF") },
+ { wli("&pi;"), wli("\x03C0") },
+ { wli("&rho;"), wli("\x03C1") },
+ { wli("&sigmaf;"), wli("\x03C2") },
+ { wli("&sigma;"), wli("\x03C3") },
+ { wli("&tau;"), wli("\x03C4") },
+ { wli("&upsilon;"), wli("\x03C5") },
+ { wli("&phi;"), wli("\x03C6") },
+ { wli("&chi;"), wli("\x03C7") },
+ { wli("&psi;"), wli("\x03C8") },
+ { wli("&omega;"), wli("\x03C9") },
+ { wli("&thetasym;"), wli("\x03D1") },
+ { wli("&upsih;"), wli("\x03D2") },
+ { wli("&piv;"), wli("\x03D6") },
+ { wli("&ensp;"), wli("\x2002") },
+ { wli("&emsp;"), wli("\x2003") },
+ { wli("&thinsp;"), wli("\x2009") },
+ { wli("&zwnj;"), wli("\x200C") },
+ { wli("&zwj;"), wli("\x200D") },
+ { wli("&lrm;"), wli("\x200E") },
+ { wli("&rlm;"), wli("\x200F") },
+ { wli("&ndash;"), wli("\x2013") },
+ { wli("&mdash;"), wli("\x2014") },
+ { wli("&lsquo;"), wli("\x2018") },
+ { wli("&rsquo;"), wli("\x2019") },
+ { wli("&sbquo;"), wli("\x201A") },
+ { wli("&ldquo;"), wli("\x201C") },
+ { wli("&rdquo;"), wli("\x201D") },
+ { wli("&bdquo;"), wli("\x201E") },
+ { wli("&dagger;"), wli("\x2020") },
+ { wli("&Dagger;"), wli("\x2021") },
+ { wli("&bull;"), wli("\x2022") },
+ { wli("&hellip;"), wli("\x2026") },
+ { wli("&permil;"), wli("\x2030") },
+ { wli("&prime;"), wli("\x2032") },
+ { wli("&Prime;"), wli("\x2033") },
+ { wli("&lsaquo;"), wli("\x2039") },
+ { wli("&rsaquo;"), wli("\x203A") },
+ { wli("&oline;"), wli("\x203E") },
+ { wli("&frasl;"), wli("\x2044") },
+ { wli("&euro;"), wli("\x20AC") },
+ { wli("&image;"), wli("\x2111") },
+ { wli("&weierp;"), wli("\x2118") },
+ { wli("&real;"), wli("\x211C") },
+ { wli("&trade;"), wli("\x2122") },
+ { wli("&alefsym;"), wli("\x2135") },
+ { wli("&larr;"), wli("\x2190") },
+ { wli("&uarr;"), wli("\x2191") },
+ { wli("&rarr;"), wli("\x2192") },
+ { wli("&darr;"), wli("\x2193") },
+ { wli("&harr;"), wli("\x2194") },
+ { wli("&crarr;"), wli("\x21B5") },
+ { wli("&lArr;"), wli("\x21D0") },
+ { wli("&uArr;"), wli("\x21D1") },
+ { wli("&rArr;"), wli("\x21D2") },
+ { wli("&dArr;"), wli("\x21D3") },
+ { wli("&hArr;"), wli("\x21D4") },
+ { wli("&forall;"), wli("\x2200") },
+ { wli("&part;"), wli("\x2202") },
+ { wli("&exist;"), wli("\x2203") },
+ { wli("&empty;"), wli("\x2205") },
+ { wli("&nabla;"), wli("\x2207") },
+ { wli("&isin;"), wli("\x2208") },
+ { wli("&notin;"), wli("\x2209") },
+ { wli("&ni;"), wli("\x220B") },
+ { wli("&prod;"), wli("\x220F") },
+ { wli("&sum;"), wli("\x2211") },
+ { wli("&minus;"), wli("\x2212") },
+ { wli("&lowast;"), wli("\x2217") },
+ { wli("&radic;"), wli("\x221A") },
+ { wli("&prop;"), wli("\x221D") },
+ { wli("&infin;"), wli("\x221E") },
+ { wli("&ang;"), wli("\x2220") },
+ { wli("&and;"), wli("\x2227") },
+ { wli("&or;"), wli("\x2228") },
+ { wli("&cap;"), wli("\x2229") },
+ { wli("&cup;"), wli("\x222A") },
+ { wli("&int;"), wli("\x222B") },
+ { wli("&there4;"), wli("\x2234") },
+ { wli("&sim;"), wli("\x223C") },
+ { wli("&cong;"), wli("\x2245") },
+ { wli("&asymp;"), wli("\x2248") },
+ { wli("&ne;"), wli("\x2260") },
+ { wli("&equiv;"), wli("\x2261") },
+ { wli("&le;"), wli("\x2264") },
+ { wli("&ge;"), wli("\x2265") },
+ { wli("&sub;"), wli("\x2282") },
+ { wli("&sup;"), wli("\x2283") },
+ { wli("&nsub;"), wli("\x2284") },
+ { wli("&sube;"), wli("\x2286") },
+ { wli("&supe;"), wli("\x2287") },
+ { wli("&oplus;"), wli("\x2295") },
+ { wli("&otimes;"), wli("\x2297") },
+ { wli("&perp;"), wli("\x22A5") },
+ { wli("&sdot;"), wli("\x22C5") },
+ { wli("&lceil;"), wli("\x2308") },
+ { wli("&rceil;"), wli("\x2309") },
+ { wli("&lfloor;"), wli("\x230A") },
+ { wli("&rfloor;"), wli("\x230B") },
+ { wli("&lang;"), wli("\x2329") },
+ { wli("&rang;"), wli("\x232A") },
+ { wli("&loz;"), wli("\x25CA") },
+ { wli("&spades;"), wli("\x2660") },
+ { wli("&clubs;"), wli("\x2663") },
+ { wli("&hearts;"), wli("\x2665") },
+ { wli("&diams;"), wli("\x2666") },
+ { 0, 0 }
};
static val html_hex_continue(val hexlist, val ch)
diff --git a/lib.h b/lib.h
index dda8dfbd..592e187b 100644
--- a/lib.h
+++ b/lib.h
@@ -188,19 +188,38 @@ INLINE type_t type(val obj)
return tag(obj) ? (type_t) tag(obj) : obj->t.type;
}
+#if LIT_ALIGN < 4
+#define wli(lit) (L ## "\0" lit)
+#else
+#define wli(lit) (L ## lit)
+#endif
+
INLINE val auto_str(const wchar_t *str)
{
+#if LIT_ALIGN < 4
+ return (val) ((cnum) (str + 1) | TAG_LIT);
+#else
return (val) ((cnum) (str) | TAG_LIT);
+#endif
}
INLINE val static_str(const wchar_t *str)
{
+#if LIT_ALIGN < 4
+ return (val) ((cnum) (str + 1) | TAG_LIT);
+#else
return (val) ((cnum) (str) | TAG_LIT);
+#endif
}
INLINE wchar_t *litptr(val obj)
{
+#if LIT_ALIGN < 4
+ wchar_t *ret = (wchar_t *) ((cnum) obj & ~TAG_MASK);
+ return (*ret == 0) ? ret + 1 : ret;
+#else
return (wchar_t *) ((cnum) obj & ~TAG_MASK);
+#endif
}
INLINE val num_fast(cnum n)
@@ -213,7 +232,12 @@ INLINE val chr(wchar_t ch)
return (val) (((cnum) ch << TAG_SHIFT) | TAG_CHR);
}
+#if LIT_ALIGN < 4
+#define lit_noex(strlit) ((obj_t *) ((cnum) (L ## "\0" L ## strlit + 1) | TAG_LIT))
+#else
#define lit_noex(strlit) ((obj_t *) ((cnum) (L ## strlit) | TAG_LIT))
+#endif
+
#define lit(strlit) lit_noex(strlit)
extern val keyword_package, system_package, user_package;
diff --git a/parser.l b/parser.l
index 6441eceb..c9c39764 100644
--- a/parser.l
+++ b/parser.l
@@ -35,6 +35,7 @@
#include <dirent.h>
#include <wchar.h>
#include <setjmp.h>
+#include <unistd.h>
#include "config.h"
#include "lib.h"
#include "y.tab.h"
diff --git a/stream.c b/stream.c
index 28fa3b84..f15e7b2a 100644
--- a/stream.c
+++ b/stream.c
@@ -415,9 +415,16 @@ static val string_out_put_string(val stream, val str)
static val string_out_put_char(val stream, val ch)
{
+#if LIT_ALIGN < 4
+ wchar_t mini[3];
+ mini[0] = 0;
+ mini[1] = c_chr(ch);
+ mini[2] = 0;
+#else
wchar_t mini[2];
mini[0] = c_chr(ch);
mini[1] = 0;
+#endif
return string_out_put_string(stream, auto_str(mini));
}
diff --git a/txr.c b/txr.c
index 3acb625b..1f0d7197 100644
--- a/txr.c
+++ b/txr.c
@@ -43,7 +43,7 @@
#include "utf8.h"
#include "txr.h"
-const wchar_t *version = L"038";
+const wchar_t *version = wli("038");
const wchar_t *progname = L"txr";
const wchar_t *spec_file = L"stdin";
val spec_file_str;