* libc/stdio/nano-vfprintf_i.c (_printf_i): Use Newlib approach to
handle string that might be not nul-terminated. * testsuite/newlib.stdio/nulprintf.c: New test.
This commit is contained in:
parent
3a4fcef804
commit
97e2f27aa1
|
@ -1,3 +1,9 @@
|
||||||
|
2014-11-06 Terry Guo <terry.guo@arm.com>
|
||||||
|
|
||||||
|
* libc/stdio/nano-vfprintf_i.c (_printf_i): Use Newlib approach to
|
||||||
|
handle string that might be not nul-terminated.
|
||||||
|
* testsuite/newlib.stdio/nulprintf.c: New test.
|
||||||
|
|
||||||
2014-10-29 Jon Turney <jon.turney@dronecode.org.uk>
|
2014-10-29 Jon Turney <jon.turney@dronecode.org.uk>
|
||||||
|
|
||||||
* libc/include/string.h: Correct guard for strcasecmp().
|
* libc/include/string.h: Correct guard for strcasecmp().
|
||||||
|
|
|
@ -211,15 +211,15 @@ number:
|
||||||
case 's':
|
case 's':
|
||||||
cp = GET_ARG (N, *ap, char_ptr_t);
|
cp = GET_ARG (N, *ap, char_ptr_t);
|
||||||
/* Precision gives the maximum number of chars to be written from a
|
/* Precision gives the maximum number of chars to be written from a
|
||||||
string, and take prec == -1 into consideration. */
|
string, and take prec == -1 into consideration.
|
||||||
if ((u_int)(pdata->size = strlen (cp)) > (u_int)(pdata->prec))
|
Use normal Newlib approach here to support case where cp is not
|
||||||
pdata->size = pdata->prec;
|
nul-terminated. */
|
||||||
/* Below code is kept for reading. The check is redundant because
|
char *p = memchr (cp, 0, pdata->prec);
|
||||||
pdata->prec will be set to pdata->size if it is -1 previously. */
|
|
||||||
#if 0
|
if (p != NULL)
|
||||||
if (pdata->prec > pdata->size)
|
pdata->prec = p - cp;
|
||||||
#endif
|
|
||||||
pdata->prec = pdata->size;
|
pdata->size = pdata->prec;
|
||||||
goto non_number_nosign;
|
goto non_number_nosign;
|
||||||
default:
|
default:
|
||||||
/* "%?" prints ?, unless ? is NUL. */
|
/* "%?" prints ?, unless ? is NUL. */
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 by ARM Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software
|
||||||
|
* is freely granted, provided that this notice is preserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "check.h"
|
||||||
|
|
||||||
|
const char m[8] = {'M','M','M','M','M','M','M','M'};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
printf ("%.*s\n", 8, m);
|
||||||
|
exit (0);
|
||||||
|
}
|
Loading…
Reference in New Issue