[Pkg-zsh-commits] [zsh] 05/11: 32056: Handle completion for different versions of iconv
Axel Beckert
abe at deuxchevaux.org
Sun Dec 15 00:38:27 UTC 2013
This is an automated email from the git hooks/post-receive script.
abe pushed a commit to branch upstream
in repository zsh.
commit 82cf0f59409fe07a5b23157e23dc778e755bad40
Author: Jun T <takimoto-j at kba.biglobe.ne.jp>
Date: Tue Nov 26 12:52:26 2013 +0900
32056: Handle completion for different versions of iconv
---
ChangeLog | 5 ++++
Completion/Unix/Command/_iconv | 67 +++++++++++++++++++++++++++---------------
2 files changed, 49 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6f030d9..61f242b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-12-09 Peter Stephenson <p.stephenson at samsung.com>
+
+ * Jun T.: 32056: Completion/Unix/Command/_iconv: Handle
+ different versions of iconv.
+
2013-12-06 Peter Stephenson <p.stephenson at samsung.com>
* Daniel Shahaf: 32091: Src/exec.c, Test/E01options.ztst:
diff --git a/Completion/Unix/Command/_iconv b/Completion/Unix/Command/_iconv
index 190ed5f..82c2d32 100644
--- a/Completion/Unix/Command/_iconv
+++ b/Completion/Unix/Command/_iconv
@@ -1,37 +1,58 @@
#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|EGLIBC)' 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 -l --list)'{-l,--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
+if _pick_variant libiconv='GNU*libiconv' glibc='(GNU*libc|EGLIBC)' unix --version; then
+ local -a args
+ local exargs="-l --list -? --help --usage --version -V"
+
+ args=(
+ "(-f --from-code $exargs)"{-f+,--from-code=}'[specify code set of input file]:code set:->from_codeset'
+ "(-t --to-code $exargs)"{-t+,--to-code=}'[specify code set for output]:code set:->to_codeset'
+ '(- 1 -l --list)'{-l,--list}'[list all character code sets]'
+ "($exargs)-c[omit invalid characters from output]"
+ "(-s --silent --verbose $exargs)"{-s,--silent}'[suppress warnings]'
+ '(-)'{-\?,--help}'[display help information]'
+ '(-)--usage[display a short usage message]'
+ '(-)'{-V,--version}'[print program version]'
+ '1:input file:_files'
+ )
+
+ case $_cmd_variant[$service] in
+ (libiconv)
+ args=( ${(R)args:#(|\*)(|\(*\))-[V\?]*} ) # remove -V and -?
+ args+=(
+ '--byte-subst=[format for unconvertible bytes]:format string:'
+ '--widechar-subst=[format for unconvertible wide chars]:format string:'
+ '--unicode-subst=[format for unconvertible Unicode chars]:format string:'
+ )
+ ;;
+ (glibc)
+ args+=(
+ "(-o --output $exargs)"{-o+,--output=}'[specify output file]:output file:_files'
+ "(-s --silent $exargs)--verbose[print progress information]"
+ )
+ ;;
+ esac
+
+ _arguments -C -S -s : $args && return 0
+
+ if [[ $state = *_codeset ]]; then
+ # suffix is meaningfull only for output encoding
+ if [[ $state = to_codeset ]] && compset -P '*[^/]/'; then
+ _wanted suffix expl suffix compadd "$@" /TRANSLIT /IGNORE && 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)"}## #}%//} && ret=0
+ -M 'm:{a-zA-Z}={A-Za-z} r:|-=* r:|=*' \
+ ${$(_call_program codesets iconv --list)%//} && ret=0
fi
fi
return ret
+
else
+ local LOCPATH="${LOCPATH:-/usr/lib/nls/loc}"
+ local -U codeset
_arguments -C \
'-f[specify code set of input file]:code set:->codeset' \
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/zsh.git
More information about the Pkg-zsh-commits
mailing list