[Expat-discuss] Re-entrant

Rich Salz rsalz@zolera.com
Mon, 13 Aug 2001 11:14:05 -0400


Sorry, but that definition from HP is completely bogus.  First,
according to ISO C, the only safe thing to do from a signal handler is
set a variable of type sig_atomic_t.  Second, it's not what reentrant
means. :)

Informally, re-entrant means that it is safe to call the function while
an existing call is pending:  can I *re-enter* the function?  An
excellent example is yacc.  Yacc exports a single function yyparse(). 
Suppose a write a parser for some language, and that language has an
import statement.  Can my import handler call yyparse to parse the new
file, while the containing file is being parsed.  Is yyparse
re-entrant?  The answer is no, it's not.  Yacc stores its state in
internal global variables.

For another example, look at the C function "strtok."

I'm not sure what the answer is to expat, except that it usually doesn't
matter.  Rather than re-enter, the thing to do is create another parser
and have that parser do the "recursive" or "internal" work.

Hope this helps.
	/r$

-- 
Zolera Systems, Your Key to Online Integrity
Securing Web services: XML, SOAP, Dig-sig, Encryption
http://www.zolera.com