summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-07-17 14:03:11 -0400
committerDave Reisner <dreisner@archlinux.org>2011-07-17 15:42:51 -0400
commit928f60ecca4d577b35ac11efa9e9566c779a41b4 (patch)
tree5420bbb942ffd42f14bdac83847103dc60bded9e
parent2cabb7f06594b7c63374d29e9bd7607f3bfc5c5e (diff)
downloadexpac-928f60ecca4d577b35ac11efa9e9566c779a41b4.tar.xz
add %! as an auto-increment record counter
-rw-r--r--README.pod2
-rw-r--r--expac.c4
2 files changed, 6 insertions, 0 deletions
diff --git a/README.pod b/README.pod
index 62a79d9..8c64540 100644
--- a/README.pod
+++ b/README.pod
@@ -126,6 +126,8 @@ The format argument allows the following interpreted sequences:
%w install reason
+ %! result number (auto-incremented counter, starts at 0)
+
%% literal %
Note that for any lowercase tokens aside from %m and %k, full printf support is
diff --git a/expac.c b/expac.c
index 85dcc19..ee057aa 100644
--- a/expac.c
+++ b/expac.c
@@ -57,6 +57,7 @@ const char *format = NULL;
const char *timefmt = NULL;
const char *listdelim = NULL;
const char *delim = NULL;
+int pkgcounter = 0;
typedef const char *(*extractfn)(void*);
@@ -406,6 +407,9 @@ static int print_pkg(pmpkg_t *pkg, const char *format) {
case 'w': /* install reason */
out += printf(fmt, alpm_pkg_get_reason(pkg) ? "dependency" : "explicit");
break;
+ case '!': /* result number */
+ out += printf("%d", pkgcounter++);
+ break;
/* times */
case 'b': /* build date */