Check-in [5f3ab55c4a]
Not logged in
Overview
SHA1:5f3ab55c4ac7b9891b42f188cb0f9175f3588409
Date: 2014-02-26 00:38:52
User: quentin@minster.io
Comment:Harmonize file headers, indent and whitespace in all files
Timelines: family | ancestors | descendants | both | trunk | origin/devel
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2014-02-26
22:37
[a9511ba2db] Cleanup of compilation warnings * Add the -Wall compilation flag * Use rl_ding() instead of undeclared ding() (user: quentin@minster.io, tags: trunk, origin/devel)
00:38
[5f3ab55c4a] Harmonize file headers, indent and whitespace in all files (user: quentin@minster.io, tags: trunk, origin/devel)
2014-02-19
00:07
[f61c58e424] Apply the Gentoo patchset Gentoo ebuild: dev-tcltk/tclreadline-2.1.0-r4 Fully applied patches: * direct sed patches from the ebuild * tclreadline-2.1.0-gold.patch * tclreadline-2.1.0-rl-executing-macro.patch * tclreadline-2.1.0-rl-history-expand.patch * tclreadline-2.1.0-rl-prompt.patch Partially applied patches: * tclreadline-2.1.0-alloc-free.patch (user: quentin@minster.io, tags: trunk, origin/devel)
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified COPYING from [a7c8b5b8da] to [c1821e21e0].

     1         -   
     2         -   Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
            1  +
            2  +   Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
     3      3      All rights reserved.
     4         -   
            4  +
     5      5      Redistribution and use in source and binary forms, with or without
     6      6      modification, are permitted provided that the following conditions
     7      7      are met:
     8         -   
            8  +
     9      9        * Redistributions of source code must retain the above copyright
    10     10          notice, this list of conditions and the following disclaimer.
    11     11        * Redistributions in binary form must reproduce the above copyright
    12     12          notice, this list of conditions and the following disclaimer in the
    13     13          documentation and/or other materials provided with the distribution.
    14     14        * Neither the name of Johannes Zellner nor the names of contributors
    15     15          to this software may be used to endorse or promote products derived
    16     16          from this software without specific prior written permission.
    17         -       
           17  +
    18     18      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    19     19      ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    20     20      LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    21     21      A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
    22     22      CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    23     23      EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    24     24      PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    25     25      PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    26     26      LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    27     27      NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    28     28      SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    29     29   

Modified Makefile.am from [e10a890a98] to [45d2bf5cbc].

     1      1   ## -*- automake -*-
     2         -## FILE: "/home/joze/src/tclreadline/Makefile.am"
     3         -## LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:33 +0100 (joze)"
     4         -## (C) 2000 - 2001 by Johannes Zellner, <johannes@zellner.org>
            2  +## FILE: Makefile.am
     5      3   ## $Id$
     6      4   ## ---
     7      5   ## tclreadline -- gnu readline for tcl
     8      6   ## http://www.zellner.org/tclreadline/
     9         -## Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
            7  +## Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    10      8   ## This software is copyright under the BSD license.
    11      9   ## ---
    12     10   
    13     11   ## AUTOMAKE_OPTIONS = foreign
    14     12   
    15     13   lib_LTLIBRARIES = libtclreadline.la
    16     14   

Modified README from [58b66551a6] to [cd868e87e1].

     1         -FILE: "/home/joze/src/tclreadline/README"
     2         -LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:33 +0100 (joze)"
     3         -(C) 1998 - 2001 by Johannes Zellner, <johannes@zellner.org>
            1  +FILE: README
     4      2   $Id$
     5      3   ---
     6         -
     7      4   tclreadline -- gnu readline for tcl
     8      5   http://www.zellner.org/tclreadline/
     9         -Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
    10         -
            6  +Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    11      7   This software is copyright under the BSD license.
            8  +---
            9  +
    12     10   
    13     11   
    14     12   tclreadline
    15     13   
    16     14   
    17     15   1. Introduction
    18     16   ---------------
................................................................................
    48     46   
    49     47       (c) The usual ./configure; make; make install sequence should do the rest.
    50     48   
    51     49       (d) Optionally (or additionally) you can build the executables
    52     50           tclshrl and / or wishrl which are a readline enhanced replacement
    53     51           for tclsh and wish. To compile these executable you should type
    54     52   
    55         -	    ./configure --enable-tclshrl --enable-wishrl
           53  +        ./configure --enable-tclshrl --enable-wishrl
    56     54   
    57         -	(or one of these if you want just tclshrl or wishrl).
    58         -	NOTE that these executables need an installed version of
    59         -	tclreadline because they need some script files to run
    60         -	so you can't test tclshrl/wishrl before installing
    61         -	the tclreadline scripts.
           55  +    (or one of these if you want just tclshrl or wishrl).
           56  +    NOTE that these executables need an installed version of
           57  +    tclreadline because they need some script files to run
           58  +    so you can't test tclshrl/wishrl before installing
           59  +    the tclreadline scripts.
    62     60   
    63     61           Building statically linked executables is DISCOURAGED
    64         -	but necessary on systems which don't support shared libs.
           62  +    but necessary on systems which don't support shared libs.
    65     63   
    66     64   
    67     65   4. Using tclreadline for interactive tcl scripting.
    68     66   ---------------------------------------------------
    69     67   
    70     68   copy the sample.tclshrc to $HOME/.tclshrc. If you use another interpreter
    71     69   like wish, you should copy the file sample.tclshrc to $HOME/.wishrc
................................................................................
    75     73   does the rest.
    76     74   
    77     75   
    78     76   4. History and Changes.
    79     77   -----------------------
    80     78   
    81     79   tclreadline-1.2 0: (Mar 2000)
    82         -	switched to a BSD type license, introduced a new read-only
    83         -	variable `license' in the tclreadline namespace.
           80  +    switched to a BSD type license, introduced a new read-only
           81  +    variable `license' in the tclreadline namespace.
    84     82   
    85     83   tclreadline-1.1 0: (Mar 2000)
    86         -	code cleanup and checked that it compiles with tcl8.3
           84  +    code cleanup and checked that it compiles with tcl8.3
    87     85   
    88     86   tclreadline-1.0.1: (Sep 1999)
    89     87   
    90         -	changes:
    91         -	    - tclreadline::readline bell.
           88  +    changes:
           89  +        - tclreadline::readline bell.
    92     90             Ring the terminal bell, obeying the setting
    93         -		  of bell-style -- audible or visible.
           91  +          of bell-style -- audible or visible.
    94     92   
    95     93   
    96     94   tclreadline-1.0.0: (Sep 1999)
    97     95   
    98         -	note:
    99         -	    - the script completer procs are written.
   100         -		  this is `sort of a first usable release'.
           96  +    note:
           97  +        - the script completer procs are written.
           98  +          this is `sort of a first usable release'.
   101     99   
   102    100       fixes:
   103         -	    - some minor configure.in fixes.
          101  +        - some minor configure.in fixes.
   104    102   
   105    103   
   106    104   tclreadline-0.9.3: (Sep 1999)
   107    105   
   108    106       changes:
   109         -	    - tk completion.
   110         -		- multiple fallback completion routines for unknown
   111         -		  commands.
   112         -		- readline reset-terminal sub-function.
          107  +        - tk completion.
          108  +        - multiple fallback completion routines for unknown
          109  +          commands.
          110  +        - readline reset-terminal sub-function.
   113    111   
   114    112       fixes:
   115         -	    - another revision of procession events and macros.
   116         -		  includes a hack using a readline's internal
   117         -		  variable _rl_executing_macro.
          113  +        - another revision of procession events and macros.
          114  +          includes a hack using a readline's internal
          115  +          variable _rl_executing_macro.
   118    116   
   119    117   
   120    118   tclreadline-0.9.2: (Aug 1999)
   121    119   
   122    120       changes:
   123    121           - history event `!' expansion on <Tab>
   124    122           - if tclreadline::historyLength >= 0,
................................................................................
   159    157           - tclreadline::readline customcompleter
   160    158           - tclreadline::readline builtincompleter
   161    159           - tclreadline::readline eofchar
   162    160           - variable, array and '[' command completion by the script
   163    161             tclreadline::ScriptCompleter. See the man page or try
   164    162             typing "puts $env<TAB>" ... Command completion currently only
   165    163             works, if a '[' preceeds immediately a non-white character.
   166         -        - the redefinition of the command `cd' was removed due to 
          164  +        - the redefinition of the command `cd' was removed due to
   167    165             multiple requests. This redefinition can be found in the
   168         -          file `sample.tclshrc' and can be uncommented, if desired. 
          166  +          file `sample.tclshrc' and can be uncommented, if desired.
   169    167           - the definition of the command `ls' was moved outside the
   170    168             proc tclreadline::Setup and can be used with the command
   171    169             namespace import tclreadline::ls (see sample.tclshrc).
   172    170   
   173    171       bug fixes:
   174    172           - lines added to tcl's history. (were only in readline's hist.)
   175    173           - macro mappings didn't work. (only when hitting

Modified SCENARIO from [797d1f2bf8] to [704bad2f7f].

     4      4   
     5      5   === SCENARIO 1 ===
     6      6   
     7      7   puts $<tab>                       puts $
     8      8                                         + a list of all variables ...
     9      9   puts $t<tab>                      puts $t
    10     10                                         + a list of all variables
    11         -									    beginning with t ...
           11  +                                        beginning with t ...
    12     12   puts $tcl_pl<tab>                 puts $tcl_platform(
    13         -	                                  + a list of all array names of
    14         -									    tcl_platform
           13  +                                      + a list of all array names of
           14  +                                        tcl_platform
    15     15   puts $tcl_platform(b<tab>         puts $tcl_platform(byteOrder)
    16     16   
    17     17   
    18     18   
    19     19   === SCENARIO 2 ===
    20     20   
    21     21   button .b                         button .b
    22         -.b co<tab>                        .b configure 
           22  +.b co<tab>                        .b configure
    23     23   .b co<tab><tab>                   .b configure
    24     24                                         + a list of all button options ...
    25         -.b co<tab><tab>-r<tab>            .b configure -relief 
           25  +.b co<tab><tab>-r<tab>            .b configure -relief
    26     26   .b co<tab><tab>-r<tab>g<tab>      .b configure -relief groove
    27     27   
    28     28   

Modified autogen.sh from [e610613007] to [8923c07aed].

     1      1   #!/bin/sh
     2         -# FILE: "/home/joze/src/tclreadline/autogen.sh"
     3         -# LAST MODIFICATION: "Mit, 10 Jan 2001 06:28:43 +0100 (joze)"
     4         -# (C) 2000 - 2001 by Johannes Zellner, <johannes@zellner.org>
            2  +# FILE: autogen.sh
     5      3   # $Id$
            4  +# ---
            5  +# tclreadline -- gnu readline for tcl
            6  +# http://www.zellner.org/tclreadline/
            7  +# Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
            8  +# This software is copyright under the BSD license.
            9  +# ---
     6     10   
     7     11   srcdir=`dirname $0`
     8     12   test -z "$srcdir" && srcdir=.
     9     13   
    10     14   ORIGDIR=`pwd`
    11     15   cd $srcdir
    12     16   PROJECT=tclreadline
    13     17   TEST_TYPE=-f
    14     18   FILE=tclreadline.c
    15     19   
    16     20   DIE=0
    17     21   
    18     22   (autoconf --version) < /dev/null > /dev/null 2>&1 || {
    19         -	echo
    20         -	echo "You must have autoconf installed to compile $PROJECT."
    21         -	echo "Download the appropriate package for your distribution,"
    22         -	echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
    23         -	DIE=1
           23  +    echo
           24  +    echo "You must have autoconf installed to compile $PROJECT."
           25  +    echo "Download the appropriate package for your distribution,"
           26  +    echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
           27  +    DIE=1
    24     28   }
    25     29   
    26     30   (automake --version) < /dev/null > /dev/null 2>&1 || {
    27         -	echo
    28         -	echo "You must have automake installed to compile $PROJECT."
    29         -	echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz"
    30         -	echo "(or a newer version if it is available)"
    31         -	DIE=1
           31  +    echo
           32  +    echo "You must have automake installed to compile $PROJECT."
           33  +    echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz"
           34  +    echo "(or a newer version if it is available)"
           35  +    DIE=1
    32     36   }
    33     37   
    34     38   if test "$DIE" -eq 1; then
    35         -	exit 1
           39  +    exit 1
    36     40   fi
    37     41   
    38     42   test $TEST_TYPE $FILE || {
    39         -	echo "You must run this script in the top-level $PROJECT directory"
    40         -	exit 1
           43  +    echo "You must run this script in the top-level $PROJECT directory"
           44  +    exit 1
    41     45   }
    42     46   
    43     47   if test -z "$*"; then
    44         -	echo "I am going to run ./configure with no arguments - if you wish "
    45         -        echo "to pass any to it, please specify them on the $0 command line."
           48  +    echo "I am going to run ./configure with no arguments - if you wish "
           49  +    echo "to pass any to it, please specify them on the $0 command line."
    46     50   fi
    47     51   
    48     52   case $CC in
    49         -*xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
           53  +    *xlc | *xlc\ * | *lcc | *lcc\ *)
           54  +        am_opt=--include-deps
           55  +        ;;
    50     56   esac
    51     57   
    52     58   aclocal $ACLOCAL_FLAGS
    53     59   
    54     60   # optionally feature autoheader
    55     61   (autoheader --version)  < /dev/null > /dev/null 2>&1 && autoheader
    56     62   
    57     63   automake -a $am_opt
    58     64   autoconf
    59     65   cd $ORIGDIR
    60     66   
    61     67   $srcdir/configure --enable-maintainer-mode "$@"
    62     68   

Modified aux/tcltags from [14371eb7a9] to [f7acdd7bce].

     1      1   #!/usr/local/bin/tclsh
     2         -# FILE: "/home/joze/bin/script/tcltags"
     3         -# LAST MODIFIED: "Mon Sep 28 10:09:29 1998 (joze)"
            2  +# FILE: aux/tcltags
     4      3   # $Id$
     5      4   # ---
            5  +# tclreadline -- gnu readline for tcl
            6  +# http://www.zellner.org/tclreadline/
            7  +# Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
            8  +# This software is copyright under the BSD license.
            9  +# ---
     6     10   
     7     11   set tags [open "tags" a+]
     8     12   #set tags stdout
     9         -#_BoxHandle	Z_Box.c	/^int _BoxHandle (Box *boxPtr, Tcl_Interp *interp, int argc, char **argv)$/;"	f
           13  +#_BoxHandle Z_Box.c /^int _BoxHandle (Box *boxPtr, Tcl_Interp *interp, int argc, char **argv)$/;"   f
    10     14   
    11     15   foreach file "$argv" {
    12     16   
    13     17       if {[file exists $file]} {
    14     18   
    15     19           set source [open $file r]
    16     20           if {$source == 0} {

Modified aux/vimtags from [f85b0cc88e] to [3390267426].

     1      1   #!/usr/local/bin/tclsh
     2      2   # ==================================================================
     3         -# FILE: "/home/joze/bin/script/vimtags"
     4         -# LAST MODIFIED: "Thu Oct 01 13:20:11 1998 (joze)"
     5         -# (c) 1998 by Johannes Zellner
     6         -# Johannes.Zellner@physik.uni-karlsruhe.de
            3  +# FILE: aux/vimtags
     7      4   # $Id$
     8         -# ================================================================== 
            5  +# ---
            6  +# tclreadline -- gnu readline for tcl
            7  +# http://www.zellner.org/tclreadline/
            8  +# Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
            9  +# This software is copyright under the BSD license.
           10  +# ==================================================================
     9     11   
    10     12   
    11     13   if [file readable tags] {
    12     14       set tags [open tags r]
    13     15       set vim [open tags.vim w]
    14     16       while {[gets $tags line] != -1} {
    15         -        if [regexp "^\(\[^ 	!\]*\)\[ 	\]" $line all proc] {
           17  +        if [regexp "^\(\[^  !\]*\)\[    \]" $line all proc] {
    16     18               set proc [string trim $proc]
    17     19               if {$proc != ""} {
    18     20                   puts $vim "syntax keyword Tag $proc"
    19     21               }
    20     22           }
    21     23       }
    22     24       close $tags
    23     25       close $vim
    24     26   }
    25     27   

Modified configure.ac from [84c8e6ef95] to [d1e0c2eb78].

     1      1   dnl -*- autoconf -*-
     2         -dnl FILE: "/home/joze/src/tclreadline/configure.in"
     3         -dnl LAST MODIFICATION: "Mit, 10 Jan 2001 06:26:43 +0100 (joze)"
     4         -dnl (C) 1998 - 2001 by Johannes Zellner, <johannes@zellner.org>
            2  +dnl FILE: configure.in
     5      3   dnl $Id$
     6      4   dnl ---
     7      5   dnl tclreadline -- gnu readline for tcl
     8      6   dnl http://www.zellner.org/tclreadline/
     9         -dnl Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
            7  +dnl Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    10      8   dnl This software is copyright under the BSD license.
            9  +dnl ---
    11     10   
    12     11   AC_INIT(tclreadline.c)
    13     12   AC_CONFIG_HEADERS(config.h)
    14     13   AC_PREREQ(2.13)
    15     14   AC_REVISION($Revision$)
    16     15   AC_CONFIG_AUX_DIR(./aux)
    17     16   
................................................................................
   140    139           break
   141    140       fi
   142    141   done
   143    142   
   144    143   dnl look directly in the include dirs for readline.h
   145    144   if test -z "$READLINE_INCLUDE_DIR"; then
   146    145       for dir in $rl_includes /usr/local/include /usr/include ; do
   147         -	if test -r $dir/readline.h; then
   148         -	    READLINE_INCLUDE_DIR=$dir
   149         -	    AC_DEFINE_UNQUOTED(READLINE_LIBRARY, 1, [ Define if we have libreadline. ])
   150         -	    break
   151         -	fi
          146  +    if test -r $dir/readline.h; then
          147  +        READLINE_INCLUDE_DIR=$dir
          148  +        AC_DEFINE_UNQUOTED(READLINE_LIBRARY, 1, [ Define if we have libreadline. ])
          149  +        break
          150  +    fi
   152    151       done
   153    152   fi
   154    153   
   155    154   if test -z "$READLINE_INCLUDE_DIR"; then
   156    155       AC_MSG_ERROR([
   157    156     Can't find readline.h.
   158    157     Use --with-readline-includes to specify the directory
   159    158     containing readline.h on your system.])
   160    159   fi
   161    160   
   162    161   AC_ARG_WITH(readline-library,
   163    162       [  --with-readline-library=DIR
   164         -		  lib spec to readline (e.g. '-L/usr/local/lib -lreadline')],
          163  +          lib spec to readline (e.g. '-L/usr/local/lib -lreadline')],
   165    164       LIBS="$LIBS $withval",
   166    165       AC_SEARCH_LIBS(rl_callback_read_char, readline, ,
   167         -		AC_MSG_RESULT([
   168         -			Your readline version does not support readline's alternate interface.
   169         -			Please upgrade to readline >= 2.2 and retry.
   170         -		])
   171         -		exit
          166  +        AC_MSG_RESULT([
          167  +            Your readline version does not support readline's alternate interface.
          168  +            Please upgrade to readline >= 2.2 and retry.
          169  +        ])
          170  +        exit
   172    171       )
   173    172   )
   174    173   
   175    174   
   176    175   
   177    176   # check for readline's rl_executing_macro
   178    177   # (could be macro.c's private variable _rl_executing_macro).
................................................................................
   223    222       AC_MSG_RESULT(no cross compiling)
   224    223   )
   225    224   
   226    225   
   227    226   AC_ARG_ENABLE(tclshrl,
   228    227       [  --enable-tclshrl        build statically linked tclshrl],
   229    228       [dnl action if given
   230         -	case "${enableval}" in
   231         -	    yes) enable_static=true ;;
   232         -	    no)  enable_static=false ;;
   233         -	    *)   AC_MSG_ERROR(bad value ${enableval} for --enable-static) ;;
   234         -	esac
          229  +    case "${enableval}" in
          230  +        yes) enable_static=true ;;
          231  +        no)  enable_static=false ;;
          232  +        *)   AC_MSG_ERROR(bad value ${enableval} for --enable-static) ;;
          233  +    esac
   235    234       ],
   236    235       [dnl action if not given
   237         -	enable_static=false
          236  +    enable_static=false
   238    237       ]
   239    238   )
   240    239   AM_CONDITIONAL(STATIC_TCLSHRL, test x$enable_static = xtrue)
   241    240   
   242    241   AC_ARG_ENABLE(wishrl,
   243    242       [  --enable-wishrl         build statically linked wishrl],
   244    243       [dnl action if given
   245         -	case "${enableval}" in
   246         -	    yes)
   247         -		enable_static=true
   248         -		dnl source the tkConfig.sh which defines TK_LIB_SPEC
   249         -		. $TCL_LIB_DIR/tkConfig.sh
   250         -		AC_SUBST(TK_LIB_SPEC)
   251         -	    ;;
   252         -	    no)  enable_static=false ;;
   253         -	    *)   AC_MSG_ERROR(bad value ${enableval} for --enable-static) ;;
   254         -	esac
          244  +    case "${enableval}" in
          245  +        yes)
          246  +        enable_static=true
          247  +        dnl source the tkConfig.sh which defines TK_LIB_SPEC
          248  +        . $TCL_LIB_DIR/tkConfig.sh
          249  +        AC_SUBST(TK_LIB_SPEC)
          250  +        ;;
          251  +        no)  enable_static=false ;;
          252  +        *)   AC_MSG_ERROR(bad value ${enableval} for --enable-static) ;;
          253  +    esac
   255    254       ],
   256    255       [dnl action if not given
   257         -	enable_static=false
          256  +    enable_static=false
   258    257       ]
   259    258   )
   260    259   AM_CONDITIONAL(STATIC_WISHRL, test x$enable_static = xtrue)
   261    260   
   262    261   
   263    262   AC_SUBST(TCL_INCLUDE_DIR)
   264    263   AC_SUBST(TCL_LIB_SPEC)
   265    264   AC_SUBST(READLINE_INCLUDE_DIR)
   266    265   AC_OUTPUT(Makefile tclreadline.h tclreadlineInit.tcl tclreadlineSetup.tcl tclreadline.n pkgIndex.tcl)

Modified pkgIndex.tcl.in from [e32c88be89] to [ebbb8f66db].

     1         -# FILE: "/home/joze/src/tclreadline/pkgIndex.tcl.in"
     2         -# LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:33 +0100 (joze)"
     3         -# (C) 1998 - 2001 by Johannes Zellner, <johannes@zellner.org>
            1  +# FILE: pkgIndex.tcl.in
     4      2   # $Id$
     5      3   # ---
     6      4   # tclreadline -- gnu readline for tcl
     7      5   # http://www.zellner.org/tclreadline/
     8         -# Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
            6  +# Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
     9      7   # This software is copyright under the BSD license.
            8  +# ---
    10      9   
    11     10   package ifneeded tclreadline @VERSION@ \
    12     11       [list source [file join $dir tclreadlineInit.tcl]]

Modified sample.tclshrc from [25ec261415] to [d65998f0e1].

     1      1   #!/bin/sh
     2         -# FILE: "/home/joze/src/tclreadline/sample.tclshrc"
     3         -# LAST MODIFICATION: "Thu, 23 Mar 2000 21:13:08 +0100 (joze)"
     4         -# (C) 1998 - 2000 by Johannes Zellner, <johannes@zellner.org>
            2  +# FILE: sample.tclshrc
     5      3   # $Id$
     6         -# vim:set ft=tcl: \
            4  +# ---
            5  +# tclreadline -- gnu readline for tcl
            6  +# http://www.zellner.org/tclreadline/
            7  +# Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
            8  +# This software is copyright under the BSD license.
            9  +# ---
           10  +
           11  +# exec with tclsh \
     7     12   exec tclsh "$0" "$@"
     8     13   
     9     14   
    10     15   if {$tcl_interactive} {
    11     16   
    12     17       package require tclreadline
    13     18   
................................................................................
    54     59       # ::tclreadline::readline customcompleter ""
    55     60   
    56     61       # go to tclrealdine's main loop.
    57     62       #
    58     63       tclreadline::Loop
    59     64   }
    60     65   
           66  +# vim:set ft=tcl:

Modified tclreadline.c from [fb738417f9] to [eb4c3e5998].

     1         -
     2      1    /* ==================================================================
     3         -    FILE: "/home/joze/src/tclreadline/tclreadline.c"
     4         -    LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:33 +0100 (joze)"
     5         -    (C) 1998 - 2001 by Johannes Zellner, <johannes@zellner.org>
            2  +    FILE: tclreadline.c
     6      3       $Id$
     7      4       ---
     8      5       tclreadline -- gnu readline for tcl
     9      6       http://www.zellner.org/tclreadline/
    10         -    Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
            7  +    Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    11      8       This software is copyright under the BSD license.
    12         -    ================================================================== */  
            9  +    ================================================================== */
    13     10   
    14     11   #ifdef HAVE_CONFIG_H
    15         -#   include "config.h"
           12  +#  include "config.h"
    16     13   #endif
    17     14   
    18     15   #include <tcl.h>
    19     16   #include <stdio.h>
    20     17   #include <stdlib.h>
    21     18   #include <string.h>
    22     19   
    23     20   #if defined (READLINE_LIBRARY)
    24         -#   include <readline.h>
    25         -#   include <history.h>
           21  +#  include <readline.h>
           22  +#  include <history.h>
    26     23   #else
    27         -#   include <readline/readline.h>
    28         -#   include <readline/history.h>
           24  +#  include <readline/readline.h>
           25  +#  include <readline/history.h>
    29     26   #endif
    30     27   
    31     28   
    32     29   /*
    33         - * this prototype is missing
           30  + * this prototype may be missing
    34     31    * in readline.h
    35     32    */
    36     33   void rl_extend_line_buffer(int len);
    37     34   
    38     35   #ifdef EXECUTING_MACRO_HACK
    39     36   /**
    40         - * this prototype is private in readline's file `macro.c'.
           37  + * this prototype may be private in readline's file `macro.c'.
    41     38    * We need it here to decide, if we should read more
    42     39    * characters from a macro. Dirty, but it should work.
    43     40    */
    44     41   extern char* EXECUTING_MACRO_NAME;
    45     42   #endif
    46     43   
    47     44   #include "tclreadline.h"
    48     45   static const char* tclrl_library = TCLRL_LIBRARY;
    49     46   static const char* tclrl_version_str = TCLRL_VERSION_STR;
    50     47   static const char* tclrl_patchlevel_str = TCLRL_PATCHLEVEL_STR;
    51     48   
    52         -#define MALLOC(size) malloc((int) size)
    53         -#define FREE(ptr) if (ptr) { free((char*) ptr); ptr = 0; }
           49  +#define MALLOC(size) malloc(size)
           50  +#define FREE(ptr) free(ptr); ptr = NULL
    54     51   
    55     52   enum {
    56     53       _CMD_SET     = (1 << 0),
    57     54       _CMD_GET     = (1 << 1)
    58     55   };
    59     56   
    60     57   
................................................................................
    82     79   static int blank_line(char* str);
    83     80   static char** TclReadlineCompletion(char* text, int start, int end);
    84     81   static char* TclReadline0generator(char* text, int state);
    85     82   static char* TclReadlineKnownCommands(char* text, int state, int mode);
    86     83   static int TclReadlineParse(char** args, int maxargs, char* buf);
    87     84   
    88     85   
    89         -enum { 
           86  +enum {
    90     87       LINE_PENDING = -1,
    91     88       LINE_EOF = (1 << 8),
    92     89       LINE_COMPLETE = (1 << 9)
    93     90   };
    94     91   
    95     92   /**
    96     93    * global variables
................................................................................
   135    132   
   136    133   
   137    134   static char*
   138    135   stripleft(char* in)
   139    136   {
   140    137       char* ptr = in;
   141    138       while (*ptr && *ptr <= ' ')
   142         -	ptr++;
          139  +        ptr++;
   143    140       if (in != ptr)
   144         -	memmove(in, ptr, strlen(ptr) + 1);
          141  +        memmove(in, ptr, strlen(ptr) + 1);
   145    142       return in;
   146    143   }
   147    144   
   148    145   static char*
   149    146   stripright(char* in)
   150    147   {
   151    148       char* ptr;
   152    149       for (ptr = strchr(in, '\0') - 1; ptr >= in && *ptr <= ' '; ptr--)
   153         -	*ptr = '\0';
          150  +        *ptr = '\0';
   154    151       return in;
   155    152   }
   156    153   
   157    154   static char*
   158    155   stripwhite(char* in)
   159    156   {
   160    157       stripleft(in);
................................................................................
   181    178       char* ptr;
   182    179       char* result_c;
   183    180       int i, len = strlen(quotechars);
   184    181       Tcl_DString result;
   185    182   
   186    183       Tcl_DStringInit(&result);
   187    184       for (ptr = text; ptr && *ptr; ptr++) {
   188         -	for (i = 0; i < len; i++) {
   189         -	    if (quotechars[i] == *ptr) {
   190         -		Tcl_DStringAppend(&result, "\\", 1);
   191         -		break;
   192         -	    }
   193         -	}
   194         -	Tcl_DStringAppend(&result, ptr, 1);
          185  +        for (i = 0; i < len; i++) {
          186  +            if (quotechars[i] == *ptr) {
          187  +                Tcl_DStringAppend(&result, "\\", 1);
          188  +                break;
          189  +            }
          190  +        }
          191  +        Tcl_DStringAppend(&result, ptr, 1);
   195    192       }
   196    193       result_c = strdup(Tcl_DStringValue(&result));
   197    194       return result_c;
   198    195   }
   199    196   
   200         -static int TclReadlineCmd(ClientData clientData, Tcl_Interp *interp, int objc,
   201         -			  Tcl_Obj *CONST objv[])
          197  +static int
          198  +TclReadlineCmd(ClientData clientData, Tcl_Interp *interp, int objc,
          199  +               Tcl_Obj *CONST objv[])
   202    200   {
   203    201       int obj_idx, status;
   204    202   
   205    203       static char *subCmds[] = {
   206         -	"read", "initialize", "write", "add", "complete",
   207         -	"customcompleter", "builtincompleter", "eofchar",
   208         -	"reset-terminal", "bell", "text", "update",
   209         -	(char *) NULL
          204  +        "read", "initialize", "write", "add", "complete",
          205  +        "customcompleter", "builtincompleter", "eofchar",
          206  +        "reset-terminal", "bell", "text", "update",
          207  +        (char *) NULL
   210    208       };
   211    209       enum SubCmdIdx {
   212         -	TCLRL_READ, TCLRL_INITIALIZE, TCLRL_WRITE, TCLRL_ADD, TCLRL_COMPLETE,
   213         -	TCLRL_CUSTOMCOMPLETER, TCLRL_BUILTINCOMPLETER, TCLRL_EOFCHAR,
   214         -	TCLRL_RESET_TERMINAL, TCLRL_BELL, TCLRL_TEXT, TCLRL_UPDATE
          210  +        TCLRL_READ, TCLRL_INITIALIZE, TCLRL_WRITE, TCLRL_ADD, TCLRL_COMPLETE,
          211  +        TCLRL_CUSTOMCOMPLETER, TCLRL_BUILTINCOMPLETER, TCLRL_EOFCHAR,
          212  +        TCLRL_RESET_TERMINAL, TCLRL_BELL, TCLRL_TEXT, TCLRL_UPDATE
   215    213       };
   216    214   
   217    215       Tcl_ResetResult(interp); /* clear the result space */
   218    216   
   219    217       if (objc < 2) {
   220         -	Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?");
   221         -	return TCL_ERROR;
          218  +        Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?");
          219  +        return TCL_ERROR;
   222    220       }
   223    221   
   224    222       status = Tcl_GetIndexFromObj
   225         -    (interp, objv[1], subCmds, "option", 0, (int *) &obj_idx);
          223  +        (interp, objv[1], subCmds, "option", 0, (int *) &obj_idx);
   226    224   
   227         -    if (status != TCL_OK) {
   228         -	return status;
   229         -    }
          225  +    if (status != TCL_OK)
          226  +        return status;
   230    227   
   231    228       switch (obj_idx) {
   232    229   
   233         -	case TCLRL_READ:
          230  +        case TCLRL_READ:
   234    231   
   235         -	    rl_callback_handler_install(
   236         -			       objc == 3 ? Tcl_GetStringFromObj(objv[2], 0)
   237         -			       : "% ", TclReadlineLineCompleteHandler);
          232  +            rl_callback_handler_install(
          233  +                       objc == 3 ? Tcl_GetStringFromObj(objv[2], 0)
          234  +                       : "% ", TclReadlineLineCompleteHandler);
   238    235   
   239         -	    Tcl_CreateFileHandler(0, TCL_READABLE,
   240         -		TclReadlineReadHandler, (ClientData) NULL);
          236  +            Tcl_CreateFileHandler(0, TCL_READABLE,
          237  +                TclReadlineReadHandler, (ClientData) NULL);
   241    238   
   242         -	    /**
   243         -	     * Main Loop.
   244         -	     * XXX each modification of the global variables
   245         -	     *     which terminates the main loop must call
   246         -	     *     rl_callback_handler_remove() to leave
   247         -	     *     readline in a defined state.          XXX
   248         -	     */
   249         -	    tclrl_state = LINE_PENDING;
          239  +            /**
          240  +             * Main Loop.
          241  +             * XXX each modification of the global variables
          242  +             *     which terminates the main loop must call
          243  +             *     rl_callback_handler_remove() to leave
          244  +             *     readline in a defined state.          XXX
          245  +             */
          246  +            tclrl_state = LINE_PENDING;
   250    247   
   251         -	    while (!TclReadlineLineComplete()) {
          248  +            while (!TclReadlineLineComplete()) {
   252    249   #ifdef EXECUTING_MACRO_NAME
   253         -		/**
   254         -		 * check first, if more characters are
   255         -		 * available from _rl_executing_macro,
   256         -		 * because Tcl_DoOneEvent() will (naturally)
   257         -		 * not detect this `event'.
   258         -		 */
   259         -		if (EXECUTING_MACRO_NAME)
   260         -		    TclReadlineReadHandler((ClientData) NULL, TCL_READABLE);
   261         -		else
          250  +                /**
          251  +                 * check first, if more characters are
          252  +                 * available from _rl_executing_macro,
          253  +                 * because Tcl_DoOneEvent() will (naturally)
          254  +                 * not detect this `event'.
          255  +                 */
          256  +                if (EXECUTING_MACRO_NAME)
          257  +                    TclReadlineReadHandler((ClientData) NULL, TCL_READABLE);
          258  +                else
   262    259   #endif
   263         -		    Tcl_DoOneEvent(TCL_ALL_EVENTS);
   264         -	    }
   265         -
   266         -	    Tcl_DeleteFileHandler(0);
   267         -
   268         -	    switch (tclrl_state) {
   269         -
   270         -		case LINE_COMPLETE:
   271         -
   272         -		    return TCL_OK;
   273         -		    /* NOTREACHED */
   274         -		    break;
   275         -
   276         -		case LINE_EOF:
   277         -		    if (tclrl_eof_string)
   278         -			return Tcl_Eval(interp, tclrl_eof_string);
   279         -		    else
   280         -			return TCL_OK;
   281         -		    /* NOTREACHED */
   282         -		    break;
   283         -
   284         -		default:
   285         -		    return tclrl_state;
   286         -		    /* NOTREACHED */
   287         -		    break;
   288         -	    }
   289         -	    break;
   290         -
   291         -	case TCLRL_INITIALIZE:
   292         -	    if (3 != objc) {
   293         -		Tcl_WrongNumArgs(interp, 2, objv, "historyfile");
   294         -		return TCL_ERROR;
   295         -	    } else {
   296         -		return TclReadlineInitialize(interp,
   297         -					     Tcl_GetStringFromObj(objv[2], 0));
   298         -	    }
   299         -	    break;
   300         -
   301         -	case TCLRL_WRITE:
   302         -	    if (3 != objc) {
   303         -		Tcl_WrongNumArgs(interp, 2, objv, "historyfile");
   304         -		return TCL_ERROR;
   305         -	    }  else if (write_history(Tcl_GetStringFromObj(objv[2], 0))) {
   306         -		Tcl_AppendResult(interp, "unable to write history to `",
   307         -		    Tcl_GetStringFromObj(objv[2], 0), "'\n", (char*) NULL);
   308         -		return TCL_ERROR;
   309         -	    }
   310         -	    if (tclrl_history_length >= 0) {
   311         -		history_truncate_file(Tcl_GetStringFromObj(objv[2], 0),
   312         -				      tclrl_history_length);
   313         -	    }
   314         -	    return TCL_OK;
   315         -	    break;
   316         -
   317         -	case TCLRL_ADD:
   318         -	    if (3 != objc) {
   319         -		Tcl_WrongNumArgs(interp, 2, objv, "completerLine");
   320         -		return TCL_ERROR;
   321         -	    } else if (TclReadlineKnownCommands(
   322         -				     Tcl_GetStringFromObj(objv[2], 0),
   323         -				     (int) 0, _CMD_SET)) {
   324         -		Tcl_AppendResult(interp, "unable to add command \"",
   325         -		    Tcl_GetStringFromObj(objv[2], 0), "\"\n", (char*) NULL);
   326         -	    }
   327         -	    break;
   328         -
   329         -	case TCLRL_COMPLETE:
   330         -	    if (3 != objc) {
   331         -		Tcl_WrongNumArgs(interp, 2, objv, "line");
   332         -		return TCL_ERROR;
   333         -	    } else if (Tcl_CommandComplete(Tcl_GetStringFromObj(objv[2], 0))) {
   334         -		Tcl_AppendResult(interp, "1", (char*) NULL);
   335         -	    } else {
   336         -		Tcl_AppendResult(interp, "0", (char*) NULL);
   337         -	    }
   338         -	    break;
   339         -
   340         -	case TCLRL_CUSTOMCOMPLETER:
   341         -	    if (objc > 3) {
   342         -		Tcl_WrongNumArgs(interp, 2, objv, "?scriptCompleter?");
   343         -		return TCL_ERROR;
   344         -	    } else if (3 == objc) {
   345         -		if (tclrl_custom_completer)
   346         -		    FREE(tclrl_custom_completer);
   347         -		if (!blank_line(Tcl_GetStringFromObj(objv[2], 0)))
   348         -		    tclrl_custom_completer =
   349         -		         stripwhite(strdup(Tcl_GetStringFromObj(objv[2], 0)));
   350         -	    }
   351         -	    Tcl_AppendResult(interp, tclrl_custom_completer, (char*) NULL);
   352         -	    break;
   353         -
   354         -	case TCLRL_BUILTINCOMPLETER:
   355         -	    if (objc > 3) {
   356         -		Tcl_WrongNumArgs(interp, 2, objv, "?boolean?");
   357         -		return TCL_ERROR;
   358         -	    } else if (3 == objc) {
   359         -		int bool = tclrl_use_builtin_completer;
   360         -		if (TCL_OK != Tcl_GetBoolean(interp,
   361         -					     Tcl_GetStringFromObj(objv[2], 0),
   362         -					     &bool)) {
   363         -		    Tcl_AppendResult(interp,
   364         -			"wrong # args: should be a boolean value.",
   365         -			(char*) NULL);
   366         -		    return TCL_ERROR;
   367         -		} else {
   368         -		    tclrl_use_builtin_completer = bool;
   369         -		}
   370         -	    }
   371         -	    Tcl_AppendResult(interp, tclrl_use_builtin_completer ? "1" : "0",
   372         -		(char*) NULL);
   373         -	    break;
   374         -
   375         -	case TCLRL_EOFCHAR:
   376         -	    if (objc > 3) {
   377         -		Tcl_WrongNumArgs(interp, 2, objv, "?script?");
   378         -		return TCL_ERROR;
   379         -	    } else if (3 == objc) {
   380         -		if (tclrl_eof_string)
   381         -		    FREE(tclrl_eof_string);
   382         -		if (!blank_line(Tcl_GetStringFromObj(objv[2], 0)))
   383         -		    tclrl_eof_string = 
   384         -		        stripwhite(strdup(Tcl_GetStringFromObj(objv[2], 0)));
   385         -	    }
   386         -	    Tcl_AppendResult(interp, tclrl_eof_string, (char*) NULL);
   387         -	    break;
   388         -
   389         -	case TCLRL_RESET_TERMINAL:
   390         -	    /* TODO: add this to the completer */
   391         -	    if (objc > 3) {
   392         -		Tcl_WrongNumArgs(interp, 2, objv, "?terminal-name?");
   393         -		return TCL_ERROR;
   394         -	    }
   395         -	    if (3 == objc) {
   396         -		/*
   397         -		 * - tcl8.0 doesn't have Tcl_GetStringFromObj()
   398         -		 * - rl_reset_terminal() might be defined
   399         -		 *   to take no arguments. This might produce
   400         -		 *   a compiler warning.
   401         -		 */
   402         -		rl_reset_terminal(Tcl_GetStringFromObj(objv[2], 0));
          260  +                    Tcl_DoOneEvent(TCL_ALL_EVENTS);
          261  +            }
          262  +
          263  +            Tcl_DeleteFileHandler(0);
          264  +
          265  +            switch (tclrl_state) {
          266  +
          267  +                case LINE_COMPLETE:
          268  +                    return TCL_OK;
          269  +                    /* NOTREACHED */
          270  +                    break;
          271  +
          272  +                case LINE_EOF:
          273  +                    if (tclrl_eof_string)
          274  +                    return Tcl_Eval(interp, tclrl_eof_string);
          275  +                    else
          276  +                    return TCL_OK;
          277  +                    /* NOTREACHED */
          278  +                    break;
          279  +
          280  +                default:
          281  +                    return tclrl_state;
          282  +                    /* NOTREACHED */
          283  +                    break;
          284  +            }
          285  +            break;
          286  +
          287  +        case TCLRL_INITIALIZE:
          288  +            if (3 != objc) {
          289  +                Tcl_WrongNumArgs(interp, 2, objv, "historyfile");
          290  +                return TCL_ERROR;
          291  +            } else {
          292  +                return TclReadlineInitialize(interp,
          293  +                                 Tcl_GetStringFromObj(objv[2], 0));
          294  +            }
          295  +            break;
          296  +
          297  +        case TCLRL_WRITE:
          298  +            if (3 != objc) {
          299  +                Tcl_WrongNumArgs(interp, 2, objv, "historyfile");
          300  +                return TCL_ERROR;
          301  +            }  else if (write_history(Tcl_GetStringFromObj(objv[2], 0))) {
          302  +                Tcl_AppendResult(interp, "unable to write history to `",
          303  +                    Tcl_GetStringFromObj(objv[2], 0), "'\n", (char*) NULL);
          304  +                return TCL_ERROR;
          305  +            }
          306  +            if (tclrl_history_length >= 0) {
          307  +                history_truncate_file(Tcl_GetStringFromObj(objv[2], 0),
          308  +                              tclrl_history_length);
          309  +            }
          310  +            return TCL_OK;
          311  +            break;
          312  +
          313  +        case TCLRL_ADD:
          314  +            if (3 != objc) {
          315  +                Tcl_WrongNumArgs(interp, 2, objv, "completerLine");
          316  +                return TCL_ERROR;
          317  +            } else if (TclReadlineKnownCommands(
          318  +                         Tcl_GetStringFromObj(objv[2], 0),
          319  +                         (int) 0, _CMD_SET)) {
          320  +                Tcl_AppendResult(interp, "unable to add command \"",
          321  +                    Tcl_GetStringFromObj(objv[2], 0), "\"\n", (char*) NULL);
          322  +            }
          323  +            break;
          324  +
          325  +        case TCLRL_COMPLETE:
          326  +            if (3 != objc) {
          327  +                Tcl_WrongNumArgs(interp, 2, objv, "line");
          328  +                return TCL_ERROR;
          329  +            } else if (Tcl_CommandComplete(Tcl_GetStringFromObj(objv[2], 0))) {
          330  +                Tcl_AppendResult(interp, "1", (char*) NULL);
          331  +            } else {
          332  +                Tcl_AppendResult(interp, "0", (char*) NULL);
          333  +            }
          334  +            break;
          335  +
          336  +        case TCLRL_CUSTOMCOMPLETER:
          337  +            if (objc > 3) {
          338  +                Tcl_WrongNumArgs(interp, 2, objv, "?scriptCompleter?");
          339  +                return TCL_ERROR;
          340  +            } else if (3 == objc) {
          341  +                if (tclrl_custom_completer)
          342  +                    FREE(tclrl_custom_completer);
          343  +                if (!blank_line(Tcl_GetStringFromObj(objv[2], 0)))
          344  +                    tclrl_custom_completer =
          345  +                         stripwhite(strdup(Tcl_GetStringFromObj(objv[2], 0)));
          346  +            }
          347  +            Tcl_AppendResult(interp, tclrl_custom_completer, (char*) NULL);
          348  +            break;
          349  +
          350  +        case TCLRL_BUILTINCOMPLETER:
          351  +            if (objc > 3) {
          352  +                Tcl_WrongNumArgs(interp, 2, objv, "?boolean?");
          353  +                return TCL_ERROR;
          354  +            } else if (3 == objc) {
          355  +                int bool = tclrl_use_builtin_completer;
          356  +                if (TCL_OK != Tcl_GetBoolean(interp,
          357  +                                 Tcl_GetStringFromObj(objv[2], 0),
          358  +                                 &bool)) {
          359  +                    Tcl_AppendResult(interp,
          360  +                        "wrong # args: should be a boolean value.",
          361  +                        (char*) NULL);
          362  +                    return TCL_ERROR;
          363  +                } else {
          364  +                    tclrl_use_builtin_completer = bool;
          365  +                }
          366  +            }
          367  +            Tcl_AppendResult(interp, tclrl_use_builtin_completer ? "1" : "0",
          368  +                (char*) NULL);
          369  +            break;
          370  +
          371  +        case TCLRL_EOFCHAR:
          372  +            if (objc > 3) {
          373  +                Tcl_WrongNumArgs(interp, 2, objv, "?script?");
          374  +                return TCL_ERROR;
          375  +            } else if (3 == objc) {
          376  +                if (tclrl_eof_string)
          377  +                    FREE(tclrl_eof_string);
          378  +                if (!blank_line(Tcl_GetStringFromObj(objv[2], 0)))
          379  +                    tclrl_eof_string =
          380  +                        stripwhite(strdup(Tcl_GetStringFromObj(objv[2], 0)));
          381  +            }
          382  +            Tcl_AppendResult(interp, tclrl_eof_string, (char*) NULL);
          383  +            break;
          384  +
          385  +        case TCLRL_RESET_TERMINAL:
          386  +            /* TODO: add this to the completer */
          387  +            if (objc > 3) {
          388  +                Tcl_WrongNumArgs(interp, 2, objv, "?terminal-name?");
          389  +                return TCL_ERROR;
          390  +            }
          391  +            if (3 == objc) {
          392  +                /*
          393  +                 * - tcl8.0 doesn't have Tcl_GetStringFromObj()
          394  +                 * - rl_reset_terminal() might be defined
          395  +                 *   to take no arguments. This might produce
          396  +                 *   a compiler warning.
          397  +                 */
          398  +                rl_reset_terminal(Tcl_GetStringFromObj(objv[2], 0));
   403    399   #ifdef CLEANUP_AFER_SIGNAL
   404         -	    } else {
   405         -		rl_cleanup_after_signal();
          400  +            } else {
          401  +                rl_cleanup_after_signal();
   406    402   #endif
   407         -	    }
   408         -	    break;
          403  +            }
          404  +            break;
   409    405   
   410         -	case TCLRL_BELL:
   411         -	    if (objc != 2) {
   412         -		Tcl_WrongNumArgs(interp, 2, objv, "");
   413         -		return TCL_ERROR;
   414         -	    }
          406  +        case TCLRL_BELL:
          407  +            if (objc != 2) {
          408  +                Tcl_WrongNumArgs(interp, 2, objv, "");
          409  +                return TCL_ERROR;
          410  +            }
   415    411   
   416    412   
   417         -	    /*
   418         -	     * ring the terminal bell obeying the current
   419         -	     * settings -- audible or visible.
   420         -	     */
          413  +            /*
          414  +             * ring the terminal bell obeying the current
          415  +             * settings -- audible or visible.
          416  +             */
   421    417   
   422         -	    ding();
   423         -	    break;
          418  +            ding();
          419  +            break;
   424    420   
   425    421           case TCLRL_UPDATE:
   426         -	    if (objc != 2) {
   427         -		Tcl_WrongNumArgs(interp, 2, objv, "");
   428         -		return TCL_ERROR;
   429         -	    }
          422  +            if (objc != 2) {
          423  +                Tcl_WrongNumArgs(interp, 2, objv, "");
          424  +                return TCL_ERROR;
          425  +            }
   430    426   
   431         -	    /* Update the input line */
          427  +            /* Update the input line */
   432    428   
   433         -	    if (rl_line_buffer) {
   434         -	        rl_forced_update_display();
   435         -	    }
          429  +            if (rl_line_buffer) {
          430  +                rl_forced_update_display();
          431  +            }
   436    432   
   437         -	    break;
          433  +            break;
   438    434   
   439    435   
   440    436           case TCLRL_TEXT:
   441         -	    if (objc != 2) {
   442         -		Tcl_WrongNumArgs(interp, 2, objv, "");
   443         -		return TCL_ERROR;
   444         -	    }
          437  +            if (objc != 2) {
          438  +                Tcl_WrongNumArgs(interp, 2, objv, "");
          439  +                return TCL_ERROR;
          440  +            }
   445    441   
   446         -	    /* Return the current input line */
   447         -	    Tcl_SetObjResult(interp,
   448         -		   Tcl_NewStringObj(rl_line_buffer ? rl_line_buffer : "", -1));
   449         -	    break;
          442  +            /* Return the current input line */
          443  +            Tcl_SetObjResult(interp,
          444  +               Tcl_NewStringObj(rl_line_buffer ? rl_line_buffer : "", -1));
          445  +            break;
   450    446   
   451         -	default:
   452         -	    goto BAD_COMMAND;
   453         -	    /* NOTREACHED */
   454         -	    break;
          447  +        default:
          448  +            goto BAD_COMMAND;
          449  +            /* NOTREACHED */
          450  +            break;
   455    451       }
   456    452   
   457    453       return TCL_OK;
   458    454   
   459    455   BAD_COMMAND:
   460    456       Tcl_AppendResult(interp,
   461         -	"wrong # args: should be \"readline option ?arg ...?\"",
   462         -	(char*) NULL);
          457  +        "wrong # args: should be \"readline option ?arg ...?\"",
          458  +        (char*) NULL);
   463    459       return TCL_ERROR;
   464    460   
   465    461   }
   466    462   
   467    463   static void
   468    464   TclReadlineReadHandler(ClientData clientData, int mask)
   469    465   {
   470    466       if (mask & TCL_READABLE) {
   471    467   #ifdef EXECUTING_MACRO_NAME
   472         -	do {
          468  +        do {
   473    469   #endif
   474         -	    rl_callback_read_char();
          470  +            rl_callback_read_char();
   475    471   #ifdef EXECUTING_MACRO_NAME
   476         -	    /**
   477         -	     * check, if we're inside a macro and
   478         -	     * if so, read all macro characters
   479         -	     * until the next eol.
   480         -	     */
   481         -	} while (EXECUTING_MACRO_NAME && !TclReadlineLineComplete());
          472  +        /**
          473  +         * check, if we're inside a macro and
          474  +         * if so, read all macro characters
          475  +         * until the next eol.
          476  +         */
          477  +        } while (EXECUTING_MACRO_NAME && !TclReadlineLineComplete());
   482    478   #endif
   483    479       }
   484    480   }
   485    481   
   486    482   static void
   487    483   TclReadlineLineCompleteHandler(char* ptr)
   488    484   {
   489    485       if (!ptr) { /* <c-d> */
   490    486   
   491         -	TclReadlineTerminate(LINE_EOF);
          487  +        TclReadlineTerminate(LINE_EOF);
   492    488   
   493    489       } else {
   494    490   
   495         -	/**
   496         -	 * From version 0.9.3 upwards, all lines are
   497         -	 * returned, even empty lines. (Only non-empty
   498         -	 * lines are stuffed in readline's history.)
   499         -	 * The calling script is responsible for handling
   500         -	 * empty strings.
   501         -	 */
   502         -
   503         -	char* expansion = (char*) NULL;
   504         -	int status = history_expand(ptr, &expansion);
   505         -
   506         -	if (status >= 2) {
   507         -	    /* TODO: make this a valid tcl output */
   508         -	    printf("%s\n", expansion);
   509         -		free(ptr);
   510         -		free(expansion);
   511         -		return;
   512         -	} else if (status <= -1) {
   513         -	    Tcl_AppendResult
   514         -	    (tclrl_interp, "error in history expansion: ", expansion, "\n", (char*) NULL);
   515         -	    TclReadlineTerminate(TCL_ERROR);
   516         -		free(ptr);
   517         -		free(expansion);
   518         -		return;
   519         -	} else {
   520         -        Tcl_AppendResult(tclrl_interp, expansion, (char*) NULL);
   521         -    }
   522         -
   523         -#ifdef EXECUTING_MACRO_NAME
   524         -	/**
   525         -	 * don't stuff macro lines
   526         -	 * into readline's history.
   527         -	 */
   528         -	if(!EXECUTING_MACRO_NAME) {
   529         -#endif
   530         -	    /**
   531         -	     * don't stuff empty lines
   532         -	     * into readline's history.
   533         -	     * don't stuff twice the same
   534         -	     * line into readline's history.
   535         -	     */
   536         -	    if (expansion && *expansion && (!tclrl_last_line ||
   537         -		    strcmp(tclrl_last_line, expansion))) {
   538         -		add_history(expansion);
   539         -	    }
   540         -	    if (tclrl_last_line)
   541         -		free(tclrl_last_line);
   542         -	    tclrl_last_line = strdup(expansion);
   543         -#ifdef EXECUTING_MACRO_NAME
   544         -	}
   545         -#endif
   546         -	/**
   547         -	 * tell the calling routines to terminate.
   548         -	 */
   549         -	TclReadlineTerminate(LINE_COMPLETE);
   550         -	FREE(ptr);
   551         -	FREE(expansion);
          491  +        /**
          492  +         * From version 0.9.3 upwards, all lines are
          493  +         * returned, even empty lines. (Only non-empty
          494  +         * lines are stuffed in readline's history.)
          495  +         * The calling script is responsible for handling
          496  +         * empty strings.
          497  +         */
          498  +
          499  +        char* expansion = (char*) NULL;
          500  +        int status = history_expand(ptr, &expansion);
          501  +
          502  +        if (status >= 2) {
          503  +            /* TODO: make this a valid tcl output */
          504  +            printf("%s\n", expansion);
          505  +            FREE(ptr);
          506  +            FREE(expansion);
          507  +            return;
          508  +        } else if (status <= -1) {
          509  +            Tcl_AppendResult
          510  +                (tclrl_interp, "error in history expansion: ", expansion, "\n", (char*) NULL);
          511  +                TclReadlineTerminate(TCL_ERROR);
          512  +            FREE(ptr);
          513  +            FREE(expansion);
          514  +            return;
          515  +        } else {
          516  +            Tcl_AppendResult(tclrl_interp, expansion, (char*) NULL);
          517  +        }
          518  +
          519  +    #ifdef EXECUTING_MACRO_NAME
          520  +        /**
          521  +         * don't stuff macro lines
          522  +         * into readline's history.
          523  +         */
          524  +        if(!EXECUTING_MACRO_NAME) {
          525  +    #endif
          526  +            /**
          527  +             * don't stuff empty lines
          528  +             * into readline's history.
          529  +             * don't stuff twice the same
          530  +             * line into readline's history.
          531  +             */
          532  +            if (expansion && *expansion && (!tclrl_last_line ||
          533  +                    strcmp(tclrl_last_line, expansion))) {
          534  +                add_history(expansion);
          535  +            }
          536  +            if (tclrl_last_line)
          537  +                FREE(tclrl_last_line);
          538  +            tclrl_last_line = strdup(expansion);
          539  +    #ifdef EXECUTING_MACRO_NAME
          540  +        }
          541  +    #endif
          542  +        /**
          543  +         * tell the calling routines to terminate.
          544  +         */
          545  +        TclReadlineTerminate(LINE_COMPLETE);
          546  +        FREE(ptr);
          547  +        FREE(expansion);
   552    548       }
   553    549   }
   554    550   
   555    551   int
   556    552   Tclreadline_SafeInit(Tcl_Interp *interp)
   557    553   {
   558    554       return Tclreadline_Init(interp);
................................................................................
   559    555   }
   560    556   
   561    557   int
   562    558   Tclreadline_Init(Tcl_Interp *interp)
   563    559   {
   564    560       int status;
   565    561       Tcl_CreateObjCommand(interp, "::tclreadline::readline", TclReadlineCmd,
   566         -	(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
          562  +        (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
   567    563       tclrl_interp = interp;
   568    564       if (TCL_OK != (status = Tcl_LinkVar(interp, "::tclreadline::historyLength",
   569         -		(char*) &tclrl_history_length, TCL_LINK_INT)))
   570         -	return status;
          565  +            (char*) &tclrl_history_length, TCL_LINK_INT)))
          566  +        return status;
   571    567   
   572    568       if (TCL_OK != (status = Tcl_LinkVar(interp, "::tclreadline::library",
   573         -		(char*) &tclrl_library, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
   574         -	return status;
          569  +            (char*) &tclrl_library, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
          570  +        return status;
   575    571       if (TCL_OK != (status = Tcl_LinkVar(interp, "::tclreadline::version",
   576         -		(char*) &tclrl_version_str, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
   577         -	return status;
          572  +            (char*) &tclrl_version_str, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
          573  +        return status;
   578    574       if (TCL_OK != (status = Tcl_LinkVar(interp, "::tclreadline::patchLevel",
   579         -		(char*) &tclrl_patchlevel_str, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
   580         -	return status;
          575  +            (char*) &tclrl_patchlevel_str, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
          576  +        return status;
   581    577       if (TCL_OK != (status = Tcl_LinkVar(interp, "::tclreadline::license",
   582         -		(char*) &tclrl_license, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
   583         -	return status;
          578  +            (char*) &tclrl_license, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
          579  +        return status;
   584    580   
   585    581       if (TCL_OK != (status = Tcl_LinkVar(interp, "tclreadline_library",
   586         -		(char*) &tclrl_library, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
   587         -	return status;
          582  +            (char*) &tclrl_library, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
          583  +        return status;
   588    584       if (TCL_OK != (status = Tcl_LinkVar(interp, "tclreadline_version",
   589         -		(char*) &tclrl_version_str, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
   590         -	return status;
          585  +            (char*) &tclrl_version_str, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
          586  +        return status;
   591    587       if (TCL_OK != (status = Tcl_LinkVar(interp, "tclreadline_patchLevel",
   592         -		(char*) &tclrl_patchlevel_str, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
   593         -	return status;
          588  +            (char*) &tclrl_patchlevel_str, TCL_LINK_STRING | TCL_LINK_READ_ONLY)))
          589  +        return status;
   594    590   
   595    591       return Tcl_PkgProvide(interp, "tclreadline", (char*)tclrl_version_str);
   596    592   }
   597    593   
   598    594   static int
   599    595   TclReadlineInitialize(Tcl_Interp* interp, char* historyfile)
   600    596   {
   601    597       rl_readline_name = "tclreadline";
   602    598       /*    rl_special_prefixes = "${\"["; */
   603    599       rl_special_prefixes = "$";
   604    600       /**
   605    601        * default is " \t\n\"\\'`@$><=;|&{("
   606    602        * removed "(" <-- arrays
   607         -     * removed "{" <-- `${' variables 
          603  +     * removed "{" <-- `${' variables
   608    604        * removed "<" <-- completion lists with < ... >
   609    605        * added "[]"
   610    606        * added "}"
   611    607        */
   612    608       /* 11.Sep rl_basic_word_break_characters = " \t\n\"\\@$}=;|&[]"; */
   613    609       /* besser (11. Sept) 2. (removed \") */
   614    610       /* rl_basic_word_break_characters = " \t\n\\@$}=;|&[]"; */
................................................................................
   627    623        */
   628    624       /*
   629    625          rl_filename_quoting_desired = 1;
   630    626        */
   631    627   
   632    628       using_history();
   633    629       if (!tclrl_eof_string)
   634         -	tclrl_eof_string = strdup("puts {}; exit");
          630  +        tclrl_eof_string = strdup("puts {}; exit");
   635    631   
   636    632       /*
   637    633        * try to read historyfile in home
   638    634        * directory. If this failes, this
   639    635        * is *not* an error.
   640    636        */
   641    637       rl_attempted_completion_function = (CPPFunction *) TclReadlineCompletion;
   642    638       if (read_history(historyfile)) {
   643         -	if (write_history(historyfile)) {
   644         -	    Tcl_AppendResult (interp, "warning: `",
   645         -		historyfile, "' is not writable.", (char*) NULL);
   646         -	}
          639  +        if (write_history(historyfile)) {
          640  +            Tcl_AppendResult (interp, "warning: `",
          641  +                historyfile, "' is not writable.", (char*) NULL);
          642  +        }
   647    643       }
   648    644       return TCL_OK;
   649    645   }
   650    646   
   651    647   static int
   652    648   blank_line(char* str)
   653    649   {
   654    650       char* ptr;
   655    651       for (ptr = str; ptr && *ptr; ptr++) {
   656         -	if (!ISWHITE(*ptr))
   657         -	    return 0;
          652  +        if (!ISWHITE(*ptr))
          653  +            return 0;
   658    654       }
   659    655       return 1;
   660    656   }
   661    657   
   662    658   static char**
   663    659   TclReadlineCompletion(char* text, int start, int end)
   664    660   {
   665    661       char** matches = (char**) NULL;
   666    662       int status;
   667    663       rl_completion_append_character = ' '; /* reset, just in case ... */
   668    664   
   669    665       if (text && ('!' == text[0]
   670         -	    || (start && rl_line_buffer[start - 1] == '!' /* for '$' */))) {
   671         -	char* expansion = (char*) NULL;
   672         -	int oldlen = strlen(rl_line_buffer);
   673         -	status = history_expand(rl_line_buffer, &expansion);
   674         -	if (status >= 1) {
   675         -	    rl_extend_line_buffer(strlen(expansion) + 1);
   676         -	    strcpy(rl_line_buffer, expansion);
   677         -	    rl_end = strlen(expansion);
   678         -	    rl_point += strlen(expansion) - oldlen;
   679         -	    FREE(expansion);
   680         -	    /*
   681         -	     * TODO:
   682         -	     * because we return 0 == matches,
   683         -	     * the filename completer will still beep.
   684         -	     rl_inhibit_completion = 1;
   685         -	     */
   686         -	    return matches;
   687         -	}
   688         -	FREE(expansion);
          666  +            || (start && rl_line_buffer[start - 1] == '!' /* for '$' */))) {
          667  +        char* expansion = (char*) NULL;
          668  +        int oldlen = strlen(rl_line_buffer);
          669  +        status = history_expand(rl_line_buffer, &expansion);
          670  +        if (status >= 1) {
          671  +            rl_extend_line_buffer(strlen(expansion) + 1);
          672  +            strcpy(rl_line_buffer, expansion);
          673  +            rl_end = strlen(expansion);
          674  +            rl_point += strlen(expansion) - oldlen;
          675  +            FREE(expansion);
          676  +            /*
          677  +             * TODO:
          678  +             * because we return 0 == matches,
          679  +             * the filename completer will still beep.
          680  +             rl_inhibit_completion = 1;
          681  +             */
          682  +            return matches;
          683  +        }
          684  +        FREE(expansion);
   689    685       }
   690    686   
   691    687       if (tclrl_custom_completer) {
   692         -	char start_s[BUFSIZ], end_s[BUFSIZ];
   693         -	Tcl_Obj* obj;
   694         -	Tcl_Obj** objv;
   695         -	int objc;
   696         -	int state;
   697         -	char* quoted_text = TclReadlineQuote(text, "$[]{}\"");
   698         -	char* quoted_rl_line_buffer = TclReadlineQuote(rl_line_buffer, "$[]{}\"");
   699         -	sprintf(start_s, "%d", start);
   700         -	sprintf(end_s, "%d", end);
   701         -	Tcl_ResetResult(tclrl_interp); /* clear result space */
   702         -	state = Tcl_VarEval(tclrl_interp, tclrl_custom_completer,
   703         -	    " \"", quoted_text, "\" ", start_s, " ", end_s,
   704         -	    " \"", quoted_rl_line_buffer, "\"", (char*) NULL);
   705         -	if (TCL_OK != state) {
   706         -	    Tcl_AppendResult (tclrl_interp, " `", tclrl_custom_completer,
   707         -		" \"", quoted_text, "\" ", start_s, " ", end_s,
   708         -		" \"", quoted_rl_line_buffer, "\"' failed.", (char*) NULL);
   709         -	    TclReadlineTerminate(state);
   710         -		free(quoted_text);
   711         -		free(quoted_rl_line_buffer);
   712         -	    return matches;
   713         -	}
   714         -	free(quoted_text);
   715         -	quoted_text = NULL;
   716         -	free(quoted_rl_line_buffer);
   717         -	quoted_rl_line_buffer = NULL;
   718         -	obj = Tcl_GetObjResult(tclrl_interp);
   719         -	status = Tcl_ListObjGetElements(tclrl_interp, obj, &objc, &objv);
   720         -	if (TCL_OK != status)
   721         -	    return matches;
   722         -
   723         -	if (objc) {
   724         -	    int i, length;
   725         -	    matches = (char**) MALLOC(sizeof(char*) * (objc + 1));
   726         -	    for (i = 0; i < objc; i++) {
   727         -		matches[i] = strdup(Tcl_GetStringFromObj(objv[i], &length));
   728         -		if (1 == objc && !strlen(matches[i])) {
   729         -		    FREE(matches[i]);
   730         -		    FREE(matches);
   731         -		    Tcl_ResetResult(tclrl_interp); /* clear result space */
   732         -		    return (char**) NULL;
   733         -		}
   734         -	    }
   735         -
   736         -	    /**
   737         -	     * this is a special one:
   738         -	     * if the script returns exactly two arguments
   739         -	     * and the second argument is the empty string,
   740         -	     * the rl_completion_append_character is set
   741         -	     * temporaryly to NULL.
   742         -	     */
   743         -	    if (2 == objc && !strlen(matches[1])) {
   744         -		i--;
   745         -		FREE(matches[1]);
   746         -		rl_completion_append_character = '\0';
   747         -	    }
   748         -
   749         -	    matches[i] = (char*) NULL; /* terminate */
   750         -	}
   751         -	Tcl_ResetResult(tclrl_interp); /* clear result space */
          688  +        char start_s[BUFSIZ], end_s[BUFSIZ];
          689  +        Tcl_Obj* obj;
          690  +        Tcl_Obj** objv;
          691  +        int objc;
          692  +        int state;
          693  +        char* quoted_text = TclReadlineQuote(text, "$[]{}\"");
          694  +        char* quoted_rl_line_buffer = TclReadlineQuote(rl_line_buffer, "$[]{}\"");
          695  +        sprintf(start_s, "%d", start);
          696  +        sprintf(end_s, "%d", end);
          697  +        Tcl_ResetResult(tclrl_interp); /* clear result space */
          698  +        state = Tcl_VarEval(tclrl_interp, tclrl_custom_completer,
          699  +            " \"", quoted_text, "\" ", start_s, " ", end_s,
          700  +            " \"", quoted_rl_line_buffer, "\"", (char*) NULL);
          701  +        if (TCL_OK != state) {
          702  +            Tcl_AppendResult (tclrl_interp, " `", tclrl_custom_completer,
          703  +                " \"", quoted_text, "\" ", start_s, " ", end_s,
          704  +                " \"", quoted_rl_line_buffer, "\"' failed.", (char*) NULL);
          705  +            TclReadlineTerminate(state);
          706  +            FREE(quoted_text);
          707  +            FREE(quoted_rl_line_buffer);
          708  +            return matches;
          709  +        }
          710  +        FREE(quoted_text);
          711  +        FREE(quoted_rl_line_buffer);
          712  +        obj = Tcl_GetObjResult(tclrl_interp);
          713  +        status = Tcl_ListObjGetElements(tclrl_interp, obj, &objc, &objv);
          714  +        if (TCL_OK != status)
          715  +            return matches;
          716  +
          717  +        if (objc) {
          718  +            int i, length;
          719  +            matches = (char**) MALLOC(sizeof(char*) * (objc + 1));
          720  +            for (i = 0; i < objc; i++) {
          721  +                matches[i] = strdup(Tcl_GetStringFromObj(objv[i], &length));
          722  +                if (1 == objc && !strlen(matches[i])) {
          723  +                    FREE(matches[i]);
          724  +                    FREE(matches);
          725  +                    Tcl_ResetResult(tclrl_interp); /* clear result space */
          726  +                    return (char**) NULL;
          727  +                }
          728  +            }
          729  +
          730  +            /**
          731  +             * this is a special one:
          732  +             * if the script returns exactly two arguments
          733  +             * and the second argument is the empty string,
          734  +             * the rl_completion_append_character is set
          735  +             * temporarily to NULL.
          736  +             */
          737  +            if (2 == objc && !strlen(matches[1])) {
          738  +                i--;
          739  +                FREE(matches[1]);
          740  +                rl_completion_append_character = '\0';
          741  +            }
          742  +
          743  +            matches[i] = (char*) NULL; /* terminate */
          744  +        }
          745  +        Tcl_ResetResult(tclrl_interp); /* clear result space */
   752    746       }
   753    747   
   754    748       if (!matches && tclrl_use_builtin_completer) {
   755         -	matches = rl_completion_matches(text, (rl_compentry_func_t *)TclReadline0generator);
          749  +        matches = rl_completion_matches(text, (rl_compentry_func_t *)TclReadline0generator);
   756    750       }
   757    751   
   758    752       return matches;
   759    753   }
   760    754   
   761    755   static char*
   762    756   TclReadline0generator(char* text, int state)
................................................................................
   776    770   
   777    771       char* local_line = (char*) NULL;
   778    772       int sub;
   779    773   
   780    774   
   781    775       switch (mode) {
   782    776   
   783         -	case _CMD_SET:
   784         -
   785         -	    new = (cmds_t *) MALLOC(sizeof(cmds_t));
   786         -	    new->next = (cmds_t *) NULL;
   787         -
   788         -	    if (!cmds) {
   789         -		cmds = new;
   790         -		cmds->prev = new;
   791         -	    }
   792         -	    else {
   793         -		cmds->prev->next = new;
   794         -		cmds->prev = new;
   795         -	    }
   796         -
   797         -	    tmp = strdup(text);
   798         -	    argc = TclReadlineParse(args, sizeof(args), tmp);
   799         -
   800         -	    new->cmd = (char**) MALLOC(sizeof(char*) * (argc + 1));
   801         -
   802         -	    for (i = 0; i < argc; i++)
   803         -		new->cmd[i] = args[i];
   804         -
   805         -	    new->cmd[argc] = (char*) NULL;
          777  +        case _CMD_SET:
          778  +
          779  +            new = (cmds_t *) MALLOC(sizeof(cmds_t));
          780  +            new->next = (cmds_t *) NULL;
          781  +
          782  +            if (!cmds) {
          783  +                cmds = new;
          784  +                cmds->prev = new;
          785  +            } else {
          786  +                cmds->prev->next = new;
          787  +                cmds->prev = new;
          788  +            }
          789  +
          790  +            tmp = strdup(text);
          791  +            argc = TclReadlineParse(args, sizeof(args), tmp);
          792  +
          793  +            new->cmd = (char**) MALLOC(sizeof(char*) * (argc + 1));
          794  +
          795  +            for (i = 0; i < argc; i++)
          796  +                new->cmd[i] = args[i];
          797  +
          798  +            new->cmd[argc] = (char*) NULL;
          799  +
          800  +            return (char*) NULL;
          801  +            /* NOTREACHED */
          802  +            break;
          803  +
          804  +
          805  +        case _CMD_GET:
          806  +
          807  +            local_line = strdup(rl_line_buffer);
          808  +            sub = TclReadlineParse(args, sizeof(args), local_line);
          809  +
          810  +            if (0 == sub || (1 == sub && '\0' != text[0])) {
          811  +                if (!state) {
          812  +                    new = cmds;
          813  +                    len = strlen(text);
          814  +                }
          815  +                while (new && (name = new->cmd)) {
          816  +                    new = new->next;
          817  +                    if (!strncmp(name[0], text, len))
          818  +                        return strdup(name[0]);
          819  +                }
          820  +                return (char*) NULL;
          821  +            } else {
          822  +
          823  +                if (!state) {
          824  +
          825  +                    new = cmds;
          826  +                    len = strlen(text);
          827  +
          828  +                    while (new && (name = new->cmd)) {
          829  +                        if (!strcmp(name[0], args[0]))
          830  +                            break;
          831  +                        new = new->next;
          832  +                    }
          833  +
          834  +                    if (!new)
          835  +                        return (char*) NULL;
          836  +
          837  +                    for (i = 0; new->cmd[i]; i++) /* EMPTY */;
          838  +
          839  +                    if (sub < i && !strncmp(new->cmd[sub], text, len))
          840  +                        return strdup(new->cmd[sub]);
          841  +                    else
          842  +                        return (char*) NULL;
   806    843   
   807         -	    return (char*) NULL;
   808         -	    break;
   809         -
   810         -
   811         -	case _CMD_GET:
   812         -
   813         -	    local_line = strdup(rl_line_buffer);
   814         -	    sub = TclReadlineParse(args, sizeof(args), local_line);
   815         -
   816         -	    if (0 == sub || (1 == sub && '\0' != text[0])) {
   817         -		if (!state) {
   818         -		    new = cmds;
   819         -		    len = strlen(text);
   820         -		}
   821         -		while (new && (name = new->cmd)) {
   822         -		    new = new->next;
   823         -		    if (!strncmp(name[0], text, len))
   824         -			return strdup(name[0]);
   825         -		}
   826         -		return (char*) NULL;
   827         -	    } else {
          844  +                }
          845  +                else
          846  +                    return (char*) NULL;
          847  +            }
   828    848   
   829         -		if (!state) {
   830         -
   831         -		    new = cmds;
   832         -		    len = strlen(text);
   833         -
   834         -		    while (new && (name = new->cmd)) {
   835         -			if (!strcmp(name[0], args[0]))
   836         -			    break;
   837         -			new = new->next;
   838         -		    }
   839         -
   840         -		    if (!new)
   841         -			return (char*) NULL;
   842         -
   843         -		    for (i = 0; new->cmd[i]; i++) /* EMPTY */;
   844         -
   845         -		    if (sub < i && !strncmp(new->cmd[sub], text, len))
   846         -			return strdup(new->cmd[sub]);
   847         -		    else
   848         -			return (char*) NULL;
   849         -
   850         -		}
   851         -		else
   852         -		    return (char*) NULL;
   853         -
   854         -		/* NOTREACHED */
   855         -		break;
   856         -	    }
          849  +            /* NOTREACHED */
          850  +            break;
   857    851   
   858    852   
   859         -	default:
   860         -	    return (char*) NULL;
   861         -	    break;
          853  +        default:
          854  +            return (char*) NULL;
          855  +            /* NOTREACHED */
          856  +            break;
   862    857   
   863    858       }
   864         -    /* NOTREACHED */
   865    859   }
   866    860   
   867    861   static int
   868    862   TclReadlineParse(char** args, int maxargs, char* buf)
   869    863   {
   870    864       int nr = 0;
   871    865   
   872    866       while (*buf != '\0' && nr < maxargs) {
   873         -	/*
   874         -	 * Strip whitespace.  Use nulls, so
   875         -	 * that the previous argument is terminated
   876         -	 * automatically.
   877         -	 */
   878         -	while (ISWHITE(*buf))
   879         -	    *buf++ = '\0';
          867  +        /*
          868  +         * Strip whitespace.  Use nulls, so
          869  +         * that the previous argument is terminated
          870  +         * automatically.
          871  +         */
          872  +        while (ISWHITE(*buf))
          873  +            *buf++ = '\0';
          874  +
          875  +        if (!(*buf)) /* don't count the terminating NULL */
          876  +            break;
   880    877   
   881         -	if (!(*buf)) /* don't count the terminating NULL */
   882         -	    break;
          878  +        *args++ = buf;
          879  +        nr++;
   883    880   
   884         -	*args++ = buf;
   885         -	nr++;
   886         -
   887         -	while (('\0' != *buf) && !ISWHITE(*buf))
   888         -	    buf++;
          881  +        while (('\0' != *buf) && !ISWHITE(*buf))
          882  +            buf++;
   889    883       }
   890    884   
   891    885       *args = '\0';
   892    886       return nr;
   893    887   }
          888  +

Modified tclreadline.h.in from [7eccbb5738] to [d85f8fea8d].

     1         -
     2      1    /* ==================================================================
     3         -    FILE: "/home/joze/src/tclreadline/tclreadline.h.in"
     4         -    LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:33 +0100 (joze)"
     5         -    (C) 1998 - 2001 by Johannes Zellner, <johannes@zellner.org>
            2  +    FILE: tclreadline.h.in
     6      3       $Id$
     7         -    vim:set ft=c:
     8      4       ---
     9      5       tclreadline -- gnu readline for tcl
    10      6       http://www.zellner.org/tclreadline/
    11         -    Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
            7  +    Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    12      8       This software is copyright under the BSD license.
    13         -    ================================================================== */  
            9  +    ================================================================== */
    14     10   
    15     11   #ifndef TCLREADLINE_H_
    16     12   #define TCLREADLINE_H_
    17     13   
    18     14   #include <tcl.h>
    19     15   
    20     16   #define TCLRL_LIBRARY        "@TCLRL_DIR@"

Modified tclreadline.n.in from [561d62d80a] to [ec7927137d].

     1      1   .TH tclreadline n "@PATCHLEVEL_STR@" "Johannes Zellner"
     2      2   
     3         -.\" FILE: "/home/joze/src/tclreadline/tclreadline.n.in"
     4         -.\" LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:33 +0100 (joze)"
     5         -.\" (C) 1998 - 2001 by Johannes Zellner, <johannes@zellner.org>
            3  +.\" FILE: tclreadline.n.in
     6      4   .\" $Id$
     7      5   .\" ---
     8      6   .\" tclreadline -- gnu readline for tcl
     9      7   .\" http://www.zellner.org/tclreadline/
    10         -.\" Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
            8  +.\" Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    11      9   .\" This software is copyright under the BSD license.
           10  +.\" ---
    12     11   
    13     12   
    14         -.\"	# CS - begin code excerpt
           13  +.\" # CS - begin code excerpt
    15     14   .de CS
    16     15   .RS
    17     16   .nf
    18     17   .ta .25i .5i .75i 1i
    19     18   ..
    20         -.\"	# CE - end code excerpt
           19  +.\" # CE - end code excerpt
    21     20   .de CE
    22     21   .fi
    23     22   .RE
    24     23   ..
    25     24   
    26     25   .SH "NAME"
    27     26   tclreadline \- gnu readline for the tcl scripting language
................................................................................
   193    192   arguments, it returns the current setting.
   194    193   
   195    194   .TP 5
   196    195   \fB::tclreadline::Loop\fP [\fIhistoryfile\fP]
   197    196   enter the tclreadline main loop. This command is typically called from
   198    197   the startup resource file (something .tclshrc, depending on the interpreter
   199    198   you use, see the file `sample.tclshrc'). The main loop sets up some
   200         -completion characteristics as variable -- try something like "puts $b<TAB>" -- 
          199  +completion characteristics as variable -- try something like "puts $b<TAB>" --
   201    200   and command completion -- try "puts [in<TAB>".
   202    201   If the optional argument \fIhistoryfile\fP is given, this file will
   203    202   be used for reading and writing the command history instead of the
   204    203   default \fB.tclsh-history\fP.
   205         -\fB::tclreadline::Loop\fP will normally not return. 
          204  +\fB::tclreadline::Loop\fP will normally not return.
   206    205   If you want to write your own main loop and/or own custom completers,
   207    206   it is probably a good idea to start with tclreadline::Loop
   208    207   (see the file tclreadlineSetup.tcl).
   209    208   
   210    209   .TP 5
   211    210   \fB::tclreadline::prompt1\fP
   212    211   a proc which is called by ::tclreadline::Loop and returns a string
................................................................................
   295    294   handler, which will write the history on <ctrl-c> before exiting.
   296    295   
   297    296   .PP
   298    297   the \fB.inputrc\fP file in the users HOME directory. This file
   299    298   is used normally for all programs which use the gnu readline (e.g.  bash).
   300    299   The `global' readline settings there will be valid also for
   301    300   \fBtclreadline\fP. Additionally the .inputrc might hold conditional
   302         -settings for the implementation name \fBtclreadline\fP. Example of 
          301  +settings for the implementation name \fBtclreadline\fP. Example of
   303    302   some lines in your .inputrc:
   304    303   .CS
   305    304       $if tclreadline
   306    305       "\\C-xp": "puts $env(PATH)"
   307    306       $endif
   308    307   .CE
   309    308   

Modified tclreadlineCompleter.tcl from [cf379af2f8] to [1ea8a61e03].

more than 10,000 changes

Modified tclreadlineInit.tcl.in from [56eefa1686] to [554b1c74c7].

     1         -# FILE: "/home/joze/src/tclreadline/tclreadlineInit.tcl.in"
     2         -# LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:33 +0100 (joze)"
     3         -# (C) 1998 - 2001 by Johannes Zellner, <johannes@zellner.org>
            1  +# FILE: tclreadlineInit.tcl.in
     4      2   # $Id$
     5      3   # ---
     6      4   # tclreadline -- gnu readline for tcl
     7      5   # http://www.zellner.org/tclreadline/
     8         -# Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
            6  +# Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
     9      7   # This software is copyright under the BSD license.
            8  +# ---
    10      9   
    11     10   package provide tclreadline @VERSION@
    12     11   
    13     12   namespace eval tclreadline:: {
    14     13       namespace export Init
    15     14   }
    16     15   
    17     16   proc ::tclreadline::Init {} {
    18     17       uplevel #0 {
    19         -	if ![info exists tclreadline::library] {
    20         -	    if [catch {load [file join @TCLRL_LIBDIR@ libtclreadline[info sharedlibextension]]} msg] {
    21         -		puts stderr $msg
    22         -		exit 2
    23         -	    }
    24         -	}
           18  +    if ![info exists tclreadline::library] {
           19  +        if [catch {load [file join @TCLRL_LIBDIR@ libtclreadline[info sharedlibextension]]} msg] {
           20  +        puts stderr $msg
           21  +        exit 2
           22  +        }
           23  +    }
    25     24       }
    26     25   }
    27     26   
    28     27   tclreadline::Init
    29     28   ::tclreadline::readline customcompleter ::tclreadline::ScriptCompleter
    30     29   
    31     30   source [file join [file dirname [info script]] tclreadlineSetup.tcl]
    32     31   
    33     32   set auto_index(::tclreadline::ScriptCompleter) \
    34     33   [list source [file join [file dirname [info script]] tclreadlineCompleter.tcl]]

Modified tclreadlineSetup.tcl.in from [91dcec21a3] to [601cc4d255].

     1         -# FILE: "/home/joze/src/tclreadline/tclreadlineSetup.tcl.in"
     2         -# LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:34 +0100 (joze)"
     3         -# (C) 1998 - 2001 by Johannes Zellner, <johannes@zellner.org>
            1  +# FILE: tclreadlineSetup.tcl.in
     4      2   # $Id$
     5      3   # ---
     6      4   # tclreadline -- gnu readline for tcl
     7      5   # http://www.zellner.org/tclreadline/
     8         -# Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
            6  +# Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
     9      7   # This software is copyright under the BSD license.
            8  +# ---
    10      9   
    11     10   
    12     11   package provide tclreadline @VERSION@
    13     12   
    14     13   proc unknown args {
    15     14   
    16     15       global auto_noexec auto_noload env unknown_pending tcl_interactive
................................................................................
    20     19       # may get modified if caught errors occur below.  The variables will
    21     20       # be restored just before re-executing the missing command.
    22     21   
    23     22       set savedErrorCode $errorCode
    24     23       set savedErrorInfo $errorInfo
    25     24       set name [lindex $args 0]
    26     25       if ![info exists auto_noload] {
    27         -	#
    28         -	# Make sure we're not trying to load the same proc twice.
    29         -	#
    30         -	if [info exists unknown_pending($name)] {
    31         -	    return -code error "self-referential recursion in \"unknown\" for command \"$name\""
    32         -	}
    33         -	set unknown_pending($name) pending
    34         -	set ret [catch {auto_load $name [uplevel 1 {namespace current}]} msg]
    35         -	unset unknown_pending($name)
    36         -	if {$ret != 0} {
    37         -	    return -code $ret -errorcode $errorCode \
    38         -	    "error while autoloading \"$name\": $msg"
    39         -	}
    40         -	if ![array size unknown_pending] {
    41         -	    unset unknown_pending
    42         -	}
    43         -	if $msg {
    44         -	    set errorCode $savedErrorCode
    45         -	    set errorInfo $savedErrorInfo
    46         -	    set code [catch {uplevel 1 $args} msg]
    47         -	    if {$code ==  1} {
    48         -		#
    49         -		# Strip the last five lines off the error stack (they're
    50         -		    # from the "uplevel" command).
    51         -		#
    52         -
    53         -		set new [split $errorInfo \n]
    54         -		set new [join [lrange $new 0 [expr [llength $new] - 6]] \n]
    55         -		return -code error -errorcode $errorCode \
    56         -		-errorinfo $new $msg
    57         -	    } else {
    58         -		return -code $code $msg
    59         -	    }
    60         -	}
           26  +    #
           27  +    # Make sure we're not trying to load the same proc twice.
           28  +    #
           29  +    if [info exists unknown_pending($name)] {
           30  +        return -code error "self-referential recursion in \"unknown\" for command \"$name\""
           31  +    }
           32  +    set unknown_pending($name) pending
           33  +    set ret [catch {auto_load $name [uplevel 1 {namespace current}]} msg]
           34  +    unset unknown_pending($name)
           35  +    if {$ret != 0} {
           36  +        return -code $ret -errorcode $errorCode \
           37  +        "error while autoloading \"$name\": $msg"
           38  +    }
           39  +    if ![array size unknown_pending] {
           40  +        unset unknown_pending
           41  +    }
           42  +    if $msg {
           43  +        set errorCode $savedErrorCode
           44  +        set errorInfo $savedErrorInfo
           45  +        set code [catch {uplevel 1 $args} msg]
           46  +        if {$code ==  1} {
           47  +        #
           48  +        # Strip the last five lines off the error stack (they're
           49  +            # from the "uplevel" command).
           50  +        #
           51  +
           52  +        set new [split $errorInfo \n]
           53  +        set new [join [lrange $new 0 [expr [llength $new] - 6]] \n]
           54  +        return -code error -errorcode $errorCode \
           55  +        -errorinfo $new $msg
           56  +        } else {
           57  +        return -code $code $msg
           58  +        }
           59  +    }
    61     60       }
    62     61   
    63     62       # REMOVED THE [info script] TEST (joze, SEP 98)
    64     63       if {([info level] == 1) && [info exists tcl_interactive] && $tcl_interactive} {
    65         -	if ![info exists auto_noexec] {
    66         -	    set new [auto_execok $name]
    67         -	    if {$new != ""} {
    68         -		set errorCode $savedErrorCode
    69         -		set errorInfo $savedErrorInfo
    70         -		set redir ""
    71         -		if {[info commands console] == ""} {
    72         -		    set redir ">&@stdout <@stdin"
    73         -		}
    74         -		# LOOK FOR GLOB STUFF IN $ARGS (joze, SEP 98)
    75         -		return [uplevel eval exec $redir $new \
    76         -		[::tclreadline::Glob [lrange $args 1 end]]]
    77         -	    }
    78         -	}
    79         -	set errorCode $savedErrorCode
    80         -	set errorInfo $savedErrorInfo
    81         -	if {$name == "!!"} {
    82         -	    set newcmd [history event]
    83         -	} elseif {[regexp {^!(.+)$} $name dummy event]} {
    84         -	    set newcmd [history event $event]
    85         -	} elseif {[regexp {^\^([^^]*)\^([^^]*)\^?$} $name dummy old new]} {
    86         -	    set newcmd [history event -1]
    87         -	    catch {regsub -all -- $old $newcmd $new newcmd}
    88         -	}
    89         -	if [info exists newcmd] {
    90         -	    tclLog $newcmd
    91         -	    history change $newcmd 0
    92         -	    return [uplevel $newcmd]
    93         -	}
    94         -
    95         -	set ret [catch {set cmds [info commands $name*]} msg]
    96         -	if {[string compare $name "::"] == 0} {
    97         -	    set name ""
    98         -	}
    99         -	if {$ret != 0} {
   100         -	    return -code $ret -errorcode $errorCode \
   101         -	    "error in unknown while checking if \"$name\" is a unique command abbreviation: $msg"
   102         -	}
   103         -	if {[llength $cmds] == 1} {
   104         -	    return [uplevel [lreplace $args 0 0 $cmds]]
   105         -	}
   106         -	if {[llength $cmds] != 0} {
   107         -	    if {$name == ""} {
   108         -		return -code error "empty command name \"\""
   109         -	    } else {
   110         -		return -code error \
   111         -		"ambiguous command name \"$name\": [lsort $cmds]"
   112         -	    }
   113         -	}
           64  +    if ![info exists auto_noexec] {
           65  +        set new [auto_execok $name]
           66  +        if {$new != ""} {
           67  +        set errorCode $savedErrorCode
           68  +        set errorInfo $savedErrorInfo
           69  +        set redir ""
           70  +        if {[info commands console] == ""} {
           71  +            set redir ">&@stdout <@stdin"
           72  +        }
           73  +        # LOOK FOR GLOB STUFF IN $ARGS (joze, SEP 98)
           74  +        return [uplevel eval exec $redir $new \
           75  +        [::tclreadline::Glob [lrange $args 1 end]]]
           76  +        }
           77  +    }
           78  +    set errorCode $savedErrorCode
           79  +    set errorInfo $savedErrorInfo
           80  +    if {$name == "!!"} {
           81  +        set newcmd [history event]
           82  +    } elseif {[regexp {^!(.+)$} $name dummy event]} {
           83  +        set newcmd [history event $event]
           84  +    } elseif {[regexp {^\^([^^]*)\^([^^]*)\^?$} $name dummy old new]} {
           85  +        set newcmd [history event -1]
           86  +        catch {regsub -all -- $old $newcmd $new newcmd}
           87  +    }
           88  +    if [info exists newcmd] {
           89  +        tclLog $newcmd
           90  +        history change $newcmd 0
           91  +        return [uplevel $newcmd]
           92  +    }
           93  +
           94  +    set ret [catch {set cmds [info commands $name*]} msg]
           95  +    if {[string compare $name "::"] == 0} {
           96  +        set name ""
           97  +    }
           98  +    if {$ret != 0} {
           99  +        return -code $ret -errorcode $errorCode \
          100  +        "error in unknown while checking if \"$name\" is a unique command abbreviation: $msg"
          101  +    }
          102  +    if {[llength $cmds] == 1} {
          103  +        return [uplevel [lreplace $args 0 0 $cmds]]
          104  +    }
          105  +    if {[llength $cmds] != 0} {
          106  +        if {$name == ""} {
          107  +        return -code error "empty command name \"\""
          108  +        } else {
          109  +        return -code error \
          110  +        "ambiguous command name \"$name\": [lsort $cmds]"
          111  +        }
          112  +    }
   114    113       }
   115    114       return -code error "invalid command name \"$name\""
   116    115   }
   117    116   
   118    117   namespace eval tclreadline {
   119    118   
   120    119   namespace export Setup Loop InitTclCmds InitTkCmds Print ls
   121    120   
   122    121   proc ls {args} {
   123         -	if {[exec uname -s] == "Linux"} {
   124         -		eval exec ls --color -FC [Glob $args]
   125         -	} else {
   126         -		eval exec ls -FC [Glob $args]
   127         -	}
          122  +    if {[exec uname -s] == "Linux"} {
          123  +        eval exec ls --color -FC [Glob $args]
          124  +    } else {
          125  +        eval exec ls -FC [Glob $args]
          126  +    }
   128    127   }
   129    128   
   130    129   proc Setup {args} {
   131    130   
   132    131       uplevel #0 {
   133    132   
   134         -	if {"" == [info commands ::tclreadline::readline]} {
   135         -	    ::tclreadline::Init
   136         -	}
   137         -
   138         -	if {"" == [info procs ::tclreadline::prompt1] && [info nameofexecutable] != ""} {
   139         -
   140         -	    namespace eval ::tclreadline {
   141         -		variable prompt_string
   142         -		set base [file tail [info nameofexecutable]]
   143         -
   144         -		if {[string match tclsh* $base] && [info exists tcl_version]} {
   145         -		    set prompt_string \
   146         -		    "\[0;31mtclsh$tcl_version\[0m"
   147         -		} elseif {[string match wish* $base] \
   148         -		    && [info exists tk_version]} {
   149         -			set prompt_string "\[0;34mwish$tk_version\[0m"
   150         -		    } else {
   151         -			set prompt_string "\[0;31m$base\[0m"
   152         -		    }
   153         -
   154         -	    }
   155         -
   156         -	    if {"" == [info procs ::tclreadline::prompt1]} {
   157         -		proc ::tclreadline::prompt1 {} {
   158         -		    variable prompt_string
   159         -		    global env
   160         -		    if {[catch {set pwd [pwd]} tmp]} {
   161         -			set pwd "unable to get pwd"
   162         -		    }
   163         -
   164         -		    if [info exists env(HOME)] {
   165         -			regsub $env(HOME) $pwd "~" pwd
   166         -		    }
   167         -		    return "$prompt_string \[$pwd\]"
   168         -		}
   169         -	    }
   170         -	    # puts body=[info body ::tclreadline::prompt1]
   171         -	}
   172         -
   173         -	if {"" == [info procs ::tclreadline::prompt2] && [info nameofexecutable] != ""} {
   174         -
   175         -	    if {"" == [info procs ::tclreadline::prompt2]} {
   176         -		proc ::tclreadline::prompt2 {} {
   177         -		    return ">"
   178         -		}
   179         -	    }
   180         -	    # puts body=[info body ::tclreadline::prompt2]
   181         -	}
   182         -
   183         -	if {"" == [info procs exit]} {
   184         -
   185         -	    catch {rename ::tclreadline::Exit ""}
   186         -	    rename exit ::tclreadline::Exit
   187         -
   188         -	    proc exit {args} {
   189         -
   190         -		if {[catch {
   191         -		    ::tclreadline::readline write \
   192         -		    [::tclreadline::HistoryFileGet]
   193         -		} ::tclreadline::errorMsg]} {
   194         -		    puts stderr $::tclreadline::errorMsg
   195         -		}
   196         -
   197         -		# this call is ignored, if tclreadline.c
   198         -		# was compiled with CLEANUP_AFER_SIGNAL
   199         -		# not defined. This is the case for
   200         -		# older versions of libreadline.
   201         -		#
   202         -		::tclreadline::readline reset-terminal
   203         -
   204         -		if [catch "eval ::tclreadline::Exit $args" message] {
   205         -		    puts stderr "error:"
   206         -		    puts stderr "$message"
   207         -		}
   208         -		# NOTREACHED
   209         -	    }
   210         -	}
          133  +    if {"" == [info commands ::tclreadline::readline]} {
          134  +        ::tclreadline::Init
          135  +    }
          136  +
          137  +    if {"" == [info procs ::tclreadline::prompt1] && [info nameofexecutable] != ""} {
          138  +
          139  +        namespace eval ::tclreadline {
          140  +        variable prompt_string
          141  +        set base [file tail [info nameofexecutable]]
          142  +
          143  +        if {[string match tclsh* $base] && [info exists tcl_version]} {
          144  +            set prompt_string \
          145  +            "\[0;31mtclsh$tcl_version\[0m"
          146  +        } elseif {[string match wish* $base] \
          147  +            && [info exists tk_version]} {
          148  +            set prompt_string "\[0;34mwish$tk_version\[0m"
          149  +            } else {
          150  +            set prompt_string "\[0;31m$base\[0m"
          151  +            }
          152  +
          153  +        }
          154  +
          155  +        if {"" == [info procs ::tclreadline::prompt1]} {
          156  +        proc ::tclreadline::prompt1 {} {
          157  +            variable prompt_string
          158  +            global env
          159  +            if {[catch {set pwd [pwd]} tmp]} {
          160  +            set pwd "unable to get pwd"
          161  +            }
          162  +
          163  +            if [info exists env(HOME)] {
          164  +            regsub $env(HOME) $pwd "~" pwd
          165  +            }
          166  +            return "$prompt_string \[$pwd\]"
          167  +        }
          168  +        }
          169  +        # puts body=[info body ::tclreadline::prompt1]
          170  +    }
          171  +
          172  +    if {"" == [info procs ::tclreadline::prompt2] && [info nameofexecutable] != ""} {
          173  +
          174  +        if {"" == [info procs ::tclreadline::prompt2]} {
          175  +        proc ::tclreadline::prompt2 {} {
          176  +            return ">"
          177  +        }
          178  +        }
          179  +        # puts body=[info body ::tclreadline::prompt2]
          180  +    }
          181  +
          182  +    if {"" == [info procs exit]} {
          183  +
          184  +        catch {rename ::tclreadline::Exit ""}
          185  +        rename exit ::tclreadline::Exit
          186  +
          187  +        proc exit {args} {
          188  +
          189  +        if {[catch {
          190  +            ::tclreadline::readline write \
          191  +            [::tclreadline::HistoryFileGet]
          192  +        } ::tclreadline::errorMsg]} {
          193  +            puts stderr $::tclreadline::errorMsg
          194  +        }
          195  +
          196  +        # this call is ignored, if tclreadline.c
          197  +        # was compiled with CLEANUP_AFER_SIGNAL
          198  +        # not defined. This is the case for
          199  +        # older versions of libreadline.
          200  +        #
          201  +        ::tclreadline::readline reset-terminal
          202  +
          203  +        if [catch "eval ::tclreadline::Exit $args" message] {
          204  +            puts stderr "error:"
          205  +            puts stderr "$message"
          206  +        }
          207  +        # NOTREACHED
          208  +        }
          209  +    }
   211    210   
   212    211       }
   213    212   
   214    213       global env
   215    214       variable historyfile
   216    215   
   217    216       if {[string trim [llength ${args}]]} {
   218         -	set historyfile ""
   219         -	catch {
   220         -	    set historyfile [file nativename [lindex ${args} 0]]
   221         -	}
   222         -	if {"" == [string trim $historyfile]} {
   223         -	    set historyfile [lindex ${args} 0]
   224         -	}
          217  +    set historyfile ""
          218  +    catch {
          219  +        set historyfile [file nativename [lindex ${args} 0]]
          220  +    }
          221  +    if {"" == [string trim $historyfile]} {
          222  +        set historyfile [lindex ${args} 0]
          223  +    }
          224  +    } else {
          225  +    if [info exists env(HOME)] {
          226  +        set historyfile  $env(HOME)/.tclsh-history
   225    227       } else {
   226         -	if [info exists env(HOME)] {
   227         -	    set historyfile  $env(HOME)/.tclsh-history
   228         -	} else {
   229         -	    set historyfile  .tclsh-history
   230         -	}
          228  +        set historyfile  .tclsh-history
          229  +    }
   231    230       }
   232    231       set ::tclreadline::errorMsg [readline initialize $historyfile]
   233    232       if {$::tclreadline::errorMsg != ""} {
   234         -	puts stderr $::tclreadline::errorMsg
          233  +    puts stderr $::tclreadline::errorMsg
   235    234       }
   236    235   
   237    236       # InitCmds
   238    237   
   239    238       rename Setup ""
   240    239   }
   241    240   
................................................................................
   246    245   
   247    246   # obsolete
   248    247   #
   249    248   proc Glob {string} {
   250    249   
   251    250       set commandstring ""
   252    251       foreach name $string {
   253         -	set replace [glob -nocomplain -- $name]
   254         -	if {$replace == ""} {
   255         -	    lappend commandstring $name
   256         -	} else {
   257         -	    lappend commandstring $replace
   258         -	}
          252  +    set replace [glob -nocomplain -- $name]
          253  +    if {$replace == ""} {
          254  +        lappend commandstring $name
          255  +    } else {
          256  +        lappend commandstring $replace
          257  +    }
   259    258       }
   260    259       # return $commandstring
   261    260       # Christian Krone <krischan@sql.de> proposed
   262    261       return [eval concat $commandstring]
   263    262   }
   264    263   
   265    264   
................................................................................
   266    265   
   267    266   proc Loop {args} {
   268    267   
   269    268       eval Setup ${args}
   270    269   
   271    270       uplevel #0 {
   272    271   
   273         -	while {1} {
          272  +    while {1} {
          273  +
          274  +        if {[catch {
          275  +        if {"" != [namespace eval ::tclreadline {info procs prompt1}]} {
          276  +            set ::tclreadline::LINE [::tclreadline::readline read \
          277  +            [::tclreadline::prompt1]]
          278  +        } else {
          279  +            set ::tclreadline::LINE [::tclreadline::readline read %]
          280  +        }
          281  +        while {![::tclreadline::readline complete $::tclreadline::LINE]} {
          282  +            append ::tclreadline::LINE "\n"
          283  +            if {"" != [namespace eval ::tclreadline {info procs prompt2}]} {
          284  +            append ::tclreadline::LINE \
          285  +                [tclreadline::readline read [::tclreadline::prompt2]]
          286  +            } else {
          287  +            append ::tclreadline::LINE [tclreadline::readline read >]
          288  +            }
          289  +        }
          290  +        } ::tclreadline::errorMsg]} {
          291  +        puts stderr [list tclreadline::Loop: error. \
          292  +        $::tclreadline::errorMsg]
          293  +        continue
          294  +        }
   274    295   
   275         -	    if {[catch {
   276         -		if {"" != [namespace eval ::tclreadline {info procs prompt1}]} {
   277         -		    set ::tclreadline::LINE [::tclreadline::readline read \
   278         -		    [::tclreadline::prompt1]]
   279         -		} else {
   280         -		    set ::tclreadline::LINE [::tclreadline::readline read %]
   281         -		}
   282         -		while {![::tclreadline::readline complete $::tclreadline::LINE]} {
   283         -		    append ::tclreadline::LINE "\n"
   284         -		    if {"" != [namespace eval ::tclreadline {info procs prompt2}]} {
   285         -			append ::tclreadline::LINE \
   286         -			    [tclreadline::readline read [::tclreadline::prompt2]]
   287         -		    } else {
   288         -			append ::tclreadline::LINE [tclreadline::readline read >]
   289         -		    }
   290         -		}
   291         -	    } ::tclreadline::errorMsg]} {
   292         -		puts stderr [list tclreadline::Loop: error. \
   293         -		$::tclreadline::errorMsg]
   294         -		continue
   295         -	    }
          296  +        # Magnus Eriksson <magnus.eriksson@netinsight.se> proposed
          297  +        # to add the line also to tclsh's history.
          298  +        #
          299  +        # I decided to add only lines which are different from
          300  +        # the previous one to the history. This is different
          301  +        # from tcsh's behaviour, but I found it quite convenient
          302  +        # while using mshell on os9.
          303  +        #
          304  +        if {[string length $::tclreadline::LINE] && \
          305  +            [history event 0] != $::tclreadline::LINE} {
          306  +        history add $::tclreadline::LINE
          307  +        }
   296    308   
   297         -	    # Magnus Eriksson <magnus.eriksson@netinsight.se> proposed
   298         -	    # to add the line also to tclsh's history.
   299         -	    #
   300         -	    # I decided to add only lines which are different from
   301         -	    # the previous one to the history. This is different
   302         -	    # from tcsh's behaviour, but I found it quite convenient
   303         -	    # while using mshell on os9.
   304         -	    #
   305         -	    if {[string length $::tclreadline::LINE] && \
   306         -		    [history event 0] != $::tclreadline::LINE} {
   307         -		history add $::tclreadline::LINE
   308         -	    }
          309  +        if [catch {
          310  +        set ::tclreadline::result [eval $::tclreadline::LINE]
          311  +        if {$::tclreadline::result != "" && [tclreadline::Print]} {
          312  +            puts $::tclreadline::result
          313  +        }
          314  +        set ::tclreadline::result ""
          315  +        } ::tclreadline::errorMsg] {
          316  +        puts stderr $::tclreadline::errorMsg
          317  +        puts stderr [list while evaluating $::tclreadline::LINE]
          318  +        }
   309    319   
   310         -	    if [catch {
   311         -		set ::tclreadline::result [eval $::tclreadline::LINE]
   312         -		if {$::tclreadline::result != "" && [tclreadline::Print]} {
   313         -		    puts $::tclreadline::result
   314         -		}
   315         -		set ::tclreadline::result ""
   316         -	    } ::tclreadline::errorMsg] {
   317         -		puts stderr $::tclreadline::errorMsg
   318         -		puts stderr [list while evaluating $::tclreadline::LINE]
   319         -	    }
   320         -
   321         -	}
          320  +    }
   322    321       }
   323    322   }
   324    323   
   325    324   proc Print {args} {
   326    325       variable PRINT
   327    326       if ![info exists PRINT] {
   328         -	set PRINT yes
          327  +    set PRINT yes
   329    328       }
   330    329       if [regexp -nocase \(true\|yes\|1\) $args] {
   331         -	set PRINT yes
          330  +    set PRINT yes
   332    331       } elseif [regexp -nocase \(false\|no\|0\) $args] {
   333         -	set PRINT no
          332  +    set PRINT no
   334    333       }
   335    334       return $PRINT
   336    335   }
   337         -# 
   338         -# 
          336  +#
          337  +#
   339    338   # proc InitCmds {} {
   340    339   #     # XXX
   341         -#     return 
          340  +#     return
   342    341   #     # XXX
   343    342   #     global tcl_version tk_version
   344    343   #     if {[info exists tcl_version]} {
   345    344   #         InitTclCmds
   346    345   #     }
   347    346   #     if {[info exists tk_version]} {
   348    347   #         InitTkCmds
   349    348   #     }
   350    349   #     rename InitCmds ""
   351    350   # }
   352         -# 
          351  +#
   353    352   # proc InitTclCmds {} {
   354    353   #     variable known_cmds
   355    354   #     foreach line {
   356    355   #         "after option ?arg arg ...?"
   357    356   #         "append varName ?value value ...?"
   358    357   #         "array option arrayName ?arg ...?"
   359    358   #         "bgerror"
................................................................................
   407    406   #         "while test command"
   408    407   #     } {
   409    408   #         readline add $line
   410    409   #         set known_cmds([lindex $line 0]) ${line}
   411    410   #     }
   412    411   #     rename InitTclCmds ""
   413    412   # }
   414         -# 
          413  +#
   415    414   # proc InitTkCmds {} {
   416    415   #     variable known_cmds
   417    416   #     foreach line {
   418    417   #         "bind window ?pattern? ?command?"
   419    418   #         "bindtags window ?tags?"
   420    419   #         "button pathName ?options?"
   421    420   #         "canvas pathName ?options?"
................................................................................
   450    449   #         "wm option window ?arg ...?"
   451    450   #     } {
   452    451   #         readline add $line
   453    452   #         set known_cmds([lindex $line 0]) ${line}
   454    453   #     }
   455    454   #     rename InitTkCmds ""
   456    455   # }
   457         -# 
          456  +#
   458    457   
   459    458   
   460    459   }; # namespace tclreadline

Modified tclshrl.c from [6604055b46] to [c7e5e71138].

     1         -
     2      1    /* ==================================================================
     3         -
     4         -    FILE: "/home/joze/src/tclreadline/tclshrl.c"
     5         -    LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:34 +0100 (joze)"
     6         -    (C) 1998 - 2001 by Johannes Zellner, <johannes@zellner.org>
            2  +    FILE: tclshrl.c
     7      3       $Id$
     8      4       ---
     9         -
    10      5       tclreadline -- gnu readline for tcl
    11      6       http://www.zellner.org/tclreadline/
    12         -    Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
    13         -
            7  +    Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    14      8       This software is copyright under the BSD license.
    15         -
    16         -    ================================================================== */  
            9  +    ================================================================== */
    17     10   
    18     11   #ifdef HAVE_CONFIG_H
    19     12   #   include "config.h"
    20     13   #endif
    21     14   
    22     15   #include <tcl.h>
    23     16   #include <tclreadline.h>
................................................................................
    34     27   {
    35     28       char file[0xff];
    36     29       int status;
    37     30   #if 0
    38     31       assert(Tcl_InitStubs(interp, TCL_VERSION, 0));
    39     32   #endif
    40     33       if (TCL_ERROR == Tcl_Init(interp)) {
    41         -	return TCL_ERROR;
           34  +        return TCL_ERROR;
    42     35       }
    43     36       if (TCL_ERROR == Tclreadline_Init(interp)) {
    44         -	return TCL_ERROR;
           37  +        return TCL_ERROR;
    45     38       }
    46     39       Tcl_StaticPackage(interp, "tclreadline",
    47         -	Tclreadline_Init, Tclreadline_SafeInit);
           40  +    Tclreadline_Init, Tclreadline_SafeInit);
    48     41   #if (TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION == 4)
    49     42       tcl_RcFileName = "~/.tclshrc";
    50     43   #else
    51     44       Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
    52     45   #endif
    53     46       sprintf(file, "%s/tclreadlineInit.tcl", TCLRL_LIBRARY);
    54     47       if ((status = Tcl_EvalFile(interp, file))) {
    55         -	fprintf(stderr, "(TclreadlineAppInit) unable to eval %s\n", file);
    56         -	exit (1);
           48  +        fprintf(stderr, "(TclreadlineAppInit) unable to eval %s\n", file);
           49  +        exit (1);
    57     50       }
    58     51       return TCL_OK;
    59     52   }
    60     53   
    61     54   int
    62     55   main(int argc, char *argv[])
    63     56   {
    64     57       Tcl_Main(argc, argv, TclreadlineAppInit);
    65     58       return 0;
    66     59   }

Modified wishrl.c from [fd844d639f] to [d3a28cc973].

     1         -
     2      1    /* ==================================================================
     3         -
     4         -    FILE: "/home/joze/src/tclreadline/wishrl.c"
     5         -    LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:34 +0100 (joze)"
     6         -    (C) 1998 - 2001 by Johannes Zellner, <johannes@zellner.org>
            2  +    FILE: wishrl.c
     7      3       $Id$
     8      4       ---
     9         -
    10      5       tclreadline -- gnu readline for tcl
    11      6       http://www.zellner.org/tclreadline/
    12         -    Copyright (c) 1998 - 2001, Johannes Zellner <johannes@zellner.org>
    13         -
            7  +    Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    14      8       This software is copyright under the BSD license.
    15         -
    16         -    ================================================================== */  
            9  +    ================================================================== */
    17     10   
    18     11   #ifdef HAVE_CONFIG_H
    19     12   #   include "config.h"
    20     13   #endif
    21     14   
    22     15   #include <tcl.h>
    23     16   #include <tk.h>
................................................................................
    29     22   int
    30     23   TclreadlineAppInit(Tcl_Interp* interp)
    31     24   {
    32     25       char file[0xff];
    33     26       int status;
    34     27   
    35     28       if (TCL_ERROR == Tcl_Init(interp)) {
    36         -	return TCL_ERROR;
           29  +        return TCL_ERROR;
    37     30       }
    38     31       if (TCL_ERROR == Tk_Init(interp)) {
    39         -	return TCL_ERROR;
           32  +        return TCL_ERROR;
    40     33       }
    41     34       if (TCL_ERROR == Tclreadline_Init(interp)) {
    42         -	return TCL_ERROR;
           35  +        return TCL_ERROR;
    43     36       }
    44     37       Tcl_StaticPackage(interp, "tclreadline",
    45         -	Tclreadline_Init, Tclreadline_SafeInit);
           38  +    Tclreadline_Init, Tclreadline_SafeInit);
    46     39   #if (TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION == 4)
    47     40       tcl_RcFileName = "~/.wishrc";
    48     41   #else
    49     42       Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
    50     43   #endif
    51     44       sprintf(file, "%s/tclreadlineInit.tcl", TCLRL_LIBRARY);
    52     45       if ((status = Tcl_EvalFile(interp, file))) {
    53         -	fprintf(stderr, "(TclreadlineAppInit) unable to eval %s\n", file);
    54         -	exit (1);
           46  +        fprintf(stderr, "(TclreadlineAppInit) unable to eval %s\n", file);
           47  +        exit (1);
    55     48       }
    56     49       return TCL_OK;
    57     50   }
    58     51   
    59     52   int
    60     53   main(int argc, char *argv[])
    61     54   {
    62     55       Tk_Main(argc, argv, TclreadlineAppInit);
    63     56       return 0;
    64     57   }