@@ -4126,23 +4126,37 @@ parse_doc(tree_t *t, /* I - Tree to parse */
4126
4126
}
4127
4127
else if (t->markup == MARKUP_FILE)
4128
4128
{
4129
- /*
4130
- * Add a file link...
4131
- */
4129
+ // Add file links, stripping any trailing HTTP GET parameters...
4130
+ uchar newname[256 ], // New filename
4131
+ *sep; // "?" separator in links
4132
+ int linkpage; // Link page
4133
+
4134
+ // Figure out what page the file will actually start on...
4135
+ linkpage = *page;
4136
+
4137
+ if ((chapter > 0 && OutputType == OUTPUT_BOOK) ||
4138
+ ((linkpage > 0 || *y < *top) && OutputType == OUTPUT_WEBPAGES))
4139
+ {
4140
+ if (*y < *top)
4141
+ linkpage ++;
4132
4142
4133
- uchar newname[256 ], /* New filename */
4134
- *sep; /* "?" separator in links */
4143
+ if (PageDuplex && (linkpage & 1 ))
4144
+ linkpage ++;
4145
+ }
4135
4146
4147
+ // Base filename link...
4148
+ strlcpy ((char *)newname, (char *)htmlGetVariable (t, (uchar *)" _HD_FILENAME" ), sizeof (newname));
4149
+ if ((sep = (uchar *)strchr ((char *)newname, ' ?' )) != NULL )
4150
+ *sep = ' \0 ' ;
4136
4151
4137
- // Strip any trailing HTTP GET data stuff...
4138
- strlcpy ((char *)newname, (char *)htmlGetVariable (t, (uchar *)" _HD_FILENAME" ),
4139
- sizeof (newname));
4152
+ add_link (NULL , newname, linkpage, (int )*top);
4140
4153
4154
+ // Relative filename link...
4155
+ strlcpy ((char *)newname, (char *)htmlGetVariable (t, (uchar *)" _HD_URL" ), sizeof (newname));
4141
4156
if ((sep = (uchar *)strchr ((char *)newname, ' ?' )) != NULL )
4142
4157
*sep = ' \0 ' ;
4143
4158
4144
- // Add the link
4145
- add_link (NULL , newname, *page, (int )*y);
4159
+ add_link (NULL , newname, linkpage, (int )*top);
4146
4160
}
4147
4161
4148
4162
if (chapter == 0 && !title_page)
0 commit comments