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:   19-Jun-2017 23:18:03
  Branch: rpm-5_4                          Handle: 2017061921180300

  Modified files:           (Branch: rpm-5_4)
    rpm/rpmio               teio.c

  Log:
    - rpmeio: haul out a load of trash.

  Summary:
    Revision    Changes     Path
    1.1.2.8     +60 -223    rpm/rpmio/teio.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/teio.c
  ============================================================================
  $ cvs diff -u -r1.1.2.7 -r1.1.2.8 teio.c
  --- rpm/rpmio/teio.c  19 Jun 2017 02:30:01 -0000      1.1.2.7
  +++ rpm/rpmio/teio.c  19 Jun 2017 21:18:03 -0000      1.1.2.8
  @@ -23,7 +23,7 @@
   
   #include "debug.h"
   
  -static int _debug = -1;
  +static int _debug = 0;
   
   #define SPEW(_fmt, ...) \
       if (_debug || _rpmeio_debug || _rpmio_debug) \
  @@ -1006,6 +1006,11 @@
       char *te = wrap->b;
   
       if (fp == NULL)  fp = stderr;
  +
  +    *te++ = '\n';
  +    te = stpcpy(stpcpy(te, "/* ========= "), wrap->subname);
  +    *te++ = '\n';
  +
       te += sprintf(te, "    case EIO_%s:\n", wrap->subname);
       for (int i = 0; wrap->argtypes[i]; i++) {
        const char * argtype = wrap->argtypes[i];
  @@ -1106,171 +1111,42 @@
        }
       }
       te += sprintf(te, "\tbreak;\n");
  -    *te = '\0';
  -
  -fprintf(fp, "%s", wrap->b);
  -
  -}
  -
  -static const char *wrapArgFormat(rpmwrap wrap, const char * argtype)
  -{
  -    if (!strcmp(argtype, "void"))
  -     return "";
  -    if (!strcmp(argtype, "..."))
  -     return "...";
  -
  -    if (strchr(argtype, '*') || strchr(argtype, '['))
  -     return "%p";
  -
  -    if (strstr(argtype, "caddr_t")
  -     || strstr(argtype, "timer_t")
  -     || strstr(argtype, "cap_user_data_t")
  -     || strstr(argtype, "cap_user_header_t")
  -     || !strcmp(argtype, "eio_wd")
  -     || !strcmp(argtype, "eio_req"))
  -     return "%p";
  -
  -    if (!strcmp(argtype, "int")
  -     || !strcmp(argtype, "int32_t"))
  -     return "%d";
  -
  -    if (!strcmp(argtype, "unsigned")
  -     || !strcmp(argtype, "uint32_t")
  -     || !strcmp(argtype, "uid_t")
  -     || !strcmp(argtype, "gid_t")
  -     || !strcmp(argtype, "pid_t")
  -     || !strcmp(argtype, "id_t"))
  -     return "%u";
  -
  -    if (!strcmp(argtype, "mode_t"))
  -     return "0%o";
  -
  -    if (!strcmp(argtype, "mqd_t")
  -     || !strcmp(argtype, "key_serial_t")
  -     || !strcmp(argtype, "key_t")
  -     || !strcmp(argtype, "dev_t")
  -     || !strcmp(argtype, "socklen_t")
  -     || !strcmp(argtype, "clockid_t")
  -     ||  strstr(argtype, "enum "))
  -     return "0x%x";
  -
  -    if (!strcmp(argtype, "off_t"))
  -     return "0x%lx";
  -
  -    if (!strcmp(argtype, "ssize_t"))
  -     return "%zd";
  -    if (!strcmp(argtype, "size_t"))
  -     return "%zu";
  -
  -    if (!strcmp(argtype, "double"))
  -     return "%f";
  -
  -    if (!strcmp(argtype, "struct timeval")
  -     || !strcmp(argtype, "struct timespec"))
  -     return "%f";
  -
  -    if (!strcmp(argtype, "long"))
  -     return "%ld";
  -
  -    if (!strcmp(argtype, "unsigned long"))
  -     return "%lu";
  -
  -    if (!strcmp(argtype, "nfds_t"))
  -     return "%lu";
  -
  -    if (!strcmp(argtype, "aio_context_t"))
  -     return "0x%lx";
  -
  -    if (!strcmp(argtype, "long long")
  -     || !strcmp(argtype, "int64_t"))
  -     return "%lld";
  -
  -    if (!strcmp(argtype, "off64_t"))
  -     return "0x%llx";
  -
  -    if (!strcmp(argtype, "unsigned long long")
  -     || !strcmp(argtype, "uint64_t")
  -     || !strcmp(argtype, "u64"))
  -     return "%llu";
   
  -    return "???";
  -}
  +    te = stpcpy(te, "*/");
  +    *te++ = '\n';
   
  -static void wrapPrint(rpmwrap wrap, FILE * fp)
  -{
  -    char *te = wrap->b;
  -    int nargs = argvCount(wrap->argtypes);
  -
  -    if (fp == NULL)  fp = stderr;
  -
  -    te = stpcpy(te, wrap->subtype);
  -    *te++ = ' ';
  -    *te++ = toupper(*wrap->subname);
  -    te = stpcpy(te, wrap->subname+1);
  -
  -    *te++ = '(';
  -    for (int i = 0; i < nargs; i++) {
  -     const char * argtype = wrap->argtypes[i];
  -     const char * argname = wrap->argnames[i];
  -     if (i > 0) te = stpcpy(te, ", ");
  -     te = stpcpy(te, argtype);
  -     *te++ = ' ';
  -     te = stpcpy(te, argname);
  -    }
  -    te = stpcpy(te, ")\n");
  -    te = stpcpy(te, "{\n");
  -
  -    te = stpcpy(te, "    ");
  -
  -    if (strcmp(wrap->subtype, "void")) {
  -     te = stpcpy(te, wrap->subtype);
  -     te = stpcpy(te, " rc = ");
  -    }
  -
  -    te = stpcpy(te, wrap->subname);
  -    *te++ = '(';
  -    for (int i = 0; i < nargs; i++) {
  -     const char * argname = wrap->argnames[i];
  -     if (i > 0) te = stpcpy(te, ", ");
  -     te = stpcpy(te, argname);
  -    }
  -    te = stpcpy(te, ");\n");
  -
  -    te = stpcpy(te, "SPEW(\"<-- %s(");
  -    for (int i = 0; i < nargs; i++) {
  -     const char * argtype = wrap->argtypes[i];
  -     if (i > 0) te = stpcpy(te, ", ");
  -     te = stpcpy(te, wrapArgFormat(wrap, argtype));
  -    }
  -    *te++ = ')';
  -    if (strcmp(wrap->subtype, "void")) {
  -     te = stpcpy(te, " rc ");
  -     te = stpcpy(te, wrapArgFormat(wrap, wrap->subtype));
  -    }
  -    te = stpcpy(te, "\\n\", __FUNCTION__");
  -    for (int i = 0; i < nargs; i++) {
  -     const char * argtype = wrap->argtypes[i];
  -     if (!strcmp(argtype, "void"))
  -         continue;
  -     const char * argname = wrap->argnames[i];
  -     if (*argname == '\0')
  -         continue;
  -     te = stpcpy(te, ", ");
  -     te = stpcpy(te, argname);
  -    }
  -    if (strcmp(wrap->subtype, "void")) {
  -     te = stpcpy(te, ", rc");
  -     te = stpcpy(te, ");\n");
  -     te = stpcpy(te, "    return rc\n");
  -    } else
  -     te = stpcpy(te, ");\n");
  -
  -    te = stpcpy(te, "}\n");
  +    *te = '\0';
   
   fprintf(fp, "%s", wrap->b);
   
   }
   
  +static char wrapSedArgs[] =
  +    " -e s/[^,]*\\\\*[^,]*/%p/g"
  +    " -e s/[^,]*\\\\][^,]*/%p/g"
  +    " -e s/[^,]*enum\\\\s[^,]*,/0x%x/g"
  +    " -e s/[^,]*void//g"
  +    " -e 
s/[^,]*(caddr_t|timer_t|cap_user_data_t|cap_user_header_t|eio_wd|eio_req)/%p/g"
  +    " -e s/[^,]*off64_t/0x%llx/g"
  +    " -e s/[^,]*nfds_t/%lu/g"
  +    " -e s/[^,]*off_t/0x%lx/g"
  +    " -e s/[^,]*aio_context_t/0x%lx/g"
  +    " -e s/[^,]*(mqd_t|key_serial_t|key_t|dev_t|socklen_t|clockid_t)/0x%x/g"
  +    " -e s/[^,]*(uid_t|gid_t|pid_t|id_t)/%u/g"
  +    " -e s/[^,]*mode_t/0%o/g"
  +    " -e s/[^,]*ssize_t/%zd/g"
  +    " -e s/[^,]*size_t/%zu/g"
  +    " -e s/[^,]*double/%f/g"
  +    " -e s/[^,]*struct\\\\s(timeval|timespec)/%f/g"
  +
  +    " -e s/[^,]*(u64|uint64_t|unsigned\\\\slong\\\\slong)/%lu/g"
  +    " -e s/[^,]*(i64|int64_t|long\\\\slong)/%ld/g"
  +    " -e s/[^,]*(unsigned\\\\slong)/%lu/g"
  +    " -e s/[^,]*(long)/%ld/g"
  +    " -e s/[^,]*(u32|u16|u8|uint32_t|uint16_t|uint8_t|unsigned)/%u/g"
  +    " -e s/[^,]*(i32|i16|i8|int32_t|int16_t|int8_t|int)/%d/g"
  +    ;
  +
   static void wrapExpand(rpmwrap wrap, FILE * fp)
   {
       char *te = wrap->b;
  @@ -1286,31 +1162,7 @@
       xstr = rpmMCExpand(wrap->mc, "%{?Subtype}", NULL);
     if (xstr && *xstr) {
       fmt = rpmMCExpand(wrap->mc,
  -             "%{sed",
  -    " -e s/[^,]*\\\\*[^,]*/%p/g",
  -    " -e s/[^,]*\\\\][^,]*/%p/g",
  -    " -e s/[^,]*enum\\\\s[^,]*,/0x%x/g",
  -    " -e s/[^,]*void//g",
  -    " -e 
s/[^,]*(caddr_t|timer_t|cap_user_data_t|cap_user_header_t|eio_wd|eio_req)/%p/g"
  -    " -e s/[^,]*off64_t/0x%llx/g", 
  -    " -e s/[^,]*nfds_t/%lu/g",
  -    " -e s/[^,]*off_t/0x%lx/g",
  -    " -e s/[^,]*aio_context_t/0x%lx/g",
  -    " -e s/[^,]*(mqd_t|key_serial_t|key_t|dev_t|socklen_t|clockid_t)/0x%x/g",
  -    " -e s/[^,]*(uid_t|gid_t|pid_t|id_t)/%u/g",
  -    " -e s/[^,]*mode_t/0%o/g",
  -    " -e s/[^,]*ssize_t/%zd/g",
  -    " -e s/[^,]*size_t/%zu/g",
  -    " -e s/[^,]*double/%f/g",
  -    " -e s/[^,]*struct\\\\s(timeval|timespec)/%f/g",
  -
  -    " -e s/[^,]*(u64|uint64_t|unsigned\\\\slong\\\\slong)/%lu/g",
  -    " -e s/[^,]*(i64|int64_t|long\\\\slong)/%ld/g",
  -    " -e s/[^,]*(unsigned\\\\slong)/%lu/g",
  -    " -e s/[^,]*(long)/%ld/g",
  -    " -e s/[^,]*(u32|u16|u8|uint32_t|uint16_t|uint8_t|unsigned)/%u/g",
  -    " -e s/[^,]*(i32|i16|i8|int32_t|int16_t|int8_t|int)/%d/g",
  -             ":", xstr, "}",
  +             "%{sed", wrapSedArgs, ":", xstr, "}",
                NULL);
   if (fmt && *fmt)
   addMacro(wrap->mc, "Subtypefmt", NULL, fmt, 0);
  @@ -1320,49 +1172,31 @@
   
       xstr = rpmMCExpand(wrap->mc, "%{@argtypes:,}", NULL);
       fmt = rpmMCExpand(wrap->mc,
  -             "%{sed",
  -    " -e s/[^,]*\\\\*[^,]*/%p/g",
  -    " -e s/[^,]*\\\\][^,]*/%p/g",
  -    " -e s/[^,]*enum\\\\s[^,]*,/0x%x/g",
  -    " -e s/[^,]*void//g",
  -    " -e 
s/[^,]*(caddr_t|timer_t|cap_user_data_t|cap_user_header_t|eio_wd|eio_req)/%p/g"
  -    " -e s/[^,]*off64_t/0x%llx/g", 
  -    " -e s/[^,]*nfds_t/%lu/g",
  -    " -e s/[^,]*off_t/0x%lx/g",
  -    " -e s/[^,]*aio_context_t/0x%lx/g",
  -    " -e s/[^,]*(mqd_t|key_serial_t|key_t|dev_t|socklen_t|clockid_t)/0x%x/g",
  -    " -e s/[^,]*(uid_t|gid_t|pid_t|id_t)/%u/g",
  -    " -e s/[^,]*mode_t/0%o/g",
  -    " -e s/[^,]*ssize_t/%zd/g",
  -    " -e s/[^,]*size_t/%zu/g",
  -    " -e s/[^,]*double/%f/g",
  -    " -e s/[^,]*struct\\\\s(timeval|timespec)/%f/g",
  -
  -    " -e s/[^,]*(u64|uint64_t|unsigned\\\\slong\\\\slong)/%lu/g",
  -    " -e s/[^,]*(i64|int64_t|long\\\\slong)/%ld/g",
  -    " -e s/[^,]*(unsigned\\\\slong)/%lu/g",
  -    " -e s/[^,]*(long)/%ld/g",
  -    " -e s/[^,]*(u32|u16|u8|uint32_t|uint16_t|uint8_t|unsigned)/%u/g",
  -    " -e s/[^,]*(i32|i16|i8|int32_t|int16_t|int8_t|int)/%d/g",
  -             ":", xstr, "}",
  +             "%{sed", wrapSedArgs, ":", xstr, "}",
                NULL);
   addMacro(wrap->mc, "argsfmt", NULL, fmt, 0);
       xstr = _free(xstr);
       fmt = _free(fmt);
   
  -    msg = rpmMCExpand(wrap->mc,
  -#ifdef       DYING
  -             "   items: %{@items:, }\n",
  -             "argtypes: %{@argtypes:, }\n",
  -             "argnames: %{@argnames:, }\n",
  -#endif       /* DYING */
  -             "**  init: %{subtype} %{Subname}(%{arglist}) {\n",
  -             "** enter:     %{?Subtype:%{subtype} rc;}\n",
  -             "**  call:     %{?Subtype:rc = }%{subname}(%{@argnames:, });\n",
  -             "**  spew: SPEW(\"<-- %s(%{argsfmt})%{?Subtype: rc 
%{Subtypefmt}}\\n\", __FUNCTION__, %{@argnames:, }%{?Subtype:, rc});\n",
  -             "**  exit:     %{?Subtype:return rc;}\n",
  -             "**  fini: }\n",
  -             NULL);
  +addMacro(wrap->mc, "init",  NULL, "%{subtype} %{Subname}(%{arglist})", 0);
  +addMacro(wrap->mc, "enter", NULL, "%{?Subtype:%{subtype} rc;}", 0);
  +addMacro(wrap->mc, "call",  NULL, "%{?Subtype:rc = }%{subname}(%{@argnames:, 
});", 0);
  +addMacro(wrap->mc, "spew",  NULL, "SPEW(\"<-- %s(%{argsfmt})%{?Subtype: rc 
%{Subtypefmt}}\\n\", __FUNCTION__, %{@argnames:, }%{?Subtype:, rc});", 0);
  +addMacro(wrap->mc, "exit",  NULL, "%{?Subtype:return rc;}",0);
  +addMacro(wrap->mc, "wrapper",  NULL,
  +"\n\
  +%{init};\n\
  +%{init}\n\
  +{\n\
  +    %{?enter}\n\
  +    %{?pre}\n\
  +    %{?call}\n\
  +    %{?post}\n\
  +%{?spew}\n\
  +    %{?exit}\n\
  +}", 0);
  +
  +    msg = rpmMCExpand(wrap->mc, "%{wrapper}\n", NULL);
   fprintf(fp, "%s", msg);
       msg = _free(msg);
   }
  @@ -1456,12 +1290,15 @@
        proto = _free(proto);
   
   wrapAnalyze(wrap, NULL);
  +
  +if (_debug)
   wrapDump(__FUNCTION__, wrap, NULL);
   
  -wrapPrint(wrap, NULL);
   wrapExpand(wrap, NULL);
   
  +if (_debug)
   rpmDumpMacroTable(wrap->mc, NULL);
  +
   wrapFree(wrap);
   
       }
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to