Make read1 more reentrant
commitf0a1e9ec3fba3d5bea5bd62f525dba3fb005d1b1
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 8 Dec 2016 19:32:48 +0000 (8 11:32 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 8 Dec 2016 21:00:32 +0000 (8 13:00 -0800)
treed4d752498b6da8154e6d3cf8dfed94643ae67614
parent162ba405ac144c2a0cb6854f791ff7d3203b0e2f
Make read1 more reentrant

This is needed if ‘read’ is called soon after startup, before the
Unicode tables have been set up, and it reads a \N escape and
needs to look up a value the Unicode tables, a lookup that in turn
calls read1 recursively.  Although this change doesn’t make ‘read’
fully reentrant, it’s good enough to handle this case.
* src/lread.c (read_buffer_size, read_buffer): Remove static vars.
(grow_read_buffer): Revamp to use locals, not statics, and to
record memory allocation un the specpdl.  All callers changed.
(read1): Start with a stack-based buffer, and use the heap
only if the stack buffer is too small.  Use unbind_to to
free any heap buffer allocated.  Use bool for boolean.
Redo symbol loop so that only one call to grow_read_buffer
is needed.
(init_obarray): Remove no-longer-needed initialization.
src/lread.c