Am 08.04.2024 um 03:24 schrieb Valery Ushakov: > On Sun, Apr 07, 2024 at 14:28:27 +0000, Roland Illig wrote: > >> Log Message: >> snprintb.3: clean up formatting and wording, prefer octal in examples >> >> Using hexadecimal character escapes requires separate string literals if >> the description starts with one of the letters A-F; octal character >> escapes have at most 3 digits, reducing ambiguity. > > 70s are over, very few people speak octal fluently. If anything, the > man page should highlight the potential snag. Besides, separate > literal for the name is good for readability anyway.
When I looked through the NetBSD tree exploring the current usage, I found that a significant majority uses octal instead of hexadecimal. I don't know the exact reasons for this, it might be due to existing practice in the 1990s, to avoid splitting the bit position and the description to separate string literals, to be able to easily split the bit position into the byte and the bit portion mentally, or maybe something entirely different. While your claim that "very few people speak octal fluently" may be true for programmers in general, I expect those using the snprintb function to be more fluent than others. Of course, I saw cases where "\040" was followed by "\039", just as I saw cases of "\x0fFIELD". Lint now warns in both these cases. Regarding the separate literals, I didn't see them in wide use up to now. Existing code seems to focus more on compressing the source code into as few lines as possible rather than making it easily readable. I agree that separate string literals are more readable, and I converted the example that uses hexadecimal escapes to this style. I didn't eradicate _all_ hexadecimal examples, I just made each example use only one number base, not mix them both. There are both octal and hexadecimal examples in the manual page. Roland