Unix Programming - Beautify code

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2007 > Beautify code





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Beautify code
Anurag

2007-05-18, 1:23 pm

Hi I wiould like to beautify code, but not create new file as needed
in indent and cb. There are any other way to do it?

Pascal Bourguignon

2007-05-18, 7:17 pm

Anurag <anurag.cs@gmail.com> writes:

> Hi I wiould like to beautify code, but not create new file as needed
> in indent and cb. There are any other way to do it?


You could use an editor like emacs.

But the "create a new file" part can easily be aleviated:

cp source.c source.c~ && indent < source.c~ | cb > source.c

Et hop! No new file!

--
__Pascal Bourguignon__ http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
Bruintje Beer

2007-05-19, 1:20 am


"Anurag" <anurag.cs@gmail.com> schreef in bericht
news:1179511873.505920.69630@q23g2000hsg.googlegroups.com...
> Hi I wiould like to beautify code, but not create new file as needed
> in indent and cb. There are any other way to do it?
>


Use astyle

John


Bin Chen

2007-05-20, 1:21 am

On May 19, 3:10 am, Pascal Bourguignon <p...@informatimago.com> wrote:
> Anurag <anurag...@gmail.com> writes:
>
> You could use an editor like emacs.
>
> But the "create a new file" part can easily be aleviated:
>
> cp source.c source.c~ && indent < source.c~ | cb > source.c


where i can find the cb tool?

guru

2007-05-20, 1:23 pm

On May 19, 12:10 am, Pascal Bourguignon <p...@informatimago.com>
wrote:
> Anurag <anurag...@gmail.com> writes:
>
> You could use an editor like emacs.
>
> But the "create a new file" part can easily be aleviated:
>
> cp source.c source.c~ && indent < source.c~ | cb > source.c


I thing sometimes doesn't work. Better to use "xargs" when using
pipes.

>
> Et hop! No new file!
>
> --
> __Pascal Bourguignon__ http://www.informatimago.com/
>
> NOTE: The most fundamental particles in this product are held
> together by a "gluing" force about which little is currently known
> and whose adhesive power can therefore not be permanently
> guaranteed.



Giorgos Keramidas

2007-05-20, 7:21 pm

On 20 May 2007 11:06:32 -0700, guru <guru.jois@gmail.com> wrote:
>On May 19, 12:10 am,
>Pascal Bourguignon <p...@informatimago.com> wrote:
>
> I thing sometimes doesn't work. Better to use "xargs" when using
> pipes.


Not really; it works fine.

The xargs utility solves a different problem, when there is a chance for
the full length of the command-line to exceed system limits. In this
case, no part of the command-line is generated by some backquote
expansion or similar constructs, so xargs is not necessary.

vasudevram

2007-05-21, 1:19 pm

On May 21, 12:28 am, Giorgos Keramidas <keram...@ceid.upatras.gr>
wrote:
> On 20 May 2007 11:06:32 -0700, guru <guru.j...@gmail.com> wrote:
>
>
>
>
>
>
> Not really; it works fine.
>
> The xargs utility solves a different problem, when there is a chance for
> the full length of the command-line to exceed system limits. In this
> case, no part of the command-line is generated by some backquote
> expansion or similar constructs, so xargs is not necessary.


Yes; also, apart from backquote expansion, a possibly more common way
in which the command line can become too long, is if filename wildcard
characters (glob chars like * are used, and there are many files
matching). That doesn't apply to the example given above, of course,
but mentioning it since the OP might try doing the command with
wildcards. If using wildcards, unless you're sure exactly what the
wildcards mean, and how many files are going to match, and how long
the command line is going to become as a result, a useful trick is to
precede the entire command with "echo "; this doesn't do anything
permanent or damaging (just prints the expanded command to the screen,
but by this you get to see the expanded command without running it. Of
course if you have pipes etc. as in the example, you may have to tweak
what I've said for the echo trick to work.

Vasudev Ram
Dancing Bison Enterprises
http://www.dancingbison.com


Thomas Dickey

2007-05-22, 7:18 am

Bin Chen <binary.chen@gmail.com> wrote:

> where i can find the cb tool?


'cb' was distributed with some of the AT&T Unix's - I haven't seen a copy
for a long time. It wasn't quite as good as 'indent' then (though
making changes to 'indent' is harder ;-)

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com