[patch] adds --wide flag (for --list), small manpage fix
Hi...
this is a simple patch which adds a --wide flag to make --list
always print entire package names.
There is also a fix for an (ugly) typo in the manpage.
diff -ur dpkg-1.8.3.orig/main/dpkg.8 dpkg-1.8.3/main/dpkg.8
--- dpkg-1.8.3.orig/main/dpkg.8 Tue Dec 26 03:18:33 2000
+++ dpkg-1.8.3/main/dpkg.8 Tue Jan 16 01:19:02 2001
@@ -200,7 +200,10 @@
is given, list all packages in \fI/var/lib/dpkg/available\fP. Normal
shell wildchars are allowed in \fIpackage-name-pattern\fP. (You will
probably have to quote \fIpackage-name-pattern\fP to prevent the shell
-from performing filename expansion. For example, \fBdpkg -l 'libc5*'\fP will list all the package names starting with "libc5".)
+from performing filename expansion. For example, \fBdpkg -l 'libc5*'\fP will list all the package names starting with "libc5".) By default, the width
+of the output will match the \fBCOLUMNS\fP environment variable, or will
+try to match the terminal. The \fB--wide\fP flag will make it wide
+enough to see all package names completely.
.TP
\fBdpkg -s\fP | \fB--status\fP \fIpackage-name\fP ...
Report status of specified package. This just displays the entry in
@@ -489,6 +492,7 @@
.TP
.B SHELL
The program \fBdpkg\fP will execute while starting a new shell.
+.TP
.B COLUMNS
Sets the number of columns \fBdpkg\fP should use when displaying formatted
text. Currently only used by -l.
diff -ur dpkg-1.8.3.orig/main/enquiry.c dpkg-1.8.3/main/enquiry.c
--- dpkg-1.8.3.orig/main/enquiry.c Sun Dec 24 14:27:43 2000
+++ dpkg-1.8.3/main/enquiry.c Tue Jan 16 01:02:25 2001
@@ -80,17 +80,23 @@
return ws.ws_col;
}
-static void list1package(struct pkginfo *pkg, int *head) {
+#define BASE_NW 14
+
+static void list1package(struct pkginfo *pkg, int *head, int maxlen) {
int l,w;
static int nw,vw,dw;
const char *pdesc;
static char format[80] = "";
if (format[0]==0) {
- w=getwidth()-80; /* get spare width */
- if (w<0) w=0; /* lets not try to deal with terminals that are too small */
- w>>=2; /* halve that so we can add that to the both the name and description */
- nw=(14+w); /* name width */
+ if (!maxlen) {
+ w=getwidth()-80; /* get spare width */
+ if (w<0) w=0; /* lets not try to deal with terminals that are too small */
+ w>>=2; /* halve that so we can add that to the both the name and description */
+ } else {
+ w = maxlen - BASE_NW; /* so that nw = maxlen, exactly fitting the name */
+ }
+ nw=(BASE_NW + w); /* name width */
vw=(14+w); /* version width */
dw=(44+(2*w)); /* description width */
sprintf(format,"%%c%%c%%c %%-%d.%ds %%-%d.%ds %%.*s\n", nw, nw, vw, vw);
@@ -126,6 +132,7 @@
struct pkginfo **pkgl;
const char *thisarg;
int np, i, head, found;
+ int len, maxlen = 0;
modstatdb_init(admindir,msdbrw_readonly);
@@ -135,6 +142,10 @@
while ((pkg= iterpkgnext(it))) {
assert(i<np);
pkgl[i++]= pkg;
+ if (f_wide) {
+ len = strlen(pkg->name);
+ if (len > maxlen) maxlen = len;
+ }
}
iterpkgend(it);
assert(i==np);
@@ -146,7 +157,7 @@
for (i=0; i<np; i++) {
pkg= pkgl[i];
if (pkg->status == stat_notinstalled) continue;
- list1package(pkg,&head);
+ list1package(pkg,&head,maxlen);
}
} else {
while ((thisarg= *argv++)) {
@@ -154,7 +165,7 @@
for (i=0; i<np; i++) {
pkg= pkgl[i];
if (fnmatch(thisarg,pkg->name,0)) continue;
- list1package(pkg,&head); found++;
+ list1package(pkg,&head,maxlen); found++;
}
if (!found)
fprintf(stderr,_("No packages found matching %s.\n"),thisarg);
diff -ur dpkg-1.8.3.orig/main/main.c dpkg-1.8.3/main/main.c
--- dpkg-1.8.3.orig/main/main.c Wed Dec 27 12:22:18 2000
+++ dpkg-1.8.3/main/main.c Tue Jan 16 01:19:06 2001
@@ -71,7 +71,7 @@
dpkg -s|--status <package-name> ... display package status details\n\
dpkg -p|--print-avail <package-name> ... display available version details\n\
dpkg -L|--listfiles <package-name> ... list files `owned' by package(s)\n\
- dpkg -l|--list [<pattern> ...] list packages concisely\n\
+ dpkg -l|--list [<pattern> ...] [--wide] list packages concisely\n\
dpkg -S|--search <pattern> ... find package(s) owning file(s)\n\
dpkg -C|--audit check for broken package(s)\n\
dpkg --print-architecture print target architecture (uses GCC)\n\
@@ -127,7 +127,7 @@
const struct cmdinfo *cipaction= 0;
int f_pending=0, f_recursive=0, f_alsoselect=1, f_skipsame=0, f_noact=0;
-int f_autodeconf=0, f_largemem=0;
+int f_autodeconf=0, f_largemem=0, f_wide=0;
unsigned long f_debug=0;
/* Change fc_overwrite to 1 to enable force-overwrite by default */
int fc_downgrade=1, fc_configureany=0, fc_hold=0, fc_removereinstreq=0, fc_overwrite=0;
@@ -359,6 +359,7 @@
{ "no-also-select", 'N', 0, &f_alsoselect, 0,0,0 /* fixme: remove sometime */ },
{ "skip-same-version", 'E', 0, &f_skipsame, 0, 0, 1 },
{ "auto-deconfigure", 'B', 0, &f_autodeconf, 0, 0, 1 },
+ { "wide", 0, 0, &f_wide, 0, 0, 1 },
{ "largemem", 0, 0, &f_largemem, 0, 0, 1 },
{ "smallmem", 0, 0, &f_largemem, 0, 0, -1 },
{ "root", 0, 1, 0, 0, setroot },
diff -ur dpkg-1.8.3.orig/main/main.h dpkg-1.8.3/main/main.h
--- dpkg-1.8.3.orig/main/main.h Mon Nov 6 02:06:48 2000
+++ dpkg-1.8.3/main/main.h Tue Jan 16 00:44:03 2001
@@ -78,7 +78,7 @@
extern const struct cmdinfo *cipaction;
extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
-extern int f_autodeconf, f_largemem;
+extern int f_autodeconf, f_largemem, f_wide;
extern unsigned long f_debug;
extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, fc_overwrite;
extern int fc_removeessential, fc_conflicts, fc_depends, fc_dependsversion;
--
Peter Eckersley http://www.cs.mu.oz.au/~pde
(pde@cs.mu.oz.au) TLI: http://www.computerbank.org.au
<~~~~.sig temporarily conservative pending divine intervention~~~~>
GPG fingerprint: 30BF 6A78 2013 DCFA 5985 E255 9D31 4A9A 7574 65BC
Reply to: