Use posix wrappers in lexer

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-03-28 22:20:32 +02:00
parent 74f34747b1
commit 66bf23d2e7
3 changed files with 13 additions and 18 deletions

View File

@ -98,8 +98,6 @@ grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
# For the lexer.
grub_script.yy.c grub_script.yy.h: script/yylex.l
$(LEX) -o grub_script.yy.c --header-file=grub_script.yy.h $(srcdir)/script/yylex.l
sed -i 's/^#include.*\(<stdio\.h>\|<string\.h>\|<errno\.h>\|<stdlib\.h>\|<unistd\.h>\)//g' grub_script.yy.h
sed -i 's/^#include.*\(<stdio\.h>\|<string\.h>\|<errno\.h>\|<stdlib\.h>\|<unistd\.h>\)//g' grub_script.yy.c
DISTCLEANFILES += grub_script.yy.c grub_script.yy.h
# For grub-script-check.
@ -655,7 +653,7 @@ normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For sh.mod.
sh_mod_SOURCES = script/main.c script/script.c script/execute.c \
script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c
sh_mod_CFLAGS = $(COMMON_CFLAGS)
sh_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS)
sh_mod_LDFLAGS = $(COMMON_LDFLAGS)
ifneq (, $(FONT_SOURCE))

View File

@ -20,5 +20,10 @@
#define GRUB_POSIX_STDIO_H 1
#include <grub/misc.h>
#include <grub/file.h>
typedef struct grub_file FILE;
#define EOF -1
#endif

View File

@ -68,31 +68,23 @@ static void copy_string (struct grub_parser_param *, const char *,
%top{
#include <sys/types.h>
typedef size_t yy_size_t;
#define YY_TYPEDEF_YY_SIZE_T 1
/*
* Some flex hacks for -nostdinc; XXX We need to fix these when libc
* support becomes availble in GRUB.
*/
#include <grub/types.h>
typedef grub_size_t size_t;
typedef grub_size_t yy_size_t;
#define YY_TYPEDEF_YY_SIZE_T 1
#define FILE void
#ifndef GRUB_UTIL
#define stdin 0
#define stdout 0
#define EOF 0
#define errno grub_errno
#define EINVAL GRUB_ERR_BAD_NUMBER
#define ENOMEM GRUB_ERR_OUT_OF_MEMORY
#define strlen grub_strlen
#define memset grub_memset
#define fprintf(...) 0
#define exit(...)
#endif
#pragma GCC diagnostic warning "-Wunused-variable"
#pragma GCC diagnostic warning "-Wunused-function"