Add MODE=optlinux build mode (#141)

This commit is contained in:
Justine Tunney 2021-10-14 19:36:49 -07:00
parent 226aaf3547
commit 67b5200a0b
111 changed files with 934 additions and 854 deletions

View file

@ -17,6 +17,7 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/alg/alg.h"
#include "libc/dce.h"
#include "libc/mem/internal.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
@ -25,6 +26,8 @@
#define MAX_VARS 512
#define ToUpper(c) ((c) >= 'a' && (c) <= 'z' ? (c) - 'a' + 'A' : (c))
static bool once;
static void PutEnvDestroy(void) {
@ -56,8 +59,12 @@ int PutEnvImpl(char *s, bool overwrite) {
PutEnvInit();
once = true;
}
p = strchr(s, '=');
if (!p) goto fail;
for (p = s; *p && *p != '='; ++p) {
if (IsWindows()) {
*p = ToUpper(*p);
}
}
if (*p != '=') goto fail;
namelen = p + 1 - s;
for (i = 0; environ[i]; ++i) {
if (!strncmp(environ[i], s, namelen)) {