#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "wine/wpp.h"
#include "wpp_private.h"
Go to the source code of this file.
|
void * | pp_xmalloc (size_t size) |
|
void * | pp_xrealloc (void *p, size_t size) |
|
char * | pp_xstrdup (const char *str) |
|
static char * | wpp_default_lookup (const char *name, int type, const char *parent_name, char **include_path, int include_path_count) |
|
static void * | wpp_default_open (const char *filename, int type) |
|
static void | wpp_default_close (void *file) |
|
static int | wpp_default_read (void *file, char *buffer, unsigned int len) |
|
static void | wpp_default_write (const char *buffer, unsigned int len) |
|
static int | pphash (const char *str) |
|
pp_entry_t * | pplookup (const char *ident) |
|
static void | free_pp_entry (pp_entry_t *ppp, int idx) |
|
int | pp_push_define_state (void) |
|
void | pp_pop_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, marg_t *args[], int nargs, mtext_t *exp) |
|
int | 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) |
|
static void | wpp_default_error (const char *file, int line, int col, const char *near, const char *msg, va_list ap) |
|
static void | wpp_default_warning (const char *file, int line, int col, const char *near, const char *msg, va_list ap) |
|
int | ppy_error (const char *s,...) |
|
int | ppy_warning (const char *s,...) |
|
void | pp_internal_error (const char *file, int line, const char *s,...) |
|
◆ HASHKEY
◆ INCLUDESEPARATOR
◆ MAXIFSTACK
◆ pp_def_state_t
◆ free_pp_entry()
Definition at line 237 of file preproc.c.
238{
240 {
242 {
246 }
247 else
248 {
252 }
255 }
256
258 {
262 }
263 else
264 {
268 }
269
271}
includelogicentry_t * pp_includelogiclist
struct includelogicentry * next
struct includelogicentry * prev
pp_entry_t * defines[HASHKEY]
includelogicentry_t * iep
◆ generic_msg()
Definition at line 688 of file preproc.c.
689{
693#ifdef WANT_NEAR_INDICATION
694 {
697 {
699 if(!cpy)
704 }
705 }
707#endif
709}
char * pp_xstrdup(const char *str)
_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 wpp_default_error(), and wpp_default_warning().
◆ pp_add_define()
Definition at line 323 of file preproc.c.
324{
326 char *cptr;
329
330 if(!def)
334 {
338 }
340 if(!ppp)
342 memset( ppp, 0,
sizeof(*ppp) );
357 ppp->
next->prev = ppp;
359 {
360
363 {
365 }
366
368 ;
371 }
374
375 return ppp;
376
382}
ACPI_SIZE strlen(const char *String)
char * strchr(const char *String, int ch)
int WINAPIV ppy_warning(const char *msg,...)
void * pp_xmalloc(size_t size)
static int pphash(const char *str)
pp_entry_t * pplookup(const char *ident)
void pp_del_define(const char *name)
#define memmove(s1, s2, n)
union pp_entry::@240 subst
◆ pp_add_macro()
Definition at line 384 of file preproc.c.
385{
388
389 if(!id)
393 {
397 }
399 if(!ppp)
401 memset( ppp, 0,
sizeof(*ppp) );
409 {
412 }
417 ppp->
next->prev = ppp;
418
420 {
423 {
425 {
428 break;
431 break;
434 break;
437 break;
438 }
439 }
441 }
442 return ppp;
443}
◆ pp_del_define()
Definition at line 302 of file preproc.c.
303{
306
308 {
311 return;
312 }
313
316
321}
static void free_pp_entry(pp_entry_t *ppp, int idx)
◆ pp_get_if_depth()
◆ pp_if_state()
Definition at line 653 of file preproc.c.
654{
657 else
659}
static pp_if_state_t if_stack[MAXIFSTACK]
◆ pp_internal_error()
◆ pp_next_if_state()
Definition at line 662 of file preproc.c.
663{
665 {
669 break;
675 break;
676 default:
678 }
679}
pp_if_state_t pp_if_state(void)
void pp_push_if(pp_if_state_t s)
void WINAPIV pp_internal_error(const char *file, int line, const char *s,...)
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
◆ pp_open_include()
Definition at line 514 of file preproc.c.
515{
517 void *fp;
518
522
523 if (fp)
524 {
527 if (newpath) *newpath =
path;
529 return fp;
530 }
533}
GLuint GLuint GLsizei GLenum type
void *(* open)(const char *filename, int type)
char *(* lookup)(const char *filename, int type, const char *parent_name, char **include_path, int include_path_count)
◆ pp_pop_define_state()
Definition at line 287 of file preproc.c.
288{
292
294 {
296 }
300}
static pp_def_state_t * pp_def_state
◆ pp_pop_if()
Definition at line 618 of file preproc.c.
619{
621 {
622 ppy_error(
"#{endif,else,elif} without #{if,ifdef,ifndef} (#if-stack underflow)");
624 }
625
627 {
630 break;
636 break;
637 default:
639 }
640
649
651}
int WINAPIV ppy_error(const char *msg,...)
void pp_pop_ignore_state(void)
◆ pp_push_define_state()
Definition at line 274 of file preproc.c.
275{
278 return 1;
279
283 return 0;
284}
◆ pp_push_if()
Definition at line 592 of file preproc.c.
593{
596
599
601
603 {
606 break;
612 break;
613 default:
615 }
616}
void pp_push_ignore_state(void)
◆ pp_xmalloc()
◆ pp_xrealloc()
Definition at line 91 of file preproc.c.
92{
94
98 {
99
101 }
103}
◆ pp_xstrdup()
Definition at line 105 of file preproc.c.
106{
109
116}
#define memcpy(s1, s2, n)
◆ pphash()
Definition at line 213 of file preproc.c.
214{
219}
static int sum(int x_, int y_)
◆ pplookup()
Definition at line 221 of file preproc.c.
222{
225
230 {
232 return ppp;
233 }
235}
int strcmp(const char *String1, const char *String2)
_In_ ULONG _In_ ULONG_PTR ident
◆ ppy_error()
Definition at line 735 of file preproc.c.
736{
742 return 1;
743}
void(* error)(const char *file, int line, int col, const char *near, const char *msg, va_list ap)
◆ ppy_warning()
Definition at line 745 of file preproc.c.
746{
751 return 0;
752}
void(* warning)(const char *file, int line, int col, const char *near, const char *msg, va_list ap)
◆ wpp_add_include_path()
Definition at line 460 of file preproc.c.
461{
462 char *tok;
464 if(!cpy)
465 return 1;
466
468 while(tok)
469 {
470 if(*tok) {
472 char *cptr;
473 char **new_path;
474
477 {
479 return 1;
480 }
481 for(cptr =
dir; *cptr; cptr++)
482 {
483
484 if(*cptr == '\\')
485 *cptr = '/';
486 }
487
489 *cptr = '\0';
490
491
493 if(!new_path)
494 {
497 return 1;
498 }
502 }
504 }
506 return 0;
507}
char * strtok(char *String, const char *Delimiters)
Referenced by main().
◆ wpp_default_close()
static void wpp_default_close |
( |
void * |
file | ) |
|
|
static |
Definition at line 200 of file preproc.c.
200 {
202}
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
◆ wpp_default_error()
◆ wpp_default_lookup()
Definition at line 118 of file preproc.c.
120{
121 char *cpy;
122 char *cptr;
124 const char *ccptr;
126
128 if(!cpy)
130 cptr = cpy;
131
132 for(ccptr =
name; *ccptr; ccptr++)
133 {
134
135 if(*ccptr == '\\') {
136
137 if(ccptr[1] == '\\')
138 ccptr++;
139 *cptr = '/';
140 }else {
141 *cptr = *ccptr;
142 }
143 cptr++;
144 }
145 *cptr = '\0';
146
147 if(
type && parent_name)
148 {
149
151
152 if ((
p =
strrchr( parent_name,
'/' )))
p++;
153 else p = parent_name;
156 {
159 }
164 {
168 }
170 }
171
172 for(
i = 0;
i < include_path_count;
i++)
173 {
176 {
179 }
185 {
189 }
191 }
194}
char * strcat(char *DstString, const char *SrcString)
char * strcpy(char *DstString, const char *SrcString)
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
Referenced by wpp_find_include().
◆ wpp_default_open()
Definition at line 196 of file preproc.c.
196 {
198}
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
◆ wpp_default_read()
Definition at line 204 of file preproc.c.
204 {
206}
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
◆ wpp_default_warning()
◆ wpp_default_write()
Definition at line 208 of file preproc.c.
208 {
210}
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
◆ wpp_find_include()
◆ default_callbacks
◆ if_stack
◆ if_stack_idx
◆ includepath
◆ nincludepath
◆ pp_def_state
◆ pp_if_state_str
Initial value:= {
"if_false",
"if_true",
"if_elif",
"if_elsefalse",
"if_elsetrue",
"if_ignore"
}
Definition at line 583 of file preproc.c.
Referenced by pp_pop_if(), and pp_push_if().
◆ pp_status
◆ wpp_callbacks