473,698 Members | 2,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: reformat to tool/editor-compliant C style?

On 4 Jul, 15:26, Hallvard B Furuseth <h.b.furus...@u sit.uio.nowrote :
I'd like to reformat an open source package (OpenLDAP) to a new C style.
8M code, 0.3M lines. With some currently hopeless formatting rules like
tab-width=4.
what's wrong with that?!

I'm sure that made sense once to save disk space for the
source code, or something:-(
wouldn't replacing spaces with tabs do that? Were disks ever
*that* small? I've worked on old mini-computers and even
then we didn't try to save space at the *source* level.
The project's normal rule is "don't
reformat unnecessarily" since it makes source control merge/diff
difficult.
use a decent configuration control system and make sure
you don't mix source code changes with reformats. Clearly label
the reformat versions.

can't help you with indent

<snip>

--
Nick Keighley
Jul 4 '08 #1
18 2843
Nick Keighley writes:
On 4 Jul, 15:26, Hallvard B Furuseth <h.b.furus...@u sit.uio.nowrote :
>I'd like to reformat an open source package (OpenLDAP) to a new C style.
8M code, 0.3M lines. With some currently hopeless formatting rules like
tab-width=4.

what's wrong with that?!
Tab width 8 is the norm elsewhere, at least in the Unix world and with
published ASCII text. So some code gets written with tab-width 4, some
with 8. Even if everyone sets indentation = tab-width, code still gets
misaligned. This written with tab-width 4 (I've substituted spaces):

int foo; /* hi there */
const char *barbaz[256]; /* and here */

becomes this when displayed with tab-width 8:

int foo; /* hi there */
const char *barbaz[256]; /* and here */
>I'm sure that made sense once to save disk space for the
source code, or something:-(

wouldn't replacing spaces with tabs do that?
Not if tab width indentation level. (e.g. 8 and 4).
Were disks ever *that* small? I've worked on old mini-computers and
even then we didn't try to save space at the *source* level.
Who knows. If the point was not to save space, I have no idea at all
what the point was.
>The project's normal rule is "don't reformat unnecessarily" since it
makes source control merge/diff difficult.

use a decent configuration control system and make sure
you don't mix source code changes with reformats. Clearly label
the reformat versions.
Actually I'm not sure what a configuration control system is, as opposed
to source control. This project is still using CVS, and I'm not going
to fight about that. In any case the reformatting changes will
certainly not pay attention to the "don't reformat" rule:-)

--
Hallvard
Jul 4 '08 #2
Hallvard B Furuseth schrieb:
Who knows. If the point was not to save space, I have no idea at all
what the point was.
The point of using tabs is that everyone can easily convert to something
convenient. I find a value of 4 spaces perfect, some prefer 2, some
prefer 8. I've also seen 3.

You suggest that you switch to 8 spaces (i.e. no tabs) which seems to me
like a really not that good idea. After all everyone should be able to
display it the way he/she wants - not the way the programmer liked it.
Code indented by spaces is an annoying pest, IMHO.

Regards,
Johannes

--
"Wer etwas kritisiert muss es noch lange nicht selber besser können. Es
reicht zu wissen, daß andere es besser können und andere es auch
besser machen um einen Vergleich zu bringen." - Wolfgang Gerber
in de.sci.electron ics <47************ ***********@new s.freenet.de>
Jul 4 '08 #3
You suggest that you switch to 8 spaces (i.e. no tabs) which seems to me
like a really not that good idea. After all everyone should be able to
display it the way he/she wants - not the way the programmer liked it.
Code indented by spaces is an annoying pest, IMHO.
If you wish to maintain vertical aligment for whatever reason, then
you have to use spaces.

Of course having vertical alignment in source code is a matter of
personal taste

Reducing indent (tab) size increases the number of nested blocks that
dont require line wrapping, or allows the use of longer variable
names.

Increasing the indent size reduces the risk of vertical alignment
being upset if the tab size is changed as possibly only a single tab
is required to maintain alignment
Jul 4 '08 #4
On Fri, 4 Jul 2008 08:07:45 -0700 (PDT), Nick Keighley
<ni************ ******@hotmail. comwrote in comp.lang.c:
On 4 Jul, 15:26, Hallvard B Furuseth <h.b.furus...@u sit.uio.nowrote :
I'd like to reformat an open source package (OpenLDAP) to a new C style.
8M code, 0.3M lines. With some currently hopeless formatting rules like
tab-width=4.

what's wrong with that?!

I'm sure that made sense once to save disk space for the
source code, or something:-(

wouldn't replacing spaces with tabs do that? Were disks ever
*that* small? I've worked on old mini-computers and even
then we didn't try to save space at the *source* level.
Apparently you never coded C under CP/M 80 on single density 8" floppy
disks.

Or Pascal on early micros where the storage medium was a cassette
tape. I say Pascal, because I don't actually remember a
cassette-based C for the original TRS-80.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Jul 5 '08 #5
Jack Klein wrote:
On Fri, 4 Jul 2008 08:07:45 -0700 (PDT), Nick Keighley
<ni************ ******@hotmail. comwrote in comp.lang.c:
>On 4 Jul, 15:26, Hallvard B Furuseth <h.b.furus...@u sit.uio.nowrote :
>>I'd like to reformat an open source package (OpenLDAP) to a new C style.
8M code, 0.3M lines. With some currently hopeless formatting rules like
tab-width=4.
what's wrong with that?!

>>I'm sure that made sense once to save disk space for the
source code, or something:-(
wouldn't replacing spaces with tabs do that? Were disks ever
*that* small? I've worked on old mini-computers and even
then we didn't try to save space at the *source* level.

Apparently you never coded C under CP/M 80 on single density 8" floppy
disks.
Forget the disks, getting the source in memory was enough of a challenge!

--
Ian Collins.
Jul 5 '08 #6
Johannes Bauer wrote:
Hallvard B Furuseth schrieb:
>Who knows. If the point was not to save space, I have no idea at all
what the point was.

The point of using tabs is that everyone can easily convert to something
convenient. I find a value of 4 spaces perfect, some prefer 2, some
prefer 8. I've also seen 3.
Fortran lives !!
Jul 5 '08 #7
Hallvard B Furuseth wrote:
Nick Keighley writes:
>On 4 Jul, 15:26, Hallvard B Furuseth <h.b.furus...@u sit.uio.nowrote :
>>I'd like to reformat an open source package (OpenLDAP) to a new C style.
8M code, 0.3M lines. With some currently hopeless formatting rules like
tab-width=4.
what's wrong with that?!

Tab width 8 is the norm elsewhere, at least in the Unix world and with
published ASCII text.
Er no, but thats a religious war so don't go there.

So some code gets written with tab-width 4, some
with 8. Even if everyone sets indentation = tab-width, code still gets
misaligned. This written with tab-width 4 (I've substituted spaces):

int foo; /* hi there */
const char *barbaz[256]; /* and here */

becomes this when displayed with tab-width 8:

int foo; /* hi there */
const char *barbaz[256]; /* and here */
So reset your editor to use tab widths of 4. Job done.
Jul 5 '08 #8
Mark McIntyre wrote:
>Hallvard B Furuseth wrote:
> So some code gets written with tab-width 4, some
with 8. Even if everyone sets indentation = tab-width, code still gets
misaligned. This written with tab-width 4 (I've substituted spaces):
int foo; /* hi there */
const char *barbaz[256]; /* and here */
becomes this when displayed with tab-width 8:
int foo; /* hi there */
const char *barbaz[256]; /* and here */

So reset your editor to use tab widths of 4. Job done.
I should have clarified: The code was _originally_ written with tab
width 4. But by now it's sprinkled with quite a bit written with tab
widht 8. Open-source project, several authors... So it gets wrong
either way.

--
Hallvard
Jul 5 '08 #9
I should have clarified: The code was _originally_ written with tab
width 4. But by now it's sprinkled with quite a bit written with tab
widht 8. Open-source project, several authors... So it gets wrong
either way.
That doesn't make sense to me. A Tab is a tab - your editor should
convert 0x09 into whatever tabspace you've defined in your editor.

Presumably you mean that some moron has tab-to-spaced your code twice,
once at 4s/t and once at 8s/t.

In which case why not just run it through indent, setting appropriate
tabs (not spaces)?

Jul 6 '08 #10

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

Similar topics

10
2027
by: Paul Kooistra | last post by:
I need a tool to browse text files with a size of 10-20 Mb. These files have a fixed record length of 800 bytes (CR/LF), and containt records used to create printed pages by an external company. Each line (record) contains an 2-character identifier, like 'A0' or 'C1'. The identifier identifies the record format for the line, thereby allowing different record formats to be used in a textfile. For example: An A0 record may consist of:
3
2160
by: Just Curious | last post by:
Hello, I am doing some XSLT tranformations. I have a pretty complicated XML document with high level of nesting. I am looking for a tool that gives me the "hierarchial path" to the element I select for example if in the xml below - I select <City>XY</City> - I want to get "Address/Address/City" <Addresses> <Address>
11
2489
by: Shiperton Henethe | last post by:
Dreamweaver 4 Hi Can anyone recommend a decent utility for compressing HTML that is safe - i.e. that *definitely* doesn't mess with the appearance in any browsers. I run a growing website whose pages are inexorably getting too "heavy".
14
6886
by: Akseli Mäki | last post by:
Hi, Hopefully this is not too much offtopic. I'm working on a FAQ. I want to make two versions of it, plain text and HTML. I'm looking for a tool that will make a plain text doc out of the HTML doc. The HTML version doesn't have anything fancy, just internal links. So the tool must be able to delete internal links and anchors from the HTML version, but leave external links in simplified form. That is, the HTML version would say <a...
3
1564
by: Xiaopeng Xiong | last post by:
If there is any command for formatting all files under a directory, that would be best. But currently, formatting a single file is enough for me. I just can not type TAB at each line. Thanks a lot! -- Xiaopeng Xiong
32
2960
by: Roman | last post by:
Hello group, I'm wondering which authoring tool would be most flexible and useful for large websites using only html, css and javascrip. So far I've tried Dreamweaver MX, but have heard BBEdit is also good. What do you think?
14
2043
by: Rajnish | last post by:
Hi C experts, Please suggest me best c programming language tool, which is like Jbuilder (for java) which suggest all avilable methods etc on typing the object. Best regards, Rajnish
3
1791
by: Tina | last post by:
Does anyone know of an asp.net general purpose table editing tool that will allow users to add modify and delete data? Thanks, T
2
1404
by: BigDave | last post by:
For a previous employer, I did a lot of BizTalk 2004 development, but am no longer doing so, and do not even have BizTalk installed. One of the things I miss is the BizTalk Scheme Editor, and how it displayed elements in a vertical tree. (Visual Studio 2005 Schema Editor and XMLSpy seem to want to display elements in a horizontal tree, and to me, not as elegantly). Does anyone know if the BizTalk Schema Editor can be obtained and used
13
2427
by: dmarrese | last post by:
I am a parent volunteer for a swim team website (makoswim.org) and am looking for a recommendation for a new web authoring tool . While I am technically oriented and have somehave some knowledge of HTML but not a deep techie. I want to give this site an extreme makeover. The tool I've been using has probably outlived it's usefulness (IBM Websphere Home Page Builder - out of support). I need something easy to use. I'd like to add...
0
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.