diff options
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; |