• map (unregistered)

    s2 = s1.Replace("?", "");// still frist - can be posted

  • TheCPUWizard (unregistered)

    "An exception handler that does nothing but show the error in a message box is also bad."...

    But that is not the case here. The exception "handler" does two things... It also converts a proper exception to a return value which can (and likely will) be ignored...and that is the WTF...

    If the [pseudo code] was:

    catch exception { MessageBox(....); throw; }

    If it only showed the error message and then proceeded exactly as if it was not there, then it might still smell, but at least the sentence used in the article would not have been a WTF in and of itself.

  • ancow (unregistered) in reply to TheCPUWizard

    It leaves the result false, which isn't really an action. So yes, it only displays and then discards the Exception.

  • Vilx- (unregistered)

    And you still missed one:

    while (sr.Peek() > -1)
    {
        s1 += sr.ReadLine();
    }
    

    This thing eliminates newlines, because ReadLine() doesn't include them.

  • Dave (unregistered) in reply to TheCPUWizard

    You think ignoring a boolean "success" return value is okay? Because it isn't.

  • LCrawford (unregistered) in reply to Vilx-

    This thing eliminates newlines, because ReadLine() doesn't include them.

    But this function is designed to only read files with all lines beginning with INS so that the newlines remain.

  • CptnNitPick (unregistered)

    articleText = articleText.replace('well', 'will');

  • LeftyMiddlewright (unregistered) in reply to CptnNitPick

    articleText1 = articleText2.replace('well', 'will'); articleText2 = articleText1.replace('oone', 'one');

  • Mike Shawaluk (google)

    Still empty... after all these years.

  • (nodebb) in reply to LCrawford

    "But this function is designed to only read files with all lines beginning with INS so that the newlines remain."

    Well, except that it will insert a blank line before the first one...

  • LawrenceW (unregistered)

    "imagine if you well"

    Shouldn't that be "imagine if you will"?

  • Geek (unregistered)

    The one that stuck out to me was the second line of the replaces:

    s1 = s2.replace("", "");

    replace an empty string with an empty string???

  • Quite (unregistered) in reply to Geek

    Looks like this to me:

    s1 = s2.replace("!", "");

    ... although the instance used of the font for the bang makes it look a little odd.

  • Boyle (unregistered)

    "still empty - can be used": Note that the replacements switch from s1 to s2 and back. It seems that there was a time where the last replacement was undefined (s2 = s1.Replace("", "");) in order to have the result in s2, and that later it was used without removing the comment with the invitation.

  • Mike Shawaluk (google) in reply to Quite

    This is what I see:

    s1 = s2.Replace("", "");

    The initial character looks like a box, but I suppose it could be any unprintable character.

  • Vilx- (unregistered) in reply to LCrawford

    Except that in that case the first line now becomes an empty line. Oh, well, close enough. :D

  • Developer (unregistered)

    Fuck all of you pussy ass niggas. This is the best code in the world.

  • Zenith (unregistered)

    TRWTF is loading an entire file into memory and doing so line by line. That works until you end up with a file a couple hundred MB in size and it chokes on the replacements if not the reads.

  • (nodebb) in reply to Mike Shawaluk

    The initial character looks like a box, but I suppose it could be any unprintable character.

    Copying and pasting into NP++ I get a unit separator.

  • Hannes (unregistered)

    "At a guess, I think this must have something to do with OCR, right? It sounds like it"

    Yes, it's used to clean files after an OCR. Since all there is to read are numbers there never can be a 'G' or a 'B', instead the most likely option is that it's '6' and '8' respectivly.

    But I wonder where that s1 = s2.Replace("", ""); line comes from? Is it really from my submission? Because it's not present in the source code... I AM CONFUSED! And empty.

  • Hannes (unregistered) in reply to Hannes

    Ah yes, it it really IS from my submission. Someone (yes, most likely it was me...) removed it because in VS 2008 it looks like s2.Replace("",""); when in reality it should be s2.Replace("Unit Seperator", "");

  • Paul Neumann (unregistered)

    imagine if you well that you have a file.

    I'm not well. I'll refrain from imagining.

  • guest (unregistered)

    I'm well. I'm the only oone. I can be used.

  • Foo AKA Fooo (unregistered)

    "Think through how you might solve this."

    sed 's/INS/\nINS/g;s/G/6/g;s/B/8/g;s/[_^·:<>.£/()A?-]//g'

    No, regexes are so evil, we rather write 50 lines of WTFy code ...

  • siciac (unregistered) in reply to Foo AKA Fooo

    sed 's/INS/\nINS/g;s/G/6/g;s/B/8/g;s/[_^·:<>.£/()A?-]//g'

    Or treat regexes as an expressive language instead of deliberately writing a pile of unreadable crap:

    mapping = { 'INS':'INS\n', 'G':'6', 'B': '8', '_':'', ...}
    pattern = re.compile('|'.join(map(re.escape), mapping.keys()))
    def tidy(value):
        return pattern.sub(lambda match: mapping[match.group(0)], value)
    
  • FormalWare (unregistered)

    Imagine, if you will, that you have a life.

  • (nodebb)

    Yes, it's used to clean files after an OCR. Since all there is to read are numbers there never can be a 'G' or a 'B', instead the most likely option is that it's '6' and '8' respectivly.

    So I'll never get an O, I, Z, E, A, S, T or g then? Or other symbols I can't think of.

  • Hannes (unregistered) in reply to Zemm

    "So I'll never get an O, I, Z, E, A, S, T or g then? Or other symbols I can't think of."

    tbh, I think the OCR already is configured in a way that it only reads the text as numbers. Never seen G, B, O, I, Z... in any of those files. But I didn't configure the scan job, so I cannot say for sure. Good thing is, this atrocity of a program won't be used much longer as the client we are doing this for switches from paper to a digitalized version (about time...). There's really no need to change the program around too much now. And yes, I know that "oh it won't be used much longer anyway" has been said numerous times before and more often than not those programs would be used for years after that statement had been uttered. But since I will be leaving this company at the end of the month, this really is SEP. ;)

  • Foo AKA Fooo (unregistered) in reply to siciac

    Oh well, another smug Python user. (I have nothing against the language, but those users piss me off.)

    What you achieved is basically to replace s/A/B/g with 'A':'B', i.e. exchange a few special characters for a few different ones. And require 3 more lines of code, including a lambda, to run it. Let's say our definitions of readable differ. (If you're referring to the lack of whitespace in my example, I just omitted it for a quick post here; in real code I'd probably have added line breaks between the substitutions; then again like most people I don't know how to put line breaks in this forum. ;)

  • Anon (unregistered)

    Are submissions changed to try and omit identifying information (e.g. key string literals)? If not couldn't someone deduce the submitters real life persona if they stumbled across this?

  • Brad Wood (google)

    Honestly, the requirements are the real WTF. "Still empty, can be used" points to that; blanking out certain characters. Which characters? That's always changing "can be used".

  • DünderSmith (unregistered) in reply to Foo AKA Fooo

    a thought: what your saying about python/pythonusers basically makes python the BMW of programming languages

    as a python programmer, I'll accept that

  • Axel (unregistered)

    "oone"?

Leave a comment on “Still Empty”

Log In or post as a guest

Replying to comment #473358:

« Return to Article