Permalink
Browse files

add %! as an auto-increment record counter

  • Loading branch information...
1 parent 2cabb7f commit 928f60ecca4d577b35ac11efa9e9566c779a41b4 @falconindy committed Jul 17, 2011
Showing with 6 additions and 0 deletions.
  1. +2 −0 README.pod
  2. +4 −0 expac.c
View
@@ -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
View
@@ -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 */

0 comments on commit 928f60e

Please sign in to comment.