X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCutil.c;h=32c7bf74d4f2af67886c93850f24825ed1ab7257;hb=a5337f63283b2cf0d70179a71ab2a52c277a6f6a;hp=c0c317bee6930677988f2e64babfec74885ed5aa;hpb=a81ec42f1883f172d4bbc3b8f367424e5ecec5ee;p=fw%2Fsdcc diff --git a/src/SDCCutil.c b/src/SDCCutil.c index c0c317be..32c7bf74 100644 --- a/src/SDCCutil.c +++ b/src/SDCCutil.c @@ -32,6 +32,11 @@ #include "SDCCmacro.h" #include "SDCCutil.h" #include "newalloc.h" +#ifndef _WIN32 +#include "findme.h" +#endif + +#include "version.h" /** Given an array of name, value string pairs creates a new hash containing all of the pairs. @@ -143,18 +148,29 @@ getBinPath(const char *prel) char * getBinPath(const char *prel) { - char *p; - size_t len; static char path[PATH_MAX]; - - if ((p = strrchr(prel, DIR_SEPARATOR_CHAR)) == NULL) - return NULL; + const char *ret_path; + + if (NULL != (ret_path = findProgramPath(prel))) { + char *p; + size_t len; - len = min((sizeof path) - 1, p - prel); - strncpy(path, prel, len); - path[len] = '\0'; + if (NULL != (p = strrchr(ret_path, DIR_SEPARATOR_CHAR)) && + PATH_MAX > (len = p - ret_path)) { + memcpy(path, ret_path, len); + path[len] = '\0'; + free((void *)ret_path); + + return path; + } + else { + free((void *)ret_path); - return path; + return NULL; + } + } + else + return NULL; } #endif @@ -272,6 +288,16 @@ char *strncatz(char *dest, const char *src, size_t n) } +/*-----------------------------------------------------------------*/ +/* getBuildNumber - return build number */ +/*-----------------------------------------------------------------*/ +const char *getBuildNumber(void) +{ + return (SDCC_BUILD_NUMBER); +} + + + #if defined(HAVE_VSNPRINTF) || defined(HAVE_VSPRINTF) size_t SDCCsnprintf(char *dst, size_t n, const char *fmt, ...) {