Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zsolt Vadász
wine
Commits
29378268
Commit
29378268
authored
21 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
Rewrote splitpath and wsplitpath to avoid modifying the path
separators.
parent
2925d6ad
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dlls/msvcrt/dir.c
+27
-69
27 additions, 69 deletions
dlls/msvcrt/dir.c
dlls/ntdll/string.c
+30
-70
30 additions, 70 deletions
dlls/ntdll/string.c
with
57 additions
and
139 deletions
dlls/msvcrt/dir.c
+
27
−
69
View file @
29378268
...
...
@@ -434,86 +434,44 @@ int _wrmdir(const MSVCRT_wchar_t * dir)
void
_wsplitpath
(
const
MSVCRT_wchar_t
*
inpath
,
MSVCRT_wchar_t
*
drv
,
MSVCRT_wchar_t
*
dir
,
MSVCRT_wchar_t
*
fname
,
MSVCRT_wchar_t
*
ext
)
{
/* Modified PD code from 'snippets' collection. */
MSVCRT_wchar_t
ch
,
*
ptr
,
*
p
;
MSVCRT_wchar_t
pathbuff
[
MAX_PATH
],
*
path
=
pathbuff
;
const
MSVCRT_wchar_t
*
p
,
*
end
;
/* FIXME: Should be an strncpyW or something */
strcpyW
(
pathbuff
,
inpath
);
TRACE
(
":splitting path %s
\n
"
,
debugstr_w
(
path
));
/* convert slashes to backslashes for searching */
for
(
ptr
=
(
MSVCRT_wchar_t
*
)
path
;
*
ptr
;
++
ptr
)
if
(
*
ptr
==
'/'
)
*
ptr
=
'\\'
;
/* look for drive spec */
if
((
ptr
=
strchrW
(
path
,
':'
))
!=
0
)
{
++
ptr
;
if
(
drv
)
if
(
inpath
[
0
]
&&
inpath
[
1
]
==
':'
)
{
strncpyW
(
drv
,
path
,
ptr
-
path
);
drv
[
ptr
-
path
]
=
0
;
if
(
drv
)
{
drv
[
0
]
=
inpath
[
0
];
drv
[
1
]
=
inpath
[
1
];
drv
[
2
]
=
0
;
}
inpath
+=
2
;
}
path
=
ptr
;
}
else
if
(
drv
)
*
drv
=
0
;
else
if
(
drv
)
drv
[
0
]
=
0
;
/*
find rightmost backslash or leftmost colon
*/
if
((
ptr
=
strrchrW
(
path
,
'\\'
))
=
=
NULL
)
ptr
=
(
strchrW
(
path
,
':'
))
;
/*
look for end of directory part
*/
end
=
NULL
;
for
(
p
=
inpath
;
*
p
;
p
++
)
if
(
*
p
==
'/'
||
*
p
==
'\\'
)
end
=
p
+
1
;
if
(
!
ptr
)
{
ptr
=
(
MSVCRT_wchar_t
*
)
path
;
/* no path */
if
(
dir
)
*
dir
=
0
;
}
else
{
++
ptr
;
/* skip the delimiter */
if
(
dir
)
if
(
end
)
/* got a directory */
{
ch
=
*
ptr
;
*
ptr
=
0
;
strcpyW
(
dir
,
path
);
*
ptr
=
ch
;
if
(
dir
)
{
memcpy
(
dir
,
inpath
,
(
end
-
inpath
)
*
sizeof
(
MSVCRT_wchar_t
)
);
dir
[
end
-
inpath
]
=
0
;
}
inpath
=
end
;
}
}
else
if
(
dir
)
dir
[
0
]
=
0
;
if
((
p
=
strrchrW
(
ptr
,
'.'
))
==
NULL
)
{
if
(
fname
)
strcpyW
(
fname
,
ptr
);
if
(
ext
)
*
ext
=
0
;
}
else
{
*
p
=
0
;
if
(
fname
)
strcpyW
(
fname
,
ptr
);
*
p
=
'.'
;
if
(
ext
)
strcpyW
(
ext
,
p
);
}
/* look for extension */
for
(
end
=
inpath
;
*
end
;
end
++
)
if
(
*
end
==
'.'
)
break
;
/* Fix pathological case - Win returns ':' as part of the
* directory when no drive letter is given.
*/
if
(
drv
&&
drv
[
0
]
==
':'
)
{
*
drv
=
0
;
if
(
dir
)
if
(
fname
)
{
pathbuff
[
0
]
=
':'
;
pathbuff
[
1
]
=
0
;
strcatW
(
pathbuff
,
dir
);
strcpyW
(
dir
,
pathbuff
);
memcpy
(
fname
,
inpath
,
(
end
-
inpath
)
*
sizeof
(
MSVCRT_wchar_t
)
);
fname
[
end
-
inpath
]
=
0
;
}
}
if
(
ext
)
strcpyW
(
ext
,
end
);
}
/* INTERNAL: Helper for _fullpath. Modified PD code from 'snippets'. */
...
...
This diff is collapsed.
Click to expand it.
dlls/ntdll/string.c
+
30
−
70
View file @
29378268
...
...
@@ -347,82 +347,42 @@ LONGLONG __cdecl _atoi64( char *str )
void
__cdecl
_splitpath
(
const
char
*
inpath
,
char
*
drv
,
char
*
dir
,
char
*
fname
,
char
*
ext
)
{
/* Modified PD code from 'snippets' collection. */
char
ch
,
*
ptr
,
*
p
;
char
pathbuff
[
MAX_PATH
],
*
path
=
pathbuff
;
strcpy
(
pathbuff
,
inpath
);
/* convert slashes to backslashes for searching */
for
(
ptr
=
(
char
*
)
path
;
*
ptr
;
++
ptr
)
if
(
'/'
==
*
ptr
)
*
ptr
=
'\\'
;
/* look for drive spec */
if
(
'\0'
!=
(
ptr
=
strchr
(
path
,
':'
)))
{
++
ptr
;
if
(
drv
)
const
char
*
p
,
*
end
;
if
(
inpath
[
0
]
&&
inpath
[
1
]
==
':'
)
{
strncpy
(
drv
,
path
,
ptr
-
path
);
drv
[
ptr
-
path
]
=
'\0'
;
if
(
drv
)
{
drv
[
0
]
=
inpath
[
0
];
drv
[
1
]
=
inpath
[
1
];
drv
[
2
]
=
0
;
}
inpath
+=
2
;
}
path
=
ptr
;
}
else
if
(
drv
)
*
drv
=
'\0'
;
/* find rightmost backslash or leftmost colon */
if
(
NULL
==
(
ptr
=
strrchr
(
path
,
'\\'
)))
ptr
=
(
strchr
(
path
,
':'
));
if
(
!
ptr
)
{
ptr
=
(
char
*
)
path
;
/* no path */
if
(
dir
)
*
dir
=
'\0'
;
}
else
{
++
ptr
;
/* skip the delimiter */
if
(
dir
)
else
if
(
drv
)
drv
[
0
]
=
0
;
/* look for end of directory part */
end
=
NULL
;
for
(
p
=
inpath
;
*
p
;
p
++
)
if
(
*
p
==
'/'
||
*
p
==
'\\'
)
end
=
p
+
1
;
if
(
end
)
/* got a directory */
{
ch
=
*
ptr
;
*
ptr
=
'\0'
;
strcpy
(
dir
,
path
);
*
ptr
=
ch
;
if
(
dir
)
{
memcpy
(
dir
,
inpath
,
end
-
inpath
);
dir
[
end
-
inpath
]
=
0
;
}
inpath
=
end
;
}
}
else
if
(
dir
)
dir
[
0
]
=
0
;
/* look for extension */
for
(
end
=
inpath
;
*
end
;
end
++
)
if
(
*
end
==
'.'
)
break
;
if
(
NULL
==
(
p
=
strrchr
(
ptr
,
'.'
)))
{
if
(
fname
)
strcpy
(
fname
,
ptr
);
if
(
ext
)
*
ext
=
'\0'
;
}
else
{
*
p
=
'\0'
;
if
(
fname
)
strcpy
(
fname
,
ptr
);
*
p
=
'.'
;
if
(
ext
)
strcpy
(
ext
,
p
);
}
/* Fix pathological case - Win returns ':' as part of the
* directory when no drive letter is given.
*/
if
(
drv
&&
drv
[
0
]
==
':'
)
{
*
drv
=
'\0'
;
if
(
dir
)
{
pathbuff
[
0
]
=
':'
;
pathbuff
[
1
]
=
'\0'
;
strcat
(
pathbuff
,
dir
);
strcpy
(
dir
,
pathbuff
);
memcpy
(
fname
,
inpath
,
end
-
inpath
);
fname
[
end
-
inpath
]
=
0
;
}
}
if
(
ext
)
strcpy
(
ext
,
end
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment