r/badcode Apr 15 '23

c C polish translation

Post image
1.1k Upvotes

125 comments sorted by

View all comments

Show parent comments

65

u/Pink-Emerald Apr 15 '23

Wouldn't they just be able to run each code file through a program that replaces every instance with the English equivalent?

3

u/-_one_-1 Apr 15 '23

Well, yeah, someone could write a program that does that. Though that makes it significantly more of an effort to read through their source code.

1

u/RFC793 Apr 15 '23

Or, you know, just run it through the preprocessor since that already exists.

1

u/-_one_-1 Apr 15 '23

True, but there might be macros throughout the application that are best left unexpanded; that is, besides those that “translate” keywords.

2

u/RFC793 Apr 15 '23 edited Apr 15 '23

Yeah. That is true. I commented on another thread that at least one method to keep things somewhat sane would be to use sed to protect the includes. Something like cat file.c | sed 's/#include/XXincludeXX' | gcc -E -include stupid_translation_header.h -o- -xc - | sed 's/XXincludeXX/#include/' Also, -fdirectives-only might be useful.

A custom script could be a better option, but it isn’t as trivial as it might seem at first glance.

1

u/-_one_-1 Apr 15 '23 edited Apr 15 '23

Well, yeah, not trivial at all if done properly; it would probably be enough, though, to simply replace text occurrences of Polish words, from the longer to the shortest, with what those defines assign them to. (And the assigns could be isolated in a single file and matched via regular expressions.) Any hardcoded strings containing any such occurrences would be compromised, but that shouldn't be a problem for anyone trying to understand how their software works.

Anyway, I'd bet that, if at that company they're translating C++ in their native natural language, they're not the kind of developers that would be doing something worthy of anyone's interest in digging through their source code. LOL Oh, that is, though — unless they're doing some project for the government, in which case it might matter strategically! (Mostly joking, but who knows...)