01.09.2014 Views

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CH07.fm Page 210 Monday, October 7, 2002 9:12 PM<br />

210 Chapter 7 • Miscellaneous Tools<br />

-bbb<br />

-sob<br />

This option is used to add a blank line before a boxed comment. An example of a<br />

boxed comment is shown below.<br />

/**************************************<br />

* hello.c<br />

*<br />

* This file is used to demonstrate use<br />

* of indent utility<br />

*************************************/<br />

This option is used to remove unnecessary blank lines from the source code.<br />

By adding n in the start of these options, their effect may be reversed. For example, the<br />

-nbad option will not add any blank line after declaration.<br />

7.1.4 Formatting Braces<br />

People have different tastes about how braces should be formatted in C language. <strong>Using</strong><br />

indent you can specify different ways of formatting braces. Let us consider a poorly formatted<br />

piece of C source code <strong>and</strong> see different ways of formatting it. <strong>The</strong> input segment of source code<br />

is shown below:<br />

if (counter > 0)<br />

{<br />

counter-- ;<br />

printf ("Counter value is: %d \n");<br />

}<br />

else<br />

{<br />

printf("Counter reached zero. Resetting counter\n");<br />

counter = 100;<br />

}<br />

<strong>The</strong> default indentation of this segment of code is shown below. This is the default GNU<br />

indentation when you use no comm<strong>and</strong> line switches with indent.<br />

if (counter > 0)<br />

{<br />

counter--;<br />

printf ("Counter value is: %d \n");<br />

}<br />

else<br />

{<br />

printf ("Counter reached zero. Resetting counter\n");<br />

counter = 100;<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!