Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > C Code Editor Formatting Unix-Windows

Reply
Thread Tools

C Code Editor Formatting Unix-Windows

 
 
Kayle
Guest
Posts: n/a
 
      09-12-2003
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


 
Reply With Quote
 
 
 
 
Andreas Kahari
Guest
Posts: n/a
 
      09-12-2003
In article <Jye8b.96223$(E-Mail Removed)>, 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
 
Reply With Quote
 
 
 
 
Nathan
Guest
Posts: n/a
 
      09-12-2003
> 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


 
Reply With Quote
 
Christian Bau
Guest
Posts: n/a
 
      09-12-2003
In article <(E-Mail Removed)>,
Andreas Kahari <(E-Mail Removed)> 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_.
 
Reply With Quote
 
Andreas Kahari
Guest
Posts: n/a
 
      09-12-2003
In article
<(E-Mail Removed)>,
Christian Bau wrote:
> In article <(E-Mail Removed)>,
> Andreas Kahari <(E-Mail Removed)> 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
 
Reply With Quote
 
Kayle
Guest
Posts: n/a
 
      09-12-2003

"Nathan" <(E-Mail Removed)> wrote in message
news:bjrup6$sd4$(E-Mail Removed)...
> > 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.


 
Reply With Quote
 
E. Robert Tisdale
Guest
Posts: n/a
 
      09-12-2003
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.

 
Reply With Quote
 
Kayle
Guest
Posts: n/a
 
      09-13-2003

"E. Robert Tisdale" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WYSIWYG editor - restrict formatting? CRON HTML 1 07-20-2006 06:25 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
Need formatting options menu for formatting hard drive Mark T. Computer Support 3 11-24-2003 11:50 PM
Code formatting rules in editor thaneesh ASP .Net 0 07-02-2003 09:04 AM



Advertisments