a few less #ifdef's
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5955 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
49276c77c7
commit
501dc3c699
3 changed files with 26 additions and 47 deletions
|
@ -1166,13 +1166,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
case TOK_P_DELFILE:
|
case TOK_P_DELFILE:
|
||||||
{
|
{
|
||||||
char *file = line.gettoken_str(1);
|
char *file = line.gettoken_str(1);
|
||||||
#ifndef _WIN32
|
PATH_CONVERT(file);
|
||||||
file = my_convert(file);
|
|
||||||
#endif
|
|
||||||
int result = unlink(file);
|
int result = unlink(file);
|
||||||
#ifndef _WIN32
|
|
||||||
my_convert_free(file);
|
|
||||||
#endif
|
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
ERROR_MSG("!delfile: \"%s\" couldn't be deleted.\n", line.gettoken_str(1));
|
ERROR_MSG("!delfile: \"%s\" couldn't be deleted.\n", line.gettoken_str(1));
|
||||||
return PS_ERROR;
|
return PS_ERROR;
|
||||||
|
@ -2911,9 +2906,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int ret=sane_system(exec);
|
int ret=sane_system(exec);
|
||||||
#else
|
#else
|
||||||
char *execfixed = my_convert(exec);
|
PATH_CONVERT(exec);
|
||||||
int ret=system(execfixed);
|
int ret=system(exec);
|
||||||
my_convert_free(execfixed);
|
|
||||||
#endif
|
#endif
|
||||||
if (comp == 0 && ret < cmpv);
|
if (comp == 0 && ret < cmpv);
|
||||||
else if (comp == 1 && ret > cmpv);
|
else if (comp == 1 && ret > cmpv);
|
||||||
|
@ -2948,16 +2942,11 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
SCRIPT_MSG("!execute: \"%s\"\n",exec);
|
SCRIPT_MSG("!execute: \"%s\"\n",exec);
|
||||||
}
|
}
|
||||||
case TOK_P_ADDINCLUDEDIR:
|
case TOK_P_ADDINCLUDEDIR:
|
||||||
#ifdef _WIN32
|
|
||||||
include_dirs.add(line.gettoken_str(1),0);
|
|
||||||
#else
|
|
||||||
{
|
{
|
||||||
char *f = line.gettoken_str(1);
|
char *f = line.gettoken_str(1);
|
||||||
char *fc = my_convert(f);
|
PATH_CONVERT(f);
|
||||||
include_dirs.add(fc,0);
|
include_dirs.add(f,0);
|
||||||
my_convert_free(fc);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
case TOK_P_INCLUDE:
|
case TOK_P_INCLUDE:
|
||||||
{
|
{
|
||||||
|
@ -2975,11 +2964,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
PRINTHELP();
|
PRINTHELP();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
char *fc = f;
|
|
||||||
#else
|
|
||||||
char *fc = my_convert(f);
|
char *fc = my_convert(f);
|
||||||
#endif
|
|
||||||
int included = 0;
|
int included = 0;
|
||||||
|
|
||||||
string dir = get_dir_name(fc);
|
string dir = get_dir_name(fc);
|
||||||
|
@ -2991,9 +2976,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
basedir = "";
|
basedir = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
my_convert_free(fc);
|
my_convert_free(fc);
|
||||||
#endif
|
|
||||||
|
|
||||||
// search working directory
|
// search working directory
|
||||||
boost::scoped_ptr<dir_reader> dr( new_dir_reader() );
|
boost::scoped_ptr<dir_reader> dr( new_dir_reader() );
|
||||||
|
@ -4550,13 +4533,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
}
|
}
|
||||||
|
|
||||||
int tf=0;
|
int tf=0;
|
||||||
#ifdef _WIN32
|
char *fn = line.gettoken_str(a);
|
||||||
int v=do_add_file(line.gettoken_str(a), attrib, 0, &tf, on);
|
PATH_CONVERT(fn);
|
||||||
#else
|
|
||||||
char *fn = my_convert(line.gettoken_str(a));
|
|
||||||
int v=do_add_file(fn, attrib, 0, &tf, on);
|
int v=do_add_file(fn, attrib, 0, &tf, on);
|
||||||
my_convert_free(fn);
|
|
||||||
#endif
|
|
||||||
if (v != PS_OK) return v;
|
if (v != PS_OK) return v;
|
||||||
if (tf > 1) PRINTHELP()
|
if (tf > 1) PRINTHELP()
|
||||||
if (!tf)
|
if (!tf)
|
||||||
|
@ -4608,13 +4587,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
t=buf;
|
t=buf;
|
||||||
}
|
}
|
||||||
int tf=0;
|
int tf=0;
|
||||||
#ifdef _WIN32
|
|
||||||
int v=do_add_file(t, attrib, rec, &tf, NULL, which_token == TOK_FILE, NULL, excluded);
|
|
||||||
#else
|
|
||||||
char *fn = my_convert(t);
|
char *fn = my_convert(t);
|
||||||
int v=do_add_file(fn, attrib, rec, &tf, NULL, which_token == TOK_FILE, NULL, excluded);
|
int v=do_add_file(fn, attrib, rec, &tf, NULL, which_token == TOK_FILE, NULL, excluded);
|
||||||
my_convert_free(fn);
|
my_convert_free(fn);
|
||||||
#endif
|
|
||||||
if (v != PS_OK) return v;
|
if (v != PS_OK) return v;
|
||||||
if (!tf)
|
if (!tf)
|
||||||
{
|
{
|
||||||
|
@ -5836,13 +5811,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
if (line.getnumtokens() == 2)
|
if (line.getnumtokens() == 2)
|
||||||
{
|
{
|
||||||
SCRIPT_MSG("PluginDir: \"%s\"\n",line.gettoken_str(1));
|
SCRIPT_MSG("PluginDir: \"%s\"\n",line.gettoken_str(1));
|
||||||
#ifdef _WIN32
|
char *path = line.gettoken_str(1);
|
||||||
m_plugins.FindCommands(line.gettoken_str(1), display_info?true:false);
|
PATH_CONVERT(path);
|
||||||
#else
|
m_plugins.FindCommands(path, display_info?true:false);
|
||||||
char *converted_path = my_convert(line.gettoken_str(1));
|
|
||||||
m_plugins.FindCommands(converted_path, display_info?true:false);
|
|
||||||
my_convert_free(converted_path);
|
|
||||||
#endif
|
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,19 +328,15 @@ void my_convert_free(char *converted_path)
|
||||||
|
|
||||||
int my_open(const char *pathname, int flags)
|
int my_open(const char *pathname, int flags)
|
||||||
{
|
{
|
||||||
char *converted_pathname = my_convert(pathname);
|
PATH_CONVERT(pathname);
|
||||||
|
int result = open(pathname, flags);
|
||||||
int result = open(converted_pathname, flags);
|
|
||||||
my_convert_free(converted_pathname);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *my_fopen(const char *path, const char *mode)
|
FILE *my_fopen(const char *path, const char *mode)
|
||||||
{
|
{
|
||||||
char *converted_path = my_convert(path);
|
PATH_CONVERT(path);
|
||||||
|
FILE *result = fopen(path, mode);
|
||||||
FILE *result = fopen(converted_path, mode);
|
|
||||||
my_convert_free(converted_path);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif//!_WIN32
|
#endif//!_WIN32
|
||||||
|
|
|
@ -74,8 +74,12 @@ FILE *my_fopen(const char *path, const char *mode);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#define my_convert(x) (x)
|
||||||
|
#define my_convert_free(x)
|
||||||
|
|
||||||
#define FOPEN(a, b) fopen(a, b)
|
#define FOPEN(a, b) fopen(a, b)
|
||||||
#define OPEN(a, b) open(a, b)
|
#define OPEN(a, b) open(a, b)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// round a value up to be a multiple of 512
|
// round a value up to be a multiple of 512
|
||||||
|
@ -142,5 +146,13 @@ RM_DEFINE_FREEFUNC(close);
|
||||||
RM_DEFINE_FREEFUNC(CloseHandle);
|
RM_DEFINE_FREEFUNC(CloseHandle);
|
||||||
RM_DEFINE_FREEFUNC(fclose);
|
RM_DEFINE_FREEFUNC(fclose);
|
||||||
RM_DEFINE_FREEFUNC(free);
|
RM_DEFINE_FREEFUNC(free);
|
||||||
|
RM_DEFINE_FREEFUNC(my_convert_free);
|
||||||
|
|
||||||
|
// Auto path conversion
|
||||||
|
#ifndef _WIN32
|
||||||
|
# define PATH_CONVERT(x) x = my_convert(x); MANAGE_WITH(x, my_convert_free);
|
||||||
|
#else
|
||||||
|
# define PATH_CONVERT(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //_UTIL_H_
|
#endif //_UTIL_H_
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue