Refactored preprocessor instructions to separate source file
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6855 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
7ecff5e1c0
commit
17d5e5003f
14 changed files with 1451 additions and 1415 deletions
|
@ -36,6 +36,7 @@ LicenseText "A test text, make sure it's all there"
|
|||
LicenseData "bigtest.nsi"
|
||||
|
||||
RequestExecutionLevel admin
|
||||
ManifestSupportedOS all
|
||||
|
||||
;--------------------------------
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@ class CMatchFinder:
|
|||
UInt32 _matchMaxLen;
|
||||
CIndex *_hash;
|
||||
CIndex *_son;
|
||||
#ifdef HASH_ARRAY_2
|
||||
UInt32 _hashMask;
|
||||
#endif
|
||||
UInt32 _cutValue;
|
||||
UInt32 _hashSizeSum;
|
||||
|
||||
|
|
|
@ -1032,7 +1032,11 @@ typedef struct tagVS_FIXEDFILEINFO {
|
|||
#endif
|
||||
|
||||
|
||||
#if defined(__clang__) && defined(__cplusplus) && __cplusplus < 201103L
|
||||
#define NSIS_CXX_THROWSPEC(throwspec) throw(throwspec) // Use exception specifications to avoid operator new missing-exception-spec warning
|
||||
#else
|
||||
#define NSIS_CXX_THROWSPEC(ignoredthrowspec) // Ignore c++ exception specifications
|
||||
#endif
|
||||
#define BUGBUG64TRUNCATE(cast,xpr) ( (cast) (xpr) )
|
||||
|
||||
/*
|
||||
|
|
|
@ -20,6 +20,7 @@ makensis_files = Split("""
|
|||
ResourceEditor.cpp
|
||||
ResourceVersionInfo.cpp
|
||||
script.cpp
|
||||
scriptpp.cpp
|
||||
ShConstants.cpp
|
||||
strlist.cpp
|
||||
tokens.cpp
|
||||
|
|
|
@ -3419,7 +3419,7 @@ int CEXEBuild::parse_pragma(LineParser &line)
|
|||
bool valid = f.OpenFileForReading(line.gettoken_str(2));
|
||||
valid = valid && 12 == f.ReadOctets(&chm, 12);
|
||||
valid = valid && FIX_ENDIAN_INT32(chm.Sig) == 0x46535449 && (FIX_ENDIAN_INT32(chm.Ver)|1) == 3; // 'ITSF' v2..3
|
||||
return valid ? rvSucc : (ERROR_MSG(_T("Invalid format\n")), PS_ERROR);
|
||||
return valid ? rvSucc : (ERROR_MSG(_T("Error: Invalid format\n")), PS_ERROR);
|
||||
}
|
||||
|
||||
if (line.gettoken_enum(1, _T("warning\0")) == -1)
|
||||
|
|
|
@ -175,26 +175,13 @@ class CEXEBuild {
|
|||
MAX_LINELENGTH = 16384, // NSI/NSH line limit, in TCHARs (including \0)
|
||||
MAX_MACRORECURSION = 50
|
||||
};
|
||||
static const TCHAR* get_commandlinecode_filename() { return _T("<command line>"); }
|
||||
|
||||
void warning(DIAGCODE dc, const TCHAR *s, ...); // to add a warning to the compiler's warning list.
|
||||
void warning_fl(DIAGCODE dc, const TCHAR *s, ...); // warning with file name and line number
|
||||
void ERROR_MSG(const TCHAR *s, ...) const;
|
||||
void SCRIPT_MSG(const TCHAR *s, ...) const;
|
||||
void INFO_MSG(const TCHAR *s, ...) const;
|
||||
class DiagState {
|
||||
public:
|
||||
DiagState() : m_pStack(0) { assert(DIAGCODE_INTERNAL_LAST <= 0xffff); }
|
||||
~DiagState() { delete m_pStack; }
|
||||
void Enable(DIAGCODE n) { m_Disabled.erase(static_cast<unsigned short>(n)); }
|
||||
void Disable(DIAGCODE n) { m_Disabled.insert(static_cast<unsigned short>(n)); }
|
||||
bool IsDisabled(DIAGCODE n) { return m_Disabled.find(static_cast<unsigned short>(n)) != m_Disabled.end(); }
|
||||
void Push();
|
||||
bool Pop();
|
||||
static bool IsValidCode(unsigned int n) { return n >= DIAGCODE_INTERNAL_FIRST && n <= DIAGCODE_INTERNAL_LAST; }
|
||||
protected:
|
||||
DiagState *m_pStack;
|
||||
std::set<unsigned short> m_Disabled;
|
||||
} diagstate;
|
||||
|
||||
typedef enum {
|
||||
TARGETFIRST,
|
||||
|
@ -326,7 +313,26 @@ class CEXEBuild {
|
|||
bool inside_comment;
|
||||
int multiple_entries_instruction; // 1 (true) or 0 (false)
|
||||
|
||||
int pp_macro(LineParser&line);
|
||||
int pp_macroundef(LineParser&line);
|
||||
int pp_insertmacro(LineParser&line);
|
||||
int pp_tempfile(LineParser&line);
|
||||
int pp_delfile(LineParser&line);
|
||||
int pp_appendfile(LineParser&line);
|
||||
int pp_getdllversion(LineParser&line);
|
||||
int pp_searchreplacestring(LineParser&line);
|
||||
int pp_searchparsestring(LineParser&line);
|
||||
DefineList *searchParseString(const TCHAR *source_string, LineParser&line, int parmOffs, bool ignCase, bool noErrors, UINT*failParam = 0);
|
||||
int pp_verbose(LineParser&line);
|
||||
int pp_define(LineParser&line);
|
||||
int pp_undef(LineParser&line);
|
||||
int pp_packhdr(LineParser&line);
|
||||
int pp_finalize(LineParser&line);
|
||||
int pp_execute(int which_token, LineParser&line);
|
||||
int pp_addincludedir(LineParser&line);
|
||||
int pp_include(LineParser&line);
|
||||
int pp_cd(LineParser&line);
|
||||
int pp_pragma(LineParser&line);
|
||||
|
||||
// build.cpp functions used mostly by script.cpp
|
||||
int set_target_architecture_data();
|
||||
|
@ -386,9 +392,24 @@ class CEXEBuild {
|
|||
int resolve_instruction(const TCHAR *fn, const TCHAR *str, entry *w, int offs, int start, int end);
|
||||
|
||||
int resolve_coderefs(const TCHAR *str);
|
||||
int uninstall_generate();
|
||||
|
||||
void print_warnings();
|
||||
void warninghelper(DIAGCODE dc, bool fl, const TCHAR *fmt, va_list args);
|
||||
int uninstall_generate();
|
||||
class DiagState {
|
||||
public:
|
||||
DiagState() : m_pStack(0) { assert(DIAGCODE_INTERNAL_LAST <= 0xffff); }
|
||||
~DiagState() { delete m_pStack; }
|
||||
void Enable(DIAGCODE n) { m_Disabled.erase(static_cast<unsigned short>(n)); }
|
||||
void Disable(DIAGCODE n) { m_Disabled.insert(static_cast<unsigned short>(n)); }
|
||||
bool IsDisabled(DIAGCODE n) { return m_Disabled.find(static_cast<unsigned short>(n)) != m_Disabled.end(); }
|
||||
void Push();
|
||||
bool Pop();
|
||||
static bool IsValidCode(unsigned int n) { return n >= DIAGCODE_INTERNAL_FIRST && n <= DIAGCODE_INTERNAL_LAST; }
|
||||
protected:
|
||||
DiagState *m_pStack;
|
||||
std::set<unsigned short> m_Disabled;
|
||||
} diagstate;
|
||||
|
||||
/** Are we defining an uninstall version of the code?
|
||||
* @param un Use like a boolean to define whether in uninstall mode.
|
||||
|
|
|
@ -138,7 +138,7 @@ double LineParser::gettoken_number(int token, int *success/*=0*/) const
|
|||
{
|
||||
const TCHAR*str=gettoken_str(token);
|
||||
if (_T('-') == *str || _T('+') == *str) ++str;
|
||||
bool forceint = false;
|
||||
unsigned int forceint = false;
|
||||
if (_T('0') == str[0])
|
||||
{
|
||||
if (_T('x') == (str[1]|32)) ++forceint;
|
||||
|
|
|
@ -543,7 +543,7 @@ static inline int makensismain(int argc, TCHAR **argv)
|
|||
}
|
||||
else if (S7IsChEqualI('x',swname[0]) && swname[1])
|
||||
{
|
||||
if (build.process_oneline(swname+1,_T("<command line>"),argpos+1) != PS_OK)
|
||||
if (build.process_oneline(swname+1,build.get_commandlinecode_filename(),argpos+1) != PS_OK)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ static inline int makensismain(int argc, TCHAR **argv)
|
|||
noconfig=true;
|
||||
tstring main_conf;
|
||||
TCHAR* env_var = _tgetenv(_T("NSISCONFDIR"));
|
||||
if(env_var == NULL)
|
||||
if (env_var == NULL)
|
||||
#ifndef NSIS_CONFIG_CONST_DATA_PATH
|
||||
main_conf = get_dir_name(get_executable_dir(argv[0]));
|
||||
#else
|
||||
|
|
|
@ -47,10 +47,12 @@ static const struct { const TCHAR *name, *guidstr; } g_soslmap[] = {
|
|||
{ _T("Win10"), _T("{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}") } //blogs.msdn.com/b/chuckw/archive/2013/09/10/manifest-madness.aspx
|
||||
};
|
||||
|
||||
void SupportedOSList::addall()
|
||||
bool SupportedOSList::addall()
|
||||
{
|
||||
for (UINT i = 0; i < COUNTOF(g_soslmap); ++i)
|
||||
append(g_soslmap[i].name);
|
||||
if (!append(g_soslmap[i].name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SupportedOSList::append(const TCHAR* osid)
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace manifest
|
|||
if (-1 == pos) return 0;
|
||||
return m_list.get() + pos;
|
||||
}
|
||||
void addall();
|
||||
bool addall();
|
||||
void deleteall()
|
||||
{
|
||||
m_list.deleteall();
|
||||
|
|
1533
Source/script.cpp
1533
Source/script.cpp
File diff suppressed because it is too large
Load diff
1233
Source/scriptpp.cpp
Normal file
1233
Source/scriptpp.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -70,7 +70,7 @@ size_t my_strncpy(TCHAR*Dest, const TCHAR*Src, size_t cchMax)
|
|||
// Dest and Src must be valid, Dest is always \0 terminated.
|
||||
// Returns number of TCHARs copied to Dest (not counting \0); min(strlen(Src),cchMax-1).
|
||||
size_t cch = 0;
|
||||
if (cchMax) for (TCHAR c; --cchMax;) if (!(c = Src[cch])) break; else Dest[cch++] = c;
|
||||
if (cchMax) for (TCHAR c; --cchMax;) { if (!(c = Src[cch])) break; Dest[cch++] = c; }
|
||||
Dest[cch] = _T('\0');
|
||||
return cch;
|
||||
}
|
||||
|
@ -159,20 +159,20 @@ TCHAR *CharPrev(const TCHAR *s, const TCHAR *p) {
|
|||
break;
|
||||
s = n;
|
||||
}
|
||||
return (TCHAR *) s;
|
||||
return const_cast<TCHAR*>(s);
|
||||
}
|
||||
|
||||
char *CharNextA(const char *s) {
|
||||
int l = 0;
|
||||
if (s && *s)
|
||||
l = max(1, mblen(s, MB_CUR_MAX));
|
||||
return (char *) s + l;
|
||||
return const_cast<char*>(s + l);
|
||||
}
|
||||
|
||||
wchar_t *CharNextW(const wchar_t *s) {
|
||||
if (sizeof(*s)==2 && IsLeadSurrogateUTF16(*s)) (wchar_t*) ++s; //BUGBUG: This assumes that 16bit wchar_t == UTF16
|
||||
// else if(...) BUGBUG: Is this the best we can do? What about combining characters/diacritics etc?
|
||||
return (wchar_t*) s + 1;
|
||||
if (sizeof(*s) == 2 && IsLeadSurrogateUTF16(*s)) ++s; //BUGBUG: This assumes that 16bit wchar_t == UTF16
|
||||
// else if (...) BUGBUG: Is this the best we can do? What about combining characters/diacritics etc?
|
||||
return const_cast<wchar_t*>(s + 1);
|
||||
}
|
||||
|
||||
char *CharNextExA(WORD codepage, const char *s, int flags) {
|
||||
|
@ -182,7 +182,7 @@ char *CharNextExA(WORD codepage, const char *s, int flags) {
|
|||
int len = mblen(s, strlen(s));
|
||||
if (len > 0) np = s + len; else np = s + 1;
|
||||
setlocale(LC_CTYPE, orglocct);
|
||||
return (char *) np;
|
||||
return const_cast<char*>(np);
|
||||
}
|
||||
|
||||
int wsprintf(TCHAR *s, const TCHAR *format, ...) {
|
||||
|
@ -554,7 +554,7 @@ void PathConvertWinToPosix(TCHAR*p)
|
|||
TCHAR *my_convert(const TCHAR *path)
|
||||
{
|
||||
TCHAR *converted_path = _tcsdup(path);
|
||||
if(!converted_path)
|
||||
if (!converted_path)
|
||||
{
|
||||
MY_ERROR_MSG(_T("Error: could not allocate memory in my_convert()\n"));
|
||||
return 0;
|
||||
|
@ -678,7 +678,7 @@ tstring get_executable_path(const TCHAR* argv0) {
|
|||
return tstring(CtoTString(temp_buf));
|
||||
#else /* Linux/BSD/POSIX/etc */
|
||||
const TCHAR *envpath = _tgetenv(_T("_"));
|
||||
if( envpath != NULL )
|
||||
if (envpath)
|
||||
return get_full_path(envpath);
|
||||
else {
|
||||
char *path = NULL, *pathtmp;
|
||||
|
@ -686,17 +686,17 @@ tstring get_executable_path(const TCHAR* argv0) {
|
|||
int nchars;
|
||||
while(1){
|
||||
pathtmp = (char*)realloc(path,len+1);
|
||||
if( pathtmp == NULL ){
|
||||
if (pathtmp == NULL) {
|
||||
free(path);
|
||||
return get_full_path(argv0);
|
||||
}
|
||||
path = pathtmp;
|
||||
nchars = readlink("/proc/self/exe", path, len);
|
||||
if( nchars == -1 ){
|
||||
if (nchars == -1) {
|
||||
free(path);
|
||||
return get_full_path(argv0);
|
||||
}
|
||||
if( nchars < (int) len ){
|
||||
if (nchars < (int) len) {
|
||||
path[nchars] = '\0';
|
||||
tstring result;
|
||||
result = CtoTString(path);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
extern double my_wtof(const wchar_t *str);
|
||||
extern size_t my_strncpy(TCHAR*Dest, const TCHAR*Src, size_t cchMax);
|
||||
static bool strtrycpy(TCHAR*Dest, const TCHAR*Src, size_t cchCap) { size_t c = my_strncpy(Dest, Src, cchCap); return c < cchCap && !Src[c]; }
|
||||
size_t my_strftime(TCHAR *s, size_t max, const TCHAR *fmt, const struct tm *tm);
|
||||
|
||||
// Adds the bitmap in filename using resource editor re as id id.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue