Add -lm dependency for gettextlib to fix LTO build
[platform/upstream/gettext.git] / gettext-runtime / intl / wprintf-parse.h
1 /* Parse printf format string.
2    Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2011, 2015 Free
3    Software Foundation, Inc.
4
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.
9
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.
14
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/>.  */
17
18 #ifndef _WPRINTF_PARSE_H
19 #define _WPRINTF_PARSE_H
20
21 #if HAVE_FEATURES_H
22 # include <features.h> /* for __GLIBC__, __UCLIBC__ */
23 #endif
24
25 #include "printf-args.h"
26
27
28 /* Flags */
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 */
34 #define FLAG_ZERO       32
35 #if __GLIBC__ >= 2 && !defined __UCLIBC__
36 # define FLAG_LOCALIZED 64      /* I flag, uses localized digits */
37 #endif
38
39 /* arg_index value indicating that no argument is consumed.  */
40 #define ARG_NONE        (~(size_t)0)
41
42 /* Number of directly allocated directives (no malloc() needed).  */
43 #define N_DIRECT_ALLOC_DIRECTIVES 7
44
45 /* A parsed directive.  */
46 typedef struct
47 {
48   const wchar_t* dir_start;
49   const wchar_t* dir_end;
50   int flags;
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 */
58   size_t arg_index;
59 }
60 wchar_t_directive;
61
62 /* A parsed format string.  */
63 typedef struct
64 {
65   size_t count;
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];
70 }
71 wchar_t_directives;
72
73
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.  */
78 #ifdef STATIC
79 STATIC
80 #else
81 extern
82 #endif
83 int wprintf_parse (const wchar_t *format, wchar_t_directives *d, arguments *a);
84
85 #endif /* _WPRINTF_PARSE_H */