r/badcode •

[deleted by user]

[deleted] — view deleted post

0 Upvotes

87 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Jan 02 '19

Good god that was silly to read - well done.

2

u/Tynach Jan 02 '19 edited Jan 02 '19

Honestly, most of the work I did was in tie(). The junk in anothr() and howmnyx() was after I finished butchering the concat operation, and when my idea for how to make it work didn't quite actually work, I started just flipping things at random until it started working.

Incidentally this is exactly how an actually bad coder would do things, but.. Well, I had tie() concatenate backwards as just a slap to conventions, and my anothr() and howmnyx() logic only started working correctly when I started putting the data in... The correct way? f and s are meant to be 'first' and 'second' (and n being 'next'), but I kinda lost track.

Actually, while typing this post here, I realized that I didn't switch semantics from first/next around when I started to build the string backwards. Ok.

... Yeah, this is some whack code I wrote. And I still don't know where that extra space at the start comes from. I'm guessing it comes from something I do in tie(), as I purposefully ensured that the memory management/pointer math was full of off-by-one errors and a lack of null terminators.

Edit: By the way, I hope the comments aren't helpful! I wasn't sure if // ad on2 etc was too much of a hint for the purpose of cnt. Was tempted to make the comment just // cntr 4 thngs or something, but ultimately went with trying to get people to confuse it with aded and ader (the latter of which I initially wrote as ads, but couldn't justify it being that within the mind of a simply unskilled developer).