Conversation

If you like , go ahead and take a look at . It's one of the finest examples of write-only C code bases I've had the displeasure to learn from.

https://dechifro.org/dcraw/dcraw.c

case 274: /* Orientation */
tiff_ifd[ifd].flip = "50132467"[get2() & 7]-'0';

I dig that is now fixing that. And not even because it's in . I can actually follow the code!

https://gitlab.freedesktop.org/libopenraw/libopenraw/-/blob/master/src/panasonic.rs?ref_type=heads#L849

4
0
0

} else if ((nonz[i & 1] = pana_bits(8)) || i > 11)
pred[i & 1] = nonz[i & 1] << 4 | pana_bits(4);

MY EYES

2
0
0

@dcz looks like a patch by Jia Tan...

1
0
0

@spaetz I found something that looks like a bug after de-obfucating, so yeah. But it's itself a decoder of a reverse-engineered protocol, so I can't be sure.

0
0
0

@dcz Is that assignment in an if statement intentional??

1
0
0

@sundew Yes. The real fun thing? pana_bits() is a file read. So it assigns and consumes the file even if the condition fails.
If you skim just over the body, you'll misunderstand the code.

0
0
0

@dcz That's the kind of stuff I write for fun ... In my free time. Wait, some people thought it was ok to push that!

1
0
0

@dcz I actually parser that code pretty easily, I'm doomed aren't I

1
0
0

@polly This snippet is easy to mechanically parse, but what are some of the identifiers? get2()? The magic number? You have to stop and think about it, which, considering that the entire 20000 lines file is like that, makes it super hard to work with.

0
0
0

@robinm Tbh I think this was written by someone in their free time for fun. And it was not pushed cause I don't think it's in version control XD

Still, it's a disappointment that people started using this widely without rewriting into something more maintainable. Some pieces here are the only implementation in free software.

0
0
0
@dcz That's actually a nice hack :-).
0
0
0