Sujet : Re: Rationale for aligning data on even bytes in a Unix shell file?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 27. Apr 2025, 00:35:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250426163100.739@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-04-26, Janis Papanagnou <janis_papanagnou+
ng@hotmail.com> wrote:
In a "C" file (of the Kornshell software) I stumbled across this
comment: "Each command in the history file starts on an even byte
and is null-terminated."
The full(er) text is:
Each command in the history file starts on an even byte and is
null-terminated. The first byte must contain the special character
HIST_UNDO and the second byte is the version number.
If the file is snarfed into a buffer, then if each command starts
on an even byte, those two-byte pairs will be aligned and can be
accessed as two-byte integers.
At a glance, I don't see where the code relies on that, but maybe
historically it did.
The alignment could be of help if you're looking at the file
with "od -tx2a".
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca