[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#292523: glibc: printf %0lld test case



In case it is of any use, here is the test case file
(stdio-common/bug-printf-0ll.c) I wrote while trying to fix the bug.
Gotom said on IRC that he has an actual fix for the bug, and my fix
wasn't a fix (need to learn to distinguish "unsigned long" from
"unsigned long long" even in the middle of the night, I do), so I am not
including the rest of the change I made, anyway. Perhaps the test case
is of some use, however.

/* Check that %0d, %0ld, and %0lld all produce the same output. */

#include <stdio.h>
#include <string.h>

static int
do_test (void)
{
  char buf[1024];
  
  sprintf (buf, "%0d", 0);
  if (strcmp (buf, "0") != 0)
    {
      printf ("error: %%0d failed, returned '%s'\n", buf);
      return 1;
    }

  sprintf (buf, "%0ld", 0L);
  if (strcmp (buf, "0") != 0)
    {
      printf ("error: %%0ld failed, returned '%s'\n", buf);
      return 1;
    }

#if 1
  sprintf (buf, "%0lld", 0LL);
  if (strcmp (buf, "0") != 0)
    {
      printf ("error: %%0lld failed, returned '%s'\n", buf);
      return 1;
    }
#endif

  return 0;
}

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

Reply to: