mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-12 05:59:10 +00:00
Implement getcwd() for XNU
This commit is contained in:
parent
417797d218
commit
95173645a1
17 changed files with 239 additions and 77 deletions
|
@ -24,7 +24,7 @@
|
|||
* This API was thought to be nearly extinct until recent versions
|
||||
* of Clang (c. 2019) started generating synthetic calls to it.
|
||||
*
|
||||
* @return unsigned char subtraction at stop index
|
||||
* @return 0 if a and b have equal contents, otherwise non-zero
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
int bcmp(const void *a, const void *b, size_t n) {
|
||||
|
|
|
@ -151,11 +151,13 @@ int strcasecmpzbw(const uint16_t *, const char *) strlenesque;
|
|||
char *stpcpy(char *, const char *) memcpyesque;
|
||||
char *stpncpy(char *, const char *, size_t) memcpyesque;
|
||||
char *strcat(char *, const char *) memcpyesque;
|
||||
char16_t *strcat16(char16_t *, const char16_t *);
|
||||
char16_t *strcat16(char16_t *, const char16_t *) memcpyesque;
|
||||
wchar_t *wcscat(wchar_t *, const wchar_t *) memcpyesque;
|
||||
size_t strlcpy(char *, const char *, size_t);
|
||||
size_t strlcat(char *, const char *, size_t);
|
||||
char *strcpy(char *, const char *) memcpyesque;
|
||||
char16_t *strcpy16(char16_t *, const char16_t *) memcpyesque;
|
||||
wchar_t *wcscpy(wchar_t *, const wchar_t *) memcpyesque;
|
||||
char *strncat(char *, const char *, size_t) memcpyesque;
|
||||
char *strncpy(char *, const char *, size_t) memcpyesque;
|
||||
char *strtok(char *, const char *) paramsnonnull((2)) libcesque;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/pcmpeqb.h"
|
||||
#include "libc/intrin/pmovmskb.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,5 +28,5 @@
|
|||
* @return original dest
|
||||
*/
|
||||
char16_t *strcpy16(char16_t *dest, const char16_t *src) {
|
||||
return memcpy(dest, src, (strlen16(src) + 1) << 1);
|
||||
return memcpy(dest, src, (strlen16(src) + 1) * sizeof(char16_t));
|
||||
}
|
||||
|
|
31
libc/str/wcscat.c
Normal file
31
libc/str/wcscat.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- 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 2020 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/str/str.h"
|
||||
|
||||
/**
|
||||
* Appends 𝑠 to 𝑑.
|
||||
*
|
||||
* @param 𝑑 is a NUL-terminated 32-bit string
|
||||
* @param 𝑠 is a NUL-terminated 32-bit string
|
||||
* @return 𝑑
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
wchar_t *wcscat(wchar_t *d, const wchar_t *s) {
|
||||
return wcscpy(d + wcslen(d), s);
|
||||
}
|
33
libc/str/wcscpy.c
Normal file
33
libc/str/wcscpy.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 2020 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/str/str.h"
|
||||
|
||||
/**
|
||||
* Copies NUL-terminated wide character string.
|
||||
*
|
||||
* 𝑑 and 𝑠 must not overlap unless 𝑑 ≤ 𝑠.
|
||||
*
|
||||
* @param 𝑑 is destination memory
|
||||
* @param 𝑠 is a NUL-terminated string
|
||||
* @return original dest
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
wchar_t *wcscpy(wchar_t *d, const wchar_t *s) {
|
||||
return memcpy(d, s, (wcslen(s) + 1) * sizeof(wchar_t));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue