#! /bin/sh # -*- Mode: Shell-script -*- # ---------------------------------------------------------------------- # nls.test --- test NLS, sort-of # # Time-stamp: "2007-07-15 18:06:14 bkorb" # Author: Bruce Korb ## ## This file is part of AutoOpts, a companion to AutoGen. ## AutoOpts is free software. ## AutoOpts is copyright (c) 1992-2007 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: ## ## 239588c55c22c60ffe159946a760a33e pkg/libopts/COPYING.gplv3 ## fa82ca978890795162346e661b47161a pkg/libopts/COPYING.lgplv3 ## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd # # $Id: nls.test,v 4.11 2007/07/16 01:15:00 bkorb Exp $ # ---------------------------------------------------------------------- . ./defs export AUTOGEN_TEMPL_DIRS=`cd ${srcdir}/..;pwd` # # # # # # # # # # 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 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_ 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 cat > ${testname}-1.hlp <<'_EOF_' test_nls - Test AutoOpts for nls USAGE: nls [ - [] | --[{=| }] ]... 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 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 cat >&3 <<'_EOF_' test_nls - Test AutoOpts for nls USAGE: nls [ - [] | --[{=| }] ]... Flg Arg Option-Name Description -o Str option The option descrip -s Num second The second descrip -? no help Display 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>&- cat > ${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 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