|
Packit |
5b56b6 |
/* Parse printf format string.
|
|
Packit |
5b56b6 |
Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2011, 2015 Free
|
|
Packit |
5b56b6 |
Software Foundation, Inc.
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
This program is free software: you can redistribute it and/or modify
|
|
Packit |
5b56b6 |
it under the terms of the GNU Lesser General Public License as published by
|
|
Packit |
5b56b6 |
the Free Software Foundation; either version 2.1 of the License, or
|
|
Packit |
5b56b6 |
(at your option) any later version.
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
This program is distributed in the hope that it will be useful,
|
|
Packit |
5b56b6 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
5b56b6 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
5b56b6 |
GNU Lesser General Public License for more details.
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
5b56b6 |
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
#ifndef _WPRINTF_PARSE_H
|
|
Packit |
5b56b6 |
#define _WPRINTF_PARSE_H
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
#if HAVE_FEATURES_H
|
|
Packit |
5b56b6 |
# include <features.h> /* for __GLIBC__, __UCLIBC__ */
|
|
Packit |
5b56b6 |
#endif
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
#include "printf-args.h"
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
/* Flags */
|
|
Packit |
5b56b6 |
#define FLAG_GROUP 1 /* ' flag */
|
|
Packit |
5b56b6 |
#define FLAG_LEFT 2 /* - flag */
|
|
Packit |
5b56b6 |
#define FLAG_SHOWSIGN 4 /* + flag */
|
|
Packit |
5b56b6 |
#define FLAG_SPACE 8 /* space flag */
|
|
Packit |
5b56b6 |
#define FLAG_ALT 16 /* # flag */
|
|
Packit |
5b56b6 |
#define FLAG_ZERO 32
|
|
Packit |
5b56b6 |
#if __GLIBC__ >= 2 && !defined __UCLIBC__
|
|
Packit |
5b56b6 |
# define FLAG_LOCALIZED 64 /* I flag, uses localized digits */
|
|
Packit |
5b56b6 |
#endif
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
/* arg_index value indicating that no argument is consumed. */
|
|
Packit |
5b56b6 |
#define ARG_NONE (~(size_t)0)
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
/* Number of directly allocated directives (no malloc() needed). */
|
|
Packit |
5b56b6 |
#define N_DIRECT_ALLOC_DIRECTIVES 7
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
/* A parsed directive. */
|
|
Packit |
5b56b6 |
typedef struct
|
|
Packit |
5b56b6 |
{
|
|
Packit |
5b56b6 |
const wchar_t* dir_start;
|
|
Packit |
5b56b6 |
const wchar_t* dir_end;
|
|
Packit |
5b56b6 |
int flags;
|
|
Packit |
5b56b6 |
const wchar_t* width_start;
|
|
Packit |
5b56b6 |
const wchar_t* width_end;
|
|
Packit |
5b56b6 |
size_t width_arg_index;
|
|
Packit |
5b56b6 |
const wchar_t* precision_start;
|
|
Packit |
5b56b6 |
const wchar_t* precision_end;
|
|
Packit |
5b56b6 |
size_t precision_arg_index;
|
|
Packit |
5b56b6 |
wchar_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */
|
|
Packit |
5b56b6 |
size_t arg_index;
|
|
Packit |
5b56b6 |
}
|
|
Packit |
5b56b6 |
wchar_t_directive;
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
/* A parsed format string. */
|
|
Packit |
5b56b6 |
typedef struct
|
|
Packit |
5b56b6 |
{
|
|
Packit |
5b56b6 |
size_t count;
|
|
Packit |
5b56b6 |
wchar_t_directive *dir;
|
|
Packit |
5b56b6 |
size_t max_width_length;
|
|
Packit |
5b56b6 |
size_t max_precision_length;
|
|
Packit |
5b56b6 |
wchar_t_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
|
|
Packit |
5b56b6 |
}
|
|
Packit |
5b56b6 |
wchar_t_directives;
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
/* Parses the format string. Fills in the number N of directives, and fills
|
|
Packit |
5b56b6 |
in directives[0], ..., directives[N-1], and sets directives[N].dir_start
|
|
Packit |
5b56b6 |
to the end of the format string. Also fills in the arg_type fields of the
|
|
Packit |
5b56b6 |
arguments and the needed count of arguments. */
|
|
Packit |
5b56b6 |
#ifdef STATIC
|
|
Packit |
5b56b6 |
STATIC
|
|
Packit |
5b56b6 |
#else
|
|
Packit |
5b56b6 |
extern
|
|
Packit |
5b56b6 |
#endif
|
|
Packit |
5b56b6 |
int wprintf_parse (const wchar_t *format, wchar_t_directives *d, arguments *a);
|
|
Packit |
5b56b6 |
|
|
Packit |
5b56b6 |
#endif /* _WPRINTF_PARSE_H */
|