GNU bug report logs - #73307
Fix ctype(3) usage

Previous Next

Package: emacs;

Reported by: Thomas Klausner <wiz <at> gatalith.at>

Date: Mon, 16 Sep 2024 21:26:01 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Thomas Klausner <wiz <at> gatalith.at>, Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 73307 <at> debbugs.gnu.org
Subject: bug#73307: Fix ctype(3) usage
Date: Tue, 17 Sep 2024 14:52:20 +0300
> Date: Mon, 16 Sep 2024 23:25:16 +0200
> From: Thomas Klausner <wiz <at> gatalith.at>
> 
> When compiling emacs on NetBSD-10.99.12/amd64, I get the following
> warning
> 
> In file included from /usr/include/ctype.h:100,
>                  from fns.c:29:
> fns.c: In function 'Fyes_or_no_p':
> fns.c:3582:33: warning: array subscript has type 'char' [-Wchar-subscripts]
>  3582 |     if ((len > 0) && !isspace (s[len - 1]))
>       |                                 ^
> 
> The NetBSD man page for ctype(3): https://man.netbsd.org/ctype.3
> is quite explicit about the problems with this - ctype(3) functions only
> accept -1 and "unsigned char" and you can get very weird problems if
> this is disregarded.
> 
> The attached patch adds the missing cast.
> [...]
>
> --- src/fns.c.orig	2024-09-16 21:11:40.908684144 +0000
> +++ src/fns.c
> @@ -3579,7 +3579,7 @@ by a mouse, or by some window-system ges
>    {
>      char *s = SSDATA (prompt);
>      ptrdiff_t len = strlen (s);
> -    if ((len > 0) && !isspace (s[len - 1]))
> +    if ((len > 0) && !isspace ((unsigned char)s[len - 1]))
>        prompt = CALLN (Fconcat, prompt, build_string (" "));
>    }
>    prompt = CALLN (Fconcat, prompt, Vyes_or_no_prompt);

Thanks.  However, I'm not sure this is the right fix, the function is
defined with argument type of 'int'.  Paul, any comments?




This bug report was last modified 267 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.