mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Add nl_langinfo(3).
This commit is contained in:
parent
601bed32fb
commit
67471b55e7
4 changed files with 214 additions and 0 deletions
|
@ -373,6 +373,8 @@ ioleast/readall.o \
|
|||
ioleast/readleast.o \
|
||||
ioleast/writeall.o \
|
||||
ioleast/writeleast.o \
|
||||
langinfo/nl_langinfo_l.o \
|
||||
langinfo/nl_langinfo.o \
|
||||
locale/localeconv.o \
|
||||
locale/setlocale.o \
|
||||
msr/rdmsr.o \
|
||||
|
|
103
libc/include/langinfo.h
Normal file
103
libc/include/langinfo.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Jonas 'Sortie' Termansen.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* langinfo.h
|
||||
* Language information constants.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_LANGINFO_H
|
||||
#define INCLUDE_LANGINFO_H
|
||||
|
||||
#ifndef __locale_t_defined
|
||||
#define __locale_t_defined
|
||||
/* TODO: figure out what this does and typedef it properly. This is just a
|
||||
temporary assignment. */
|
||||
typedef int __locale_t;
|
||||
typedef __locale_t locale_t;
|
||||
#endif
|
||||
|
||||
#ifndef __nl_item_defined
|
||||
#define __nl_item_defined
|
||||
typedef int nl_item;
|
||||
#endif
|
||||
|
||||
#define CODESET 1
|
||||
#define D_T_FMT 2
|
||||
#define D_FMT 3
|
||||
#define T_FMT 4
|
||||
#define T_FMT_AMPM 5
|
||||
#define AM_STR 6
|
||||
#define PM_STR 7
|
||||
#define DAY_1 8
|
||||
#define DAY_2 9
|
||||
#define DAY_3 10
|
||||
#define DAY_4 11
|
||||
#define DAY_5 12
|
||||
#define DAY_6 13
|
||||
#define DAY_7 14
|
||||
#define ABDAY_1 15
|
||||
#define ABDAY_2 16
|
||||
#define ABDAY_3 17
|
||||
#define ABDAY_4 18
|
||||
#define ABDAY_5 19
|
||||
#define ABDAY_6 20
|
||||
#define ABDAY_7 21
|
||||
#define MON_1 22
|
||||
#define MON_2 23
|
||||
#define MON_3 24
|
||||
#define MON_4 25
|
||||
#define MON_5 26
|
||||
#define MON_6 27
|
||||
#define MON_7 28
|
||||
#define MON_8 29
|
||||
#define MON_9 30
|
||||
#define MON_10 31
|
||||
#define MON_11 32
|
||||
#define MON_12 33
|
||||
#define ABMON_1 34
|
||||
#define ABMON_2 35
|
||||
#define ABMON_3 36
|
||||
#define ABMON_4 37
|
||||
#define ABMON_5 38
|
||||
#define ABMON_6 39
|
||||
#define ABMON_7 40
|
||||
#define ABMON_8 41
|
||||
#define ABMON_9 42
|
||||
#define ABMON_10 43
|
||||
#define ABMON_11 44
|
||||
#define ABMON_12 45
|
||||
#define ERA 46
|
||||
#define ERA_D_FMT 47
|
||||
#define ERA_D_T_FMT 48
|
||||
#define ERA_T_FMT 49
|
||||
#define ALT_DIGITS 50
|
||||
#define RADIXCHAR 51
|
||||
#define THOUSEP 52
|
||||
#define YESEXPR 53
|
||||
#define NOEXPR 54
|
||||
#define CRNCYSTR 55
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char* nl_langinfo(nl_item);
|
||||
char* nl_langinfo_l(nl_item, locale_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
25
libc/langinfo/nl_langinfo.c
Normal file
25
libc/langinfo/nl_langinfo.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Jonas 'Sortie' Termansen.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* langinfo/nl_langinfo.c
|
||||
* Language information.
|
||||
*/
|
||||
|
||||
#include <langinfo.h>
|
||||
|
||||
char* nl_langinfo(nl_item item)
|
||||
{
|
||||
return nl_langinfo_l(item, 0 /* TODO */);
|
||||
}
|
84
libc/langinfo/nl_langinfo_l.c
Normal file
84
libc/langinfo/nl_langinfo_l.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Jonas 'Sortie' Termansen.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* langinfo/nl_langinfo_l.c
|
||||
* Language information.
|
||||
*/
|
||||
|
||||
#include <langinfo.h>
|
||||
|
||||
char* nl_langinfo_l(nl_item item, locale_t locale)
|
||||
{
|
||||
(void) locale; /* TODO */
|
||||
switch ( item )
|
||||
{
|
||||
case CODESET: return "UTF-8";
|
||||
case D_T_FMT: return "%a %b %e %T %Y";
|
||||
case D_FMT: return "%Y-%m-%d";
|
||||
case T_FMT: return "%H:%M:%S";
|
||||
case T_FMT_AMPM: return "%I:%M:%S %p";
|
||||
case AM_STR: return "AM";
|
||||
case PM_STR: return "PM";
|
||||
case DAY_1: return "Sunday";
|
||||
case DAY_2: return "Monday";
|
||||
case DAY_3: return "Tuesday";
|
||||
case DAY_4: return "Wednesday";
|
||||
case DAY_5: return "Thursday";
|
||||
case DAY_6: return "Friday";
|
||||
case DAY_7: return "Saturday";
|
||||
case ABDAY_1: return "Sun";
|
||||
case ABDAY_2: return "Mon";
|
||||
case ABDAY_3: return "Tue";
|
||||
case ABDAY_4: return "Wed";
|
||||
case ABDAY_5: return "Thu";
|
||||
case ABDAY_6: return "Fri";
|
||||
case ABDAY_7: return "Sat";
|
||||
case MON_1: return "January";
|
||||
case MON_2: return "February";
|
||||
case MON_3: return "March";
|
||||
case MON_4: return "April";
|
||||
case MON_5: return "May";
|
||||
case MON_6: return "June";
|
||||
case MON_7: return "July";
|
||||
case MON_8: return "August";
|
||||
case MON_9: return "September";
|
||||
case MON_10: return "October";
|
||||
case MON_11: return "November";
|
||||
case MON_12: return "December";
|
||||
case ABMON_1: return "Jan";
|
||||
case ABMON_2: return "Feb";
|
||||
case ABMON_3: return "Mar";
|
||||
case ABMON_4: return "Apr";
|
||||
case ABMON_5: return "May";
|
||||
case ABMON_6: return "Jun";
|
||||
case ABMON_7: return "Jul";
|
||||
case ABMON_8: return "Aug";
|
||||
case ABMON_9: return "Sep";
|
||||
case ABMON_10: return "Oct";
|
||||
case ABMON_11: return "Nov";
|
||||
case ABMON_12: return "Dec";
|
||||
case ERA: return "";
|
||||
case ERA_D_FMT: return "";
|
||||
case ERA_D_T_FMT: return "";
|
||||
case ERA_T_FMT: return "";
|
||||
case ALT_DIGITS: return "";
|
||||
case RADIXCHAR: return ".";
|
||||
case THOUSEP: return "";
|
||||
case YESEXPR: return "^[yY]";
|
||||
case NOEXPR: return "^[nN]";
|
||||
case CRNCYSTR: return "";
|
||||
}
|
||||
return "";
|
||||
}
|
Loading…
Reference in a new issue