It's all greek to me



  • Snippet from the huge, untiered, tear inducing behemoth that it is my unfortunate role to support and improve:

    '-æ+¤iÐ++- Ȥi ð+---- ¦+ È- ð¤Ë¤ËÈ- -+Ð-¤iË
    for i=1 to MaxItems
      k=1
        for j=2 to MaxPeriods*3 step 3
          PercentPricesArray(i,k)=PricesArray(i,k)
          if Trim(PercentPricesArray(i,k))="" then PercentPricesArray(i,k)=0
          k=k+1
        next
    next

    That is the real comment and there are a lot comments similar throughout the code. I love the fact the guy who wrote this block cared enough to write a comment. But I am worried about what he's trying to say.

    Oh and you'll notice the effective use of the step command. *3, step 3, and then using k instead of j which we increment manually by 1 each loop. I'd refactor it, but I'm worried that the ð¤Ë¤ËÈ will no longer -+Ð-¤iË



  • I think you have korean or something like that in UTF8 on your head. But that's not so bad. It's far worse then you have VB in there!



  • Yeah, looks like mojibake, using some Asian character set. I can't seem to match it to a specific character set, though, so maybe something was lost while copying it in here - it certainly doesn't match a CJK character set or a Unicode one.



  • I can't match it to anything. In fact, it looks sorta like mojibake, but the characters are too repetitive. Selective line noise?



  • Triscopic, could you post a hex dump of the original comment (and maybe a few others)?  I'm curious about what they might be.

     



  • @Pidgeot said:

    Yeah, looks like mojibake, using some Asian character set. I can't seem to match it to a specific character set, though, so maybe something was lost while copying it in here - it certainly doesn't match a CJK character set or a Unicode one.

    I'm guessing that with all the +s and -s and |s, that somehow DOS code page 850 was involved somewhere in the mangling; +, - and | often serve as substitutions for the DOS line-draw characters when translated into other encodings.

    Though why CP850 would be involved is anyone's guess...



  • @Daid said:

    But that's not so bad. It's far worse then you have VB in there!
     

     A)  Why do you feel the need to persist in bigotry against VB?

    B)  Don't assume.  It isn't VB.  VB doesn't have the (quite useful) STEP token.



  • @RonBeck62 said:

    Don't assume.  It isn't VB.  VB doesn't have the (quite useful) STEP token.
    Yes, it does.  I struggle to fathom that you don't know that.



  • @RonBeck62 said:

    VB doesn't have the (quite useful) STEP token.

    You're in unfamiliar territory, aren't ya? STEP has been available for so long, I don't even know when it was introduced. I could almost swear it was in VB 3, but I haven't used that in so long, I can't say for certain.



  • @AbbydonKrafts said:

    @RonBeck62 said:
    VB doesn't have the (quite useful) STEP token.

    You're in unfamiliar territory, aren't ya? STEP has been available for so long, I don't even know when it was introduced. I could almost swear it was in VB 3, but I haven't used that in so long, I can't say for certain.

     

    Don't I recall it being in most (if not all) flavors of BASIC as well??



  • @MasterPlanSoftware said:

    Don't I recall it being in most (if not all) flavors of BASIC as well??

    I'm not entirely up on my history of programming languages, but I'm fairly certain the dinosaurs invented the first programming language with a STEP for their for loops. The programming language was called, and here's where you'll need to correct me if I'm wrong, RRRRRRRRRRRRROAR.



  • STEP by STEP

    @MasterPlanSoftware said:

    Don't I recall it being in most (if not all) flavors of BASIC as well??

    Yep. Just for the heck of it, I just used the MESS emulator to try it on the four computers I remember most from childhood: the Apple II, the Commodore VIC-20, the TI-99/4A, and the TRS-80 Color Computer.

    Every one of them supported FOR statements with a STEP: Apple, VIC-20, TI, and TRS-80.

    Of course, according to Wikipedia, three out of those four were based on Microsoft code anyway.

    (And clearly, I have no life.)



  • Here you go...

    -æ+¤iÐ++- Ȥi ð+---- ¦+ È+¦+Ë -¤ËȤiË

    2DC7DD2BCF69D12B2B2D20D4CF6920D02B2D2D2D2D20DD2B20D42BDD2BD3202DCFD3D4CF69D3

    -æ+¤iÐ++- Ȥi ð+---- ¦+ È- ð¤Ë¤ËÈ- -+Ð-¤iË

    2DC7DD2BCF69D12B2B2D20D4CF6920D02B2D2D2D2D20DD2B20D42D20D0CFD3CFD3D42D202D2BD12DCF69D3

    -æ+¤iÐ++- Ȥi ð+---- ¦+ È+¦+Ë ð+-ÃËÃË

    2DC7DD2BCF69D12B2B2D20D4CF6920D02B2D2D2D2D20DD2B20D42BDD2BD320D02B2DC7D3C7D3

    Weirdly, my hex editor appears to render the characters differently too, e.g. Ë becomes Ó, Ã becomes Ç etc. And I can't seem to copy the non-hex data from the hex editor.



  • @RonBeck62 said:

    B)  Don't assume.  It isn't VB.  VB doesn't have the (quite useful) STEP token.

    Sorry, but it is: Classic ASP. In fact it's 2,500 files, and no sub routines.

    Oh but it's ok, because instead of subroutines we have lots and lots of:

    if (condition) then
    %><!-- #include virtual='somefile.asp' --><%
    end if

    Need the routine 4 times? No problem just repeat the above 4 times. Of course I pity the fool who tries to refactor the code to use dimensioned variables or constants because then the Dim / Const gets parsed 4 times and the page won't render.......

    I may kill myself.



  • @RonBeck62 said:

    @Daid said:

    But that's not so bad. It's far worse then you have VB in there!
     

    A)  Why do you feel the need to persist in bigotry against VB?

    B)  Don't assume.  It isn't VB.  VB doesn't have the (quite useful) STEP token.

    Hihihi.

    A) Because I see VB code on a daily basis, and usualy are the person that has to fix it?

    B) As pointed out already VB has the STEP token. I might have a copy of VB2 somewhere to check if it's in there. And I'm very sure that I have a copy of VB3. But then again, I'm VERY sure that STEP was in QBasic, and wouldn't be surprized if it was already there in GWBasic. But clearly you lack knowlage about VB, just like 90% of the VB programmers, like me :D. And THAT'S why VB is that bad. (And "On Error Resume Next")



  • @Triscopic said:

    In fact it's 2,500 files, and no sub
    routines.
    You can search much faster if you mash it all into
    one big file.  Then you can add noodles.  Mmmm, Jam!@Daid said:
    And THAT'S why VB is that bad. (And "On Error Resume Next")
    Nooooo... gotta catch them all!



  • @codeman38 said:

    @MasterPlanSoftware said:
    Don't I recall it being in most (if not all) flavors of BASIC as well??

    Yep. Just for the heck of it, I just used the MESS emulator to try it on the four computers I remember most from childhood: the Apple II, the Commodore VIC-20, the TI-99/4A, and the TRS-80 Color Computer.

    Every one of them supported FOR statements with a STEP: Apple, VIC-20, TI, and TRS-80.

     

    The original Dartmouth BASIC has STEP, so it's definitely not a Microsoft Innovation™.



  • I feel your plight, buddy (insert obligatory "I'm not your buddy/friend/guy, buddy/friend/guy" South Park reference).

    The job I'm leaving next week (finally had the balls to give notice - maybe I'll document the WTFs and submit it, it would make a great story - easily as great as Virtudyne although not as long) had a similar setup - thousands upon thousands (I think the count was somewhere around 35+) of mashed-together VBScript hackery, no Option Explicit and couldn't use it because everything would break, On Error Resume Next thrown everywhere, and it would break if you removed it because methods were called on things that didn't exist at the time it was called, no objects whatsoever, tons of include files that include other include files... you get the point.

    It's not so much that we hate VB, but the vast majority of VB out there is written by Mort hacks who don't know what the fuck they're doing, and just happily type out garbage that kinda sorta maybe works, unless you need to modify it to do something else and then it all breaks down.  Personally I enjoy using VB.NET (although I prefer C#), but at least I try to write it the proper way instead of using variable names with no vowels and a limit of eight characters, or not indenting any blocks.  People who do that shit and hack up unreadable, unmaintainable code should be, to quote Garfield the cat, dragged out into the street and shot.    



  • Ok, I have a long-shot theory.  I like codeman38's idea about [url=http://en.wikipedia.org/wiki/Code_page_850]CP850[/url] being involved.  Assume it was originally in another code page like [url=http://en.wikipedia.org/wiki/Windows-1253]Windows-1253[/url] (Greek).  Then somewhere along the line it got "converted" by something that thought it was in CP850 and wanted to produce [url=http://en.wikipedia.org/wiki/Windows-1252]Windows-1252[/url] or ISO-8859-1.  To do this it would map the box drawing characters into '+', '-' and '|'.  And it would probably convert things like 'ı' (LATIN SMALL LETTER DOTLESS I) at 0xD5 into the regular lowercase dotted i at 0x69.  Other characters that it didn't know how to map it might leave with their original representation.

    The conversion of the box drawing characters is lossy so it is hard to reverse.  But we can map 0x69 back into 0xD5 and then treat the result as Windows-1253.  I get the following for the three comments:

    • -Ηέ+ΟΥΡ++- ΤΟΥ Π+---- έ+ Τ+έ+Σ -ΟΣΤΟΥΣ
    • -Ηέ+ΟΥΡ++- ΤΟΥ Π+---- έ+ Τ- ΠΟΣΟΣΤ- -+Ρ-ΟΥΣ
    • -Ηέ+ΟΥΡ++- ΤΟΥ Π+---- έ+ Τ+έ+Σ Π+-ΗΣΗΣ

    Does anybody out there know Greek well enough to say if this looks reasonable?  Assume that the +, - and | represent unknown characters.





  • I must say I love this community. Having just converted from a lurker to a poster, I'm in awe of the way you've collectively decyphered the cryptic comments. All we need now is a greek speaker and we'd be done. Not that it matters, I've decided to kill the entire contents of the file this code is in and introduce crazy things like functions and english comments.

    FYI, good detective work. The clue was in the title of course, but the original dev (who in addition to not believing in sub routines or using the same language as the rest of the dev team, also disagreed with the ideas of normalisation, naming conventions and listening to other people) was in fact greek.



  • @Triscopic said:

    All we need now is a greek speaker and we'd be done.

    I wound if Alex speaks Greek... at least his surname is Greek. 



  • I think I've mostly got it now.  The comment

    -Ηέ+ΟΥΡ++- ΤΟΥ Π+---- έ+ Τ+έ+Σ -ΟΣΤΟΥΣ
    was originally
    ΔΗΜΙΟΥΡΓΊΑ ΤΟΥ ΠΙΘΑΝΆ ΜΕ ΤΙΜΉΣ ΚΟΣΤΟΥΣ
    which according to Google means "creation of a possible cost price". 

    The comment

    -Ηέ+ΟΥΡ++- ΤΟΥ Π+---- έ+ Τ- ΠΟΣΟΣΤ- -+Ρ-ΟΥΣ
    was originaly
    ΔΗΜΙΟΥΡΓΊΑ ΤΟΥ ΠΙΘΑΝΆ ΜΕ ΤΑ ΠΟΣΟΣΤΌ ΆΕΡΓΟΥΣ
    or "the possible creation of a percentage inactive". 

    And the comment

    -Ηέ+ΟΥΡ++- ΤΟΥ Π+---- έ+ Τ+έ+Σ Π+-ΗΣΗΣ
    was originally
    ΔΗΜΙΟΥΡΓΊΑ ΤΟΥ ΠΙΘΑΝΆ ΜΕ ΤΙΜΉΣ ΠΏΛΗΣΗΣ
    or "creation of a possible sale price"

    This is some pretty garbled stuff.  I've probably gotten a few words wrong in there but I'm willing to declare this puzzle solved unless a native Greek speaker wishes to make corrections.

     



  • And I've got a new theory about how the corruption happened.  Assume your text editor works in Windows-1252 (or similar) internally but it has an option to read/write files in other code pages.  When loading a file it does a best-effort conversion from the specified code page to Windows-1252.  When saving it does a best-effort conversion of Windows-1252 back to the specified code page.  This will change any chararacters that aren't present in both code pages but for a document that uses only a few common accented vowels it could produce acceptable results.

    If you set this text editor to use CP850 it would map the box drawing characters to available characters in Windows-1252: '+' (0x2B), '-' (0x2D), and '¦' (0xA6).  It would map "dotless i"at 0xD5 to 'i' at 0x69.  And it would map other accented vowels to their equivalent locations: Ë at 0xD3 moves to 0xCB, Ã at 0xC7 moves to 0xC3, etc.  Then when saving this file again it would map in the other direction.  The characters '+' and '-' stay the same because they are both at the same position in both code pages.  The character '¦' at 0xA6 moves to 0xDD.  The accented vowels get put back to where they were: Ë at 0xCB moves back to 0xD3, Ã at 0xC3 moves back to 0xC7, etc.

    And this is exactly what we saw when you posted the strings from your text editor along side the hex dumps.  The character that appears as a broken bar (¦) in your text editor is saved to disk as 0xDD.  The character that you see as Ë is saved as 0xD3.  The character you see as à is saved as 0xC7.  When you look at these characters in your hex editor it assumes the file is in Windows-1252 and shows the characters that are in those positions so Ë at 0xD3 is shown as Ó, and à at 0xC7 is shown as Ç.

    The net result of this when loading a file that's not CP850 but is in fact Windows-1253 is to corrupt some characters and leave undisturbed the characters that correspond to accented vowels that are available in both CP850 and Windows-1252.  This also explains why my earlier posts had a έ as a placeholder character.  The hex dump has a 0xDD there and I treated that directly as a Windows-1253 character which has έ at 0xDD.  But I needed to treat it as a CP850 character which has ¦ at 0xDD and map it to 0xA6.  I should have noticed when I said that +, -, and ¦ were representing unknown characters but I had no ¦ characters in my strings.

    So my advice here is to check the settings on your text editor and see if it is configured for CP850 for some reason.

     

     



  • You could try to look at the files with a browser.  That would let you fool around with encodings easily (Firefox: View/Character Encodings).  Of course, you'd have to get an original, unedited file first.



  • @Novus said:

    The original Dartmouth BASIC has STEP, so it's definitely not a Microsoft Innovation™.

    Even so, what is the problem with STEP?

    In C this translates to the following:

    for(int x, x< 10, x+3)



  • @KattMan said:

    In C this translates to the following:

    for(int x, x< 10, x+3)

     

    Please send codez for ColdFusion.



  • @MasterPlanSoftware said:

    @KattMan said:

    In C this translates to the following:

    for(int x, x< 10, x+3)

     

    Please send codez for ColdFusion.

    <cfloop index="x" from="0" to="10" step="3">
    More elegified code
    </cfloop>



  • @KattMan said:

    In C this translates to the following:

    for(int x, x< 10, x+3)

     

    <OverbearinglyPedantic>

    int x; 

    for(x = 0; x< 10; x+=3)

    </OverbearinglyPedantic>



  • @CodeSimian said:

    <OverbearinglyPedantic>

    int x; 

    for(x = 0; x< 10; x+=3)

    </OverbearinglyPedantic>

     

    Gentlemen... let the flamewar begin!



  • @CodeSimian said:

    @KattMan said:

    In C this translates to the following:

    for(int x, x< 10, x+3)

     

    <OverbearinglyPedantic>

    int x; 

    for(x = 0; x< 10; x+=3)

    </OverbearinglyPedantic>

    See, proof positive that bad code can be written in any language.  If only I had used the proper command separater I could have claimed it would compile.  Running it without properly initializing x would have been interesting though.



  • @MasterPlanSoftware said:

    Gentlemen... let the flamewar begin!
    In all seriousness, it is not my intention to start a flamewar.  Otherwise, why would I use a self-deprecating tag like "overbearinglypedantic"?



  • @MasterPlanSoftware said:

    @CodeSimian said:

    <OverbearinglyPedantic>

    int x; 

    for(x = 0; x< 10; x+=3)

    </OverbearinglyPedantic>

     

    Gentlemen... let the flamewar begin!

    MAGIC NUMBERS ARE BAD!


    int START = 0;
    int STOP = 10;
    int STEP = 3;
    int x;
    for(x = START; x < STOP; x+=STEP)



  • @bstorer said:

    MAGIC NUMBERS ARE BAD!

    int START = 0;
    int STOP = 10;
    int STEP = 3;
    int x;
    for(x = START; x < STOP; x+=STEP)

     

    You are such a noob.

    const int START=0;

     

    DUH!



  • @bstorer said:

    int START = 0;
    int STOP = 10;
    int STEP = 3;
    int x;
    for(x = START; x < STOP; x+=STEP)

    Getting this verbose, I want to crawl back to VB.

     



  • @bstorer said:

    MAGIC NUMBERS ARE BAD!

    int START = 0;
    int STOP = 10;
    int STEP = 3;
    int x;
    for(x = START; x < STOP; x+=STEP)

     

    So why do you use them? 

    int START;
    int STOP;
    int STEP;
    int x;
    START=STOP-STOP;
    STEP=!START+!START+!START;

    STOP=STEP+STEP+STEP+STEP/STEP;

    for(x = START; x < STOP; x+=STEP)

    See? No more numeric literals, no more magic numbers. Pure beauty. Do it like that and sooner or later you'll be famous.

     



  • @ammoQ said:

    So why do you use them? 

    int START;
    int STOP;
    int STEP;
    int x;
    START=STOP-STOP;
    STEP=!START+!START+!START;

    STOP=STEP+STEP+STEP+STEP/STEP;

    for(x = START; x < STOP; x+=STEP)

    See? No more numeric literals, no more magic numbers. Pure beauty. Do it like that and sooner or later you'll be famous.

    That is...  PURE FREAKING GENIOUS!  I mean at first I was like WTF until I realized this would actually work.  I bow down to your superior abilities.



  • @ammoQ said:

    int START;
    int STOP;
    int STEP;
    int x;
    START=STOP-STOP;
    STEP=!START+!START+!START;

    STOP=STEP+STEP+STEP+STEP/STEP;

    for(x = START; x < STOP; x+=STEP)

    See? No more numeric literals, no more magic numbers. Pure beauty. Do it like that and sooner or later you'll be famous.

    Oh, silly, silly boy. First, you assume that the factorial is part of the programming language. Second, you rely upon default variable initialization (potentially very dangerous). And third and most troubling, you are hoping that the compiler will pre-calculate this for you. Otherwise, you're foisting these computations on the user every time the program is run, resulting in a loss of NANOSECONDS every time the program is run. The solution in C++, of course, is quite evident: template meta-programming! Here's the right way to do it:

    #include <math.h>
    

    struct BASE {
    static const int value = int();
    };

    template <typename T>
    struct SUCC {
    static const int value = T::value - (~int());
    };

    int START = BASE::value;
    int STOP = SUCC< SUCC< SUCC< SUCC< SUCC< SUCC< SUCC< SUCC< SUCC< SUCC<BASE> > > > > > > > > >::value;
    int STEP = SUCC< SUCC< SUCC<BASE> > >::value;

    for(x = START; x < STOP; x+=STEP)



  • @bstorer said:

    Oh, silly, silly boy. First, you assume that the factorial is part of the programming language. Second, you rely upon default variable initialization (potentially very dangerous).

    I'm not a C++ Wizard like you are, pstorer, but I think you are confused here.  The "factorial" is actually a boolean negation.  Also, the STOP variable can contain any value as START is set by subtracting STOP from itself, thus always resulting in zero. 



  • @morbiuswilters said:

    I'm not a C++ Wizard like you are, pstorer, but I think you are confused here.  The "factorial" is actually a boolean negation.  Also, the STOP variable can contain any value as START is set by subtracting STOP from itself, thus always resulting in zero. 

    Fair enough, but that still relies upon !0 == 1, which may or may not be true. Better stick with mine anyway.



  • @bstorer said:

    Fair enough, but that still relies upon !0 == 1, which may or may not be true.

    It's true per C99 6.5.3.3(5) or C++98 5.3.1(8) and 4.5(4).



  • @bstorer said:

    Fair enough, but that still relies upon !0 == 1, which may or may not be true. Better stick with mine anyway.

     

    For use in a C++ program, your version is obviously superior. Putting C code (any sequence of characters, longer than 5, that a C compiler might understand) into a C++ program is IMO bad style and shows a lack of ambition.

    Anyway, I'm disappointed that your program doesn't make any use of operator overloading and multiple inheritance. 



  • @Spectre said:

    @bstorer said:
    Fair enough, but that still relies upon !0 == 1, which may or may not be true.

    It's true per C99 6.5.3.3(5) or C++98 5.3.1(8) and 4.5(4).

    Look, I'm trying to justify my needless complexity. Shaddup, stop stomping all over my fun, and just enjoy the massive WTF I've created for your amusement.



  • @ammoQ said:

    Anyway, I'm disappointed that your program doesn't make any use of operator overloading and multiple inheritance. 

    Aw, come on! I thought I'd given you solid gold with the T::value - (~int()); nonsense in order to avoid using + 1! Fine, I'll see what I can do...


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.