zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: multibyte configuration
@ 2006-01-06 11:33 Peter Stephenson
  2006-01-07  2:45 ` Danek Duvall
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Stephenson @ 2006-01-06 11:33 UTC (permalink / raw)
  To: Zsh hackers list

This probes for wcswidth() and assumes the value 1 if the function isn't
available, which at least means the code compiles on OpenBSD with
--enable-multibyte, though it still didn't seem to work.

Danek Duvall tried out a simplified test for multibyte handling on
Solaris which wasn't working for me, but it was for him, so I still have
no clue what's happening there.  Any reports of working zsh with
--enable-multibyte (and real multibyte characters, I know that at least
it compiles and runs) on Solaris 8+ would be useful.

Index: configure.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.ac,v
retrieving revision 1.46
diff -u -r1.46 configure.ac
--- configure.ac	9 Dec 2005 19:20:02 -0000	1.46
+++ configure.ac	6 Jan 2006 11:28:36 -0000
@@ -1121,7 +1121,7 @@
 	       pcre_compile pcre_study pcre_exec \
 	       nl_langinfo \
 	       erand48 open_memstream \
-	       wctomb mbrtowc wcrtomb iconv \
+	       wctomb mbrtowc wcrtomb wcswidth iconv \
 	       grantpt unlockpt ptsname \
 	       htons ntohs)
 AC_FUNC_STRCOLL
Index: Src/system.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/system.h,v
retrieving revision 1.36
diff -u -r1.36 system.h
--- Src/system.h	15 Dec 2005 14:51:41 -0000	1.36
+++ Src/system.h	6 Jan 2006 11:28:39 -0000
@@ -703,6 +703,10 @@
  */
 # include <wchar.h>
 # include <wctype.h>
+#ifndef HAVE_WCSWIDTH
+/* wcswidth is missing on OpenBSD: assume single-width characters */
+#define wcswidth(x, y)	(1)
+#endif
 #endif
 #ifdef HAVE_LANGINFO_H
 #  include <langinfo.h>


Your mail client is unable to display the latest news from CSR. To access our news copy this link into a web browser:  http://www.csr.com/email_sig.html


^ permalink raw reply	[flat|nested] 9+ messages in thread
* PATCH: _hosts
@ 2006-02-03 15:46 Peter Stephenson
  2006-02-03 19:45 ` Danek Duvall
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Stephenson @ 2006-02-03 15:46 UTC (permalink / raw)
  To: Zsh hackers list

I've just run (for the second time) across
  zstyle -e '*' hosts 'reply=($hosts)'
not working because the variable hosts is used locally in the _hosts
function.  This converts it to _hosts.  We need to watch out for more
like this.

Even more, we need namespaces:  I run across problems like this again
and again when writing functions for TCP handling, which I use
frequently.  It's compounded by the inability to pass back values from
shell functions in postional parameters.  Hmm, we could think of a
syntax for the latter...  Hmmhmm, being able to insert a parameter into
the enclosing scope regardless of values in the current scope would fix
it, but it's just the sort of feature that makes the already horrific
parameter code even worse.  We've been talking about proper namespaces
for ages.

I've also made the function search ~/.ssh/known_hosts for host names
(and strip out IPv4 dot addresses).

I've also converted a conditional array assignment into an unconditional
one since I didn't see why the former was necessary, but maybe someone
can explain.

Index: Completion/Unix/Type/_hosts
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_hosts,v
retrieving revision 1.5
diff -u -r1.5 _hosts
--- Completion/Unix/Type/_hosts	24 Oct 2005 17:09:11 -0000	1.5
+++ Completion/Unix/Type/_hosts	3 Feb 2006 15:36:42 -0000
@@ -1,21 +1,34 @@
 #compdef ftp rwho rup xping traceroute host aaaa zone mx ns soa txt
 
-local expl hosts tmp
+# avoid calling variable "hosts", it's an obvious candidate for use in
+#  zstyle -e '*' hosts 'reply=($hosts)'
+local expl _hosts tmp
 
-if ! zstyle -a ":completion:${curcontext}:hosts" hosts hosts; then
-  (( $+_cache_hosts )) ||
-      if (( ${+commands[getent]} )); then
-	: ${(A)_cache_hosts:=${(s: :)${(ps:\t:)${(f)~~"$(_call_program hosts getent hosts 2>/dev/null)"}##[:blank:]#[^[:blank:]]#}}}
-      else
-        : ${(A)_cache_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
-	if (( ${+commands[ypcat]} )) &&
-	    tmp=$(_call_program hosts ypcat hosts.byname 2>/dev/null); then
-          _cache_hosts+=( ${=${(f)tmp}##[:blank:]#[^[:blank:]]#} ) # If you use YP
-	fi
+if ! zstyle -a ":completion:${curcontext}:hosts" hosts _hosts; then
+  if (( $+_cache_hosts == 0 )); then
+    # uniquify
+    typeset -gUa _cache_hosts
+    if (( ${+commands[getent]} )); then
+      # pws: we were using the horrible ": ${(A)...:=}" syntax to assign
+      # to _cache_hosts, overriding the typeset as well as being unreadable
+      # and having obscure splitting behaviour.  Why?  We've just
+      # tested _cache_hosts doesn't exist.
+      _cache_hosts=(${(s: :)${(ps:\t:)${(f)~~"$(_call_program hosts getent hosts 2>/dev/null)"}##[:blank:]#[^[:blank:]]#}})
+    else
+      _cache_hosts=(${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}})
+      if (( ${+commands[ypcat]} )) &&
+    	tmp=$(_call_program hosts ypcat hosts.byname 2>/dev/null); then
+        _cache_hosts+=( ${=${(f)tmp}##[:blank:]#[^[:blank:]]#} ) # If you use YP
       fi
+    fi
 
-  hosts=( "$_cache_hosts[@]" )
+    if [[ -r ~/.ssh/known_hosts ]]; then
+      _cache_hosts+=( $(sed -e '/^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]/d' -e 's/[ ,].*//p' ~/.ssh/known_hosts) )
+    fi
+  fi
+
+  _hosts=( "$_cache_hosts[@]" )
 fi
 
 _wanted hosts expl host \
-    compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' -a "$@" - hosts
+    compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' -a "$@" - _hosts

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-02-03 22:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-06 11:33 PATCH: multibyte configuration Peter Stephenson
2006-01-07  2:45 ` Danek Duvall
2006-01-07  8:04   ` Danek Duvall
2006-01-07 13:22   ` Peter Stephenson
2006-01-07 16:44     ` Danek Duvall
2006-02-03 15:46 PATCH: _hosts Peter Stephenson
2006-02-03 19:45 ` Danek Duvall
2006-02-03 22:40   ` Peter Stephenson
2006-02-03 22:48     ` Danek Duvall

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).