summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-20 13:36:42 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-20 13:36:42 +0000
commitcbaaa32d55fd87eba6882c581db2ac32ef88c3f9 (patch)
treec7c89aca11947cf477953eb5138a0b476975c364
parente3e729a0259c4c89296ac368556563ca096cd3e9 (diff)
downloadcrawl-ref-cbaaa32d55fd87eba6882c581db2ac32ef88c3f9.tar.gz
crawl-ref-cbaaa32d55fd87eba6882c581db2ac32ef88c3f9.zip
Allow UNICODE_LOCALE=. in makefile.unix to specify a setlocale(LC_ALL,"") call instead of forcing a specific locale (adapted from Guus' Debian patch). Also fixed some makefile.unix checks to strip variables that are prone to trailing spaces.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2885 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/INSTALL13
-rw-r--r--crawl-ref/source/libunix.cc7
-rw-r--r--crawl-ref/source/makefile.unix35
3 files changed, 37 insertions, 18 deletions
diff --git a/crawl-ref/INSTALL b/crawl-ref/INSTALL
index 4a4ca0c082..5a266f271a 100644
--- a/crawl-ref/INSTALL
+++ b/crawl-ref/INSTALL
@@ -361,7 +361,18 @@ not UTF-8, you can force it to UTF-8 on most systems by doing "export
LC_ALL=en_US.UTF-8" or the equivalent, depending on your language
locale and what shell you're using.
+Crawl tries to use en_US.UTF-8 as its default Unicode locale. If you
+do not have this locale installed, but do have some other UTF-8 locale,
+you can tell Crawl to use your preferred UTF-8 locale by setting
+UNICODE_LOCALE = ${foo}.UTF-8 in makefile.unix, where ${foo} is your
+locale name.
+
+You may not want to embed the locale in Crawl itself, but have Crawl
+use the locale as set in the environment LC_* variables. In such
+cases, you can use UNICODE_LOCALE = . in makefile.unix. Crawl will
+then use the locale as set in your environment.
+
If you're playing Crawl on a remote machine, the remote Crawl should be
built with Unicode support, it needs to have a UTF-8 locale installed,
*and* your local terminal (where you're running telnet/ssh) needs to be
-able to decode UTF-8.
+able to decode UTF-8. \ No newline at end of file
diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc
index 9f264cf70d..ea2d535469 100644
--- a/crawl-ref/source/libunix.cc
+++ b/crawl-ref/source/libunix.cc
@@ -216,10 +216,13 @@ static void termio_init()
tcsetattr(0, TCSAFLUSH, &game_term);
+ crawl_state.unicode_ok = false;
#ifdef UNICODE_GLYPHS
- if ((crawl_state.unicode_ok = !!setlocale(LC_ALL, UNICODE_LOCALE)))
+ if (setlocale(LC_ALL, UNICODE_LOCALE)
+ && !strcmp(nl_langinfo(CODESET), "UTF-8"))
{
- crawl_state.glyph2strfn = unix_glyph2string;
+ crawl_state.unicode_ok = true;
+ crawl_state.glyph2strfn = unix_glyph2string;
crawl_state.multibyte_strlen = unix_multibyte_strlen;
}
#endif
diff --git a/crawl-ref/source/makefile.unix b/crawl-ref/source/makefile.unix
index e671d68a25..0e8e0632e0 100644
--- a/crawl-ref/source/makefile.unix
+++ b/crawl-ref/source/makefile.unix
@@ -17,13 +17,14 @@ DELETE = rm -f
COPY = cp
OS_TYPE = UNIX
-# Change this to y if you want to use Unicode glyphs in the map, and you have
-# libncursesw available.
+# Change this to y (case-sensitive!) if you want to use Unicode glyphs
+# in the map, and you have libncursesw available.
UNICODE_GLYPHS = n
# If you're using UNICODE_GLYPHS=y, and have a preferred Unicode
# (UTF-8) locale you want Crawl to use, you can set it here. The
-# default is en_US.UTF-8.
+# default is en_US.UTF-8. If you'd prefer that Crawl use the locale
+# as set in your environment LC_* variables, use UNICODE_LOCALE = .
UNICODE_LOCALE =
# If you have lex and yacc, set DOYACC to y (lowercase y).
@@ -60,14 +61,14 @@ NDBM_FILE := /usr/include/ndbm.h
HAVE_DBH := $(shell [ -f $(DBH_FILE) ] && echo y)
HAVE_NDBM := $(shell [ -f $(NDBM_FILE) ] && echo y)
-ifeq ($(HAVE_DBH),y)
+ifeq ($(strip $(HAVE_DBH)),y)
ifneq ($(shell grep dbm_open $(DBH_FILE)),)
SELDBM := -DDB_DBH
LIBDBM := -ldb
endif
endif
-ifeq ($(HAVE_NDBM),y)
+ifeq ($(strip $(HAVE_NDBM)),y)
SELDBM ?= -DDB_NDBM
ifeq ($(SELDBM),-DDB_NDBM)
LIBDBM := -ldbm
@@ -79,7 +80,7 @@ SQLLIB := sqlite3
SQLLIBA := lib$(SQLLIB).a
FSQLLIBA := $(SQLSRC)/$(SQLLIBA)
-ifeq ($(LIBDBM),)
+ifeq ($(strip $(LIBDBM)),)
LIBDBM := -L$(SQLSRC) -lsqlite3
EXTRA_INCLUDES += -I$(SQLSRC)
EXTRA_DEPENDS += $(FSQLLIBA)
@@ -98,15 +99,15 @@ CFWARN += -Wuninitialized
CFOTHERS += -O2
endif
-ifneq ($(SAVEDIR),)
-CFOTHERS += '-DSAVE_DIR_PATH="$(SAVEDIR)"'
+ifneq ($(strip $(SAVEDIR)),)
+CFOTHERS += '-DSAVE_DIR_PATH="$(strip $(SAVEDIR))"'
endif
-ifneq ($(DATADIR),)
-CFOTHERS += '-DDATA_DIR_PATH="$(DATADIR)"'
+ifneq ($(strip $(DATADIR)),)
+CFOTHERS += '-DDATA_DIR_PATH="$(strip $(DATADIR))"'
endif
-ifeq ($(UNICODE_GLYPHS),y)
+ifeq ($(strip $(UNICODE_GLYPHS)),y)
# Include path for (n)curses with Unicode support.
INCLUDES += -I/usr/include/ncursesw
@@ -115,8 +116,12 @@ INCLUDES += -I/usr/include/ncursesw
LIBCURS = ncursesw
CFOTHERS += -DUNICODE_GLYPHS
-ifneq ($(UNICODE_LOCALE),)
-CFOTHERS += -DUNICODE_LOCALE=\"$(UNICODE_LOCALE)\"
+ifneq ($(strip $(UNICODE_LOCALE)),)
+ifneq ($(strip $(UNICODE_LOCALE)),.)
+CFOTHERS += -DUNICODE_LOCALE=\"$(strip $(UNICODE_LOCALE))\"
+else
+CFOTHERS += -DUNICODE_LOCALE=\"\"
+endif
endif
# The standard ncurses library also supports Unicode on Mac OS/Darwin.
@@ -142,11 +147,11 @@ YTABH := levcomp.tab.h
OBJECTS := $(UTIL)levcomp.tab.o $(UTIL)levcomp.lex.o $(OBJECTS)
-ifeq ($(LEX),)
+ifeq ($(strip $(LEX)),)
DOYACC :=
endif
-ifeq ($(YACC),)
+ifeq ($(strip $(YACC)),)
DOYACC :=
endif