Special section of data for user vars, whitch allow compiler to assign the right size and no code needed in exehead for mem allocs. Warnings for unreferenced user vars. (758773) Error, if temp file not available, now directory is created if not exist.

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2673 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
ramon18 2003-06-23 22:40:11 +00:00
parent 2077919dc5
commit 054db45f63
12 changed files with 227 additions and 105 deletions

View file

@ -7,19 +7,84 @@
#include "Lang.h"
class UserVarsStringList : public LangStringList
struct uservarstring {
int name;
int index;
int pos;
int reference;
};
class UserVarsStringList : public SortedStringListND<struct uservarstring>
{
public:
UserVarsStringList()
{
index = 0;
}
~UserVarsStringList() { }
int add(const char *name, int ref_count = 0 )
{
int pos=SortedStringListND<struct uservarstring>::add(name);
if (pos == -1) return -1;
((struct uservarstring*)gr.get())[pos].index = index;
((struct uservarstring*)gr.get())[pos].pos = pos;
((struct uservarstring*)gr.get())[pos].reference = ref_count;
int temp = index;
index++;
return temp;
}
int get(char *name, size_t n_chars = -1)
{
int v=SortedStringListND<struct langstring>::find(name, n_chars);
int v=SortedStringListND<struct uservarstring>::find(name, n_chars);
if (v==-1) return -1;
return (((struct langstring*)gr.get())[v].index);
return (((struct uservarstring*)gr.get())[v].index);
}
int getnum()
{
return index;
}
int get_reference(int idx)
{
int pos=get_internal_idx(idx);
if (pos==-1) return -1;
return (((struct uservarstring*)gr.get())[pos].reference);
}
int inc_reference(int idx)
{
int pos=get_internal_idx(idx);
((struct uservarstring*)gr.get())[pos].reference++;
return (((struct uservarstring*)gr.get())[pos].reference)-1;
}
char *idx2name(int idx)
{
int pos=get_internal_idx(idx);
if (pos==-1) return NULL;
struct uservarstring *data=(struct uservarstring *)gr.get();
return ((char*)strings.get() + data[pos].name);
}
private:
int index;
int get_internal_idx(int idx)
{
struct uservarstring *data=(struct uservarstring *)gr.get();
for (int i = 0; i < index; i++)
{
if (data[i].index == idx)
{
return i;
}
}
return -1;
}
};
#endif //NSIS_SUPPORT_NAMED_USERVARS