8000 fix bug built on windows by aosemp · Pull Request #149 · vnmakarov/mir · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix bug built on windows #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v0_master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions c2mir/c2mir-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static const char *lib_suffix = ".dylib";
static lib_t std_libs[] = {{"msvcrt.dll", NULL}, {"kernel32.dll", NULL}};
static const char *std_lib_dirs[] = {""};
static const char *lib_suffix = ".dll";
#define dlopen(n, f) LoadLibrary (n)
#define dlopen(n, f) LoadLibraryA (n)
#define dlclose(h) FreeLibrary (h)
#define dlsym(h, s) GetProcAddress (h, s)
#endif
Expand Down Expand Up @@ -154,7 +154,7 @@ static void *open_lib (const char *dir, const char *name) {

VARR_TRUNC (char, temp_string, 0);
VARR_PUSH_ARR (char, temp_string, dir, strlen (dir));
if (last_slash[1] != '\0') VARR_PUSH (char, temp_string, slash);
if (last_slash && last_slash[1] != '\0') VARR_PUSH (char, temp_string, slash);
VARR_PUSH_ARR (char, temp_string, "lib", 3);
VARR_PUSH_ARR (char, temp_string, name, strlen (name));
VARR_PUSH_ARR (char, temp_string, lib_suffix, strlen (lib_suffix));
Expand Down
9 changes: 5 additions & 4 deletions c2mir/c2mir.c
8000
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ static token_t get_next_pptoken_1 (c2m_ctx_t c2m_ctx, int header_p) {
}
cs = VARR_LAST (stream_t, streams);
if (cs->f == NULL && cs->fname != NULL && !string_stream_p (cs)) {
if ((cs->f = fopen (cs->fname, "r")) == NULL) {
if ((cs->f = fopen (cs->fname, "rb")) == NULL) {
if (c2m_options->message_file != NULL)
fprintf (c2m_options->message_file, "cannot reopen file %s -- good bye\n", cs->fname);
longjmp (c2m_ctx->env, 1); // ???
Expand Down Expand Up @@ -2008,7 +2008,7 @@ static void add_include_stream (c2m_ctx_t c2m_ctx, const char *fname, const char
FILE *f;

assert (fname != NULL);
if (content == NULL && (f = fopen (fname, "r")) == NULL) {
if (content == NULL && (f = fopen (fname, "rb")) == NULL) {
if (c2m_options->message_file != NULL)
error (c2m_ctx, err_pos, "error in opening file %s", fname);
longjmp (c2m_ctx->env, 1); // ???
Expand Down Expand Up @@ -2206,7 +2206,7 @@ static void copy_and_push_back (c2m_ctx_t c2m_ctx, VARR (token_t) * tokens, pos_
static int file_found_p (const char *name) {
FILE *f;

if ((f = fopen (name, "r")) == NULL) return FALSE;
if ((f = fopen (name, "rb")) == NULL) return FALSE;
fclose (f);
return TRUE;
}
Expand Down Expand Up @@ -2884,6 +2884,7 @@ static void process_directive (c2m_ctx_t c2m_ctx) {
error (c2m_ctx, t->pos, "more %d include levels", VARR_LENGTH (stream_t, streams) - 1);
goto ret;
}
cs->pos = t->pos;
add_include_stream (c2m_ctx, name, content, t->pos);
} else if (strcmp (t->repr, "line") == 0) {
skip_nl (c2m_ctx, NULL, temp_buffer);
Expand Down Expand Up @@ -3437,7 +3438,7 @@ static void processing (c2m_ctx_t c2m_ctx, int ignore_directive_p) {
} else {
arg = VARR_LAST (token_arr_t, mc->args);
if ((name = get_header_name (c2m_ctx, arg, t->pos, &content)) != NULL) {
res = content != NULL || ((f = fopen (name, "r")) != NULL && !fclose (f)) ? 1 : 0;
res = content != NULL || ((f = fopen (name, "rb")) != NULL && !fclose (f)) ? 1 : 0;
} else {
error (c2m_ctx, t->pos, "wrong arg of predefined __has_include");
res = 0;
Expand Down
0