--- src/print.c.orig Sun Jun 19 18:20:28 2005
+++ src/print.c Sun Jun 19 19:39:45 2005
@@ -2917,7 +2917,7 @@
void write_toplevel_indices(int amountmsgs)
{
- int i, j, newfile;
+ int i, j, newfile, offset, k;
bool first = TRUE;
struct emailsubdir *sd;
char *subject = lang[MSG_FOLDERS_INDEX];
@@ -2930,6 +2930,8 @@
char *abbr_dateformat = "%e %b %Y";
char *verbose_dateformat = "%A, %e %B %Y";
+ char *tmpstr;
+
FILE *fp;
filename = htmlfilename(index_name[0][FOLDERS_INDEX], NULL, "");
@@ -2949,6 +2951,19 @@
print_index_header_links(fp, FOLDERS_INDEX, firstdatenum, lastdatenum, amountmsgs, NULL);
fprintf (fp, "\n");
fprintf(fp, "
\n");
+
+ /* find which element of index_name is the default index */
+ offset = 0;
+ if (set_defaultindex) {
+ tmpstr = setindex(INDEXNAME, INDEXNAME, set_htmlsuffix);
+ for (j = 0; j <= ATTACHMENT_INDEX; ++j) {
+ if (0 == strcmp(tmpstr, index_name[1][j])) {
+ offset = j;
+ break;
+ }
+ }
+ }
+
for (i = 0, j = 0; j <= ATTACHMENT_INDEX; ++j) {
if (show_index[1][j])
i++;
@@ -2974,10 +2989,12 @@
if (!datelist->data)
continue;
for (j = 0; j <= ATTACHMENT_INDEX; ++j) {
- if (!show_index[1][j])
+ /* apply offset so the period column's href points to index.html */
+ k = (j + offset) % (ATTACHMENT_INDEX + 1);
+ if (!show_index[1][k])
continue;
set_dateformat = saved_set_dateformat;
- switch (j) {
+ switch (k) {
case DATE_INDEX:
writedates(sd->count, sd->first_email);
index_title = lang[MSG_LTITLE_LISTED_BY_DATE];
@@ -3036,7 +3053,7 @@
if (sd->count > 0)
fprintf (fp, "",
verbose_period_name, index_title,
- sd->subdir, index_name[1][j]);
+ sd->subdir, index_name[1][k]);
fprintf (fp, "%s", abbr_period_name);
if (sd->count > 0)
fprintf (fp, "");
@@ -3051,8 +3068,8 @@
if (sd->count > 0)
fprintf (fp, "",
verbose_period_name, index_title,
- sd->subdir, index_name[1][j]);
- fprintf (fp, "%s", indextypename[j]);
+ sd->subdir, index_name[1][k]);
+ fprintf (fp, "%s", indextypename[k]);
if (sd->count > 0)
fprintf (fp, "");
fprintf (fp, "\n");