develooper Front page | perl.perl5.porters | Postings from September 2008

[PATCH] Lies, damn lies and end-of-block comments

Thread Next
From:
Michael G Schwern
Date:
September 25, 2008 21:06
Subject:
[PATCH] Lies, damn lies and end-of-block comments
Message ID:
48DC5FC7.3000807@pobox.com
--------------010003070900030206060900
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

I was reading reentr.h and noticed a lot of the endif's for the
HAS_XXX_R macros were wrongly indented and their comments had the
wrong condition.

The attached patch fixes the indentation and removes all but the last
comment which is shortest and furthest from its start.  No point in an
end-of-block comment on a one statement block, just falls out of date
and obscures the structure.

Before:

#ifdef HAS_LOCALTIME_R
#  if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
#   undef localtime
#   if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_S_TS
#       define localtime(a) (L_R_TZSET localtime_r(a, &PL_reentrant_buffer->_loc
altime_struct) ? &PL_reentrant_buffer->_localtime_struct : 0)
#  endif /* if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1) */
#   if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_I_TS
#       define localtime(a) (L_R_TZSET localtime_r(a, &PL_reentrant_buffer->_loc
altime_struct) == 0 ? &PL_reentrant_buffer->_localtime_struct : 0)
#  endif /* if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1) */
#   endif /* HAS_LOCALTIME */
#endif /* HAS_LOCALTIME_R */


After:

#ifdef HAS_LOCALTIME_R
#  if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
#   undef localtime
#   if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_S_TS
#       define localtime(a) (L_R_TZSET localtime_r(a,
&PL_reentrant_buffer->_localtime_struct) ?
&PL_reentrant_buffer->_localtime_struct : 0)
#   endif
#   if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_I_TS
#       define localtime(a) (L_R_TZSET localtime_r(a,
&PL_reentrant_buffer->_localtime_struct) == 0 ?
&PL_reentrant_buffer->_localtime_struct : 0)
#   endif
#  endif
#endif /* HAS_LOCALTIME_R */


-- 
The mind is a terrible thing,
and it must be stopped.


--------------010003070900030206060900
Content-Type: text/plain;
 name="reentr.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="reentr.patch"

diff --git a/reentr.pl b/reentr.pl
index ea327a0..8cc4a5e 100644
--- a/reentr.pl
+++ b/reentr.pl
@@ -751,13 +751,13 @@ EOF
 EOF
 		}
 	    }
-	    push @wrap, <<EOF;
-#  endif /* if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1) */
+	    push @wrap, <<EOF;  # !defined(xxx) && XXX_R_PROTO == REENTRANT_PROTO_Y_TS
+#   endif
 EOF
 	}
 
-	    push @wrap, <<EOF;
-#   endif /* HAS_\U$func */
+	    push @wrap, <<EOF;  # defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
+#  endif
 EOF
 
 	push @wrap, $endif, "\n";

--------------010003070900030206060900--

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About