Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[BZ #3902]
2007-01-22  Ulrich Drepper  <drepper@redhat.com>
	[BZ #3902]
	* stdio-common/_itoa.c (_itoa): Make sure at least a zero is emitted.
	* stdio-common/Makefile (tests): Add bug17.
	* stdio-common/bug17.c: New file.
  • Loading branch information
Ulrich Drepper committed Jan 22, 2007
1 parent 439201d commit 6cae395
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
2007-01-22 Ulrich Drepper <drepper@redhat.com>

[BZ #3902]
* stdio-common/_itoa.c (_itoa): Make sure at least a zero is emitted.
* stdio-common/Makefile (tests): Add bug17.
* stdio-common/bug17.c: New file.

2007-01-19 Ulrich Drepper <drepper@redhat.com>

* iconvdata/brf.c: New file.
Expand Down
4 changes: 2 additions & 2 deletions stdio-common/Makefile
@@ -1,4 +1,4 @@
# Copyright (C) 1991-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
# Copyright (C) 1991-2006, 2007 Free Software Foundation, Inc.
# This file is part of the GNU C Library.

# The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -54,7 +54,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \
tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \
tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
tst-fwrite bug16
tst-fwrite bug16 bug17

test-srcs = tst-unbputc tst-printf

Expand Down
5 changes: 4 additions & 1 deletion stdio-common/_itoa.c
@@ -1,5 +1,5 @@
/* Internal function for converting integers to ASCII.
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2002, 2003, 2004
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2002, 2003, 2004, 2007
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Torbjorn Granlund <tege@matematik.su.se>
Expand Down Expand Up @@ -269,6 +269,7 @@ _itoa (value, buflim, base, upper_case)

default:
{
char *bufend = buflim;
#if BITS_PER_MP_LIMB == 64
mp_limb_t base_multiplier = brec->base_multiplier;
if (brec->flag)
Expand Down Expand Up @@ -454,6 +455,8 @@ _itoa (value, buflim, base, upper_case)
}
while (n != 0);
#endif
if (buflim == bufend)
*--buflim = '0';
}
break;
}
Expand Down
31 changes: 31 additions & 0 deletions stdio-common/bug17.c
@@ -0,0 +1,31 @@
#include <stdio.h>
#include <string.h>

static int
do_test (void)
{
static const char expect[] = "0, 0, 0";
char buf[100];
int status = 0;

static const char fmt1[] = "%0d, %0ld, %0lld";
snprintf (buf, sizeof (buf), fmt1, 0, 0L, 0LL);
if (strcmp (buf, expect) != 0)
{
printf ("\"%s\": got \"%s\", expected \"%s\"\n", fmt1, buf, expect);
status = 1;
}

static const char fmt2[] = "%0u, %0lu, %0llu";
snprintf (buf, sizeof (buf), fmt2, 0u, 0uL, 0uLL);
if (strcmp (buf, expect) != 0)
{
printf ("\"%s\": got \"%s\", expected \"%s\"\n", fmt2, buf, expect);
status = 1;
}

return status;
}

#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"

0 comments on commit 6cae395

Please sign in to comment.