RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: [email protected] Module: rpm Date: 18-Jun-2017 06:49:08 Branch: rpm-5_4 Handle: 2017061804490800 Modified files: (Branch: rpm-5_4) rpm/rpmio teio.c Log: - rpmeio: WIP. Summary: Revision Changes Path 1.1.2.4 +65 -25 rpm/rpmio/teio.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/rpmio/teio.c ============================================================================ $ cvs diff -u -r1.1.2.3 -r1.1.2.4 teio.c --- rpm/rpmio/teio.c 17 Jun 2017 22:20:57 -0000 1.1.2.3 +++ rpm/rpmio/teio.c 18 Jun 2017 04:49:08 -0000 1.1.2.4 @@ -962,6 +962,7 @@ unsigned nlongs; unsigned nlonglongs; unsigned nother; + char b[BUFSIZ]; }; struct rpmwrap_s _wrap; @@ -1109,6 +1110,8 @@ if (!strcmp(argtype, "off_t")) return "0x%lx"; + if (!strcmp(argtype, "ssize_t")) + return "%zd"; if (!strcmp(argtype, "size_t")) return "%zu"; @@ -1152,45 +1155,77 @@ static void wrapPrint(rpmwrap wrap, FILE * fp) { + char *te = wrap->b; int nargs = argvCount(wrap->argtypes); if (fp == NULL) fp = stderr; - fprintf(fp, "%s %c%s(", wrap->subtype, toupper(wrap->subname[0]), wrap->subname+1); + 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) fprintf(fp, ", "); - fprintf(fp, "%s %s", argtype, argname); + if (i > 0) te = stpcpy(te, ", "); + te = stpcpy(te, argtype); + *te++ = ' '; + te = stpcpy(te, argname); } - fprintf(fp, ")\n"); - fprintf(fp, "{\n"); + te = stpcpy(te, ")\n"); + te = stpcpy(te, "{\n"); - fprintf(fp, " %s rc = ", wrap->subtype); - fprintf(fp, "%s(", wrap->subname); + 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) fprintf(fp, ", "); - fprintf(fp, "%s", argname); + if (i > 0) te = stpcpy(te, ", "); + te = stpcpy(te, argname); } - fprintf(fp, ");\n"); + te = stpcpy(te, ");\n"); - fprintf(fp, "SPEW(\"<-- %%s("); + te = stpcpy(te, "SPEW(\"<-- %s("); for (int i = 0; i < nargs; i++) { const char * argtype = wrap->argtypes[i]; - if (i > 0) fprintf(fp, ", "); - fprintf(fp, "%s", wrapArgFormat(wrap, argtype)); + 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)); } - fprintf(fp, ") rc %%d\\n\", __FUNCTION__, "); + 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 (i > 0) fprintf(fp, ", "); - fprintf(fp, "%s", argname); + if (*argname == '\0') + continue; + te = stpcpy(te, ", "); + te = stpcpy(te, argname); } - fprintf(fp, ", rc);\n"); - fprintf(fp, " return rc;\n"); - fprintf(fp, "}\n"); + 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"); + +fprintf(fp, "%s", wrap->b); + } static int spewEIO(ARGV_t av, int ac) @@ -1213,8 +1248,15 @@ wrap->arglist = xstrdup(arglist); char * subtype = proto; - t = strrchr(subtype, ' '); - if (t) + + /* XXX need to handle '**' */ + if ((t = strrchr(subtype, '*')) != NULL) { + if (t[-1] == ' ' && t[1] != ' ') { + t[-1] = '*'; + t[0] = ' '; + } + } + if ((t = strrchr(subtype, ' ')) != NULL) *t++ = '\0'; else t = proto; @@ -1229,11 +1271,8 @@ for (int i = 0; i < nitems; i++) { char * item = (char *) items[i]; + /* Trim white space. */ for (t = item; *t == ' ';) t++; -#ifdef DYING - if (!strncmp(t, "const ", sizeof("const ")-1)) - t += sizeof("const ")-1; -#endif for (te = t + strlen(t); te > t && te[-1] == ' ';) te--; item = strndup(t, (te-t)); items[i] = _free(items[i]); @@ -1248,6 +1287,7 @@ t[0] = ' '; } } + if ((t = strrchr(item, ' ')) != NULL) *t++ = '\0'; else @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository [email protected]
