Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #62966 > unrolled thread

Re: Searching online "indent"

Started byIan Collins <ian-news@hotmail.com>
First post2015-06-04 15:54 +1200
Last post2015-06-05 07:23 +1200
Articles 12 — 7 participants

Back to article view | Back to comp.lang.c

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Searching online "indent" Ian Collins <ian-news@hotmail.com> - 2015-06-04 15:54 +1200
    Re: Searching online "indent" "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-06-04 07:22 -0700
    Re: Searching online "indent" "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-06-04 08:55 -0700
    Re: Searching online "indent" "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-06-04 09:35 -0700
    Re: Searching online "indent" Etienne Prud'homme <e.e.f.prudhomme@gmail.com> - 2015-06-04 12:59 -0400
      Re: Searching online "indent" Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-04 19:43 +0100
        Re: Searching online "indent" Etienne <e.e.f.prudhomme@gmail.com> - 2015-06-04 15:09 -0400
        Re: Searching online "indent" James Kuyper <jameskuyper@verizon.net> - 2015-06-04 16:52 -0400
        Re: Searching online "indent" Morris Dovey <mrdovey@iedu.com> - 2015-06-04 16:37 -0500
          Re: Searching online "indent" James Kuyper <jameskuyper@verizon.net> - 2015-06-04 18:02 -0400
            Re: Searching online "indent" Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-04 23:37 +0100
    Re: Searching online "indent" Ian Collins <ian-news@hotmail.com> - 2015-06-05 07:23 +1200

#62966 — Re: Searching online "indent"

FromIan Collins <ian-news@hotmail.com>
Date2015-06-04 15:54 +1200
SubjectRe: Searching online "indent"
Message-ID<cta0gdFr31aU1@mid.individual.net>
Stefan Ram wrote:
>    Do you know a website that is an online beautifier /
>    reformatter / pretty printer / indent for C that
>    totally reformats source code (including the choice
>    of where a line begins and ends) with output in 1TBS?
>
>    For example, it should accept input with all the program on
>    a long line with 8000 characters on this line (except
>    preprocessor directives, which are one separate lines) or
>    one token per line (with many very short lines) and then
>    create a readable listing with reasonable line lengths from it.
>
>    If you don't know an online version, 2nd best solution would
>    be a small download for Windows that can be run without
>    installation (»portable«) with a GUI, say an editor with a
>    reformatter. Eclipse with a plugin might do this, but I'd
>    like a download much smaller than Eclipse.

Netbeans (and probably most other IDEs) will.

-- 
Ian Collins

[toc] | [next] | [standalone]


#62968

From"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Date2015-06-04 07:22 -0700
Message-ID<8823b353-13f3-4b02-8afe-1e0b7278a2c1@googlegroups.com>
In reply to#62966
On Wednesday, June 3, 2015 at 11:55:05 PM UTC-4, Ian Collins wrote:
> Stefan Ram wrote:
> >    Do you know a website that is an online beautifier /
> >    reformatter / pretty printer / indent for C that
> >    totally reformats source code (including the choice
> >    of where a line begins and ends) with output in 1TBS?
> >
> >    For example, it should accept input with all the program on
> >    a long line with 8000 characters on this line (except
> >    preprocessor directives, which are one separate lines) or
> >    one token per line (with many very short lines) and then
> >    create a readable listing with reasonable line lengths from it.
> >
> >    If you don't know an online version, 2nd best solution would
> >    be a small download for Windows that can be run without
> >    installation (»portable«) with a GUI, say an editor with a
> >    reformatter. Eclipse with a plugin might do this, but I'd
> >    like a download much smaller than Eclipse.
> 
> Netbeans (and probably most other IDEs) will.
> 
> -- 
> Ian Collins

I have used Netbeans to format C/C++ code.  It has a wide variety of
custom settings.  The Netbeans ANSI style/format (with a few custom
settings) produces source code which is very close to the way I write
code. There are also options for Linux and GNU styles.

Netbeans also has a GCC/GDB interface for writing and debugging C/C++
apps.  It is usable, but I mostly use it only for Java, and for source
code formatting.

Best regards,
Rick C. Hodgin

[toc] | [prev] | [next] | [standalone]


#62970

From"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Date2015-06-04 08:55 -0700
Message-ID<1aeac467-f1f7-4bca-8f5a-4f11507b9ef9@googlegroups.com>
In reply to#62966
On Thursday, June 4, 2015 at 11:00:58 AM UTC-4, Stefan Ram wrote:
> Ian Collins <ian-news@hotmail.com> writes:
> >Netbeans (and probably most other IDEs) will.
> 
>   Yesterday, I was in a classroom looking for an on-line
>   beautifier. Since I did not find one appropriate, I indeed
>   did open Netbeans, which happened to be installed in that
>   classroom. However, I had the impression that it only did
>   support Java projects. I even was searching for »C« under the
>   project types of »other«, but did not find it. 
> 
>   Netbeans would be a great solution, because it often is 
>   installed in the classrooms where I need the beautfier!
>   But the problem is: I can't find out how to enable its
>   »C language mode«.

If you go to the add-ons, there is a C module.  Once it is
loaded the functionality is included.

Netbeans 7.x and later are all I've used, but they've all
had it.

Best regards,
Rick C. Hodgin

[toc] | [prev] | [next] | [standalone]


#62971

From"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Date2015-06-04 09:35 -0700
Message-ID<7e49e9b6-e230-4cf5-a477-b870c5b707ba@googlegroups.com>
In reply to#62966
On Thursday, June 4, 2015 at 11:00:58 AM UTC-4, Stefan Ram wrote:
> Ian Collins <ian-news@hotmail.com> writes:
> >Netbeans (and probably most other IDEs) will.
> 
>   Yesterday, I was in a classroom looking for an on-line
>   beautifier. Since I did not find one appropriate, I indeed
>   did open Netbeans, which happened to be installed in that
>   classroom. However, I had the impression that it only did
>   support Java projects. I even was searching for »C« under the
>   project types of »other«, but did not find it. 
> 
>   Netbeans would be a great solution, because it often is 
>   installed in the classrooms where I need the beautfier!
>   But the problem is: I can't find out how to enable its
>   »C language mode«.

You can also directly download the C/C++ version:
https://netbeans.org/downloads/

63MB on Windows.  62MB on Linux.

Best regards,
Rick C. Hodgin

[toc] | [prev] | [next] | [standalone]


#62972

FromEtienne Prud'homme <e.e.f.prudhomme@gmail.com>
Date2015-06-04 12:59 -0400
Message-ID<20150604125943.8fa4c0b46f4ab3a05bda7d8f@gmail.com>
In reply to#62966
On 4 Jun 2015 15:00:50 GMT
ram@zedat.fu-berlin.de (Stefan Ram) wrote:

> Ian Collins <ian-news@hotmail.com> writes:
> >Netbeans (and probably most other IDEs) will.
> 
>   Yesterday, I was in a classroom looking for an on-line
>   beautifier. Since I did not find one appropriate, I indeed
>   did open Netbeans, which happened to be installed in that
>   classroom. However, I had the impression that it only did
>   support Java projects. I even was searching for »C« under the
>   project types of »other«, but did not find it. 
> 
>   Netbeans would be a great solution, because it often is 
>   installed in the classrooms where I need the beautfier!
>   But the problem is: I can't find out how to enable its
>   »C language mode«.
> 

   It's not online,  but I would recommand emacs. You  press [Alt]-x &
tap indent-buffer. You can also bind  a key to that command, but since
it's not  really used, I  would not. You  may set different  styles of
indentation. K&R, GNU, etc. You can also indent a region.

   For  an  online  tools, I  don't  really  know  for  C. I  went  on
prettyprinter.de  & it  does  the job.  Not perfect,  but  a search  &
replace removes unnecessary spaces.

-- 
Etienne

[toc] | [prev] | [next] | [standalone]


#62976

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2015-06-04 19:43 +0100
Message-ID<87oakvnwlk.fsf@bsb.me.uk>
In reply to#62972
Etienne Prud'homme <e.e.f.prudhomme@gmail.com> writes:

> On 4 Jun 2015 15:00:50 GMT
> ram@zedat.fu-berlin.de (Stefan Ram) wrote:
>
>> Ian Collins <ian-news@hotmail.com> writes:
>> >Netbeans (and probably most other IDEs) will.
>> 
>>   Yesterday, I was in a classroom looking for an on-line
>>   beautifier. Since I did not find one appropriate, I indeed
>>   did open Netbeans, which happened to be installed in that
>>   classroom. However, I had the impression that it only did
>>   support Java projects. I even was searching for »C« under the
>>   project types of »other«, but did not find it. 
>> 
>>   Netbeans would be a great solution, because it often is 
>>   installed in the classrooms where I need the beautfier!
>>   But the problem is: I can't find out how to enable its
>>   »C language mode«.
>> 
>
>    It's not online,  but I would recommand emacs. You  press [Alt]-x &
> tap indent-buffer.

(not available in my Emacs -- indent-region, yes, but not indent-buffer)

> You can also bind  a key to that command, but since
> it's not  really used, I  would not. You  may set different  styles of
> indentation. K&R, GNU, etc. You can also indent a region.

But I don't think this does what the OP wants.  Emacs indents line by
line, so if the line breaks are gone, or you've got odd lines already
(such as if (x) y = x; else x = y; all on one line) it won't split the
statement and indent the result.  The commonly used indent command has
the same restriction.

That requirement got snipped so it's easy to have missed it.  I wonder
if the suggestion to use NetBeans has the same flaw.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#62978

FromEtienne <e.e.f.prudhomme@gmail.com>
Date2015-06-04 15:09 -0400
Message-ID<20150604150928.4070e369a16f79445d924119@gmail.com>
In reply to#62976
On Thu, 04 Jun 2015 19:43:03 +0100
Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:

> >    It's not online,  but I would recommand emacs. You  press [Alt]-x &
> > tap indent-buffer.
> 
> (not available in my Emacs -- indent-region, yes, but not indent-buffer)
   Sorry, you're totally right. I took that function from a portion of
preclude.

> But I don't think this does what the OP wants.  Emacs indents line by
> line
   You're right again.  There are a lot of tweaks  in my config files.
There's  gnu indent.  It's pretty  powerful,  but that's  not part  of
emacs.

   Again sorry. I've  edited my config file some time  ago, so I don't
remember all what I did.

-- 
Etienne

[toc] | [prev] | [next] | [standalone]


#62980

FromJames Kuyper <jameskuyper@verizon.net>
Date2015-06-04 16:52 -0400
Message-ID<5570BAA7.2020907@verizon.net>
In reply to#62976
On 06/04/2015 02:58 PM, Stefan Ram wrote:
> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>> That requirement got snipped so it's easy to have missed it.  I wonder
>> if the suggestion to use NetBeans has the same flaw.
> 
>   Yeah. I want to totally neutralize any formatting decision
>   made by the original author. That is, two source codes that
>   have the same sequence of tokens but were formatted by
>   different authors should give the same result.

That's an understandable goal, but the tools I've used that had anything
close to that ability, didn't go quite that far. The tool I'm most
familiar with is GNU indent: it will insert line breaks where required
by the style rules that it is applying, including maximum line lengths,
and will remove line breaks that are prohibited by that style, and will
break up overly long lines - but it will not merge short lines. Without
such mergers, the normalization you're hoping to achieve won't happen.
Personally, I don't mind, because I sometimes insert more newlines than
be explained by any hard-and-fast style rule, in order to emphasize some
aspect of the structure of my statements that isn't covered by any of
those rules.

[toc] | [prev] | [next] | [standalone]


#62981

FromMorris Dovey <mrdovey@iedu.com>
Date2015-06-04 16:37 -0500
Message-ID<mkqgds$kau$1@speranza.aioe.org>
In reply to#62976
On 6/4/15 1:58 PM, Stefan Ram wrote:
>    Yeah. I want to totally neutralize any formatting decision
>    made by the original author. That is, two source codes that
>    have the same sequence of tokens but were formatted by
>    different authors should give the same result.

Hmm – does that mean discarding all comments?

Will you also want to detect variations of sequencing e.g.

    int a, b;
    int a; int b;
    int b; int a;
    int b, a;

and similar?

-- 
Morris Dovey
http://www.iedu.com/Solar

[toc] | [prev] | [next] | [standalone]


#62983

FromJames Kuyper <jameskuyper@verizon.net>
Date2015-06-04 18:02 -0400
Message-ID<5570CAE3.4090108@verizon.net>
In reply to#62981
On 06/04/2015 05:52 PM, Stefan Ram wrote:
> Morris Dovey <mrdovey@iedu.com> writes:

[Reinstate clipped material]
> On 6/4/15 1:58 PM, Stefan Ram wrote:
>>    Yeah. I want to totally neutralize any formatting decision
>>    made by the original author. That is, two source codes that
>>    have the same sequence of tokens but were formatted by
>>    different authors should give the same result.
[end reinstatement]

>> does that mean discarding all comments?
> 
>   Comments should be retained and even handled with care
>   as their meaning might depend on their formatting.
>   So, comments should be changed as little as possible.

Note: the standard considers comments to be white space, rather than
tokens, so two files can have the same sequence of tokens even if they
are commented differently. Therefore, you'll need to make appropriate
changes to your description of the desired behavior.

[toc] | [prev] | [next] | [standalone]


#62985

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2015-06-04 23:37 +0100
Message-ID<876173nlqg.fsf@bsb.me.uk>
In reply to#62983
ram@zedat.fu-berlin.de (Stefan Ram) writes:

> James Kuyper <jameskuyper@verizon.net> writes:
>>           two files can have the same sequence of tokens even if they
>>are commented differently. Therefore, you'll need to make appropriate
>>changes to your description of the desired behavior.
>
>   Thanks for the correction!
>
>>Note: the standard considers comments to be white space, rather than
>
>   I know, I treat this topic in each of my beginner's courses and
>   explain that instead of:
>
> - -65
>
>   one also can write
>
> -/**/-65
>
>   but not
>
> --65
>
>   or show this piece of ASCII-art that I created:
>
>
> white space component
>                                                   .-------------.
> | |----.----------------------------------------->| space       |----.--->| |
>        |                                          '-------------'    ^
>        |                                                             |
>        |                                          .-------------.    |
>        '-------------------------------------.--->| line ending |--->'
>        |                                     ^    '-------------'    |
>        |                                     |                       |
>        v                                     |                       |
>       .-.                                    |                       |
>      ( / )                                   |                       |
>       '-'                                    |                       |
>        |                                     |                       |
>        |     .-.                             |                       |
>        '--->( / )---.------------------------'                       |
>        |     '-'    ^                        |                       |
>        |            |   .---------------.    |                       |
>        |            |   | any character |    |                       |
>        |            '---| except of a   |<---'                       |
>        |                | line ending   |                            |
>        |                '---------------'                            |
>        |                                                             |
>        |                .---------------.                            |
>        |                | any character |                            |
>        |            .---| except "*"    |<--------.                  |
>        |            |   | and "/"       |         |                  |
>        |            |   '---------------'         |                  |
>        |     .-.    v                             |                  |
>        '--->( * )---'-----------------------------'                  |
>              '-'    |            ^                ^                  |
>                     |            |                |                  |
>                     |            |                |                  |
>                     .<-----------.                |                  |
>                     |            |                |                  |
>                     |     .-.    |                |                  |
>                     '--->( / )---'   .------------.                  |
>                     |     '-'        |            |                  |
>                     |                |            |                  |
>                     |                v     .-.    |    .-.           |
>                     '----------------'--->( * )---'---( / )----------'
>                                            '-'         '-'

Consider:

int main(void) /\
* comment *\
/
/\
/ comment\
  comment
{
}

but maybe you deal with joined lines at another layer of processing.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#62979

FromIan Collins <ian-news@hotmail.com>
Date2015-06-05 07:23 +1200
Message-ID<ctbmt6Fr31aU2@mid.individual.net>
In reply to#62966
Stefan Ram wrote:
> Ian Collins <ian-news@hotmail.com> writes:
>> Netbeans (and probably most other IDEs) will.
>
>    Yesterday, I was in a classroom looking for an on-line
>    beautifier. Since I did not find one appropriate, I indeed
>    did open Netbeans, which happened to be installed in that
>    classroom. However, I had the impression that it only did
>    support Java projects. I even was searching for »C« under the
>    project types of »other«, but did not find it.
>
>    Netbeans would be a great solution, because it often is
>    installed in the classrooms where I need the beautfier!
>    But the problem is: I can't find out how to enable its
>    »C language mode«.

Tools -> Plugins select C/C++.

-- 
Ian Collins

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c


csiph-web