Compare commits

..

24 Commits

Author SHA1 Message Date
Laurence Withers 82aa0f2f20 Bump version 2015-06-12 11:01:21 +01:00
Laurence Withers 2e610c4db3 Add 2015-06-30 leap second to built-in table 2015-06-12 10:55:53 +01:00
Laurence Withers dd3fe182af Update build system (Doxyfile) 2015-06-12 10:53:31 +01:00
Laurence Withers 0d5c2078b3 Bump version 2013-04-05 09:35:19 +00:00
Laurence Withers 6b25293f35 Fix build system ordering
Make sure that the library is built before either of the isodate or setisodate
apps, otherwise we end up with problems compiling from scratch.
2013-04-05 09:32:22 +00:00
Laurence Withers dcb15f2081 Bump version 2012-01-07 17:42:57 +00:00
Laurence Withers 4c470ec1e9 Bump version 2012-01-07 17:42:57 +00:00
Laurence Withers ba81c458e1 Update for 2012-06-30 leap second 2012-01-07 17:42:44 +00:00
Laurence Withers 49536349f7 Bump version 2011-11-18 12:19:09 +00:00
Laurence Withers c7b38eab5a Bump version 2011-11-18 12:19:09 +00:00
Laurence Withers c198eaf34b Remove accidental variable definition 2011-11-16 12:04:15 +00:00
Laurence Withers b622223b64 Remove unneeded nonnull attribute 2011-11-16 09:58:21 +00:00
Laurence Withers 81df4e8a05 Add C++ extern C include guards 2011-11-15 16:49:46 +00:00
Laurence Withers 7a5f30bfcd Update build system 2011-11-15 16:49:46 +00:00
Laurence Withers d910e88bc3 Bump version 2010-08-02 12:01:43 +00:00
Laurence Withers 2aa3d5aaac Bump version 2010-08-02 12:01:43 +00:00
Laurence Withers d013bff263 Remove incorrect nonnull attribute
iso8601_leap_table_load() had an incorrect ‘nonnull’ attribute, which could
lead to crashes as the compiled code could omit the test for null which then
substitutes the system default. Fix it by removing the attribute.
2010-08-02 12:00:20 +00:00
Laurence Withers 8cc71fb069 Bump version 2010-06-18 12:49:36 +00:00
Laurence Withers 2d9621e0a5 Bump version 2010-06-18 12:49:33 +00:00
Laurence Withers 944331702f Cope with negative C library timestamps
While perhaps not strictly valid, negative timestamps can potentially be
returned by the C library and passed in to iso8601_from_ts() etc. This commit
adds a check for such timestamps and copes with the gracefully, whereas
previously invalid ISO8601 timestamps would have been generated.
2010-06-18 12:47:38 +00:00
Laurence Withers 0d56edd890 Bump version 2010-01-28 16:22:46 +00:00
Laurence Withers 65fe613272 Bump version 2010-01-28 16:22:39 +00:00
Laurence Withers 64e06d17c4 Add explicit note on params which may be null 2010-01-28 16:22:03 +00:00
Laurence Withers cd9a2d252a iso8601_difference(): incorrect nonnull attribute
iso8601_difference was incorrectly marked as having all of its attributes
required to be non-null, but this is not the case according to the docs or
the implementation. This was causing a crash as the compiled library was
taking advantage of the nonnull notation to remove some tests against null
which, according to the docs, are actually required.

Fix by tightening the nonnull specification to those parameters which actually
require it.
2010-01-28 16:17:53 +00:00
32 changed files with 2341 additions and 192 deletions

View File

@ -292,5 +292,4 @@ done
exit 0
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1,9 +1,9 @@
#!/bin/bash
# libiso8601/test.sh
#
# (c)2009, Laurence Withers, <l@lwithers.me.uk>.
# Released under the GNU GPLv3. See file COPYING or
# http://www.gnu.org/copyleft/gpl.html for details.
# Copyright: ©20092011, Güralp Systems Ltd.
# Author: Laurence Withers <lwithers@guralp.com>
# License: GPLv3
#
# Running this script on its own will display a summary of all the
@ -21,7 +21,7 @@ run_test() {
return 1
fi
LD_LIBRARY_PATH="obj" "${EXE}" "$@" || return 1
LD_LIBRARY_PATH="obj:${LD_LIBRARY_PATH}" "${EXE}" "$@" || return 1
return 0
}
@ -36,11 +36,12 @@ print_tests() {
[ -x "${EXE}" ] || continue
NAME="$(echo "${EXE}" | sed 's,obj/tests/,,')"
echo -ne "${NAME}\t"
LD_LIBRARY_PATH="obj" "${EXE}" --print-summary
LD_LIBRARY_PATH="obj:${LD_LIBRARY_PATH}" "${EXE}" --print-summary
done
}
# Main script
if [ $# -eq 0 ]
then
@ -48,7 +49,6 @@ then
exit 0
fi
run_test $*
run_test "$@"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

1
scripts/.gitignore vendored
View File

@ -7,6 +7,7 @@ build.docs.none
build.files.none
build.firmware.gpasm
build.firmware.sdcc
build.header.c
build.lib.c
build.lib.c++
build.make.none

View File

@ -1,8 +1,8 @@
# libiso8601/scripts/functions.sh
#
# (c)2007, Laurence Withers, <l@lwithers.me.uk>.
# Released under the GNU GPLv3. See file COPYING or
# http://www.gnu.org/copyleft/gpl.html for details.
# Copyright: ©20072011, Güralp Systems Ltd.
# Author: Laurence Withers, <lwithers@guralp.com>
# License: GPLv3
#
# Common functions
@ -63,5 +63,4 @@ do_cmd_redir() {
fi
}
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4

View File

@ -1,8 +1,8 @@
# libiso8601/scripts/paths
#
# (c)2007, Laurence Withers, <l@lwithers.me.uk>.
# Released under the GNU GPLv3. See file COPYING or
# http://www.gnu.org/copyleft/gpl.html for details.
# Copyright: ©2011, Güralp Systems Ltd.
# Author: Laurence Withers, <lwithers@guralp.com>
# License: GPLv3
#
# Default path setup. Not meant for editing; use environment variables
# to override values if needed.
@ -60,5 +60,4 @@ fi
[ -z "${WEBDIR}" ] && WEBDIR="${SRVDIR}/http"
[ -z "${CGIDIR}" ] && CGIDIR="${WEBDIR}/cgi-bin"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

File diff suppressed because it is too large Load Diff

View File

@ -39,5 +39,4 @@ then
docs_BUILT=1
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -17,5 +17,4 @@ do
done
print_success "Documentation installed"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -8,7 +8,8 @@ build_target libiso8601
if [ -z ${isodate_BUILT} ]
then
isodate="obj/isodate"
EXTRAS="${libiso8601} ${libiso8601_DEP_CFLAGS} ${libiso8601_DEP_LIBS}"
EXTRAS="-std=gnu99 -D_GNU_SOURCE -DAPP_NAME=\"isodate\" \
${libiso8601} ${libiso8601_DEP_CFLAGS} ${libiso8601_DEP_LIBS}"
echo "Building application ${isodate}..."
@ -39,5 +40,4 @@ then
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -8,5 +8,4 @@ echo "Installing binaries into '${BINDIR}'"
install_file "${isodate}" "${BINDIR}" 0755 || return 1
print_success "Done"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -14,5 +14,4 @@ then
MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}"
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -8,6 +8,10 @@
#ifndef HEADER_libiso8601
#define HEADER_libiso8601
#ifdef __cplusplus
extern "C" {
#endif
/* standard includes, or includes needed for type declarations */
#include <time.h>
#include <stdint.h>

View File

@ -39,6 +39,8 @@ leap_second_days_table[] = {
730119, /* 1998-12-31 */
732676, /* 2005-12-31 */
733772, /* 2008-12-31 */
735049, /* 2012-06-30 */
736144, /* 2015-06-30 */
};

View File

@ -58,7 +58,7 @@ enum iso8601_date_prec {
/*! \brief Year, week and weekday specified (week format). */
iso8601_prec_wday
}date_prec;
};
@ -87,7 +87,7 @@ enum iso8601_time_prec {
iso8601_prec_minfrac,
/*! \brief Display hour, minute, second and nanoseconds. */
iso8601_prec_secfrac
}time_prec;
};

View File

@ -22,7 +22,8 @@ iso8601_now(struct iso8601_date* date, struct iso8601_details* details)
if(use_gettimeofday || clock_gettime(CLOCK_REALTIME, &ts)) {
use_gettimeofday = 1;
gettimeofday(&tv, 0);
ts.tv_sec = tv.tv_sec;
if(tv.tv_sec < 0) ts.tv_sec = 0;
else ts.tv_sec = tv.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000L;
}
@ -79,6 +80,10 @@ iso8601_from_ts(struct iso8601_date* date, const struct timespec* ts)
ldiv_t qr;
qr = ldiv(ts->tv_sec, 86400);
if(ts->tv_sec < 0) {
--qr.quot;
qr.rem += 86400;
}
date->day = EPOCH_GDAY + qr.quot;
date->sec = qr.rem;
date->nsec = ts->tv_nsec;
@ -101,6 +106,10 @@ iso8601_from_tv(struct iso8601_date* date, const struct timeval* tv)
ldiv_t qr;
qr = ldiv(tv->tv_sec, 86400);
if(tv->tv_sec < 0) {
--qr.quot;
qr.rem += 86400;
}
date->day = EPOCH_GDAY + qr.quot;
date->sec = qr.rem;
date->nsec = tv->tv_usec * 1000;
@ -123,6 +132,10 @@ iso8601_from_time_t(struct iso8601_date* date, const time_t* t)
ldiv_t qr;
qr = ldiv(*t, 86400);
if(*t < 0) {
--qr.quot;
qr.rem += 86400;
}
date->day = EPOCH_GDAY + qr.quot;
date->sec = qr.rem;
date->nsec = 0;

View File

@ -19,8 +19,8 @@ conversion).
/*! \brief Retrieve the current time.
\param[out] date Current date/time (may be 0), in UTC.
\param[out] details Details (may be 0), including timezone.
\param[out] date Current date/time (may be 0), in UTC. May be 0.
\param[out] details Details (may be 0), including timezone. May be 0.
Retrieves the current time from the system clock, storing it into \a date and
\a details (both parameters optional).

View File

@ -26,11 +26,7 @@ understood by humans, and vice versa.
Returns non-0 if \a year is a leap year.
*/
int iso8601_isleap(int year)
#ifndef DOXYGEN
__attribute__((nonnull))
#endif
;
int iso8601_isleap(int year);

View File

@ -124,11 +124,7 @@ be set appropriately. If \a errno is \c EINVAL, then the file does not contain
a valid leap second table.
*/
int iso8601_leap_table_load(const char* fname)
#ifndef DOXYGEN
__attribute__((nonnull))
#endif
;
int iso8601_leap_table_load(const char* fname);

View File

@ -148,7 +148,7 @@ stored in \a sign (if it is not a null pointer), i.e. -1 if \a d2 &gt; \a d1 or
void iso8601_difference(const struct iso8601_date* d1,
const struct iso8601_date* d2, struct iso8601_elapsed* per, int* sign)
#ifndef DOXYGEN
__attribute__((nonnull))
__attribute__((nonnull(1,2)))
#endif
;

View File

@ -5,6 +5,10 @@
* http://www.gnu.org/copyleft/gpl.html for details.
*/
#ifdef __cplusplus
}
#endif
#endif
/* options for text editors

View File

@ -34,5 +34,4 @@ do_cmd_redir "${CONFFILE}" sed \
do_cmd chmod 0755 "${CONFFILE}"
print_success "Done"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -14,7 +14,9 @@ then
libiso8601="obj/${libiso8601_BASE}.so.${SOMAJOR}.${SOMICRO}"
libiso8601_DEP_CFLAGS=""
libiso8601_DEP_LIBS="-lrt"
SO_EXTRA="-std=gnu99 -D_GNU_SOURCE -DDEFAULT_LEAP_TABLE=\"${DEFAULT_LEAP_TABLE}\" ${libiso8601_DEP_CFLAGS} ${libiso8601_DEP_LIBS} -lc"
SO_EXTRA="${libiso8601_DEP_CFLAGS} ${libiso8601_DEP_LIBS} -lc \
-D_GNU_SOURCE -std=gnu99 \
-DDEFAULT_LEAP_TABLE=\"${DEFAULT_LEAP_TABLE}\""
echo "Building library ${libiso8601}..."
@ -52,5 +54,4 @@ then
libiso8601_HEADER=${HDR}
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -17,5 +17,4 @@ then
libiso8601_MONOLITHIC=1
MONOLITHIC_DOC="${MONOLITHIC_DOC} ${HDR}"
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -95,4 +95,3 @@ true
# vim: syntax=sh:expandtab:ts=4:sw=4
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;

View File

@ -1,8 +1,8 @@
# libiso8601/src/libiso8601/soversion
#
# (c)2007, Laurence Withers, <l@lwithers.me.uk>.
# Released under the GNU GPLv3. See file COPYING or
# http://www.gnu.org/copyleft/gpl.html for details.
# Copyright: ©20072011, Güralp Systems Ltd.
# Author: Laurence Withers <lwithers@guralp.com>
# License: GPLv3
#
@ -12,4 +12,4 @@
SOMAJOR=1
# SOMICRO is bumped every time there is a binary-compatible release.
SOMICRO=5
SOMICRO=10

View File

@ -8,7 +8,8 @@ build_target libiso8601
if [ -z ${setisodate_BUILT} ]
then
setisodate="obj/setisodate"
EXTRAS="${libiso8601} ${libiso8601_DEP_CFLAGS} ${libiso8601_DEP_LIBS}"
EXTRAS="-std=gnu99 -D_GNU_SOURCE -DAPP_NAME=\"setisodate\" \
${libiso8601} ${libiso8601_DEP_CFLAGS} ${libiso8601_DEP_LIBS}"
echo "Building application ${setisodate}..."
@ -39,5 +40,4 @@ then
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -8,5 +8,4 @@ echo "Installing binaries into '${SBINDIR}'"
install_file "${setisodate}" "${SBINDIR}" 0755 || return 1
print_success "Done"
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -14,5 +14,4 @@ then
MONOLITHIC_DOC="${MONOLITHIC_DOC} ${SRC}"
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -1,3 +1 @@
source src/tests/build.tests
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -7,7 +7,7 @@ build_target libiso8601 || return 1
if [ -z ${tests_BUILT} ]
then
LIBS="${libiso8601} ${libiso8601_DEP_CFLAGS} ${libiso8601_DEP_LIBS} "
EXTRAS="-D_GNU_SOURCE"
EXTRAS="-lm"
echo "Building test programs..."
do_cmd mkdir -p obj/tests || return 1
@ -25,14 +25,9 @@ then
fi
done
case "${TEST}" in
obj/tests/manip) TEST_EXTRAS="-lm" ;;
*) TEST_EXTRAS="" ;;
esac
if [ ${MODIFIED} -ne 0 ]
then
do_cmd ${CC} -Iobj ${CFLAGS} -o ${TEST} ${SRC} ${LIBS} ${EXTRAS} ${TEST_EXTRAS} || return 1
do_cmd ${CC} -Iobj ${CFLAGS} -o ${TEST} ${SRC} ${LIBS} ${EXTRAS} || return 1
print_success "Built ${TEST}"
else
print_success "${TEST} is up to date"
@ -44,5 +39,4 @@ then
tests_BUILT=1
fi
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: syntax=sh:expandtab:ts=4:sw=4

View File

@ -1,9 +1,9 @@
/* libiso8601/src/tests/???.c
/* libiso8601/src/tests/xxx.c
*
* (c)2007, Laurence Withers, <l@lwithers.me.uk>.
* Released under the GNU GPLv3. See file COPYING or
* http://www.gnu.org/copyleft/gpl.html for details.
*/
* Copyright: ©20072011, Güralp Systems Ltd.
* Author: Laurence Withers <lwithers@guralp.com>
* License: GPLv3
*/
#include "iso8601.h"
@ -12,7 +12,8 @@
int main(int argc, char* argv[])
int
main(int argc, char* argv[])
{
int ret = 0;
@ -30,7 +31,8 @@ int main(int argc, char* argv[])
return ret;
}
/* options for text editors
kate: replace-trailing-space-save true; space-indent true; tab-width 4;
vim: expandtab:ts=4:sw=4
*/

View File

@ -1,8 +1,8 @@
# libiso8601/version
#
# (c)2007, Laurence Withers, <l@lwithers.me.uk>.
# Released under the GNU GPLv3. See file COPYING or
# http://www.gnu.org/copyleft/gpl.html for details.
# Copyright: ©20072011, Güralp Systems Ltd.
# Author: Laurence Withers <lwithers@guralp.com>
# License: GPLv3
#
@ -11,7 +11,6 @@
# expected to be in 'major.minor.micro' format.
VERMAJOR=0
VERMINOR=3
VERMICRO=8
VERMICRO=15
# kate: replace-trailing-space-save true; space-indent true; tab-width 4;
# vim: expandtab:ts=4:sw=4:syntax=sh