texinfo-commits
[Top][All Lists]
Advanced

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

texinfo ChangeLog NEWS info/Makefile.am info/di...


From: Sergey Poznyakoff
Subject: texinfo ChangeLog NEWS info/Makefile.am info/di...
Date: Sat, 17 Nov 2012 17:16:19 +0000

CVSROOT:        /cvsroot/texinfo
Module name:    texinfo
Changes by:     Sergey Poznyakoff <gray>        12/11/17 17:16:19

Modified files:
        .              : ChangeLog NEWS 
        info           : Makefile.am dir.c display.c display.h filesys.c 
                         filesys.h info-utils.c info-utils.h nodes.c 
                         nodes.h 
Added files:
        info           : tag.c tag.h 

Log message:
        Use the text attribute to represent "image" tag.
        Provide a general-purpose solution, so new tags can be easily added.
        
        This fixes bug #37686.
        
        * info/tag.c: New file
        * info/tag.h: New file
        * info/Makefile.am: Add new files.
        * info/dir.c: Use size_t instead of long to represent file size.
        * info/display.c (handle_tag)
        (handle_tag_start,handle_tag_end): Remove.
        * info/display.h (handle_tag): Remove.
        * info/filesys.c (filesys_read_info_file): Use size_t instead of
        long to represent file sizes and offsets.
        Call tags_expand to expand info tags.
        (filesys_read_compressed): Do not call convert_eols, leave that
        for filesys_read_info_file.
        * info/filesys.h (filesys_read_info_file)
        (filesys_read_compressed): Use size_t instead of
        long to represent file sizes and offsets.
        * info/info-utils.c (text_buffer_alloc): New function.
        * info/info-utils.h (MIN_TEXT_BUF_ALLOC): New define.
        (text_buffer_alloc): New proto.
        (text_buffer_reset,text_buffer_base)
        (text_buffer_off): New macros.
        * info/nodes.c: Use size_t instead of long to represent file sizes
        and offsets.
        * info/nodes.h (FILE_BUFFER) <filesize>: Change type to size_t.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/ChangeLog?cvsroot=texinfo&r1=1.1447&r2=1.1448
http://cvs.savannah.gnu.org/viewcvs/texinfo/NEWS?cvsroot=texinfo&r1=1.218&r2=1.219
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/Makefile.am?cvsroot=texinfo&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/dir.c?cvsroot=texinfo&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/display.c?cvsroot=texinfo&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/display.h?cvsroot=texinfo&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/filesys.c?cvsroot=texinfo&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/filesys.h?cvsroot=texinfo&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/info-utils.c?cvsroot=texinfo&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/info-utils.h?cvsroot=texinfo&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/nodes.c?cvsroot=texinfo&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/nodes.h?cvsroot=texinfo&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/tag.c?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/tag.h?cvsroot=texinfo&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/texinfo/texinfo/ChangeLog,v
retrieving revision 1.1447
retrieving revision 1.1448
diff -u -b -r1.1447 -r1.1448
--- ChangeLog   16 Nov 2012 23:34:51 -0000      1.1447
+++ ChangeLog   17 Nov 2012 17:16:18 -0000      1.1448
@@ -1,3 +1,36 @@
+2012-11-17  Sergey Poznyakoff  <address@hidden>
+
+       Use the text attribute to represent "image" tag.
+       Provide a general-purpose solution, so new tags can be easily
+       added.
+
+       This fixes bug #37686.
+
+       * info/tag.c: New file
+       * info/tag.h: New file
+       * info/Makefile.am: Add new files.
+       * info/dir.c: Use size_t instead of long to represent file size.
+       * info/display.c (handle_tag)
+       (handle_tag_start,handle_tag_end): Remove.
+       * info/display.h (handle_tag): Remove.
+       * info/filesys.c (filesys_read_info_file): Use size_t instead of
+       long to represent file sizes and offsets.
+       Call tags_expand to expand info tags.
+       (filesys_read_compressed): Do not call convert_eols, leave that
+       for filesys_read_info_file.
+       * info/filesys.h (filesys_read_info_file)
+       (filesys_read_compressed): Use size_t instead of
+        long to represent file sizes and offsets.
+       * info/info-utils.c (text_buffer_alloc): New function.
+       * info/info-utils.h (MIN_TEXT_BUF_ALLOC): New define.
+       (text_buffer_alloc): New proto.
+       (text_buffer_reset,text_buffer_base)
+       (text_buffer_off): New macros.
+       * info/nodes.c: Use size_t instead of long to represent file sizes
+       and offsets.
+       * info/nodes.h (FILE_BUFFER) <filesize>: Change type to size_t.
+       * NEWS: Update.
+       
 2012-11-16  Eli Zaretskii  <address@hidden>
 
        Support for MS-Windows screen and keyboard in Info.

Index: NEWS
===================================================================
RCS file: /cvsroot/texinfo/texinfo/NEWS,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -b -r1.218 -r1.219
--- NEWS        16 Nov 2012 23:31:16 -0000      1.218
+++ NEWS        17 Nov 2012 17:16:18 -0000      1.219
@@ -1,4 +1,4 @@
-$Id: NEWS,v 1.218 2012/11/16 23:31:16 karl Exp $
+$Id: NEWS,v 1.219 2012/11/17 17:16:18 gray Exp $
 This NEWS file records noteworthy changes, very tersely.
 See the manual for detailed information.
 
@@ -93,6 +93,8 @@
     value is 1.  It can be changed by setting the variable min-search-length,
     either by `M-x set-variable', or using infokey.
   . xz compression supported.
+  . Fix bug #37686: use the text attribute to represent "image" tags on
+    output.
 
 * install-info:
   . xz compression supported.

Index: info/Makefile.am
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/Makefile.am,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- info/Makefile.am    11 Jun 2012 17:54:26 -0000      1.17
+++ info/Makefile.am    17 Nov 2012 17:16:18 -0000      1.18
@@ -1,7 +1,7 @@
-# $Id: Makefile.am,v 1.17 2012/06/11 17:54:26 karl Exp $
+# $Id: Makefile.am,v 1.18 2012/11/17 17:16:18 gray Exp $
 # Makefile.am for texinfo/info.
 #
-# Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+# Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012
 # Free Software Foundation, Inc.
 #
 # This file is free software; as a special exception the author gives
@@ -40,7 +40,7 @@
   indices.c indices.h info-utils.c info-utils.h info.c info.h infodoc.c \
   infomap.c infomap.h m-x.c man.c man.h nodemenu.c nodes.c nodes.h \
   search.c search.h session.c session.h signals.c signals.h \
-  termdep.h terminal.c terminal.h tilde.c tilde.h \
+  tag.c tag.h termdep.h terminal.c terminal.h tilde.c tilde.h \
   variables.c variables.h window.c window.h
 nodist_ginfo_SOURCES = doc.c funs.h
 infokey_SOURCES = infokey.c infokey.h key.h

Index: info/dir.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/dir.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- info/dir.c  16 Nov 2012 23:34:51 -0000      1.11
+++ info/dir.c  17 Nov 2012 17:16:18 -0000      1.12
@@ -1,5 +1,5 @@
 /* dir.c -- how to build a special "dir" node from "localdir" files.
-   $Id: dir.c,v 1.11 2012/11/16 23:34:51 karl Exp $
+   $Id: dir.c,v 1.12 2012/11/17 17:16:18 gray Exp $
 
    Copyright (C) 1993, 1997, 1998, 2004, 2007, 
    2008, 2009, 2012 Free Software Foundation, Inc.
@@ -28,7 +28,7 @@
    with the addition of the menus of every file named in the array
    dirs_to_add which are found in INFOPATH. */
 
-static void add_menu_to_file_buffer (char *contents, long int size,
+static void add_menu_to_file_buffer (char *contents, size_t size,
     FILE_BUFFER *fb);
 static void insert_text_into_fb_at_binding (FILE_BUFFER *fb,
     SEARCH_BINDING *binding, char *text, int textlen);
@@ -139,7 +139,7 @@
           /* Only add this file if we have not seen it before.  */
           if (statable && S_ISREG (finfo.st_mode) && new_dir_file_p (&finfo))
             {
-              long filesize;
+              size_t filesize;
              int compressed;
               char *contents = filesys_read_info_file (fullpath, &filesize,
                                                        &finfo, &compressed);
@@ -167,7 +167,7 @@
    to the menu found in FB->contents.  Second argument SIZE is the total
    size of CONTENTS. */
 static void
-add_menu_to_file_buffer (char *contents, long int size, FILE_BUFFER *fb)
+add_menu_to_file_buffer (char *contents, size_t size, FILE_BUFFER *fb)
 {
   SEARCH_BINDING contents_binding, fb_binding;
   long contents_offset, fb_offset;

Index: info/display.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/display.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- info/display.c      5 Oct 2008 16:06:18 -0000       1.17
+++ info/display.c      17 Nov 2012 17:16:18 -0000      1.18
@@ -1,7 +1,7 @@
 /* display.c -- How to display Info windows.
-   $Id: display.c,v 1.17 2008/10/05 16:06:18 gray Exp $
+   $Id: display.c,v 1.18 2012/11/17 17:16:18 gray Exp $
 
-   Copyright (C) 1993, 1997, 2003, 2004, 2006, 2007, 2008
+   Copyright (C) 1993, 1997, 2003, 2004, 2006, 2007, 2008, 2012
    Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -21,16 +21,13 @@
 
 #include "info.h"
 #include "display.h"
+#include "tag.h"
 
 extern int info_any_buffered_input_p (void); /* Found in session.c. */
 
 static void free_display (DISPLAY_LINE **display);
 static DISPLAY_LINE **make_display (int width, int height);
 
-void handle_tag (char *tag);
-void handle_tag_start (char *tag);
-void handle_tag_end (char *tag);
-
 /* An array of display lines which tell us what is currently visible on
    the display.  */
 DISPLAY_LINE **the_display = NULL;
@@ -91,33 +88,6 @@
   display_update_one_window (the_echo_area);
 }
 
-void
-handle_tag_start (char *tag)
-{
-  /* TODO really handle this tag.  */
-  return;
-}
-
-void
-handle_tag_end (char *tag)
-{
-  /* TODO really handle this tag.  */
-  return;
-}
-
-void
-handle_tag (char *tag)
-{
-    if (tag[0] == '/')
-      {
-       tag++;
-       handle_tag_end (tag);
-      }
-    else
-      handle_tag_start (tag);
-}
-
-
 struct display_node_closure {
   WINDOW *win;
   DISPLAY_LINE **display;
@@ -265,7 +235,8 @@
       dnc.win = win;
       dnc.display = the_display;
       
-      line_index = process_node_text (win, win->line_starts[win->pagetop],
+      line_index = process_node_text (win,
+                                     win->line_starts[win->pagetop],
                                      1,
                                      display_node_text,
                                      &dnc);

Index: info/display.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/display.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- info/display.h      18 Oct 2011 18:47:19 -0000      1.9
+++ info/display.h      17 Nov 2012 17:16:18 -0000      1.10
@@ -1,10 +1,10 @@
 /* display.h -- How the display in Info is done.
-   $Id: display.h,v 1.9 2011/10/18 18:47:19 karl Exp $
+   $Id: display.h,v 1.10 2012/11/17 17:16:18 gray Exp $
 
    This file is part of GNU Info, a program for reading online documentation
    stored in Info format.
 
-   Copyright (C) 1993, 1997, 2004, 2007, 2008, 2011
+   Copyright (C) 1993, 1997, 2004, 2007, 2008, 2011, 2012
    Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -75,6 +75,4 @@
 extern void display_scroll_line_starts (WINDOW *window, int old_pagetop,
     char **old_starts, int old_count);
 
-void handle_tag (char *tag);
-
 #endif /* not INFO_DISPLAY_H */

Index: info/filesys.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/filesys.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- info/filesys.c      18 Oct 2011 18:47:19 -0000      1.17
+++ info/filesys.c      17 Nov 2012 17:16:18 -0000      1.18
@@ -1,8 +1,8 @@
 /* filesys.c -- filesystem specific functions.
-   $Id: filesys.c,v 1.17 2011/10/18 18:47:19 karl Exp $
+   $Id: filesys.c,v 1.18 2012/11/17 17:16:18 gray Exp $
 
-   Copyright 1993, 1997, 1998, 2000, 2002, 2003, 2004, 2007, 2008, 2009, 2011
-   Free Software Foundation, Inc.
+   Copyright 1993, 1997, 1998, 2000, 2002, 2003, 2004, 2007, 2008, 2009, 2011,
+   2012 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
@@ -23,6 +23,7 @@
 
 #include "tilde.h"
 #include "filesys.h"
+#include "tag.h"
 
 /* Local to this file. */
 static char *info_file_in_path (char *filename, char *path);
@@ -596,22 +597,22 @@
    If the file turns out to be compressed, set IS_COMPRESSED to non-zero.
    If the file cannot be read, return a NULL pointer. */
 char *
-filesys_read_info_file (char *pathname, long int *filesize,
+filesys_read_info_file (char *pathname, size_t *filesize,
     struct stat *finfo, int *is_compressed)
 {
-  long st_size;
+  size_t fsize;
+  char *contents;
 
-  *filesize = filesys_error_number = 0;
+  fsize = filesys_error_number = 0;
 
   if (compressed_filename_p (pathname))
     {
       *is_compressed = 1;
-      return filesys_read_compressed (pathname, filesize);
+      contents = filesys_read_compressed (pathname, &fsize);
     }
   else
     {
       int descriptor;
-      char *contents;
 
       *is_compressed = 0;
       descriptor = open (pathname, O_RDONLY | O_BINARY, 0666);
@@ -624,9 +625,9 @@
         }
 
       /* Try to read the contents of this file. */
-      st_size = (long) finfo->st_size;
-      contents = xmalloc (1 + st_size);
-      if ((read (descriptor, contents, st_size)) != st_size)
+      fsize = (long) finfo->st_size;
+      contents = xmalloc (1 + fsize);
+      if ((read (descriptor, contents, fsize)) != fsize)
         {
          filesys_error_number = errno;
          close (descriptor);
@@ -635,20 +636,21 @@
         }
 
       close (descriptor);
+    }
 
       /* Convert any DOS-style CRLF EOLs into Unix-style NL.
         Seems like a good idea to have even on Unix, in case the Info
         files are coming from some Windows system across a network.  */
-      *filesize = convert_eols (contents, st_size);
+  fsize = convert_eols (contents, fsize);
+
+  tags_expand (&contents, &fsize);
 
       /* EOL conversion can shrink the text quite a bit.  We don't
         want to waste storage.  */
-      if (*filesize < st_size)
-       contents = xrealloc (contents, 1 + *filesize);
-      contents[*filesize] = '\0';
-
+  contents = xrealloc (contents, 1 + fsize);
+  contents[fsize] = '\0';
+  *filesize = fsize;
       return contents;
-    }
 }
 
 /* Typically, pipe buffers are 4k. */
@@ -658,7 +660,7 @@
 #define FILESYS_PIPE_BUFFER_SIZE (16 * BASIC_PIPE_BUFFER)
 
 char *
-filesys_read_compressed (char *pathname, long int *filesize)
+filesys_read_compressed (char *pathname, size_t *filesize)
 {
   FILE *stream;
   char *command, *decompressor;
@@ -695,7 +697,7 @@
   /* Read chunks from this file until there are none left to read. */
   if (stream)
     {
-      long offset, size;
+      size_t offset, size;
       char *chunk;
     
       offset = size = 0;
@@ -703,7 +705,7 @@
 
       while (1)
         {
-          int bytes_read;
+          size_t bytes_read;
 
           bytes_read = fread (chunk, 1, FILESYS_PIPE_BUFFER_SIZE, stream);
 
@@ -727,9 +729,9 @@
        }
       else
        {
-         *filesize = convert_eols (contents, offset);
-         contents = xrealloc (contents, 1 + *filesize);
-         contents[*filesize] = '\0';
+         contents = xrealloc (contents, 1 + offset);
+         contents[offset] = '\0';
+         *filesize = offset;
        }
     }
   else

Index: info/filesys.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/filesys.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- info/filesys.h      14 Mar 2009 17:31:30 -0000      1.8
+++ info/filesys.h      17 Nov 2012 17:16:18 -0000      1.9
@@ -1,7 +1,7 @@
 /* filesys.h -- external declarations for filesys.c.
-   $Id: filesys.h,v 1.8 2009/03/14 17:31:30 karl Exp $
+   $Id: filesys.h,v 1.9 2012/11/17 17:16:18 gray Exp $
 
-   Copyright 1993, 1997, 1998, 2002, 2004, 2005, 2007, 2009 Free Software
+   Copyright 1993, 1997, 1998, 2002, 2004, 2005, 2007, 2009, 2012 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -52,10 +52,10 @@
    that file in it, and returning the size of that buffer in FILESIZE.
    FINFO is a stat struct which has already been filled in by the caller.
    If the file cannot be read, return a NULL pointer. */
-extern char *filesys_read_info_file (char *pathname, long int *filesize,
+extern char *filesys_read_info_file (char *pathname, size_t *filesize,
     struct stat *finfo, int *is_compressed);
 
-extern char *filesys_read_compressed (char *pathname, long int *filesize);
+extern char *filesys_read_compressed (char *pathname, size_t *filesize);
 
 /* Return the command string that would be used to decompress FILENAME. */
 extern char *filesys_decompressor_for_file (char *filename);

Index: info/info-utils.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/info-utils.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- info/info-utils.c   14 Jul 2012 22:41:02 -0000      1.19
+++ info/info-utils.c   17 Nov 2012 17:16:18 -0000      1.20
@@ -1,5 +1,5 @@
 /* info-utils.c -- miscellanous.
-   $Id: info-utils.c,v 1.19 2012/07/14 22:41:02 karl Exp $
+   $Id: info-utils.c,v 1.20 2012/11/17 17:16:18 gray Exp $
 
    Copyright (C) 1993, 1998, 2003, 2004, 2007, 2008, 2009, 2011, 2012
    Free Software Foundation, Inc.
@@ -787,7 +787,7 @@
   if (!buf->base)
     {
       if (buf->size == 0)
-       buf->size = 512; /* Initial allocation */
+       buf->size = MIN_TEXT_BUF_ALLOC; /* Initial allocation */
       
       buf->base = xmalloc (buf->size);
     }
@@ -816,14 +816,22 @@
   return n;
 }
 
-size_t
-text_buffer_add_string (struct text_buffer *buf, const char *str, size_t len)
+void
+text_buffer_alloc (struct text_buffer *buf, size_t len)
 {
   if (buf->off + len > buf->size)
     {
       buf->size = buf->off + len;
+      if (buf->size < MIN_TEXT_BUF_ALLOC)
+       buf->size = MIN_TEXT_BUF_ALLOC;
       buf->base = xrealloc (buf->base, buf->size);
     }
+}
+
+size_t
+text_buffer_add_string (struct text_buffer *buf, const char *str, size_t len)
+{
+  text_buffer_alloc (buf, len);
   memcpy (buf->base + buf->off, str, len);
   buf->off += len;
   return len;
@@ -835,11 +843,7 @@
   char *p;
   int i;
   
-  if (buf->off + len > buf->size)
-    {
-      buf->size = buf->off + len;
-      buf->base = xrealloc (buf->base, buf->size);
-    }
+  text_buffer_alloc (buf, len);
 
   for (i = 0, p = buf->base + buf->off; i < len; i++)
     *p++ = c;

Index: info/info-utils.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/info-utils.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- info/info-utils.h   12 Apr 2012 10:38:29 -0000      1.12
+++ info/info-utils.h   17 Nov 2012 17:16:18 -0000      1.13
@@ -1,7 +1,7 @@
 /* info-utils.h -- Exported functions and variables from info-utils.c.
-   $Id: info-utils.h,v 1.12 2012/04/12 10:38:29 gray Exp $   
+   $Id: info-utils.h,v 1.13 2012/11/17 17:16:18 gray Exp $   
 
-   Copyright (C) 1993, 1996, 1998, 2002, 2003, 2004, 2007, 2011
+   Copyright (C) 1993, 1996, 1998, 2002, 2003, 2004, 2007, 2011, 2012
    Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -151,8 +151,11 @@
   size_t off;
 };
 
+#define MIN_TEXT_BUF_ALLOC 512
+
 void text_buffer_init (struct text_buffer *buf);
 void text_buffer_free (struct text_buffer *buf);
+void text_buffer_alloc (struct text_buffer *buf, size_t len);
 size_t text_buffer_vprintf (struct text_buffer *buf, const char *format,
                            va_list ap);
 size_t text_buffer_add_string (struct text_buffer *buf, const char *str,
@@ -160,5 +163,8 @@
 size_t text_buffer_fill (struct text_buffer *buf, int c, size_t len);
 void text_buffer_add_char (struct text_buffer *buf, int c);
 size_t text_buffer_printf (struct text_buffer *buf, const char *format, ...);
+#define text_buffer_reset(buf) ((buf)->off = 0)
+#define text_buffer_base(buf) ((buf)->base)
+#define text_buffer_off(buf) ((buf)->off)
 
 #endif /* not INFO_UTILS_H */

Index: info/nodes.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/nodes.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- info/nodes.c        12 Apr 2012 10:38:29 -0000      1.19
+++ info/nodes.c        17 Nov 2012 17:16:18 -0000      1.20
@@ -1,8 +1,8 @@
 /* nodes.c -- how to get an Info file and node.
-   $Id: nodes.c,v 1.19 2012/04/12 10:38:29 gray Exp $
+   $Id: nodes.c,v 1.20 2012/11/17 17:16:18 gray Exp $
 
    Copyright (C) 1993, 1998, 1999, 2000, 2002, 2003, 2004, 2006, 2007,
-   2008, 2009, 2011 Free Software Foundation, Inc.
+   2008, 2009, 2011, 2012 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
@@ -333,7 +333,7 @@
 info_load_file_internal (char *filename, int get_tags)
 {
   char *fullpath, *contents;
-  long filesize;
+  size_t filesize;
   struct stat finfo;
   int retcode, compressed;
   FILE_BUFFER *file_buffer = NULL;

Index: info/nodes.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/info/nodes.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- info/nodes.h        12 Apr 2012 10:38:29 -0000      1.9
+++ info/nodes.h        17 Nov 2012 17:16:19 -0000      1.10
@@ -1,7 +1,7 @@
 /* nodes.h -- How we represent nodes internally.
-   $Id: nodes.h,v 1.9 2012/04/12 10:38:29 gray Exp $
+   $Id: nodes.h,v 1.10 2012/11/17 17:16:19 gray Exp $
 
-   Copyright (C) 1993, 1997, 1998, 2002, 2004, 2007, 2011
+   Copyright (C) 1993, 1997, 1998, 2002, 2004, 2007, 2011, 2012
    Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -104,7 +104,7 @@
   char *fullpath;               /* The full pathname of this info file. */
   struct stat finfo;            /* Information about this file. */
   char *contents;               /* The contents of this particular file. */
-  long filesize;                /* The number of bytes this file expands to. */
+  size_t filesize;              /* The number of bytes this file expands to. */
   char **subfiles;              /* If non-null, the list of subfiles. */
   TAG **tags;                   /* If non-null, the indirect tags table. */
   int tags_slots;               /* Number of slots allocated for TAGS. */

Index: info/tag.c
===================================================================
RCS file: info/tag.c
diff -N info/tag.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ info/tag.c  17 Nov 2012 17:16:19 -0000      1.1
@@ -0,0 +1,244 @@
+/* tag.c -- Functions to handle Info tags.
+   $Id: tag.c,v 1.1 2012/11/17 17:16:19 gray Exp $
+
+   Copyright (C) 2012 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
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+
+#include "info.h"
+#include "tag.h" 
+#include "info-utils.h"
+
+struct tag_handler
+{
+  const char *name;
+  size_t len;
+  int (*handler) (char *, struct text_buffer *);
+};
+
+struct info_tag
+{
+  struct info_tag *next;
+  char *kw;
+  char *val;
+};
+
+static void
+info_tag_free (struct info_tag *tag)
+{
+  while (tag)
+    {
+      struct info_tag *next = tag->next;
+      free (tag->kw);
+      free (tag->val);
+      free (tag);
+      tag = next;
+    }
+}
+
+static struct info_tag *
+info_tag_find (struct info_tag *tag, const char *kw)
+{
+  for (; tag; tag = tag->next)
+    if (strcmp (tag->kw, kw) == 0)
+      return tag;
+  return NULL;
+}
+
+static int
+tag_image (char *text, struct text_buffer *outbuf)
+{
+  mbi_iterator_t iter;
+  enum { state_kw, state_val, state_qstr, state_delim } state = state_kw;
+  struct text_buffer tmpbuf;
+  char *kw;
+  struct info_tag *tag_head = NULL, *tag;
+  int escaped = 0;
+  
+  text_buffer_init (&tmpbuf);
+  for (mbi_init (iter, text, strlen (text)); mbi_avail (iter);
+       mbi_advance (iter))
+    {
+      const char *cur_ptr;
+      size_t cur_len;
+      
+      if (mb_isspace (mbi_cur (iter)))
+       {
+         if (state == state_val)
+           {
+             text_buffer_add_char (&tmpbuf, 0);
+             tag = xmalloc (sizeof (*tag));
+             tag->next = tag_head;
+             tag_head = tag;
+             tag->kw = xstrdup (kw);
+             tag->val = xstrdup (kw + strlen(kw) + 1);
+             text_buffer_reset (&tmpbuf);
+             state = state_delim;
+           }
+         if (state == state_delim)
+           continue;
+       }
+      cur_len = mb_len (mbi_cur (iter));
+      cur_ptr = mbi_cur_ptr (iter);
+      
+      if (state == state_qstr && escaped)
+       {
+         escaped = 0;
+       }
+      else if (cur_len == 1)
+       {
+         switch (*cur_ptr)
+           {
+           case '=':
+             text_buffer_add_char (&tmpbuf, 0);
+             kw = tmpbuf.base;
+             if (!mbi_avail (iter))
+               break;
+             mbi_advance (iter);
+             state = state_val;
+             cur_len = mb_len (mbi_cur (iter));
+             cur_ptr = mbi_cur_ptr (iter);
+             if (!(cur_len == 1 && *cur_ptr == '"'))
+               break;
+             /* fall through */
+
+           case '"':
+             if (state == state_val)
+               {
+                 state = state_qstr;
+                 continue;
+               }
+             if (state == state_qstr)
+               {
+                 text_buffer_add_char (&tmpbuf, 0);
+                 tag = xmalloc (sizeof (*tag));
+                 tag->next = tag_head;
+                 tag_head = tag;
+                 tag->kw = xstrdup (kw);
+                 tag->val = xstrdup (kw + strlen(kw) + 1);
+                 text_buffer_reset (&tmpbuf);
+                 state = state_delim;
+                 continue;
+               }
+             break;
+
+           case '\\':
+             if (state == state_qstr)
+               {
+                 escaped = 1;
+                 continue;
+               }
+           }
+       }
+      text_buffer_add_string (&tmpbuf, cur_ptr, cur_len);
+    }
+
+  tag = info_tag_find (tag_head, "text");
+  if (!tag)
+    tag = info_tag_find (tag_head, "alt");
+
+  if (tag)
+    {
+      text_buffer_add_string (outbuf, tag->val, strlen (tag->val));
+    }
+  
+  text_buffer_free (&tmpbuf);
+  info_tag_free (tag_head);
+  return 0;
+}
+
+static struct tag_handler tagtab[] = {
+  { "image", 5, tag_image },
+  { NULL }
+};
+
+static struct tag_handler *
+find_tag_handler (char *tag, size_t taglen)
+{
+  struct tag_handler *tp;
+
+  for (tp = tagtab; tp->name; tp++)
+    if (taglen >= tp->len && strncmp (tp->name, tag, tp->len) == 0)
+      return tp;
+  return NULL;
+}
+
+void
+tags_expand (char **pbuf, size_t *pbuflen)
+{
+  char *input = *pbuf;
+  char *endp = input + *pbuflen;
+  struct text_buffer outbuf;
+  char *p;
+
+  text_buffer_init (&outbuf);
+
+  while ((p = input + strlen (input)) < endp)
+    {
+      size_t len = p - input;
+      if (memcmp(p + 1, "\b[", 2) == 0)
+       {
+         char *q;
+         size_t len;
+         struct tag_handler *tp;
+
+         p += 3;
+         q = p + strlen (p);
+         if (memcmp (q + 1, "\b]", 2) == 0)
+           {
+             size_t len;
+             struct tag_handler *tp;
+
+             len = strcspn (p, " \t");
+             tp = find_tag_handler (p, len);
+             if (tp)
+               {
+                 while (p[len] == ' ' || p[len] == '\t')
+                   ++len;
+             
+                 if (!text_buffer_off (&outbuf))
+                   text_buffer_add_string (&outbuf, *pbuf, p - *pbuf - 3);
+                 else
+                   text_buffer_add_string (&outbuf, input, p - input - 3);
+                 if (tp->handler (p + len, &outbuf) == 0)
+                   {
+                     input = q + 3;
+                     continue;
+                   }
+               }
+           }
+       }
+
+      if (text_buffer_off (&outbuf))
+       {
+         text_buffer_add_string (&outbuf, input, p - input);
+       }
+      input = p + 1;
+    }
+
+  if (text_buffer_off (&outbuf))
+    {
+      if (input < endp)
+       text_buffer_add_string (&outbuf, input, endp - input);
+      free (*pbuf);
+      *pbuflen = text_buffer_off (&outbuf);
+      *pbuf = text_buffer_base (&outbuf);
+    }
+}
+  
+size_t
+handle_tag (char *tag)
+{
+  /* Nothing so far */
+}

Index: info/tag.h
===================================================================
RCS file: info/tag.h
diff -N info/tag.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ info/tag.h  17 Nov 2012 17:16:19 -0000      1.1
@@ -0,0 +1,25 @@
+/* tag.c -- Functions to handle Info tags.
+   $Id: tag.h,v 1.1 2012/11/17 17:16:19 gray Exp $
+
+   Copyright (C) 2012 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
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef TAG_H
+#define TAG_H
+
+void tags_expand (char **pbuf, size_t *pbuflen);
+size_t handle_tag (char *tag);
+
+#endif



reply via email to

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