Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/time Use correct number of digits as described in l...
details: https://anonhg.NetBSD.org/src/rev/b1d7c015d194
branches: trunk
changeset: 472404:b1d7c015d194
user: tv <tv%NetBSD.org@localhost>
date: Thu Apr 29 02:58:30 1999 +0000
description:
Use correct number of digits as described in lib/7001. This brings us
pretty close to UNIX98, but %U and %W still don't work.
diffstat:
lib/libc/time/strptime.c | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
diffs (65 lines):
diff -r 9306f4912af1 -r b1d7c015d194 lib/libc/time/strptime.c
--- a/lib/libc/time/strptime.c Thu Apr 29 02:55:50 1999 +0000
+++ b/lib/libc/time/strptime.c Thu Apr 29 02:58:30 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strptime.c,v 1.17 1998/11/15 17:11:06 christos Exp $ */
+/* $NetBSD: strptime.c,v 1.18 1999/04/29 02:58:30 tv Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: strptime.c,v 1.17 1998/11/15 17:11:06 christos Exp $");
+__RCSID("$NetBSD: strptime.c,v 1.18 1999/04/29 02:58:30 tv Exp $");
#endif
#include "namespace.h"
@@ -130,7 +130,7 @@
if (!(bp = strptime(bp, "%m/%d/%y", tm)))
return (0);
break;
-
+
case 'R': /* The time as "%H:%M". */
LEGAL_ALT(0);
if (!(bp = strptime(bp, "%H:%M", tm)))
@@ -321,7 +321,7 @@
case 'Y': /* The year. */
LEGAL_ALT(ALT_E);
- if (!(conv_num(&bp, &i, 0, INT_MAX)))
+ if (!(conv_num(&bp, &i, 0, 9999)))
return (0);
tm->tm_year = i - TM_YEAR_BASE;
@@ -372,18 +372,23 @@
int *dest;
int llim, ulim;
{
- *dest = 0;
+ int result = 0;
+
+ /* The limit also determines the number of valid digits. */
+ int rulim = ulim;
if (**buf < '0' || **buf > '9')
return (0);
do {
- *dest *= 10;
- *dest += *(*buf)++ - '0';
- } while ((*dest * 10 <= ulim) && **buf >= '0' && **buf <= '9');
+ result *= 10;
+ result += *(*buf)++ - '0';
+ rulim /= 10;
+ } while ((result * 10 <= ulim) && rulim && **buf >= '0' && **buf <= '9');
- if (*dest < llim || *dest > ulim)
+ if (result < llim || result > ulim)
return (0);
+ *dest = result;
return (1);
}
Home |
Main Index |
Thread Index |
Old Index