mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 05:49:22 +02:00
gencat/pdf.c: key index entries by the tree node, to distinguish duplicates
Before, duplicate names in the tree always pointed to the same page. Now they point to the respective locations. Note that this does not affect handling of duplicate names in libraries, where still only one "wins" while the other is completely ignored.
This commit is contained in:
parent
605585ffdb
commit
463e8dcac4
33
gencat/pdf.c
33
gencat/pdf.c
@ -89,7 +89,13 @@ static void ps_string(FILE *file, const char *s)
|
|||||||
/* ----- Alphabetic index -------------------------------------------------- */
|
/* ----- Alphabetic index -------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
static void collect_names(const struct node *node, const char ***idx, int *n)
|
struct index {
|
||||||
|
const char *s;
|
||||||
|
const struct node *node;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void collect_names(const struct node *node, struct index **idx, int *n)
|
||||||
{
|
{
|
||||||
const struct name *name;
|
const struct name *name;
|
||||||
|
|
||||||
@ -99,10 +105,11 @@ static void collect_names(const struct node *node, const char ***idx, int *n)
|
|||||||
else {
|
else {
|
||||||
for (name = node->e->names; name; name = name->next) {
|
for (name = node->e->names; name; name = name->next) {
|
||||||
(*n)++;
|
(*n)++;
|
||||||
*idx = realloc(*idx, *n*sizeof(char *));
|
*idx = realloc(*idx, *n*sizeof(struct entry));
|
||||||
if (!*idx)
|
if (!*idx)
|
||||||
abort();
|
abort();
|
||||||
(*idx)[*n-1] = name->s;
|
(*idx)[*n-1].s = name->s;
|
||||||
|
(*idx)[*n-1].node = node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node = node->next;
|
node = node->next;
|
||||||
@ -112,18 +119,22 @@ static void collect_names(const struct node *node, const char ***idx, int *n)
|
|||||||
|
|
||||||
static int comp(const void *a, const void *b)
|
static int comp(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
return strcmp(*(const char **) a, *(const char **) b);
|
const struct index *ai = a;
|
||||||
|
const struct index *bi = b;
|
||||||
|
|
||||||
|
return strcmp(ai->s, bi->s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void make_index(FILE *file, const struct node *node)
|
static void make_index(FILE *file, const struct node *node)
|
||||||
{
|
{
|
||||||
const char **idx = NULL, **p;
|
struct index *idx = NULL;
|
||||||
|
const struct index *p;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int line = 0, col = 0;
|
int line = 0, col = 0;
|
||||||
|
|
||||||
collect_names(node, &idx, &n);
|
collect_names(node, &idx, &n);
|
||||||
qsort(idx, n, sizeof(char *), comp);
|
qsort(idx, n, sizeof(struct index), comp);
|
||||||
|
|
||||||
fprintf(file, "[ /Title (Index) /Count 0 /OUT pdfmark\n");
|
fprintf(file, "[ /Title (Index) /Count 0 /OUT pdfmark\n");
|
||||||
|
|
||||||
@ -147,15 +158,16 @@ static void make_index(FILE *file, const struct node *node)
|
|||||||
format.index.y+line*format.index_line_skip);
|
format.index.y+line*format.index_line_skip);
|
||||||
|
|
||||||
fprintf(file, "[ /Rect [ ");
|
fprintf(file, "[ /Rect [ ");
|
||||||
ps_string(file, *p);
|
ps_string(file, p->s);
|
||||||
fprintf(file, " false charpath flattenpath pathbbox ]\n");
|
fprintf(file, " false charpath flattenpath pathbbox ]\n");
|
||||||
fprintf(file, " /Subtype /Link\n");
|
fprintf(file, " /Subtype /Link\n");
|
||||||
fprintf(file, " /Border [ 0 0 0 ]\n");
|
fprintf(file, " /Border [ 0 0 0 ]\n");
|
||||||
fprintf(file, " /Action << /Subtype /GoTo /Dest /%p >>\n", *p);
|
fprintf(file, " /Action << /Subtype /GoTo /Dest /%p%p >>\n",
|
||||||
|
p->node, p->s);
|
||||||
fprintf(file, " /ANN pdfmark\n");
|
fprintf(file, " /ANN pdfmark\n");
|
||||||
|
|
||||||
fprintf(file, "moveto ");
|
fprintf(file, "moveto ");
|
||||||
ps_string(file, *p);
|
ps_string(file, p->s);
|
||||||
fprintf(file, " show\n");
|
fprintf(file, " show\n");
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
@ -206,7 +218,8 @@ static void make_title(FILE *file, const struct node *node, int unit)
|
|||||||
ps_string(file, name->s);
|
ps_string(file, name->s);
|
||||||
fprintf(file, " show\n");
|
fprintf(file, " show\n");
|
||||||
if (!unit)
|
if (!unit)
|
||||||
fprintf(file, "[ /Dest /%p /DEST pdfmark\n", name->s);
|
fprintf(file, "[ /Dest /%p%p /DEST pdfmark\n",
|
||||||
|
node, name->s);
|
||||||
}
|
}
|
||||||
fprintf(file, "0 setgray\n");
|
fprintf(file, "0 setgray\n");
|
||||||
if (node->e->units > 1)
|
if (node->e->units > 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user