]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - stdlib/strfmon_l.c
hurd: Fix build
[thirdparty/glibc.git] / stdlib / strfmon_l.c
index 8fb7deccce39e747cb73d7ba1f393fb68c02442d..cd3796ced9805dbe57d26713f16555d5bc77058d 100644 (file)
@@ -1,5 +1,5 @@
 /* Formatting a monetary value according to the given locale.
-   Copyright (C) 1996-2012 Free Software Foundation, Inc.
+   Copyright (C) 1996-2018 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
 #define _NL_CURRENT(category, item) \
   (current->values[_NL_ITEM_INDEX (item)].string)
 
-extern int __printf_fp (FILE *, const struct printf_info *,
-                       const void *const *);
-libc_hidden_proto (__printf_fp)
-/* This function determines the number of digit groups in the output.
-   The definition is in printf_fp.c.  */
-extern unsigned int __guess_grouping (unsigned int intdig_max,
-                                     const char *grouping, wchar_t sepchar);
-
 
 /* We have to overcome some problems with this implementation.  On the
    one hand the strfmon() function is specified in XPG4 and of course
@@ -84,7 +76,7 @@ extern unsigned int __guess_grouping (unsigned int intdig_max,
    too.  Some of the information contradicts the information which can
    be specified in format string.  */
 ssize_t
-__vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
+__vstrfmon_l (char *s, size_t maxsize, locale_t loc, const char *format,
              va_list ap)
 {
   struct __locale_data *current = loc->__locales[LC_MONETARY];
@@ -103,7 +95,7 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
       union
       {
        double dbl;
-       __long_double_t ldbl;
+       long double ldbl;
       }
       fpnum;
       int int_format;
@@ -158,8 +150,8 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
       group = 1;                       /* Print digits grouped.  */
       pad = ' ';                       /* Fill character is <SP>.  */
       is_long_double = 0;              /* Double argument by default.  */
-      p_sign_posn = -1;                        /* This indicates whether the */
-      n_sign_posn = -1;                        /* '(' flag is given.  */
+      p_sign_posn = -2;                        /* This indicates whether the */
+      n_sign_posn = -2;                        /* '(' flag is given.  */
       width = -1;                      /* No width specified so far.  */
       left = 0;                                /* Right justified by default.  */
 
@@ -181,7 +173,7 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
              group = 0;
              continue;
            case '+':                   /* Use +/- for sign of number.  */
-             if (n_sign_posn != -1)
+             if (n_sign_posn != -2)
                {
                  __set_errno (EINVAL);
                  return -1;
@@ -190,7 +182,7 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
              n_sign_posn = *_NL_CURRENT (LC_MONETARY, N_SIGN_POSN);
              continue;
            case '(':                   /* Use ( ) for negative sign.  */
-             if (n_sign_posn != -1)
+             if (n_sign_posn != -2)
                {
                  __set_errno (EINVAL);
                  return -1;
@@ -310,16 +302,16 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
 
       /* If not specified by the format string now find the values for
         the format specification.  */
-      if (p_sign_posn == -1)
+      if (p_sign_posn == -2)
        p_sign_posn = *_NL_CURRENT (LC_MONETARY, int_format ? INT_P_SIGN_POSN : P_SIGN_POSN);
-      if (n_sign_posn == -1)
+      if (n_sign_posn == -2)
        n_sign_posn = *_NL_CURRENT (LC_MONETARY, int_format ? INT_N_SIGN_POSN : N_SIGN_POSN);
 
       if (right_prec == -1)
        {
          right_prec = *_NL_CURRENT (LC_MONETARY, int_format ? INT_FRAC_DIGITS : FRAC_DIGITS);
 
-         if (right_prec == CHAR_MAX)
+         if (right_prec == '\377')
            right_prec = 2;
        }
 
@@ -327,9 +319,7 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
         extra characters this means.  */
       if (group && left_prec != -1)
        left_prec += __guess_grouping (left_prec,
-                                      _NL_CURRENT (LC_MONETARY, MON_GROUPING),
-                                      *_NL_CURRENT (LC_MONETARY,
-                                                    MON_THOUSANDS_SEP));
+                                      _NL_CURRENT (LC_MONETARY, MON_GROUPING));
 
       /* Now it's time to get the value.  */
       if (is_long_double == 1)
@@ -384,13 +374,13 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
        cs_precedes = 1;
       if (other_cs_precedes != 0)
        other_cs_precedes = 1;
-      if (sep_by_space == CHAR_MAX)
+      if (sep_by_space == '\377')
        sep_by_space = 0;
-      if (other_sep_by_space == CHAR_MAX)
+      if (other_sep_by_space == '\377')
        other_sep_by_space = 0;
-      if (sign_posn == CHAR_MAX)
+      if (sign_posn == '\377')
        sign_posn = 1;
-      if (other_sign_posn == CHAR_MAX)
+      if (other_sign_posn == '\377')
        other_sign_posn = 1;
 
       /* Check for degenerate cases */
@@ -515,7 +505,7 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
 #ifdef _IO_MTSAFE_IO
       f._sbf._f._lock = NULL;
 #endif
-      _IO_init (&f._sbf._f, 0);
+      _IO_init_internal (&f._sbf._f, 0);
       _IO_JUMPS (&f._sbf) = &_IO_str_jumps;
       _IO_str_init_static_internal (&f, dest, (s + maxsize) - dest, dest);
       /* We clear the last available byte so we can find out whether
@@ -532,7 +522,7 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
       info.extra = 1;          /* This means use values from LC_MONETARY.  */
 
       ptr = &fpnum;
-      done = __printf_fp (&f._sbf._f, &info, &ptr);
+      done = __printf_fp_l (&f._sbf._f, loc, &info, &ptr);
       if (done < 0)
        return -1;
 
@@ -612,7 +602,7 @@ __vstrfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format,
 }
 
 ssize_t
-___strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...)
+___strfmon_l (char *s, size_t maxsize, locale_t loc, const char *format, ...)
 {
   va_list ap;