Once you see the fucking code

Overview

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

Fucking code

① 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 **.

② Minus 10,000

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.)

③ Octopus panic

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.

④ (Addition) The power of include!

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)

that's all

I want to devote myself every day so as not to write shit code.

Postscript ① 2020/06/21 (Sun)

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.

Postscript ② 2020/06/21 (Sun)

④ was added. I just remembered it (bitter smile)

Postscript ③ 2020/06/22 (Sun)

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

Once you see the fucking code
Until you run the Apache Velocity sample code
What to do if you don't see the test code error message in the terminal console
Site where you can see the version relation of spring (?)
Post back the coupon code you used to the specified endpoint
Summarize the words you learned
Until the code is executed
When reading the source code
Java Converts disparate character codes to the same character code at once