From: Waldemar Kozaczuk <[email protected]>
Committer: Waldemar Kozaczuk <[email protected]>
Branch: master

libc: replace locale/strfmon.c with the musl copy

This file had been imported from musl as part of the commit 
79d5ad7d6f7bbcc20edf2ce2bbf3cc08f04b08dd.
It looks like it got slightly modified to possibly silence the compiler (see 
the diff below).

```
diff musl/src/locale/strfmon.c libc/locale/strfmon.c
12c12
<       int fill, nogrp, negpar, nosym, left, intl;
Message-Id: <[email protected]>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1046,7 +1046,7 @@ musl += locale/strcasecmp_l.o
 libc += locale/strcoll.o
 libc += locale/strcoll_l.o
 musl += locale/strerror_l.o
-libc += locale/strfmon.o
+musl += locale/strfmon.o
 libc += locale/strftime_l.o
 musl += locale/strncasecmp_l.o
 libc += locale/strtod_l.o
diff --git a/libc/locale/strfmon.c b/libc/locale/strfmon.c
--- a/libc/locale/strfmon.c
+++ b/libc/locale/strfmon.c
@@ -1,91 +0,0 @@
-#include <stdio.h>
-#include <ctype.h>
-#include <stdarg.h>
-#include <monetary.h>
-#include <errno.h>
-#include <stdarg.h>
-
-static ssize_t vstrfmon_l(char *s, size_t n, locale_t loc, const char *fmt, 
va_list ap)
-{
-       size_t l;
-       double x;
-       int left;
-       int lp, rp, w, fw;
-       char *s0=s;
-       for (; n && *fmt; ) {
-               if (*fmt != '%') {
-               literal:
-                       *s++ = *fmt++;
-                       n--;
-                       continue;
-               }
-               fmt++;
-               if (*fmt == '%') goto literal;
-
-               left = 0;
-               for (; ; fmt++) {
-                       switch (*fmt) {
-                       case '=':
-                               continue;
-                       case '^':
-                               continue;
-                       case '(':
-                       case '+':
-                               continue;
-                       case '!':
-                               continue;
-                       case '-':
-                               left = 1;
-                               continue;
-                       }
-                       break;
-               }
-
-               for (fw=0; isdigit(*fmt); fmt++)
-                       fw = 10*fw + (*fmt-'0');
-               lp = 0;
-               rp = 2;
-               if (*fmt=='#') for (lp=0, fmt++; isdigit(*fmt); fmt++)
-                       lp = 10*lp + (*fmt-'0');
-               if (*fmt=='.') for (rp=0, fmt++; isdigit(*fmt); fmt++)
-                       rp = 10*rp + (*fmt-'0');
-
-               w = lp + 1 + rp;
-               if (!left && fw>w) w = fw;
-
-               x = va_arg(ap, double);
-               l = snprintf(s, n, "%*.*f", w, rp, x);
-               if (l >= n) {
-                       errno = E2BIG;
-                       return -1;
-               }
-               s += l;
-               n -= l;
-       }
-       return s-s0;
-}
-
-ssize_t strfmon_l(char *restrict s, size_t n, locale_t loc, const char 
*restrict fmt, ...)
-{
-       va_list ap;
-       ssize_t ret;
-
-       va_start(ap, fmt);
-       ret = vstrfmon_l(s, n, loc, fmt, ap);
-       va_end(ap);
-
-       return ret;
-}
-
-
-ssize_t strfmon(char *restrict s, size_t n, const char *restrict fmt, ...)
-{
-       va_list ap;
-       ssize_t ret;
-
-       va_start(ap, fmt);
-       ret = vstrfmon_l(s, n, 0, fmt, ap);
-       va_end(ap);
-
-       return ret;
-}

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/00000000000088c8e505ad476b87%40google.com.

Reply via email to