ReactOS  0.4.15-dev-321-g2d9b385
preproc.c File Reference
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "wpp_private.h"
Include dependency graph for preproc.c:

Go to the source code of this file.

Classes

struct  pp_def_state
 

Macros

#define HASHKEY   2039
 
#define MAXIFSTACK   64
 

Typedefs

typedef struct pp_def_state pp_def_state_t
 

Functions

voidpp_xmalloc (size_t size)
 
voidpp_xrealloc (void *p, size_t size)
 
charpp_xstrdup (const char *str)
 
static int pphash (const char *str)
 
pp_entry_tpplookup (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_tpp_add_define (const char *def, const char *text)
 
pp_entry_tpp_add_macro (char *id, marg_t *args[], int nargs, mtext_t *exp)
 
voidpp_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)
 
void WINAPIV pp_internal_error (const char *file, int line, const char *s,...)
 

Variables

struct pp_status pp_status
 
static pp_def_state_tpp_def_state
 
static pp_if_state_t if_stack [MAXIFSTACK]
 
static int if_stack_idx = 0
 

Macro Definition Documentation

◆ HASHKEY

#define HASHKEY   2039

Definition at line 31 of file preproc.c.

◆ MAXIFSTACK

#define MAXIFSTACK   64

Definition at line 41 of file preproc.c.

Typedef Documentation

◆ pp_def_state_t

Function Documentation

◆ free_pp_entry()

static void free_pp_entry ( pp_entry_t ppp,
int  idx 
)
static

Definition at line 111 of file preproc.c.

112 {
113  if(ppp->iep)
114  {
115  if(ppp->iep == pp_includelogiclist)
116  {
117  pp_includelogiclist = ppp->iep->next;
120  }
121  else
122  {
123  ppp->iep->prev->next = ppp->iep->next;
124  if(ppp->iep->next)
125  ppp->iep->next->prev = ppp->iep->prev;
126  }
127  free(ppp->iep->filename);
128  free(ppp->iep);
129  }
130 
131  if(pp_def_state->defines[idx] == ppp)
132  {
133  pp_def_state->defines[idx] = ppp->next;
134  if(pp_def_state->defines[idx])
136  }
137  else
138  {
139  ppp->prev->next = ppp->next;
140  if(ppp->next)
141  ppp->next->prev = ppp->prev;
142  }
143 
144  free(ppp);
145 }
pp_entry_t * defines[HASHKEY]
Definition: preproc.c:36
#define free
Definition: debug_ros.c:5
struct pp_entry * prev
Definition: wpp_private.h:97
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
struct includelogicentry * prev
Definition: wpp_private.h:46
includelogicentry_t * pp_includelogiclist
Definition: ppl.yy.c:1547
struct includelogicentry * next
Definition: wpp_private.h:45
struct pp_entry * next
Definition: wpp_private.h:96
includelogicentry_t * iep
Definition: wpp_private.h:109

Referenced by pp_del_define().

◆ pp_add_define()

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

Definition at line 194 of file preproc.c.

195 {
196  int len;
197  char *cptr;
198  int idx;
199  pp_entry_t *ppp;
200 
201  if(!def)
202  return NULL;
203  idx = pphash(def);
204  if((ppp = pplookup(def)) != NULL)
205  {
206  if(pp_status.pedantic)
207  ppy_warning("Redefinition of %s\n\tPrevious definition: %s:%d", def, ppp->filename, ppp->linenumber);
208  pp_del_define(def);
209  }
210  ppp = pp_xmalloc(sizeof(pp_entry_t));
211  if(!ppp)
212  return NULL;
213  memset( ppp, 0, sizeof(*ppp) );
214  ppp->ident = pp_xstrdup(def);
215  if(!ppp->ident)
216  goto error;
217  ppp->type = def_define;
218  ppp->subst.text = text ? pp_xstrdup(text) : NULL;
219  if(text && !ppp->subst.text)
220  goto error;
221  ppp->filename = pp_xstrdup(pp_status.input ? pp_status.input : "<internal or cmdline>");
222  if(!ppp->filename)
223  goto error;
225  ppp->next = pp_def_state->defines[idx];
226  pp_def_state->defines[idx] = ppp;
227  if(ppp->next)
228  ppp->next->prev = ppp;
229  if(ppp->subst.text)
230  {
231  /* Strip trailing white space from subst text */
232  len = strlen(ppp->subst.text);
233  while(len && strchr(" \t\r\n", ppp->subst.text[len-1]))
234  {
235  ppp->subst.text[--len] = '\0';
236  }
237  /* Strip leading white space from subst text */
238  for(cptr = ppp->subst.text; *cptr && strchr(" \t\r", *cptr); cptr++)
239  ;
240  if(ppp->subst.text != cptr)
241  memmove(ppp->subst.text, cptr, strlen(cptr)+1);
242  }
243  return ppp;
244 
245 error:
246  free(ppp->ident);
247  free(ppp->subst.text);
248  free(ppp);
249  return NULL;
250 }
pp_entry_t * defines[HASHKEY]
Definition: preproc.c:36
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
char * text
Definition: wpp_private.h:104
#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
char * ident
Definition: wpp_private.h:99
int line_number
Definition: wpp_private.h:222
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
union pp_entry::@241 subst
static int pphash(const char *str)
Definition: preproc.c:87
int linenumber
Definition: wpp_private.h:108
char * input
Definition: wpp_private.h:220
int ppy_warning(const char *s,...)
Definition: preproc.c:745
char * pp_xstrdup(const char *str)
Definition: preproc.c:73
Definition: wpp_private.h:95
void pp_del_define(const char *name)
Definition: preproc.c:176
char * filename
Definition: wpp_private.h:107
GLenum GLsizei len
Definition: glext.h:6722
pp_entry_t * pplookup(const char *ident)
Definition: preproc.c:95
char * strchr(const char *String, int ch)
Definition: utclib.c:501
struct pp_entry * next
Definition: wpp_private.h:96
def_type_t type
Definition: wpp_private.h:98
void * pp_xmalloc(size_t size)
Definition: preproc.c:45
int pedantic
Definition: wpp_private.h:225
#define memset(x, y, z)
Definition: compat.h:39

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

◆ pp_add_macro()

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

Definition at line 252 of file preproc.c.

253 {
254  int idx;
255  pp_entry_t *ppp;
256 
257  if(!id)
258  return NULL;
259  idx = pphash(id);
260  if((ppp = pplookup(id)) != NULL)
261  {
262  if(pp_status.pedantic)
263  ppy_warning("Redefinition of %s\n\tPrevious definition: %s:%d", id, ppp->filename, ppp->linenumber);
264  pp_del_define(id);
265  }
266  ppp = pp_xmalloc(sizeof(pp_entry_t));
267  if(!ppp)
268  return NULL;
269  memset( ppp, 0, sizeof(*ppp) );
270  ppp->ident = id;
271  ppp->type = def_macro;
272  ppp->margs = args;
273  ppp->nargs = nargs;
274  ppp->subst.mtext= exp;
275  ppp->filename = pp_xstrdup(pp_status.input ? pp_status.input : "<internal or cmdline>");
276  if(!ppp->filename)
277  {
278  free(ppp);
279  return NULL;
280  }
282  ppp->next = pp_def_state->defines[idx];
283  pp_def_state->defines[idx] = ppp;
284  if(ppp->next)
285  ppp->next->prev = ppp;
286  return ppp;
287 }
pp_entry_t * defines[HASHKEY]
Definition: preproc.c:36
int nargs
Definition: wpp_private.h:101
#define free
Definition: debug_ros.c:5
char * ident
Definition: wpp_private.h:99
int line_number
Definition: wpp_private.h:222
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
union pp_entry::@241 subst
static int pphash(const char *str)
Definition: preproc.c:87
mtext_t * mtext
Definition: wpp_private.h:103
int linenumber
Definition: wpp_private.h:108
char * input
Definition: wpp_private.h:220
int ppy_warning(const char *s,...)
Definition: preproc.c:745
char * pp_xstrdup(const char *str)
Definition: preproc.c:73
Definition: wpp_private.h:95
void pp_del_define(const char *name)
Definition: preproc.c:176
char * filename
Definition: wpp_private.h:107
pp_entry_t * pplookup(const char *ident)
Definition: preproc.c:95
marg_t ** margs
Definition: wpp_private.h:100
DWORD exp
Definition: msg.c:16033
struct pp_entry * next
Definition: wpp_private.h:96
def_type_t type
Definition: wpp_private.h:98
void * pp_xmalloc(size_t size)
Definition: preproc.c:45
GLenum GLuint id
Definition: glext.h:5579
int pedantic
Definition: wpp_private.h:225
#define memset(x, y, z)
Definition: compat.h:39
#define args
Definition: format.c:66

Referenced by yyparse().

◆ pp_del_define()

void pp_del_define ( const char name)

Definition at line 176 of file preproc.c.

177 {
178  pp_entry_t *ppp;
179  int idx = pphash(name);
180 
181  if((ppp = pplookup(name)) == NULL)
182  {
183  if(pp_status.pedantic)
184  ppy_warning("%s was not defined", name);
185  return;
186  }
187 
188  free( ppp->ident );
189  free( ppp->subst.text );
190  free( ppp->filename );
191  free_pp_entry( ppp, idx );
192 }
char * text
Definition: wpp_private.h:104
#define free
Definition: debug_ros.c:5
char * ident
Definition: wpp_private.h:99
static void free_pp_entry(pp_entry_t *ppp, int idx)
Definition: preproc.c:111
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
union pp_entry::@241 subst
static int pphash(const char *str)
Definition: preproc.c:87
int ppy_warning(const char *s,...)
Definition: preproc.c:745
Definition: wpp_private.h:95
char * filename
Definition: wpp_private.h:107
pp_entry_t * pplookup(const char *ident)
Definition: preproc.c:95
Definition: name.c:38
int pedantic
Definition: wpp_private.h:225

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

◆ pp_get_if_depth()

int pp_get_if_depth ( void  )

Definition at line 433 of file preproc.c.

434 {
435  return if_stack_idx;
436 }
static int if_stack_idx
Definition: preproc.c:43

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

◆ pp_if_state()

pp_if_state_t pp_if_state ( void  )

Definition at line 405 of file preproc.c.

406 {
407  if(!if_stack_idx)
408  return if_true;
409  else
410  return if_stack[if_stack_idx-1];
411 }
static pp_if_state_t if_stack[MAXIFSTACK]
Definition: preproc.c:42
static int if_stack_idx
Definition: preproc.c:43

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

◆ pp_internal_error()

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

Definition at line 438 of file preproc.c.

439 {
441  __ms_va_start(ap, s);
442  fprintf(stderr, "Internal error (please report) %s %d: ", file, line);
443  vfprintf(stderr, s, ap);
444  fprintf(stderr, "\n");
445  __ms_va_end(ap);
446  exit(3);
447 }
static static const char __ms_va_list
Definition: printf.c:76
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
Definition: parser.c:48
GLdouble s
Definition: gl.h:2039
#define __ms_va_end(list)
Definition: windef.h:458
#define __ms_va_start(list, arg)
Definition: windef.h:457
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
FILE * stderr
void exit(int exitcode)
Definition: _exit.c:33
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
Definition: fci.c:126

Referenced by add_expand_text(), expand_special(), make_number(), pop_buffer(), pop_macro(), pp_next_if_state(), pp_pop_if(), pp_push_if(), push_buffer(), while(), and yyparse().

◆ pp_next_if_state()

void pp_next_if_state ( int  i)

Definition at line 414 of file preproc.c.

415 {
416  switch(pp_if_state())
417  {
418  case if_true:
419  case if_elsetrue:
421  break;
422  case if_false:
423  case if_elsefalse:
424  case if_elif:
425  case if_ignore:
427  break;
428  default:
429  pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d) in #{if,ifdef,ifndef} directive", (int)pp_if_state());
430  }
431 }
void WINAPIV pp_internal_error(const char *file, int line, const char *s,...)
Definition: preproc.c:438
void pp_push_if(pp_if_state_t s)
Definition: preproc.c:357
pp_if_state_t pp_if_state(void)
Definition: preproc.c:405
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

Referenced by yyparse().

◆ pp_open_include()

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

Definition at line 290 of file preproc.c.

291 {
292  char *path;
293  void *fp;
294 
295  if (!(path = wpp_lookup(name, type, parent_name))) return NULL;
296  fp = wpp_open(path, type);
297 
298  if (fp)
299  {
300  if (newpath) *newpath = path;
301  else free( path );
302  return fp;
303  }
304  free( path );
305  return NULL;
306 }
GLsizei const GLchar ** path
Definition: glext.h:7234
#define free
Definition: debug_ros.c:5
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
smooth NULL
Definition: ftsmooth.c:416
void * wpp_open(const char *filename, int type)
Definition: compiler.c:195
char * wpp_lookup(const char *filename, int type, const char *parent_name)
Definition: compiler.c:162
Definition: name.c:38

Referenced by pp_do_include().

◆ pp_pop_define_state()

void pp_pop_define_state ( void  )

Definition at line 161 of file preproc.c.

162 {
163  int i;
164  pp_entry_t *ppp;
166 
167  for (i = 0; i < HASHKEY; i++)
168  {
169  while ((ppp = pp_def_state->defines[i]) != NULL) pp_del_define( ppp->ident );
170  }
172  pp_def_state = state->next;
173  free( state );
174 }
pp_entry_t * defines[HASHKEY]
Definition: preproc.c:36
static pp_def_state_t * pp_def_state
Definition: preproc.c:39
#define free
Definition: debug_ros.c:5
char * ident
Definition: wpp_private.h:99
#define HASHKEY
Definition: preproc.c:31
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
Definition: wpp_private.h:95
static int state
Definition: maze.c:121
void pp_del_define(const char *name)
Definition: preproc.c:176

Referenced by wpp_parse().

◆ pp_pop_if()

pp_if_state_t pp_pop_if ( void  )

Definition at line 380 of file preproc.c.

381 {
382  if(if_stack_idx <= 0)
383  {
384  ppy_error("#{endif,else,elif} without #{if,ifdef,ifndef} (#if-stack underflow)");
385  return if_error;
386  }
387 
388  switch(pp_if_state())
389  {
390  case if_true:
391  case if_elsetrue:
392  break;
393  case if_false:
394  case if_elsefalse:
395  case if_elif:
396  case if_ignore:
398  break;
399  default:
400  pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d)", (int)pp_if_state());
401  }
402  return if_stack[--if_stack_idx];
403 }
void WINAPIV pp_internal_error(const char *file, int line, const char *s,...)
Definition: preproc.c:438
pp_if_state_t pp_if_state(void)
Definition: preproc.c:405
int ppy_error(const char *s,...)
Definition: preproc.c:735
static pp_if_state_t if_stack[MAXIFSTACK]
Definition: preproc.c:42
static int if_stack_idx
Definition: preproc.c:43
void pp_pop_ignore_state(void)
Definition: ppl.yy.c:4753

Referenced by wpp_parse(), and yyparse().

◆ pp_push_define_state()

int pp_push_define_state ( void  )

Definition at line 148 of file preproc.c.

149 {
150  pp_def_state_t *state = pp_xmalloc( sizeof(*state) );
151  if(!state)
152  return 1;
153 
154  memset( state->defines, 0, sizeof(state->defines) );
155  state->next = pp_def_state;
157  return 0;
158 }
static pp_def_state_t * pp_def_state
Definition: preproc.c:39
static int state
Definition: maze.c:121
void * pp_xmalloc(size_t size)
Definition: preproc.c:45
#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 357 of file preproc.c.

358 {
359  if(if_stack_idx >= MAXIFSTACK)
360  pp_internal_error(__FILE__, __LINE__, "#if-stack overflow; #{if,ifdef,ifndef} nested too deeply (> %d)", MAXIFSTACK);
361 
362  if_stack[if_stack_idx++] = s;
363 
364  switch(s)
365  {
366  case if_true:
367  case if_elsetrue:
368  break;
369  case if_false:
370  case if_elsefalse:
371  case if_elif:
372  case if_ignore:
374  break;
375  default:
376  pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d)", (int)pp_if_state());
377  }
378 }
void WINAPIV pp_internal_error(const char *file, int line, const char *s,...)
Definition: preproc.c:438
pp_if_state_t pp_if_state(void)
Definition: preproc.c:405
static pp_if_state_t if_stack[MAXIFSTACK]
Definition: preproc.c:42
GLdouble s
Definition: gl.h:2039
void pp_push_ignore_state(void)
Definition: ppl.yy.c:4748
static int if_stack_idx
Definition: preproc.c:43
#define MAXIFSTACK
Definition: preproc.c:41

Referenced by pp_next_if_state(), and yyparse().

◆ pp_xmalloc()

void* pp_xmalloc ( size_t  size)

Definition at line 45 of file preproc.c.

46 {
47  void *res;
48 
49  assert(size > 0);
50  res = malloc(size);
51  if(res == NULL)
52  {
53  /* Set the error flag */
54  pp_status.state = 1;
55  }
56  return res;
57 }
#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 p,
size_t  size 
)

Definition at line 59 of file preproc.c.

60 {
61  void *res;
62 
63  assert(size > 0);
64  res = realloc(p, size);
65  if(res == NULL)
66  {
67  /* Set the error flag */
68  pp_status.state = 1;
69  }
70  return res;
71 }
#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 73 of file preproc.c.

74 {
75  char *s;
76  int len;
77 
78  assert(str != NULL);
79  len = strlen(str)+1;
80  s = pp_xmalloc(len);
81  if(!s)
82  return NULL;
83  return memcpy(s, str, len);
84 }
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
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
void * pp_xmalloc(size_t size)
Definition: preproc.c:45

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().

◆ pphash()

static int pphash ( const char str)
static

Definition at line 87 of file preproc.c.

88 {
89  int sum = 0;
90  while(*str)
91  sum += *str++;
92  return sum % HASHKEY;
93 }
#define HASHKEY
Definition: preproc.c:31
const WCHAR * str
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35

Referenced by pp_add_define(), pp_add_macro(), pp_del_define(), and pplookup().

◆ pplookup()

pp_entry_t* pplookup ( const char ident)

Definition at line 95 of file preproc.c.

96 {
97  int idx;
98  pp_entry_t *ppp;
99 
100  if(!ident)
101  return NULL;
102  idx = pphash(ident);
103  for(ppp = pp_def_state->defines[idx]; ppp; ppp = ppp->next)
104  {
105  if(!strcmp(ident, ppp->ident))
106  return ppp;
107  }
108  return NULL;
109 }
pp_entry_t * defines[HASHKEY]
Definition: preproc.c:36
char * ident
Definition: wpp_private.h:99
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
static int pphash(const char *str)
Definition: preproc.c:87
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3993
Definition: wpp_private.h:95
struct pp_entry * next
Definition: wpp_private.h:96
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().

Variable Documentation

◆ if_stack

pp_if_state_t if_stack[MAXIFSTACK]
static

Definition at line 42 of file preproc.c.

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

◆ if_stack_idx

int if_stack_idx = 0
static

Definition at line 43 of file preproc.c.

Referenced by pp_get_if_depth(), pp_if_state(), pp_pop_if(), and pp_push_if().

◆ pp_def_state

Definition at line 39 of file preproc.c.

Referenced by pp_pop_define_state(), and pp_push_define_state().

◆ pp_status

Definition at line 29 of file preproc.c.