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\ietf-network@2018-02-26.yang" does not match module name "ietf-network".
  • Loading branch information
jktjkt committed Sep 5, 2023
1 parent 0490634 commit f0c235c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tree_schema_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2599,6 +2599,13 @@ ly_check_module_filename(const struct ly_ctx *ctx, const char *name, const char

/* 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 */
*module = strrchr(*dir, '/');
if (!(*module)) {
*module = *dir;
Expand Down

0 comments on commit f0c235c

Please sign in to comment.