diff options
author | John Ankarström <john@ankarstrom.se> | 2021-07-20 01:48:01 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-07-20 01:48:01 +0200 |
commit | 7fb5e36da3b4e873793036f5e7feaccbde924b10 (patch) | |
tree | 9f0574b6ac150c08b9d74080ede00bfa612dda0e /refs.lex | |
parent | 1ef148f6f3fc515866be7abdbd5a844a45cb4f49 (diff) | |
download | fref-7fb5e36da3b4e873793036f5e7feaccbde924b10.tar.gz |
Clear fields after each entry
Diffstat (limited to 'refs.lex')
-rw-r--r-- | refs.lex | 28 |
1 files changed, 25 insertions, 3 deletions
@@ -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; |