comparison src/lread.c @ 55158:e69f42e233dc

(read1): Use BOOL_VECTOR_BITS_PER_CHAR instead of BITS_PER_CHAR for bool vectors.
author Andreas Schwab <schwab@suse.de>
date Mon, 26 Apr 2004 21:28:40 +0000
parents f78c7b75f616
children a65f6f256839 1a68e4b22355 4c90ffeb71c5
comparison
equal deleted inserted replaced
55157:2a1571603eac 55158:e69f42e233dc
1991 length = read1 (readcharfun, pch, first_in_list); 1991 length = read1 (readcharfun, pch, first_in_list);
1992 c = READCHAR; 1992 c = READCHAR;
1993 if (c == '"') 1993 if (c == '"')
1994 { 1994 {
1995 Lisp_Object tmp, val; 1995 Lisp_Object tmp, val;
1996 int size_in_chars = ((XFASTINT (length) + BITS_PER_CHAR - 1) 1996 int size_in_chars
1997 / BITS_PER_CHAR); 1997 = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1)
1998 / BOOL_VECTOR_BITS_PER_CHAR);
1998 1999
1999 UNREAD (c); 2000 UNREAD (c);
2000 tmp = read1 (readcharfun, pch, first_in_list); 2001 tmp = read1 (readcharfun, pch, first_in_list);
2001 if (size_in_chars != SCHARS (tmp) 2002 if (size_in_chars != SCHARS (tmp)
2002 /* We used to print 1 char too many 2003 /* We used to print 1 char too many
2003 when the number of bits was a multiple of 8. 2004 when the number of bits was a multiple of 8.
2004 Accept such input in case it came from an old version. */ 2005 Accept such input in case it came from an old version. */
2005 && ! (XFASTINT (length) 2006 && ! (XFASTINT (length)
2006 == (SCHARS (tmp) - 1) * BITS_PER_CHAR)) 2007 == (SCHARS (tmp) - 1) * BOOL_VECTOR_BITS_PER_CHAR))
2007 Fsignal (Qinvalid_read_syntax, 2008 Fsignal (Qinvalid_read_syntax,
2008 Fcons (make_string ("#&...", 5), Qnil)); 2009 Fcons (make_string ("#&...", 5), Qnil));
2009 2010
2010 val = Fmake_bool_vector (length, Qnil); 2011 val = Fmake_bool_vector (length, Qnil);
2011 bcopy (SDATA (tmp), XBOOL_VECTOR (val)->data, 2012 bcopy (SDATA (tmp), XBOOL_VECTOR (val)->data,
2012 size_in_chars); 2013 size_in_chars);
2013 /* Clear the extraneous bits in the last byte. */ 2014 /* Clear the extraneous bits in the last byte. */
2014 if (XINT (length) != size_in_chars * BITS_PER_CHAR) 2015 if (XINT (length) != size_in_chars * BOOL_VECTOR_BITS_PER_CHAR)
2015 XBOOL_VECTOR (val)->data[size_in_chars - 1] 2016 XBOOL_VECTOR (val)->data[size_in_chars - 1]
2016 &= (1 << (XINT (length) % BITS_PER_CHAR)) - 1; 2017 &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
2017 return val; 2018 return val;
2018 } 2019 }
2019 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#&...", 5), 2020 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#&...", 5),
2020 Qnil)); 2021 Qnil));
2021 } 2022 }