emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r112537: * src/doc.c (get_doc_string)


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112537: * src/doc.c (get_doc_string): Slightly relax the sanity checking.
Date: Thu, 09 May 2013 14:30:46 -0400
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112537
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Thu 2013-05-09 14:30:46 -0400
message:
  * src/doc.c (get_doc_string): Slightly relax the sanity checking.
  * src/lread.c (skip_dyn_eof): New function.
  (read1): Use it to skip the end of a file in response to address@hidden
modified:
  src/ChangeLog
  src/doc.c
  src/lread.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-05-09 15:17:38 +0000
+++ b/src/ChangeLog     2013-05-09 18:30:46 +0000
@@ -1,3 +1,10 @@
+2013-05-09  Stefan Monnier  <address@hidden>
+
+       * lread.c (skip_dyn_eof): New function.
+       (read1): Use it to skip the end of a file in response to address@hidden
+
+       * doc.c (get_doc_string): Slightly relax the sanity checking.
+
 2013-05-09  Jan Djärv  <address@hidden>
 
        * nsfns.m: Include IOGraphicsLib.h if Cocoa.

=== modified file 'src/doc.c'
--- a/src/doc.c 2013-04-02 01:54:56 +0000
+++ b/src/doc.c 2013-05-09 18:30:46 +0000
@@ -215,14 +215,20 @@
   if (CONSP (filepos))
     {
       int test = 1;
-      if (get_doc_string_buffer[offset - test++] != ' ')
-       return Qnil;
-      while (get_doc_string_buffer[offset - test] >= '0'
-            && get_doc_string_buffer[offset - test] <= '9')
-       test++;
-      if (get_doc_string_buffer[offset - test++] != '@'
-         || get_doc_string_buffer[offset - test] != '#')
-       return Qnil;
+      /* A dynamic docstring should be either at the very beginning of a "#@
+        comment" or right after a dynamic docstring delimiter (in case we
+        pack several such docstrings within the same comment).  */
+      if (get_doc_string_buffer[offset - test] != '\037')
+       {
+         if (get_doc_string_buffer[offset - test++] != ' ')
+           return Qnil;
+         while (get_doc_string_buffer[offset - test] >= '0'
+                && get_doc_string_buffer[offset - test] <= '9')
+           test++;
+         if (get_doc_string_buffer[offset - test++] != '@'
+             || get_doc_string_buffer[offset - test] != '#')
+           return Qnil;
+       }
     }
   else
     {

=== modified file 'src/lread.c'
--- a/src/lread.c       2013-05-07 19:15:08 +0000
+++ b/src/lread.c       2013-05-09 18:30:46 +0000
@@ -378,6 +378,19 @@
     }
 }
 
+static void
+skip_dyn_eof (Lisp_Object readcharfun)
+{
+  if (FROM_FILE_P (readcharfun))
+    {
+      block_input ();          /* FIXME: Not sure if it's needed.  */
+      fseek (instream, 0, SEEK_END);
+      unblock_input ();
+    }
+  else
+    while (READCHAR >= 0);
+}
+
 /* Unread the character C in the way appropriate for the stream READCHARFUN.
    If the stream is a user function, call it with the char as argument.  */
 
@@ -2622,7 +2635,7 @@
       if (c == '@')
        {
          enum { extra = 100 };
-         ptrdiff_t i, nskip = 0;
+         ptrdiff_t i, nskip = 0, digits = 0;
 
          /* Read a decimal integer.  */
          while ((c = READCHAR) >= 0
@@ -2630,8 +2643,14 @@
            {
              if ((STRING_BYTES_BOUND - extra) / 10 <= nskip)
                string_overflow ();
+             digits++;
              nskip *= 10;
              nskip += c - '0';
+             if (digits == 2 && nskip == 0)
+               { /* We've just seen address@hidden, which means "skip to end". 
 */
+                 skip_dyn_eof (readcharfun);
+                 return Qnil;
+               }
            }
          if (nskip > 0)
            /* We can't use UNREAD here, because in the code below we side-step


reply via email to

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