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:   24-Jun-2017 22:47:34
  Branch: rpm-5_4                          Handle: 2017062420473400

  Modified files:           (Branch: rpm-5_4)
    rpm/rpmio               Makefile.am rpmjs185.cpp

  Log:
    - orphan.

  Summary:
    Revision    Changes     Path
    1.293.2.100 +1  -1      rpm/rpmio/Makefile.am
    1.1.2.7     +50 -6      rpm/rpmio/rpmjs185.cpp
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.293.2.99 -r1.293.2.100 Makefile.am
  --- rpm/rpmio/Makefile.am     24 Jun 2017 20:32:04 -0000      1.293.2.99
  +++ rpm/rpmio/Makefile.am     24 Jun 2017 20:47:34 -0000      1.293.2.100
  @@ -552,7 +552,7 @@
   
   rpmjs185_SOURCES = rpmjs185.cpp
   rpmjs185_CPPFLAGS = -DXP_UNIX=1 -DJS_THREADSAFE=1 -I/usr/include/js -fPIC 
-DRPMJSS_SELF_TEST
  -rpmjs185_LDADD = -L/usr/lib64 -ljs
  +rpmjs185_LDADD = -L/usr/lib64 -ljs $(RPMIO_LDADD_COMMON)
   
   rpmjs17_SOURCES = rpmjs17.cpp
   rpmjs17_CPPFLAGS = -include /usr/include/js-17.0/js/RequiredDefines.h 
-I/usr/include/js-17.0 -fPIC -DRPMJSS_SELF_TEST
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs185.cpp
  ============================================================================
  $ cvs diff -u -r1.1.2.6 -r1.1.2.7 rpmjs185.cpp
  --- rpm/rpmio/rpmjs185.cpp    24 Jun 2017 19:09:35 -0000      1.1.2.6
  +++ rpm/rpmio/rpmjs185.cpp    24 Jun 2017 20:47:34 -0000      1.1.2.7
  @@ -493,8 +493,40 @@
        if (!ok)
            return 1;
       }
  -    JSString *str = JS_ValueToString(I->cx, rval);
  -    char * t = JS_EncodeString(I->cx, str);
  +
  +    char b[128];
  +    size_t nb = sizeof(b);
  +    char * t = NULL;
  +
  +    if (JSVAL_IS_NULL(rval)) {
  +     t = xstrdup("");
  +    } else
  +    if (JSVAL_IS_VOID(rval)) {
  +     t = xstrdup("");
  +    } else
  +    if (JSVAL_IS_BOOLEAN(rval)) {
  +     snprintf(b, nb, "%c", (JSVAL_TO_BOOLEAN(rval) ? 'T' : 'F'));
  +     t = xstrdup(b);
  +    } else
  +    if (JSVAL_IS_INT(rval)) {        /* int32_t */
  +     snprintf(b, nb, "%d", JSVAL_TO_INT(rval));
  +     t = xstrdup(b);
  +    } else
  +    if (JSVAL_IS_DOUBLE(rval)) {
  +     snprintf(b, nb, "%.16g", JSVAL_TO_DOUBLE(rval));
  +     t = xstrdup(b);
  +    } else
  +#ifdef       FIXME
  +    if (JSVAL_IS_NUMBER(rval)) {
  +     snprintf(b, nb, "%.16g", JSVAL_TO_NUMBER(rval));
  +     t = xstrdup(b);
  +    } else
  +#endif
  +    if (JSVAL_IS_STRING(rval)) {
  +     t = JS_EncodeString(I->cx, JSVAL_TO_STRING(rval));
  +    } else
  +     t = xstrdup("");
  +
       if (resultp)
        *resultp = t;
       else
  @@ -507,6 +539,9 @@
   JSIO_t mozjs185 = &_mozjs185;
   
   #if defined(RPMJSS_SELF_TEST)
  +#include <rpmio.h>
  +#include <argv.h>
  +
   struct rpmjss_s _jss;
   rpmjss jss = &_jss;
   
  @@ -518,14 +553,23 @@
       JSI_t I = (JSI_t) mozInit(jss);
       jss->I = I;
   
  -    {
  -     const char *script = "'hello'+'world, it is '+new Date()";
  +    const char * _fn = "rpmjss.inp";
  +    FD_t fd = Fopen(_fn, "r.fpio");
  +    ARGV_t av = NULL;
  +    rc = argvFgets(&av, fd, 0);
  +    rc = Fclose(fd);
  +    int ac = argvCount(av);
  +
  +    for (int i = 0; i < ac; i++) {
  +     const char *script = av[i];
        const char * result = NULL;
  -     rc = mozRun(jss, &result, script, __FILE__, __LINE__);
  -     fprintf(stderr, "<== result |%s|\n", result);
  +     rc = mozRun(jss, &result, script, _fn, i);
  +     fprintf(stderr, "<== result |%s| from |%s|\n", result, script);
        result = _free(result);
       }
   
  +    av = argvFree(av);
  +
       mozFini(jss);
   
       return rc;
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to