# HG changeset patch # User William Astle # Date 1359086400 25200 # Node ID 4b36eaaf80c35a145756ab16612eb783ecd9bf05 # Parent b97460509c3d940d4c8a55134ad8a492fd40b28d First attempt at fixing the drive letter problem on Windows Absolute paths in windows cannot be detected by simply checking for a leading slash, even in MinGW. Instead, apply a heuristic that looks for either a leading slash or a letter followed by a colon. This heuristic is only activated on windows builds. diff -r b97460509c3d -r 4b36eaaf80c3 lwasm/input.c --- a/lwasm/input.c Thu Jan 24 20:58:30 2013 -0700 +++ b/lwasm/input.c Thu Jan 24 21:00:00 2013 -0700 @@ -82,6 +82,28 @@ struct ifl *ifl_head = NULL; +static int input_isabsolute(const char *s) +{ +#if defined(WIN32) || defined(WIN64) + // aiming for the root of the current drive - treat as absolute + if (s[0] == '/') + return 1; + // check for drive letter stuff + if (!s[0] || !s[1]) + return 0; + if (s[1] != ':') + return 0; + if (isalpha(s[0])) + return 1; + return 0; +#else + /* this is suitable for unix-like systems */ + if (s[0] == '/') + return 1; + return 0; +#endif +} + /* this adds real filenames that were opened to a list */ void input_add_to_resource_list(asmstate_t *as, const char *s) { @@ -208,7 +230,7 @@ { case input_type_include: /* first check for absolute path and if so, skip path */ - if (*s == '/') + if (input_isabsolute(s)) { /* absolute path */ IS -> data = fopen(s, "rb"); @@ -292,7 +314,7 @@ debug_message(as, 2, "Open file (st) %s", s); /* first check for absolute path and if so, skip path */ - if (*s == '/') + if (input_isabsolute(s)) { /* absolute path */ debug_message(as, 2, "Open file (st abs) %s", s);