From 7fb5e36da3b4e873793036f5e7feaccbde924b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 20 Jul 2021 01:48:01 +0200 Subject: Clear fields after each entry --- refs.lex | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'refs.lex') diff --git a/refs.lex b/refs.lex index 714a79e..5440777 100644 --- a/refs.lex +++ b/refs.lex @@ -35,6 +35,7 @@ main(int argc, char *argv[0]) yylex(); } +/* Save entry field. */ void field(char *t) { @@ -56,15 +57,36 @@ field(char *t) exit(1); } +/* Print formatted entry. */ void entry() { + +#define EI(a, b) a ? a : b + (pf("% (%).\n", e.au, e.da) || pf("%.\n", e.au)); - (pf("%.\n\\fI%\\fP.\n", e.ti, e.bo ? e.bo : e.jo) - || pf("%.\n", e.ti)); + if (*e.bo || *e.jo){ + pf("%.\n", e.ti); + pf("\\fI%\\fP", EI(e.bo, e.jo)); + pf(" ("ED" %)", e.ed); + pf(".\n"); + }else + pf("\\fI%\\fP.\n", e.ti); + pf(TR" %.\n", e.tr); (pf("%: %.\n", e.ci, e.pu) || pf("%.\n", e.pu)); + +#define CL(a) *a = 0 + + CL(e.au); CL(e.al); + CL(e.bo); CL(e.ci); + CL(e.da); CL(e.ed); + CL(e.jo); CL(e.no); + CL(e.pg); CL(e.pu); + CL(e.se); CL(e.ti); + CL(e.tr); CL(e.vo); } +/* Print formatted text if given strings are non-empty. */ int pf(char *fmt, ...) { @@ -85,7 +107,7 @@ pf(char *fmt, ...) switch(*fmt){ case '%': p = va_arg(ap, char *); - if(!p || !p[0]) + if(!p || !*p) return 0; strcat(buf, p); break; -- cgit v1.2.3