Commit 91872318 authored by Alexandre Julliard's avatar Alexandre Julliard

wpp: Get rid of the no longer needed callbacks.

parent c8d34ef0
......@@ -24,30 +24,6 @@
#include <stdio.h>
#include <stdarg.h>
struct wpp_callbacks
{
/* I/O callbacks */
/* Looks for a file to include, returning the path where it is found */
/* The type param is true for local (#include "filename.h") includes */
/* parent_name is the directory of the parent source file, includepath
* is an array of additional include paths */
char *(*lookup)( const char *filename, int type, const char *parent_name,
char **include_path, int include_path_count );
/* Opens an include file */
void *(*open)( const char *filename, int type );
/* Closes a previously opened file */
void (*close)( void *file );
/* Reads buffer from the input */
int (*read)( void *file, char *buffer, unsigned int len );
/* Writes buffer to the output */
void (*write)( const char *buffer, unsigned int len );
/* Error callbacks */
void (*error)( const char *file, int line, int col, const char *near, const char *msg, va_list ap );
void (*warning)( const char *file, int line, int col, const char *near, const char *msg, va_list ap );
};
/* Return value == 0 means successful execution */
extern int wpp_add_define( const char *name, const char *value );
extern void wpp_del_define( const char *name );
......@@ -57,6 +33,5 @@ extern void wpp_set_pedantic( int on );
extern int wpp_add_include_path( const char *path );
extern char *wpp_find_include( const char *name, const char *parent_name );
extern int wpp_parse( const char *input, FILE *output );
extern void wpp_set_callbacks( const struct wpp_callbacks *callbacks );
#endif /* __WINE_WPP_H */
......@@ -306,7 +306,7 @@ includelogicentry_t *pp_includelogiclist = NULL;
#define YY_INPUT(buf,result,max_size) \
{ \
result = wpp_callbacks->read(pp_status.file, buf, max_size); \
result = fread(buf, 1, max_size, pp_status.file); \
}
#define BUFFERINITIALCAPACITY 256
......@@ -353,7 +353,7 @@ void pp_writestring(const char *format, ...)
va_end(valist);
}
wpp_callbacks->write(buffer, len);
fwrite(buffer, 1, len, ppy_out);
}
%}
......@@ -1340,7 +1340,7 @@ static bufferstackentry_t *pop_buffer(void)
if(!bufferstack[bufferstackidx].should_pop)
{
wpp_callbacks->close(pp_status.file);
fclose(pp_status.file);
pp_writestring("# %d \"%s\" 2\n", bufferstack[bufferstackidx].line_number, bufferstack[bufferstackidx].filename);
/* We have EOF, check the include logic */
......@@ -1561,7 +1561,7 @@ static void put_buffer(const char *s, int len)
if(top_macro())
add_text_to_macro(s, len);
else
wpp_callbacks->write(s, len);
fwrite(s, 1, len, ppy_out);
}
......
......@@ -112,8 +112,8 @@ char *pp_xstrdup(const char *str)
return memcpy(s, str, len);
}
static char *wpp_default_lookup(const char *name, int type, const char *parent_name,
char **include_path, int include_path_count)
char *wpp_lookup(const char *name, int type, const char *parent_name,
char **include_path, int include_path_count)
{
char *cpy;
char *cptr;
......@@ -190,22 +190,6 @@ static char *wpp_default_lookup(const char *name, int type, const char *parent_n
return NULL;
}
static void *wpp_default_open(const char *filename, int type) {
return fopen(filename,"rt");
}
static void wpp_default_close(void *file) {
fclose(file);
}
static int wpp_default_read(void *file, char *buffer, unsigned int len){
return fread(buffer, 1, len, file);
}
static void wpp_default_write( const char *buffer, unsigned int len ) {
fwrite(buffer, 1, len, ppy_out);
}
/* Don't comment on the hash, it's primitive but functional... */
static int pphash(const char *str)
{
......@@ -505,7 +489,7 @@ int wpp_add_include_path(const char *path)
char *wpp_find_include(const char *name, const char *parent_name)
{
return wpp_default_lookup(name, !!parent_name, parent_name, includepath, nincludepath);
return wpp_lookup(name, !!parent_name, parent_name, includepath, nincludepath);
}
void *pp_open_include(const char *name, int type, const char *parent_name, char **newpath)
......@@ -513,9 +497,8 @@ void *pp_open_include(const char *name, int type, const char *parent_name, char
char *path;
void *fp;
if (!(path = wpp_callbacks->lookup(name, type, parent_name, includepath,
nincludepath))) return NULL;
fp = wpp_callbacks->open(path, type);
if (!(path = wpp_lookup(name, type, parent_name, includepath, nincludepath))) return NULL;
fp = fopen(path, "rt");
if (fp)
{
......@@ -705,45 +688,20 @@ end:
fprintf(stderr, "\n");
}
static void wpp_default_error(const char *file, int line, int col, const char *near, const char *msg, va_list ap)
{
generic_msg(msg, "Error", near, ap);
exit(1);
}
static void wpp_default_warning(const char *file, int line, int col, const char *near, const char *msg, va_list ap)
{
generic_msg(msg, "Warning", near, ap);
}
static const struct wpp_callbacks default_callbacks =
{
wpp_default_lookup,
wpp_default_open,
wpp_default_close,
wpp_default_read,
wpp_default_write,
wpp_default_error,
wpp_default_warning,
};
const struct wpp_callbacks *wpp_callbacks = &default_callbacks;
int ppy_error(const char *s, ...)
{
va_list ap;
va_start(ap, s);
wpp_callbacks->error(pp_status.input, pp_status.line_number, pp_status.char_number, ppy_text, s, ap);
generic_msg(s, "Error", ppy_text, ap);
va_end(ap);
pp_status.state = 1;
return 1;
exit(1);
}
int ppy_warning(const char *s, ...)
{
va_list ap;
va_start(ap, s);
wpp_callbacks->warning(pp_status.input, pp_status.line_number, pp_status.char_number, ppy_text, s, ap);
generic_msg(s, "Warning", ppy_text, ap);
va_end(ap);
return 0;
}
......
......@@ -197,7 +197,7 @@ int wpp_parse( const char *input, FILE *output )
add_special_defines();
if (!input) pp_status.file = stdin;
else if (!(pp_status.file = wpp_callbacks->open(input, 1)))
else if (!(pp_status.file = fopen(input, "rt")))
{
ppy_error("Could not open %s\n", input);
del_special_defines();
......@@ -217,7 +217,7 @@ int wpp_parse( const char *input, FILE *output )
if (input)
{
wpp_callbacks->close(pp_status.file);
fclose(pp_status.file);
free(pp_status.input);
}
/* Clean if_stack, it could remain dirty on errors */
......@@ -227,9 +227,3 @@ int wpp_parse( const char *input, FILE *output )
pp_pop_define_state();
return ret;
}
void wpp_set_callbacks( const struct wpp_callbacks *callbacks )
{
wpp_callbacks = callbacks;
}
......@@ -190,6 +190,8 @@ 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);
char *wpp_lookup(const char *name, int type, const char *parent_name,
char **include_path, int include_path_count);
#ifndef __GNUC__
#define __attribute__(x) /*nothing*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment