The relevant files under libc/locale and libc/time/__asctime.c
are pretty much identical to their copies under musl/
so we are replacing them with current version.

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
---
 Makefile                    |  5 ++-
 libc/locale/langinfo.c      | 61 -------------------------------------
 libc/locale/nl_langinfo_l.c | 11 -------
 libc/time/__asctime.c       | 28 -----------------
 4 files changed, 2 insertions(+), 103 deletions(-)
 delete mode 100644 libc/locale/langinfo.c
 delete mode 100644 libc/locale/nl_langinfo_l.c
 delete mode 100644 libc/time/__asctime.c

diff --git a/Makefile b/Makefile
index 6d39e5bf..2d19ccc6 100644
--- a/Makefile
+++ b/Makefile
@@ -1038,9 +1038,8 @@ musl += locale/iswspace_l.o
 musl += locale/iswupper_l.o
 musl += locale/iswxdigit_l.o
 musl += locale/isxdigit_l.o
-libc += locale/langinfo.o
+musl += locale/langinfo.o
 musl += locale/localeconv.o
-libc += locale/nl_langinfo_l.o
 musl += locale/setlocale.o
 musl += locale/strcasecmp_l.o
 musl += locale/strcoll.o
@@ -1643,7 +1642,7 @@ musl += temp/mktemp.o
 musl += temp/mkostemp.o
 musl += temp/mkostemps.o
 
-libc += time/__asctime.o
+musl += time/__asctime.o
 musl += time/__map_file.o
 $(out)/musl/src/time/__map_file.o: CFLAGS += --include 
libc/syscall_to_function.h
 musl += time/__month_to_secs.o
diff --git a/libc/locale/langinfo.c b/libc/locale/langinfo.c
deleted file mode 100644
index 01593148..00000000
--- a/libc/locale/langinfo.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <locale.h>
-#include <langinfo.h>
-#include "libc.h"
-
-static const char c_time[] =
-       "Sun\0" "Mon\0" "Tue\0" "Wed\0" "Thu\0" "Fri\0" "Sat\0"
-       "Sunday\0" "Monday\0" "Tuesday\0" "Wednesday\0"
-       "Thursday\0" "Friday\0" "Saturday\0"
-       "Jan\0" "Feb\0" "Mar\0" "Apr\0" "May\0" "Jun\0"
-       "Jul\0" "Aug\0" "Sep\0" "Oct\0" "Nov\0" "Dec\0"
-       "January\0"   "February\0" "March\0"    "April\0"
-       "May\0"       "June\0"     "July\0"     "August\0"
-       "September\0" "October\0"  "November\0" "December\0"
-       "AM\0" "PM\0"
-       "%a %b %e %T %Y\0"
-       "%m/%d/%y\0"
-       "%H:%M:%S\0"
-       "%I:%M:%S %p\0"
-       "\0"
-       "%m/%d/%y\0"
-       "0123456789"
-       "%a %b %e %T %Y\0"
-       "%H:%M:%S";
-
-static const char c_messages[] = "^[yY]\0" "^[nN]";
-static const char c_numeric[] = ".\0" "";
-
-char *__langinfo(nl_item item)
-{
-       int cat = item >> 16;
-       int idx = item & 65535;
-       const char *str;
-
-       if (item == CODESET) return "UTF-8";
-       
-       switch (cat) {
-       case LC_NUMERIC:
-               if (idx > 1) return NULL;
-               str = c_numeric;
-               break;
-       case LC_TIME:
-               if (idx > 0x31) return NULL;
-               str = c_time;
-               break;
-       case LC_MONETARY:
-               if (idx > 0) return NULL;
-               str = "";
-               break;
-       case LC_MESSAGES:
-               if (idx > 1) return NULL;
-               str = c_messages;
-               break;
-       default:
-               return NULL;
-       }
-
-       for (; idx; idx--, str++) for (; *str; str++);
-       return (char *)str;
-}
-
-weak_alias(__langinfo, nl_langinfo);
diff --git a/libc/locale/nl_langinfo_l.c b/libc/locale/nl_langinfo_l.c
deleted file mode 100644
index 2c5a9794..00000000
--- a/libc/locale/nl_langinfo_l.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <locale.h>
-#include <langinfo.h>
-#include "libc.h"
-
-char *__nl_langinfo_l(nl_item item, locale_t l)
-{
-       return nl_langinfo(item);
-}
-
-/* OSv local: a libstdc++ build against glibc wants the __ version */
-weak_alias(__nl_langinfo_l, nl_langinfo_l);
diff --git a/libc/time/__asctime.c b/libc/time/__asctime.c
deleted file mode 100644
index 5362f0db..00000000
--- a/libc/time/__asctime.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <time.h>
-#include <stdio.h>
-#include <langinfo.h>
-#include "atomic.h"
-
-const char *__langinfo(nl_item);
-
-char *__asctime(const struct tm *restrict tm, char *restrict buf)
-{
-       /* FIXME: change __langinfo to __C_langinfo once we have locales */
-       if (snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
-               __langinfo(ABDAY_1+tm->tm_wday),
-               __langinfo(ABMON_1+tm->tm_mon),
-               tm->tm_mday, tm->tm_hour,
-               tm->tm_min, tm->tm_sec,
-               1900 + tm->tm_year) >= 26)
-       {
-               /* ISO C requires us to use the above format string,
-                * even if it will not fit in the buffer. Thus asctime_r
-                * is _supposed_ to crash if the fields in tm are too large.
-                * We follow this behavior and crash "gracefully" to warn
-                * application developers that they may not be so lucky
-                * on other implementations (e.g. stack smashing..).
-                */
-               a_crash();
-       }
-       return buf;
-}
-- 
2.26.2

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20200826035356.201786-5-jwkozaczuk%40gmail.com.

Reply via email to