texinfo-commits
[Top][All Lists]
Advanced

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

texinfo ChangeLog info/.gdbinit info/tag.c


From: karl
Subject: texinfo ChangeLog info/.gdbinit info/tag.c
Date: Sun, 10 Feb 2013 19:44:42 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     karl <karl>     13/02/10 19:44:42

Modified files:
        .              : ChangeLog 
        info           : .gdbinit tag.c 

Log message:
        notice image text= buffer realloc

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/ChangeLog?cvsroot=texinfo&r1=1.1546&r2=1.1547
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/.gdbinit?cvsroot=texinfo&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/texinfo/info/tag.c?cvsroot=texinfo&r1=1.2&r2=1.3

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/texinfo/texinfo/ChangeLog,v
retrieving revision 1.1546
retrieving revision 1.1547
diff -u -b -r1.1546 -r1.1547
--- ChangeLog   10 Feb 2013 15:14:11 -0000      1.1546
+++ ChangeLog   10 Feb 2013 19:44:42 -0000      1.1547
@@ -1,3 +1,9 @@
+2013-02-10  Karl Berry  <address@hidden>
+
+       * info/tag.c (tag_found_keyword): new fn, including a check
+       for the text buffer being realloc-ed, invalidating kw.  Sigh.
+       (tag_image): call it (twice).
+
 2013-02-10  Patrice Dumas  <address@hidden>
 
        * autogen.sh, tp/maintain/regenerate_cmd_tests.sh, tp/tests/*:

Index: info/.gdbinit
===================================================================
RCS file: /sources/texinfo/texinfo/info/.gdbinit,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- info/.gdbinit       17 Feb 2008 15:08:09 -0000      1.10
+++ info/.gdbinit       10 Feb 2013 19:44:42 -0000      1.11
@@ -11,4 +11,6 @@
 #set args --restore /tmp/q ./foobar
 #set args -O info
 
-set args --restore $ttests/drib.isearch
+#set args --restore $ttests/drib.isearch
+#set env INFOPATH /usr/share/info
+set args ./imagetxt

Index: info/tag.c
===================================================================
RCS file: /sources/texinfo/texinfo/info/tag.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- info/tag.c  30 Nov 2012 23:58:20 -0000      1.2
+++ info/tag.c  10 Feb 2013 19:44:42 -0000      1.3
@@ -1,7 +1,8 @@
-/* tag.c -- Functions to handle Info tags.
-   $Id: tag.c,v 1.2 2012/11/30 23:58:20 gray Exp $
+/* tag.c -- Functions to handle Info tags (that is, the special
+   construct for images, not the "tag table" of starting position.)
+   $Id: tag.c,v 1.3 2013/02/10 19:44:42 karl Exp $
 
-   Copyright (C) 2012 Free Software Foundation, Inc.
+   Copyright (C) 2012, 2013 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
@@ -47,6 +48,9 @@
     }
 }
 
+
+/* See if KW is one of the tags in the list starting at TAG.  */
+
 static struct info_tag *
 info_tag_find (struct info_tag *tag, const char *kw)
 {
@@ -56,6 +60,29 @@
   return NULL;
 }
 
+
+/* Found a keyword when parsing the full tag string: alt, text, etc.
+   Return the new tag, update *TMPBUF_PTR and set *KW.  */
+
+static struct info_tag *
+tag_found_keyword (struct text_buffer *tmpbuf_ptr, char **kw)
+{
+  struct info_tag *tag = xmalloc (sizeof (*tag));
+  tag->next = NULL;  /* have to update in caller */
+
+  text_buffer_add_char (tmpbuf_ptr, 0);
+  if (*kw != tmpbuf_ptr->base) { /* in case tmpbuf got realloc-ed */
+    *kw = tmpbuf_ptr->base;      /* ick */
+  }
+  tag->kw = xstrdup (*kw);
+  tag->val = xstrdup (*kw + strlen(*kw) + 1);
+  text_buffer_reset (tmpbuf_ptr);
+
+  return tag;
+}
+
+/* Handle the image tag.  */
+
 static int
 tag_image (char *text, struct text_buffer *outbuf)
 {
@@ -77,14 +104,11 @@
        {
          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);
+              struct info_tag *new_kw = tag_found_keyword (&tmpbuf, &kw);
+              new_kw->next = tag_head;
+              tag_head = new_kw;
              state = state_delim;
+              continue;
            }
          if (state == state_delim)
            continue;
@@ -121,13 +145,9 @@
                }
              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);
+                 struct info_tag *new_kw = tag_found_keyword (&tmpbuf, &kw);
+                 new_kw->next = tag_head;
+                 tag_head = new_kw;
                  state = state_delim;
                  continue;
                }
@@ -158,6 +178,9 @@
   return 0;
 }
 
+
+/* We don't do anything with the index tag; it'll just be ignored.  */
+
 static struct tag_handler tagtab[] = {
   { "image", 5, tag_image },
   { NULL }
@@ -184,25 +207,25 @@
 
   text_buffer_init (&outbuf);
 
-  while ((p = input + strlen (input)) < endp)
+  while ((p = input + strlen (input)) < endp) /* go forward to null */
     {
-      if (memcmp(p + 1, "\b[", 2) == 0)
+      if (memcmp(p + 1, "\b[", 2) == 0)       /* opening magic? */
        {
          char *q;
 
          p += 3;
-         q = p + strlen (p);
-         if (memcmp (q + 1, "\b]", 2) == 0)
+         q = p + strlen (p);                 /* forward to next null */
+         if (memcmp (q + 1, "\b]", 2) == 0)  /* closing magic? */
            {
              size_t len;
              struct tag_handler *tp;
 
-             len = strcspn (p, " \t");
+             len = strcspn (p, " \t");       /* tag name */
              tp = find_tag_handler (p, len);
              if (tp)
                {
                  while (p[len] == ' ' || p[len] == '\t')
-                   ++len;
+                   ++len;                      /* move past whitespace */
              
                  if (!text_buffer_off (&outbuf))
                    text_buffer_add_string (&outbuf, *pbuf, p - *pbuf - 3);



reply via email to

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