From f07856de0fb1b51e83b6229bb4c8721ea23efce6 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Tue, 29 Dec 2020 18:52:37 +0100 Subject: [PATCH] Mes C Library: m2/getcwd.c: Remove specialization. * lib/posix/getcwd.c (getcwd): Cater for M2-Planet. * lib/m2/getcwd.c: Remove. * kaem.run: Update accordingly. * simple.make (M2_SOURCES): Likewise. --- kaem.run | 2 +- lib/m2/getcwd.c | 37 ------------------------------------- lib/posix/getcwd.c | 15 ++++++++++----- simple.make | 2 +- 4 files changed, 12 insertions(+), 44 deletions(-) delete mode 100644 lib/m2/getcwd.c diff --git a/kaem.run b/kaem.run index 61a09bb0..703dd683 100644 --- a/kaem.run +++ b/kaem.run @@ -90,7 +90,7 @@ M2-Planet \ -f lib/m2/clock_gettime.c \ -f lib/m2/time.c \ -f lib/linux/_getcwd.c \ - -f lib/m2/getcwd.c \ + -f lib/posix/getcwd.c \ -f lib/linux/dup.c \ -f lib/linux/dup2.c \ -f lib/string/strcmp.c \ diff --git a/lib/m2/getcwd.c b/lib/m2/getcwd.c deleted file mode 100644 index b078dde4..00000000 --- a/lib/m2/getcwd.c +++ /dev/null @@ -1,37 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2019 Jan (janneke) Nieuwenhuizen - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see . - */ - -#include -#include -#include -#include - -// CONSTANT PATH_MAX 1024 - -char * -getcwd (char *buffer, int size) -{ - if (__getcwd_buf == 0) - __getcwd_buf = malloc (PATH_MAX); - char *buf = __itoa_buf; - if (buffer != 0) - return _getcwd (buffer, size); - return _getcwd (buf, PATH_MAX); -} diff --git a/lib/posix/getcwd.c b/lib/posix/getcwd.c index dd7b7f87..7eb4f28e 100644 --- a/lib/posix/getcwd.c +++ b/lib/posix/getcwd.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -19,15 +19,20 @@ */ #include +#include #include +#include #include -#include + +// CONSTANT PATH_MAX 1024 char * -getcwd (char *buffer, size_t size) +getcwd (char *buffer, int size) { - static char buf[PATH_MAX]; - if (buffer) + if (__getcwd_buf == 0) + __getcwd_buf = malloc (PATH_MAX); + char *buf = __getcwd_buf; + if (buffer != 0) return _getcwd (buffer, size); return _getcwd (buf, PATH_MAX); } diff --git a/simple.make b/simple.make index b40dd0ce..e8f3b977 100644 --- a/simple.make +++ b/simple.make @@ -129,7 +129,7 @@ M2_SOURCES = \ lib/m2/clock_gettime.c \ lib/m2/time.c \ lib/linux/_getcwd.c \ - lib/m2/getcwd.c \ + lib/posix/getcwd.c \ lib/linux/dup.c \ lib/linux/dup2.c \ lib/string/strcmp.c \