Long Life bug : Do not use the letter 'j'



  • I am working on a legacy application, coded in Borland C++ version 5, and using Microsoft CAB files to deliver compressed 'directories' of files used in product label and document printing.  The entirety of this is a WTF and is being replaced with C#/.Net 

    These labels and documents are effectively mail-merged documents but their layout varies widely based on the content of some of the fields, and the design of the label on the product.  As most mail-merges use fairly fixed formats, a custom application was created.

    Most of the time if you wanted to show a complex label or document with a lot of text, the easy way out was to make a .BMP of the label with most of the text and simply overwrite the variable part of the text on top of blank fields on the bitmap file which was rendered underneath the text of the  document.

    Recently I decided to produce a legal document using the system - a warranty form with disclaimers. Instead of going the .BMP route I decided to format the text using the text formatting primitives. 

    The text started  "Subject to the above ..."

    Every time I printed the form it printed the word "Sub" and then a big blank space. 

    A lot of headscratching later and I found a C/C++ statement hidden in the CAB file decompressor interface 

    if (c == '\n' || c=='\j')  { /* process end of line */ };

    What makes this one truly epic is that according to the guy who wrote the code 10 years ago, the bug was in the first version of the code, and every user of the code managed to avoid the lowercase letter 'j' in any printed text constant.  

     

     

     



  • @mikedjames said:

    I am working on a legacy application, coded in Borland C++
    Hell, yeah!

    version 5
    Oh, nevermind.


  • @mikedjames said:

    A lot of headscratching later and I found a C/C++ statement hidden in the CAB file decompressor interface 

    if (c == '\n' || c=='\j')  { /* process end of line / };

    Right, that should obviously read

    if (c == '\m' || c=='\j')  { / process end of line */ };



  •  the real WTF is that he managed to type "j" instead of "r"



  • @mikedjames said:

    if (c == '\n' || c=='\j')  { /* process end of line */ };

    Does that mean he was matching on jewlines?



  • @mikedjames said:

    What makes this one truly epic is that according to the guy who wrote the code 10 years ago, the bug was in the first version of the code, and every user of the code managed to avoid the lowercase letter 'j' in any printed text constant. 

     

     

    More than likely there was another requirement that all text be uppercase.

     



  • I think I could go pretty long without using a lowercase 'j'.

    Challenge accepted!


  • Considered Harmful

    July: join jolly Jack & jejune Joe's juice jamboree! Just jam juniper juleps.



  • @joe.edwards said:

    July: join jolly Jack & jejune Joe's juice jamboree! Just jam juniper juleps.


    This entire paragraph has no lowercase letters that come between 'i' and 'k' in the alphabet. It is actually fairly surprising how uncommon that letter is. Just goes to show you that you can learn something new every day about linguistics. And yes, I recognize what letter the previous sentence started with. Before you decide to get on my case about it, please check what case the letter is. In any case, I think I could probably keep going for a really long time in this vein. Why do we even have that useless letter anyway if nobody actually uses it? Why not do as the Romans did and simply use the letter 'i' or the letter 'g' as appropriate.



  • @mikedjames said:

    I am working on a legacy application, coded in Borland C++ version 5, and using Microsoft CAB files to deliver compressed 'directories' of files used in product label and document printing.  The entirety of this is a WTF and is being replaced with C#/.Net 

    These labels and documents are effectively mail-merged documents but their layout varies widely based on the content of some of the fields, and the design of the label on the product.  As most mail-merges use fairly fixed formats, a custom application was created.

    Most of the time if you wanted to show a complex label or document with a lot of text, the easy way out was to make a .BMP of the label with most of the text and simply overwrite the variable part of the text on top of blank fields on the bitmap file which was rendered underneath the text of the  document.

    Recently I decided to produce a legal document using the system - a warranty form with disclaimers. Instead of going the .BMP route I decided to format the text using the text formatting primitives. 

    The text started  "Subject to the above ..."

    Every time I printed the form it printed the word "Sub" and then a big blank space. 

    A lot of headscratching later and I found a C/C++ statement hidden in the CAB file decompressor interface 

    if (c == '\n' || c=='\j')  { /* process end of line */ };

    What makes this one truly epic is that according to the guy who wrote the code 10 years ago, the bug was in the first version of the code, and every user of the code managed to avoid the lowercase letter 'j' in any printed text constant.

     

    OK, not being a C++ coder, I must be missing something here.  It's supposed to break on '\j', but it breaks on 'j' instead?

     



  • @Mason Wheeler said:

    OK, not being a C++ coder, I must be missing something here.  It's supposed to break on '\j', but it breaks on 'j' instead?
    '\j' does not mean anything special (like '\n' means newline, or '\r' means carriage return); it doesn't even mean ^J. The \ has no effect. '\j' == 'j'.



  • @Mason Wheeler said:

    OK, not being a C++ coder, I must be missing something here.  It's supposed to break on '\j', but it breaks on 'j' instead?

    The "j" is a typo; presumably it was meant to be '\r'. The reason this bug happens is because C (and by extension C++) is retarded. The single quotes indicate a single character, not a string. '\j' is not a valid escape sequence, so C just converts it to the single character 'j'. The compiler emits a warning while doing this. TRWTF is that apparently the OP's company compiles without warnings. (Or maybe Borland C++ Version 5 doesn't even have them..)



  • @morbiuswilters said:

    TRWTF is that apparently the OP's company compiles without warnings. (Or maybe Borland C++ Version 5 doesn't even have them..)
    Or perhaps, like some places I've worked, their code produces so many warnings that it is too difficult to find the serious ones among the ocean of trivial ones, and they are all simply ignored. Yeah, that is effectively the same as compiling without warnings, but with uglier, harder-to-read log files.



  • @Snooder said:

    Why do we even have that useless letter anyway if nobody actually uses it?

    It's worth 10 points in Scrabble.



  • @Snooder said:

    Why do we even have that useless letter anyway if nobody actually uses it?
    All the people named John, Jane, Jim and Joe would like to have a word with you. Without it, going to the john would a problem (as would being a john, I suppose, although that already poses potential legal and health problems). You would be unable to jump, and it would be a sad thing if there were no joy in the world.



  • @HardwareGeek said:

    @Snooder said:
    Why do we even have that useless letter anyway if nobody actually uses it?
    All the people named John, Jane, Jim and Joe would like to have a word with you.

    Unless you're talking about the lojban spellings of those names, they do not contain lowercase j's.



  • @Ben L. said:

    @HardwareGeek said:
    @Snooder said:
    Why do we even have that useless letter anyway if nobody actually uses it?
    All the people named John, Jane, Jim and Joe would like to have a word with you.

    Unless you're talking about the lojban spellings of those names, they do not contain lowercase j's.


    On the other hand, we could have a world without lojban.



  • @HardwareGeek said:

    All the people named John, Jane, Jim and Joe would like to have a word with you.
    It's a lower-case j, so all those people (and me) would be just fine. C is the reason many modern language are case-sensitive, that's a good enough reason for me to hate it.



  • @mikeTheLiar said:

    @Ben L. said:
    @HardwareGeek said:
    @Snooder said:
    Why do we even have that useless letter anyway if nobody actually uses it?
    All the people named John, Jane, Jim and Joe would like to have a word with you.

    Unless you're talking about the lojban spellings of those names, they do not contain lowercase j's.


    On the other hand, we could have a world without lojban.

    No price is too high to live in a world without lojban.



  • @morbiuswilters said:

    @mikeTheLiar said:
    @Ben L. said:
    @HardwareGeek said:
    @Snooder said:
    Why do we even have that useless letter anyway if nobody actually uses it?
    All the people named John, Jane, Jim and Joe would like to have a word with you.

    Unless you're talking about the lojban spellings of those names, they do not contain lowercase j's.


    On the other hand, we could have a world without lojban.

    No price is too high to live in a world without lojban.

    Let's get rid of logji and bangu.



  • @Ben L. said:

    @morbiuswilters said:
    @mikeTheLiar said:
    @Ben L. said:
    @HardwareGeek said:
    @Snooder said:
    Why do we even have that useless letter anyway if nobody actually uses it?
    All the people named John, Jane, Jim and Joe would like to have a word with you.

    Unless you're talking about the lojban spellings of those names, they do not contain lowercase j's.


    On the other hand, we could have a world without lojban.

    No price is too high to live in a world without lojban.

    Let's get rid of logji and bangu.

    Every fucking thing on those pages makes me want to stab you so much.



  • @bstorer said:

    @Ben L. said:
    @morbiuswilters said:
    @mikeTheLiar said:
    @Ben L. said:
    @HardwareGeek said:
    @Snooder said:
    Why do we even have that useless letter anyway if nobody actually uses it?
    All the people named John, Jane, Jim and Joe would like to have a word with you.

    Unless you're talking about the lojban spellings of those names, they do not contain lowercase j's.


    On the other hand, we could have a world without lojban.

    No price is too high to live in a world without lojban.

    Let's get rid of logji and bangu.

    Every fucking thing on those pages makes me want to stab you so much.
    Please. I'd be willing to contribute toward your plane fare to Milwaukee.



  • @HardwareGeek said:

    @bstorer said:
    @Ben L. said:
    @morbiuswilters said:
    @mikeTheLiar said:
    @Ben L. said:
    @HardwareGeek said:
    @Snooder said:
    Why do we even have that useless letter anyway if nobody actually uses it?
    All the people named John, Jane, Jim and Joe would like to have a word with you.

    Unless you're talking about the lojban spellings of those names, they do not contain lowercase j's.


    On the other hand, we could have a world without lojban.

    No price is too high to live in a world without lojban.

    Let's get rid of logji and bangu.

    Every fucking thing on those pages makes me want to stab you so much.
    Please. I'd be willing to contribute toward your plane fare to Milwaukee.

    Filed under: Any other contributors?, Note: This is only a (possibly feeble) attempt at humor not an actual threat or inducement of armed assault.

    Quoted for the next tag purge so you don't get arrested.



  • @HardwareGeek said:

    Filed under: Any other contributors?, Note: This is only a (possibly feeble) attempt at humor not an actual threat or inducement of armed assault.

    Fun Fact: In Common Law jurisdictions, assault is merely creating the apprehension of violence against a person. In other words, it's just a credible threat of violence and not the act of violence. If I take a swing at you, that's assault. Battery, on the other hand, is the actual act of causing violence. (An act of battery often results in both assault and battery charges or a combined charge, since inflicting violence would imply the apprehension of violence by a victim.)

    "Armed assault" (that is, threatening someone with a lethal weapon) is usually the crime of aggravated assault. Actually hurting someone with a lethal weapon is usually charged as attempted murder.

    All good stuff to know for when we throw Ben a blanket party.



  • @bstorer said:

    @Ben L. said:
    @morbiuswilters said:
    @mikeTheLiar said:
    @Ben L. said:
    @HardwareGeek said:
    @Snooder said:
    Why do we even have that useless letter anyway if nobody actually uses it?
    All the people named John, Jane, Jim and Joe would like to have a word with you.

    Unless you're talking about the lojban spellings of those names, they do not contain lowercase j's.


    On the other hand, we could have a world without lojban.

    No price is too high to live in a world without lojban.

    Let's get rid of logji and bangu.

    Every fucking thing on those pages makes me want to stab you so much.

    Wow, those two links are the equivalent of stripping naked, writing "I have Asperger's" on your chest with your own feces and running around town handing out train schedules while reciting all of the digits of Pi.



  • @morbiuswilters said:

    all of the digits of Pi
    3.[0-9]+





  • @flabdablet said:

    @morbiuswilters said:
    all of the digits of Pi
    \A0*3.[0-9]+\z

    FTFY



  • @morbiuswilters said:

    @Mason Wheeler said:
    OK, not being a C++ coder, I must be missing something here.  It's supposed to break on '\j', but it breaks on 'j' instead?

    The "j" is a typo; presumably it was meant to be '\r'.

    I thought of another possibility: the original dev had a brain fart and got conceptually confused between an escaped character and a control character. Noticing that the code wasn't detecting all line-end characters, thought 'Oh, maybe \n is translated to CR because of DOS-style line endings, I'll just check for LF (aka Ctrl-J) as well.'

    After all, 'j' and 'r' are pretty far apart on a QWERTY layout.



  • @DaveK said:

    @morbiuswilters said:
    @Mason Wheeler said:
    OK, not being a C++ coder, I must be missing something here.  It's supposed to break on '\j', but it breaks on 'j' instead?

    The "j" is a typo; presumably it was meant to be '\r'.

    I thought of another possibility: the original dev had a brain fart and got conceptually confused between an escaped character and a control character. Noticing that the code wasn't detecting all line-end characters, thought 'Oh, maybe \n is translated to CR because of DOS-style line endings, I'll just check for LF (aka Ctrl-J) as well.'

    After all, 'j' and 'r' are pretty far apart on a QWERTY layout.

    Good point.



  • @Snooder said:

    @joe.edwards said:

    July: join jolly Jack & jejune Joe's juice jamboree! Just jam juniper juleps.


    This entire paragraph has no lowercase letters that come between 'i' and 'k' in the alphabet. It is actually fairly surprising how uncommon that letter is. Just goes to show you that you can learn something new every day about linguistics. And yes, I recognize what letter the previous sentence started with. Before you decide to get on my case about it, please check what case the letter is. In any case, I think I could probably keep going for a really long time in this vein. Why do we even have that useless letter anyway if nobody actually uses it? Why not do as the Romans did and simply use the letter 'i' or the letter 'g' as appropriate.

     

    IESLETVSALLRITELIKETHEROMANSINALLCAPSVITHOVTSPACESPVNCTVATIONANDALLTHOSEVSELESSLETTERS

    HVNEEDSTHEMANIVAI

     



  • @blakeyrat said:

    I think I could go pretty long without using a lowercase 'j'.
    Challenge accepted!
    YOU CALL THAT A CHALLENGE? HAHA, YOU GOT TO BE JOKING.

     



  • @morbiuswilters said:

    @DaveK said:
    @morbiuswilters said:
    @Mason Wheeler said:
    OK, not being a C++ coder, I must be missing something here.  It's supposed to break on '\j', but it breaks on 'j' instead?

    The "j" is a typo; presumably it was meant to be '\r'.

    I thought of another possibility: the original dev had a brain fart and got conceptually confused between an escaped character and a control character. Noticing that the code wasn't detecting all line-end characters, thought 'Oh, maybe \n is translated to CR because of DOS-style line endings, I'll just check for LF (aka Ctrl-J) as well.'

    After all, 'j' and 'r' are pretty far apart on a QWERTY layout.

    Good point.

    Late, though.



  • @mikeTheLiar said:

    @Snooder said:
    Why do we even have that useless letter anyway if nobody actually uses it?

    It's worth 10 points in Scrabble.

    I'm shocked. In this hive of pedantry, no-one has yet picked up on the fact that this is wrong. J of course being worth 8 points, not 10.

    (Or maybe I'm the only sad bastard that still plays scrabble occasionally. With a proper physical board and everything.)



  • @Zagyg said:

    @mikeTheLiar said:
    @Snooder said:
    Why do we even have that useless letter anyway if nobody actually uses it?

    It's worth 10 points in Scrabble.

    I'm shocked. In this hive of pedantry, no-one has yet picked up on the fact that this is wrong. J of course being worth 8 points, not 10.

    (Or maybe I'm the only sad bastard that still plays scrabble occasionally. With a proper physical board and everything.)

    Ahem. Allow me to correct myself. It's worth 10 points in a mobile version that resembles but is legally distinct from Scrabble.


  • Trolleybus Mechanic

    @Zagyg said:

    (Or maybe I'm the only sad bastard that still plays scrabble occasionally. With a proper physical board and everything.)
     

    That reminds me of a WTF I've meant to post. Was in a store and say "Words with Friends: The Board Game".

    So it's a board game-- based off a video game-- which is based off a board game.

    I can't wait for the video game adaptation of the Pac-Man Board Game.


  • Discourse touched me in a no-no place

    @Zagyg said:

    In this hive of pedantry, no-one has yet picked up on the fact that this is wrong. J of course being worth 8 points, not 10.
    I believe that might also depend on what language you're using. I'm informed that Z is much lower scoring in Polish, for example.



  • @Lorne Kates said:

    @Zagyg said:

    (Or maybe I'm the only sad bastard that still plays scrabble occasionally. With a proper physical board and everything.)
     

    That reminds me of a WTF I've meant to post. Was in a store and say "Words with Friends: The Board Game".

    So it's a board game-- based off a video game-- which is based off a board game.

    I can't wait for the video game adaptation of the Pac-Man Board Game.

    Clearly you never played Street Fighter: The Movie.



  • @mikeTheLiar said:

    Ahem. Allow me to correct myself. It's worth 10 points in a mobile version that resembles but is legally distinct from Scrabble.

    Ahh I see. Personally, I've never seen the attraction to board games / card games etc. in electronic form - even the ones that lend themselves to it such as chess & poker. As for the likes of Monopoly - nice way to rip the soul out of a product. (this is of course the old fart in me talking again).

    I wonder what made them think Scrabble's judgement that J was 8 not 10 was off. Have they re-scored many other letters?

    @dkf said:

    I believe that might also depend on what language you're using. I'm informed that Z is much lower scoring in Polish, for example.

    Very true, [url]http://en.wikipedia.org/wiki/Scrabble_letter_distributions[/url]. And since I was the one being sarcastic about Pedantry, I suppose I should have qualified this.



  • @Zagyg said:

    Ahh I see. Personally, I've never seen the attraction to board games / card games etc. in electronic form - even the ones that lend themselves to it such as chess & poker. As for the likes of Monopoly - nice way to rip the soul out of a product. (this is of course the old fart in me talking again).


    I actually like online monopoly. Mostly because it's the only way to get a game together without having your friends tar and feather you afterward for being "too cheap" when you stack 5 hotels on Baltic and Mediterranean avenue. Plus, it's much more difficult for the dealer to steal hundreds out of the till.

     



  • @Snooder said:

    I actually like online monopoly. Mostly because it's the only way to get a game together without having your friends tar and feather you afterward for being "too cheap" when you stack 5 hotels on Baltic and Mediterranean avenue. Plus, it's much more difficult for the dealer to steal hundreds out of the till.

    Why? It's well designed to make the point that it is supposed to, but that point wasn't being fun to play. I mean I understand playing it online being better than playing in the same room as someone but that doesn't explain why you are playing a shitty game in the first place. Pick up some actually good board games.



  • @locallunatic said:

    @Snooder said:
    I actually like online monopoly. Mostly because it's the only way to get a game together without having your friends tar and feather you afterward for being "too cheap" when you stack 5 hotels on Baltic and Mediterranean avenue. Plus, it's much more difficult for the dealer to steal hundreds out of the till.
    Why? It's well designed to make the point that it is supposed to, but that point wasn't being fun to play. I mean I understand playing it online being better than playing in the same room as someone but that doesn't explain why you are playing a shitty game in the first place. Pick up some actually good board games.


    I LIKE monopoly. Mostly because I like being a capitalist selfish prick, and monopoly is a great way to explore that particular fantasy. Backroom deals, secret collusion, cornering a market and using your iron control to crush all the upstarts who dare to trespass on your property... It's an amazing game.



  • @Snooder said:

    I LIKE monopoly.
    Yes. I've never played it online, but I like it enough that I have, a few times, started to write a framework for developing Monopoly-like computer mediated board games. Never got very far with it, though.@Snooder said:
    Mostly because I like being a capitalist selfish prick
    As opposed to a Socialist selfish prick, which are not as rare as socialist economic theory would like to pretend.



  • @Snooder said:

    I LIKE monopoly. Mostly because I like being a capitalist selfish prick, and monopoly is a great way to explore that particular fantasy. Backroom deals, secret collusion, cornering a market and using your iron control to crush all the upstarts who dare to trespass on your property... It's an amazing game.

    Nicely put - that was kind of my point. The game itself is ... meh. But what brings it alive is the human interaction - the deals & collusions (and depending on who you are playing with, watching out for cheats and thieves, which may or may not be "acceptable" (friendly family game vs bunch-of-mates game)). So when you port it over to a device, which is often done with just the core rules in tact, you lose almost everything that makes the game fun.

    Back in a previous life I used to play MTG like an addict, when it was very new. Someone introduced me to the online game, fucking hated it. Completely soulless, and like certain online Multiplayer games*, riddled with retards and fucking idiots.

    *Some online games seemed to really suffer from retard overload, and some seemed to largely avoid it. Dunno if that's still true these days. Never could figure out the common factor - what made the retards flock to one over the other.


  • Trolleybus Mechanic

    @bstorer said:

    Clearly you never played Street Fighter: The Movie.
     

    I hope they release a Street Fighter: The Movie: The Video Game expansion for the CCG!


Log in to reply