tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: printf(1), sh(1), POSIX.2 and octal escape sequences



On Wed, Jun 28, 2023 at 06:32:10PM +0200, tlaronde%polynum.com@localhost wrote:
 > > If you want to write a two digit octal number you can not continue with
 > > another ocatal digit. In C you could do "...\77" "7" and have it concat
 > > the literals. In config files (without concatenation) you need some
 > > other trick.
 > 
 > I beg to differ: since due to this very unfortunate "variable length"
 > feature, your scanner has to read char by char, it can reject the third
 > digit since it would yield an out of range byte value.

The behavior of escapes in C strings is widely used and well
understood. Don't improvise.

There are such things as invalid inputs. Reject them with a reasonable
diagnostic message instead of trying to guess what the user might have
meant. Works out much better in the long run.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index