emacs-devel
[Top][All Lists]
Advanced

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

Re: address@hidden (Pavel Janík)] Re: crash in emacs-21.1


From: Gerd Moellmann
Subject: Re: address@hidden (Pavel Janík)] Re: crash in emacs-21.1
Date: 30 Oct 2001 14:19:00 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1.50

Kenichi Handa <address@hidden> writes:

> Thank you!  With this, I found a bug in read1 (in lread.c).
> It was me who introduced this bug.  :-(

The only way not to make mistakes is to do nothing at all :-).

[...]

> Is this information enough?  Gerd, could you install a
> proper fix?
> 
I think this copes with the buffer reallocation, but the reallocation
isn't triggered with the elc files, and the result is identical to
what it was before (same backtrace etc.).  Could you please check
if I've made a stupid mistake here?


*** lread.c.~1.263.~    Tue Oct 23 16:07:29 2001
--- lread.c     Tue Oct 30 14:14:00 2001
***************
*** 193,198 ****
--- 193,199 ----
  
  static Lisp_Object Vbytecomp_version_regexp;
  
+ static void to_multibyte P_ ((char **, char **, int *));
  static void readevalloop P_ ((Lisp_Object, FILE*, Lisp_Object, 
                              Lisp_Object (*) (), int,
                              Lisp_Object, Lisp_Object));
***************
*** 1769,1774 ****
--- 1770,1812 ----
  }
  
  
+ /* Convert unibyte text in read_buffer to multibyte.
+ 
+    Initially, *P is a pointer after the end of the unibyte text, and
+    the pointer *END points after the end of read_buffer.
+ 
+    If read_buffer doesn't have enough room to hold the result
+    of the conversion, reallocate it and adjust *P and *END.
+ 
+    At the end, make *P point after the result of the conversion, and
+    return in *NCHARS the number of characters in the converted
+    text.  */
+ 
+ static void
+ to_multibyte (p, end, nchars)
+      char **p, **end;
+      int *nchars;
+ {
+   int nbytes;
+ 
+   parse_str_as_multibyte (read_buffer, *p - read_buffer, &nbytes, nchars);
+   if (nbytes > read_buffer_size)
+     {
+       int offset = *p - read_buffer;
+       read_buffer_size *= 2;
+       read_buffer = (char *) xrealloc (read_buffer, read_buffer_size);
+       *p = read_buffer + offset;
+       *end = read_buffer + read_buffer_size;
+     }
+ 
+   if (nbytes != *nchars)
+     nbytes = str_as_multibyte (read_buffer, read_buffer_size,
+                              *p - read_buffer, nchars);
+   
+   *p = read_buffer + nbytes;
+ }
+ 
+ 
  /* If the next token is ')' or ']' or '.', we store that character
     in *PCH and the return value is not interesting.  Else, we store
     zero in *PCH and we read and return one lisp object.
***************
*** 2122,2129 ****
  
      case '"':
        {
!       register char *p = read_buffer;
!       register char *end = read_buffer + read_buffer_size;
        register int c;
        /* Nonzero if we saw an escape sequence specifying
           a multibyte character.  */
--- 2160,2167 ----
  
      case '"':
        {
!       char *p = read_buffer;
!       char *end = read_buffer + read_buffer_size;
        register int c;
        /* Nonzero if we saw an escape sequence specifying
           a multibyte character.  */
***************
*** 2208,2222 ****
          return make_number (0);
  
        if (force_multibyte)
!         p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
!                                             p - read_buffer, &nchars);
        else if (force_singlebyte)
          nchars = p - read_buffer;
        else if (load_convert_to_unibyte)
          {
            Lisp_Object string;
!           p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
!                                               p - read_buffer, &nchars);
            if (p - read_buffer != nchars)
              {
                string = make_multibyte_string (read_buffer, nchars,
--- 2246,2258 ----
          return make_number (0);
  
        if (force_multibyte)
!         to_multibyte (&p, &end, &nchars);
        else if (force_singlebyte)
          nchars = p - read_buffer;
        else if (load_convert_to_unibyte)
          {
            Lisp_Object string;
!           to_multibyte (&p, &end, &nchars);
            if (p - read_buffer != nchars)
              {
                string = make_multibyte_string (read_buffer, nchars,
***************
*** 2226,2238 ****
          }
        else if (EQ (readcharfun, Qget_file_char)
                 || EQ (readcharfun, Qlambda))
!         /* Nowadays, reading directly from a file is used only for
!            compiled Emacs Lisp files, and those always use the
!            Emacs internal encoding.  Meanwhile, Qlambda is used
!            for reading dynamic byte code (compiled with
!            byte-compile-dynamic = t).  */
!         p = read_buffer + str_as_multibyte (read_buffer, end - read_buffer,
!                                             p - read_buffer, &nchars);
        else
          /* In all other cases, if we read these bytes as
             separate characters, treat them as separate characters now.  */
--- 2262,2275 ----
          }
        else if (EQ (readcharfun, Qget_file_char)
                 || EQ (readcharfun, Qlambda))
!         {
!           /* Nowadays, reading directly from a file is used only for
!              compiled Emacs Lisp files, and those always use the
!              Emacs internal encoding.  Meanwhile, Qlambda is used
!              for reading dynamic byte code (compiled with
!              byte-compile-dynamic = t).  */
!           to_multibyte (&p, &end, &nchars);
!         }
        else
          /* In all other cases, if we read these bytes as
             separate characters, treat them as separate characters now.  */



reply via email to

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