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, 28 Jun 2023, tlaronde%polynum.com@localhost wrote:

But isn't it incorrect? POSIX 2018 says:

'"\ddd", where ddd is a one, two, or three-digit octal number, shall be
written as a byte with the numeric value specified by the octal number.'

since 477 -> 777 are not byte values, shouldn't \777 be interpreted as
'\77' octal then the digit 7; \677 -> \67 octal then 7 etc. ?


Better to do what the C compiler does: try converting up to 3 digits, and
if the result of the conversion is > 255, complain.

-RVP


Home | Main Index | Thread Index | Old Index