From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 488C5FA3743 for ; Thu, 27 Oct 2022 18:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235571AbiJ0S2g (ORCPT ); Thu, 27 Oct 2022 14:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236365AbiJ0S2V (ORCPT ); Thu, 27 Oct 2022 14:28:21 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E85F7992D for ; Thu, 27 Oct 2022 11:28:20 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id ml12so2178863qvb.0 for ; Thu, 27 Oct 2022 11:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=wEdZOEYjrllCAot2dTAA4KX0CdNoEXMJ9BmzaOuDVdI=; b=T/yx4PJ4RHQPFV86A2BeP473agGj/WJk6zWc5l56IseidOqLDSaXwuFZkIocHU533Q Yqz3muzZsTyk8+MlpD0cvUoOsFqBfxZMuROtUtg57iTtb/5PSYiTdWosU7yAfnitmzIM 28RHz7CU3/A6B1cqE3d5MA8RJ7WNWOjaLOxLI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wEdZOEYjrllCAot2dTAA4KX0CdNoEXMJ9BmzaOuDVdI=; b=Z/IfCywtiD0UAboY6X9NPAJBZexdZdCBdecJA4T/kzyO6b+HnzNpocm4S8gGfQ/Ruo WH/xaQLKJWaR78IdKGPDPhuaoecuSpG1kGwP3en4t6ZOMQhF2uqTfiewbIoRj77s6JSX TCXeyZ0/+Ae3M8RHTwS5xBwi2OsJ9rLPBO2d7Rtt9clxIJXIy412IYgJTz5TAQM6RmlN THfUlKqCGFk0R5u9RtI8NAK7Q1nJpPYeu0yYWwu22R+9rzYpiX5rUnbMAKJXcuioALf+ CFVPk4o8bYYYfvLoi2ZgXkE5ikT2dLfANWiv6ujHlOp7sNWG3txZrIA0LnnuIGWCEeoW ReIw== X-Gm-Message-State: ACrzQf1Fm9pKNehfp5gS7aMZ/jZ95MjAqyMJarYmiPu8675BujAQ1ssZ +lAneNH1fIavPW/mTb1HyNbSwwvtEh6bSA== X-Google-Smtp-Source: AMsMyM49TRQjib2MdTFRGgeaPYuyiLiCmNbkElgQel9d0y/yOEn1vYrPSpundfuwFMAlK3/hXisMnQ== X-Received: by 2002:a05:6214:f0f:b0:4bb:698d:50fd with SMTP id gw15-20020a0562140f0f00b004bb698d50fdmr20801198qvb.98.1666895299220; Thu, 27 Oct 2022 11:28:19 -0700 (PDT) Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com. [209.85.219.180]) by smtp.gmail.com with ESMTPSA id x2-20020ac87ec2000000b00398a7c860c2sm1257070qtj.4.2022.10.27.11.28.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Oct 2022 11:28:18 -0700 (PDT) Received: by mail-yb1-f180.google.com with SMTP id 63so3254241ybq.4 for ; Thu, 27 Oct 2022 11:28:18 -0700 (PDT) X-Received: by 2002:a5b:984:0:b0:6ca:9345:b2ee with SMTP id c4-20020a5b0984000000b006ca9345b2eemr8266384ybq.362.1666895298062; Thu, 27 Oct 2022 11:28:18 -0700 (PDT) MIME-Version: 1.0 References: <20221019162648.3557490-1-Jason@zx2c4.com> <3a2fa7c1-2e31-0479-761f-9c189f8ed8c3@rasmusvillemoes.dk> <915a104b-0e70-dfb8-3c85-54fd1e5e63e5@rasmusvillemoes.dk> In-Reply-To: <915a104b-0e70-dfb8-3c85-54fd1e5e63e5@rasmusvillemoes.dk> From: Linus Torvalds Date: Thu, 27 Oct 2022 11:28:02 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: make ctype ascii only? (was [PATCH] kbuild: treat char as always signed) To: Rasmus Villemoes Cc: "Jason A. Donenfeld" , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, linux-toolchains@vger.kernel.org, Masahiro Yamada , Kees Cook , Andrew Morton , Andy Shevchenko , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Thu, Oct 27, 2022 at 12:59 AM Rasmus Villemoes wrote: > > AFAICT, the differences are: > > - 0xaa (FEMININE ORDINAL INDICATOR), 0xb5 (MICRO SIGN), 0xba (FEMININE > ORDINAL INDICATOR) should be lower (hence alpha and alnum), not punct. > > - depending a little on just exactly what one wants latin1 to mean, but > if it does mean "first 256 codepoints of Unicode", 0x80-0x9f should be cntrl > > - for some reason at least glibc seems to classify 0xa0 as punctuation > and not space (hence also as isgraph) > > - 0xdf and 0xff are correctly classified as lower, but since they don't > have upper-case versions (at least not any that are representable in > latin1), correct toupper() behaviour is to return them unchanged, but we > just subtract 0x20, so 0xff becomes 0xdf which isn't isupper() and 0xdf > becomes something that isn't even isalpha(). Heh. Honestly, I don't think we should care at all. For the byte range 128-255, anybody who uses ctype on them gets what they get. In the kernel, the most likely use of it is for 'isprint()', and if those care, they can (and some do) use 'isascii()' in addition. I don't know if you realize, but the kernel already says "screw libc", and makes all the isxyz() things just cast the argument to 'unsigned char', and doesn't care about EOF. And for the rest, let's just call it the "kernel locale", and just admit that the kernel locale is entirely historical. Boom - problem solved, and it's entirely standards conformant (apart possibly from the EOF case, I think that is marked as a "lower case character" right now ;) Looking through https://pubs.opengroup.org/onlinepubs/9699919799/ I'm not actually seeing anything that says that we don't do *exactly* what the standard requires. You thinking that the kernel locale is US-ASCII is just wrong. Linus