Skip to content

Commit

Permalink
updated a lexer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kray-G committed Mar 30, 2021
1 parent dfffe6c commit 5bff1b6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,15 @@ static int set_package_version(const char *pkgname, int pos)
return pos;
}

static const char *search_using_path(const char *name)
static const char *search_using_path(const char *name, char *libname, int size)
{
char libname[LIBNAME_BUFSIZE*2] = {0};
const char *file = NULL;
/* Trying to search the file in the same directory first. */
snprintf(libname, LIBNAME_BUFSIZE*2-1, "%s%c%s.kx", parent_path(kx_lexinfo.file), PATH_DELCH, name);
snprintf(libname, size-1, "%s%c%s.kx", parent_path(kx_lexinfo.file), PATH_DELCH, name);
if (file_exists(libname)) {
file = libname;
} else {
snprintf(libname, LIBNAME_BUFSIZE*2-1, "%s.kx", name);
snprintf(libname, size-1, "%s.kx", name);
file = kxlib_file_exists(libname);
}
return file;
Expand Down Expand Up @@ -232,7 +231,7 @@ static int load_using_module(const char *name, const char *pkgname, const char *
return load_using_module_asta(name, len, pkgname, pkgkey);
}
} else {
file = search_using_path(name);
file = search_using_path(name, libname, LIBNAME_BUFSIZE*2-1);
if (!file) {
if (!no_error) {
const char *msg = pkgname && !is_package_installed(pkgname)
Expand Down

0 comments on commit 5bff1b6

Please sign in to comment.