Skip to content
Snippets Groups Projects
Commit 64d13632 authored by Michael Tüxen's avatar Michael Tüxen
Browse files

Add support for #ifdef Apple.

parent a7e08295
No related branches found
No related tags found
No related merge requests found
...@@ -104,7 +104,7 @@ static s64 hextol(const char *s) ...@@ -104,7 +104,7 @@ static s64 hextol(const char *s)
} }
enum ifdef_os { enum ifdef_os {
Linux_IFDEF = 1, FreeBSD_IFDEF, NetBSD_IFDEF, OpenBSD_IFDEF, Omnet_IFDEF Linux_IFDEF = 1, FreeBSD_IFDEF, NetBSD_IFDEF, OpenBSD_IFDEF, Omnet_IFDEF, Apple_IFDEF
}; };
#define MAX_IFDEF_DEPTH 1 #define MAX_IFDEF_DEPTH 1
...@@ -123,34 +123,35 @@ static inline int get_os_name_length(enum ifdef_os os) { ...@@ -123,34 +123,35 @@ static inline int get_os_name_length(enum ifdef_os os) {
return strlen("OpenBSD"); return strlen("OpenBSD");
case Omnet_IFDEF: case Omnet_IFDEF:
return strlen("Omnet"); return strlen("Omnet");
case Apple_IFDEF:
return strlen("Apple");
default: default:
return -1; return -1;
} }
} }
static inline bool ignore_ifdef(enum ifdef_os os) { static inline bool ignore_ifdef(enum ifdef_os os) {
switch (os) {
#ifdef linux #ifdef linux
if (os == Linux_IFDEF) { case Linux_IFDEF:
return false;
}
#endif #endif
#ifdef __FreeBSD__ #ifdef __FreeBSD__
if (os == FreeBSD_IFDEF) { case FreeBSD_IFDEF:
return false;
}
#endif #endif
#ifdef __OpenBSD__ #ifdef __OpenBSD__
if (os == OpenBSD_IFDEF) { case OpenBSD_IFDEF:
return false;
}
#endif #endif
#ifdef __NetBSD__ #ifdef __NetBSD__
if (os == NetBSD_IFDEF) { case NetBSD_IFDEF:
return false; #endif
} #ifdef __APPLE__
case Apple_IFDEF:
#endif #endif
/* no need to handle Omnet here */ /* no need to handle Omnet here */
return true; return false;
default:
return true;
}
} }
static inline char* remove_ifdef_start_and_endtag(char *code, int os_name_length) { static inline char* remove_ifdef_start_and_endtag(char *code, int os_name_length) {
...@@ -187,11 +188,11 @@ static void handle_ifdef(enum ifdef_os os, const char *s) { ...@@ -187,11 +188,11 @@ static void handle_ifdef(enum ifdef_os os, const char *s) {
} }
code = strdup(s); code = strdup(s);
// keep track of the current value of yylineno, because we need to restore it later (see EOF-Condition), // keep track of the current value of yylineno, because we need to restore it later (see EOF-Condition),
// otherwise all ifdefs that were interpreted will count twice in yylineno, // otherwise all ifdefs that were interpreted will count twice in yylineno,
// which will mess up the value in yylineno. // which will mess up the value in yylineno.
old_yylineno = yylineno; old_yylineno = yylineno;
code_without_ifdef = remove_ifdef_start_and_endtag(code, os_name_length); code_without_ifdef = remove_ifdef_start_and_endtag(code, os_name_length);
ifdef_stack[ifdef_stack_ptr++] = YY_CURRENT_BUFFER; ifdef_stack[ifdef_stack_ptr++] = YY_CURRENT_BUFFER;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment