help-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: @documentencoding, `makeinfo --enable-encoding' and texi2dvi(was: A


From: Karl Berry
Subject: Re: @documentencoding, `makeinfo --enable-encoding' and texi2dvi(was: An accented i)
Date: Wed, 30 Apr 2003 20:37:29 -0400

    Does it make sense to include the following immediately before @bye:

    @ifinfo
    @example
    Local Variables:
    coding: iso-latin-1
    End:
    @end example
    @end ifinfo

See attached patch, or get the current Texinfo sources from savannah cvs
(https://savannah.gnu.org/cvs/?group=texinfo), and then try makeinfo
--enable-encoding (and @documentencoding in the source file).

It works for me with @documentencoding ISO-8859-1, but it does not work
with ISO-8859-2.  However, I'm not clear as to whether that's simply a
function of the font I'm using in my xterm (which is ...-iso8859-1).  In
general, I'm never sure of my testing with different encodings.

I preceded the Local Variables: section with an Info cookie (CTRL-_).
This seemed to magically make both Emacs Info and standalone Info not
display the LV section as text, without any repercussions.  I was so
happy, I didn't check into it what was really happening :).

So, please try these changes if you can and let me know if it has problems.

BTW, I hope to start making pretests for the next release in a few days.
If any of you would like to be on my address@hidden list to
receive announcements of pretests, as well as other such discussion,
please let me know.

Thanks,
karl


Index: html.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/html.c,v
retrieving revision 1.11
diff -c -r1.11 html.c
*** html.c      26 Apr 2003 12:38:12 -0000      1.11
--- html.c      1 May 2003 00:01:56 -0000
***************
*** 49,55 ****
    add_word ("<meta http-equiv=\"Content-Type\" content=\"text/html");
    if (document_encoding_code != no_encoding)
      add_word_args ("; charset=%s",
!                    encoding_table[document_encoding_code].ecname);
    add_word ("\">\n");

    if (!document_description)
--- 49,55 ----
    add_word ("<meta http-equiv=\"Content-Type\" content=\"text/html");
    if (document_encoding_code != no_encoding)
      add_word_args ("; charset=%s",
!                    encoding_table[document_encoding_code].encname);
    add_word ("\">\n");

    if (!document_description)
Index: lang.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/lang.c,v
retrieving revision 1.7
diff -c -r1.7 lang.c
*** lang.c      1 Apr 2003 01:54:30 -0000       1.7
--- lang.c      1 May 2003 00:01:59 -0000
***************
*** 432,438 ****
  cm_documentlanguage ()
  {
    language_code_type c;
!   char *lang_arg;

    /* Read the line with the language code on it.  */
    get_rest_of_line (0, &lang_arg);
--- 432,438 ----
  cm_documentlanguage ()
  {
    language_code_type c;
!   char *lang_arg;

    /* Read the line with the language code on it.  */
    get_rest_of_line (0, &lang_arg);
***************
*** 487,499 ****
  {
    encoding_code_type enc;
    char *enc_arg;
!
    get_rest_of_line (1, &enc_arg);

    /* See if we have this encoding.  */
    for (enc = no_encoding+1; enc != last_encoding_code; enc++)
      {
!       if (strcasecmp (enc_arg, encoding_table[enc].ecname) == 0)
          {
            document_encoding_code = enc;
            break;
--- 487,499 ----
  {
    encoding_code_type enc;
    char *enc_arg;
!
    get_rest_of_line (1, &enc_arg);

    /* See if we have this encoding.  */
    for (enc = no_encoding+1; enc != last_encoding_code; enc++)
      {
!       if (strcasecmp (enc_arg, encoding_table[enc].encname) == 0)
          {
            document_encoding_code = enc;
            break;
***************
*** 502,508 ****

    /* If we didn't find this code, complain.  */
    if (enc == last_encoding_code)
!     warning (_("unrecogized encoding name `%s'"), enc_arg);

    else if (encoding_table[document_encoding_code].isotab == NULL)
      warning (_("sorry, encoding `%s' not supported"), enc_arg);
--- 502,508 ----

    /* If we didn't find this code, complain.  */
    if (enc == last_encoding_code)
!     warning (_("unrecognized encoding name `%s'"), enc_arg);

    else if (encoding_table[document_encoding_code].isotab == NULL)
      warning (_("sorry, encoding `%s' not supported"), enc_arg);
***************
*** 556,562 ****
       char *html_solo;
  {
    static int valid_html_accent; /* yikes */
!
    if (arg == START)
      { /* If HTML has good support for this character, use it.  */
        if (strchr (html_supported, curchar ()))
--- 556,562 ----
       char *html_solo;
  {
    static int valid_html_accent; /* yikes */
!
    if (arg == START)
      { /* If HTML has good support for this character, use it.  */
        if (strchr (html_supported, curchar ()))
***************
*** 569,575 ****
          escape_html = saved_escape_html;
          }
        else
!         {
            valid_html_accent = 0;
            if (html_solo_standalone)
              { /* No special HTML support, so produce standalone char.  */
--- 569,575 ----
          escape_html = saved_escape_html;
          }
        else
!         {
            valid_html_accent = 0;
            if (html_solo_standalone)
              { /* No special HTML support, so produce standalone char.  */
***************
*** 614,620 ****
            buffer[0] = output_paragraph[end - 1];
            buffer[1] = 0;
            strcat (buffer, html_solo);
!
            rc = cm_search_iso_map (buffer);
            if (rc >= 0)
              /* A little bit tricky ;-)
--- 614,620 ----
            buffer[0] = output_paragraph[end - 1];
            buffer[1] = 0;
            strcat (buffer, html_solo);
!
            rc = cm_search_iso_map (buffer);
            if (rc >= 0)
              /* A little bit tricky ;-)
***************
*** 627,638 ****
            else
              { /* If we didn't find a translation for this character,
                   put the single instead. E.g., &Xuml; does not exist so X&uml;
!                  should be produced. */
                warning (_("%s is an invalid ISO code, using %c"),
                         buffer, single);
                add_char (single);
              }
!
            free (buffer);
          }
      }
--- 627,638 ----
            else
              { /* If we didn't find a translation for this character,
                   put the single instead. E.g., &Xuml; does not exist so X&uml;
!                  should be produced. */
                warning (_("%s is an invalid ISO code, using %c"),
                         buffer, single);
                add_char (single);
              }
!
            free (buffer);
          }
      }
***************
*** 701,707 ****
    else if (no_headers)
      cm_accent_generic_no_headers (arg, start, end, single, html_solo);
    else if (arg == END)
!     {
        if (enable_encoding)
          /* use 8-bit if available */
          cm_accent_generic_no_headers (arg, start, end, single, html_solo);
--- 701,707 ----
    else if (no_headers)
      cm_accent_generic_no_headers (arg, start, end, single, html_solo);
    else if (arg == END)
!     {
        if (enable_encoding)
          /* use 8-bit if available */
          cm_accent_generic_no_headers (arg, start, end, single, html_solo);
Index: lang.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/lang.h,v
retrieving revision 1.3
diff -c -r1.3 lang.h
*** lang.h      7 Nov 2002 16:10:49 -0000       1.3
--- lang.h      1 May 2003 00:01:59 -0000
***************
*** 1,7 ****
  /* lang.h -- declarations for language codes etc.
     $Id: lang.h,v 1.3 2002/11/07 16:10:49 karl Exp $

!    Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.

     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
--- 1,7 ----
  /* lang.h -- declarations for language codes etc.
     $Id: lang.h,v 1.3 2002/11/07 16:10:49 karl Exp $

!    Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.

     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
***************
*** 80,88 ****
  typedef enum {
      no_encoding,
      US_ASCII,
!     ISO_8859_1,    /* default for en, de, */
!     ISO_8859_2,    /* actualy not supported like the rest below */
!     ISO_8859_3,
      ISO_8859_4,
      ISO_8859_5,
      ISO_8859_6,
--- 80,88 ----
  typedef enum {
      no_encoding,
      US_ASCII,
!     ISO_8859_1,
!     ISO_8859_2,
!     ISO_8859_3,    /* this and none of the rest are supported. */
      ISO_8859_4,
      ISO_8859_5,
      ISO_8859_6,
***************
*** 118,124 ****
  typedef struct
  {
    encoding_code_type ec; /* document encoding type (see above enum) */
!   char *ecname;          /* encoding name like ISO-8859-1 */
    iso_map_type *isotab;  /* address of ISO translation table */
  } encoding_type;

--- 118,124 ----
  typedef struct
  {
    encoding_code_type ec; /* document encoding type (see above enum) */
!   char *encname;         /* encoding name like "ISO-8859-1", valid in Emacs */
    iso_map_type *isotab;  /* address of ISO translation table */
  } encoding_type;

Index: makeinfo.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/makeinfo.c,v
retrieving revision 1.27
diff -c -r1.27 makeinfo.c
*** makeinfo.c  28 Apr 2003 23:26:44 -0000      1.27
--- makeinfo.c  1 May 2003 00:02:05 -0000
***************
*** 31,36 ****
--- 31,37 ----
  #include "html.h"
  #include "index.h"
  #include "insertion.h"
+ #include "lang.h"
  #include "macro.h"
  #include "node.h"
  #include "toc.h"
***************
*** 1163,1168 ****
--- 1164,1171 ----
    input_text_offset = i;
    *string = temp;
  }
+
+
  
  /* Converting a file.  */

***************
*** 1623,1629 ****
--- 1626,1643 ----
            close_paragraph ();
          }

+       /* maybe we want local variables: in info output.  */
+       {
+         char *trailer = info_trailer ();
+         if (trailer)
+           {
+             insert_string (trailer);
+             free (trailer);
+           }
+       }
+
        flush_output ();          /* in case there was no @bye */
+
        if (output_stream != stdout)
          fclose (output_stream);

***************
*** 1652,1657 ****
--- 1666,1694 ----
    free (real_output_filename);
  }

+
+ 
+ /* If enable_encoding and document_encoding are both set, return a Local
+    Variables: section (as a malloc-ed string) so that Emacs' locale
+    features can work.  Else return NULL.  */
+
+ char *
+ info_trailer ()
+ {
+   if (!enable_encoding || document_encoding_code <= US_ASCII)
+     return NULL;
+
+   {
+ #define LV_FMT "\n\037\nLocal Variables:\ncoding: %s\nEnd:\n"
+     char *enc_name = encoding_table[document_encoding_code].encname;
+     char *lv = xmalloc (sizeof (LV_FMT) + strlen (enc_name));
+     sprintf (lv, LV_FMT, enc_name);
+     return lv;
+   }
+ }
+
+
+ 
  void
  free_and_clear (pointer)
       char **pointer;
Index: makeinfo.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/makeinfo.h,v
retrieving revision 1.7
diff -c -r1.7 makeinfo.h
*** makeinfo.h  22 Apr 2003 13:00:47 -0000      1.7
--- makeinfo.h  1 May 2003 00:02:06 -0000
***************
*** 268,275 ****

  /* Stuff for splitting large files.  The numbers for Emacs
     texinfo-format-buffer are much smaller, but memory capacities have
!    increased so much, 50k info files seems a bit tiny these days.  */
! #define SPLIT_SIZE_THRESHOLD 500000
  #define DEFAULT_SPLIT_SIZE 300000
  DECLARE (int, splitting, 1);    /* Defaults to true for now. */

--- 268,274 ----

  /* Stuff for splitting large files.  The numbers for Emacs
     texinfo-format-buffer are much smaller, but memory capacities have
!    increased so much, 50k info files seem a bit tiny these days.  */
  #define DEFAULT_SPLIT_SIZE 300000
  DECLARE (int, splitting, 1);    /* Defaults to true for now. */

***************
*** 293,297 ****
--- 292,299 ----
     else zero. */
  #define looking_at(string) \
    (strncmp (input_text + input_text_offset, string, strlen (string)) == 0)
+
+ /* Possibly return Local Variables: trailer for Info output.  */
+ extern char *info_trailer ();

  #endif /* not MAKEINFO_H */
Index: node.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/node.c,v
retrieving revision 1.10
diff -c -r1.10 node.c
*** node.c      29 Apr 2003 23:05:48 -0000      1.10
--- node.c      1 May 2003 00:02:07 -0000
***************
*** 1634,1641 ****
    if (size == 0)
      size = DEFAULT_SPLIT_SIZE;

!   if ((stat (filename, &fileinfo) != 0) ||
!       (((long) fileinfo.st_size) < SPLIT_SIZE_THRESHOLD))
      return;
    file_size = (long) fileinfo.st_size;

--- 1634,1641 ----
    if (size == 0)
      size = DEFAULT_SPLIT_SIZE;

!   if ((stat (filename, &fileinfo) != 0)
!       || (((long) fileinfo.st_size) < size))
      return;
    file_size = (long) fileinfo.st_size;

***************
*** 1662,1667 ****
--- 1662,1671 ----
      TAG_ENTRY *tags = tag_table;
      char *indirect_info = NULL;

+     /* Maybe we want a Local Variables: section.  */
+     char *trailer = info_trailer ();
+     int trailer_len = trailer ? strlen (trailer) : 0;
+
      /* Remember the `header' of this file.  The first tag in the file is
         the bottom of the header; the top of the file is the start. */
      the_header = xmalloc (1 + (header_size = tags->position));
***************
*** 1783,1789 ****
                        || write (fd, the_header, header_size) != header_size
                        || write (fd, the_file + file_top, file_bot - file_top)
                           != (file_bot - file_top)
!                       || (close (fd)) < 0)
                      {
                        perror (split_filename);
                        if (fd != -1)
--- 1787,1795 ----
                        || write (fd, the_header, header_size) != header_size
                        || write (fd, the_file + file_top, file_bot - file_top)
                           != (file_bot - file_top)
!                       || (trailer_len
!                           && write (fd, trailer, trailer_len) != trailer_len)
!                       || close (fd) < 0)
                      {
                        perror (split_filename);
                        if (fd != -1)
***************
*** 1828,1834 ****
--- 1834,1849 ----
        /* Inhibit newlines. */
        paragraph_is_open = 0;

+       /* Write the indirect tag table.  */
        write_tag_table_indirect ();
+
+       /* preserve local variables: in info output.  */
+       if (trailer)
+         {
+           insert_string (trailer);
+           free (trailer);
+         }
+
        fclose (output_stream);
        free (the_header);
        free (the_file);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]