mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 19:28:29 +00:00
Improve linenoise and get it working on Windows
Some progress has been made on introducing completion but there's been difficulties using the Python C API to get local shell variables.
This commit is contained in:
parent
968474d291
commit
5029e20bef
23 changed files with 408 additions and 209 deletions
|
@ -53,6 +53,7 @@ void *xunbinga(size_t, const char16_t *) attributeallocalign((1)) _XMAL _XRET;
|
|||
void *xunbing(const char16_t *) _XMAL _XRET;
|
||||
char16_t *utf8toutf16(const char *, size_t, size_t *) nodiscard;
|
||||
char *utf16toutf8(const char16_t *, size_t, size_t *) nodiscard;
|
||||
char *xhomedir(void) nodiscard;
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § eXtended apis » files ─╬─│┼
|
||||
|
|
43
libc/x/xhomedir.c
Normal file
43
libc/x/xhomedir.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*-*- 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/dce.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
/**
|
||||
* Returns home directory.
|
||||
*/
|
||||
char *xhomedir(void) {
|
||||
int fd;
|
||||
const char *a, *b;
|
||||
if ((a = getenv("HOME"))) {
|
||||
b = "";
|
||||
} else if (IsWindows()) {
|
||||
a = getenv("HOMEDRIVE");
|
||||
b = getenv("HOMEPATH");
|
||||
if (!a || !b) {
|
||||
a = "C:";
|
||||
b = "";
|
||||
}
|
||||
} else {
|
||||
a = ".";
|
||||
b = "";
|
||||
}
|
||||
return xasprintf("%s%s", a, b);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue