bdf2sfd

BDF to SFD converter, allowing to vectorize bitmap fonts
Log | Files | Refs | README | LICENSE

commit 28a818e9cc071879f1b7289a1e7335b91fb7b22b
parent 8829c11bfe5a0d6e6ad885ff61200a661c34f3eb
Author: Frederic Cambus <fred@statdns.com>
Date:   Tue, 16 Nov 2021 14:02:17 +0100

Switch to using getline(3) instead of fgets(3).

This allows reading lines of arbitrary length, and performance testing
using hyperfine didn't show any significant regressions.

Diffstat:
Msrc/bdf2sfd.c | 8+++++---
Msrc/config.h | 4+---
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/bdf2sfd.c b/src/bdf2sfd.c @@ -4,7 +4,7 @@ * https://github.com/fcambus/bdf2sfd * * Created: 2019-11-21 - * Last Updated: 2021-02-28 + * Last Updated: 2021-11-16 * * bdf2sfd is released under the BSD 2-Clause license. * See LICENSE file for details. @@ -73,7 +73,8 @@ main(int argc, char *argv[]) const char *errstr = NULL; char *input; char *value = NULL; - char linebuffer[LINE_LENGTH_MAX]; + char *linebuffer = NULL; + size_t linesize = 0; bool readglyph = false; bool name_allocated = false, psname_allocated = false; @@ -147,7 +148,7 @@ main(int argc, char *argv[]) return EXIT_FAILURE; } - while (fgets(linebuffer, LINE_LENGTH_MAX, bdf)) { + while (getline(&linebuffer, &linesize, bdf) != -1) { if (!*linebuffer) continue; @@ -310,6 +311,7 @@ main(int argc, char *argv[]) glyphs, elapsed.tv_sec + elapsed.tv_nsec / 1E9); /* Clean up */ + free(linebuffer); fclose(bdf); if (name_allocated) diff --git a/src/config.h b/src/config.h @@ -4,7 +4,7 @@ * https://github.com/fcambus/bdf2sfd * * Created: 2019-11-21 - * Last Updated: 2020-10-08 + * Last Updated: 2021-11-16 * * bdf2sfd is released under the BSD 2-Clause license. * See LICENSE file for details. @@ -17,6 +17,4 @@ #define VERSION "bdf2sfd 1.1.6" -#define LINE_LENGTH_MAX 65536 - #endif /* CONFIG_H */