Back to index

glibc  2.9
Defines | Functions
tst-sscanf.c File Reference
#include <stdio.h>
#include <locale.h>
#include <assert.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define P0   "\xDB\xB0"
#define P1   "\xDB\xB1"
#define P2   "\xDB\xB2"
#define P3   "\xDB\xB3"
#define P4   "\xDB\xB4"
#define P5   "\xDB\xB5"
#define P6   "\xDB\xB6"
#define P7   "\xDB\xB7"
#define P8   "\xDB\xB8"
#define P9   "\xDB\xB9"
#define PD   "\xd9\xab"
#define PT   "\xd9\xac"
#define TEST_FUNCTION   do_test ()

Functions

static int check_sscanf (const char *s, const char *format, const float n)
static int do_test (void)

Define Documentation

#define P0   "\xDB\xB0"

Definition at line 5 of file tst-sscanf.c.

#define P1   "\xDB\xB1"

Definition at line 6 of file tst-sscanf.c.

#define P2   "\xDB\xB2"

Definition at line 7 of file tst-sscanf.c.

#define P3   "\xDB\xB3"

Definition at line 8 of file tst-sscanf.c.

#define P4   "\xDB\xB4"

Definition at line 9 of file tst-sscanf.c.

#define P5   "\xDB\xB5"

Definition at line 10 of file tst-sscanf.c.

#define P6   "\xDB\xB6"

Definition at line 11 of file tst-sscanf.c.

#define P7   "\xDB\xB7"

Definition at line 12 of file tst-sscanf.c.

#define P8   "\xDB\xB8"

Definition at line 13 of file tst-sscanf.c.

#define P9   "\xDB\xB9"

Definition at line 14 of file tst-sscanf.c.

#define PD   "\xd9\xab"

Definition at line 15 of file tst-sscanf.c.

#define PT   "\xd9\xac"

Definition at line 16 of file tst-sscanf.c.

#define TEST_FUNCTION   do_test ()

Definition at line 55 of file tst-sscanf.c.


Function Documentation

static int check_sscanf ( const char *  s,
const char *  format,
const float  n 
) [static]

Definition at line 19 of file tst-sscanf.c.

{
  float f;

  if (sscanf (s, format, &f) != 1)
    {
      printf ("nothing found for \"%s\"\n", s);
      return 1;
    }
  if (f != n)
    {
      printf ("got %f expected %f from \"%s\"\n", f, n, s);
      return 1;
    }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int do_test ( void  ) [static]

Definition at line 37 of file tst-sscanf.c.

{
  if (setlocale (LC_ALL, "fa_IR.UTF-8") == NULL)
    {
      puts ("cannot set fa_IR locale");
      return 1;
    }

  int r = check_sscanf (P3 PD P1 P4, "%I8f", 3.14);
  r |= check_sscanf (P3 PT P1 P4 P5, "%I'f", 3145);
  r |= check_sscanf (P3 PD P1 P4 P1 P5 P9, "%If", 3.14159);
  r |= check_sscanf ("-" P3 PD P1 P4 P1 P5, "%If", -3.1415);
  r |= check_sscanf ("+" PD P1 P4 P1 P5, "%If", +.1415);
  r |= check_sscanf (P3 PD P1 P4 P1 P5 "e+" P2, "%Ie", 3.1415e+2);

  return r;
}

Here is the call graph for this function: