Browse Source

The conditional using of locale functions.

git-svn-id: https://klish.googlecode.com/svn/trunk@343 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
566921f938
6 changed files with 121 additions and 14 deletions
  1. 22 0
      aclocal.m4
  2. 12 1
      bin/clish.cpp
  3. 6 0
      config.h.in
  4. 67 10
      configure
  5. 13 2
      configure.ac
  6. 1 1
      contrib/buildroot/package/klish/klish.mk

+ 22 - 0
aclocal.m4

@@ -19,6 +19,28 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically `autoreconf'.])])
 
+# codeset.m4 serial 4 (gettext-0.18)
+dnl Copyright (C) 2000-2002, 2006, 2008-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_LANGINFO_CODESET],
+[
+  AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
+    [AC_TRY_LINK([#include <langinfo.h>],
+      [char* cs = nl_langinfo(CODESET); return !cs;],
+      [am_cv_langinfo_codeset=yes],
+      [am_cv_langinfo_codeset=no])
+    ])
+  if test $am_cv_langinfo_codeset = yes; then
+    AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
+      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+  fi
+])
+
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
 #
 #   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,

+ 12 - 1
bin/clish.cpp

@@ -1,7 +1,7 @@
 //-------------------------------------
 // clish.cpp
 //
-// A simple client for libclish
+// A console client for libclish
 //-------------------------------------
 
 #ifdef HAVE_CONFIG_H
@@ -16,8 +16,12 @@
 #include <getopt.h>
 #endif
 #include <signal.h>
+#if HAVE_LOCALE_H
 #include <locale.h>
+#endif
+#if HAVE_LANGINFO_CODESET
 #include <langinfo.h>
+#endif
 
 #include "clish/shell.h"
 #include "clish/internal.h"
@@ -94,8 +98,10 @@ int main(int argc, char **argv)
 	sigpipe_act.sa_handler = SIG_IGN;
 	sigaction(SIGPIPE, &sigpipe_act, NULL);
 
+#if HAVE_LOCALE_H
 	/* Set current locale */
 	setlocale(LC_ALL, "");
+#endif
 
 	/* Parse command line options */
 	optind = 0;
@@ -191,9 +197,14 @@ int main(int argc, char **argv)
 	if (utf8 || bit8)
 		clish_shell__set_utf8(shell, utf8);
 	else {
+#if HAVE_LANGINFO_CODESET
 		/* Autodetect encoding */
 		if (!strcmp(nl_langinfo(CODESET), "UTF-8"))
 			clish_shell__set_utf8(shell, BOOL_TRUE);
+#else
+		/* The default is 8-bit if locale is not supported */
+		clish_shell__set_utf8(shell, BOOL_FALSE);
+#endif
 	}
 	/* Execute startup */
 	running = clish_shell_startup(shell);

+ 6 - 0
config.h.in

@@ -12,6 +12,9 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
+/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+#undef HAVE_LANGINFO_CODESET
+
 /* Have Binary File Decription library */
 #undef HAVE_LIBBFD
 
@@ -27,6 +30,9 @@
 /* Have TCL library */
 #undef HAVE_LIBTCL
 
+/* Define to 1 if you have the <locale.h> header file. */
+#undef HAVE_LOCALE_H
+
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 

+ 67 - 10
configure

@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for klish 1.3.1.
+# Generated by GNU Autoconf 2.68 for klish 1.4.0.
 #
 # Report bugs to <serj.kalichev at gmail dot com>.
 #
@@ -570,8 +570,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='klish'
 PACKAGE_TARNAME='klish'
-PACKAGE_VERSION='1.3.1'
-PACKAGE_STRING='klish 1.3.1'
+PACKAGE_VERSION='1.4.0'
+PACKAGE_STRING='klish 1.4.0'
 PACKAGE_BUGREPORT='serj.kalichev at gmail dot com'
 PACKAGE_URL=''
 
@@ -1327,7 +1327,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures klish 1.3.1 to adapt to many kinds of systems.
+\`configure' configures klish 1.4.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1397,7 +1397,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of klish 1.3.1:";;
+     short | recursive ) echo "Configuration of klish 1.4.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1509,7 +1509,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-klish configure 1.3.1
+klish configure 1.4.0
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2177,7 +2177,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by klish $as_me 1.3.1, which was
+It was created by klish $as_me 1.4.0, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -15127,7 +15127,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='klish'
- VERSION='1.3.1'
+ VERSION='1.4.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -16139,6 +16139,63 @@ fi
 done
 
 
+################################
+# Check for locale.h
+################################
+for ac_header in locale.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default"
+if test "x$ac_cv_header_locale_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LOCALE_H 1
+_ACEOF
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: locale.h not found: the locales is not supported" >&5
+$as_echo "$as_me: WARNING: locale.h not found: the locales is not supported" >&2;}
+fi
+
+done
+
+
+################################
+# Check for CODESET within nl_langinfo
+################################
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5
+$as_echo_n "checking for nl_langinfo and CODESET... " >&6; }
+if ${am_cv_langinfo_codeset+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <langinfo.h>
+int
+main ()
+{
+char* cs = nl_langinfo(CODESET); return !cs;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  am_cv_langinfo_codeset=yes
+else
+  am_cv_langinfo_codeset=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_langinfo_codeset" >&5
+$as_echo "$am_cv_langinfo_codeset" >&6; }
+  if test $am_cv_langinfo_codeset = yes; then
+
+$as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h
+
+  fi
+
+
 ac_config_files="$ac_config_files Makefile"
 
 cat >confcache <<\_ACEOF
@@ -16691,7 +16748,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by klish $as_me 1.3.1, which was
+This file was extended by klish $as_me 1.4.0, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -16757,7 +16814,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-klish config.status 1.3.1
+klish config.status 1.4.0
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 

+ 13 - 2
configure.ac

@@ -1,8 +1,8 @@
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 m4_define([MAJOR_VERSION], 1)
-m4_define([MINOR_VERSION], 3)
-m4_define([MICRO_VERSION], 1)
+m4_define([MINOR_VERSION], 4)
+m4_define([MICRO_VERSION], 0)
 
 AC_PREREQ(2.59)
 AC_INIT([klish],
@@ -241,5 +241,16 @@ fi
 AC_CHECK_HEADERS(getopt.h, [],
     AC_MSG_WARN([getopt.h not found: only short parameters can be used on command line]))
 
+################################
+# Check for locale.h
+################################
+AC_CHECK_HEADERS(locale.h, [],
+    AC_MSG_WARN([locale.h not found: the locales is not supported]))
+
+################################
+# Check for CODESET within nl_langinfo
+################################
+AM_LANGINFO_CODESET
+
 AC_CONFIG_FILES(Makefile)
 AC_OUTPUT

+ 1 - 1
contrib/buildroot/package/klish/klish.mk

@@ -9,7 +9,7 @@ KLISH_VERSION:=HEAD
 KLISH_SITE:=http://klish.googlecode.com/svn/trunk
 KLISH_SITE_METHOD:=svn
 else
-KLISH_VERSION = 1.3.1
+KLISH_VERSION = 1.4.0
 KLISH_SOURCE = klish-$(KLISH_VERSION).tar.bz2
 KLISH_SITE = http://klish.googlecode.com/files
 endif