mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Implement setlocale() stub (#43)
This commit is contained in:
parent
08d3700c15
commit
667ab245fe
19 changed files with 56 additions and 84 deletions
33
libc/unicode/iconv.c
Normal file
33
libc/unicode/iconv.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or 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. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
typedef void *iconv_t;
|
||||
|
||||
iconv_t iconv_open(const char *to, const char *from) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int iconv_close(iconv_t cd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t iconv(iconv_t cd, char **in, size_t *inb, char **out, size_t *outb) {
|
||||
return -1;
|
||||
}
|
26
libc/unicode/locale.h
Normal file
26
libc/unicode/locale.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_UNICODE_LOCALE_H_
|
||||
#define COSMOPOLITAN_LIBC_UNICODE_LOCALE_H_
|
||||
|
||||
#define LC_CTYPE 0
|
||||
#define LC_NUMERIC 1
|
||||
#define LC_CTYPE_MASK 1
|
||||
#define LC_TIME 2
|
||||
#define LC_NUMERIC_MASK 2
|
||||
#define LC_COLLATE 3
|
||||
#define LC_MONETARY 4
|
||||
#define LC_TIME_MASK 4
|
||||
#define LC_MESSAGES 5
|
||||
#define LC_ALL 6
|
||||
#define LC_COLLATE_MASK 8
|
||||
#define LC_MONETARY_MASK 16
|
||||
#define LC_MESSAGES_MASK 32
|
||||
#define LC_ALL_MASK 0x1fbf
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
char *setlocale(int, const char *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_UNICODE_LOCALE_H_ */
|
29
libc/unicode/setlocale.c
Normal file
29
libc/unicode/setlocale.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or 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. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
/**
|
||||
* Sets program locale.
|
||||
*
|
||||
* Cosmopolitan only supports the C or POSIX locale.
|
||||
*/
|
||||
char *setlocale(int category, const char *locale) {
|
||||
return firstnonnull(locale, "C");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue