From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26894 invoked from network); 16 Dec 2022 03:04:05 -0000 Received: from minnie.tuhs.org (50.116.15.146) by inbox.vuxu.org with ESMTPUTF8; 16 Dec 2022 03:04:05 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id C90394238F; Fri, 16 Dec 2022 13:03:41 +1000 (AEST) Received: from mail-vs1-f45.google.com (mail-vs1-f45.google.com [209.85.217.45]) by minnie.tuhs.org (Postfix) with ESMTPS id AF7D54238C for ; Fri, 16 Dec 2022 13:03:34 +1000 (AEST) Received: by mail-vs1-f45.google.com with SMTP id c184so1136723vsc.3 for ; Thu, 15 Dec 2022 19:03:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dartmouth.edu; s=google1; h=content-transfer-encoding:cc:to:subject:message-id:date:from :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WkNY2EgONef63jGM8MKxPIy3fr+NVYH+LYsDrpBRzI0=; b=Uoz0WpmvZbpJMXWhqS8i0ubkaBQOJI42Drh/Cv+SXEbRYHGZZo8Uq6qq4OYOBafaCP /4iRkTjYc/RuLFfBvxXiSQSTfk0sDUui8XchYhjM9XHlc1uovJOpK2blvobjkAFvt7av AHHY9i5UA8snJ3FDIivI7KiHdQ+voU/Bd5y4mdCiN+0ME1g9dXOqzphJ7iVAeg2lEEIE w8rwWGbMFs0YqF7D3ENh3BVSVDVGBobTQt5iL0WX08XKY+ibL7U9EV/nVtOWH3c25yLR QwM2Tg6Mta1Jla93wdtdwl6XuHm0mW/JrWFLdWjvATKgT4WGA2BQhAaDl49jC1i0AsEa 7Hag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WkNY2EgONef63jGM8MKxPIy3fr+NVYH+LYsDrpBRzI0=; b=6Olxlx+TgMk3hDsQY/M92AWg9nRD6T8QD5oehYJ010rEQcPlP4PZpgYyjvH1BMvicB gwEU2uRUHj91rz0dNi40Pvz74LggBfh3jmv7kBJj+R9jw/C6/xkjDkXdBDor5sv+aQK2 CAOYEKWRZyDunBsWBAqI2Ms1JWK12EmNWnLzpfYCSCNP/XA8v7EXEHG42BGKayQof6J3 Bs57oWlhslOuOL6OWX/BUbxn6ahLUJ/h8gGjLJZasn6xS+ZH660PlPEl8wU2Z/yOpmjF EGf9A2NoM7SfWBaNkPPLHWmwXUjYRLjGOr3qgM2K1Me36HeWDasLC9y4zOHAysmxb3kJ uscQ== X-Gm-Message-State: ANoB5pl0iYfqKHRrfv/j8KFlEGjfQhDrG4LmFClwWLjpCIdFJt6+8GyT bIWlGjqweC7A+yvwdKXZgeF9Idase0t5KYYqldwd0bMk3YsRF4dq X-Google-Smtp-Source: AA0mqf6CxdraXVrGZiXA79bA0UZZfTffOAdeI1i2nxImyOwICKgKIu3xeUlwZT9VvfuYzLOT0fan1bi4uOI4Pecd7fk= X-Received: by 2002:a67:b602:0:b0:3b2:e469:d123 with SMTP id d2-20020a67b602000000b003b2e469d123mr10753346vsm.86.1671159753676; Thu, 15 Dec 2022 19:02:33 -0800 (PST) MIME-Version: 1.0 From: Douglas McIlroy Date: Thu, 15 Dec 2022 22:02:18 -0500 Message-ID: To: Alejandro Colomar Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BHXSUQQTPMDQKV5GUW5FJKQL2MIJ5BSN X-Message-ID-Hash: BHXSUQQTPMDQKV5GUW5FJKQL2MIJ5BSN X-MailFrom: douglas.mcilroy@dartmouth.edu X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-tuhs.tuhs.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: TUHS main list X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [TUHS] origin of null-terminated strings List-Id: The Unix Heritage Society mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: I think this cited quote from https://www.joelonsoftware.com/2001/12/11/ is urban legend. Why do C strings [have a terminating NUl]? It=E2=80=99s because the PDP= -7 microprocessor, on which UNIX and the C programming language were invented, had an ASCIZ string type. ASCIZ meant =E2=80=9CASCII with a Z (ze= ro) at the end.=E2=80=9D This assertion seems unlikely since neither C nor the library string functions existed on the PDP-7. In fact the "terminating character" of a string in the PDP-7 language B was the pair '*e'. A string was a sequence of words, packed two characters per word. For odd-length strings half of the final one-character word was effectively NUL-padded as described below. One might trace null termination to the original (1965) proposal for ASCII, https://dl.acm.org/doi/10.1145/363831.363839. There the only role specifically suggested for NUL is to "serve to accomplish time fill or media fill." With character-addressable hardware (not the PDP-7), it is only a small step from using NUL as terminal padding to the convention of null termination in all cases. Ken would probably know for sure whether there's any truth in the attribution to ASCIZ. Doug