1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-04 22:51:42 +02:00

merge changes from 4.3 branch

This commit is contained in:
Oliver Kiddle 2005-03-21 16:50:17 +00:00
parent 9e942b364a
commit e222689ea1
9 changed files with 609 additions and 15 deletions

View file

@ -8,6 +8,16 @@
* 20959 (variant of 20958): Src/params.c, Src/Module/parameter.c,
Test/V01zmodload.ztst: fix crash unloading zsh/parameter and test.
2005-03-03 Oliver Kiddle <opk@zsh.org>
* 20921, 20924: Src/utils.c, Completion/Unix/Command/_iconv:
using UCS-4BE instead of ISO-10646 to identify character
encoding is more portable; make error message more specific;
find more encodings in iconv completion on Solaris
* Henryk Konsek: 20918 (modified): Completion/Unix/Command/_unace:
new completion for unace
2005-03-02 Clint Adams <clint@zsh.org>
* 20906: Completion/Unix/Command/_make: patch from
@ -20,6 +30,19 @@
a single-character Makefile variable if it is a digit. Avoids
an infinite recursion from a Makefile referencing $1.
2005-02-25 Oliver Kiddle <opk@zsh.org>
* 20867: Completion/Unix/Command/_ant: handle imported files
that are specified using a relative path
2005-02-24 Oliver Kiddle <opk@zsh.org>
* Konstantin Sobolev: 20832 (modified):
Completion/Unix/Command/_ant: gather targets from imported files
* 20862: configure.ac, Src/system.h, Src/utils.c: attempt to
fix configure scripts to detect iconv properly
2005-02-21 Peter Stephenson <pws@csr.com>
* 20837: Doc/Zsh/contrib.yo: typos.
@ -94,6 +117,17 @@
as errors, causing initialisation scripts, functions, etc., etc.
to exit.
2005-01-21 Oliver Kiddle <opk@zsh.org>
* unposted: remove Completion/Unix/Command/_larch: larch has
been superceded by tla and is no longer available
* 20734: Completion/Linux/Command/_valgrind: rewrite to handle
version 2.2.0 of valgrind
* 20730 (modified): Completion/Base/Completer/_expand: fix
suffix style to regard quoted special characters as not special
2005-01-19 Peter Stephenson <pws@csr.com>
* 20728 (with typo fixed): configure.ac, Doc/Zsh/builtins.yo,

View file

@ -0,0 +1,226 @@
#autoload
# This completer function is intended to be used as the first completer
# function and allows one to say more explicitly when and how the word
# from the line should be expanded than expand-or-complete.
# This function will allow other completer functions to be called if
# the expansions done produce no result or do not change the original
# word from the line.
setopt localoptions nonomatch
[[ _matcher_num -gt 1 ]] && return 1
local exp word sort expr expl subd suf=" " force opt asp tmp opre pre epre
local continue=0
(( $# )) &&
while getopts gsco opt; do
force="$force$opt"
done
if [[ "$funcstack[2]" = _prefix ]]; then
word="$IPREFIX$PREFIX$SUFFIX"
else
word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX"
fi
[[ "$word" = *\$(|\{[^\}]#) ||
( "$word" = *\$[a-zA-Z0-9_]## && $+parameters[${word##*\$}] -eq 0 ) ]] &&
return 1
### I'm not sure about the pattern to use in the following test.
# It once was:
# [[ "$word" = (\~*/|\$(|[=~#^+])[a-zA-Z0-9_\[\]]##[^a-zA-Z0-9_\[\]]|\$\{*\}?)[^\$\{\}\(\)\<\>?^*#~]# ]] &&
zstyle -T ":completion:${curcontext}:" suffix &&
[[ "$word" = (\~*/*|*\$(|[=~#^+])[a-zA-Z0-9_\[\]]##[^a-zA-Z0-9_\[\]]|*\$\{*\}?) &&
"${(e)word}" != (#s)(*[^\\]|)[][^*?\(\)\<\>\{\}\|]* ]] &&
return 1
zstyle -s ":completion:${curcontext}:" accept-exact tmp ||
[[ ! -o recexact ]] || tmp=1
if [[ "$tmp" != (yes|true|on|1) ]]; then
{ [[ "$word" = \~(|[-+]) ||
( "$word" = \~[-+][1-9]## && $word[3,-1] -le $#dirstack ) ]] && return 1 }
{ [[ ( "$word" = \~* && ${#userdirs[(I)${word[2,-1]}*]}+${#nameddirs[(I)${word[2,-1]}*]} -gt 1 ) ||
( "$word" = *\$[a-zA-Z0-9_]## &&
${#parameters[(I)${word##*\$}*]} -ne 1 ) ]] && continue=1 }
[[ continue -eq 1 && "$tmp" != continue ]] && return 1
fi
# In exp we will collect the expansions.
exp=("$word")
# First try substitution. That weird thing spanning multiple lines
# changes quoted spaces, tabs, and newlines into spaces and protects
# this function from aborting on parse errors in the expansion.
if [[ "$force" = *s* ]] ||
zstyle -T ":completion:${curcontext}:" substitute; then
### We once used this:
###
### [[ ! -o ignorebraces && "${#${exp}//[^\{]}" = "${#${exp}//[^\}]}" ]] &&
### eval exp\=\( ${${(q)exp}:gs/\\{/\{/:gs/\\}/\}/} \) 2>/dev/null
###
### instead of the following loop to expand braces. But that made
### parameter expressions such as ${foo} be expanded like brace
### expansions, too (and with braceccl set...).
if [[ ! -o ignorebraces && "${#${exp}//[^\{]}" = "${#${exp}//[^\}]}" ]]; then
local otmp
tmp=${(q)word}
while [[ $#tmp != $#otmp ]]; do
otmp=$tmp
tmp=${tmp//(#b)\\\$\\\{(([^\{\}]|\\\\{|\\\\})#)([^\\])\\\}/\\$\\\\{${match[1]}${match[3]}\\\\}}
done
eval exp\=\( ${tmp:gs/\\{/\{/:gs/\\}/\}/} \) 2>/dev/null
fi
### There's a bug: spaces resulting from brace expansion are quoted in
### the following expression, too. We don't want that, but I have no
### idea how to fix it.
eval 'exp=( ${${(e)exp//\\[
]/ }//(#b)([
])/\\$match[1]} )' 2>/dev/null
else
exp=( ${exp:s/\\\$/\$} )
fi
# If the array is empty, store the original string again.
[[ -z "$exp" ]] && exp=("$word")
subd=("$exp[@]")
# Now try globbing.
[[ "$force" = *g* ]] || zstyle -T ":completion:${curcontext}:" glob &&
eval 'exp=( ${~exp//(#b)\\[
]/$match[1]} ); exp=( ${(q)exp} )' 2>/dev/null
### Don't remember why we once used this instead of the (q) above.
# eval 'exp=( ${~exp} ); exp=( ${exp//(#b)([][()|*?^#~<>\\=])/\\${match[1]}} )' 2>/dev/null
# If we don't have any expansions or only one and that is the same
# as the original string, we let other completers run.
(( $#exp )) || exp=("$subd[@]")
[[ $#exp -eq 1 && "${exp[1]//\\}" = "${word//\\}"(|\(N\)) ]] && return 1
# With subst-globs-only we bail out if there were no glob expansions,
# regardless of any substitutions
{ [[ "$force" = *o* ]] ||
zstyle -t ":completion:${curcontext}:" subst-globs-only } &&
[[ "$subd" = "$exp"(|\(N\)) ]] && return 1
zstyle -s ":completion:${curcontext}:" keep-prefix tmp || tmp=changed
if [[ "$word" = (\~*/*|*\$*/*) && "$tmp" = (yes|true|on|1|changed) ]]; then
if [[ "$word" = *\$* ]]; then
opre="${(M)word##*\$[^/]##/}"
else
opre="${word%%/*}"
fi
eval 'epre=( ${(e)~opre} )' 2> /dev/null
if [[ -n "$epre" && $#epre -eq 1 ]]; then
pre="${(q)epre[1]}"
[[ ( "$tmp" != changed || $#exp -gt 1 ||
"${opre}${exp[1]#${pre}}" != "$word" ) && "${exp[1]}" = $pre* ]] &&
exp=( ${opre}${^exp#${pre}} )
fi
[[ $#exp -eq 1 && "$exp[1]" = "$word" ]] && return 1
fi
# Now add as matches whatever the user requested.
zstyle -s ":completion:${curcontext}:" sort sort
[[ "$sort" = (yes|true|1|on) ]] && exp=( "${(@o)exp}" )
if zstyle -s ":completion:${curcontext}:" add-space tmp; then
if [[ "$tmp" != *subst* || "$word" != *\$* || "$exp[1]" = *\$* ]]; then
[[ "$tmp" = *file* ]] && asp=file
[[ "$tmp" = *(yes|true|1|on|subst)* ]] && asp="yes$asp"
fi
else
asp=file
fi
# If there is only one expansion, add a suitable suffix
if (( $#exp == 1 )); then
if [[ -d ${exp[1]/${opre}/${pre}} && "$exp[1]" != */ ]]; then
suf=/
elif [[ "$asp" = yes* ||
( "$asp" = *file && -f "${exp[1]/${opre}/${pre}}" ) ]]; then
suf=' '
else
suf=
fi
fi
if [[ -z "$compstate[insert]" ]] ;then
if [[ "$sort" = menu ]]; then
_description expansions expl expansions "o:$word"
else
_description -V expansions expl expansions "o:$word"
fi
compadd "$expl[@]" -UQ -qS "$suf" -a exp
else
_tags all-expansions expansions original
if [[ $#exp -gt 1 ]] && _requested expansions; then
local i j normal space dir
if [[ "$sort" = menu ]]; then
_description expansions expl expansions "o:$word"
else
_description -V expansions expl expansions "o:$word"
fi
normal=()
space=()
dir=()
for i in "$exp[@]"; do
j="${i/${opre}/${pre}}"
if [[ -d "$j" && "$i" != */ ]]; then
dir=( "$dir[@]" "$i" )
elif [[ "$asp" = yes* || ( "$asp" = *file && -f "$j" ) ]]; then
space=( "$space[@]" "$i" )
else
normal=( "$normal[@]" "$i" )
fi
done
(( $#dir )) && compadd "$expl[@]" -UQ -qS/ -a dir
(( $#space )) && compadd "$expl[@]" -UQ -qS " " -a space
(( $#normal )) && compadd "$expl[@]" -UQ -qS "" -a normal
fi
if _requested all-expansions expl 'all expansions'; then
local disp dstr
if [[ "${#${exp}}" -ge COLUMNS ]]; then
disp=( -ld dstr )
dstr=( "${(r:COLUMNS-5:)exp} ..." )
else
disp=()
fi
[[ -o multios ]] && exp=($exp[1] $compstate[redirect]${^exp[2,-1]})
compadd "$disp[@]" "$expl[@]" -UQ -qS "$suf" - "$exp"
fi
_requested original expl original && compadd "$expl[@]" -UQ - "$word"
compstate[insert]=menu
fi
return continue

View file

@ -0,0 +1,96 @@
#compdef valgrind -value-,VALGRIND_OPTS,-default-
local curcontext="$curcontext" state line common cmd
local -a args args_{memcheck,addrcheck,cachegrind,helgrind,massif}
cmd=(
'1:command name:_command_names -e'
'*::args :_normal'
)
if [[ $service = *_OPTS* ]]; then
compset -q
words=( fake "$words[@]" )
(( CURRENT++ ))
cmd=()
fi
common=(
'--sloppy-malloc=-[round malloc sizes to multiple of 4]:enable:(yes no)'
'--alignment=-[set minimum alignment of allocations]:number'
)
args_addrcheck=(
$common
'--partial-loads-ok=-:enable:(yes no)'
'--freelist-vol=-[volume of freed blocks queue]:blocks'
'--leak-check=-[search for memory leaks at exit]:enable:(yes no)'
'--leak-resolution=-[how much bt merging in leak check]:(low med high)'
'--show-reachable=-[show reachable blocks in leak check]:enable:(yes no)'
'--workaround-gcc296-bugs=-:enable:(yes no)'
)
args_memcheck=(
$args_addrcheck
'--avoid-strlen-errors=-[suppress errs from inlined strlen]:enable:(yes no)'
)
args_cachegrind=(
'--I1=-[set I1 cache manually]:size,assoc,line_size'
'--D1=-[set D1 cache manually]:size,assoc,line_size'
'--L2=-[set L2 cache manually]:size,assoc,line_size'
)
args_helgrind=(
$common
'--private-stacks=-[assume thread stacks are used privately]:enable:(yes no)'
'--show-last-access=-[show location of last word access on error]:locations:(no some all)'
)
args_massif=(
$common
'--heap=-[profile heap blocks]:enable:(yes no)'
'--heap-admin=-[specify average admin bytes per heap block]:bytes'
'--stacks=-[enable profile stacks]:enable:(yes no)'
'--depth=-[depth of contexts]:depth'
'--alloc-fn=-[specify alloc function]:function'
'--format=-[specify format of textual output]:format:(text html)'
)
args="args_${${words[(r)--(skin|tool)=*]#*=}:-memcheck}"
_arguments -C ${(P)args} $cmd \
'(--tool --skin)'{--tool,--skin}'=-[specify valgrind tool]:valgrind tool:->tools' \
'(-h --help)'{-h,--help}'[show help information]' \
'--help-debug[show help info including debugging options]' \
'--version[show version]' \
'(-q --quiet)'{-q,--quiet}'[run silently; only print error msgs]' \
'(-v --verbose)'{-v,--verbose}'[be more verbose]' \
'--trace-children=-[valgrind-ise child processes]:enable:(yes no)' \
'--track-fds=-[track open file descriptors]:enable:(yes no)' \
'--time-stamp=-[add timestamps to log messages]:enable:(yes no)' \
'--run-libc-freeres=-[free up glibc memory at exit]:enable:(yes no)' \
'--weird-hacks=-[enable hack]:hack:(lax-ioctls)' \
'--signal-polltime=-[signal poll period (ms)]:period' \
'--lowlat-signals=-[improve thread signal wake-up latency]:enable:(yes no)' \
'--lowlat-syscalls=-[improve thread syscall wake-up latency]:enable:(yes no)' \
'--pointercheck=-[enforce client address space limits]:enable:(yes no)' \
'--log-fd=-[log messages to specified file descriptor]:file descriptor:_file_descriptors' \
'--log-file=-[log messages to specified file]:file:_files' \
'--log-socket=-[log messages to socket]:ipaddr\:port' \
'--demangle=-[automatically demangle C++ names]:enable:(yes no)' \
'--num-callers=-[specify no of callers to show in stack traces]:number' \
'--error-limit=-[stop showing new errors if too many]:enable:(yes no)' \
'--show-below-main=-[continue stack traces below main()]:enable:(yes no)' \
'--suppressions=-[suppress errors described in specified file]:file:_files' \
'--gen-suppressions=-[print suppressions for errors detected]:enable:(yes no)' \
'--db-attach=-[start debugger when errors detected]:enable:(yes no)' \
'--db-command=-[specify command to start debugger]:command:_command_names -e' \
'--input-fd=-[specify file descriptor for input]:file descriptor:_file_descriptors' && return
if [[ -n "$state" ]]; then
_wanted tools exl 'valgrind tool' compadd ${=${${(f)"$(_call_program \
tools valgrind --tool= 2>&1)"}[(r)Available*,-1]}[2,-1]} && return
fi
return 1

View file

@ -0,0 +1,31 @@
DISTFILES_SRC='
.distfiles
_a2ps _bittorrent _darcs
_dvi _gzip _man _rcs _w3m
_apachectl _enscript _iconv _mh _rlogin _webbrowser
_cdrecord _fakeroot _imagemagick _mount _sh _wget
_arp _fetchmail _init_d _mutt _slrn _whereis
_bison _find _ispell _mysql_utils _socket _whois
_bzip2 _finger _java _ncftp _ssh _xargs
_chown _flex _joe _nslookup _strip _yodl
_compress _gcc _killall _pack _stty _yp
_configure _gdb _look _patch _su _zcat
_cpio _getconf _lp _pbm _sudo _zdump
_cvs _gnu_generic _ls _perl _tar _zip
_dd _gprof _lynx _perldoc _telnet _pine
_dict _grep _lzop _prcs _tiff _elm
_diff _gs _make _psutils _tin _mail
_last _loadkeys _ruby _sysctl _links _samba
_user_admin _rsync _arping _spamassassin _mtools _ifconfig
_fsh _chkconfig _cdcd _irssi _mysqldiff _sccs
_aap _ant _antiword _apm _attr
_baz _bogofilter
_cal _chmod _du _ecasound _elinks _figlet
_getent _global _gpg _gphoto2 _less _lsof
_mencal _mt _mtr _netcat _nice _nmap
_perforce _php _postfix _printenv _python
_raggle _rar _renice
_sablotron _screen _sed _subversion
_texinfo _tla _tidy
_unace _uniq _vorbis _vux _wiggle _xmlsoft
'

View file

@ -0,0 +1,102 @@
#compdef ant -value-,ANT_ARGS,-default-
typeset -A opt_args
local buildfile tmp state line curcontext="$curcontext" ret=1
local targets importedfiles
local c target='*:target:->target'
c=( $ANT_HOME/lib/*.jar )
if [[ $service = *ANT_ARGS* ]]; then
compset -q
words=( fake "$words[@]" )
(( CURRENT++ ))
unset target
fi
_arguments -C \
'-help[display usage information]' \
'-projecthelp[print project help information]' \
'-version[display version information]' \
'-diagnostics[display info useful to problem diagnosis]' \
'(-q -quiet)'{-q,-quiet}'[be extra quiet]' \
'(-v -verbose)'{-v,-verbose}'[be more verbose]' \
'-debug[print debugging information]' \
'-emacs[produce logging information without adornments]' \
'(-l -logfile)'{-l,-logfile}'[use specified file for log]:logfile:_files' \
'-logger[the class which is to perform logging]:classname:_java_class -cp ${(j.:.)c}' \
'*-listener[add an instance of class as a project listener]:classname:_java_class -cp ${(j.:.)c}' \
'(-f -file -buildfile -find)'{-f,-file,-buildfile}'[use specified build file]:build file:_files' \
'*-D[specify property with value to use]:property:->property' \
'-propertyfile[load properties from specified file]:property file:_files' \
'-inputhandler[specify class which will handle input requests]:class:_java_class -cp ${(j.\:.)c}' \
'(-f -file -buildfile)-find[search for build file towards the root of filesystem]:build file:(build.xml)' \
$target && ret=0
case $state in
property)
if compset -P '*='; then
_default
else
_message -e properties 'property name'
fi
;;
target)
if zstyle -t ":completion:${curcontext}:targets" call-command; then
# Run ant -projecthelp also passing any of -find, -buildfile or -f options.
# Parse output into an array of the format "target:description".
# For the array to be set with correct argument boundaries, the entire
# set statement needs to be eval'd. On Cygwin, need to kill \r's output
# from Java or parsing will fail.
eval set -A tmp "${$(_call_program targets "$words[1]" $buildxml -projecthelp |
while read target desc
do
# This loop reads ant -projecthelp output from versions 1.3 to 1.5
ln="${target}${desc:+:$desc}"
[[ $target = "" ]] && continue # skip blank lines
case $ln in
(Buildfile:*)
buildfile=$desc
;;
(Default:target:*)
# with version 1.5, target is on the same line
default_target="${${desc/target:/}# }"
# versions 1.3 and 1.4 with default target on a separate line
if [[ -z $default_target ]]; then
read junk
read default_target junk
fi
# Output target again indicating its the default one.
print -n "'${default_target}:(Default target) ' "
;;
(Searching:*|Main:targets:|Subtargets:|BUILD:SUCCESSFUL|Total:time:
*)
;;
(*)
# Return target and description
print -n "'$ln' "
;;
esac
done
)//$'\015'}"
_describe 'target' tmp && ret=0
else
if [[ -n $opt_args[-find] ]]; then
buildfile=( (../)#${opt_args[-find]:-build.xml}(N[-1]) )
else
buildfile=${(v)opt_args[(I)(-f|-file|-buildfile)]:-build.xml}
fi
if [[ -f $buildfile ]]; then
importedfiles=( $(sed -n "s/ *<import[^>]* file=[\"']\([^\"']*\)[\"'].*/\1/p" < $buildfile) )
targets=( $(sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $buildfile) )
(( $#importedfiles )) && targets+=( $(cd $buildfile:h;
sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $importedfiles) )
_wanted targets expl target compadd -a targets && ret=0
else
_message -e targets target
fi
fi
;;
esac
return ret

View file

@ -0,0 +1,55 @@
#compdef iconv
local expl curcontext="$curcontext" state line ret=1
local LOCPATH="${LOCPATH:-/usr/lib/nls/loc}"
local -U codeset
if _pick_variant gnu=GNU unix --version; then
local exargs="--list -? --help --usage --version -V"
_arguments -C -S -s \
"(-f --from-code $exargs)"{-f+,--from-code=}'[specify code set of input file]:code set:->codeset' \
"(-t --to-code $exargs)"{-t+,--to-code=}'[specify code set for output]:code set:->codeset' \
'(- 1)--list[list all character code sets]' \
"($exargs)-c[omit invalid characters from output]" \
"(-o --output $exargs)"{-o+,--output=}'[specify output file]:output file:_files' \
"(-s --silent --verbose $exargs)"{-s,--silent}'[suppress warnings]' \
"(-s --silent $exargs)--verbose[print progress information]" \
'(-)'{-\?,--help}'[display help information]' \
'(-)--usage[display a short usage message]' \
'(-)'{-V,--version}'[print program version]' \
'1:input file:_files' && return 0
if [[ $state = codeset ]]; then
if compset -P '*/'; then
_wanted option expl option compadd "$@" /TRANSLIT && ret=0
else
_wanted codesets expl 'code set' compadd "$@" \
-M 'm:{a-zA-Z}={A-Za-z} r:|-=* r:|=*' \
${${${(f)"$(_call_program codesets iconv --list|sed -n '/^$/,$ p')"}## #}%//} && ret=0
fi
fi
return ret
else
_arguments -C \
'-f[specify code set of input file]:code set:->codeset' \
'-t[specify code set for output]:code set:->codeset' \
'1:file:_files' && return 0
if [[ $state = codeset ]]; then
if [[ -f /usr/lib/iconv/iconv_data ]]; then # IRIX & Solaris
codeset=( ${${(f)"$(</usr/lib/iconv/iconv_data)"}%%[[:blank:]]*} )
codeset+=( /usr/lib/iconv/*%*.so(Ne.'reply=( ${${REPLY:t}%%%*} ${${REPLY:r}#*%} )'.) )
elif [[ -d $LOCPATH/iconv ]]; then # OSF
codeset=( $LOCPATH/iconv/*(N:t) )
codeset=( ${(j:_:s:_:)codeset} )
else
return 1
fi
_wanted codesets expl 'code set' compadd "$@" -a codeset
fi
fi

View file

@ -0,0 +1,18 @@
#compdef unace
_arguments -S \
'-c[show comments]' \
'-f[full path matching]' \
'-o[overwrite files]' \
'-p+[specify password]:password' \
'-y[assume yes on all queries]' \
'-x+[specify files to exclude]:files' \
'-h[print help information]' \
'1:unace command:((
e\:extract\ files
l\:list\ archive
t\:test\ archive\ integrity
v\:list\ archive\ \(verbose\)
x\:extract\ files\ with\ full\ path
))' \
'*:files:_files -g "*.ace(-.)"'

View file

@ -3455,6 +3455,7 @@ dquotedzputs(char const *s, FILE *stream)
# if defined(HAVE_NL_LANGINFO) && defined(CODESET) && !defined(__STDC_ISO_10646__)
/* Convert a character from UCS4 encoding to UTF-8 */
/**/
size_t
ucs4toutf8(char *dest, unsigned int wval)
{
@ -3479,7 +3480,7 @@ ucs4toutf8(char *dest, unsigned int wval)
case 4: dest[3] = (wval & 0x3f) | 0x80; wval >>= 6;
case 3: dest[2] = (wval & 0x3f) | 0x80; wval >>= 6;
case 2: dest[1] = (wval & 0x3f) | 0x80; wval >>= 6;
*dest = wval | (0xfc << (6 - len)) & 0xfc;
*dest = wval | ((0xfc << (6 - len)) & 0xfc);
break;
case 1: *dest = wval;
}
@ -3521,11 +3522,10 @@ getkeystring(char *s, int *len, int fromwhere, int *misc)
size_t count;
#else
unsigned int wval;
# if defined(HAVE_NL_LANGINFO) && defined(CODESET) && (defined(HAVE_ICONV_H) || defined(HAVE_ICONV) || defined(HAVE_LIBICONV))
# if defined(HAVE_NL_LANGINFO) && defined(CODESET) && defined(HAVE_ICONV)
iconv_t cd;
char inbuf[4];
size_t inbytes, outbytes;
char *inptr;
size_t count;
# endif
#endif
@ -3642,17 +3642,17 @@ getkeystring(char *s, int *len, int fromwhere, int *misc)
t += ucs4toutf8(t, wval);
continue;
} else {
# if defined(HAVE_ICONV_H) || defined(HAVE_ICONV) || defined(HAVE_LIBICONV)
# ifdef HAVE_ICONV
ICONV_CONST char *inptr = inbuf;
inbytes = 4;
outbytes = 6;
inptr = inbuf;
/* assume big endian convention for UCS-4 */
/* store value in big endian form */
for (i=3;i>=0;i--) {
inbuf[i] = wval & 0xff;
wval >>= 8;
}
cd = iconv_open(nl_langinfo(CODESET), "ISO-10646");
cd = iconv_open(nl_langinfo(CODESET), "UCS-4BE");
if (cd == (iconv_t)-1) {
zerr("cannot do charset conversion", NULL, 0);
if (fromwhere == 4) {
@ -3663,10 +3663,10 @@ getkeystring(char *s, int *len, int fromwhere, int *misc)
*len = t - buf;
return buf;
}
count = iconv(cd, (char **)&inptr, &inbytes, &t, &outbytes);
count = iconv(cd, &inptr, &inbytes, &t, &outbytes);
iconv_close(cd);
if (count == (size_t)-1) {
zerr("cannot do charset conversion", NULL, 0);
zerr("character not in range", NULL, 0);
*t = '\0';
*len = t - buf;
return buf;

View file

@ -727,13 +727,45 @@ fi
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(iconv, iconv)
dnl ---------------
dnl CHECK FOR ICONV
dnl ---------------
case "$host_os" in
cygwin | darwin*)
dnl cygwin iconv() is really libiconv()
AC_CHECK_LIB(iconv, libiconv) ;;
esac
dnl Find iconv. It may be in libiconv and may be iconv() or libiconv()
if test "x$ac_cv_header_iconv_h" = "xyes"; then
AC_CHECK_FUNC(iconv, ac_found_iconv=yes, ac_found_iconv=no)
if test "x$ac_found_iconv" = "xno"; then
AC_CHECK_LIB(iconv, iconv, ac_found_iconv=yes)
if test "x$ac_found_iconv" = "xno"; then
AC_CHECK_LIB(iconv, libiconv, ac_found_iconv=yes)
fi
if test "x$ac_found_iconv" != "xno"; then
LIBS="-liconv $LIBS"
fi
fi
fi
if test "x$ac_found_iconv" = xyes; then
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
fi
dnl Check if iconv uses const in prototype declaration
if test "x$ac_found_iconv" = "xyes"; then
AC_CACHE_CHECK(for iconv declaration, ac_cv_iconv_const,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
#include <iconv.h>]],
[[#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif]])],
[ac_cv_iconv_const=],
[ac_cv_iconv_const=const])])
AC_DEFINE_UNQUOTED([ICONV_CONST], $ac_cv_iconv_const,
[Define as const if the declaration of iconv() needs const.])
fi
if test x$enable_pcre = xyes; then
dnl pcre-config should probably be employed here