Hopefully readable now: indent -nut -kr -bl -bli0 -i2 *
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2423 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
e1bc9f0971
commit
0e30afb5d9
16 changed files with 6231 additions and 5689 deletions
|
@ -11,40 +11,40 @@ static int compare_entries(void *av, void *bv);
|
|||
|
||||
indexdata *make_index(void)
|
||||
{
|
||||
indexdata *ret = mknew(indexdata);
|
||||
ret->tags = newtree234(compare_tags);
|
||||
ret->entries = newtree234(compare_entries);
|
||||
return ret;
|
||||
indexdata *ret = mknew(indexdata);
|
||||
ret->tags = newtree234(compare_tags);
|
||||
ret->entries = newtree234(compare_entries);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static indextag *make_indextag(void)
|
||||
{
|
||||
indextag *ret = mknew(indextag);
|
||||
ret->name = NULL;
|
||||
ret->implicit_text = NULL;
|
||||
ret->explicit_texts = NULL;
|
||||
ret->nexplicit = ret->explicit_size = ret->nrefs = 0;
|
||||
ret->refs = NULL;
|
||||
return ret;
|
||||
indextag *ret = mknew(indextag);
|
||||
ret->name = NULL;
|
||||
ret->implicit_text = NULL;
|
||||
ret->explicit_texts = NULL;
|
||||
ret->nexplicit = ret->explicit_size = ret->nrefs = 0;
|
||||
ret->refs = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int compare_tags(void *av, void *bv)
|
||||
{
|
||||
indextag *a = (indextag *) av, *b = (indextag *) bv;
|
||||
return ustricmp(a->name, b->name);
|
||||
indextag *a = (indextag *) av, *b = (indextag *) bv;
|
||||
return ustricmp(a->name, b->name);
|
||||
}
|
||||
|
||||
static int compare_to_find_tag(void *av, void *bv)
|
||||
{
|
||||
wchar_t *a = (wchar_t *) av;
|
||||
indextag *b = (indextag *) bv;
|
||||
return ustricmp(a, b->name);
|
||||
wchar_t *a = (wchar_t *) av;
|
||||
indextag *b = (indextag *) bv;
|
||||
return ustricmp(a, b->name);
|
||||
}
|
||||
|
||||
static int compare_entries(void *av, void *bv)
|
||||
{
|
||||
indexentry *a = (indexentry *) av, *b = (indexentry *) bv;
|
||||
return compare_wordlists(a->text, b->text);
|
||||
indexentry *a = (indexentry *) av, *b = (indexentry *) bv;
|
||||
return compare_wordlists(a->text, b->text);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -52,7 +52,7 @@ static int compare_entries(void *av, void *bv)
|
|||
*/
|
||||
indextag *index_findtag(indexdata * idx, wchar_t * name)
|
||||
{
|
||||
return find234(idx->tags, name, compare_to_find_tag);
|
||||
return find234(idx->tags, name, compare_to_find_tag);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -66,65 +66,72 @@ indextag *index_findtag(indexdata * idx, wchar_t * name)
|
|||
void
|
||||
index_merge(indexdata * idx, int is_explicit, wchar_t * tags, word * text)
|
||||
{
|
||||
indextag *t, *existing;
|
||||
indextag *t, *existing;
|
||||
|
||||
/*
|
||||
* FIXME: want to warn on overlapping source sets.
|
||||
*/
|
||||
for (; *tags; tags = uadv(tags)) {
|
||||
t = make_indextag();
|
||||
t->name = tags;
|
||||
existing = add234(idx->tags, t);
|
||||
if (existing == t) {
|
||||
/*
|
||||
* Duplicate this so we can free it independently.
|
||||
*/
|
||||
t->name = ustrdup(tags);
|
||||
/*
|
||||
* FIXME: want to warn on overlapping source sets.
|
||||
*/
|
||||
for (; *tags; tags = uadv(tags))
|
||||
{
|
||||
t = make_indextag();
|
||||
t->name = tags;
|
||||
existing = add234(idx->tags, t);
|
||||
if (existing == t)
|
||||
{
|
||||
/*
|
||||
* Duplicate this so we can free it independently.
|
||||
*/
|
||||
t->name = ustrdup(tags);
|
||||
|
||||
/*
|
||||
* Every tag has an implicit \IM. So if this tag
|
||||
* doesn't exist and we're explicit, then we should
|
||||
* warn (and drop it, since it won't be referenced).
|
||||
*/
|
||||
if (is_explicit) {
|
||||
error(err_nosuchidxtag, tags);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Every tag has an implicit \IM. So if this tag
|
||||
* doesn't exist and we're explicit, then we should
|
||||
* warn (and drop it, since it won't be referenced).
|
||||
*/
|
||||
if (is_explicit)
|
||||
{
|
||||
error(err_nosuchidxtag, tags);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise, this is a new tag with an implicit \IM.
|
||||
*/
|
||||
t->implicit_text = text;
|
||||
} else {
|
||||
sfree(t);
|
||||
t = existing;
|
||||
if (!is_explicit) {
|
||||
/*
|
||||
* An implicit \IM for a tag that's had an implicit
|
||||
* \IM before. FIXME: we should check the text
|
||||
* against the existing text and warn on
|
||||
* differences. And check the tag for case match
|
||||
* against the existing tag, likewise.
|
||||
*/
|
||||
} else {
|
||||
/*
|
||||
* An explicit \IM added to a valid tag. In
|
||||
* particular, this removes the implicit \IM if
|
||||
* present.
|
||||
*/
|
||||
if (t->implicit_text) {
|
||||
free_word_list(t->implicit_text);
|
||||
t->implicit_text = NULL;
|
||||
}
|
||||
if (t->nexplicit >= t->explicit_size) {
|
||||
t->explicit_size = t->nexplicit + 8;
|
||||
t->explicit_texts = resize(t->explicit_texts,
|
||||
t->explicit_size);
|
||||
}
|
||||
t->explicit_texts[t->nexplicit++] = text;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Otherwise, this is a new tag with an implicit \IM.
|
||||
*/
|
||||
t->implicit_text = text;
|
||||
} else
|
||||
{
|
||||
sfree(t);
|
||||
t = existing;
|
||||
if (!is_explicit)
|
||||
{
|
||||
/*
|
||||
* An implicit \IM for a tag that's had an implicit
|
||||
* \IM before. FIXME: we should check the text
|
||||
* against the existing text and warn on
|
||||
* differences. And check the tag for case match
|
||||
* against the existing tag, likewise.
|
||||
*/
|
||||
} else
|
||||
{
|
||||
/*
|
||||
* An explicit \IM added to a valid tag. In
|
||||
* particular, this removes the implicit \IM if
|
||||
* present.
|
||||
*/
|
||||
if (t->implicit_text)
|
||||
{
|
||||
free_word_list(t->implicit_text);
|
||||
t->implicit_text = NULL;
|
||||
}
|
||||
if (t->nexplicit >= t->explicit_size)
|
||||
{
|
||||
t->explicit_size = t->nexplicit + 8;
|
||||
t->explicit_texts = resize(t->explicit_texts, t->explicit_size);
|
||||
}
|
||||
t->explicit_texts[t->nexplicit++] = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -136,52 +143,59 @@ index_merge(indexdata * idx, int is_explicit, wchar_t * tags, word * text)
|
|||
*/
|
||||
void build_index(indexdata * i)
|
||||
{
|
||||
indextag *t;
|
||||
word **ta;
|
||||
int ti;
|
||||
int j;
|
||||
indextag *t;
|
||||
word **ta;
|
||||
int ti;
|
||||
int j;
|
||||
|
||||
for (ti = 0; (t = (indextag *) index234(i->tags, ti)) != NULL; ti++) {
|
||||
if (t->implicit_text) {
|
||||
t->nrefs = 1;
|
||||
ta = &t->implicit_text;
|
||||
} else {
|
||||
t->nrefs = t->nexplicit;
|
||||
ta = t->explicit_texts;
|
||||
}
|
||||
if (t->nrefs) {
|
||||
t->refs = mknewa(indexentry *, t->nrefs);
|
||||
for (j = 0; j < t->nrefs; j++) {
|
||||
indexentry *ent = mknew(indexentry);
|
||||
ent->text = *ta++;
|
||||
t->refs[j] = add234(i->entries, ent);
|
||||
if (t->refs[j] != ent) /* duplicate */
|
||||
sfree(ent);
|
||||
}
|
||||
}
|
||||
for (ti = 0; (t = (indextag *) index234(i->tags, ti)) != NULL; ti++)
|
||||
{
|
||||
if (t->implicit_text)
|
||||
{
|
||||
t->nrefs = 1;
|
||||
ta = &t->implicit_text;
|
||||
} else
|
||||
{
|
||||
t->nrefs = t->nexplicit;
|
||||
ta = t->explicit_texts;
|
||||
}
|
||||
if (t->nrefs)
|
||||
{
|
||||
t->refs = mknewa(indexentry *, t->nrefs);
|
||||
for (j = 0; j < t->nrefs; j++)
|
||||
{
|
||||
indexentry *ent = mknew(indexentry);
|
||||
ent->text = *ta++;
|
||||
t->refs[j] = add234(i->entries, ent);
|
||||
if (t->refs[j] != ent) /* duplicate */
|
||||
sfree(ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cleanup_index(indexdata * i)
|
||||
{
|
||||
indextag *t;
|
||||
indexentry *ent;
|
||||
int ti;
|
||||
indextag *t;
|
||||
indexentry *ent;
|
||||
int ti;
|
||||
|
||||
for (ti = 0; (t = (indextag *) index234(i->tags, ti)) != NULL; ti++) {
|
||||
sfree(t->name);
|
||||
free_word_list(t->implicit_text);
|
||||
sfree(t->explicit_texts);
|
||||
sfree(t->refs);
|
||||
sfree(t);
|
||||
}
|
||||
freetree234(i->tags);
|
||||
for (ti = 0; (ent = (indexentry *) index234(i->entries, ti)) != NULL;
|
||||
ti++) {
|
||||
sfree(ent);
|
||||
}
|
||||
freetree234(i->entries);
|
||||
sfree(i);
|
||||
for (ti = 0; (t = (indextag *) index234(i->tags, ti)) != NULL; ti++)
|
||||
{
|
||||
sfree(t->name);
|
||||
free_word_list(t->implicit_text);
|
||||
sfree(t->explicit_texts);
|
||||
sfree(t->refs);
|
||||
sfree(t);
|
||||
}
|
||||
freetree234(i->tags);
|
||||
for (ti = 0; (ent = (indexentry *) index234(i->entries, ti)) != NULL;
|
||||
ti++)
|
||||
{
|
||||
sfree(ent);
|
||||
}
|
||||
freetree234(i->entries);
|
||||
sfree(i);
|
||||
}
|
||||
|
||||
static void dbg_prtwordlist(int level, word * w);
|
||||
|
@ -189,57 +203,61 @@ static void dbg_prtmerge(int is_explicit, wchar_t * tag, word * text);
|
|||
|
||||
void index_debug(indexdata * i)
|
||||
{
|
||||
indextag *t;
|
||||
indexentry *y;
|
||||
int ti;
|
||||
int j;
|
||||
indextag *t;
|
||||
indexentry *y;
|
||||
int ti;
|
||||
int j;
|
||||
|
||||
printf("\nINDEX TAGS\n==========\n\n");
|
||||
for (ti = 0; (t = (indextag *) index234(i->tags, ti)) != NULL; ti++) {
|
||||
printf("\n");
|
||||
if (t->implicit_text)
|
||||
dbg_prtmerge(0, t->name, t->implicit_text);
|
||||
for (j = 0; j < t->nexplicit; j++)
|
||||
dbg_prtmerge(1, t->name, t->explicit_texts[j]);
|
||||
}
|
||||
printf("\nINDEX TAGS\n==========\n\n");
|
||||
for (ti = 0; (t = (indextag *) index234(i->tags, ti)) != NULL; ti++)
|
||||
{
|
||||
printf("\n");
|
||||
if (t->implicit_text)
|
||||
dbg_prtmerge(0, t->name, t->implicit_text);
|
||||
for (j = 0; j < t->nexplicit; j++)
|
||||
dbg_prtmerge(1, t->name, t->explicit_texts[j]);
|
||||
}
|
||||
|
||||
printf("\nINDEX ENTRIES\n=============\n\n");
|
||||
for (ti = 0; (y = (indexentry *) index234(i->entries, ti)) != NULL;
|
||||
ti++) {
|
||||
printf("\n");
|
||||
printf("{\n");
|
||||
dbg_prtwordlist(1, y->text);
|
||||
printf("}\n");
|
||||
}
|
||||
printf("\nINDEX ENTRIES\n=============\n\n");
|
||||
for (ti = 0; (y = (indexentry *) index234(i->entries, ti)) != NULL; ti++)
|
||||
{
|
||||
printf("\n");
|
||||
printf("{\n");
|
||||
dbg_prtwordlist(1, y->text);
|
||||
printf("}\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void dbg_prtmerge(int is_explicit, wchar_t * tag, word * text)
|
||||
{
|
||||
printf("\\IM: %splicit: \"", is_explicit ? "ex" : "im");
|
||||
for (; *tag; tag++)
|
||||
putchar(*tag);
|
||||
printf("\" {\n");
|
||||
dbg_prtwordlist(1, text);
|
||||
printf("}\n");
|
||||
printf("\\IM: %splicit: \"", is_explicit ? "ex" : "im");
|
||||
for (; *tag; tag++)
|
||||
putchar(*tag);
|
||||
printf("\" {\n");
|
||||
dbg_prtwordlist(1, text);
|
||||
printf("}\n");
|
||||
}
|
||||
|
||||
static void dbg_prtwordlist(int level, word * w)
|
||||
{
|
||||
for (; w; w = w->next) {
|
||||
wchar_t *wp;
|
||||
printf("%*sword %d ", level * 4, "", w->type);
|
||||
if (w->text) {
|
||||
printf("\"");
|
||||
for (wp = w->text; *wp; wp++)
|
||||
putchar(*wp);
|
||||
printf("\"");
|
||||
} else
|
||||
printf("(no text)");
|
||||
if (w->alt) {
|
||||
printf(" alt = {\n");
|
||||
dbg_prtwordlist(level + 1, w->alt);
|
||||
printf("%*s}", level * 4, "");
|
||||
}
|
||||
printf("\n");
|
||||
for (; w; w = w->next)
|
||||
{
|
||||
wchar_t *wp;
|
||||
printf("%*sword %d ", level * 4, "", w->type);
|
||||
if (w->text)
|
||||
{
|
||||
printf("\"");
|
||||
for (wp = w->text; *wp; wp++)
|
||||
putchar(*wp);
|
||||
printf("\"");
|
||||
} else
|
||||
printf("(no text)");
|
||||
if (w->alt)
|
||||
{
|
||||
printf(" alt = {\n");
|
||||
dbg_prtwordlist(level + 1, w->alt);
|
||||
printf("%*s}", level * 4, "");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue