The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: Douglas McIlroy <douglas.mcilroy@dartmouth.edu>
Cc: TUHS main list <tuhs@tuhs.org>
Subject: [TUHS] Terms for string, and similar character constructs (was: origin of null-terminated strings)
Date: Fri, 16 Dec 2022 23:30:34 +0100	[thread overview]
Message-ID: <1ef751f4-16d0-69a1-367b-d201f815e88c@gmail.com> (raw)
In-Reply-To: <6009124d-750d-365e-a424-ec7bb25922b9@gmail.com>

[Resend from my subscribed address, as the list is subscribers-only, it seems]

In C, most syscalls and libc functions use strings, that is, zero or more 
non-NUL characters followed by a NUL.

However, there are a few cases where other incompatible character constructs are 
used.  A few examples:

-  utmpx(5): Some of its fields use fixed-width char arrays which contain a 
sequence of non-NUL characters, and padding of NULs to fill the rest (although 
some systems only require a NUL to delimit the padding, which can then contain 
garbage).

-  Some programs use just a pointer and a length to determine sequences of 
characters.  No NULs involved.

-  abstract sockets:  On Linux, abstract Unix socket names are stored in a 
fixed-width array, and all bytes are meaningful (up to the specified size), even 
if they are NULs.  Only special that that the first byte is NUL.

Since those are only rare cases, those constructs don't seem to have a name; 
some programmers call them strings (quite confusingly).

Has there been any de-facto standard (or informal naming) to call those things, 
and differentiate them?


Thanks,

Alex

-- 
<http://www.alejandro-colomar.es/>

  parent reply	other threads:[~2022-12-16 22:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16  3:02 [TUHS] origin of null-terminated strings Douglas McIlroy
2022-12-16  3:14 ` [TUHS] " Ken Thompson
2022-12-16  9:13   ` Dr Iain Maoileoin
2022-12-16 13:42     ` Dan Halbert
2022-12-16 16:10       ` Dan Cross
2022-12-16 16:22         ` Tom Lyon
2022-12-16 16:29         ` Jon Steinhart
2022-12-16 20:12     ` Dave Horsfall
2022-12-16 21:02       ` Warner Losh
2022-12-16 21:13         ` Clem Cole
2022-12-16 21:49           ` Clem Cole
2022-12-17  0:26             ` Phil Budne
2022-12-16 21:18         ` Luther Johnson
2022-12-16 21:20         ` Dan Halbert
2022-12-16  3:17 ` Steve Nickolas
2022-12-16 17:24 ` John P. Linderman
     [not found] ` <6009124d-750d-365e-a424-ec7bb25922b9@gmail.com>
2022-12-16 22:30   ` Alejandro Colomar [this message]
2022-12-16 22:51     ` [TUHS] Re: Terms for string, and similar character constructs (was: origin of null-terminated strings) Dave Horsfall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ef751f4-16d0-69a1-367b-d201f815e88c@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=douglas.mcilroy@dartmouth.edu \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).