projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
unistr/u8-chr, unistr/u8-strchr: use Boyer-Moore like algorithm.
[gnulib.git]
/
lib
/
vasnprintf.c
diff --git
a/lib/vasnprintf.c
b/lib/vasnprintf.c
index
6c11b72
..
41c6271
100644
(file)
--- a/
lib/vasnprintf.c
+++ b/
lib/vasnprintf.c
@@
-2889,8
+2889,8
@@
VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
length += n;
}
}
length += n;
}
}
- }
# endif
# endif
+ }
#endif
#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
else if ((dp->conversion == 'a' || dp->conversion == 'A')
#endif
#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
else if ((dp->conversion == 'a' || dp->conversion == 'A')
@@
-4953,6
+4953,7
@@
VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
}
#endif
}
#endif
+ errno = 0;
switch (type)
{
case TYPE_SCHAR:
switch (type)
{
case TYPE_SCHAR:
@@
-5147,15
+5148,21
@@
VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
/* Attempt to handle failure. */
if (count < 0)
{
/* Attempt to handle failure. */
if (count < 0)
{
+ /* SNPRINTF or sprintf failed. Save and use the errno
+ that it has set, if any. */
+ int saved_errno = errno;
+
if (!(result == resultbuf || result == NULL))
free (result);
if (buf_malloced != NULL)
free (buf_malloced);
CLEANUP ();
errno =
if (!(result == resultbuf || result == NULL))
free (result);
if (buf_malloced != NULL)
free (buf_malloced);
CLEANUP ();
errno =
- (dp->conversion == 'c' || dp->conversion == 's'
- ? EILSEQ
- : EINVAL);
+ (saved_errno != 0
+ ? saved_errno
+ : (dp->conversion == 'c' || dp->conversion == 's'
+ ? EILSEQ
+ : EINVAL));
return NULL;
}
return NULL;
}
@@
-5491,6
+5498,8
@@
VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
length += count;
break;
}
length += count;
break;
}
+#undef pad_ourselves
+#undef prec_ourselves
}
}
}
}
}
}