diff --git a/README.bsd b/README.bsd
index 79adf273..2654381f 100644
--- a/README.bsd
+++ b/README.bsd
@@ -1,4 +1,4 @@
-% Tested on FreeBSD 13.2-RELEASE (with X11 + GNOME installed) and OpenBSD 7.3 (with X11)
+% Tested on FreeBSD 14.0-RELEASE (with X11 + GNOME installed), OpenBSD 7.4 (with X11) and NetBSD 9.3 (with X11)
1. Prerequisites for building zint
==================================
@@ -15,6 +15,12 @@ or OpenBSD (make and clang should already be installed):
pkg_add git cmake png
exit
+or NetBSD (make and gcc should already be installed):
+
+ su
+ pkgin install git cmake png
+ exit
+
Then clone the latest source
git clone https://git.code.sf.net/p/zint/code zint
@@ -36,6 +42,12 @@ On OpenBSD:
pkg_add qtbase qttools qtsvg
exit
+On NetBSD:
+
+ su
+ pkgin install qt5-qtbase qt5-qttools qt5-qtsvg
+ exit
+
3. Build
========
@@ -54,6 +66,10 @@ except that on OpenBSD you need to use
cmake -DCMAKE_PREFIX_PATH=/usr/local/lib/qt5/cmake ..
+and on NetBSD
+
+ cmake -DCMAKE_PREFIX_PATH=/usr/pkg/qt5 ..
+
instead.
diff --git a/backend/filemem.c b/backend/filemem.c
index c6e2175a..6fad2bf3 100644
--- a/backend/filemem.c
+++ b/backend/filemem.c
@@ -187,7 +187,7 @@ INTERNAL int fm_write(const void *restrict ptr, const size_t size, const size_t
fm_setpos(fmp, fmp->mempos + tot_size);
return 1;
}
- if (fwrite(ptr, size, nitems, fmp->fp) == 0) {
+ if (fwrite(ptr, size, nitems, fmp->fp) != nitems) {
return fm_seterr(fmp, errno);
}
return 1;
@@ -304,11 +304,8 @@ INTERNAL int fm_printf(struct filemem *restrict const fmp, const char *fmt, ...)
}
va_start(ap, fmt);
ret = vfprintf(fmp->fp, fmt, ap) >= 0; /* NOLINT(clang-analyzer-valist.Uninitialized) - see above */
- if (!ret) {
- (void) fm_seterr(fmp, errno);
- }
va_end(ap);
- return ret != 0;
+ return ret ? 1 : fm_seterr(fmp, errno);
}
/* Output float without trailing zeroes to `fmp` with decimal pts `dp` (precision), returning 1 on success, 0 on
@@ -436,9 +433,12 @@ INTERNAL long fm_tell(struct filemem *restrict const fmp) {
return ret;
}
-/* Return `err`, which uses `errno` values */
+/* Return `err`, which uses `errno` values; if file and `err` not set, test `ferror()` also */
INTERNAL int fm_error(struct filemem *restrict const fmp) {
assert(fmp);
+ if (fmp->err == 0 && !(fmp->flags & BARCODE_MEMORY_FILE) && ferror(fmp->fp)) {
+ (void) fm_seterr(fmp, EIO);
+ }
return fmp->err;
}
diff --git a/backend/filemem.h b/backend/filemem.h
index e79e1647..74704ecd 100644
--- a/backend/filemem.h
+++ b/backend/filemem.h
@@ -84,7 +84,7 @@ INTERNAL int fm_seek(struct filemem *restrict const fmp, const long offset, cons
/* `ftell()` returns current file/memory offset if successful, -1 on failure */
INTERNAL long fm_tell(struct filemem *restrict const fmp);
-/* Return `err`, which uses `errno` values */
+/* Return `err`, which uses `errno` values; if file and `err` not set, test `ferror()` also */
INTERNAL int fm_error(struct filemem *restrict const fmp);
/* `fflush()` if file, no-op if memory, returning 1 on success, 0 on failure
diff --git a/backend/ps.c b/backend/ps.c
index 834b18ed..21ffd71c 100644
--- a/backend/ps.c
+++ b/backend/ps.c
@@ -263,17 +263,18 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
}
/* Start writing the header */
- fm_puts("%!PS-Adobe-3.0 EPSF-3.0\n", fmp);
+ fm_puts("%!PS-Adobe-3.0 EPSF-3.0\n"
+ "%%Creator: Zint ", fmp);
if (ZINT_VERSION_BUILD) {
- fm_printf(fmp, "%%%%Creator: Zint %d.%d.%d.%d\n",
+ fm_printf(fmp, "%d.%d.%d.%d\n",
ZINT_VERSION_MAJOR, ZINT_VERSION_MINOR, ZINT_VERSION_RELEASE, ZINT_VERSION_BUILD);
} else {
- fm_printf(fmp, "%%%%Creator: Zint %d.%d.%d\n", ZINT_VERSION_MAJOR, ZINT_VERSION_MINOR, ZINT_VERSION_RELEASE);
+ fm_printf(fmp, "%d.%d.%d\n", ZINT_VERSION_MAJOR, ZINT_VERSION_MINOR, ZINT_VERSION_RELEASE);
}
fm_puts("%%Title: Zint Generated Symbol\n"
- "%%Pages: 0\n", fmp);
- fm_printf(fmp, "%%%%BoundingBox: 0 0 %d %d\n",
- (int) ceilf(symbol->vector->width), (int) ceilf(symbol->vector->height));
+ "%%Pages: 0\n"
+ "%%BoundingBox: 0 0 ", fmp);
+ fm_printf(fmp, "%d %d\n", (int) ceilf(symbol->vector->width), (int) ceilf(symbol->vector->height));
fm_puts("%%EndComments\n", fmp);
/* Definitions */
diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c
index 112407d1..83803b76 100644
--- a/backend/tests/test_library.c
+++ b/backend/tests/test_library.c
@@ -34,7 +34,6 @@
#include
su
pkg_add zint zint-gui
exit
-To build from source see "README.bsd"
in the project
-root directory.
To build from source (including for NetBSD) see
+"README.bsd"
in the project root directory.
For Microsoft Windows, Zint is distributed as a binary executable.
Simply download the ZIP file, then right-click on the ZIP file and
diff --git a/docs/manual.pmd b/docs/manual.pmd
index f0c80e21..e8aba36f 100644
--- a/docs/manual.pmd
+++ b/docs/manual.pmd
@@ -193,7 +193,8 @@ pkg_add zint zint-gui
exit
```
-To build from source see `"README.bsd"` in the project root directory.
+To build from source (including for NetBSD) see `"README.bsd"` in the project
+root directory.
## 2.3 Microsoft Windows
diff --git a/docs/manual.txt b/docs/manual.txt
index 2b66257a..3e03200c 100644
--- a/docs/manual.txt
+++ b/docs/manual.txt
@@ -375,7 +375,8 @@ and on OpenBSD (where the GUI is in a separate zint-gui package):
pkg_add zint zint-gui
exit
-To build from source see "README.bsd" in the project root directory.
+To build from source (including for NetBSD) see "README.bsd" in the project root
+directory.
2.3 Microsoft Windows
diff --git a/frontend/main.c b/frontend/main.c
index 92d93eaf..82f64ccf 100644
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -26,20 +26,27 @@
#include