RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: rpm                              Date:   16-Apr-2009 20:28:32
  Branch: HEAD                             Handle: 2009041618283101

  Modified files:
    rpm                     CHANGES
    rpm/lib                 psm.c
    rpm/rpmio               rpmtcl.c rpmtcl.h

  Log:
    - tcl: load and use $argv and $argc.
    - tcl: fix: don't append multiple newlines.

  Summary:
    Revision    Changes     Path
    1.2939      +2  -0      rpm/CHANGES
    2.363       +3  -9      rpm/lib/psm.c
    2.9         +27 -10     rpm/rpmio/rpmtcl.c
    2.7         +0  -1      rpm/rpmio/rpmtcl.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2938 -r1.2939 CHANGES
  --- rpm/CHANGES       16 Apr 2009 17:27:16 -0000      1.2938
  +++ rpm/CHANGES       16 Apr 2009 18:28:31 -0000      1.2939
  @@ -1,5 +1,7 @@
   
   5.2a4 -> 5.2b1:
  +    - jbj: tcl: load and use $argv and $argc.
  +    - jbj: tcl: fix: don't append multiple newlines.
       - jbj: perl: load and use @ARGV. Note that shell $1 ends up in perl 
$ARGV[0]
       - jbj: ruby: load and use ARGV. Note that shell $1 ends up in ruby 
ARGV[0].
       - jbj: python: load and use sys.argv.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/psm.c
  ============================================================================
  $ cvs diff -u -r2.362 -r2.363 psm.c
  --- rpm/lib/psm.c     16 Apr 2009 17:27:16 -0000      2.362
  +++ rpm/lib/psm.c     16 Apr 2009 18:28:32 -0000      2.363
  @@ -679,15 +679,9 @@
   #endif
   #if defined(WITH_TCL)
       if (!strcmp(Phe->p.argv[0], "<tcl>")) {
  -     rpmtcl tcl = rpmtclNew(NULL, 0);
  -     char args[128];
  -     (void)snprintf(args, sizeof(args), "set arg { %d %d }", arg1, arg2);
  -     args[sizeof(args)-1] = '\0';
  -     if (rpmtclRun(tcl, args, NULL) == RPMRC_OK
  -      && rpmtclRun(tcl, script, NULL) == RPMRC_OK)
  -         rc = RPMRC_OK;
  -     else
  -         rc = RPMRC_FAIL;
  +     rpmtcl tcl = rpmtclNew(av, 0);
  +     rc = rpmtclRun(tcl, script, NULL) == RPMRC_OK
  +         ? RPMRC_OK : RPMRC_FAIL;
        tcl = rpmtclFree(tcl);
       } else
   #endif
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmtcl.c
  ============================================================================
  $ cvs diff -u -r2.8 -r2.9 rpmtcl.c
  --- rpm/rpmio/rpmtcl.c        15 Apr 2009 23:01:40 -0000      2.8
  +++ rpm/rpmio/rpmtcl.c        16 Apr 2009 18:28:32 -0000      2.9
  @@ -1,5 +1,7 @@
   #include "system.h"
   
  +#include <argv.h>
  +
   #ifdef       WITH_TCL
   #include <tcl.h>
   #endif
  @@ -20,7 +22,6 @@
   {
       rpmtcl tcl = _tcl;
   
  -    tcl->flags = 0;
   #if defined(WITH_TCL)
       Tcl_DeleteInterp((Tcl_Interp *)tcl->I);
   #endif
  @@ -70,7 +71,13 @@
       rpmtcl tcl = (rpmtcl) CD;
   if (_rpmtcl_debug)
   fprintf(stderr, "==> %s(%p, %p[%d], %p)\n", __FUNCTION__, CD, b, nb, errnop);
  -    (void) rpmiobAppend(tcl->iob, b, (size_t)nb);
  +    if (nb > 0) {
  +     char * t = (char *)b;
  +     int c = t[nb];
  +     if (c) t[nb] = '\0';
  +     (void) rpmiobAppend(tcl->iob, b, 0);
  +     if (c) t[nb] = c;
  +    }
       return nb;
   }
   
  @@ -108,15 +115,25 @@
   {
       rpmtcl tcl = rpmtclGetPool(_rpmtclPool);
   
  -    tcl->flags = flags;
  -
   #if defined(WITH_TCL)
  -    {        Tcl_Interp * tclI = Tcl_CreateInterp();
  -     tcl->I = tclI;
  -     tcl->tclout = Tcl_GetStdChannel(TCL_STDOUT);
  -     Tcl_SetChannelOption(tclI, tcl->tclout, "-translation", "auto");
  -     Tcl_StackChannel(tclI, &rpmtclIO, tcl, TCL_WRITABLE, tcl->tclout);
  -    }
  +    static const char * _av[] = { "rpmtcl", NULL };
  +    Tcl_Interp * tclI = Tcl_CreateInterp();
  +    char b[32];
  +    int ac;
  +
  +    if (av == NULL) av = _av;
  +    ac = argvCount(av);
  +
  +    Tcl_SetVar(tclI, "argv", Tcl_Merge(ac-1, av+1), TCL_GLOBAL_ONLY);
  +    (void)sprintf(b, "%d", ac-1);
  +    Tcl_SetVar(tclI, "argc", b, TCL_GLOBAL_ONLY);
  +    Tcl_SetVar(tclI, "argv0", av[0], TCL_GLOBAL_ONLY);
  +    Tcl_SetVar(tclI, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
  +
  +    tcl->I = tclI;
  +    tcl->tclout = Tcl_GetStdChannel(TCL_STDOUT);
  +    Tcl_SetChannelOption(tclI, tcl->tclout, "-translation", "auto");
  +    Tcl_StackChannel(tclI, &rpmtclIO, tcl, TCL_WRITABLE, tcl->tclout);
   #endif
       tcl->iob = rpmiobNew(0);
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmtcl.h
  ============================================================================
  $ cvs diff -u -r2.6 -r2.7 rpmtcl.h
  --- rpm/rpmio/rpmtcl.h        15 Apr 2009 23:01:40 -0000      2.6
  +++ rpm/rpmio/rpmtcl.h        16 Apr 2009 18:28:32 -0000      2.7
  @@ -21,7 +21,6 @@
   
   struct rpmtcl_s {
       struct rpmioItem_s _item;        /*!< usage mutex and pool identifier. */
  -    int flags;
       void * I;                        /* Tcl_Interp */
       void * tclout;           /* Tcl_Channel */
       rpmiob iob;
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to