C Code Editor Formatting Unix-Windows

Discussion in 'C Programming' started by Kayle, Sep 12, 2003.

  1. Kayle

    Kayle Guest

    For preservation of indentation when moving the C source file from Windows
    to Linux machine, what is the advice to format the code.
    Should the code formatted using spaces instead of tabs?
    When opened using nedit in Linux, the indentation was not preserved, or
    should we limit the length of each line ?

    Any advice on this ? Thanks
     
    Kayle, Sep 12, 2003
    #1
    1. Advertising

  2. In article <Jye8b.96223$>, Kayle wrote:
    > For preservation of indentation when moving the C source file from Windows
    > to Linux machine, what is the advice to format the code.
    > Should the code formatted using spaces instead of tabs?
    > When opened using nedit in Linux, the indentation was not preserved, or
    > should we limit the length of each line ?
    >
    > Any advice on this ? Thanks
    >
    >


    [off-topic]
    The formatting of the code has no impact on the functionality
    of the program. The indentation should be such that the code
    is readable, but whether you use tabs or spaces (or, like me, a
    mix of them) is not important unless you're working in a group
    with weird formatting requierments. Hmmm... regarding the line
    length. The line length is not really important either. Keep
    it short to increase readability.

    Consult system specific groups for questions regarding porting
    non-standard functionality.


    [on-topic]
    A standard related question for the group: I'm reading the
    rationale for section 7.19.2, which says that C99 increased the
    minimum maximum line length from 254 to 4095, but the standard
    itself says in 7.19.2 ("Streams") nothing about 4095... Is there
    a mismatch here between the standard and the rationale?

    I'm not sure this has anything to do with the length of lines in
    a program source. Does it?

    --
    Andreas Kähäri
     
    Andreas Kahari, Sep 12, 2003
    #2
    1. Advertising

  3. Kayle

    Nathan Guest

    > For preservation of indentation when moving the C source file from Windows
    > to Linux machine, what is the advice to format the code.
    > Should the code formatted using spaces instead of tabs?
    > When opened using nedit in Linux, the indentation was not preserved, or
    > should we limit the length of each line ?
    >
    > Any advice on this ? Thanks


    I've configured my editor to replace tabs by spaces, in that case you don't
    have such problems with formats when using your files on other platforms or
    in other editors. The length of each line could make the layout of your code
    look a bit strange if your editor wraps lines.

    Regards,
    Nathan
     
    Nathan, Sep 12, 2003
    #3
  4. In article <>,
    Andreas Kahari <> wrote:

    > [on-topic]
    > A standard related question for the group: I'm reading the
    > rationale for section 7.19.2, which says that C99 increased the
    > minimum maximum line length from 254 to 4095, but the standard
    > itself says in 7.19.2 ("Streams") nothing about 4095... Is there
    > a mismatch here between the standard and the rationale?
    >
    > I'm not sure this has anything to do with the length of lines in
    > a program source. Does it?


    Why would capabilities of streams have anything to do with properties of
    the language? Capabilities of streams would be interesting to know if
    you write a compiler for _any_ language in C and use streams to read
    source lines. But a compiler for the C language can be written in any
    language you wish to use. The limit for a C source line is there to make
    life easier for people writing C compilers _in any language they
    choose_.
     
    Christian Bau, Sep 12, 2003
    #4
  5. In article
    <>,
    Christian Bau wrote:
    > In article <>,
    > Andreas Kahari <> wrote:
    >
    >> [on-topic]
    >> A standard related question for the group: I'm reading the
    >> rationale for section 7.19.2, which says that C99 increased the
    >> minimum maximum line length from 254 to 4095, but the standard
    >> itself says in 7.19.2 ("Streams") nothing about 4095... Is there
    >> a mismatch here between the standard and the rationale?
    >>
    >> I'm not sure this has anything to do with the length of lines in
    >> a program source. Does it?

    >
    > Why would capabilities of streams have anything to do with properties of
    > the language? Capabilities of streams would be interesting to know if
    > you write a compiler for _any_ language in C and use streams to read
    > source lines. But a compiler for the C language can be written in any
    > language you wish to use. The limit for a C source line is there to make
    > life easier for people writing C compilers _in any language they
    > choose_.


    That's what I thought, good.

    As it happens, I found the place where the standard says that
    the maximum length of a logical source line is 4095 (section
    5.2.4.1), which happens to correspond to the maximum length of
    a line in a stream, according to the rationale anyway. The
    values conincide, which is probably so that one *could* parse a
    C source file with a program written in C.

    Is the rationale out of sync with the standard regarding the
    maximum line length in a stream?

    --
    Andreas Kähäri
     
    Andreas Kahari, Sep 12, 2003
    #5
  6. Kayle

    Kayle Guest

    "Nathan" <> wrote in message
    news:bjrup6$sd4$...
    > > For preservation of indentation when moving the C source file from

    Windows
    > > to Linux machine, what is the advice to format the code.
    > > Should the code formatted using spaces instead of tabs?
    > > When opened using nedit in Linux, the indentation was not preserved, or
    > > should we limit the length of each line ?
    > >
    > > Any advice on this ? Thanks

    >
    > I've configured my editor to replace tabs by spaces, in that case you

    don't
    > have such problems with formats when using your files on other platforms

    or
    > in other editors. The length of each line could make the layout of your

    code
    > look a bit strange if your editor wraps lines.
    >
    > Regards,
    > Nathan
    >
    >


    Thanks Nathan.
     
    Kayle, Sep 12, 2003
    #6
  7. Off Topic: C Code Editor Formatting Unix-Windows

    Kayle wrote:

    > For preservation of indentation when moving the C source file
    > from Windows to Linux machine, what is the advice to format the code.
    > Should the code formatted using spaces instead of tabs?
    > When opened using nedit in Linux, the indentation was not preserved.
    > Or should we limit the length of each line?


    Read the man pages for expand and unexpand.
    They will help you convert the tabs to the correct number of spaces.

    Also, read your man page for nedit.

    -tabs n
    Set tab stops every n characters.
     
    E. Robert Tisdale, Sep 12, 2003
    #7
  8. Kayle

    Kayle Guest

    Re: Off Topic: C Code Editor Formatting Unix-Windows

    "E. Robert Tisdale" <> wrote in message
    news:...
    > Kayle wrote:
    >
    > > For preservation of indentation when moving the C source file
    > > from Windows to Linux machine, what is the advice to format the code.
    > > Should the code formatted using spaces instead of tabs?
    > > When opened using nedit in Linux, the indentation was not preserved.
    > > Or should we limit the length of each line?

    >
    > Read the man pages for expand and unexpand.
    > They will help you convert the tabs to the correct number of spaces.
    >
    > Also, read your man page for nedit.
    >
    > -tabs n
    > Set tab stops every n characters.
    >


    The question is not how to set the tab or expand/unexpand.
    It is how to preserve the format when transferring the C code between
    Windows and Unix machine.

    Thank you for giving comments.
     
    Kayle, Sep 13, 2003
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. thaneesh

    Code formatting rules in editor

    thaneesh, Jul 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,192
    thaneesh
    Jul 2, 2003
  2. Stylus Studio
    Replies:
    0
    Views:
    775
    Stylus Studio
    Aug 3, 2004
  3. Replies:
    12
    Views:
    1,705
    Dave Thompson
    Jan 10, 2005
  4. Replies:
    18
    Views:
    663
    Dave Thompson
    Jan 10, 2005
  5. Robert Wallace

    my own perl "dos->unix"/"unix->dos"

    Robert Wallace, Jan 21, 2004, in forum: Perl Misc
    Replies:
    7
    Views:
    316
    Michele Dondi
    Jan 22, 2004
Loading...

Share This Page