[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/makeinfo toc.c,1.3,1.4
From: |
dirt |
Subject: |
texinfo/makeinfo toc.c,1.3,1.4 |
Date: |
Thu, 8 Jan 2004 16:17:15 +0100 |
Update of /cvsroot/texinfo/texinfo/makeinfo
In directory sheep:/tmp/cvs-serv2112/makeinfo
Modified Files:
toc.c
Log Message:
2004-01-08 Alper Ersoy <address@hidden>
* makeinfo/cmds.c: use cm_contents for @shortcontents
and @summarycontents too.
* makeinfo/files.c (register_delayed_write)
(handle_delayed_writes): new functions.
* makeinfo/files.h: new delayed_write struct and
handling_delayed_writes variable.
* makeinfo/makeinfo.c (insert): use whitespace macro instead of
testing characters manually.
(convert_from_loaded_file): call handle_delayed_writes when finished.
* makeinfo/toc.c (contents_update_html, contents_update_info)
(shortcontents_update_html, shortcontents_update_info): changed file
read/writes with insert and insert_string.
(rewrite_top, contents_update, shortcontents_update)
(toc_update, cm_shortcontents): removed functions.
(cm_contents): for HTML and Info, only call register_delayed_write if
handling_delayed_writes is not true. Call contents_update_html and
other variants according to output format and command name.
* makeinfo/toc.h: removed obsolete variables and functions.
Index: toc.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/toc.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** toc.c 6 Jan 2004 18:42:10 -0000 1.3
--- toc.c 8 Jan 2004 15:17:13 -0000 1.4
***************
*** 41,52 ****
static int toc_counter = 0;
- /* the file where we found the @contents directive */
- char *contents_filename;
-
- /* the file where we found the @shortcontents directive */
- char *shortcontents_filename;
-
- static const char contents_placebo[] = "\n...Table of Contents...\n";
- static const char shortcontents_placebo[] = "\n...Short Contents...\n";
static const char lots_of_stars[] =
"***************************************************************************";
--- 41,44 ----
***************
*** 201,211 ****
}
}
-
/* Print table of contents in HTML. */
static void
! contents_update_html (fp)
! FILE *fp;
{
int i;
--- 193,201 ----
}
}
/* Print table of contents in HTML. */
static void
! contents_update_html ()
{
int i;
***************
*** 218,224 ****
return;
! flush_output (); /* in case we are writing stdout */
!
! fprintf (fp, "\n<div class=\"contents\">\n<h2>%s</h2>\n<ul>\n", _("Table of
Contents"));
last_level = toc_entry_alist[0]->level;
--- 208,212 ----
return;
! add_html_block_elt_args ("\n<div class=\"contents\">\n<h2>%s</h2>\n<ul>\n",
_("Table of Contents"));
last_level = toc_entry_alist[0]->level;
***************
*** 232,236 ****
@subsubsection ... ? */
for (k = 0; k < (toc_entry_alist[i]->level-last_level); k++)
! fputs ("<ul>\n", fp);
}
else if (toc_entry_alist[i]->level < last_level)
--- 220,224 ----
@subsubsection ... ? */
for (k = 0; k < (toc_entry_alist[i]->level-last_level); k++)
! add_html_block_elt ("<ul>\n");
}
else if (toc_entry_alist[i]->level < last_level)
***************
*** 239,243 ****
@chapter ... this IS usual.*/
for (k = 0; k < (last_level-toc_entry_alist[i]->level); k++)
! fputs ("</li></ul>\n", fp);
}
--- 227,231 ----
@chapter ... this IS usual.*/
for (k = 0; k < (last_level-toc_entry_alist[i]->level); k++)
! add_word ("</li></ul>\n");
}
***************
*** 247,255 ****
{
/* each toc entry is a list item. */
! fputs ("<li>", fp);
/* Insert link -- to an external file if splitting, or
within the current document if not splitting. */
! fprintf (fp, "<a ");
/* For chapters (only), insert an anchor that the short contents
will link to. */
--- 235,243 ----
{
/* each toc entry is a list item. */
! add_word ("<li>");
/* Insert link -- to an external file if splitting, or
within the current document if not splitting. */
! add_word ("<a ");
/* For chapters (only), insert an anchor that the short contents
will link to. */
***************
*** 264,271 ****
while (*p && *p != '"')
p++;
! fprintf (fp, "name=\"toc_%.*s\" ",
p - toc_entry_alist[i]->name, toc_entry_alist[i]->name);
}
! fprintf (fp, "href=\"%s#%s</a>\n",
splitting ? toc_entry_alist[i]->html_file : "",
toc_entry_alist[i]->name);
--- 252,259 ----
while (*p && *p != '"')
p++;
! add_word_args ("name=\"toc_%.*s\" ",
p - toc_entry_alist[i]->name, toc_entry_alist[i]->name);
}
! add_word_args ("href=\"%s#%s</a>\n",
splitting ? toc_entry_alist[i]->html_file : "",
toc_entry_alist[i]->name);
***************
*** 278,284 ****
if (toc_entry_alist[0]->level < last_level)
for (k = 0; k < (last_level-toc_entry_alist[0]->level); k++)
! fputs ("</li></ul>\n", fp);
! fputs ("</li></ul>\n</div>\n\n", fp);
}
--- 266,272 ----
if (toc_entry_alist[0]->level < last_level)
for (k = 0; k < (last_level-toc_entry_alist[0]->level); k++)
! add_word ("</li></ul>\n");
! add_word ("</li></ul>\n</div>\n\n");
}
***************
*** 286,291 ****
May be we should create a new command line switch --ascii ? */
static void
! contents_update_info (fp)
! FILE *fp;
{
int i;
--- 274,278 ----
May be we should create a new command line switch --ascii ? */
static void
! contents_update_info ()
{
int i;
***************
*** 295,322 ****
return;
! flush_output (); /* in case we are writing stdout */
!
! fprintf (fp, "%s\n%.*s\n\n", _("Table of Contents"),
! (int) strlen (_("Table of Contents")), lots_of_stars);
for (i = 0; i < toc_counter; i++)
{
if (toc_entry_alist[i]->level == 0)
! fputs ("\n", fp);
/* indention with two spaces per level, should this
changed? */
for (k = 0; k < toc_entry_alist[i]->level; k++)
! fputs (" ", fp);
! fprintf (fp, "%s\n", toc_entry_alist[i]->name);
}
! fputs ("\n\n", fp);
}
/* shortcontents in HTML; Should this produce a standalone file? */
static void
! shortcontents_update_html (fp)
! FILE *fp;
{
int i;
--- 282,311 ----
return;
! insert_string (_("Table of Contents"));
! insert ('\n');
! for (i = 0; i < strlen (_("Table of Contents")); i++)
! insert ('*');
! insert_string ("\n\n");
for (i = 0; i < toc_counter; i++)
{
if (toc_entry_alist[i]->level == 0)
! add_char ('\n');
/* indention with two spaces per level, should this
changed? */
for (k = 0; k < toc_entry_alist[i]->level; k++)
! insert_string (" ");
! insert_string (toc_entry_alist[i]->name);
! insert ('\n');
}
! insert_string ("\n\n");
}
/* shortcontents in HTML; Should this produce a standalone file? */
static void
! shortcontents_update_html (contents_filename)
! char *contents_filename;
{
int i;
***************
*** 327,333 ****
return;
! flush_output (); /* in case we are writing stdout */
!
! fprintf (fp, "\n<div class=\"shortcontents\">\n<h2>%s</h2>\n<ul>\n",
_("Short Contents"));
if (contents_filename)
--- 316,320 ----
return;
! add_html_block_elt_args ("\n<div
class=\"shortcontents\">\n<h2>%s</h2>\n<ul>\n", _("Short Contents"));
if (contents_filename)
***************
*** 341,352 ****
{
if (contents_filename)
! fprintf (fp, "<li><a href=\"%s#toc_%s</a></li>\n",
splitting ? toc_file : "", name);
else
! fprintf (fp, "<a href=\"%s#%s</a>\n",
splitting ? toc_entry_alist[i]->html_file : "", name);
}
}
! fputs ("</ul>\n</div>\n\n", fp);
if (contents_filename)
free (toc_file);
--- 328,339 ----
{
if (contents_filename)
! add_word_args ("<li><a href=\"%s#toc_%s</a></li>\n",
splitting ? toc_file : "", name);
else
! add_word_args ("<a href=\"%s#%s</a>\n",
splitting ? toc_entry_alist[i]->html_file : "", name);
}
}
! add_word ("</ul>\n</div>\n\n");
if (contents_filename)
free (toc_file);
***************
*** 355,360 ****
/* short contents in ASCII (--no-headers). */
static void
! shortcontents_update_info (fp)
! FILE *fp;
{
int i;
--- 342,346 ----
/* short contents in ASCII (--no-headers). */
static void
! shortcontents_update_info ()
{
int i;
***************
*** 363,476 ****
return;
! flush_output (); /* in case we are writing stdout */
!
! fprintf (fp, "%s\n%.*s\n\n", _("Short Contents"),
! (int) strlen (_("Short Contents")), lots_of_stars);
for (i = 0; i < toc_counter; i++)
{
if (toc_entry_alist[i]->level == 0)
! fprintf (fp, "%s\n", toc_entry_alist[i]->name);
! }
! fputs ("\n\n", fp);
! }
!
!
! static FILE *toc_fp;
! static char *toc_buf;
!
! static int
! rewrite_top (fname, placebo)
! const char *fname, *placebo;
! {
! int idx;
!
! /* Can't rewrite standard output or the null device. No point in
! complaining. */
! if (STREQ (fname, "-")
! || FILENAME_CMP (fname, NULL_DEVICE) == 0
! || FILENAME_CMP (fname, ALSO_NULL_DEVICE) == 0)
! return -1;
!
! toc_buf = find_and_load (fname);
!
! if (!toc_buf)
! {
! fs_error (fname);
! return -1;
! }
!
! idx = search_forward (placebo, 0);
!
! if (idx < 0)
! {
! error (_("%s: TOC should be here, but it was not found"), fname);
! return -1;
! }
!
! toc_fp = fopen (fname, "w");
! if (!toc_fp)
! {
! fs_error (fname);
! return -1;
! }
!
! if (fwrite (toc_buf, 1, idx, toc_fp) != idx)
! {
! fs_error (fname);
! return -1;
}
!
! return idx + strlen (placebo);
! }
!
! static void
! contents_update ()
! {
! int cont_idx = rewrite_top (contents_filename, contents_placebo);
!
! if (cont_idx < 0)
! return;
!
! if (html)
! contents_update_html (toc_fp);
! else
! contents_update_info (toc_fp);
!
! if (fwrite (toc_buf + cont_idx, 1, input_text_length - cont_idx, toc_fp)
! != input_text_length - cont_idx
! || fclose (toc_fp) != 0)
! fs_error (contents_filename);
! }
!
! static void
! shortcontents_update ()
! {
! int cont_idx = rewrite_top (shortcontents_filename, shortcontents_placebo);
!
! if (cont_idx < 0)
! return;
!
! if (html)
! shortcontents_update_html (toc_fp);
! else
! shortcontents_update_info (toc_fp);
!
! if (fwrite (toc_buf + cont_idx, 1, input_text_length - cont_idx - 1, toc_fp)
! != input_text_length - cont_idx - 1
! || fclose (toc_fp) != 0)
! fs_error (shortcontents_filename);
! }
!
! void
! toc_update ()
! {
! if (!html && !no_headers)
! return;
!
! if (contents_filename)
! contents_update ();
! if (shortcontents_filename)
! shortcontents_update ();
}
--- 349,367 ----
return;
! insert_string (_("Short Contents"));
! insert ('\n');
! for (i = 0; i < strlen (_("Short Contents")); i++)
! insert ('*');
! insert_string ("\n\n");
for (i = 0; i < toc_counter; i++)
{
if (toc_entry_alist[i]->level == 0)
! {
! insert_string (toc_entry_alist[i]->name);
! insert ('\n');
! }
}
! insert_string ("\n\n");
}
***************
*** 479,549 ****
int arg;
{
! if ((html || no_headers) && arg == START)
! {
! if (contents_filename)
! {
! free (contents_filename);
! contents_filename = NULL;
! }
! if (contents_filename && STREQ (contents_filename, "-"))
! {
! if (html)
! contents_update_html (stdout);
! else
! contents_update_info (stdout);
! }
! else
! {
! if (!executing_string && html)
! html_output_head ();
! contents_filename = xstrdup (current_output_filename);
! insert_string (contents_placebo); /* just mark it, for now */
! }
! }
! else
{
! if (xml && arg == START)
! {
! xml_insert_element (CONTENTS, START);
! xml_insert_element (CONTENTS, END);
! }
}
- }
! void
! cm_shortcontents (arg)
! int arg;
! {
! if ((html || no_headers) && arg == START)
{
! if (shortcontents_filename)
! {
! free (shortcontents_filename);
! shortcontents_filename = NULL;
! }
! if (shortcontents_filename && STREQ (shortcontents_filename, "-"))
! {
! if (html)
! shortcontents_update_html (stdout);
! else
! shortcontents_update_info (stdout);
! }
! else
{
! if (!executing_string && html)
! html_output_head ();
! shortcontents_filename = xstrdup (current_output_filename);
! insert_string (shortcontents_placebo); /* just mark it, for now */
}
}
! else
! {
! if (xml && arg == START)
! {
! xml_insert_element (SHORTCONTENTS, START);
! xml_insert_element (SHORTCONTENTS, END);
! }
! }
}
--- 370,408 ----
int arg;
{
! /* the file where we found the @contents directive */
! static char *contents_filename;
! /* No need to mess with delayed stuff for XML and Docbook. */
! if (xml)
{
! if (arg != START)
! return;
! xml_insert_element (STREQ (command, "contents")
! ? CONTENTS : SHORTCONTENTS, START);
! xml_end_current_element ();
!
! return;
}
! if (!handling_delayed_writes)
{
! if (!executing_string && html)
! html_output_head ();
! register_delayed_write (STREQ (command, "contents")
! ? "@contents" : "@shortcontents");
!
! if (html && STREQ (command, "contents"))
{
! if (contents_filename)
! free (contents_filename);
! contents_filename = xstrdup (current_output_filename);
}
}
! else if (html)
! STREQ (command, "contents")
! ? contents_update_html () : shortcontents_update_html
(contents_filename);
! else if (no_headers)
! STREQ (command, "contents")
! ? contents_update_info () : shortcontents_update_info ();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/makeinfo toc.c,1.3,1.4,
dirt <=
- Prev by Date:
texinfo/makeinfo cmds.c,1.17,1.18 files.c,1.1.1.1,1.2 makeinfo.c,1.28,1.29 files.h,1.1.1.1,1.2 toc.h,1.1.1.1,1.2
- Next by Date:
texinfo ChangeLog,1.91,1.92
- Previous by thread:
texinfo/makeinfo cmds.c,1.17,1.18 files.c,1.1.1.1,1.2 makeinfo.c,1.28,1.29 files.h,1.1.1.1,1.2 toc.h,1.1.1.1,1.2
- Next by thread:
texinfo ChangeLog,1.91,1.92
- Index(es):