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:   12-Apr-2009 21:39:59
  Branch: HEAD                             Handle: 2009041219395801

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

  Log:
    - tcl: attach rpmtclIO to macro expansion buffer with
    Tcl_StackChannel.

  Summary:
    Revision    Changes     Path
    1.2917      +1  -0      rpm/CHANGES
    2.5         +72 -2      rpm/rpmio/rpmtcl.c
    2.4         +2  -0      rpm/rpmio/rpmtcl.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2916 -r1.2917 CHANGES
  --- rpm/CHANGES       12 Apr 2009 17:26:33 -0000      1.2916
  +++ rpm/CHANGES       12 Apr 2009 19:39:58 -0000      1.2917
  @@ -1,5 +1,6 @@
   
   5.2a3 -> 5.2a4:
  +    - jbj: tcl: attach rpmtclIO to macro expansion buffer with 
Tcl_StackChannel.
       - jbj: ruby: attach $stdout to macro expansion buffer using StringIO.
       - jbj: python: attach sys.stdout to macro expansion buffer using 
cStringIO.
       - jbj: tpython: permit interactive shells.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmtcl.c
  ============================================================================
  $ cvs diff -u -r2.4 -r2.5 rpmtcl.c
  --- rpm/rpmio/rpmtcl.c        7 Apr 2009 17:17:21 -0000       2.4
  +++ rpm/rpmio/rpmtcl.c        12 Apr 2009 19:39:59 -0000      2.5
  @@ -21,6 +21,8 @@
       Tcl_DeleteInterp(tcl->I);
   #endif
       tcl->I = NULL;
  +    (void)rpmiobFree(tcl->iob);
  +    tcl->iob = NULL;
   }
   
   /*...@unchecked@*/ /*...@only@*/ /*...@null@*/
  @@ -40,6 +42,64 @@
       return (rpmtcl) rpmioGetPool(pool, sizeof(*tcl));
   }
   
  +#if defined(WITH_TCL)
  +static int rpmtclIOclose(ClientData CD, Tcl_Interp *I)
  +     /*...@*/
  +{
  +if (_rpmtcl_debug)
  +fprintf(stderr, "==> %s(%p, %p)\n", __FUNCTION__, CD, I);
  +    return 0;
  +}
  +
  +static int rpmtclIOread(ClientData CD, char *b, int nb, int *errnop)
  +     /*...@*/
  +{
  +if (_rpmtcl_debug)
  +fprintf(stderr, "==> %s(%p, %p[%d], %p)\n", __FUNCTION__, CD, b, nb, errnop);
  +    *errnop = EINVAL;
  +    return -1;
  +}
  +
  +static int rpmtclIOwrite(ClientData CD, const char *b, int nb, int *errnop)
  +     /*...@*/
  +{
  +    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);
  +    return nb;
  +}
  +
  +static int rpmtclIOseek(ClientData CD, long off, int mode, int *errnop)
  +     /*...@*/
  +{
  +if (_rpmtcl_debug)
  +fprintf(stderr, "==> %s(%p, %ld, %d, %p)\n", __FUNCTION__, CD, off, mode, 
errnop);
  +    *errnop = EINVAL;
  +    return -1;
  +}
  +
  +static Tcl_ChannelType rpmtclIO = {
  +    "rpmtclIO",                      /* Type name */
  +    TCL_CHANNEL_VERSION_2,   /* Tcl_ChannelTypeVersion */
  +    rpmtclIOclose,           /* Tcl_DriverCloseProc */
  +    rpmtclIOread,            /* Tcl_DriverInputProc */
  +    rpmtclIOwrite,           /* Tcl_DriverOutputProc */
  +    rpmtclIOseek,            /* Tcl_DriverSeekProc */
  +    NULL,                    /* Tcl_DriverSetOptionProc */
  +    NULL,                    /* Tcl_DriverGetOptionProc */
  +    NULL,                    /* Tcl_DriverWatchProc */
  +    NULL,                    /* Tcl_DriverGetHandleProc */
  +    NULL,                    /* Tcl_DriverClose2Proc */
  +    NULL,                    /* Tcl_DriverBlockModeProc */
  +    NULL,                    /* Tcl_DriverFlushProc */
  +    NULL,                    /* Tcl_DriverHandlerProc */
  +    NULL,                    /* Tcl_DriverWideSeekProc */
  +    NULL,                    /* Tcl_DriverThreadActionProc */
  +    NULL,                    /* Tcl_DriverTruncateProc */
  +};
  +#endif
  +
   rpmtcl rpmtclNew(const char * fn, int flags)
   {
       rpmtcl tcl = rpmtclGetPool(_rpmtclPool);
  @@ -48,7 +108,13 @@
        tcl->fn = xstrdup(fn);
       tcl->flags = flags;
   
  +#if defined(WITH_TCL)
       tcl->I = Tcl_CreateInterp();
  +    tcl->tclout = Tcl_GetStdChannel(TCL_STDOUT);
  +    Tcl_SetChannelOption(tcl->I, tcl->tclout, "-translation", "auto");
  +    Tcl_StackChannel(tcl->I, &rpmtclIO, tcl, TCL_WRITABLE, tcl->tclout);
  +#endif
  +    tcl->iob = rpmiobNew(0);
   
       return rpmtclLink(tcl);
   }
  @@ -60,11 +126,13 @@
   if (_rpmtcl_debug)
   fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, tcl, fn);
   
  +#if defined(WITH_TCL)
       if (fn != NULL && Tcl_EvalFile(tcl->I, fn) == TCL_OK) {
        rc = RPMRC_OK;
        if (resultp)
  -         *resultp = Tcl_GetStringResult(tcl->I); /* XXX Tcl_GetObjResult */
  +         *resultp = rpmiobStr(tcl->iob);
       }
  +#endif
       return rc;
   }
   
  @@ -75,11 +143,13 @@
   if (_rpmtcl_debug)
   fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, tcl, str);
   
  +#if defined(WITH_TCL)
       if (str != NULL && Tcl_Eval(tcl->I, str) == TCL_OK) {
        rc = RPMRC_OK;
        if (resultp)
  -         *resultp = Tcl_GetStringResult(tcl->I); /* XXX Tcl_GetObjResult */
  +         *resultp = rpmiobStr(tcl->iob);
       }
  +#endif
       return rc;
   }
   #endif       /* WITH_TCL */
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmtcl.h
  ============================================================================
  $ cvs diff -u -r2.3 -r2.4 rpmtcl.h
  --- rpm/rpmio/rpmtcl.h        7 Apr 2009 17:17:21 -0000       2.3
  +++ rpm/rpmio/rpmtcl.h        12 Apr 2009 19:39:59 -0000      2.4
  @@ -21,6 +21,8 @@
       const char * fn;
       int flags;
       Tcl_Interp * I;
  +    void * tclout;
  +    rpmiob iob;
   };
   #endif /* _RPMTCL_INTERNAL */
   
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to