From: Juergen Perlinger Date: Sun, 27 Sep 2015 07:35:12 +0000 (+0200) Subject: Merge bk://bk.ntp.org/ntp-stable X-Git-Tag: NTP_4_3_74~1^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de8740ea1a17c0e8bdb4817cbc4e4167b780ea79;p=thirdparty%2Fntp.git Merge bk://bk.ntp.org/ntp-stable into hydra.localnet:/home/jnperlin/Projects/Packages/NTP-DEV/src/ntp-stable-cal2 bk: 56079c30I0WW5OKe9r5rl9Tg0_homA --- de8740ea1a17c0e8bdb4817cbc4e4167b780ea79 diff --cc ChangeLog index 80749108c,266244bf2..f58c42d68 --- a/ChangeLog +++ b/ChangeLog @@@ -16,9 -16,10 +16,11 @@@ be configured for the distribution targets. Harlan Stenn. * [Bug 2883] ntpd crashes on exit with empty driftfile. Miroslav Lichvar. * [Bug 2886] Mis-spelling: "outlyer" should be "outlier". dave@horsfall.org +* [Bug 2888] streamline calendar functions. perlinger@ntp.org * [Bug 2889] ntp-dev-4.3.67 does not build on Windows. perlinger@ntp.org * [Bug 2890] Ignore ENOBUFS on routing netlink socket. Konstantin Khlebnikov. + * [Bug 2906] make check needs better support for pthreads. Harlan Stenn. + * [Bug 2907] dist* build targets require our libevent/ to be enabled. HStenn. * libntp/emalloc.c: Remove explicit include of stdint.h. Harlan Stenn. * Put Unity CPPFLAGS items in unity_config.h. Harlan Stenn. * tests/ntpd/g_leapsec.cpp typo fix. Harlan Stenn. diff --cc tests/libntp/calendar.c index c702a60f8,2d4578d0d..036427f88 --- a/tests/libntp/calendar.c +++ b/tests/libntp/calendar.c @@@ -74,14 -103,28 +74,14 @@@ CalendarFromCalToString } char * -CalendarFromIsoToString(const struct isodate iso) { - +CalendarFromIsoToString( + const struct isodate *iso) +{ - char * str = malloc (sizeof (char) * 100); + char * str = emalloc (sizeof (char) * 100); - - char buffer[100] =""; - snprintf(buffer, 100, "%u", iso.year); - strcat(str, buffer); - strcat(str, "-"); - snprintf(buffer, 100, "%u", (u_int)iso.week); - strcat(str, buffer); - strcat(str, "-"); - snprintf(buffer, 100, "%u", (u_int)iso.weekday); - strcat(str, buffer); - snprintf(buffer, 100, "%u", (u_int)iso.hour); - strcat(str, buffer); - strcat(str, ":"); - snprintf(buffer, 100, "%u", (u_int)iso.minute); - strcat(str, buffer); - strcat(str, ":"); - snprintf(buffer, 100, "%u", (u_int)iso.second); - strcat(str, buffer); - + snprintf(str, 100, "%u-W%02u-%02u %02u:%02u:%02u", + iso->year, (u_int)iso->week, (u_int)iso->weekday, + (u_int)iso->hour, (u_int)iso->minute, (u_int)iso->second); + str[99] = '\0'; /* paranoia rulez! */ return str; } @@@ -127,27 -160,42 +127,27 @@@ IsEqualIso } char * -DateFromCalToString(const struct calendar cal) { +DateFromCalToString( + const struct calendar *cal) +{ - char * str = malloc (sizeof (char) * 100); + char * str = emalloc (sizeof (char) * 100); - - char buffer[100] =""; - snprintf(buffer, 100, "%u", cal.year); - strcat(str, buffer); - strcat(str, "-"); - snprintf(buffer, 100, "%u", (u_int)cal.month); - strcat(str, buffer); - strcat(str, "-"); - snprintf(buffer, 100, "%u", (u_int)cal.monthday); - strcat(str, buffer); - strcat(str, " ("); - snprintf(buffer, 100, "%u", cal.yearday); - strcat(str, buffer); - strcat(str, ")"); - + snprintf(str, 100, "%u-%02u-%02u (%u)", + cal->year, (u_int)cal->month, (u_int)cal->monthday, + cal->yearday); + str[99] = '\0'; /* paranoia rulez! */ return str; } char * -DateFromIsoToString(const struct isodate iso) { +DateFromIsoToString( + const struct isodate *iso) +{ - char * str = malloc (sizeof (char) * 100); + char * str = emalloc (sizeof (char) * 100); - - char buffer[100] =""; - snprintf(buffer, 100, "%u", iso.year); - strcat(str, buffer); - strcat(str, "-"); - snprintf(buffer, 100, "%u", (u_int)iso.week); - strcat(str, buffer); - strcat(str, "-"); - snprintf(buffer, 100, "%u", (u_int)iso.weekday); - strcat(str, buffer); - + snprintf(str, 100, "%u-W%02u-%02u", + iso->year, (u_int)iso->week, (u_int)iso->weekday); + str[99] = '\0'; /* paranoia rulez! */ return str; }