aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ref2bib.awk
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2026-06-06 12:26:27 -0400
committerDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2026-06-06 12:26:27 -0400
commitb56c273d8198ae6cee69bbc9fe5a6a61da4074e4 (patch)
treef75b89299fe2783354ba0ab7e3ace088fa60245a /lib/ref2bib.awk
parent4aec9800fca665713b0eba19f10af927b483332e (diff)
downloadbibutils-b56c273d8198ae6cee69bbc9fe5a6a61da4074e4.tar.gz
Code cleanup
Diffstat (limited to 'lib/ref2bib.awk')
-rw-r--r--lib/ref2bib.awk20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/ref2bib.awk b/lib/ref2bib.awk
index 422fdd7..9384677 100644
--- a/lib/ref2bib.awk
+++ b/lib/ref2bib.awk
@@ -19,6 +19,14 @@ function r_emit(name, v) {
printf " %s = {%s},\n", name, v
}
+# join arr[1..n] with " and ", as bibtex name lists expect
+function r_join(arr, n, s, i) {
+ s = arr[1]
+ for (i = 2; i <= n; i++)
+ s = s " and " arr[i]
+ return s
+}
+
{
split("", val)
na = 0
@@ -65,14 +73,10 @@ function r_emit(name, v) {
print ""
printf "@%s{FIXME,\n", type
- authors = ""
- for (i = 1; i <= na; i++)
- authors = (i == 1) ? A[i] : authors " and " A[i]
- r_emit("author", authors)
- editors = ""
- for (i = 1; i <= ne; i++)
- editors = (i == 1) ? E[i] : editors " and " E[i]
- r_emit("editor", editors)
+ if (na > 0)
+ r_emit("author", r_join(A, na))
+ if (ne > 0)
+ r_emit("editor", r_join(E, ne))
r_emit("title", val["T"])
r_emit("journal", val["J"])