Blame wcsmbs/tst-wcstof.c

Packit 6c4009
#define _GNU_SOURCE 1
Packit 6c4009
#include <wchar.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <string.h>
Packit 6c4009
#include <wctype.h>
Packit 6c4009
#include <libc-diag.h>
Packit 6c4009
Packit 6c4009
static int
Packit 6c4009
do_test (void)
Packit 6c4009
{
Packit 6c4009
  int result = 0;
Packit 6c4009
  char buf[100];
Packit 6c4009
  wchar_t tmp[3];
Packit 6c4009
  tmp[0] = '8';
Packit 6c4009
  tmp[1] = '1';
Packit 6c4009
  tmp[2] = 0;
Packit 6c4009
Packit 6c4009
  /* GCC does not know the result of wcstof so cannot see that the
Packit 6c4009
     snprintf output is not truncated.  */
Packit 6c4009
  DIAG_PUSH_NEEDS_COMMENT;
Packit 6c4009
#if __GNUC_PREREQ (7, 0)
Packit 6c4009
  DIAG_IGNORE_NEEDS_COMMENT (7.0, "-Wformat-truncation");
Packit 6c4009
#endif
Packit 6c4009
  snprintf (buf, 100, "%S = %f", tmp, wcstof (tmp, NULL));
Packit 6c4009
  DIAG_POP_NEEDS_COMMENT;
Packit 6c4009
  printf ("\"%s\" -> %s\n", buf,
Packit 6c4009
	  strcmp (buf, "81 = 81.000000") == 0 ? "okay" : "buggy");
Packit 6c4009
  result |= strcmp (buf, "81 = 81.000000") != 0;
Packit 6c4009
Packit 6c4009
  return result;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#include <support/test-driver.c>