summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-05-23 22:53:47 (GMT)
committerGuido van Rossum <guido@python.org>1996-05-23 22:53:47 (GMT)
commitbceeac8dc1627c307e64c2ace9dcd1e486636ad8 (patch)
treef0fe0c2f97b8ef6c04e316560547a59b21d1326c /Modules
parentdadc824c6e927ea76f3a6cec4d0ffcfc88414783 (diff)
downloadcpython-bceeac8dc1627c307e64c2ace9dcd1e486636ad8.zip
cpython-bceeac8dc1627c307e64c2ace9dcd1e486636ad8.tar.gz
cpython-bceeac8dc1627c307e64c2ace9dcd1e486636ad8.tar.bz2
Watcom changes.
Add mktime() overflow test and make it NeXT robust by initializing the structure from localtime().
Diffstat (limited to 'Modules')
-rw-r--r--Modules/timemodule.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index ee3fb8d..d8c1b2b 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -52,6 +52,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <sys/timeb.h>
#endif
+#ifdef __WATCOMC__
+#include <i86.h>
+#else
#ifdef _M_IX86
#include <windows.h>
#define timezone _timezone
@@ -59,6 +62,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define daylight _daylight
#define altzone _altzone
#endif
+#endif
/* Forward declarations */
static int floatsleep PROTO((double));
@@ -268,9 +272,17 @@ time_mktime(self, args)
object *args;
{
struct tm buf;
+ time_t tt;
+ tt = time(&tt);
+ buf = *localtime(&tt);
if (!gettmarg(args, &buf))
return NULL;
- return newintobject((long)mktime(&buf));
+ tt = mktime(&buf);
+ if (tt == (time_t)(-1)) {
+ err_setstr(OverflowError, "mktime argument out of range");
+ return NULL;
+ }
+ return newfloatobject((double)tt);
}
static struct methodlist time_methods[] = {
@@ -423,6 +435,10 @@ floatsleep(secs)
return -1;
}
#else /* !macintosh */
+#ifdef __WATCOMC__
+ /* XXX Can't interrupt this sleep */
+ delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */
+#else /* !__WATCOMC__ */
#ifdef MSDOS
struct timeb t1, t2;
double frac;
@@ -459,6 +475,7 @@ floatsleep(secs)
sleep((int)secs);
#endif /* _M_IX86 */
#endif /* !MSDOS */
+#endif /* !__WATCOMC__ */
#endif /* !macintosh */
#endif /* !HAVE_SELECT */
return 0;