473,326 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

C Code Editor Formatting Unix-Windows

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
Nov 13 '05 #1
7 4027
In article <Jy*******************@news-server.bigpond.net.au>, 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
Nov 13 '05 #2
> 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
Nov 13 '05 #3
In article <sl*********************@vinland.freeshell.org>,
Andreas Kahari <ak*******@freeshell.org> 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_.
Nov 13 '05 #4
In article
<ch*********************************@slb-newsm1.svr.pol.co.uk>,
Christian Bau wrote:
In article <sl*********************@vinland.freeshell.org>,
Andreas Kahari <ak*******@freeshell.org> 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
Nov 13 '05 #5

"Nathan" <na******@hotmail.com> wrote in message
news:bj**********@www-2.dev.ict.nl...
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.
Nov 13 '05 #6
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.

Nov 13 '05 #7

"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:3F************@jpl.nasa.gov...
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.
Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mike Kamermans | last post by:
I hope someone can help me, because what I'm going through at the moment trying to edit XML documents is enough to make me want to never edit XML again. I'm looking for an XML editor that has a...
3
by: Ike | last post by:
Does anyone know where I can find example scritp for formatting text input? I want to have a text box where only legitiamte filesname under unix can be netered (no whitespace, only alphanumeric,...
1
by: enrio | last post by:
I have made a number of changes to the code of an access 2000 application, and now the person responsible for the application wants to import one change at a time into his "master copy", after he...
9
by: Axel Dahmen | last post by:
I've just read about the new Whidbey, which I think gives great features to the programmer. The HTML editor comes with a bunch of great formatting options. It'd be great if C# would get some of...
4
by: Ken Allen | last post by:
While I like many of the features of the C# editor in Visual Studio, the default control for indentation drives me nuts! Regardless of how I lay it out, the editor frequently reformats my code! ...
12
by: Jacob Crossley | last post by:
Please tell me there is a way to prevent this annoyance ; - ) I'm into writing perfectly indented html, but the .net dev environment is being overzealous and messing up my html formatting. for...
135
by: Xah Lee | last post by:
Tabs versus Spaces in Source Code Xah Lee, 2006-05-13 In coding a computer program, there's often the choices of tabs or spaces for code indentation. There is a large amount of confusion about...
1
by: Sven Fischer | last post by:
After installation of Visual CSharp Studio the current settings of the source code editor are not suitable for me. The brackets are automaticlly set in front of the lines e.g. if (.......) {...
6
by: Brian Schwartz | last post by:
Quick question related to Visual Studio's automatic code formatting. Often I like to write my variable declarations with spacing to line them up, like this (not sure if this spacing will come out...
10
by: Greg Lovern | last post by:
I have a very large html table created by MS Word, saved as it's "Web Page, Filtered" file type. Every html table cell has lots of formatting tags. Most of the file size is that formatting. Is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.