Date: Mon, 18 Mar 1996 01:44:35 +1100 From: Bruce Evans <bde@zeta.org.au> To: freebsd-hackers@freebsd.org, j@uriah.heep.sax.de Cc: serg@bcs1.bcs.zaporizhzhe.ua Subject: Re: core dump in tr Message-ID: <199603171444.BAA09395@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>As Sergey Shkonda wrote: >> >> Try tr "A-B" "C-D" >> >> ( A, B, C, D > 127 ) >> ! u_char *str; /* user's string */ >Thanks for pointing this out. It didn't dump core for me, but >nevertheless, it didn't do what it was supposed to either. I think ordinary A-D and other characters in the C locale are required to be positive as chars. If not, then the suggested patch introduces new bugs in code like int ch; ... switch (ch = *s->str) { ... case '\\': ... } if '\\' < 0, then case '\\' isn't reachable. >I've modified your suggested fix. The data type of any `char' that >holds a real string (as opposed to random byte-sized binary garbage) >should really be `char' (neither explicitly signed nor unsigned), but >before assigning it to an int or compare it with sign extension, it >should be casted to `u_char' first. And before calling isdigit()... The ctype functions currently handle negative characters by converting them to unsigned chars, but are slower for negative chars. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603171444.BAA09395>