News for hackers. Stuff that matters.
Re:Wc2: Investigates optimizing 'wc', the Unix word count pr... by samatman on Thursday June 20, 2024 @02:39PM (#40741796)
> But I'm not sure why the table is 4×4. The fourth transition from every state is unreachable since the symbols are all in [0, 2].

I think the fourth transition represents illegal Unicode. From there it stays in the illegal state until it hits legal UTF-8, then goes back to counting.

Re:Wc2: Investigates optimizing 'wc', the Unix word count pr... by James_K on Thursday June 20, 2024 @04:27PM (#40742994)
That isn't relevant in the ASCII example, and the UTF-8 one uses a 256×256 table.
Re:Wc2: Investigates optimizing 'wc', the Unix word count pr... by samatman on Friday June 21, 2024 @01:04PM (#40751528)
Half of all bytes are illegal ASCII though.
Re:Wc2: Investigates optimizing 'wc', the Unix word count pr... by James_K on Friday June 21, 2024 @05:26PM (#40754004)
And actually there isn't a state for illegal ASCII so it makes no sense to have a transition to/from it. And it still can never receive a 3 as input and use that transition.
Re:Wc2: Investigates optimizing 'wc', the Unix word count pr... by teo_zero on Saturday June 22, 2024 @01:15AM (#40756469)
For handling ASCII, table needs 4 states × 3 classes of chars. Why is it defined as 4×4?

To handle illegal chars, it would need a 4th class but also a 5th state, so that's not the reason.

Can it be to replace a 'modulo' operation with an 'and' in the access to table?