1 /* Parse printf format string.
2 Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2011, 2015 Free
3 Software Foundation, Inc.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #ifndef _WPRINTF_PARSE_H
19 #define _WPRINTF_PARSE_H
22 # include <features.h> /* for __GLIBC__, __UCLIBC__ */
25 #include "printf-args.h"
29 #define FLAG_GROUP 1 /* ' flag */
30 #define FLAG_LEFT 2 /* - flag */
31 #define FLAG_SHOWSIGN 4 /* + flag */
32 #define FLAG_SPACE 8 /* space flag */
33 #define FLAG_ALT 16 /* # flag */
35 #if __GLIBC__ >= 2 && !defined __UCLIBC__
36 # define FLAG_LOCALIZED 64 /* I flag, uses localized digits */
39 /* arg_index value indicating that no argument is consumed. */
40 #define ARG_NONE (~(size_t)0)
42 /* Number of directly allocated directives (no malloc() needed). */
43 #define N_DIRECT_ALLOC_DIRECTIVES 7
45 /* A parsed directive. */
48 const wchar_t* dir_start;
49 const wchar_t* dir_end;
51 const wchar_t* width_start;
52 const wchar_t* width_end;
53 size_t width_arg_index;
54 const wchar_t* precision_start;
55 const wchar_t* precision_end;
56 size_t precision_arg_index;
57 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 */
62 /* A parsed format string. */
66 wchar_t_directive *dir;
67 size_t max_width_length;
68 size_t max_precision_length;
69 wchar_t_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
74 /* Parses the format string. Fills in the number N of directives, and fills
75 in directives[0], ..., directives[N-1], and sets directives[N].dir_start
76 to the end of the format string. Also fills in the arg_type fields of the
77 arguments and the needed count of arguments. */
83 int wprintf_parse (const wchar_t *format, wchar_t_directives *d, arguments *a);
85 #endif /* _WPRINTF_PARSE_H */