Back to index

glibc  2.9
Defines | Functions
printf-prs.c File Reference
#include <stdio.h>
#include <printf.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <sys/param.h>
#include "../locale/localeinfo.h"
#include "printf-parse.h"

Go to the source code of this file.


#define CHAR_T   char
#define UCHAR_T   unsigned char
#define INT_T   int
#define L_(Str)   Str
#define ISDIGIT(Ch)   isdigit (Ch)
#define ISASCII(Ch)   isascii (Ch)
#define MBRLEN(Cp, L, St)   __mbrlen (Cp, L, St)
#define PUT(F, S, N)   _IO_sputn (F, S, N)
#define PAD(Padchar)


size_t parse_printf_format (char *fmt, size_t n, int *argtypes) const

Define Documentation

#define CHAR_T   char

Definition at line 30 of file printf-prs.c.

Definition at line 56 of file printf-prs.c.

#define INT_T   int

Definition at line 32 of file printf-prs.c.

#define ISASCII (   Ch)    isascii (Ch)

Definition at line 35 of file printf-prs.c.

#define ISDIGIT (   Ch)    isdigit (Ch)

Definition at line 34 of file printf-prs.c.

#define L_ (   Str)    Str

Definition at line 33 of file printf-prs.c.

#define MBRLEN (   Cp,
)    __mbrlen (Cp, L, St)

Definition at line 36 of file printf-prs.c.

#define PAD (   Padchar)
if (width > 0)                                                       \
    done += INTUSE(_IO_padn) (s, Padchar, width)

Definition at line 39 of file printf-prs.c.

#define PUT (   F,
)    _IO_sputn (F, S, N)

Definition at line 38 of file printf-prs.c.

#define UCHAR_T   unsigned char

Definition at line 31 of file printf-prs.c.

Function Documentation

size_t parse_printf_format ( char *  fmt,
size_t  n,
int argtypes 
) const

Definition at line 61 of file printf-prs.c.

  size_t nargs;                    /* Number of arguments.  */
  size_t max_ref_arg;              /* Highest index used in a positional arg.  */
  struct printf_spec spec;
  const unsigned char *f = (const unsigned char *) fmt;

  nargs = 0;
  max_ref_arg = 0;

  /* Search for format specifications.  */
  for (f = __find_specmb (f); *f != '\0'; f = spec.next_fmt)
      /* Parse this spec.  */
      nargs += __parse_one_specmb (f, nargs, &spec, &max_ref_arg);

      /* If the width is determined by an argument this is an int.  */
      if (spec.width_arg != -1 && (size_t) spec.width_arg < n)
       argtypes[spec.width_arg] = PA_INT;

      /* If the precision is determined by an argument this is an int.  */
      if (spec.prec_arg != -1 && (size_t) spec.prec_arg < n)
       argtypes[spec.prec_arg] = PA_INT;

      if ((size_t) spec.data_arg < n)
       switch (spec.ndata_args)
         case 0:            /* No arguments.  */
         case 1:            /* One argument; we already have the type.  */
           argtypes[spec.data_arg] = spec.data_arg_type;
           /* We have more than one argument for this format spec.  We must
               call the arginfo function again to determine all the types.  */
           (void) (*__printf_arginfo_table[])
             (&, n - spec.data_arg, &argtypes[spec.data_arg]);

  return MAX (nargs, max_ref_arg);

Here is the call graph for this function: