Inspired by @ rana_kualu's article, I'll write about the most dangerous fucking code I've ever seen.
(Original article) -The dirtiest source code I've ever seen-Qiita https://qiita.com/rana_kualu/items/2f3c40642836c11f5ddc
① typedef
Reproduction code.c
typedef void coid;
typedef void boid;
Looking at the keyboard, [** c ] [ v ] [ b **] are lined up. That is, this means that ** typos are covered by redefining the model name **. As expected, I thought that this was ** not a program **.
The variable name is appropriate for the time being.
Reproduction code.php
$date0 = '20201122'; //The character string comes from the screen with YYYYMMDD
$date1 = $date0 -10000;
$year = substr($date1, 0, 4);
$month = substr($date1, 4, 2);
$day = substr($date1, 6, 2);
What is the process of subtracting 10,000? A colleague (at that time) found this code from a mechanic under maintenance and bothered with him. In date processing, 10,000 is bad. .. .. Fortunately, the person who wrote it was next to me, so I asked him directly.
Calculated one year ago
:thinking::thinking::thinking::thinking::thinking:
: astonished: I see! : rage: Rewrite! : punch_tone2:
Fortunately, the person who wrote it was a friend (classmate) from high school, so I hit him for the time being.
For date manipulation, there is a function for date manipulation, so let's use it. (I mean, I'm a static type field person, so my knees trembled when I used dynamic type conversion.)
Reproduction code.java
boolean checkNumber (str) {
boolean isNumber = !NumberUtils.isNumber(str);
if(isNumber) {
//Error message processing
}
return !isNumber;
}
Tsukkomi
The logical value (truth value) is messed up.
Logical values are very confusing, so be careful when handling them. I try to make the positive one true and the negative one false.
I somehow remembered it when I saw @ fujitanozomu's sample code, so I will add it.
Reproduction code.c
int tbl[] = {
#include <list.csv>
};
This is how to use it like this. .. .. Rough work because you understand the compilation process! ?? I tought.
Macro culture has become a basic bad law in programming languages. (Although some features remain in later languages)
I want to devote myself every day so as not to write shit code.
I'm scared because the number of views is larger than I expected. The part that is a little horny is private and seems to be a problem, so Some descriptions have been deleted.
④ was added. I just remembered it (bitter smile)
I received information from @sakuro. There seems to be a file format that was originally supposed to be included. ・ XPM-Wikipedia https://ja.wikipedia.org/wiki/XPM XPM itself seems to be the body of the C language source code.
Recommended Posts