- /* And the index. */
- sect = html_new_sect(§s, NULL);
- sect->text = NULL;
- sect->type = INDEX;
- sect->parent = topsect;
- html_file_section(&conf, &files, sect, 0); /* peer of chapters */
- sect->fragment = utoa_dup(conf.index_text, CS_ASCII);
- sect->fragment = html_sanitise_fragment(&files, sect->file,
- sect->fragment);
- files.index = sect->file;
+ /* And the index, if we have one. */
+ has_index = (count234(idx->entries) > 0);
+ if (has_index) {
+ sect = html_new_sect(§s, NULL, &conf);
+ sect->text = NULL;
+ sect->type = INDEX;
+ sect->parent = topsect;
+ sect->contents_depth = 0;
+ html_file_section(&conf, &files, sect, 0); /* peer of chapters */
+ sect->fragments[0] = utoa_dup(conf.index_text, CS_ASCII);
+ sect->fragments[0] = html_sanitise_fragment(&files, sect->file,
+ sect->fragments[0]);
+ files.index = sect->file;
+ }