The following commit has been merged in the master branch:
commit 686d2bd8ecd8f43afa211167aabecc62f9542230
Author: Guillem Jover <[email protected]>
Date: Sun Nov 8 17:34:06 2009 +0100
dpkg: Refactor filename summarizing into a new function
diff --git a/src/processarc.c b/src/processarc.c
index 5539a66..ba9cdc5 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -49,6 +49,29 @@
#include "main.h"
#include "archives.h"
+static const char *
+summarize_filename(const char *filename)
+{
+ const char *pfilename;
+ char *pfilenamebuf;
+
+ for (pfilename = filename;
+ pfilename && strlen(pfilename) > 30 && strchr(pfilename, '/') != NULL;
+ pfilename++)
+ pfilename = strchr(pfilename, '/');
+
+ if (pfilename && pfilename != filename) {
+ pfilenamebuf = nfmalloc(strlen(pfilename) + 5);
+ strcpy(pfilenamebuf, ".../");
+ strcat(pfilenamebuf, pfilename);
+ pfilename = pfilenamebuf;
+ } else {
+ pfilename = filename;
+ }
+
+ return pfilename;
+}
+
void process_archive(const char *filename) {
static const struct TarFunctions tf = {
.Read = tarfileread,
@@ -76,7 +99,7 @@ void process_archive(const char *filename) {
struct pkgiterator *it;
struct pkginfo *pkg, *otherpkg, *divpkg;
char *cidir, *cidirrest, *p;
- char *pfilenamebuf, conffilenamebuf[MAXCONFFILENAME];
+ char conffilenamebuf[MAXCONFFILENAME];
char *psize;
const char *pfilename, *newinfofilename;
struct fileinlist *newconff, **newconffileslastp;
@@ -97,17 +120,7 @@ void process_archive(const char *filename) {
cleanup_pkg_failed= cleanup_conflictor_failed= 0;
admindirlen= strlen(admindir);
- for (pfilename= filename ; pfilename && strlen(pfilename) > 30 &&
- strchr(pfilename,'/') != NULL ; pfilename++ )
- pfilename= strchr(pfilename,'/');
- if (pfilename && pfilename != filename) {
- pfilenamebuf= (char *)nfmalloc(strlen(pfilename)+5);
- strcpy(pfilenamebuf,".../");
- strcat(pfilenamebuf,pfilename);
- pfilename= pfilenamebuf;
- } else {
- pfilename= filename;
- }
+ pfilename = summarize_filename(filename);
if (stat(filename,&stab)) ohshite(_("cannot access archive"));
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]