C source code formatter: looking for a good one - Page 2

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Re: C source code formatter: looking for a good one
Quoted text here. Click to load it
                          ^^^^^^^^^^^^^^^^^
A double negative negating the desired meaning of a sentance
is very common among non-native English speakers or the well
unedutaced.

--
Trevor Barton

Re: C source code formatter: looking for a good one

Quoted text here. Click to load it

Sentance? unedutaced?

Are you the same guy that applied for a programming job who signed off his
resume with "I am willing to lern"?

Peter




Re: C source code formatter: looking for a good one

Quoted text here. Click to load it

That's *well* unedutaced. As opposed to poorly unedutaced.
Quoted text here. Click to load it

--
Al Balmer
Balmer Consulting
We've slightly trimmed the long signature. Click to see the full one.
Re: C source code formatter: looking for a good one
Quoted text here. Click to load it

LOL.  It was first thing in the morning, and I was somewhat irritated
at the tone of the person to whom I was responding ;-)

--
Trevor Barton

Re: C source code formatter: looking for a good one
Quoted text here. Click to load it

Or those who were sloppy in editing their message :-)  But my
spelling is better'n yours, yar har yar har :-) (sentence,
educate).

--
Chuck F ( snipped-for-privacy@yahoo.com) ( snipped-for-privacy@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
We've slightly trimmed the long signature. Click to see the full one.
Re: C source code formatter: looking for a good one



Quoted text here. Click to load it

Hi Chuck,

 I downloaded and compiled your uncomnt.zip: it works! Thanks.
 I made some minor changes in order to read files from the
 disk and not from the standard input.

ciao
 Enrico

--
 ***********************************************************
 * Enrico Migliore - Co-founder and Senior Software Engineer
 *
We've slightly trimmed the long signature. Click to see the full one.
Re: C source code formatter: looking for a good one
[...]

Quoted text here. Click to load it

.. which in turn can be a major clue to understanding the code itself,
since typical errors are a major input for digging into somebody
else's way of thinking.  Sometimes you need that such a model of their
mind to decipher the code coming from it.  Which proves one of the
wisdoms I've gathered so far: it never pays to throw away information.

OTOH, such code _may_ yet better be thrown away right along with the
comments, and rewritten from scratch, if deadlines permit.

Quoted text here. Click to load it

I am, of course, in the former class (being German), and do hope to be
in the second, i.e. after resolving the double negation: the
reasonably well educated. ;-) But every now and then, one of those
"false friends" still gets me.  Thanks for pointing it out --- will
try to remember not to do that any more.

--
Hans-Bernhard Broeker ( snipped-for-privacy@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Re: C source code formatter: looking for a good one
[...]

Quoted text here. Click to load it

.. which in turn can be a major clue to understanding the code itself,
since typical errors are a major input for digging into somebody
else's way of thinking.  Sometimes you need such a model of their mind
to decipher the code coming from it.  Which proves one of the wisdoms
I've gathered so far: it never pays to throw away information.

OTOH, such code _may_ yet better be thrown away right along with the
comments, and rewritten from scratch, if deadlines permit.

Quoted text here. Click to load it

I am, of course, in the former class (being German), and do hope to be
in the second, i.e. after resolving the double negation: the
reasonably well educated. ;-) But every now and then, one of those
"false friends" still gets me.  Thanks for pointing it out --- will
try to remember not to do that any more.

--
Hans-Bernhard Broeker ( snipped-for-privacy@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Re: C source code formatter: looking for a good one



Quoted text here. Click to load it

Hi Bryan,

 there are two reasons:

 1. the MISRA industry guidelines say that the production code should
     be free of any comment.

 2. My customer wants two versions of the code I'm writing for him:
     the commented and a "clean" one.


 Enrico


Re: C source code formatter: looking for a good one


Quoted text here. Click to load it

I've never looked into MISRA, and probably never will, but this is very
strange. Who came up with that and why?

My code is free of comments by the time the compiler gets it.

Quoted text here. Click to load it


Re: C source code formatter: looking for a good one


snip

Quoted text here. Click to load it

Hello Enrico

I think you may have misunderstood the MISRA guidelines.
I checked mine (dated April 1998) and on page 23 it refers to comments under
Rules 7.3

it says:
Rule 9 (required)   Comments shall not be nested

Rule 10 (advisory) Sections of code should not be 'commented out'

Perhaps there is a newer version - please let me know because I can't think
of any reason at all (and I mean ANY) to deliberately use two different
source code's for the same project - which do you test ?

Michael Kellett






Re: C source code formatter: looking for a good one
Quoted text here. Click to load it

Well, no comments at all would certainly satisfy r10 and r9 ;)


Given the level of C competence of most of the MISRA committee
(in one draft I saw plenty of the examples weren't even in legal C)...
who knows what they *meant*?

MISRA have taken years to turn Les Hatton's excellent work on Safer C
into a morass of mealy-mouthed 'guidelines'.

pete
--
snipped-for-privacy@fenelon.com "there's no room for enigmas in built-up areas."

Re: C source code formatter: looking for a good one


[...]
Quoted text here. Click to load it

IMHO, that indicates it's high time for a customer upgrade...  If they
want to have a comment-stripped version, but can't trust their own
skill to strip the comments off the master source by themselves, so
they have to ask you to provide it, odds they're in way over their
heads.

Quoted text here. Click to load it

Exactly.  And even worse: what would make them believe that the test
results of one version have anything to do with those of the other, if
they can't replicate the mapping between those two?

And quoting MISRA:

Quoted text here. Click to load it

A slightly strange rule IMHO, given that nested comments never existed
in standard C in the first place.

Quoted text here. Click to load it

This rule seems too vague to be applicable.  What does 'commented out'
mean (#ifdef SOMETHING / #if 0 / only /* ... */ comments)? What
exactly is a "section of code" (as opposed to a normal comment block,
or a line of code)?  And why did they want to put one of these in
quotes, but not the other?

--
Hans-Bernhard Broeker ( snipped-for-privacy@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Re: C source code formatter: looking for a good one


[...]
Quoted text here. Click to load it

IMHO, that indicates it's high time for a customer upgrade...  If they
want to have a comment-stripped version, but can't trust their own
skills to strip the comments off the master source by themselves, so
they have to ask you to provide it, odds are they're in way over their
heads.

Quoted text here. Click to load it

Exactly.  And even worse: what would make them believe that the test
results of one version have anything to do with those of the other, if
they can't replicate the mapping between those two?

And quoting MISRA:

Quoted text here. Click to load it

A slightly strange rule IMHO, given that nested comments never existed
in standard C in the first place.

Quoted text here. Click to load it

This rule seems too vague to be applicable.  What does 'commented out'
mean (#ifdef SOMETHING / #if 0 / only /* ... */ comments)? What
exactly is a "section of code" (as opposed to a normal comment block,
or a line of code)?  And why did they want to put one of these in
quotes, but not the other?

--
Hans-Bernhard Broeker ( snipped-for-privacy@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Re: C source code formatter: looking for a good one
On 5 Dec 2003 17:24:35 GMT, Hans-Bernhard Broeker

[...]
Quoted text here. Click to load it

Actually, it's just redundant.  Rule 1 is "ISO 9899 C only," and since
ISO C doesn't allow nested comments, this is covered.  

MISRA is full of little directives that are essentially "don't make
this typo in your code."  One of my favorites is the one (rule 85)
saying that a function that takes no parameters must be called with
empty parentheses.  E.g. given something like

   extern int ok_to_continue(void);

use this:

   if (ok_to_continue() != FALSE)

and not this:

   if (ok_to_continue != FALSE)

Note that rule 85 is only advisory...

Quoted text here. Click to load it

Having the explanations helps sometimes.  In this particular case,
they are attempting to prevent accidentally nested comments, and
explicitly say that using #if or #ifdef to conditionally compile a
section of code is OK.

Sometimes the explanations don't help.  For example, rule 29
(required) is "The use of a tag shall agree with its declaration."
The full explanation given in the document is

   "Where a tag has been given in the declaration of a structure,
    union or enumeration type, all subsequent uses of the tag shall be
    consistent with the declaration. For example, it would be
    incorrect to initialise the tag with an initialiser which did not
    match the structure declared for that tag. "

I *think* that means "Don't access any field of a structure that
doesn't exist," but I'm not sure.

Mostly, I ignore such rules since they're impossible to break anyway.

I've said it before, but linting your code will produce far better
results than blindly following any coding guideline.  IMHO, and IME.

Regards,

                               -=Dave
--
Change is inevitable, progress is not.

Re: C source code formatter: looking for a good one
Quoted text here. Click to load it

FWIW, according to contributors to the safety critical mail list
( snipped-for-privacy@cs.york.ac.uk hosted out of the Univ of York,) the MISRA
quidelines are in the process of a major re-write to further restrict C
features that are prone to abuse, e.g., bizarre casts that compile but don't
necessarilly generate reasonable/accurate results.  MISRA C V2 is listed on
the MISRA website as available Q1 2004.

--
Scott
Validated Software Corp.



Re: C source code formatter: looking for a good one
Quoted text here. Click to load it

Maybe SCO is involved?  :^P

--
Ron Sharp.



Re: C source code formatter: looking for a good one

Quoted text here. Click to load it

I think there is a strong argument for wanting to strip comments out IF it
is to review the code. If the code looks meaningless without comments then
you are going to have serious problems. I have come across many instances
where unsuitable variable names are used repeatedly or the same variable is
used in many places (within the same scope) for different things. The more I
think about it the more I like the idea of looking at the code without
comments to see it stands up for itself. After all, the compiler does not
look at the comments when validating an expression.

Regards
Sergio Masci

http://www.xcprod.com/titan/XCSB - optimising structured PIC BASIC compiler



Re: C source code formatter: looking for a good one

Quoted text here. Click to load it

See http://www.semdesigns.com/Products/Formatters/index.html .
Our C formatter can do both of these tasks trivially.

I'd guess from your interest in stripping comments
that you might be interested in obfuscating the source.
The same page will lead to a link to C obfuscating tools.


--
Ira D. Baxter, Ph.D., CTO   512-250-1018
Semantic Designs, Inc.      www.semdesigns.com




We've slightly trimmed the long signature. Click to see the full one.
Re: C source code formatter: looking for a good one
On Fri, 5 Dec 2003 08:22:45 -0600, "Ira Baxter"

Quoted text here. Click to load it

Not needed; that capability was designed into the language.

John


Site Timeline