Skip to content

Commit

Permalink
Windows: accept backslashes in file names
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
jktjkt committed Sep 5, 2023
1 parent 545f724 commit 1265f6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tree_schema_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2598,6 +2598,12 @@ void ly_sanity_check_module_filename(const struct ly_ctx *ctx, const char *name,

/* check that name and revision match filename */
basename = strrchr(filename, '/');
#ifdef _WIN32
const char *backslash = strrchr(filename, '\\');
if (!basename || (basename && backslash && backslash > basename)) {
basename = backslash;
}
#endif
if (!basename) {
basename = filename;
} else {
Expand Down
1 change: 1 addition & 0 deletions tools/lint/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ parse_schema_path(const char *path, char **dir, char **module)

/* split the path to dirname and basename for further work */
*dir = strdup(path);
/* FIXME: this is broken on Windows */

Check notice

Code scanning / CodeQL

FIXME comment Note

FIXME comment: this is broken on Windows
*module = strrchr(*dir, '/');
if (!(*module)) {
*module = *dir;
Expand Down

0 comments on commit 1265f6b

Please sign in to comment.