Skip to content

Commit 35c145a

Browse files
jktjktmichalvasko
authored andcommitted
Windows: accept backslashes in file names
Without this patch, a warning gets printed for any .yang files that are read using native path names: libyang[1]: File name "D:\a\oopt-gnpy-libyang\oopt-gnpy-libyang\tests\yang\[email protected]" does not match module name "ietf-network".
1 parent 026737b commit 35c145a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/tree_schema_common.c

+7
Original file line numberDiff line numberDiff line change
@@ -2599,6 +2599,13 @@ ly_check_module_filename(const struct ly_ctx *ctx, const char *name, const char
25992599

26002600
/* check that name and revision match filename */
26012601
basename = strrchr(filename, '/');
2602+
#ifdef _WIN32
2603+
const char *backslash = strrchr(filename, '\\');
2604+
2605+
if (!basename || (basename && backslash && (backslash > basename))) {
2606+
basename = backslash;
2607+
}
2608+
#endif
26022609
if (!basename) {
26032610
basename = filename;
26042611
} else {

tools/lint/common.c

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ parse_schema_path(const char *path, char **dir, char **module)
5454

5555
/* split the path to dirname and basename for further work */
5656
*dir = strdup(path);
57+
/* FIXME: this is broken on Windows */
5758
*module = strrchr(*dir, '/');
5859
if (!(*module)) {
5960
*module = *dir;

0 commit comments

Comments
 (0)