News for hackers. Stuff that matters.
Re:Let's write a setjmp by layer8 on Sunday February 12, 2023 @12:03PM (#34764460)
I would use a do-while, because at least one char is always copied:

    char c;
    do
    {
        c = *src++;
        *dst++ = c;
    }
    while (c != 0);
The post-increment is idiomatic enough in C-based languages that I wouldn’t worry about that.
Re:Let's write a setjmp by bee_rider on Sunday February 12, 2023 @12:55PM (#34765002)
I don’t write much C, but to an outsider like me this is a pretty big improvement.

It is a shame post-test loops aren’t more popular, given the similarity to the assembly they output. Seems more mechanically sympathetic. Oh well, at least it is an excuse to whip out the goto.

Re:Let's write a setjmp by layer8 on Sunday February 12, 2023 @01:09PM (#34765131)
In Pascal, you could do

    repeat
        ...
    until c = 0;
which might be even clearer for this use case.
Re:Let's write a setjmp by flohofwoe on Monday February 13, 2023 @05:53AM (#34772110)
I was considering that but had my doubts that people who already find post-increment confusing could handle a do-while loop ;)