From 9afe491e1a8370e5a9b816fc03ac5190ff808056 Mon Sep 17 00:00:00 2001 From: Kinneyzhang Date: Sun, 26 Jul 2026 19:53:39 +0800 Subject: [PATCH] chore: silence build warnings on non-macOS toolchains MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ekp_hyphen.c: check fgets return when skipping the dictionary encoding line (gcc -Wunused-result via glibc fortify); behavior unchanged — an empty file already fell through to EOF in the loops - ekp-utils.el: declare-function for font-info, which does not exist in non-window-system builds (emacs-nox); call site is runtime-guarded by display-multi-font-p. Keeps byte-compile-error-on-warn green. Verified: clean gcc build + 36/36 ERT + 300-case fuzz on Ubuntu 24.04 (Emacs 29.3, arm64), clean clang build + 36/36 ERT on macOS (30.2). Co-Authored-By: Claude Fable 5 --- ekp-utils.el | 4 ++++ ekp_c/ekp_hyphen.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ekp-utils.el b/ekp-utils.el index 172ae8a..9d20aaa 100644 --- a/ekp-utils.el +++ b/ekp-utils.el @@ -41,6 +41,10 @@ information is available (batch mode, tty frames)." (let ((family (face-attribute 'default :family))) (if (stringp family) family (format "%s" family))))) +;; GUI-only C function; absent in non-window-system builds (emacs-nox). +;; Call sites are guarded by `display-multi-font-p'. +(declare-function font-info "font.c" (name &optional frame)) + (defun ekp-font-monospace-p (font-family) "Return non-nil if FONT-FAMILY appears to be monospace. Returns nil (unknown) when font information is unavailable." diff --git a/ekp_c/ekp_hyphen.c b/ekp_c/ekp_hyphen.c index bfeda10..f5d1d1c 100644 --- a/ekp_c/ekp_hyphen.c +++ b/ekp_c/ekp_hyphen.c @@ -99,7 +99,9 @@ ekp_hyphenator_t *ekp_hyphen_create(const char *dict_path) char line[256]; size_t count = 0; - fgets(line, sizeof(line), fp); /* skip encoding line */ + if (!fgets(line, sizeof(line), fp)) { + /* empty file: no encoding line to skip; count loop sees EOF */ + } while (fgets(line, sizeof(line), fp)) { size_t len = strlen(line); @@ -128,7 +130,9 @@ ekp_hyphenator_t *ekp_hyphen_create(const char *dict_path) /* Second pass: parse patterns */ rewind(fp); - fgets(line, sizeof(line), fp); /* skip encoding line */ + if (!fgets(line, sizeof(line), fp)) { + /* empty file: no encoding line to skip; parse loop sees EOF */ + } size_t idx = 0; while (fgets(line, sizeof(line), fp)) {