Skip to content

Conversation

@Reckordp
Copy link
Contributor

@Reckordp Reckordp commented Mar 7, 2020

On mirb

File.expand_path("~")

Result in windows

(mirb):1: non-absolute home (ArgumentError)

I have added some code for this. I like it when combined :)

{
#ifdef _WIN32
if (strlen(path) < 2) return 0;
return path[0] >= 64 && path[0] <= 90 && path[1] == ':'; // 64 to 90 is ASCII
Copy link
Contributor

@mattn mattn Mar 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not enoguh to check paths with slash or backslash. And "c:" is not absolute paths on Windows.

#define IS_PATHSEP(x) (x == '/' || x == '\')
    return (isalpha(path[0]) && path[1] == ':' && IS_PATHSEP(path[2]));
#undef IS_PATHSEP

Also if you want to handle UNC paths, it should check more strictly.

Copy link
Contributor Author

@Reckordp Reckordp Mar 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will adjust it like the source in ruby. just found out about UNC thanks

@matz matz merged commit 30eaee3 into mruby:master Mar 7, 2020
matz added a commit that referenced this pull request Mar 7, 2020
matz added a commit that referenced this pull request Mar 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants