#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.
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;
- len = min((sizeof path) - 1, p - prel);
- strncpy(path, prel, len);
- path[len] = '\0';
+ if (NULL != (ret_path = findProgramPath(prel))) {
+ char *p;
+ size_t len;
- return path;
+ 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 NULL;
+ }
+ }
+ else
+ return NULL;
}
#endif
}
void
-buildCmdLine2 (char *pbuffer, const char *pcmd, size_t len)
+buildCmdLine2 (char *pbuffer, size_t len, const char *pcmd, ...)
{
+ va_list ap;
char *poutcmd;
+
assert(pbuffer && pcmd);
assert(_mainValues);
- poutcmd = msprintf(_mainValues, pcmd);
+ va_start(ap, pcmd);
+
+ poutcmd = mvsprintf(_mainValues, pcmd, ap);
+
+ va_end(ap);
+
strncpyz(pbuffer, poutcmd, len);
+ Safe_free(poutcmd);
}
void
}
+/*-----------------------------------------------------------------*/
+/* 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, ...)
{