This is not the end



  • Just encountered this error in eclipse. And I always thought a "Line End" is a rather atomic thing ...

     



  •  Have you never heard of a small company from Seattle who like to end lines with a two-character code?



  •  @pjt33 said:

     Have you never heard of a small company from Seattle who like to end lines with a two-character code?

    Speaking of, what's the sense of that, anyway? Please enlighten a young and naive CS student. They didn't really have a seperate character code to move the electron beam/daisy wheel printer carriage/whatever back to the left, did they?



  • @pjt33 said:

     Have you never heard of a small company from Seattle who like to end lines with a two-character code?

    Have you never heard of a small company from Cupertino who like to end lines with different two-character code?


  • @PSWorx said:

     [quote user="pjt33"]

     Have you never heard of a small company from Seattle who like to end lines with a two-character code?

    Speaking of, what's the sense of that, anyway? Please enlighten a young and naive CS student. They didn't really have a seperate character code to move the electron beam/daisy wheel printer carriage/whatever back to the left, did they?

    [/quote]

    Actually, they did. Windows just follows in the standards of the older DOS operating systems built for the older terminals. IIRC, the reason UNIX-like systems use LF is that C used LF as a line terminator and treated CR as whitespace.



  • @pjt33 said:

     Have you never heard of a small company from Seattle who like to end lines with a two-character code?

    From Seattle?  Are we talking about Starbucks?


  • @alegr said:

    Have you never heard of a small company from Cupertino who like to end lines with different two-character code?

    No. Enlighten me.

    Edit: Is it Sun?



  •  @MiffTheFox said:

    Actually, they did. Windows just follows in the standards of the older DOS operating systems built for the older terminals. IIRC, the reason UNIX-like systems use LF is that C used LF as a line terminator and treated CR as whitespace.

    So, when you worked on those terminals, what happened if you forgot a CR once?



  • @PSWorx said:

     [quote user="MiffTheFox"]

    Actually, they did. Windows just follows in the standards of the older DOS operating systems built for the older terminals. IIRC, the reason UNIX-like systems use LF is that C used LF as a line terminator and treated CR as whitespace.

    So, when you worked on those terminals, what happened if you forgot a CR once?

    [/quote]

    You'd move down a line but not to the beginning. For example, "aaa\nbbb":

    aaa
       bbb
    

    And "aaa\r\nbbb":

    aaa
    bbb
    


  • @MiffTheFox said:

    You'd move down a line but not to the beginning. For example, "aaa\nbbb":

    aaa
       bbb
    

    And "aaa\r\nbbb":

    aaa
    bbb
    

     

    Dammit, there go my hopes of flying screws... alright alright...;)



  • @derula said:

    @alegr said:
    Have you never heard of a small company from Cupertino who like to end lines with different two-character code?
    No. Enlighten me.

    Edit: Is it Sun?

    Mac OS used LF CR for EOL. I believe OS X follows Unix convention now.


  • @alegr said:

    Mac OS used LF CR for EOL. I believe OS X follows Unix convention now.

    Nope, it just used CR, at least judging from the output of various Classic Mac OS apps I've worked with.



  • @codeman38 said:

    @alegr said:
    Mac OS used LF CR for EOL. I believe OS X follows Unix convention now.
    Nope, it just used CR, at least judging from the output of various Classic Mac OS apps I've worked with.
    Correct.
    [quote user="wikipedia"]

     [/quote]



  •  @pjt33 said:

     Have you never heard of a small company from Seattle who like to end lines with a two-character code?

    Are you referring to Microsoft? They're from Redmond, not Seattle. (Although they're increasingly moving into Seattle, due to employee complaints about Redmond commute times.)



  • @belgariontheking said:

    CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS

    On the other hand, IIRC, RT-11 Fortran produced lines that started with LF and ended with CR.



  • @MiffTheFox said:

    UNIX-like systems use LF is that C used LF as a line terminator and treated CR as whitespace.

    I'm pretty sure UNIX terminals also treat CR the same way DOS does. Try this program:

    #include <iostream>

    int main() {
        for (int i = 0; i < 10000; ++i) {
            std::cout << "\rHello: " << i << std::flush;
        }
        std::cout << std::endl;
    }

    Also any competent text editor in Windows has no problem with either line ending type. So I don't know what the error in OP's picture is about.



  • @PSWorx said:

    Speaking of, what's the sense of that, anyway? Please enlighten a young and naive CS student. They didn't really have a seperate character code to move the electron beam/daisy wheel printer carriage/whatever back to the left, did they?

     

    Yup.

    Why CR LF, and not LF CR?

    Because the carriage took more than one character period to return to the left margin, so putting the LF second gave the CR time to complete before the next character arrived. Doing it the other way round would cause the first character of each line to appear half way across the page!

     



  • @SlyEcho said:

    I'm pretty sure UNIX terminals also treat CR the same way DOS does. Try this program:

    #include <iostream>

    int main() {
        for (int i = 0; i < 10000; ++i) {
            std::cout << "\rHello: " << i << std::flush;
        }
        std::cout << std::endl;
    }

    Also any competent text editor in Windows has no problem with either line ending type. So I don't know what the error in OP's picture is about.

     

     Are you sure that your cout is in binary mode? I think not. That editors don't make a big fuss about what convention you use, is laudable but that doesn't affect how other programs or OSes respond.

    Anyway, CR was great for underlining. You could send "Hello, world\r       _____\r\n" and the "world" would be underlined. Fantastic. Under unix you had to send "Hello, w^H_o^H_r^H_l^H_d^H_\n". Such a waste of good bytes. 



  • The CR would take 2 character times on the ASR33 teletype unless the little shutter across the shock absorbing air damper hole was covering too much of the hole in which case the carriage would still be going backwards as the first character following LF was being printed.

    Mounted on a wobbly table, the printer was quite alarming, and the regular thump of the carriage would annoy neighbours.

    That was my first printer in 1984 - it cost £0.50 and I relaxed for a couple of days before my final EE exams by rebuilding it as it had tried to eat itself and several parts were wrapped around the motor spindle inside.

     

     



  • @blakeyrat said:

    Are you referring to Microsoft? They're from Redmond, not Seattle. (Although they're increasingly moving into Seattle, due to employee complaints about Redmond commute times.)

     

    Oops. I generally just think of them as based in Washington, but I probably had something about Seattle kicking around in my subconscious.

     

    @SlyEcho said:

    Also any competent text editor in Windows has no problem with either line ending type. So I don't know what the error in OP's picture is about.


    My guess is that while it might handle LF or CR-LF it gets confused by a lone CR.



  • @PSWorx said:

     @pjt33 said:

     Have you never heard of a small company from Seattle who like to end lines with a two-character code?

    Speaking of, what's the sense of that, anyway? Please enlighten a young and naive CS student. They didn't really have a seperate character code to move the electron beam/daisy wheel printer carriage/whatever back to the left, did they?


    Yes, they did. It dates back to the days of the teletype. The purpose of separating the two was to permit formatting effects while keeping a simple transmission system: a CR followed by a series of underscores would give you underlined text; a CR and a series of hyphens gives struck-out text. A linefeed followed by an appropriate number of backspaces gives you columnar text somewhere other than the beginning of the line.



    The combination of carriage-movement and paper-movement codes could also give other effects. Character-backspace-character sequences were used to expand the available characters without needing more than 7 bits. For example, 'c' + backspace + '/' gives the 'cent' symbol, while '`', '"', '^' , and ''' could be used to give accented letters (this is half the reason why ASCII doesn't include accented letters).



  • @Carnildo said:

    Yes, they did. It dates back to the days of the teletype. The purpose of separating the two was to permit formatting effects while keeping a simple transmission system: a CR followed by a series of underscores would give you underlined text; a CR and a series of hyphens gives struck-out text. A linefeed followed by an appropriate number of backspaces gives you columnar text somewhere other than the beginning of the line.

    The combination of carriage-movement and paper-movement codes could also give other effects. Character-backspace-character sequences were used to expand the available characters without needing more than 7 bits. For example, 'c' + backspace + '/' gives the 'cent' symbol, while '`', '"', '^' , and ''' could be used to give accented letters (this is half the reason why ASCII doesn't include accented letters).

    Which just goes to show: our forebears were more clever than they generally get credit for.



  • @belgariontheking said:

    @codeman38 said:

    @alegr said:
    Mac OS used LF CR for EOL. I believe OS X follows Unix convention now.
    Nope, it just used CR, at least judging from the output of various Classic Mac OS apps I've worked with.
    Correct.
    [quote user="wikipedia"]

     

    [/quote]

    Incorrect.

    MacOS X uses just LF some places, and just CR in other places. At least as of MacOS 10.3.9, I'm pretty sure there was at least one thing that wanted CR LF.

    Note that it will treat all of the above as valid line end sequences most places, although there's a few that don't like CR LF, and a very few that insist on either CR or LF.  With each successive minor update to MacOS X, more and more stuff works with and prefers LF and fewer things will only take LF.  It is possible that the last few versions I've used have completely eliminated the use of CR LF, as I've not encountered any since 10.3.9.  It is possible that the latest MacOS has eliminated the use of CR, as I haven't yet probed under the hood to find out.  However, historically, MacOS X has definitely used a lot of CR line endings.


Log in to reply