mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Make fixes and improvements
- Polyfill UTIME_OMIT on XNU - Refactor Lua build code so it's better - Add unix module to lua.com (Discord request) - Add unix.utimensat() and unix.futimens() to redbean - Avoid creating double slash path in linenoise (#428) - Remove double slashes in NT paths automatically (#428) - Make strerror() smarter about showing NT errors (#428) Fixes #428
This commit is contained in:
parent
67b28b9af1
commit
c1cfca8ae1
18 changed files with 569 additions and 194 deletions
|
@ -43,3 +43,10 @@ TEST(mkntpath, testUnicode) {
|
|||
EXPECT_EQ(20, __mkntpath("C:\\𐌰𐌱𐌲𐌳\\𐌴𐌵𐌶𐌷", p));
|
||||
EXPECT_STREQ(u"C:\\𐌰𐌱𐌲𐌳\\𐌴𐌵𐌶𐌷", p);
|
||||
}
|
||||
|
||||
TEST(mkntpath, testRemoveDoubleSlash) {
|
||||
EXPECT_EQ(21, __mkntpath("C:\\Users\\jart\\\\.config", p));
|
||||
EXPECT_STREQ(u"C:\\Users\\jart\\.config", p);
|
||||
EXPECT_EQ(8, __mkntpath("\\\\?\\doge", p));
|
||||
EXPECT_STREQ(u"\\\\?\\doge", p);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,14 @@ TEST(open, eexist) {
|
|||
ASSERT_SYS(EEXIST, -1, open("exists", O_WRONLY | O_CREAT | O_EXCL));
|
||||
}
|
||||
|
||||
TEST(open, doubleSlash_worksAndGetsNormalizedOnWindows) {
|
||||
ASSERT_SYS(0, 0, mkdir("o", 0755));
|
||||
ASSERT_SYS(0, 3,
|
||||
open(gc(xjoinpaths(gc(getcwd(0, 0)), "o//deleteme")),
|
||||
O_WRONLY | O_CREAT | O_TRUNC, 0644));
|
||||
ASSERT_SYS(0, 0, close(3));
|
||||
}
|
||||
|
||||
TEST(open, enametoolong) {
|
||||
size_t n = 260;
|
||||
char *s = gc(xcalloc(1, n + 1));
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/utime.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/time/time.h"
|
||||
|
||||
|
@ -59,3 +60,20 @@ TEST(futimens, test) {
|
|||
EXPECT_EQ(1655455857, st.st_atim.tv_sec);
|
||||
EXPECT_EQ(827727928, st.st_mtim.tv_sec);
|
||||
}
|
||||
|
||||
TEST(utimensat, testOmit) {
|
||||
if (IsLinux() && !__is_linux_2_6_23()) {
|
||||
// TODO(jart): Ugh.
|
||||
return;
|
||||
}
|
||||
struct stat st;
|
||||
struct timespec ts[2] = {
|
||||
{123, UTIME_OMIT},
|
||||
{123, UTIME_OMIT},
|
||||
};
|
||||
EXPECT_SYS(0, 0, touch("boop", 0644));
|
||||
EXPECT_SYS(0, 0, utimensat(AT_FDCWD, "boop", ts, 0));
|
||||
EXPECT_SYS(0, 0, stat("boop", &st));
|
||||
EXPECT_NE(123, st.st_atim.tv_sec);
|
||||
EXPECT_NE(123, st.st_mtim.tv_sec);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/intrin/wait0.internal.h"
|
||||
|
@ -60,6 +61,10 @@ int Worker(void *p) {
|
|||
}
|
||||
|
||||
TEST(dtoa, test) {
|
||||
if (IsNetbsd()) {
|
||||
// TODO(jart): Why does this flake on NetBSD?!
|
||||
return;
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < THREADS; ++i) {
|
||||
clone(Worker,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue