Adjust whitespace in examples to be closer to our style
authorFabian Keil <fk@fabiankeil.de>
Tue, 20 Mar 2012 13:05:14 +0000 (13:05 +0000)
committerFabian Keil <fk@fabiankeil.de>
Tue, 20 Mar 2012 13:05:14 +0000 (13:05 +0000)
doc/source/developer-manual.sgml

index 0cd061c..f0e3af8 100644 (file)
@@ -24,7 +24,7 @@
                 This file belongs into
                 ijbswa.sourceforge.net:/home/groups/i/ij/ijbswa/htdocs/
 
- $Id: developer-manual.sgml,v 2.45 2012/03/20 13:04:41 fabiankeil Exp $
+ $Id: developer-manual.sgml,v 2.46 2012/03/20 13:04:54 fabiankeil Exp $
 
  Copyright (C) 2001-2012 Privoxy Developers http://www.privoxy.org/
  See LICENSE.
@@ -51,7 +51,7 @@
     </pubdate>
 
 
-    <pubdate>$Id: developer-manual.sgml,v 2.45 2012/03/20 13:04:41 fabiankeil Exp $</pubdate>
+    <pubdate>$Id: developer-manual.sgml,v 2.46 2012/03/20 13:04:54 fabiankeil Exp $</pubdate>
 
 <!--
 
@@ -738,13 +738,13 @@ Hal.
     <para><emphasis>Example:</emphasis></para>
 <programlisting>
 /* if page size greater than 1k ... */
-if ( page_length() > 1024 )
+if (page_length() > 1024)
 {
     ... "block" the page up ...
 }
 
 /* if page size is small, send it in blocks */
-if ( page_length() > 1024 )
+if (page_length() > 1024)
 {
     ... "block" the page up ...
 }
@@ -772,20 +772,20 @@ is actually being done.
 /*********************************************************************
  * This will stand out clearly in your code!
  *********************************************************************/
-if ( this_variable == that_variable )
+if (this_variable == that_variable)
 {
    do_something_very_important();
 }
 
 
 /* unfortunately, this may not */
-if ( this_variable == that_variable )
+if (this_variable == that_variable)
 {
    do_something_very_important();
 }
 
 
-if ( this_variable == that_variable ) /* this may not either */
+if (this_variable == that_variable) /* this may not either */
 {
    do_something_very_important();
 }</programlisting>
@@ -819,12 +819,12 @@ if ( this_variable == that_variable ) /* this may not either */
  * This will stand out clearly in your code,
  * But the second example won't.
  *********************************************************************/
-if ( this_variable == this_variable )
+if (this_variable == this_variable)
 {
    do_something_very_important();
 }
 
-if ( this_variable == this_variable ) /*can you see me?*/
+if (this_variable == this_variable) /*can you see me?*/
 {
    do_something_very_important(); /*not easily*/
 }
@@ -836,7 +836,7 @@ if ( this_variable == this_variable ) /*can you see me?*/
 int urls_read     = 0;     /* # of urls read + rejected */
 int urls_rejected = 0;     /* # of urls rejected */
 
-if ( 1 == X )
+if (1 == X)
 {
    do_something_very_important();
 }
@@ -913,7 +913,7 @@ short do_something_very_important(
 
     <para><emphasis>Example:</emphasis></para>
 <programlisting>
-if ( 1 == X )
+if (1 == X)
 {
    do_something_very_important();
    ...some long list of commands...
@@ -921,11 +921,11 @@ if ( 1 == X )
 
 or:
 
-if ( 1 == X )
+if (1 == X)
 {
    do_something_very_important();
    ...some long list of commands...
-} /* -END- if ( 1 == X ) */
+} /* -END- if (1 == X) */
 </programlisting>
   </sect3>
 
@@ -975,14 +975,14 @@ int msiis5hack = 0; int msIis5Hack = 0;
 
     <para><emphasis>Example:</emphasis></para>
 <programlisting>
-int load_some_file( struct client_state *csp )</programlisting>
+int load_some_file(struct client_state *csp)</programlisting>
 
     <para><emphasis>Instead of:</emphasis></para>
 
     <para>
 <programlisting>
-int loadsomefile( struct client_state *csp )
-int loadSomeFile( struct client_state *csp )
+int loadsomefile(struct client_state *csp)
+int loadSomeFile(struct client_state *csp)
 </programlisting>
 </para>
 
@@ -1000,14 +1000,14 @@ int loadSomeFile( struct client_state *csp )
 
     <para><emphasis>Example:</emphasis></para>
 <programlisting>
-(.h) extern int load_aclfile( struct client_state *csp );
-(.c) int load_aclfile( struct client_state *csp )</programlisting>
+(.h) extern int load_aclfile(struct client_state *csp);
+(.c) int load_aclfile(struct client_state *csp)</programlisting>
 
     <para><emphasis>Instead of:</emphasis>
 <programlisting>
-(.h) extern int load_aclfile( struct client_state * ); or
+(.h) extern int load_aclfile(struct client_state *); or
 (.h) extern int load_aclfile();
-(.c) int load_aclfile( struct client_state *csp )
+(.c) int load_aclfile(struct client_state *csp)
 </programlisting>
 </para>
 
@@ -1025,7 +1025,7 @@ int loadSomeFile( struct client_state *csp )
 
     <para><emphasis>Example:</emphasis></para>
 <programlisting>
-(enumeration) : enum Boolean { FALSE, TRUE };
+(enumeration) : enum Boolean {FALSE, TRUE};
 (#define) : #define DEFAULT_SIZE 100;</programlisting>
 
     <para><emphasis>Note:</emphasis> We have a standard naming scheme for #defines
@@ -1093,18 +1093,18 @@ int loadSomeFile( struct client_state *csp )
 
     <para><emphasis>Example:</emphasis></para>
 <programlisting>
-if ( this == that )
+if (this == that)
 {
    ...
 }</programlisting>
 
     <para><emphasis>Instead of:</emphasis></para>
 
-    <para>if ( this == that ) { ... }</para>
+    <para>if (this == that) { ... }</para>
 
     <para>or</para>
 
-    <para>if ( this == that ) { ... }</para>
+    <para>if (this == that) { ... }</para>
 
     <para><emphasis>Note:</emphasis> In the special case that the if-statement is
     inside a loop, and it is trivial, i.e. it tests for a
@@ -1116,12 +1116,12 @@ if ( this == that )
 
     <para><emphasis>Example exception:</emphasis></para>
 <programlisting>
-while ( more lines are read )
+while (more lines are read)
 {
    /* Please document what is/is not a comment line here */
-   if ( it's a comment ) continue;
+   if (it's a comment) continue;
 
-   do_something( line );
+   do_something(line);
 }
 </programlisting>
   </sect3>
@@ -1138,7 +1138,7 @@ while ( more lines are read )
 
     <para><emphasis>Example:</emphasis></para>
 <programlisting>
-if ( this == that )
+if (this == that)
 {
    do_something();
    do_something_else();
@@ -1146,11 +1146,11 @@ if ( this == that )
 
     <para><emphasis>Instead of:</emphasis></para>
 
-    <para>if ( this == that ) do_something(); do_something_else();</para>
+    <para>if (this == that) do_something(); do_something_else();</para>
 
     <para>or</para>
 
-    <para>if ( this == that ) do_something();</para>
+    <para>if (this == that) do_something();</para>
 
     <para><emphasis>Note:</emphasis> The first example in "Instead of" will execute
     in a manner other than that which the developer desired (per
@@ -1167,11 +1167,11 @@ if ( this == that )
 
     <para><emphasis>Example:</emphasis></para>
 <programlisting>
-structure->flag = ( condition );</programlisting>
+structure->flag = (condition);</programlisting>
 
     <para><emphasis>Instead of:</emphasis></para>
 
-    <para>if ( condition ) { structure->flag = 1; } else {
+    <para>if (condition) { structure->flag = 1; } else {
     structure->flag = 0; }</para>
 
     <para><emphasis>Note:</emphasis> The former is readable and concise. The later
@@ -1197,10 +1197,6 @@ int first_value   = 0;
 int some_value    = 0;
 int another_value = 0;
 int this_variable = 0;
-
-if ( this_variable == this_variable )
-
-first_value = old_value + ( ( some_value - another_value ) - whatever )
 </programlisting>
   </sect3>
 
@@ -1239,19 +1235,19 @@ function_name();</programlisting>
 int function1( ... )
 {
    ...code...
-   return( ret_code );
+   return(ret_code);
 
-}   /* -END- function1 */
+} /* -END- function1 */
 
 
 int function2( ... )
 {
-}   /* -END- function2 */
+} /* -END- function2 */
 </programlisting>
 
     <para><emphasis>Instead of:</emphasis></para>
 
-    <para>int function1( ... ) { ...code... return( ret_code ); } int
+    <para>int function1( ... ) { ...code... return(ret_code); } int
     function2( ... ) { }</para>
 
     <para><emphasis>Note:</emphasis> Use 1 blank line before the closing brace and 2
@@ -1288,16 +1284,16 @@ static const char * const url_code_map[256] =
 
 int function1( ... )
 {
-   if ( 1 )
+   if (1)
    {
-      return( ALWAYS_TRUE );
+      return ALWAYS_TRUE;
    }
    else
    {
-      return( HOW_DID_YOU_GET_HERE );
+      return HOW_DID_YOU_GET_HERE;
    }
 
-   return( NEVER_GETS_HERE );
+   return NEVER_GETS_HERE;
 
 }
 </programlisting>
@@ -1382,7 +1378,7 @@ is_web_page_blank();
 
     <para><emphasis>Example:</emphasis></para>
 <programlisting>
-for ( size_t cnt = 0; cnt &lt; block_list_length(); cnt++ )
+for (size_t cnt = 0; cnt &lt; block_list_length(); cnt++)
 {
    ....
 }</programlisting>
@@ -1405,7 +1401,7 @@ for ( size_t cnt = 0; cnt &lt; block_list_length(); cnt++ )
 <programlisting>
 size_t len = block_list_length();
 
-for ( size_t cnt = 0; cnt &lt; len; cnt++ )
+for (size_t cnt = 0; cnt &lt; len; cnt++)
 {
    ....
 }</programlisting>
@@ -1425,12 +1421,12 @@ for ( size_t cnt = 0; cnt &lt; len; cnt++ )
     <para>This allows a developer to define a const pointer and call
     your function. If your function does not have the const
     keyword, we may not be able to use your function. Consider
-    strcmp, if it were defined as: extern int strcmp( char *s1,
-    char *s2 );</para>
+    strcmp, if it were defined as: extern int strcmp(char *s1,
+    char *s2);</para>
 
-    <para>I could then not use it to compare argv's in main: int main(
-    int argc, const char *argv[] ) { strcmp( argv[0], "privoxy"
-    ); }</para>
+    <para>I could then not use it to compare argv's in main: int
+    main(int argc, const char *argv[]) { strcmp(argv[0], "privoxy");
+     }</para>
 
     <para>Both these pointers are *const*! If the c runtime library
     maintainers do it, we should too.</para>
@@ -1445,11 +1441,11 @@ for ( size_t cnt = 0; cnt &lt; len; cnt++ )
 
     <para>Most structures cannot fit onto a normal stack entry (i.e.
     they are not 4 bytes or less). Aka, a function declaration
-    like: int load_aclfile( struct client_state csp )</para>
+    like: int load_aclfile(struct client_state csp)</para>
 
     <para>would not work. So, to be consistent, we should declare all
-    prototypes with "pass by value": int load_aclfile( struct
-    client_state *csp )</para>
+    prototypes with "pass by value": int load_aclfile(struct
+    client_state *csp)</para>
 
 
   </sect3>
@@ -1592,22 +1588,22 @@ extern file_list *xyz;</programlisting>
 
     <para><emphasis>Example:</emphasis></para>
 <programlisting>
-switch( hash_string( cmd ) )
+switch (hash_string(cmd))
 {
-   case hash_actions_file :
+   case hash_actions_file:
       ... code ...
       break;
 
-   case hash_confdir :
+   case hash_confdir:
       ... code ...
       break;
 
-   default :
+   default:
       log_error( ... );
       ... anomaly code goes here ...
       continue; / break; / exit( 1 ); / etc ...
 
-} /* end switch( hash_string( cmd ) ) */</programlisting>
+} /* end switch (hash_string(cmd)) */</programlisting>
 
     <para><emphasis>Note:</emphasis> If you already have a default condition, you
     are obviously exempt from this point. Of note, most of the
@@ -1750,8 +1746,8 @@ list, then it should definitely be allocated via `malloc'.
 
     <para><emphasis>Example:</emphasis></para>
 <programlisting>
-int load_re_filterfile( struct client_state *csp ) { ... }
-static void unload_re_filterfile( void *f ) { ... }</programlisting>
+int load_re_filterfile(struct client_state *csp) { ... }
+static void unload_re_filterfile(void *f) { ... }</programlisting>
 
     <para><emphasis>Exceptions:</emphasis></para>
 
@@ -1951,10 +1947,10 @@ extern const char FILENAME_h_rcs[];
  * Returns     :  0 => Ok, everything else is an error.
  *
  *********************************************************************/
-int FUNCTION_NAME( void *param1, const char *x )
+int FUNCTION_NAME(void *param1, const char *x)
 {
    ...
-   return( 0 );
+   return 0;
 
 }
 </programlisting>
@@ -3062,6 +3058,9 @@ at sourceforge. Three simple steps:
   Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
   $Log: developer-manual.sgml,v $
+  Revision 2.46  2012/03/20 13:04:54  fabiankeil
+  IJB is dead, long live Privoxy
+
   Revision 2.45  2012/03/20 13:04:41  fabiankeil
   The redhat-dok target no longer exists so there's no point documenting it