sw

simple wallet
git clone git://git.bitsmanent.org/sw
Log | Files | Refs | README | LICENSE

commit 1fa30336120b2ca2d9a9feedd396ec35c04a4bfe
parent 8af46f6e144feb33016b6c193fa9bdf3885122a5
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Thu, 15 Aug 2024 22:07:06 +0200

Show 25 movements by default and allow -l 0 (limit = MAX_INT).

Diffstat:
Marg.h | 8--------
Msw.1 | 13+++++++------
Msw.c | 12++++++------
3 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/arg.h b/arg.h @@ -28,7 +28,6 @@ extern char *argv0; break;\ argc_ = argv[0][0];\ switch (argc_) - #define ARGEND }\ } @@ -37,11 +36,4 @@ extern char *argv0; (brk_ = 1, (argv[0][1] != '\0')?\ (&argv[0][1]) :\ (argc--, argv++, argv[0]))) - -#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\ - (char *)0 :\ - (brk_ = 1, (argv[0][1] != '\0')?\ - (&argv[0][1]) :\ - (argc--, argv++, argv[0]))) - #endif diff --git a/sw.1 b/sw.1 @@ -3,10 +3,11 @@ sw \- simple wallet .SH SYNOPSIS .B sw -.RB [ \-v ]\ [ \-dfit \ <arg>]\ [ \-e \ <text>\ ...]\ [ \-l \ [limit]]\ [<date\ [time]\>\ <amount>\ <note>] +.RB [ \-v ]\ [ \-dfit \ <arg>]\ [ \-e \ <text>\ ...]\ [ \-l \ <limit>]\ [<date\ [time]\>\ <amount>\ <note>] .SH DESCRIPTION -sw is a simple wallet management tool which features a simple yet powerful -interface to keep track of your money movements. +sw is a wallet management tool which features a simple yet powerful interface +to keep track of your money movements. By default (e.g. if no -l is specified) +last 25 movements are shown. .SH OPTIONS .TP .B \-v @@ -25,9 +26,9 @@ consider only movements after the given date and optional time .B \-i\ <file> use the given file as movements database. .TP -.B \-l\ [limit] -limit the number of movements in the listing. In no argument is specified then -assume a value of 25. +.B \-l\ <limit> +limit the number of movements in the listing. If zero is specified then assume +a value of INT_MAX (show all movements). .TP .B \-t\ <date\ [time]> consider only movements before the given date and optional time diff --git a/sw.c b/sw.c @@ -75,7 +75,7 @@ Filter *filters; Totals totals; FILE *movsfile; char movsfilename[256]; -int limit = INT_MAX; +int limit = 25; int filtered = 0; int nfilters = 0; @@ -358,7 +358,7 @@ strtots(char *s) { void usage(void) { - die("Usage: %s [-v] [-dfit <arg>] [-e <text> ...] [-l [limit]] [<date [time]> <amount> <note>]\n", argv0); + die("Usage: %s [-v] [-dfit <arg>] [-e <text> ...] [-l <limit>] [<date [time]> <amount> <note>]\n", argv0); } int @@ -366,7 +366,6 @@ main(int argc, char *argv[]) { int delid = 0; int from = 0, to = 0; char *txt = NULL; - char *num; ARGBEGIN { case 'd': delid = atoi(EARGF(usage())); break; @@ -374,9 +373,10 @@ main(int argc, char *argv[]) { case 'f': addfilter(F_DATEFROM, EARGF(usage())); break; case 'i': snprintf(movsfilename, sizeof movsfilename, "%s", EARGF(usage())); break; case 'l': - num = ARGF(); - limit = num ? atoi(num) : 25; - break; + limit = atoi(EARGF(usage())); + if(!limit) + limit = INT_MAX; + break; case 't': addfilter(F_DATETO, EARGF(usage())); break; case 'v': die("sw-"VERSION"\n"); default: usage();