summaryrefslogtreecommitdiff
path: root/autoopts/test/nls.test
diff options
context:
space:
mode:
Diffstat (limited to 'autoopts/test/nls.test')
-rwxr-xr-xautoopts/test/nls.test156
1 files changed, 156 insertions, 0 deletions
diff --git a/autoopts/test/nls.test b/autoopts/test/nls.test
new file mode 100755
index 0000000..1455515
--- /dev/null
+++ b/autoopts/test/nls.test
@@ -0,0 +1,156 @@
+#! /bin/sh
+# -*- Mode: Shell-script -*-
+# ----------------------------------------------------------------------
+# nls.test --- test NLS, sort-of
+#
+# Time-stamp: "2011-08-07 17:36:29 bkorb"
+# Author: Bruce Korb <bkorb@gnu.org>
+##
+## This file is part of AutoOpts, a companion to AutoGen.
+## AutoOpts is free software.
+## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
+##
+## AutoOpts is available under any one of two licenses. The license
+## in use must be one of these two and the choice is under the control
+## of the user of the license.
+##
+## The GNU Lesser General Public License, version 3 or later
+## See the files "COPYING.lgplv3" and "COPYING.gplv3"
+##
+## The Modified Berkeley Software Distribution License
+## See the file "COPYING.mbsd"
+##
+## These files have the following md5sums:
+##
+## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3
+## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3
+## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
+#
+# ----------------------------------------------------------------------
+
+. ./defs
+AUTOGEN_TEMPL_DIRS=`cd ${srcdir}/..;pwd`
+export AUTOGEN_TEMPL_DIRS
+
+# # # # # # # # # # DEFINITIONS FILE # # # # # # # # #
+
+echo "creating ${testname}.def in `pwd`"
+testname="${testname}" test_main="YES" \
+argument="${argument}" long_opts="YES" \
+${SHELLX} ${stdopts} option:'opt init' second=020 || \
+ failure "Could not run stdopts.def"
+
+echo 'export = "extern char* gettext( char const* );";' >> ${testname}.def
+CC="${CC} ${CFLAGS} -DENABLE_NLS=1 ${INC}"
+CFLAGS=''
+INC=''
+
+compile_with_nls() {
+
+ echo ${AG_L} ${testname}.def
+ ${AG_L} ${testname}.def || \
+ failure AutoGen could not process
+
+ chmod u+w ${testname}.[ch]
+ cat >> ${testname}.c <<'_EOF_'
+#include <ctype.h>
+char*
+gettext( char const* pzS )
+{
+ static char z[ 4096 ];
+ char* pzD = z + sizeof(z) - 1;
+ int ct = 0;
+ int found_nl = 0;
+ if (pzS == NULL)
+ return NULL;
+ if (strchr(pzS, '%') != NULL)
+ return (void *)pzS;
+ *--pzD = '\0';
+ while (*pzS == ' ') pzS++;
+ for (;;) {
+ char ch = *(pzS++);
+ if (ch == '\0')
+ break;
+ *(--pzD) = ch;
+ ct++;
+ if (ch != '\n')
+ continue;
+ found_nl = 1;
+ while (*pzS == ' ') pzS++;
+ }
+ if (found_nl)
+ strcpy(z + sizeof(z) - 2, "\n");
+ while (*pzD == '\n')
+ pzD++;
+ return pzD;
+}
+_EOF_
+
+ sedcmd='/ot sgub .* tropeR$/d;/ yb degakcaP/d'
+ compile "--pleh"
+ mv ${testname}.help ${testname}-${1}.help
+ cmp -s ${testname}-${1}.help ${testname}-${1}.hlp || { set +x ; \
+ failure "`diff -c ${testname}-${1}.hlp ${testname}-${1}.help`" ; }
+}
+
+# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # #
+
+echo creating ${testname}.hlp
+clean_help > ${testname}-1.hlp <<'_EOF_'
+test_nls - Test AutoOpts for nls
+USAGE: nls [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
+noitpircseD emaN-noitpO grA glF
+ -o rtS noitpo pircsed noitpo noitpo ehT
+ -s muN dnoces pircsed noitpo dnoces ehT
+ -? on pleh tixe dna noitamrofni egasu dednetxe yalpsiD
+ -! on pleh-erom regap urht dessap noitamrofni egasu dednetxE
+
+.retcarahc galf eht dna nehpyh
+elgnis a yb ro eman rieht dna snehpyh delbuod yb deificeps era snoitpO
+_EOF_
+
+compile_with_nls 1
+
+mv ${testname}.def ${testname}-1.def
+
+exec 3> ${testname}.def
+cat ${testname}-1.def >&3
+echo 'full-usage = <''<''- _EOF_' >&3
+clean_help >&3 <<'_EOF_'
+test_nls - Test AutoOpts for nls
+USAGE: nls [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
+ Flg Arg Option-Name Description
+ -o Str option The option descrip
+ -s Num second The second descrip
+ -? no help Display extended usage information and exit
+ -! no more-help Extended usage information passed thru pager
+
+Options are specified by doubled hyphens and their name or by a single
+hyphen and the flag character.
+_EOF_
+echo '_EOF_;' >&3
+exec 3>&-
+
+clean_help > ${testname}-2.hlp <<'_EOF_'
+.retcarahc galf eht dna nehpyh
+elgnis a yb ro eman rieht dna snehpyh delbuod yb deificeps era snoitpO
+
+regap urht dessap noitamrofni egasu dednetxE pleh-erom on !-
+tixe dna noitamrofni egasu dednetxe yalpsiD pleh on ?-
+pircsed dnoces ehT dnoces muN s-
+pircsed noitpo ehT noitpo rtS o-
+noitpircseD emaN-noitpO grA glF
+...] ]>lav<} |={[>eman<-- | ]>lav<[ >galf<- [ sln :EGASU
+sln rof stpOotuA tseT - sln_tset
+_EOF_
+
+compile_with_nls 2
+cleanup
+
+## Local Variables:
+## mode: shell-script
+## indent-tabs-mode: nil
+## sh-indentation: 2
+## End:
+
+# end of nls.test