- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
With that last example you realise that syntax highlighting in code editors us such a blessing.
Admin
The first one is stupid, the second one looks like it stems from a misunderstanding of how C handles strings, and the third looks like it's a server-side script where you can just change the comment markers to change the response of the web server. Of course, it would be clearer to just put // at the beginning of two of the lines.
Admin
That last one is centainly one of the most confusing ways to do commenting...
Admin
I'm getting tired of reading: this is just stupid is not a WTF!!!
Well for me the first example is a big WTF, a little more of WTFness and the example could go to college, graduate, work in finnancial institutions, marry and have children by means of copulating with female WTFs.
Admin
I think the first one was actually attempting to make each item point to a seperate instance of "\nDEFAULT", and went about it in quite a bizarre way.
Admin
/* First! /* The real WTF*//is the forum software. / I personally like those small SoD, // Where is the wooden*///table?/keep them coming. / They need FILE_NOT_FOUND Captcha: tastey */
Admin
if true what is the point? what is more = new String("\nDEFAULT"); would have accomplished that... I think
Admin
Why do you say first when the first post was an hour before you?
Admin
The WTF is that in polish "dupa" (as in strdupa()) means "ASS".
Admin
9th
Admin
That 'First!' was commented out. Can't you read?!?
Admin
psh! everyone knows it should be this:
ignorant fools!
Admin
or even:
buffer[0] ='\0'; prependString(buffer,string)
You can take my CAPTCHA from my cold dead hands!
Admin
that was awesome!!! I had to paste it into my emacs window to read it!!!
Um, I can imagine a backwards compiler that parsed that wrong, thinking it's a nested comment and like having a stack of /*. but if it happened i'd have to kill myself.
Admin
err, the last line is ridiculous... strcpy already takes care of the ending NUL char... rtfm and in case it wouldnt, strlen() would not help as strlen also looks for the NUL char (which isnt there, its probably somewhere out of the memory allocated to that variable) and you would overwrite another NUL (pretty damn good change for access violation)
Admin
strdupa...
dupa means arse in polish.
Admin
Hear the "wwwoooshh" sound? That's the other posters joke going right over your head.
Admin
Admin
forgot to quote the comment:
my comment was for this, not the articleAdmin
using Java:
Admin
Admin
Admin
Damn: gotta start proofreading before posting...
Admin
yeah... he's new here
Admin
It looks like VB, which is on .NET now, which means that all strings are interned. So any two references to the string "\nDEFAULT", no matter how they were constructed, will point to the same exact string objects in the string store.
Admin
I don't believe that VB.NET interns all strings. C# certainly doesn't. For instance:
string x = "hello"; string y = "hel"+"lo"; string tmp = "hel"; string z = tmp+"lo";
x and y now refer to the same strings. z refers to a different string.
Jon
Admin
Bah. If only people used "safe" string functions, there would be no such problems:
Admin
I especially like how the coder has used double-quotes, so there are actually two null bytes. Possibly the extra one is for redundancy, in case cosmic radition flips a bit in the first one? Or maybe it's for unicode support! Genius!!!!1
Admin
Neither does VB.NET (which uses largely the same libraries after all):
prints
so only the string literals were interned. Sorry for the bad layout, but the WTFish forum software inserts
elements into
Admin
strfry()?
I thought that was only for text manipulation on Chinese web sites.
Admin
Strings can cut both ways. Null terminators perplex; re-write it in Perl.
Admin
As per yesterday's example this should be:
Admin
Admin
Hehe, That's a new one. I've never seen someone try to append the already present null terminator...
Admin
Admin
If you read the whole thing, he's aping the WTF memes.
Admin
And don't forget to free it when done!
Admin
c-strings < g-strings (and i'm not talking about music...)
Admin
Things are going to get very entertaining around here, real soon now.
Admin
Pleeeeease be joking... strcpy() may be THE single easiest function in C to implement. You simply CANNOT work on a platform where you have to guard against it possibly not working. If you can't trust it, supply your own... period! The other str* functions are trickier, yes, but seriously; broken strcpy()? Really?
Admin
On some early systems I did maintence on, some programmers would write:
char buffer[16];
for (i = 0; i < 16; i++) buffer[i] = '\0'; strcpy(buffer, "Some String");
There would be houndreds of example of this idiom in the program.
Crash Magnet
Admin
No, I think that strlen is easier.
Not to mention wrong anyway if strcpy doesn't append the null character.
Addendum (2007-04-19 17:58): Yes, that strlen is wrong. I'm an idiot. "Thanks" to iMalc for pointing that out. ;-)
Admin
clbuttic :)
6?
I suppose if you're being really picky you could complain about "i" being an int instead of size_t. But I have unilaterally decided that's not a wtf, because I'd probably do that do :)
Admin
Admin
flame-on!
Admin
I was actually more stunned by the implicit suggestion (based on the response to a previous post), that one deal with the possibility of broken str* functions by manually null terminating after each use. That is a vile thought! :)
But yes, especially with "optimizations", I suppose I can imagine a broken strcpy(). But the canonical, unoptimized (arguably) K&R versions are small and easy to carry around with you, until you prove the library versions correct. Working with broken C string functions is like trying to write a story without consonants or vowels.
Admin
Admin
I'm not quite familiar with that language, looks like python to me, but it seems that for the first line, and first line only, it would add what was in sb before the loop, then add "\nDEFAULT" for every other line.
It's definately obfuscated though.
For instanct, say sb contained "Test". It would hit the while, append "\nDEFAULT" to "Test" making "Test\nDEFAULT" and add that as the first index, then until indexN add just "DEFAULT".
Or am I seeing the code wrong? Without seeing the whole program, more specifically what was in sb before this while loop was hit, it would be hard to say.
Admin
It's VB.NET and yeah, that's what it does. The first time through the loop could be special because sb could have something in it from before. The subsequent times through the loop it just puts "\nDEFAULT" in.
However, the user of a StringBuilder there is definitely overkill.
Admin
btw, your strlen is broken. I've never seen anyone use chars 1 thru 10 to terminate a string before.