News for hackers. Stuff that matters.
Re:Obfuscated Tiny C Compiler by vermilingua on Monday February 15, 2021 @06:42AM (#26141793)
I thought I could follow at least some of the unobsfucated C, and then this monstrosity:

    t = "++#m--%am*@R<^1c/@%[_[H3c%@%[_[[email protected]#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!=\'g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b";
Could someone please explain what is going on in that routine?
Re:Obfuscated Tiny C Compiler by edflsafoiewq on Monday February 15, 2021 @08:00AM (#26142302)
Based on the unobfuscated source, this is a lookup table of some kind for operators, encoded in a string.

  ++   -> tokl=11 tokc=0x1
  --   -> tokl=11 tokc=0xff
  *    -> tokl=1 tokc=0xc1af
  /    -> tokl=1 tokc=0xf9f7
  %    -> tokl=1 tokc=0xf9f7
  +    -> tokl=2 tokc=0xc801
  -    -> tokl=2 tokc=0xd8f7
  <<   -> tokl=3 tokc=0xe0d3
  >>   -> tokl=3 tokc=0xf8d3
  ...
  !    -> tokl=2 tokc=0x4
  *    -> tokl=0 tokc=0x0
For example

  *@R<^1c
  ^^       operator (padded with @ when one character)
    ^^^^   tokc (variable length)
        ^  tokl
Re:Obfuscated Tiny C Compiler by bombcar on Monday February 15, 2021 @06:49AM (#26141850)
T is being assigned a string value that looks like line noise. I assume it's Perl.
Re:Obfuscated Tiny C Compiler by userbinator on Monday February 15, 2021 @06:04PM (#26148810)
It's funny to see the Perl comparison when APL-family languages normally have code that looks like that:

https://github.com/Co-dfns/Co-dfns/tree/master/cmp

Re:Obfuscated Tiny C Compiler by johnisgood on Tuesday February 16, 2021 @07:27PM (#26160931)
Rust is more unreadable to me than Perl, in all fairness.
Re:Obfuscated Tiny C Compiler by hu3 on Monday February 15, 2021 @07:08AM (#26141971)
Haha. Thanks I needed that Monday morning laugh.
Re:Obfuscated Tiny C Compiler by xashor on Monday February 15, 2021 @08:00AM (#26142303)
It's part of the tokenizer. t contains data in the format of [char 0][char 1][base 64 encoded token id …], whereas the id is as long as the entry is smaller than 'b'. So it's ('++', `#m`), ('--', `%am`), ('*@', 'R<^1c'), and so on. '@' is used as a wildcard. As you can see this part parses operators.
Re:Obfuscated Tiny C Compiler by jedisct1 on Monday February 15, 2021 @06:47AM (#26141838)
Looks like a type definition in Rust.
Re:Obfuscated Tiny C Compiler by scoutt on Monday February 15, 2021 @10:05AM (#26143356)
If it doesn't end with .unwrap() then it isn't Rust.
Re:Obfuscated Tiny C Compiler by cztomsik on Wednesday February 17, 2021 @04:45PM (#26172216)
true :(
Re:Obfuscated Tiny C Compiler by neilalexander on Monday February 15, 2021 @06:52AM (#26141864)
This made me smile :-)
Re:Obfuscated Tiny C Compiler by caf on Monday February 15, 2021 @08:11AM (#26142382)
It's looking for operators. That string encodes the operator to look for, and the values of tokl and tokc that will be used if that operator is found.

The first entry looks for "++", and if found sets tokc to 1 ('#' - 'b' + 64) and tokl to 11 ('m' - 'b').

The second entry looks for "--" and if found sets tokc to 255 and tokl to 11.

The third entry looks for "*" and if found sets tokc to 12693263 and tokl to 1. (12693263 is 0xc1af0f, which is an x86 IMUL instruction).

Re:Obfuscated Tiny C Compiler by eimrine on Monday February 15, 2021 @07:24AM (#26142055)
I would like to look at the code after preprocessing, it is too hard to analyze the code with all those #define statements.
Re:Obfuscated Tiny C Compiler by archi42 on Monday February 15, 2021 @08:01AM (#26142310)
First thought would be "opcodes", but on a closer look the operators in there seem to be relevant. Maybe this encodes their meaning/relevant opcode and precedence?

From the website:

``` binary operators, by decreasing priority order: '*' '/' '%', '+' '-', '>>' '<<', '<' '<=' '>' '>=', '==' '!=', '&', '^', '|', '=', '&&', '||'. ```

The unary operators ++ and -- have a higher precedence, so they come first. Then there are "*@R<^1c", "/@%[_[H3c", "%@%[_[H3c" (same as for '/', though), "[email protected]#d" and so.

I did not have time to read the source (my compile finished a minute ago), but maybe you can now figure out the rest? :)

//edit: ha, edflsafoiewq and xashor we're a bit faster and more thorough. But nice to see we agree on the overall idea.

Re:Obfuscated Tiny C Compiler by coldtea on Monday February 15, 2021 @12:04PM (#26144563)
Isn't it obvious? /s