Add support for LC_TIME, from Joachim Kuebart, through PR lib/10877
This commit is contained in:
parent
c32a7179d7
commit
7e349f87af
|
@ -1,4 +1,4 @@
|
|||
LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.816 $>
|
||||
LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.817 $>
|
||||
|
||||
|
||||
[Note: This file does not mention every change made to the NetBSD source tree.
|
||||
|
@ -71,3 +71,4 @@ Changes from NetBSD 4.0 to NetBSD 5.0:
|
|||
power and overheating in CPUs supporting the Thermal
|
||||
Monitor feature (TM). Adapted from OpenBSD/FreeBSD.
|
||||
See options(4) for more information. [xtraeme 20070320]
|
||||
libc: add support for LC_TIME [manu 20070328]
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# from: @(#)Makefile.inc 5.1 (Berkeley) 2/18/91
|
||||
# $NetBSD: Makefile.inc,v 1.50 2006/10/13 17:28:09 tnozaki Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.51 2007/03/28 19:05:48 manu Exp $
|
||||
|
||||
# locale sources
|
||||
.PATH: ${ARCHDIR}/locale ${.CURDIR}/locale
|
||||
|
||||
SRCS+= _def_messages.c _def_monetary.c _def_numeric.c _def_time.c \
|
||||
ctypeio.c localeconv.c nl_langinfo.c setlocale.c setlocale1.c \
|
||||
setlocale32.c __mb_cur_max.c wcscoll.c wcsftime.c \
|
||||
setlocale32.c __mb_cur_max.c wcscoll.c wcsftime.c timeio.c \
|
||||
wcstol.c wcstoll.c wcstoimax.c wcstoul.c wcstoull.c wcstoumax.c \
|
||||
wcsxfrm.c aliasname.c
|
||||
MAN+= nl_langinfo.3 setlocale.3 wcstol.3 wcscoll.3 wcsxfrm.3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: _def_time.c,v 1.8 2005/06/12 05:21:27 lukem Exp $ */
|
||||
/* $NetBSD: _def_time.c,v 1.9 2007/03/28 19:05:53 manu Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
|
@ -7,13 +7,13 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: _def_time.c,v 1.8 2005/06/12 05:21:27 lukem Exp $");
|
||||
__RCSID("$NetBSD: _def_time.c,v 1.9 2007/03/28 19:05:53 manu Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/localedef.h>
|
||||
#include <locale.h>
|
||||
|
||||
const _TimeLocale _DefaultTimeLocale =
|
||||
_TimeLocale _DefaultTimeLocale =
|
||||
{
|
||||
{
|
||||
"Sun","Mon","Tue","Wed","Thu","Fri","Sat",
|
||||
|
@ -39,4 +39,4 @@ const _TimeLocale _DefaultTimeLocale =
|
|||
"%I:%M:%S %p"
|
||||
};
|
||||
|
||||
const _TimeLocale *_CurrentTimeLocale = &_DefaultTimeLocale;
|
||||
_TimeLocale *_CurrentTimeLocale = &_DefaultTimeLocale;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: setlocale.c,v 1.50 2006/02/16 19:19:49 tnozaki Exp $ */
|
||||
/* $NetBSD: setlocale.c,v 1.51 2007/03/28 19:05:53 manu Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)setlocale.c 8.1 (Berkeley) 7/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: setlocale.c,v 1.50 2006/02/16 19:19:49 tnozaki Exp $");
|
||||
__RCSID("$NetBSD: setlocale.c,v 1.51 2007/03/28 19:05:53 manu Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -63,6 +63,7 @@ __RCSID("$NetBSD: setlocale.c,v 1.50 2006/02/16 19:19:49 tnozaki Exp $");
|
|||
#else
|
||||
#include "ctypeio.h"
|
||||
#endif
|
||||
#include "timeio.h"
|
||||
|
||||
#ifdef CITRUS
|
||||
#include <citrus/citrus_namespace.h>
|
||||
|
@ -263,11 +264,16 @@ revert_to_default(category)
|
|||
}
|
||||
#endif
|
||||
break;
|
||||
case LC_TIME:
|
||||
if (_CurrentTimeLocale != &_DefaultTimeLocale) {
|
||||
free((void *)_CurrentTimeLocale);
|
||||
_CurrentTimeLocale = &_DefaultTimeLocale;
|
||||
}
|
||||
break;
|
||||
case LC_MESSAGES:
|
||||
case LC_COLLATE:
|
||||
case LC_MONETARY:
|
||||
case LC_NUMERIC:
|
||||
case LC_TIME:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -341,10 +347,13 @@ load_locale_sub(category, locname, isspecial)
|
|||
}
|
||||
break;
|
||||
|
||||
case LC_TIME:
|
||||
if (!__loadtime(name))
|
||||
return -1;
|
||||
break;
|
||||
case LC_COLLATE:
|
||||
case LC_MONETARY:
|
||||
case LC_NUMERIC:
|
||||
case LC_TIME:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/* $NetBSD: timeio.c,v 1.1 2007/03/28 19:05:53 manu Exp $ */
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Joachim Kuebart. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Joachim Kuebart.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/localedef.h>
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "timeio.h"
|
||||
|
||||
|
||||
int
|
||||
__loadtime(name)
|
||||
const char *name;
|
||||
{
|
||||
FILE *fp;
|
||||
struct stat st;
|
||||
unsigned char **ab, *p, *pend;
|
||||
_TimeLocale *tl;
|
||||
|
||||
|
||||
|
||||
|
||||
if ((fp = fopen(name, "r")) == NULL)
|
||||
return 0;
|
||||
if (fstat(fileno(fp), &st) != 0) {
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
if ((tl = malloc(sizeof(*tl) + (unsigned)st.st_size)) == NULL) {
|
||||
(void) fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
if (fread(tl + 1, (unsigned)st.st_size, 1, fp) != 1)
|
||||
goto bad;
|
||||
(void) fclose(fp);
|
||||
/* LINTED pointer cast */
|
||||
p = (unsigned char *)&tl[1];
|
||||
pend = p + (unsigned)st.st_size;
|
||||
/* LINTED pointer cast */
|
||||
for (ab = (unsigned char **)tl;
|
||||
ab != (unsigned char **)&tl[1];
|
||||
ab++) {
|
||||
*ab = p;
|
||||
while (p != pend && *p != '\n')
|
||||
p++;
|
||||
if (p == pend)
|
||||
goto bad;
|
||||
*p++ = '\0';
|
||||
}
|
||||
if (_CurrentTimeLocale != &_DefaultTimeLocale)
|
||||
/* LINTED const castaway */
|
||||
free((void *)_CurrentTimeLocale);
|
||||
_CurrentTimeLocale = tl;
|
||||
return 1;
|
||||
bad:
|
||||
free(tl);
|
||||
(void) fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/* $NetBSD: timeio.h,v 1.1 2007/03/28 19:05:54 manu Exp $ */
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Joachim Kuebart. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Joachim Kuebart.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
__BEGIN_DECLS
|
||||
int __loadtime __P((const char *));
|
||||
__END_DECLS
|
Loading…
Reference in New Issue