exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / wprintf-parse.h
blob43a6430f65652135e477cff009f24415e386e6cb
1 /* Parse wprintf format string.
2 Copyright (C) 1999-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* This file can be parametrized with the following macros:
18 STATIC Set to 'static' to declare the function static. */
19 #ifndef _WPRINTF_PARSE_H
20 #define _WPRINTF_PARSE_H
22 #if HAVE_FEATURES_H
23 # include <features.h> /* for __GLIBC__, __UCLIBC__ */
24 #endif
26 #include "printf-args.h"
29 /* Flags */
30 #define FLAG_GROUP 1 /* ' flag */
31 #define FLAG_LEFT 2 /* - flag */
32 #define FLAG_SHOWSIGN 4 /* + flag */
33 #define FLAG_SPACE 8 /* space flag */
34 #define FLAG_ALT 16 /* # flag */
35 #define FLAG_ZERO 32
36 #if __GLIBC__ >= 2 && !defined __UCLIBC__
37 # define FLAG_LOCALIZED 64 /* I flag, uses localized digits */
38 #endif
40 /* arg_index value indicating that no argument is consumed. */
41 #define ARG_NONE (~(size_t)0)
43 /* Number of directly allocated directives (no malloc() needed). */
44 #define N_DIRECT_ALLOC_DIRECTIVES 7
46 /* A parsed directive. */
47 typedef struct
49 const wchar_t* dir_start;
50 const wchar_t* dir_end;
51 int flags;
52 const wchar_t* width_start;
53 const wchar_t* width_end;
54 size_t width_arg_index;
55 const wchar_t* precision_start;
56 const wchar_t* precision_end;
57 size_t precision_arg_index;
58 wchar_t conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */
59 size_t arg_index;
61 wchar_t_directive;
63 /* A parsed format string. */
64 typedef struct
66 size_t count;
67 wchar_t_directive *dir;
68 size_t max_width_length;
69 size_t max_precision_length;
70 wchar_t_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
72 wchar_t_directives;
75 /* Parses the format string. Fills in the number N of directives, and fills
76 in directives[0], ..., directives[N-1], and sets directives[N].dir_start
77 to the end of the format string. Also fills in the arg_type fields of the
78 arguments and the needed count of arguments. */
79 #ifdef STATIC
80 STATIC
81 #else
82 extern
83 #endif
84 int wprintf_parse (const wchar_t *format, wchar_t_directives *d, arguments *a);
86 #endif /* _WPRINTF_PARSE_H */