ReactOS  0.4.14-dev-114-gc8cbd56
wpp_private.h File Reference
#include <stdio.h>
#include <string.h>
Include dependency graph for wpp_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  includelogicentry
 
struct  marg
 
struct  mtext
 
struct  pp_entry
 
struct  include_state_t
 
struct  cval
 
struct  pp_status
 

Macros

#define MAXIFSTACK   64 /* If this isn't enough you should alter the source... */
 
#define SIZE_CHAR   1
 
#define SIZE_SHORT   2
 
#define SIZE_INT   3
 
#define SIZE_LONG   4
 
#define SIZE_LONGLONG   5
 
#define SIZE_MASK   0x00ff
 
#define FLAG_SIGNED   0x0100
 
#define __attribute__(x)   /*nothing*/
 

Typedefs

typedef struct includelogicentry includelogicentry_t
 
typedef struct marg marg_t
 
typedef struct mtext mtext_t
 
typedef struct pp_entry pp_entry_t
 
typedef long wrc_sll_t
 
typedef unsigned long wrc_ull_t
 
typedef struct cval cval_t
 

Enumerations

enum  def_arg_t { arg_single, arg_list }
 
enum  def_exp_t { exp_text, exp_concat, exp_stringize, exp_subst }
 
enum  def_type_t { def_none, def_define, def_macro, def_special }
 
enum  pp_if_state_t {
  if_false, if_true, if_elif, if_elsefalse,
  if_elsetrue, if_ignore, if_error
}
 
enum  ctype_t {
  cv_sint = SIZE_INT + FLAG_SIGNED, cv_uint = SIZE_INT, cv_slong = SIZE_LONG + FLAG_SIGNED, cv_ulong = SIZE_LONG,
  cv_sll = SIZE_LONGLONG + FLAG_SIGNED, cv_ull = SIZE_LONGLONG
}
 

Functions

voidpp_xmalloc (size_t)
 
voidpp_xrealloc (void *, size_t)
 
charpp_xstrdup (const char *str)
 
pp_entry_tpplookup (const char *ident)
 
int pp_push_define_state (void)
 
void pp_pop_define_state (void)
 
pp_entry_tpp_add_define (const char *def, const char *text)
 
pp_entry_tpp_add_macro (char *ident, marg_t *args[], int nargs, mtext_t *exp)
 
void pp_del_define (const char *name)
 
voidpp_open_include (const char *name, int type, const char *parent_name, char **newpath)
 
void pp_push_if (pp_if_state_t s)
 
void pp_next_if_state (int)
 
pp_if_state_t pp_pop_if (void)
 
pp_if_state_t pp_if_state (void)
 
int pp_get_if_depth (void)
 
int ppy_error (const char *s,...) __attribute__((format(printf
 
int int ppy_warning (const char *s,...) __attribute__((format(printf
 
int int void pp_internal_error (const char *file, int line, const char *s,...) __attribute__((format(printf
 
int ppy_lex (void)
 
void pp_do_include (char *fname, int type)
 
void pp_push_ignore_state (void)
 
void pp_pop_ignore_state (void)
 
void pp_writestring (const char *format,...) __attribute__((format(printf
 
void int ppy_parse (void)
 

Variables

const struct wpp_callbackswpp_callbacks
 
struct pp_status pp_status
 
include_state_t pp_incl_state
 
includelogicentry_tpp_includelogiclist
 
FILEppy_in
 
FILEppy_out
 
charppy_text
 
int pp_flex_debug
 
int ppy_debug
 

Macro Definition Documentation

◆ __attribute__

#define __attribute__ (   x)    /*nothing*/

Definition at line 218 of file wpp_private.h.

◆ FLAG_SIGNED

#define FLAG_SIGNED   0x0100

Definition at line 164 of file wpp_private.h.

◆ MAXIFSTACK

#define MAXIFSTACK   64 /* If this isn't enough you should alter the source... */

Definition at line 108 of file wpp_private.h.

◆ SIZE_CHAR

#define SIZE_CHAR   1

Definition at line 158 of file wpp_private.h.

◆ SIZE_INT

#define SIZE_INT   3

Definition at line 160 of file wpp_private.h.

◆ SIZE_LONG

#define SIZE_LONG   4

Definition at line 161 of file wpp_private.h.

◆ SIZE_LONGLONG

#define SIZE_LONGLONG   5

Definition at line 162 of file wpp_private.h.

◆ SIZE_MASK

#define SIZE_MASK   0x00ff

Definition at line 163 of file wpp_private.h.

◆ SIZE_SHORT

#define SIZE_SHORT   2

Definition at line 159 of file wpp_private.h.

Typedef Documentation

◆ cval_t

typedef struct cval cval_t

◆ includelogicentry_t

◆ marg_t

typedef struct marg marg_t

◆ mtext_t

typedef struct mtext mtext_t

◆ pp_entry_t

◆ wrc_sll_t

typedef long wrc_sll_t

Definition at line 154 of file wpp_private.h.

◆ wrc_ull_t

typedef unsigned long wrc_ull_t

Definition at line 155 of file wpp_private.h.

Enumeration Type Documentation

◆ ctype_t

Enumerator
cv_sint 
cv_uint 
cv_slong 
cv_ulong 
cv_sll 
cv_ull 

Definition at line 166 of file wpp_private.h.

166  {
167 #if 0
168  cv_schar = SIZE_CHAR + FLAG_SIGNED,
169  cv_uchar = SIZE_CHAR,
170  cv_sshort = SIZE_SHORT + FLAG_SIGNED,
171  cv_ushort = SIZE_SHORT,
172 #endif
174  cv_uint = SIZE_INT,
179 } ctype_t;
#define SIZE_LONGLONG
Definition: wpp_private.h:162
#define SIZE_CHAR
Definition: wpp_private.h:158
#define FLAG_SIGNED
Definition: wpp_private.h:164
#define SIZE_SHORT
Definition: wpp_private.h:159
#define SIZE_LONG
Definition: wpp_private.h:161
ctype_t
Definition: wpp_private.h:166
#define SIZE_INT
Definition: wpp_private.h:160

◆ def_arg_t

Enumerator
arg_single 
arg_list 

Definition at line 46 of file wpp_private.h.

46  {
47  arg_single,
48  arg_list
49 } def_arg_t;
def_arg_t
Definition: wpp_private.h:46

◆ def_exp_t

Enumerator
exp_text 
exp_concat 
exp_stringize 
exp_subst 

Definition at line 60 of file wpp_private.h.

60  {
61  exp_text, /* Simple text substitution */
62  exp_concat, /* Concat (##) operator requested */
63  exp_stringize, /* Stringize (#) operator requested */
64  exp_subst /* Substitute argument */
65 } def_exp_t;
def_exp_t
Definition: wpp_private.h:60

◆ def_type_t

Enumerator
def_none 
def_define 
def_macro 
def_special 

Definition at line 80 of file wpp_private.h.

80  {
81  def_none, /* Not-a-define; used as return value */
82  def_define, /* Simple defines */
83  def_macro, /* Macro defines */
84  def_special /* Special expansions like __LINE__ and __FILE__ */
85 } def_type_t;
def_type_t
Definition: wpp_private.h:80

◆ pp_if_state_t

Enumerator
if_false 
if_true 
if_elif 
if_elsefalse 
if_elsetrue 
if_ignore 
if_error 

Definition at line 110 of file wpp_private.h.

Function Documentation

◆ pp_add_define()

pp_entry_t* pp_add_define ( const char def,
const char text 
)

Definition at line 323 of file preproc.c.

324 {
325  int len;
326  char *cptr;
327  int idx;
328  pp_entry_t *ppp;
329 
330  if(!def)
331  return NULL;
332  idx = pphash(def);
333  if((ppp = pplookup(def)) != NULL)
334  {
335  if(pp_status.pedantic)
336  ppy_warning("Redefinition of %s\n\tPrevious definition: %s:%d", def, ppp->filename, ppp->linenumber);
337  pp_del_define(def);
338  }
339  ppp = pp_xmalloc(sizeof(pp_entry_t));
340  if(!ppp)
341  return NULL;
342  memset( ppp, 0, sizeof(*ppp) );
343  ppp->ident = pp_xstrdup(def);
344  if(!ppp->ident)
345  goto error;
346  ppp->type = def_define;
347  ppp->subst.text = text ? pp_xstrdup(text) : NULL;
348  if(text && !ppp->subst.text)
349  goto error;
350  ppp->filename = pp_xstrdup(pp_status.input ? pp_status.input : "<internal or cmdline>");
351  if(!ppp->filename)
352  goto error;
354  ppp->next = pp_def_state->defines[idx];
355  pp_def_state->defines[idx] = ppp;
356  if(ppp->next)
357  ppp->next->prev = ppp;
358  if(ppp->subst.text)
359  {
360  /* Strip trailing white space from subst text */
361  len = strlen(ppp->subst.text);
362  while(len && strchr(" \t\r\n", ppp->subst.text[len-1]))
363  {
364  ppp->subst.text[--len] = '\0';
365  }
366  /* Strip leading white space from subst text */
367  for(cptr = ppp->subst.text; *cptr && strchr(" \t\r", *cptr); cptr++)
368  ;
369  if(ppp->subst.text != cptr)
370  memmove(ppp->subst.text, cptr, strlen(cptr)+1);
371  }
372  if(pp_status.debug)
373  printf("Added define (%s, %d) <%s> to <%s>\n", pp_status.input, pp_status.line_number, ppp->ident, ppp->subst.text ? ppp->subst.text : "(null)");
374 
375  return ppp;
376 
377 error:
378  free(ppp->ident);
379  free(ppp->subst.text);
380  free(ppp);
381  return NULL;
382 }
pp_entry_t * pplookup(const char *ident)
Definition: preproc.c:221
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
char * text
Definition: wpp_private.h:96
#define error(str)
Definition: mkdosfs.c:1605
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const WCHAR * text
Definition: package.c:1827
#define free
Definition: debug_ros.c:5
int line_number
Definition: wpp_private.h:233
char * filename
Definition: wpp_private.h:99
char * input
Definition: wpp_private.h:231
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
static int pphash(const char *str)
Definition: preproc.c:213
void * pp_xmalloc(size_t size)
Definition: preproc.c:77
int linenumber
Definition: wpp_private.h:100
int ppy_warning(const char *s,...)
Definition: preproc.c:745
char * ident
Definition: wpp_private.h:91
Definition: wpp_private.h:87
char * pp_xstrdup(const char *str)
Definition: preproc.c:105
void pp_del_define(const char *name)
Definition: preproc.c:302
GLenum GLsizei len
Definition: glext.h:6722
pp_entry_t * defines[HASHKEY]
Definition: preproc.c:46
struct pp_entry * next
Definition: wpp_private.h:88
char * strchr(const char *String, int ch)
Definition: utclib.c:501
def_type_t type
Definition: wpp_private.h:90
int pedantic
Definition: wpp_private.h:236
#define memset(x, y, z)
Definition: compat.h:39
union pp_entry::@4038 subst
#define printf
Definition: config.h:203

Referenced by add_cmdline_defines(), add_special_defines(), and yyparse().

◆ pp_add_macro()

pp_entry_t* pp_add_macro ( char ident,
marg_t args[],
int  nargs,
mtext_t exp 
)

Definition at line 384 of file preproc.c.

385 {
386  int idx;
387  pp_entry_t *ppp;
388 
389  if(!id)
390  return NULL;
391  idx = pphash(id);
392  if((ppp = pplookup(id)) != NULL)
393  {
394  if(pp_status.pedantic)
395  ppy_warning("Redefinition of %s\n\tPrevious definition: %s:%d", id, ppp->filename, ppp->linenumber);
396  pp_del_define(id);
397  }
398  ppp = pp_xmalloc(sizeof(pp_entry_t));
399  if(!ppp)
400  return NULL;
401  memset( ppp, 0, sizeof(*ppp) );
402  ppp->ident = id;
403  ppp->type = def_macro;
404  ppp->margs = args;
405  ppp->nargs = nargs;
406  ppp->subst.mtext= exp;
407  ppp->filename = pp_xstrdup(pp_status.input ? pp_status.input : "<internal or cmdline>");
408  if(!ppp->filename)
409  {
410  free(ppp);
411  return NULL;
412  }
414  ppp->next = pp_def_state->defines[idx];
415  pp_def_state->defines[idx] = ppp;
416  if(ppp->next)
417  ppp->next->prev = ppp;
418 
419  if(pp_status.debug)
420  {
421  fprintf(stderr, "Added macro (%s, %d) <%s(%d)> to <", pp_status.input, pp_status.line_number, ppp->ident, nargs);
422  for(; exp; exp = exp->next)
423  {
424  switch(exp->type)
425  {
426  case exp_text:
427  fprintf(stderr, " \"%s\" ", exp->subst.text);
428  break;
429  case exp_stringize:
430  fprintf(stderr, " #(%d) ", exp->subst.argidx);
431  break;
432  case exp_concat:
433  fprintf(stderr, "##");
434  break;
435  case exp_subst:
436  fprintf(stderr, " <%d> ", exp->subst.argidx);
437  break;
438  }
439  }
440  fprintf(stderr, ">\n");
441  }
442  return ppp;
443 }
pp_entry_t * pplookup(const char *ident)
Definition: preproc.c:221
int nargs
Definition: wpp_private.h:93
#define free
Definition: debug_ros.c:5
int line_number
Definition: wpp_private.h:233
char * filename
Definition: wpp_private.h:99
marg_t ** margs
Definition: wpp_private.h:92
char * input
Definition: wpp_private.h:231
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
static int pphash(const char *str)
Definition: preproc.c:213
mtext_t * mtext
Definition: wpp_private.h:95
void * pp_xmalloc(size_t size)
Definition: preproc.c:77
int linenumber
Definition: wpp_private.h:100
int ppy_warning(const char *s,...)
Definition: preproc.c:745
char * ident
Definition: wpp_private.h:91
Definition: wpp_private.h:87
char * pp_xstrdup(const char *str)
Definition: preproc.c:105
void pp_del_define(const char *name)
Definition: preproc.c:302
pp_entry_t * defines[HASHKEY]
Definition: preproc.c:46
struct pp_entry * next
Definition: wpp_private.h:88
DWORD exp
Definition: msg.c:15681
def_type_t type
Definition: wpp_private.h:90
GLenum GLuint id
Definition: glext.h:5579
FILE * stderr
int pedantic
Definition: wpp_private.h:236
#define memset(x, y, z)
Definition: compat.h:39
#define args
Definition: format.c:66
union pp_entry::@4038 subst

Referenced by yyparse().

◆ pp_del_define()

void pp_del_define ( const char name)

Definition at line 302 of file preproc.c.

303 {
304  pp_entry_t *ppp;
305  int idx = pphash(name);
306 
307  if((ppp = pplookup(name)) == NULL)
308  {
309  if(pp_status.pedantic)
310  ppy_warning("%s was not defined", name);
311  return;
312  }
313 
314  if(pp_status.debug)
315  printf("Deleting (%s, %d) <%s>\n", pp_status.input, pp_status.line_number, name);
316 
317  free( ppp->ident );
318  free( ppp->subst.text );
319  free( ppp->filename );
320  free_pp_entry( ppp, idx );
321 }
pp_entry_t * pplookup(const char *ident)
Definition: preproc.c:221
char * text
Definition: wpp_private.h:96
#define free
Definition: debug_ros.c:5
int line_number
Definition: wpp_private.h:233
char * filename
Definition: wpp_private.h:99
char * input
Definition: wpp_private.h:231
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
static int pphash(const char *str)
Definition: preproc.c:213
int ppy_warning(const char *s,...)
Definition: preproc.c:745
char * ident
Definition: wpp_private.h:91
Definition: wpp_private.h:87
Definition: name.c:36
int pedantic
Definition: wpp_private.h:236
static void free_pp_entry(pp_entry_t *ppp, int idx)
Definition: preproc.c:237
union pp_entry::@4038 subst
#define printf
Definition: config.h:203

Referenced by del_cmdline_defines(), del_special_defines(), pp_add_define(), pp_add_macro(), pp_pop_define_state(), and yyparse().

◆ pp_do_include()

void pp_do_include ( char fname,
int  type 
)

Definition at line 4529 of file ppl.yy.c.

4530 {
4531  char *newpath;
4532  int n;
4533  includelogicentry_t *iep;
4534  void *fp;
4535 
4536  if(!fname)
4537  return;
4538 
4539  for(iep = pp_includelogiclist; iep; iep = iep->next)
4540  {
4541  if(!strcmp(iep->filename, fname))
4542  {
4543  /*
4544  * We are done. The file was included before.
4545  * If the define was deleted, then this entry would have
4546  * been deleted too.
4547  */
4548  free(fname);
4549  return;
4550  }
4551  }
4552 
4553  n = strlen(fname);
4554 
4555  if(n <= 2)
4556  {
4557  ppy_error("Empty include filename");
4558  free(fname);
4559  return;
4560  }
4561 
4562  /* Undo the effect of the quotation */
4563  fname[n-1] = '\0';
4564 
4565  if((fp = pp_open_include(fname+1, type, pp_status.input, &newpath)) == NULL)
4566  {
4567  ppy_error("Unable to open include file %s", fname+1);
4568  free(fname);
4569  return;
4570  }
4571 
4572  fname[n-1] = *fname; /* Redo the quotes */
4573  push_buffer(NULL, newpath, fname, 0);
4575  pp_incl_state.state = 0;
4577 
4578  if(pp_status.debug)
4579  fprintf(stderr, "pp_do_include: %s:%d: include_state=%d, include_ppp='%s', include_ifdepth=%d\n",
4581  pp_status.file = fp;
4583 
4584  pp_writestring("# 1 \"%s\" 1%s\n", newpath, type ? "" : " 3");
4585 }
struct includelogicentry * next
Definition: wpp_private.h:37
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define free
Definition: debug_ros.c:5
int line_number
Definition: wpp_private.h:233
GLdouble n
Definition: glext.h:7729
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void pp_writestring(const char *format,...)
Definition: ppl.yy.c:1351
char * input
Definition: wpp_private.h:231
#define YY_BUF_SIZE
Definition: ppl.yy.c:176
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
include_state_t pp_incl_state
Definition: ppl.yy.c:1334
smooth NULL
Definition: ftsmooth.c:416
void * file
Definition: wpp_private.h:232
YY_BUFFER_STATE ppy__create_buffer(FILE *file, int size)
Definition: ppl.yy.c:3210
int ppy_error(const char *s,...)
Definition: preproc.c:735
includelogicentry_t * pp_includelogiclist
Definition: ppl.yy.c:1342
static void push_buffer(pp_entry_t *ppp, char *filename, char *incname, int pop)
Definition: ppl.yy.c:4246
FILE * stderr
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void ppy__switch_to_buffer(YY_BUFFER_STATE new_buffer)
Definition: ppl.yy.c:3165
void * pp_open_include(const char *name, int type, const char *parent_name, char **newpath)
Definition: preproc.c:514

Referenced by yyparse().

◆ pp_get_if_depth()

int pp_get_if_depth ( void  )

Definition at line 681 of file preproc.c.

682 {
683  return if_stack_idx;
684 }
static int if_stack_idx
Definition: preproc.c:53

Referenced by push_buffer(), while(), wpp_parse(), and yyparse().

◆ pp_if_state()

pp_if_state_t pp_if_state ( void  )

Definition at line 653 of file preproc.c.

654 {
655  if(!if_stack_idx)
656  return if_true;
657  else
658  return if_stack[if_stack_idx-1];
659 }
static int if_stack_idx
Definition: preproc.c:53
static pp_if_state_t if_stack[MAXIFSTACK]
Definition: preproc.c:52

Referenced by pp_next_if_state(), pp_pop_if(), and pp_push_if().

◆ pp_internal_error()

int int void pp_internal_error ( const char file,
int  line,
const char s,
  ... 
)

◆ pp_next_if_state()

void pp_next_if_state ( int  )

Definition at line 662 of file preproc.c.

663 {
664  switch(pp_if_state())
665  {
666  case if_true:
667  case if_elsetrue:
669  break;
670  case if_false:
671  case if_elsefalse:
672  case if_elif:
673  case if_ignore:
675  break;
676  default:
677  pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d) in #{if,ifdef,ifndef} directive", (int)pp_if_state());
678  }
679 }
void pp_internal_error(const char *file, int line, const char *s,...)
Definition: preproc.c:754
pp_if_state_t pp_if_state(void)
Definition: preproc.c:653
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
Definition: glfuncs.h:248
void pp_push_if(pp_if_state_t s)
Definition: preproc.c:592

Referenced by yyparse().

◆ pp_open_include()

void* pp_open_include ( const char name,
int  type,
const char parent_name,
char **  newpath 
)

Definition at line 514 of file preproc.c.

515 {
516  char *path;
517  void *fp;
518 
519  if (!(path = wpp_callbacks->lookup(name, type, parent_name, includepath,
520  nincludepath))) return NULL;
521  fp = wpp_callbacks->open(path, type);
522 
523  if (fp)
524  {
525  if (pp_status.debug)
526  printf("Going to include <%s>\n", path);
527  if (newpath) *newpath = path;
528  else free( path );
529  return fp;
530  }
531  free( path );
532  return NULL;
533 }
void *(* open)(const char *filename, int type)
Definition: wpp.h:38
GLsizei const GLchar ** path
Definition: glext.h:7234
#define free
Definition: debug_ros.c:5
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static int nincludepath
Definition: preproc.c:458
smooth NULL
Definition: ftsmooth.c:416
static char ** includepath
Definition: preproc.c:457
Definition: services.c:325
Definition: name.c:36
char *(* lookup)(const char *filename, int type, const char *parent_name, char **include_path, int include_path_count)
Definition: wpp.h:35
#define printf
Definition: config.h:203

Referenced by pp_do_include().

◆ pp_pop_define_state()

void pp_pop_define_state ( void  )

Definition at line 287 of file preproc.c.

288 {
289  int i;
290  pp_entry_t *ppp;
292 
293  for (i = 0; i < HASHKEY; i++)
294  {
295  while ((ppp = pp_def_state->defines[i]) != NULL) pp_del_define( ppp->ident );
296  }
298  pp_def_state = state->next;
299  free( state );
300 }
#define free
Definition: debug_ros.c:5
static pp_def_state_t * pp_def_state
Definition: preproc.c:49
#define HASHKEY
Definition: preproc.c:41
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
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
char * ident
Definition: wpp_private.h:91
Definition: wpp_private.h:87
void pp_del_define(const char *name)
Definition: preproc.c:302
static int state
Definition: maze.c:121
pp_entry_t * defines[HASHKEY]
Definition: preproc.c:46

Referenced by wpp_parse().

◆ pp_pop_if()

pp_if_state_t pp_pop_if ( void  )

Definition at line 618 of file preproc.c.

619 {
620  if(if_stack_idx <= 0)
621  {
622  ppy_error("#{endif,else,elif} without #{if,ifdef,ifndef} (#if-stack underflow)");
623  return if_error;
624  }
625 
626  switch(pp_if_state())
627  {
628  case if_true:
629  case if_elsetrue:
630  break;
631  case if_false:
632  case if_elsefalse:
633  case if_elif:
634  case if_ignore:
636  break;
637  default:
638  pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d)", (int)pp_if_state());
639  }
640 
641  if(pp_flex_debug)
642  fprintf(stderr, "Pop if %s:%d: %s(%d) -> %s(%d)\n",
646  if_stack_idx,
648  if_stack_idx-1);
649 
650  return if_stack[--if_stack_idx];
651 }
static int if_stack_idx
Definition: preproc.c:53
void pp_internal_error(const char *file, int line, const char *s,...)
Definition: preproc.c:754
int line_number
Definition: wpp_private.h:233
void pp_pop_ignore_state(void)
Definition: ppl.yy.c:4598
char * input
Definition: wpp_private.h:231
pp_if_state_t pp_if_state(void)
Definition: preproc.c:653
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
int ppy_error(const char *s,...)
Definition: preproc.c:735
static pp_if_state_t if_stack[MAXIFSTACK]
Definition: preproc.c:52
static const char *const pp_if_state_str[]
Definition: preproc.c:583
int pp_flex_debug
Definition: wpp.c:31
FILE * stderr

Referenced by wpp_parse(), and yyparse().

◆ pp_pop_ignore_state()

void pp_pop_ignore_state ( void  )

Definition at line 4598 of file ppl.yy.c.

4599 {
4600  yy_pop_state();
4601 }
static void yy_pop_state(void)
Definition: ppl.yy.c:3516

Referenced by pp_pop_if().

◆ pp_push_define_state()

int pp_push_define_state ( void  )

Definition at line 274 of file preproc.c.

275 {
276  pp_def_state_t *state = pp_xmalloc( sizeof(*state) );
277  if(!state)
278  return 1;
279 
280  memset( state->defines, 0, sizeof(state->defines) );
281  state->next = pp_def_state;
283  return 0;
284 }
static pp_def_state_t * pp_def_state
Definition: preproc.c:49
void * pp_xmalloc(size_t size)
Definition: preproc.c:77
static int state
Definition: maze.c:121
#define memset(x, y, z)
Definition: compat.h:39

Referenced by wpp_parse().

◆ pp_push_if()

void pp_push_if ( pp_if_state_t  s)

Definition at line 592 of file preproc.c.

593 {
594  if(if_stack_idx >= MAXIFSTACK)
595  pp_internal_error(__FILE__, __LINE__, "#if-stack overflow; #{if,ifdef,ifndef} nested too deeply (> %d)", MAXIFSTACK);
596 
597  if(pp_flex_debug)
599 
600  if_stack[if_stack_idx++] = s;
601 
602  switch(s)
603  {
604  case if_true:
605  case if_elsetrue:
606  break;
607  case if_false:
608  case if_elsefalse:
609  case if_elif:
610  case if_ignore:
612  break;
613  default:
614  pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d)", (int)pp_if_state());
615  }
616 }
static int if_stack_idx
Definition: preproc.c:53
void pp_internal_error(const char *file, int line, const char *s,...)
Definition: preproc.c:754
int line_number
Definition: wpp_private.h:233
char * input
Definition: wpp_private.h:231
pp_if_state_t pp_if_state(void)
Definition: preproc.c:653
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static pp_if_state_t if_stack[MAXIFSTACK]
Definition: preproc.c:52
void pp_push_ignore_state(void)
Definition: ppl.yy.c:4593
static const char *const pp_if_state_str[]
Definition: preproc.c:583
GLdouble s
Definition: gl.h:2039
#define MAXIFSTACK
Definition: preproc.c:51
int pp_flex_debug
Definition: wpp.c:31
FILE * stderr

Referenced by pp_next_if_state(), and yyparse().

◆ pp_push_ignore_state()

void pp_push_ignore_state ( void  )

Definition at line 4593 of file ppl.yy.c.

4594 {
4596 }
#define pp_ignore
Definition: ppl.yy.c:1423
static void yy_push_state(int new_state)
Definition: ppl.yy.c:3492

Referenced by pp_push_if().

◆ pp_writestring()

void pp_writestring ( const char format,
  ... 
)

◆ pp_xmalloc()

void* pp_xmalloc ( size_t  )

Definition at line 77 of file preproc.c.

78 {
79  void *res;
80 
81  assert(size > 0);
82  res = malloc(size);
83  if(res == NULL)
84  {
85  /* Set the error flag */
86  pp_status.state = 1;
87  }
88  return res;
89 }
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
#define malloc
Definition: debug_ros.c:4

Referenced by get_string(), new_marg(), new_mtext(), pop_buffer(), pp_add_define(), pp_add_macro(), pp_push_define_state(), pp_writestring(), pp_xstrdup(), push_macro(), wpp_add_define(), wpp_default_lookup(), and yyparse().

◆ pp_xrealloc()

void* pp_xrealloc ( void ,
size_t   
)

Definition at line 91 of file preproc.c.

92 {
93  void *res;
94 
95  assert(size > 0);
96  res = realloc(p, size);
97  if(res == NULL)
98  {
99  /* Set the error flag */
100  pp_status.state = 1;
101  }
102  return res;
103 }
#define realloc
Definition: debug_ros.c:6
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by add_new_marg(), add_string(), add_text(), add_text_to_macro(), combine_mtext(), expand_special(), macro_add_arg(), merge_text(), pp_writestring(), and wpp_add_include_path().

◆ pp_xstrdup()

char* pp_xstrdup ( const char str)

Definition at line 105 of file preproc.c.

106 {
107  char *s;
108  int len;
109 
110  assert(str != NULL);
111  len = strlen(str)+1;
112  s = pp_xmalloc(len);
113  if(!s)
114  return NULL;
115  return memcpy(s, str, len);
116 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define assert(x)
Definition: debug.h:53
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
void * pp_xmalloc(size_t size)
Definition: preproc.c:77
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039

Referenced by generic_msg(), macro_add_arg(), macro_add_expansion(), pp_add_define(), pp_add_macro(), while(), wpp_add_cmdline_define(), wpp_add_define(), wpp_add_include_path(), and wpp_parse().

◆ pplookup()

pp_entry_t* pplookup ( const char ident)

Definition at line 221 of file preproc.c.

222 {
223  int idx;
224  pp_entry_t *ppp;
225 
226  if(!ident)
227  return NULL;
228  idx = pphash(ident);
229  for(ppp = pp_def_state->defines[idx]; ppp; ppp = ppp->next)
230  {
231  if(!strcmp(ident, ppp->ident))
232  return ppp;
233  }
234  return NULL;
235 }
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
static int pphash(const char *str)
Definition: preproc.c:213
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3993
char * ident
Definition: wpp_private.h:91
Definition: wpp_private.h:87
pp_entry_t * defines[HASHKEY]
Definition: preproc.c:46
struct pp_entry * next
Definition: wpp_private.h:88
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by pop_buffer(), pp_add_define(), pp_add_macro(), pp_del_define(), while(), and yyparse().

◆ ppy_error()

int ppy_error ( const char s,
  ... 
)

◆ ppy_lex()

int ppy_lex ( void  )

◆ ppy_parse()

void int ppy_parse ( void  )

◆ ppy_warning()

int int ppy_warning ( const char s,
  ... 
)

Variable Documentation

◆ pp_flex_debug

◆ pp_incl_state

include_state_t pp_incl_state

Definition at line 1334 of file ppl.yy.c.

Referenced by pop_buffer(), pp_do_include(), push_buffer(), while(), and yyparse().

◆ pp_includelogiclist

includelogicentry_t* pp_includelogiclist

Definition at line 1342 of file ppl.yy.c.

Referenced by free_pp_entry(), pop_buffer(), and pp_do_include().

◆ pp_status

Definition at line 39 of file preproc.c.

◆ ppy_debug

int ppy_debug

Definition at line 31 of file wpp.c.

Referenced by pop_buffer(), push_buffer(), and wpp_set_debug().

◆ ppy_in

FILE* ppy_in

◆ ppy_out

FILE* ppy_out

◆ ppy_text

char* ppy_text

◆ wpp_callbacks

Definition at line 733 of file preproc.c.