projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Don't test the ACL_TYPE_DEFAULT ACL on OSF/1.
[gnulib.git]
/
lib
/
posixtm.c
diff --git
a/lib/posixtm.c
b/lib/posixtm.c
index
85936f3
..
fff53f5
100644
(file)
--- a/
lib/posixtm.c
+++ b/
lib/posixtm.c
@@
-1,12
+1,12
@@
/* Parse dates for touch and date.
/* Parse dates for touch and date.
- Copyright (C) 1989, 1990, 1991, 1998, 2000, 2001, 2002, 2003, 2004,
2005
- Free Software Foundation Inc.
+ Copyright (C) 1989, 1990, 1991, 1998, 2000, 2001, 2002, 2003, 2004,
+
2005, 2006, 2007
Free Software Foundation Inc.
- This program is free software
;
you can redistribute it and/or modify
+ This program is free software
:
you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version
2, or (at your option)
- any later version.
+ the Free Software Foundation; either version
3 of the License, or
+
(at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-14,41
+14,30
@@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Yacc-based version written by Jim Kingdon and David MacKenzie.
Rewritten by Jim Meyering. */
/* Yacc-based version written by Jim Kingdon and David MacKenzie.
Rewritten by Jim Meyering. */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include <config.h>
-#include
<stdbool.h>
+#include
"posixtm.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
-#ifdef TM_IN_SYS_TIME
-# include <sys/time.h>
-#else
-# include <time.h>
-#endif
-
-#include "posixtm.h"
-
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
/* ISDIGIT differs from isdigit, as follows:
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
/* ISDIGIT differs from isdigit, as follows:
- - Its arg may be any int or unsigned int; it need not be an unsigned char
.
-
- It's guaranteed to evaluate its argument exactly once
.
+ - Its arg may be any int or unsigned int; it need not be an unsigned char
+
or EOF
.
- It's typically faster.
POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
- It's typically faster.
POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
-
ISDIGIT_LOCALE
unless it's important to use the locale's definition
+
isdigit
unless it's important to use the locale's definition
of `digit' even when the host does not conform to POSIX. */
#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
of `digit' even when the host does not conform to POSIX. */
#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
@@
-62,8
+51,8
@@
time_t mktime ();
(PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS)
touch mmddhhmm[YY] FILE... (obsoleted by POSIX 1003.1-2001)
(PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS)
touch mmddhhmm[YY] FILE... (obsoleted by POSIX 1003.1-2001)
- 8 or 10 digits
- (PDS_TRAILING_YEAR)
+ 8 or 10 digits
, YY (if present) must be in the range 69-99
+ (PDS_TRAILING_YEAR
| PDS_PRE_2000
)
date mmddhhmm[[CC]YY]
8, 10, or 12 digits
date mmddhhmm[[CC]YY]
8, 10, or 12 digits
@@
-72,7
+61,7
@@
time_t mktime ();
*/
static int
*/
static int
-year (struct tm *tm, const int *digit_pair, size_t n,
int allow_century
)
+year (struct tm *tm, const int *digit_pair, size_t n,
unsigned int syntax_bits
)
{
switch (n)
{
{
switch (n)
{
@@
-82,11
+71,15
@@
year (struct tm *tm, const int *digit_pair, size_t n, int allow_century)
POSIX requires that 00-68 be interpreted as 2000-2068,
and that 69-99 be interpreted as 1969-1999. */
if (digit_pair[0] <= 68)
POSIX requires that 00-68 be interpreted as 2000-2068,
and that 69-99 be interpreted as 1969-1999. */
if (digit_pair[0] <= 68)
- tm->tm_year += 100;
+ {
+ if (syntax_bits & PDS_PRE_2000)
+ return 1;
+ tm->tm_year += 100;
+ }
break;
case 2:
break;
case 2:
- if (!
allow_century
)
+ if (!
(syntax_bits & PDS_CENTURY)
)
return 1;
tm->tm_year = digit_pair[0] * 100 + digit_pair[1] - 1900;
break;
return 1;
tm->tm_year = digit_pair[0] * 100 + digit_pair[1] - 1900;
break;
@@
-148,7
+141,7
@@
posix_time_parse (struct tm *tm, const char *s, unsigned int syntax_bits)
p = pair;
if (syntax_bits & PDS_LEADING_YEAR)
{
p = pair;
if (syntax_bits & PDS_LEADING_YEAR)
{
- if (year (tm, p, len - 4, syntax_bits
& PDS_CENTURY
))
+ if (year (tm, p, len - 4, syntax_bits))
return 1;
p += len - 4;
len = 4;
return 1;
p += len - 4;
len = 4;
@@
-164,7
+157,7
@@
posix_time_parse (struct tm *tm, const char *s, unsigned int syntax_bits)
/* Handle any trailing year. */
if (syntax_bits & PDS_TRAILING_YEAR)
{
/* Handle any trailing year. */
if (syntax_bits & PDS_TRAILING_YEAR)
{
- if (year (tm, p, len, syntax_bits
& PDS_CENTURY
))
+ if (year (tm, p, len, syntax_bits))
return 1;
}
return 1;
}
@@
-329,6
+322,6
@@
main (void)
\f
/*
Local Variables:
\f
/*
Local Variables:
-compile-command: "gcc -DTEST_POSIXTIME -
DHAVE_CONFIG_H -I.. -
g -O -Wall -W posixtm.c"
+compile-command: "gcc -DTEST_POSIXTIME -g -O -Wall -W posixtm.c"
End:
*/
End:
*/