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 19:26:33
  Branch: HEAD                             Handle: 2009041217263300

  Modified files:
    rpm                     CHANGES
    rpm/rpmio               rpmpython.c rpmruby.c

  Log:
    - ruby: attach $stdout to macro expansion buffer using StringIO.

  Summary:
    Revision    Changes     Path
    1.2916      +1  -0      rpm/CHANGES
    2.4         +2  -2      rpm/rpmio/rpmpython.c
    2.3         +13 -9      rpm/rpmio/rpmruby.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2915 -r1.2916 CHANGES
  --- rpm/CHANGES       12 Apr 2009 02:24:39 -0000      1.2915
  +++ rpm/CHANGES       12 Apr 2009 17:26:33 -0000      1.2916
  @@ -1,5 +1,6 @@
   
   5.2a3 -> 5.2a4:
  +    - 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.
       - jbj: fix: permit rpmiobSlurp() to be used on stdin.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmpython.c
  ============================================================================
  $ cvs diff -u -r2.3 -r2.4 rpmpython.c
  --- rpm/rpmio/rpmpython.c     12 Apr 2009 02:45:48 -0000      2.3
  +++ rpm/rpmio/rpmpython.c     12 Apr 2009 17:26:33 -0000      2.4
  @@ -43,7 +43,7 @@
       return (rpmpython) rpmioGetPool(pool, sizeof(*python));
   }
   
  -static const char * initStringIO = "\
  +static const char * rpmpythonInitStringIO = "\
   import rpm\n\
   import sys\n\
   from cStringIO import StringIO\n\
  @@ -63,7 +63,7 @@
       Py_Initialize();
       if (PycStringIO == NULL)
        PycStringIO = PyCObject_Import("cStringIO", "cStringIO_CAPI");
  -    (void) rpmpythonRun(python, initStringIO, NULL);
  +    (void) rpmpythonRun(python, rpmpythonInitStringIO, NULL);
   #endif
   
       return rpmpythonLink(python);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmruby.c
  ============================================================================
  $ cvs diff -u -r2.2 -r2.3 rpmruby.c
  --- rpm/rpmio/rpmruby.c       8 Apr 2009 19:55:57 -0000       2.2
  +++ rpm/rpmio/rpmruby.c       12 Apr 2009 17:26:33 -0000      2.3
  @@ -54,6 +54,11 @@
       return (rpmruby) rpmioGetPool(pool, sizeof(*ruby));
   }
   
  +static const char * rpmrubyInitStringIO = "\
  +require 'stringio'\n\
  +$stdout = StringIO.new($result, \"w+\")\n\
  +";
  +
   rpmruby rpmrubyNew(const char * fn, int flags)
   {
       rpmruby ruby = rpmrubyGetPool(_rpmrubyPool);
  @@ -64,7 +69,10 @@
   
   #if defined(WITH_RUBY)
       ruby_init();
  +    ruby_init_loadpath();
       ruby_script("rpmruby");
  +    rb_gv_set("$result", rb_str_new2(""));
  +    (void) rpmrubyRun(ruby, rpmrubyInitStringIO, NULL);
   #endif
   
       return rpmrubyLink(ruby);
  @@ -81,11 +89,9 @@
   #if defined(WITH_RUBY)
        rb_load_file(fn);
        ruby->state = ruby_exec();
  +     if (resultp != NULL)
  +         *resultp = RSTRING_PTR(rb_gv_get("$result"));
        rc = RPMRC_OK;
  -#ifdef       NOTYET
  -     if (resultp)
  -         *resultp = Tcl_GetStringResult(ruby->I);
  -#endif
   #endif
       }
       return rc;
  @@ -96,16 +102,14 @@
       rpmRC rc = RPMRC_FAIL;
   
   if (_rpmruby_debug)
  -fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, ruby, str);
  +fprintf(stderr, "==> %s(%p,%s,%p)\n", __FUNCTION__, ruby, str, resultp);
   
       if (str != NULL) {
   #if defined(WITH_RUBY)
        ruby->state = rb_eval_string(str);
  +     if (resultp != NULL)
  +         *resultp = RSTRING_PTR(rb_gv_get("$result"));
        rc = RPMRC_OK;
  -#ifdef       NOTYET
  -     if (resultp)
  -         *resultp = Tcl_GetStringResult(ruby->I);
  -#endif
   #endif
       }
       return rc;
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to