lib/macro.c: Create rpmCleanPath().
authorjbj <devnull@localhost>
Fri, 26 Nov 1999 16:19:30 +0000 (16:19 +0000)
committerjbj <devnull@localhost>
Fri, 26 Nov 1999 16:19:30 +0000 (16:19 +0000)
build/misc.c: Delete cleanFileName().

CVS patchset: 3435
CVS date: 1999/11/26 16:19:30

build/misc.c
build/rpmbuild.h
lib/macro.c
lib/rpminstall.c
lib/rpmmacro.h
po/rpm.pot
rpmio/macro.c
rpmio/rpmmacro.h

index 7e99e34..f7de2e3 100644 (file)
@@ -14,28 +14,3 @@ int parseNum(const char *line, int *res)
 
     return 0;
 }
-
-const char *cleanFileName(const char *name)
-{
-    static char res[BUFSIZ];   /* XXX yuk */
-    char *copyTo, copied;
-    const char *copyFrom;
-
-    /* Copy to fileName, eliminate duplicate "/" and trailing "/" */
-    copyTo = res;
-    copied = '\0';
-    copyFrom = name;
-    while (*copyFrom) {
-       if (*copyFrom != '/' || copied != '/') {
-           *copyTo++ = copied = *copyFrom;
-       }
-       copyFrom++;
-    }
-    *copyTo = '\0';
-    copyTo--;
-    if ((copyTo != res) && (*copyTo == '/')) {
-       *copyTo = '\0';
-    }
-
-    return res;
-}
index 5b5908c..8d574d2 100644 (file)
@@ -95,7 +95,6 @@ int isPart(char *line);
 /* from build/misc.h */
 
 int parseNum(const char *line, /*@out@*/int *res);
-/*@observer@*/ const char *cleanFileName(const char *name);
 
 /* from build/parse.h */
 
index bf8a5a4..0323f28 100644 (file)
@@ -132,7 +132,7 @@ sortMacroTable(MacroContext *mc)
 }
 
 void
-dumpMacroTable(MacroContext *mc, FILE *f)
+dumpMacroTable(MacroContext * mc, FILE * fp)
 {
        int i;
        int nempty = 0;
@@ -140,10 +140,10 @@ dumpMacroTable(MacroContext *mc, FILE *f)
 
        if (mc == NULL)
                mc = &globalMacroContext;
-       if (f == NULL)
-               f = stderr;
+       if (fp == NULL)
+               fp = stderr;
     
-       fprintf(f, "========================\n");
+       fprintf(fp, "========================\n");
        for (i = 0; i < mc->firstFree; i++) {
                MacroEntry *me;
                if ((me = mc->macroTable[i]) == NULL) {
@@ -151,16 +151,16 @@ dumpMacroTable(MacroContext *mc, FILE *f)
                        nempty++;
                        continue;
                }
-               fprintf(f, "%3d%c %s", me->level,
+               fprintf(fp, "%3d%c %s", me->level,
                        (me->used > 0 ? '=' : ':'), me->name);
                if (me->opts && *me->opts)
-                       fprintf(f, "(%s)", me->opts);
+                       fprintf(fp, "(%s)", me->opts);
                if (me->body && *me->body)
-                       fprintf(f, "\t%s", me->body);
-               fprintf(f, "\n");
+                       fprintf(fp, "\t%s", me->body);
+               fprintf(fp, "\n");
                nactive++;
        }
-       fprintf(f, _("======================== active %d empty %d\n"),
+       fprintf(fp, _("======================== active %d empty %d\n"),
                nactive, nempty);
 }
 
@@ -1462,32 +1462,14 @@ rpmExpandNumeric(const char *arg)
     return rc;
 }
 
-/* Return concatenated and expanded path with multiple /'s removed */
-const char *
-rpmGetPath(const char *path, ...)
+const char *rpmCleanPath(char * path)
 {
-    char buf[BUFSIZ], *t, *te, *se;
     const char *s;
-    va_list ap;
-
-    if (path == NULL)
-       return xstrdup("");
+    char *se, *t, *te;
 
-    t = buf;
-    te = stpcpy(t, path);
-    *te = '\0';
-
-    va_start(ap, path);
-    while ((s = va_arg(ap, const char *)) != NULL) {
-       te = stpcpy(te, s);
-       *te = '\0';
-    }
-    va_end(ap);
-    expandMacros(NULL, NULL, buf, sizeof(buf));
-
-    s = t = te = buf;
+    s = t = te = path;
     while (*s) {
-/*fprintf(stderr, "*** got \"%.*s\"\trest \"%s\"\n", (t-buf), buf, s); */
+/*fprintf(stderr, "*** got \"%.*s\"\trest \"%s\"\n", (t-path), path, s); */
        switch(*s) {
        case ':':                       /* handle url's */
            if (s[1] == '/' && s[2] == '/') {
@@ -1501,37 +1483,37 @@ rpmGetPath(const char *path, ...)
                ;
            if (se < t && *se == '/') {
                te = se;
-/*fprintf(stderr, "*** next pdir \"%.*s\"\n", (te-buf), buf); */
+/*fprintf(stderr, "*** next pdir \"%.*s\"\n", (te-path), path); */
            }
            while (s[1] == '/')
                s++;
-           while (t > buf && t[-1] == '/')
+           while (t > path && t[-1] == '/')
                t--;
            break;
        case '.':
            /* Leading .. is special */
-           if (t == buf && s[1] == '.') {
+           if (t == path && s[1] == '.') {
                *t++ = *s++;
                break;
            }
            /* Single . is special */
-           if (t == buf && s[1] == '\0') {
+           if (t == path && s[1] == '\0') {
                break;
            }
            /* Trim leading ./ , embedded ./ , trailing /. */
-           if ((t == buf || t[-1] == '/') && (s[1] == '/' || s[1] == '\0')) {
+           if ((t == path || t[-1] == '/') && (s[1] == '/' || s[1] == '\0')) {
 /*fprintf(stderr, "*** Trim leading ./ , embedded ./ , trailing /.\n"); */
                s++;
                continue;
            }
            /* Trim embedded /../ and trailing /.. */
-           if (t > buf && t[-1] == '/' && s[1] == '.' && (s[2] == '/' || s[2] == '\0')) {
+           if (t > path && t[-1] == '/' && s[1] == '.' && (s[2] == '/' || s[2] == '\0')) {
                t = te;
                /* Move parent dir forward */
-               if (te > buf)
-                   for (--te; te > buf && *te != '/'; te--)
+               if (te > path)
+                   for (--te; te > path && *te != '/'; te--)
                        ;
-/*fprintf(stderr, "*** prev pdir \"%.*s\"\n", (te-buf), buf); */
+/*fprintf(stderr, "*** prev pdir \"%.*s\"\n", (te-path), path); */
                s++;
                s++;
                continue;
@@ -1542,12 +1524,40 @@ rpmGetPath(const char *path, ...)
        }
        *t++ = *s++;
     }
+
     /* Trim trailing / (but leave single / alone) */
-    if (t > &buf[1] && t[-1] == '/')
+    if (t > &path[1] && t[-1] == '/')
        t--;
     *t = '\0';
 
-    return xstrdup(buf);
+    return path;
+}
+
+/* Return concatenated and expanded canonical path. */
+const char *
+rpmGetPath(const char *path, ...)
+{
+    char buf[BUFSIZ];
+    const char * s;
+    char * t, * te;
+    va_list ap;
+
+    if (path == NULL)
+       return xstrdup("");
+
+    t = buf;
+    te = stpcpy(t, path);
+    *te = '\0';
+
+    va_start(ap, path);
+    while ((s = va_arg(ap, const char *)) != NULL) {
+       te = stpcpy(te, s);
+       *te = '\0';
+    }
+    va_end(ap);
+    expandMacros(NULL, NULL, buf, sizeof(buf));
+
+    return xstrdup( rpmCleanPath(buf) );
 }
 
 /* Merge 3 args into path, any or all of which may be a url. */
index e717784..18cd2bc 100644 (file)
@@ -90,13 +90,14 @@ static void * showProgress(const Header h, const rpmCallbackType what,
 
 int rpmInstall(const char * rootdir, const char ** argv, int transFlags, 
              int interfaceFlags, int probFilter, 
-             rpmRelocation * relocations) {
+             rpmRelocation * relocations)
+{
     rpmdb db = NULL;
     FD_t fd;
     int i;
     int mode, rc, major;
-    const char ** packages, ** tmpPackages;
-    const char ** filename;
+    const char ** pkgURL, ** tmppkgURL;
+    const char ** fileURL;
     int numPackages;
     int numTmpPackages = 0, numBinaryPackages = 0, numSourcePackages = 0;
     int numFailed = 0;
@@ -108,7 +109,7 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
     size_t nb;
     int notifyFlags = interfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 );
     int dbIsOpen = 0;
-    const char ** sourcePackages;
+    const char ** sourceURL;
     rpmRelocation * defaultReloc;
 
     if (transFlags & RPMTRANS_FLAG_TEST) 
@@ -121,31 +122,31 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
     if (defaultReloc && !defaultReloc->newPath) defaultReloc = NULL;
 
     rpmMessage(RPMMESS_DEBUG, _("counting packages to install\n"));
-    for (filename = argv, numPackages = 0; *filename; filename++, numPackages++)
+    for (fileURL = argv, numPackages = 0; *fileURL; fileURL++, numPackages++)
        ;
 
     rpmMessage(RPMMESS_DEBUG, _("found %d packages\n"), numPackages);
 
     nb = (numPackages + 1) * sizeof(char *);
-    packages = alloca(nb);
-    memset(packages, 0, nb);
-    tmpPackages = alloca(nb);
-    memset(tmpPackages, 0, nb);
+    pkgURL = alloca(nb);
+    memset(pkgURL, 0, nb);
+    tmppkgURL = alloca(nb);
+    memset(tmppkgURL, 0, nb);
     nb = (numPackages + 1) * sizeof(Header);
 
     rpmMessage(RPMMESS_DEBUG, _("looking for packages to download\n"));
-    for (filename = argv, i = 0; *filename; filename++) {
+    for (fileURL = argv, i = 0; *fileURL; fileURL++) {
 
-       switch (urlIsURL(*filename)) {
+       switch (urlIsURL(*fileURL)) {
        case URL_IS_FTP:
        case URL_IS_HTTP:
-       case URL_IS_PATH:
        {   int myrc;
            const char *tfn;
 
            if (rpmIsVerbose())
-               fprintf(stdout, _("Retrieving %s\n"), *filename);
+               fprintf(stdout, _("Retrieving %s\n"), *fileURL);
 
+#ifdef DYING
            {   char tfnbuf[64];
                const char * tempfn;
                strcpy(tfnbuf, "rpm-xfer.XXXXXX");
@@ -168,29 +169,36 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
                    break;
                }
            }
+#else
+           {   char tfnbuf[64];
+               strcpy(tfnbuf, "rpm-xfer.XXXXXX");
+               tfn = rpmGenPath(rootdir, "%{_tmppath}/", mktemp(tfnbuf));
+           }
+#endif
 
            /* XXX undefined %{name}/%{version}/%{release} here */
            /* XXX %{_tmpdir} does not exist */
            rpmMessage(RPMMESS_DEBUG, _(" ... as %s\n"), tfn);
-           myrc = urlGetFile(*filename, tfn);
+           myrc = urlGetFile(*fileURL, tfn);
            if (myrc < 0) {
                rpmMessage(RPMMESS_ERROR, 
                        _("skipping %s - transfer failed - %s\n"), 
-                       *filename, ftpStrerror(myrc));
+                       *fileURL, ftpStrerror(myrc));
                numFailed++;
-               packages[i] = NULL;
+               pkgURL[i] = NULL;
                xfree(tfn);
            } else {
-               tmpPackages[numTmpPackages++] = packages[i++] = tfn;
+               tmppkgURL[numTmpPackages++] = pkgURL[i++] = tfn;
            }
        }   break;
+       case URL_IS_PATH:
        default:
-           packages[i++] = *filename;
+           pkgURL[i++] = *fileURL;
            break;
        }
     }
 
-    sourcePackages = alloca(sizeof(*sourcePackages) * i);
+    sourceURL = alloca(sizeof(*sourceURL) * i);
 
     rpmMessage(RPMMESS_DEBUG, _("retrieved %d packages\n"), numTmpPackages);
 
@@ -198,13 +206,15 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
        are installed right here, only because they don't have headers and
        would create all sorts of confusion later. */
 
-    for (filename = packages; *filename; filename++) {
-       fd = Fopen(*filename, "r.ufdio");
+    for (fileURL = pkgURL; *fileURL; fileURL++) {
+       const char * fileName;
+       (void) urlPath(*fileURL, &fileName);
+       fd = Fopen(*fileURL, "r.ufdio");
        if (Ferror(fd)) {
-           rpmMessage(RPMMESS_ERROR, _("cannot open file %s: %s\n"), *filename,
+           rpmMessage(RPMMESS_ERROR, _("cannot open file %s: %s\n"), *fileURL,
                Fstrerror(fd));
            numFailed++;
-           packages[i] = NULL;
+           pkgURL[i] = NULL;
            continue;
        }
 
@@ -215,16 +225,16 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
            Fclose(fd);
            rpmMessage(RPMMESS_ERROR, 
                        _("%s does not appear to be a RPM package\n"), 
-                       *filename);
+                       *fileURL);
            break;
        default:
-           rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), *filename);
+           rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), *fileURL);
            numFailed++;
-           packages[i] = NULL;
+           pkgURL[i] = NULL;
            break;
        case 0:
            if (isSource) {
-               sourcePackages[numSourcePackages++] = *filename;
+               sourceURL[numSourcePackages++] = fileName;
                Fclose(fd);
            } else {
                if (!dbIsOpen) {
@@ -260,7 +270,7 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
                    }
                }
 
-               rc = rpmtransAddPackage(rpmdep, h, NULL, *filename,
+               rc = rpmtransAddPackage(rpmdep, h, NULL, fileName,
                               (interfaceFlags & INSTALL_UPGRADE) != 0,
                               relocations);
 
@@ -272,13 +282,13 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
                        break;
                case 1:
                        rpmMessage(RPMMESS_ERROR, 
-                           _("error reading from file %s\n"), *filename);
+                           _("error reading from file %s\n"), *fileURL);
                        return numPackages;
                        /*@notreached@*/ break;
                case 2:
                        rpmMessage(RPMMESS_ERROR, 
                            _("file %s requires a newer version of RPM\n"),
-                           *filename);
+                           *fileURL);
                        return numPackages;
                        /*@notreached@*/ break;
                }
@@ -341,10 +351,10 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
 
     if (numSourcePackages && !stopInstall) {
        for (i = 0; i < numSourcePackages; i++) {
-           fd = Fopen(sourcePackages[i], "r.ufdio");
+           fd = Fopen(sourceURL[i], "r.ufdio");
            if (Ferror(fd)) {
                rpmMessage(RPMMESS_ERROR, _("cannot open file %s: %s\n"), 
-                          sourcePackages[i], Fstrerror(fd));
+                          sourceURL[i], Fstrerror(fd));
                continue;
            }
 
@@ -357,8 +367,8 @@ int rpmInstall(const char * rootdir, const char ** argv, int transFlags,
     }
 
     for (i = 0; i < numTmpPackages; i++) {
-       unlink(tmpPackages[i]);
-       xfree(tmpPackages[i]);
+       Unlink(tmppkgURL[i]);
+       xfree(tmppkgURL[i]);
     }
 
     /* FIXME how do we close our various fd's? */
index a1d0386..9ad1e5d 100644 (file)
@@ -33,28 +33,32 @@ typedef /*@abstract@*/ struct MacroContext {
 extern "C" {
 #endif
 
-void   dumpMacroTable  (MacroContext *mc, FILE *f);
+void   dumpMacroTable  (MacroContext * mc, FILE * fp);
 
 /* XXX this is used only in build/expression.c and will go away. */
 const char *getMacroBody (MacroContext *mc, const char *name);
 
-int    expandMacros    (void *spec, MacroContext *mc, char *sbuf, size_t sbuflen);
-void   addMacro        (MacroContext *mc, const char *n, const char *o, const char *b, int depth);
-void   delMacro        (MacroContext *mc, const char *n);
+int    expandMacros    (void * spec, MacroContext * mc, char * sbuf,
+                               size_t sbuflen);
+void   addMacro        (MacroContext * mc, const char * n, const char * o,
+                               const char * b, int depth);
+void   delMacro        (MacroContext * mc, const char * n);
 
-int    rpmDefineMacro  (MacroContext *mc, const char *macro, int level);
-void   initMacros      (MacroContext *mc, const char *macrofile);
-void   freeMacros      (MacroContext *mc);
+int    rpmDefineMacro  (MacroContext * mc, const char * macro, int level);
+void   initMacros      (MacroContext * mc, const char * macrofile);
+void   freeMacros      (MacroContext * mc);
 
 #define COMPRESSED_NOT   0
 #define COMPRESSED_OTHER 1
 #define COMPRESSED_BZIP2 2
-int    isCompressed    (const char *file, int *compressed);
+int    isCompressed    (const char * file, int * compressed);
 
-char * rpmExpand       (const char *arg, ...);
-const char *rpmGetPath (const char *path, ...);
-const char *rpmGenPath (const char *root, const char *mdir, const char *file);
-int    rpmExpandNumeric (const char *arg);
+char * rpmExpand       (const char * arg, ...);
+const char *rpmCleanPath(char * path);
+const char *rpmGetPath (const char * path, ...);
+const char *rpmGenPath (const char * root, const char * mdir,
+                               const char * file);
+int    rpmExpandNumeric (const char * arg);
 
 #ifdef __cplusplus
 }
index 0c9c023..5ebf7d9 100644 (file)
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-11-24 11:06-0500\n"
+"POT-Creation-Date: 1999-11-24 13:35-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -14,7 +14,7 @@ msgstr ""
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: ENCODING\n"
 
-#: build.c:25 lib/rpminstall.c:236 lib/rpminstall.c:396
+#: build.c:25 lib/rpminstall.c:246 lib/rpminstall.c:406
 #, c-format
 msgid "cannot open %s/packages.rpm\n"
 msgstr ""
@@ -1938,41 +1938,41 @@ msgstr ""
 msgid "can't unlink %s: %s\n"
 msgstr ""
 
-#: lib/cpio.c:529
+#: lib/cpio.c:527
 #, c-format
 msgid "getNextHeader: %s\n"
 msgstr ""
 
-#: lib/cpio.c:996
+#: lib/cpio.c:992
 #, c-format
 msgid "(error 0x%x)"
 msgstr ""
 
-#: lib/cpio.c:999
+#: lib/cpio.c:995
 msgid "Bad magic"
 msgstr ""
 
-#: lib/cpio.c:1000
+#: lib/cpio.c:996
 msgid "Bad/unreadable  header"
 msgstr ""
 
-#: lib/cpio.c:1018
+#: lib/cpio.c:1014
 msgid "Header size too big"
 msgstr ""
 
-#: lib/cpio.c:1019
+#: lib/cpio.c:1015
 msgid "Unknown file type"
 msgstr ""
 
-#: lib/cpio.c:1020
+#: lib/cpio.c:1016
 msgid "Missing hard link"
 msgstr ""
 
-#: lib/cpio.c:1021
+#: lib/cpio.c:1017
 msgid "Internal error"
 msgstr ""
 
-#: lib/cpio.c:1030
+#: lib/cpio.c:1026
 msgid " failed - "
 msgstr ""
 
@@ -2547,7 +2547,7 @@ msgstr ""
 msgid "old format source packages cannot be queried\n"
 msgstr ""
 
-#: lib/query.c:495 lib/rpminstall.c:217
+#: lib/query.c:495 lib/rpminstall.c:227
 #, c-format
 msgid "%s does not appear to be a RPM package\n"
 msgstr ""
@@ -2611,7 +2611,7 @@ msgstr ""
 msgid "record %d could not be read\n"
 msgstr ""
 
-#: lib/query.c:641 lib/rpminstall.c:407
+#: lib/query.c:641 lib/rpminstall.c:417
 #, c-format
 msgid "package %s is not installed\n"
 msgstr ""
@@ -2857,89 +2857,89 @@ msgid ""
 "database"
 msgstr ""
 
-#: lib/rpmdb.c:471
+#: lib/rpmdb.c:462
 #, c-format
 msgid "package %s not listed in %s"
 msgstr ""
 
-#: lib/rpmdb.c:482
+#: lib/rpmdb.c:473
 #, c-format
 msgid "package %s not found in %s"
 msgstr ""
 
-#: lib/rpmdb.c:506 lib/uninstall.c:86
+#: lib/rpmdb.c:497 lib/uninstall.c:86
 #, c-format
 msgid "cannot read header at %d for uninstall"
 msgstr ""
 
-#: lib/rpmdb.c:514
+#: lib/rpmdb.c:505
 msgid "package has no name"
 msgstr ""
 
-#: lib/rpmdb.c:516
+#: lib/rpmdb.c:507
 msgid "removing name index\n"
 msgstr ""
 
-#: lib/rpmdb.c:521
+#: lib/rpmdb.c:512
 msgid "package has no group\n"
 msgstr ""
 
-#: lib/rpmdb.c:523
+#: lib/rpmdb.c:514
 msgid "removing group index\n"
 msgstr ""
 
-#: lib/rpmdb.c:530
+#: lib/rpmdb.c:521
 #, c-format
 msgid "removing provides index for %s\n"
 msgstr ""
 
-#: lib/rpmdb.c:545
+#: lib/rpmdb.c:536
 #, c-format
 msgid "removing requiredby index for %s\n"
 msgstr ""
 
-#: lib/rpmdb.c:557
+#: lib/rpmdb.c:548
 #, c-format
 msgid "removing trigger index for %s\n"
 msgstr ""
 
-#: lib/rpmdb.c:568
+#: lib/rpmdb.c:559
 #, c-format
 msgid "removing conflict index for %s\n"
 msgstr ""
 
-#: lib/rpmdb.c:579
+#: lib/rpmdb.c:570
 #, c-format
 msgid "removing file index for %s\n"
 msgstr ""
 
-#: lib/rpmdb.c:588
+#: lib/rpmdb.c:579
 msgid "package has no files\n"
 msgstr ""
 
-#: lib/rpmdb.c:671
+#: lib/rpmdb.c:662
 msgid "cannot allocate space for database"
 msgstr ""
 
-#: lib/rpmdb.c:730
+#: lib/rpmdb.c:721
 #, c-format
 msgid "cannot read header at %d for update"
 msgstr ""
 
-#: lib/rpmdb.c:739
+#: lib/rpmdb.c:730
 msgid "header changed size!"
 msgstr ""
 
-#: lib/rpminstall.c:123
+#: lib/rpminstall.c:124
 msgid "counting packages to install\n"
 msgstr ""
 
-#: lib/rpminstall.c:127
+#: lib/rpminstall.c:128
 #, c-format
 msgid "found %d packages\n"
 msgstr ""
 
-#: lib/rpminstall.c:136
+#: lib/rpminstall.c:137
 msgid "looking for packages to download\n"
 msgstr ""
 
@@ -2950,79 +2950,79 @@ msgstr ""
 
 #. XXX undefined %{name}/%{version}/%{release} here
 #. XXX %{_tmpdir} does not exist
-#: lib/rpminstall.c:174
+#: lib/rpminstall.c:181
 #, c-format
 msgid " ... as %s\n"
 msgstr ""
 
-#: lib/rpminstall.c:178
+#: lib/rpminstall.c:185
 #, c-format
 msgid "skipping %s - transfer failed - %s\n"
 msgstr ""
 
-#: lib/rpminstall.c:195
+#: lib/rpminstall.c:203
 #, c-format
 msgid "retrieved %d packages\n"
 msgstr ""
 
-#: lib/rpminstall.c:204 lib/rpminstall.c:346
+#: lib/rpminstall.c:214 lib/rpminstall.c:356
 #, c-format
 msgid "cannot open file %s: %s\n"
 msgstr ""
 
-#: lib/rpminstall.c:221 lib/rpminstall.c:484
+#: lib/rpminstall.c:231 lib/rpminstall.c:494
 #, c-format
 msgid "%s cannot be installed\n"
 msgstr ""
 
-#: lib/rpminstall.c:257
+#: lib/rpminstall.c:267
 #, c-format
 msgid "package %s is not relocateable\n"
 msgstr ""
 
-#: lib/rpminstall.c:275
+#: lib/rpminstall.c:285
 #, c-format
 msgid "error reading from file %s\n"
 msgstr ""
 
-#: lib/rpminstall.c:280
+#: lib/rpminstall.c:290
 #, c-format
 msgid "file %s requires a newer version of RPM\n"
 msgstr ""
 
-#: lib/rpminstall.c:297
+#: lib/rpminstall.c:307
 #, c-format
 msgid "found %d source and %d binary packages\n"
 msgstr ""
 
-#: lib/rpminstall.c:308
+#: lib/rpminstall.c:318
 msgid "failed dependencies:\n"
 msgstr ""
 
-#: lib/rpminstall.c:326
+#: lib/rpminstall.c:336
 msgid "installing binary packages\n"
 msgstr ""
 
-#: lib/rpminstall.c:411
+#: lib/rpminstall.c:421
 #, c-format
 msgid "searching for package %s\n"
 msgstr ""
 
-#: lib/rpminstall.c:420
+#: lib/rpminstall.c:430
 #, c-format
 msgid "\"%s\" specifies multiple packages\n"
 msgstr ""
 
-#: lib/rpminstall.c:446
+#: lib/rpminstall.c:456
 msgid "removing these packages would break dependencies:\n"
 msgstr ""
 
-#: lib/rpminstall.c:473
+#: lib/rpminstall.c:483
 #, c-format
 msgid "cannot open %s: %s\n"
 msgstr ""
 
-#: lib/rpminstall.c:479
+#: lib/rpminstall.c:489
 #, c-format
 msgid "Installing %s\n"
 msgstr ""
index bf8a5a4..0323f28 100644 (file)
@@ -132,7 +132,7 @@ sortMacroTable(MacroContext *mc)
 }
 
 void
-dumpMacroTable(MacroContext *mc, FILE *f)
+dumpMacroTable(MacroContext * mc, FILE * fp)
 {
        int i;
        int nempty = 0;
@@ -140,10 +140,10 @@ dumpMacroTable(MacroContext *mc, FILE *f)
 
        if (mc == NULL)
                mc = &globalMacroContext;
-       if (f == NULL)
-               f = stderr;
+       if (fp == NULL)
+               fp = stderr;
     
-       fprintf(f, "========================\n");
+       fprintf(fp, "========================\n");
        for (i = 0; i < mc->firstFree; i++) {
                MacroEntry *me;
                if ((me = mc->macroTable[i]) == NULL) {
@@ -151,16 +151,16 @@ dumpMacroTable(MacroContext *mc, FILE *f)
                        nempty++;
                        continue;
                }
-               fprintf(f, "%3d%c %s", me->level,
+               fprintf(fp, "%3d%c %s", me->level,
                        (me->used > 0 ? '=' : ':'), me->name);
                if (me->opts && *me->opts)
-                       fprintf(f, "(%s)", me->opts);
+                       fprintf(fp, "(%s)", me->opts);
                if (me->body && *me->body)
-                       fprintf(f, "\t%s", me->body);
-               fprintf(f, "\n");
+                       fprintf(fp, "\t%s", me->body);
+               fprintf(fp, "\n");
                nactive++;
        }
-       fprintf(f, _("======================== active %d empty %d\n"),
+       fprintf(fp, _("======================== active %d empty %d\n"),
                nactive, nempty);
 }
 
@@ -1462,32 +1462,14 @@ rpmExpandNumeric(const char *arg)
     return rc;
 }
 
-/* Return concatenated and expanded path with multiple /'s removed */
-const char *
-rpmGetPath(const char *path, ...)
+const char *rpmCleanPath(char * path)
 {
-    char buf[BUFSIZ], *t, *te, *se;
     const char *s;
-    va_list ap;
-
-    if (path == NULL)
-       return xstrdup("");
+    char *se, *t, *te;
 
-    t = buf;
-    te = stpcpy(t, path);
-    *te = '\0';
-
-    va_start(ap, path);
-    while ((s = va_arg(ap, const char *)) != NULL) {
-       te = stpcpy(te, s);
-       *te = '\0';
-    }
-    va_end(ap);
-    expandMacros(NULL, NULL, buf, sizeof(buf));
-
-    s = t = te = buf;
+    s = t = te = path;
     while (*s) {
-/*fprintf(stderr, "*** got \"%.*s\"\trest \"%s\"\n", (t-buf), buf, s); */
+/*fprintf(stderr, "*** got \"%.*s\"\trest \"%s\"\n", (t-path), path, s); */
        switch(*s) {
        case ':':                       /* handle url's */
            if (s[1] == '/' && s[2] == '/') {
@@ -1501,37 +1483,37 @@ rpmGetPath(const char *path, ...)
                ;
            if (se < t && *se == '/') {
                te = se;
-/*fprintf(stderr, "*** next pdir \"%.*s\"\n", (te-buf), buf); */
+/*fprintf(stderr, "*** next pdir \"%.*s\"\n", (te-path), path); */
            }
            while (s[1] == '/')
                s++;
-           while (t > buf && t[-1] == '/')
+           while (t > path && t[-1] == '/')
                t--;
            break;
        case '.':
            /* Leading .. is special */
-           if (t == buf && s[1] == '.') {
+           if (t == path && s[1] == '.') {
                *t++ = *s++;
                break;
            }
            /* Single . is special */
-           if (t == buf && s[1] == '\0') {
+           if (t == path && s[1] == '\0') {
                break;
            }
            /* Trim leading ./ , embedded ./ , trailing /. */
-           if ((t == buf || t[-1] == '/') && (s[1] == '/' || s[1] == '\0')) {
+           if ((t == path || t[-1] == '/') && (s[1] == '/' || s[1] == '\0')) {
 /*fprintf(stderr, "*** Trim leading ./ , embedded ./ , trailing /.\n"); */
                s++;
                continue;
            }
            /* Trim embedded /../ and trailing /.. */
-           if (t > buf && t[-1] == '/' && s[1] == '.' && (s[2] == '/' || s[2] == '\0')) {
+           if (t > path && t[-1] == '/' && s[1] == '.' && (s[2] == '/' || s[2] == '\0')) {
                t = te;
                /* Move parent dir forward */
-               if (te > buf)
-                   for (--te; te > buf && *te != '/'; te--)
+               if (te > path)
+                   for (--te; te > path && *te != '/'; te--)
                        ;
-/*fprintf(stderr, "*** prev pdir \"%.*s\"\n", (te-buf), buf); */
+/*fprintf(stderr, "*** prev pdir \"%.*s\"\n", (te-path), path); */
                s++;
                s++;
                continue;
@@ -1542,12 +1524,40 @@ rpmGetPath(const char *path, ...)
        }
        *t++ = *s++;
     }
+
     /* Trim trailing / (but leave single / alone) */
-    if (t > &buf[1] && t[-1] == '/')
+    if (t > &path[1] && t[-1] == '/')
        t--;
     *t = '\0';
 
-    return xstrdup(buf);
+    return path;
+}
+
+/* Return concatenated and expanded canonical path. */
+const char *
+rpmGetPath(const char *path, ...)
+{
+    char buf[BUFSIZ];
+    const char * s;
+    char * t, * te;
+    va_list ap;
+
+    if (path == NULL)
+       return xstrdup("");
+
+    t = buf;
+    te = stpcpy(t, path);
+    *te = '\0';
+
+    va_start(ap, path);
+    while ((s = va_arg(ap, const char *)) != NULL) {
+       te = stpcpy(te, s);
+       *te = '\0';
+    }
+    va_end(ap);
+    expandMacros(NULL, NULL, buf, sizeof(buf));
+
+    return xstrdup( rpmCleanPath(buf) );
 }
 
 /* Merge 3 args into path, any or all of which may be a url. */
index a1d0386..9ad1e5d 100644 (file)
@@ -33,28 +33,32 @@ typedef /*@abstract@*/ struct MacroContext {
 extern "C" {
 #endif
 
-void   dumpMacroTable  (MacroContext *mc, FILE *f);
+void   dumpMacroTable  (MacroContext * mc, FILE * fp);
 
 /* XXX this is used only in build/expression.c and will go away. */
 const char *getMacroBody (MacroContext *mc, const char *name);
 
-int    expandMacros    (void *spec, MacroContext *mc, char *sbuf, size_t sbuflen);
-void   addMacro        (MacroContext *mc, const char *n, const char *o, const char *b, int depth);
-void   delMacro        (MacroContext *mc, const char *n);
+int    expandMacros    (void * spec, MacroContext * mc, char * sbuf,
+                               size_t sbuflen);
+void   addMacro        (MacroContext * mc, const char * n, const char * o,
+                               const char * b, int depth);
+void   delMacro        (MacroContext * mc, const char * n);
 
-int    rpmDefineMacro  (MacroContext *mc, const char *macro, int level);
-void   initMacros      (MacroContext *mc, const char *macrofile);
-void   freeMacros      (MacroContext *mc);
+int    rpmDefineMacro  (MacroContext * mc, const char * macro, int level);
+void   initMacros      (MacroContext * mc, const char * macrofile);
+void   freeMacros      (MacroContext * mc);
 
 #define COMPRESSED_NOT   0
 #define COMPRESSED_OTHER 1
 #define COMPRESSED_BZIP2 2
-int    isCompressed    (const char *file, int *compressed);
+int    isCompressed    (const char * file, int * compressed);
 
-char * rpmExpand       (const char *arg, ...);
-const char *rpmGetPath (const char *path, ...);
-const char *rpmGenPath (const char *root, const char *mdir, const char *file);
-int    rpmExpandNumeric (const char *arg);
+char * rpmExpand       (const char * arg, ...);
+const char *rpmCleanPath(char * path);
+const char *rpmGetPath (const char * path, ...);
+const char *rpmGenPath (const char * root, const char * mdir,
+                               const char * file);
+int    rpmExpandNumeric (const char * arg);
 
 #ifdef __cplusplus
 }