From 8c095a5169d78409444388646517145c5b6b25ab Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 1 Aug 2005 09:54:55 +0000 Subject: unposted: Perforce "attribute" command 21551: FEATURES description for file<20-> 21546: oddities of subscripts when searching arrays 21544: ioctl() prototyping --- ChangeLog | 14 +++++++ Completion/Unix/Command/_perforce | 40 ++++++++++++++++++- Doc/Zsh/params.yo | 23 +++++++++++ FEATURES | 2 +- Src/system.h | 2 +- configure.ac | 84 +++++++++++++++++++++++++-------------- 6 files changed, 131 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5112c6f77..64b905f98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-08-01 Peter Stephenson + + * unposted: Completion/Unix/Command/_perforce: add the as yet + undocumented "attribute" command. + + * 21551: Matthias Kopfermann: FEATURES: file<20-> globbing + example is confusing. + + * 21546: Doc/Zsh/params.yo: document the oddities of subscripts + when searching arrays. + + * 21544: Thorsten Dahlheimer: configure.ac, Src/system.h: ioctl() + prototyping was substandard and missing on Cygwin. + 2005-07-31 Peter Stephenson * 21553: Doc/Makefile.in, Doc/.distfiles: Create zsh.pdf diff --git a/Completion/Unix/Command/_perforce b/Completion/Unix/Command/_perforce index aab8d99ed..3d7de0cb1 100644 --- a/Completion/Unix/Command/_perforce +++ b/Completion/Unix/Command/_perforce @@ -397,7 +397,7 @@ _perforce_call_p4() { (( $+functions[_perforce_gen_cmd_list] )) || _perforce_gen_cmd_list() { (( ${+_perforce_cmd_list} )) || typeset -ga _perforce_cmd_list - local hline + local hline line match mbegin mend # Output looks like command-namedescription in words... # Ignore blank lines and the heading line beginning `Perforce...' # Just gets run once, then cached, so don't bother optimising @@ -407,6 +407,18 @@ _perforce_gen_cmd_list() { [[ $hline[1] = (#i)perforce ]] && continue _perforce_cmd_list+=("${hline[1]}:${hline[2,-1]}") done + # Also cache the server version for nefarious purposes. + _perforce_call_p4 info info | while read line; do + if [[ $line = (#b)"Server version: "*/*/(<->.<->)/*" "(*) ]]; then + _perforce_server_version=$match[1] + fi + done + if [[ -n ${_perforce_server_version} && \ + ${_perforce_server_version%%.*} -ge 2004 && \ + ${_perforce_cmd_list[(r)attribute:*]} = '' ]]; then + # As yet unsupported attribute command + _perforce_cmd_list+=("attribute:Set attributes for open file (EXPERIMENTAL)") + fi } @@ -1389,6 +1401,23 @@ _perforce_cmd_annotate() { '*::file:_perforce_files -tR' } + +(( $+functions[_perforce_cmd_attribute] )) || +_perforce_cmd_attribute() { + # This is currently (2005.1) an unsupported command. + # See "p4 help undoc". + local limit + # If -f is present, search unopened files, else don't + [[ ${words[(I)-f]} -eq 0 ]] && limit=" -to" + _arguments -s : \ + '-e[Value is in hex]' \ + '-f[Set the attribute on a submitted file]' \ + '-n[Set name of attribute]:attribute: ' \ + '-v[Set value of attribute]:value: ' \ + "*::file:_perforce_files$limit" +} + + (( $+functions[_perforce_cmd_branch] )) || _perforce_cmd_branch() { _arguments -s : \ @@ -1620,6 +1649,12 @@ _perforce_cmd_flush() { (( $+functions[_perforce_cmd_fstat] )) || _perforce_cmd_fstat() { + local Oattr Aattr + if [[ ${_perforce_cmd_list[(r)attribute:*]} != '' ]]; then + # Unsupported feature, try not to show if not present + Oattr=' a\:show\ attributes d\:attributes\ digest e\:attributes\ in\ hex' + Aattr='-A[Restrict attributes by pattern]:attribute pattern: ' + fi _arguments -s : \ '-c+[affected since change]:change:_perforce_changes -ts' \ '-e+[affected by change]:change:_perforce_changes -ts' \ @@ -1627,10 +1662,11 @@ _perforce_cmd_fstat() { '-H[select synced files (-Rh)]' \ '-W[select opened files (-Ro)]' \ '-l[include fileSize, possibly slow (-Ol)]' \ - '-O-[select output type]:output type:((f\:all\ revisions l\:fileSize p\:client\ path\ format r\:pending\ integrations s\:exclude\ local\ path))' \ + "-O-[select output type]:output type:((f\:all\ revisions l\:fileSize p\:client\ path\ format r\:pending\ integrations s\:exclude\ local\ path$Oattr))" \ '-P[output clientFile in full Perforce syntax (-Op)]' \ '-R-[restrict selected files]:restriction:((c\:mapped\ in\ client h\:synced\ to\ client n\:not\ synced\ to\ head o\:opened r\:resolved u\:unresolved))' \ '-s[shorten, no client-related data (-Os)]' \ + $Aattr \ '*::file:_perforce_files' } diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index 75464dc94..d48723756 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -201,11 +201,30 @@ is the number of the matching element, so that pairs of subscripts such as possible if the parameter is not an associative array. If the parameter is an associative array, only the value part of each pair is compared to the pattern, and the result is that value. + +If a search through an ordinary array failed, the search sets the +subscript to one past the end of the array, and hence +tt(${array[(r)pattern]}) will substitute the empty string. Thus the +success of a search can be tested by using the tt((i)) flag, for +example (assuming the option tt(KSH_ARRAYS) is not in effect): + +example([[ ${array[(i)pattern]} -le ${#array} ]]) + +If tt(KSH_ARRAYS) is in effect, the tt(-le) should be replaced by tt(-lt). ) item(tt(R))( Like `tt(r)', but gives the last match. For associative arrays, gives all possible matches. May be used for assigning to ordinary array elements, but not for assigning to associative arrays. + +Note that this flag can give odd results on failure. For an ordinary array +the item substituted is that corresponding to subscript 0. If the option +tt(KSH_ARRAYS) is not in effect, this is the same as the element +corresponding to subscript 1, although the form tt(${array[(I)pattern]}) +will evaluate to 0 for a failed match. If the option tt(KSH_ARRAYS) is in +effect, the subscript is still 0 for a failed match; this cannot be +distinguished from a successful match without testing tt(${array[0]}) +against the pattern. ) item(tt(i))( Like `tt(r)', but gives the index of the match instead; this may not be @@ -213,10 +232,14 @@ combined with a second argument. On the left side of an assignment, behaves like `tt(r)'. For associative arrays, the key part of each pair is compared to the pattern, and the first matching key found is the result. + +See `tt(r)' for discussion of subscripts of failed matches. ) item(tt(I))( Like `tt(i)', but gives the index of the last match, or all possible matching keys in an associative array. + +See `tt(R)' for discussion of subscripts of failed matches. ) item(tt(k))( If used in a subscript on an associative array, this flag causes the keys diff --git a/FEATURES b/FEATURES index 95a0d617c..10ac67178 100644 --- a/FEATURES +++ b/FEATURES @@ -19,7 +19,7 @@ generalized pipes (ls foo >>(cmd1) 2>>(cmd2) pipes stdout to cmd1 arithmetic expressions advanced globbing: ls **/file searches recursively for "file" in subdirectories - ls file<20-> matches file20, file30, file100, etc. + ls file<20-> matches file20, file21, file22, etc. ls *.(c|pro) matches *.c and *.pro ls *(R) matches only world-readable files ls *.c~lex.c matches all .c files except lex.c diff --git a/Src/system.h b/Src/system.h index a57e67fb6..04a21edd8 100644 --- a/Src/system.h +++ b/Src/system.h @@ -337,7 +337,7 @@ struct timezone { # endif /* HAVE_TERMIO_H */ #endif /* HAVE_TERMIOS_H */ -#if defined(GWINSZ_IN_SYS_IOCTL) || defined(CLOBBERS_TYPEAHEAD) +#if defined(GWINSZ_IN_SYS_IOCTL) || defined(IOCTL_IN_SYS_IOCTL) # include #endif #ifdef WINSIZE_IN_PTEM diff --git a/configure.ac b/configure.ac index 32230b3c5..f66b2ddf1 100644 --- a/configure.ac +++ b/configure.ac @@ -575,18 +575,15 @@ if test $ac_cv_header_sys_time_h = yes && test $ac_cv_header_sys_select_h = yes; fi fi -AC_CACHE_CHECK(POSIX termios, zsh_cv_sys_posix_termios, -[AC_TRY_LINK([#include -#include -#include ], -[/* SunOS 4.0.3 has termios.h but not the library calls. */ -tcgetattr(0, 0);], - zsh_cv_sys_posix_termios=yes, zsh_cv_sys_posix_termios=no)]) - -if test $zsh_cv_sys_posix_termios = yes; then +AH_TEMPLATE([GWINSZ_IN_SYS_IOCTL], +[Define if TIOCGWINSZ is defined in sys/ioctl.h but not in termios.h.]) +if test $ac_cv_header_termios_h = yes; then AC_CACHE_CHECK(TIOCGWINSZ in termios.h, zsh_cv_header_termios_h_tiocgwinsz, - [AC_TRY_LINK([#include + [AC_TRY_LINK([ +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include ], [int x = TIOCGWINSZ;], zsh_cv_header_termios_h_tiocgwinsz=yes, @@ -594,13 +591,13 @@ if test $zsh_cv_sys_posix_termios = yes; then else zsh_cv_header_termios_h_tiocgwinsz=no fi - -AH_TEMPLATE([GWINSZ_IN_SYS_IOCTL], -[Define if your system defines TIOCGWINSZ in sys/ioctl.h.]) if test $zsh_cv_header_termios_h_tiocgwinsz = no; then AC_CACHE_CHECK(TIOCGWINSZ in sys/ioctl.h, zsh_cv_header_sys_ioctl_h_tiocgwinsz, - [AC_TRY_LINK([#include + [AC_TRY_LINK([ +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include ], [int x = TIOCGWINSZ;], zsh_cv_header_sys_ioctl_h_tiocgwinsz=yes, @@ -1694,24 +1691,12 @@ if test $zsh_cv_header_unistd_h_sbrk_proto = yes; then AC_DEFINE(HAVE_SBRK_PROTO) fi -dnl ---------------------------------- -dnl ioctl and mknod prototypes for OSF -dnl ---------------------------------- - -AH_TEMPLATE([HAVE_IOCTL_PROTO], -[Define to 1 if there is a prototype defined for ioctl() on your system]) +dnl ----------------------- +dnl mknod prototype for OSF +dnl ----------------------- AH_TEMPLATE([HAVE_MKNOD_PROTO], -[Define to 1 if there is a prototype defined for mknod() on your system]) +[Define to 1 if there is a prototype defined for mknod() on your system.]) if test "$ac_cv_prog_cc_stdc" != no; then - AC_CACHE_CHECK(for ioctl prototype in , - zsh_cv_header_sys_ioctl_h_ioctl_proto, - [AC_TRY_COMPILE([#include - int ioctl(double x);], [int i;], - zsh_cv_header_sys_ioctl_h_ioctl_proto=no, - zsh_cv_header_sys_ioctl_h_ioctl_proto=yes)]) - if test $zsh_cv_header_sys_ioctl_h_ioctl_proto = yes; then - AC_DEFINE(HAVE_IOCTL_PROTO) - fi AC_CACHE_CHECK(for mknod prototype in , zsh_cv_header_sys_stat_h_mknod_proto, [AC_TRY_COMPILE([#include @@ -1723,6 +1708,45 @@ if test "$ac_cv_prog_cc_stdc" != no; then fi fi +dnl ---------------------------------------- +dnl presence and location of ioctl prototype +dnl ---------------------------------------- +AC_CACHE_CHECK(for ioctl prototype in or , +zsh_cv_header_unistd_h_termios_h_ioctl_proto, +[AC_TRY_COMPILE([ +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_TERMIOS_H +# include +#endif +double ioctl();], [int i;], +zsh_cv_header_unistd_h_termios_h_ioctl_proto=no, +zsh_cv_header_unistd_h_termios_h_ioctl_proto=yes)]) + +if test $zsh_cv_header_unistd_h_termios_h_ioctl_proto = no; then + AC_CACHE_CHECK(for ioctl prototype in , + zsh_cv_header_sys_ioctl_h_ioctl_proto, + [AC_TRY_COMPILE([#include + double ioctl();], [int i;], + zsh_cv_header_sys_ioctl_h_ioctl_proto=no, + zsh_cv_header_sys_ioctl_h_ioctl_proto=yes)]) +else + zsh_cv_header_sys_ioctl_h_ioctl_proto=no +fi + +AH_TEMPLATE([HAVE_IOCTL_PROTO], +[Define to 1 if there is a prototype defined for ioctl() on your system.]) +if test $zsh_cv_header_unistd_h_termios_h_ioctl_proto = yes || \ + test $zsh_cv_header_sys_ioctl_h_ioctl_proto = yes; then + AC_DEFINE(HAVE_IOCTL_PROTO) +fi +AH_TEMPLATE([IOCTL_IN_SYS_IOCTL], +[Define to 1 if we must include to get a prototype for ioctl().]) +if test $zsh_cv_header_sys_ioctl_h_ioctl_proto = yes; then + AC_DEFINE(IOCTL_IN_SYS_IOCTL) +fi + dnl ------------------- dnl select() defined in , ie BeOS R4.51 dnl ------------------- -- cgit 1.4.1