fixed ${NSISDIR} on POSIX when makensis is called with an absolute path
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3542 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
890a83c2b1
commit
c458fd50bc
3 changed files with 38 additions and 56 deletions
|
@ -459,49 +459,15 @@ definedlist.add("NSIS_SUPPORT_LANG_IN_STRINGS");
|
||||||
|
|
||||||
void CEXEBuild::setdirs(char *argv0)
|
void CEXEBuild::setdirs(char *argv0)
|
||||||
{
|
{
|
||||||
char szNSISDir[NSIS_MAX_STRLEN],*fn2;
|
char szNSISDir[NSIS_MAX_STRLEN*2],*fn2;
|
||||||
|
int len = sizeof(szNSISDir) - sizeof(PATH_SEPARATOR_STR "Include") - 1;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
GetModuleFileName(NULL,szNSISDir,sizeof(szNSISDir)-sizeof(PATH_SEPARATOR_STR "Include"));
|
GetModuleFileName(NULL,szNSISDir,len);
|
||||||
#else
|
#else
|
||||||
if (argv0[0] == '.' || argv0[0] == PATH_SEPARATOR_C)
|
char *buffer = my_realpath(argv0);
|
||||||
{
|
strncpy(szNSISDir, buffer, len);
|
||||||
getcwd(szNSISDir,sizeof(szNSISDir)-strlen(argv0)-2);
|
szNSISDir[sizeof(szNSISDir)-1] = 0;
|
||||||
if (szNSISDir[strlen(szNSISDir)-1]!=PATH_SEPARATOR_C)
|
my_free_realpath(argv0, buffer);
|
||||||
strcat(szNSISDir,PATH_SEPARATOR_STR);
|
|
||||||
strcat(szNSISDir,argv0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *path = getenv("PATH");
|
|
||||||
if (path)
|
|
||||||
{
|
|
||||||
char *p = path;
|
|
||||||
char *l = path;
|
|
||||||
char *e = path + strlen(path);
|
|
||||||
while (p <= e)
|
|
||||||
{
|
|
||||||
if (*p == ':' || !*p)
|
|
||||||
{
|
|
||||||
*p = 0;
|
|
||||||
strncpy(szNSISDir,l,sizeof(szNSISDir)-strlen(argv0)-2);
|
|
||||||
if (szNSISDir[strlen(szNSISDir)-1]!=PATH_SEPARATOR_C)
|
|
||||||
strcat(szNSISDir,PATH_SEPARATOR_STR);
|
|
||||||
strcat(szNSISDir,argv0);
|
|
||||||
struct stat st;
|
|
||||||
if (!stat(szNSISDir,&st))
|
|
||||||
break;
|
|
||||||
szNSISDir[0]=0;
|
|
||||||
l = ++p;
|
|
||||||
}
|
|
||||||
p = CharNext(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if defined(MAX_PATH) && (NSIS_MAX_STRLEN >= MAX_PATH)
|
|
||||||
const char buf[NSIS_MAX_STRLEN];
|
|
||||||
strcpy(buf, szNSISDir);
|
|
||||||
realpath(buf, szNSISDir);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
fn2=strrchr(szNSISDir,PATH_SEPARATOR_C);
|
fn2=strrchr(szNSISDir,PATH_SEPARATOR_C);
|
||||||
if(fn2!=NULL) *fn2=0;
|
if(fn2!=NULL) *fn2=0;
|
||||||
|
@ -2389,23 +2355,10 @@ int CEXEBuild::write_output(void)
|
||||||
char *p;
|
char *p;
|
||||||
GetFullPathName(build_output_filename,1024,buffer,&p);
|
GetFullPathName(build_output_filename,1024,buffer,&p);
|
||||||
#else
|
#else
|
||||||
# ifdef PATH_MAX
|
char *buffer = my_realpath(build_output_filename);
|
||||||
char buffer[PATH_MAX];
|
|
||||||
# else
|
|
||||||
int path_max = pathconf(build_output_filename, _PC_PATH_MAX);
|
|
||||||
if (path_max <= 0)
|
|
||||||
path_max = 4096;
|
|
||||||
char *buffer = (char *) malloc(path_max);
|
|
||||||
if (!buffer)
|
|
||||||
buffer = build_output_filename;
|
|
||||||
# endif
|
|
||||||
realpath(build_output_filename, buffer);
|
|
||||||
#endif
|
|
||||||
notify(MAKENSIS_NOTIFY_OUTPUT, buffer);
|
notify(MAKENSIS_NOTIFY_OUTPUT, buffer);
|
||||||
INFO_MSG("\nOutput: \"%s\"\n", buffer);
|
INFO_MSG("\nOutput: \"%s\"\n", buffer);
|
||||||
#if !defined(_WIN32) && !defined(PATH_MAX)
|
my_free_realpath(build_output_filename, buffer);
|
||||||
if (buffer != build_output_filename)
|
|
||||||
free(buffer);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
FILE *fp = fopen(build_output_filename,"w+b");
|
FILE *fp = fopen(build_output_filename,"w+b");
|
||||||
|
|
|
@ -389,6 +389,33 @@ int wsprintf(char *s, const char *format, ...) {
|
||||||
va_end(val);
|
va_end(val);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *my_realpath(char *path)
|
||||||
|
{
|
||||||
|
#ifdef PATH_MAX
|
||||||
|
static char buffer[PATH_MAX];
|
||||||
|
#else
|
||||||
|
int path_max = pathconf(path, _PC_PATH_MAX);
|
||||||
|
if (path_max <= 0)
|
||||||
|
path_max = 4096;
|
||||||
|
char *buffer = (char *) malloc(path_max);
|
||||||
|
if (!buffer)
|
||||||
|
return path;
|
||||||
|
#endif
|
||||||
|
if (!realpath(path, buffer))
|
||||||
|
strcpy(buffer, path);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void my_free_realpath(char *path, char *buffer)
|
||||||
|
{
|
||||||
|
#if !defined(_WIN32) && !defined(PATH_MAX)
|
||||||
|
if (buffer != path)
|
||||||
|
free(buffer);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *operator new(size_t size) {
|
void *operator new(size_t size) {
|
||||||
|
|
|
@ -31,6 +31,8 @@ int WCStrLen(const WCHAR* szwStr);
|
||||||
char *CharPrev(const char *s, const char *p);
|
char *CharPrev(const char *s, const char *p);
|
||||||
char *CharNext(const char *s);
|
char *CharNext(const char *s);
|
||||||
int wsprintf(char *s, const char *format, ...);
|
int wsprintf(char *s, const char *format, ...);
|
||||||
|
char *my_realpath(char *path);
|
||||||
|
void my_free_realpath(char *path, char *buffer);
|
||||||
// iconv const inconsistency workaround by Alexandre Oliva
|
// iconv const inconsistency workaround by Alexandre Oliva
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline size_t __iconv_adaptor
|
inline size_t __iconv_adaptor
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue