#include "config.h"
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
#include "../tools.h"
#include "utils.h"
#include "wpp_private.h"
Go to the source code of this file.
|
| static char * | wpp_lookup (const char *name, int type, const char *parent_name) |
| |
| static int | pphash (const char *str) |
| |
| pp_entry_t * | pplookup (const char *ident) |
| |
| static void | free_pp_entry (pp_entry_t *ppp, int idx) |
| |
| static void | pp_init_define_state (void) |
| |
| static void | pp_free_define_state (void) |
| |
| void | pp_del_define (const char *name) |
| |
| pp_entry_t * | pp_add_define (const char *def, const char *text) |
| |
| pp_entry_t * | pp_add_macro (char *id, char *args[], int nargs, int variadic, mtext_t *exp) |
| |
| void | wpp_add_include_path (const char *path) |
| |
| char * | wpp_find_include (const char *name, const char *parent_name) |
| |
| void * | pp_open_include (const char *name, int type, const char *parent_name, char **newpath) |
| |
| void | pp_push_if (pp_if_state_t s) |
| |
| pp_if_state_t | pp_pop_if (void) |
| |
| pp_if_state_t | pp_if_state (void) |
| |
| void | pp_next_if_state (int i) |
| |
| int | pp_get_if_depth (void) |
| |
| static void | generic_msg (const char *s, const char *t, const char *n, va_list ap) |
| |
| int | ppy_error (const char *s,...) |
| |
| int | ppy_warning (const char *s,...) |
| |
| static void | add_cmdline_defines (void) |
| |
| static void | add_special_defines (void) |
| |
| static void | wpp_add_define (const char *name, const char *value) |
| |
| void | wpp_del_define (const char *name) |
| |
| void | wpp_add_cmdline_define (const char *value) |
| |
| void | wpp_set_debug (int lex_debug, int parser_debug, int msg_debug) |
| |
| int | wpp_parse (const char *input, FILE *output) |
| |
◆ HASHKEY
Definition at line 39 of file wpp.c.
◆ MAXIFSTACK
Definition at line 43 of file wpp.c.
◆ add_cmdline_defines()
| static void add_cmdline_defines |
( |
void |
| ) |
|
|
static |
Definition at line 517 of file wpp.c.
518{
520
522 {
524 }
525}
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
pp_entry_t * pp_add_define(const char *def, const char *text)
static struct list cmdline_defines
Referenced by wpp_parse().
◆ add_special_defines()
| static void add_special_defines |
( |
void |
| ) |
|
|
static |
Definition at line 527 of file wpp.c.
528{
532
535
538
541
544}
GLenum GLuint GLenum GLsizei const GLchar * buf
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
size_t CDECL strftime(char *str, size_t max, const char *format, const struct tm *mstm)
Referenced by wpp_parse().
◆ free_pp_entry()
◆ generic_msg()
Definition at line 491 of file wpp.c.
492{
497}
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
void int int ULONGLONG int va_list * ap
Referenced by ppy_error(), and ppy_warning().
◆ pp_add_define()
Definition at line 199 of file wpp.c.
200{
202 char *cptr;
205
208 {
210 ppy_warning(
"Redefinition of %s\n%s:%d: note: previous definition was here",
213 }
215 memset( ppp, 0,
sizeof(*ppp) );
223 {
224
227 {
229 }
230
232 ;
235 }
238
239 return ppp;
240}
ACPI_SIZE strlen(const char *String)
char * strchr(const char *String, int ch)
char * xstrdup(const char *s)
static void list_add_head(struct list_entry *head, struct list_entry *entry)
#define memmove(s1, s2, n)
union pp_entry::@276 subst
int ppy_warning(const char *s,...)
static int pphash(const char *str)
pp_entry_t * pplookup(const char *ident)
static struct list pp_defines[HASHKEY]
void pp_del_define(const char *name)
Referenced by add_cmdline_defines(), and add_special_defines().
◆ pp_add_macro()
Definition at line 242 of file wpp.c.
243{
246
249 {
251 ppy_warning(
"Redefinition of %s\n%s:%d: note: previous definition was here",
254 }
256 memset( ppp, 0,
sizeof(*ppp) );
267 {
270 {
272 {
275 break;
278 break;
281 break;
284 break;
285 }
286 }
288 }
289 return ppp;
290}
◆ pp_del_define()
Definition at line 178 of file wpp.c.
179{
182
184 {
187 return;
188 }
189
192
197}
static void free_pp_entry(pp_entry_t *ppp, int idx)
Referenced by pp_add_define(), and pp_add_macro().
◆ pp_free_define_state()
| static void pp_free_define_state |
( |
void |
| ) |
|
|
static |
Definition at line 161 of file wpp.c.
162{
165
167 {
169 {
174 }
175 }
176}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Referenced by wpp_parse().
◆ pp_get_if_depth()
◆ pp_if_state()
◆ pp_init_define_state()
| static void pp_init_define_state |
( |
void |
| ) |
|
|
static |
Definition at line 153 of file wpp.c.
154{
156
158}
static void list_init(struct list_entry *head)
Referenced by wpp_parse().
◆ pp_next_if_state()
Definition at line 467 of file wpp.c.
468{
470 {
474 break;
480 break;
483 }
484}
pp_if_state_t pp_if_state(void)
void pp_push_if(pp_if_state_t s)
◆ pp_open_include()
Definition at line 320 of file wpp.c.
321{
323 void *fp;
324
327
328 if (fp)
329 {
332 if (newpath) *newpath =
path;
334 return fp;
335 }
338}
GLuint GLuint GLsizei GLenum type
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
static char * wpp_lookup(const char *name, int type, const char *parent_name)
◆ pp_pop_if()
Definition at line 423 of file wpp.c.
424{
426 {
427 ppy_error(
"#{endif,else,elif} without #{if,ifdef,ifndef} (#if-stack underflow)");
429 }
430
432 {
435 break;
441 break;
444 }
445
454
456}
void pp_pop_ignore_state(void)
static const char *const pp_if_state_str[]
int ppy_error(const char *s,...)
Referenced by wpp_parse().
◆ pp_push_if()
Definition at line 397 of file wpp.c.
398{
400 error(
"#if-stack overflow; #{if,ifdef,ifndef} nested too deeply (> %d)\n",
MAXIFSTACK);
401
404
406
408 {
411 break;
417 break;
420 }
421}
void pp_push_ignore_state(void)
Referenced by pp_next_if_state().
◆ pphash()
◆ pplookup()
◆ ppy_error()
Definition at line 499 of file wpp.c.
500{
506}
static void generic_msg(const char *s, const char *t, const char *n, va_list ap)
Referenced by pp_pop_if(), and wpp_parse().
◆ ppy_warning()
◆ wpp_add_cmdline_define()
◆ wpp_add_define()
◆ wpp_add_include_path()
Definition at line 298 of file wpp.c.
299{
301 char *cptr;
302
303 for(cptr =
dir; *cptr; cptr++)
304 {
305
306 if(*cptr == '\\')
307 *cptr = '/';
308 }
309
311
313}
static struct strarray includes
Referenced by main(), and option_callback().
◆ wpp_del_define()
Definition at line 571 of file wpp.c.
572{
574
576 {
578 {
581 return;
582 }
583 }
584}
◆ wpp_find_include()
◆ wpp_lookup()
Definition at line 59 of file wpp.c.
60{
61 char *cpy;
62 char *cptr;
64 const char *ccptr;
66
68 cptr = cpy;
69
70 for(ccptr =
name; *ccptr; ccptr++)
71 {
72
73 if(*ccptr == '\\') {
74
75 if(ccptr[1] == '\\')
76 ccptr++;
77 *cptr = '/';
78 }else {
79 *cptr = *ccptr;
80 }
81 cptr++;
82 }
83 *cptr = '\0';
84
85 if(
type && parent_name)
86 {
87
91 {
95 }
97 }
98
100 {
104 {
108 }
110 }
113}
char * strmake(size_t *lenp,...)
Referenced by pp_open_include(), and wpp_find_include().
◆ wpp_parse()
Definition at line 610 of file wpp.c.
611{
613
617
621
625
627
630
632
634 {
637 }
638
642}
void WINAPIV int ppy_parse(void)
GLenum GLenum GLenum input
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
static void add_special_defines(void)
int pp_get_if_depth(void)
static void pp_free_define_state(void)
static void pp_init_define_state(void)
pp_if_state_t pp_pop_if(void)
static void add_cmdline_defines(void)
◆ wpp_set_debug()
| void wpp_set_debug |
( |
int |
lex_debug, |
|
|
int |
parser_debug, |
|
|
int |
msg_debug |
|
) |
| |
◆ cmdline_defines
◆ if_stack
◆ if_stack_idx
◆ includes
◆ pp_defines
◆ pp_flex_debug
◆ pp_if_state_str
Initial value:= {
"if_false",
"if_true",
"if_elif",
"if_elsefalse",
"if_elsetrue",
"if_ignore"
}
Definition at line 388 of file wpp.c.
Referenced by pp_pop_if(), and pp_push_if().
◆ pp_status
Definition at line 37 of file wpp.c.
◆ ppy_debug