[git commit] time.c: Readability improvements - no code changes

Denys Vlasenko vda.linux at googlemail.com
Mon Mar 26 14:01:51 UTC 2012


commit: http://git.uclibc.org/uClibc/commit/?id=db45ed982f8bfe8e84442cc8866b7f74bc6519a7
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Pulled assignments out of ifs, added whitespace around operation symbols.

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 libc/misc/time/time.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index 8e2ebf1..534a7aa 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -671,7 +671,7 @@ static int tm_isdst(register const struct tm *__restrict ptm,
 		isleap = __isleap(i);
 		--i;
 		day0 = (1
-				+ i				/* Normal years increment 1 wday. */
+				+ i	/* Normal years increment 1 wday. */
 				+ (i/4)
 				- (i/100)
 				+ (i/400) ) % 7;
@@ -684,20 +684,22 @@ static int tm_isdst(register const struct tm *__restrict ptm,
 				}
 			} else if (r->rule_type == 'M') {
 				/* Find 0-based day number for 1st of the month. */
-				day = 31*r->month - day_cor[r->month -1];
+				day = 31 * r->month - day_cor[r->month - 1];
 				if (isleap && (day >= 59)) {
 					++day;
 				}
-				monlen = 31 + day_cor[r->month -1] - day_cor[r->month];
+				monlen = 31 + day_cor[r->month - 1] - day_cor[r->month];
 				if (isleap && (r->month == 2)) {
 					++monlen;
 				}
-				/* Wweekday (0 is Sunday) of 1st of the month
+				/* Weekday (0 is Sunday) of 1st of the month
 				 * is (day0 + day) % 7. */
-				if ((mday = r->day - ((day0 + day) % 7)) >= 0) {
-					mday -= 7;	/* Back up into prev month since r->week>0. */
+				mday = r->day - ((day0 + day) % 7);
+				if (mday >= 0) {
+					mday -= 7;	/* Back up into prev month since r->week > 0. */
 				}
-				if ((mday += 7 * r->week) >= monlen) {
+				mday += 7 * r->week;
+				if (mday >= monlen) {
 					mday -= 7;
 				}
 				/* So, 0-based day number is... */


More information about the uClibc-cvs mailing list