Staging
v0.5.1
v0.5.1
https://github.com/python/cpython
Revision d51ee54a232f4986abd18a4113f3af1158c2fd53 authored by Amaury Forgeot d'Arc on 06 July 2008, 21:37:52 UTC, committed by Amaury Forgeot d'Arc on 06 July 2008, 21:37:52 UTC
........ r64762 | amaury.forgeotdarc | 2008-07-06 23:34:39 +0200 (dim., 06 juil. 2008) | 8 lines Issue839496: SimpleHTTPServer should open all files in binary mode. Forward-port of 38255 (2005/01/15!) This was already fixed in 2.4, but never merged into trunk... py3k is already right, thanks to the bytes/str distinction! Should be backported to 2.5. ........
1 parent bfc644b
Tip revision: d51ee54a232f4986abd18a4113f3af1158c2fd53 authored by Amaury Forgeot d'Arc on 06 July 2008, 21:37:52 UTC
Blocked revisions 64762 via svnmerge
Blocked revisions 64762 via svnmerge
Tip revision: d51ee54
grammar1.c
/* Grammar subroutines needed by parser */
#include "Python.h"
#include "pgenheaders.h"
#include "grammar.h"
#include "token.h"
/* Return the DFA for the given type */
dfa *
PyGrammar_FindDFA(grammar *g, register int type)
{
register dfa *d;
#if 1
/* Massive speed-up */
d = &g->g_dfa[type - NT_OFFSET];
assert(d->d_type == type);
return d;
#else
/* Old, slow version */
register int i;
for (i = g->g_ndfas, d = g->g_dfa; --i >= 0; d++) {
if (d->d_type == type)
return d;
}
assert(0);
/* NOTREACHED */
#endif
}
char *
PyGrammar_LabelRepr(label *lb)
{
static char buf[100];
if (lb->lb_type == ENDMARKER)
return "EMPTY";
else if (ISNONTERMINAL(lb->lb_type)) {
if (lb->lb_str == NULL) {
PyOS_snprintf(buf, sizeof(buf), "NT%d", lb->lb_type);
return buf;
}
else
return lb->lb_str;
}
else {
if (lb->lb_str == NULL)
return _PyParser_TokenNames[lb->lb_type];
else {
PyOS_snprintf(buf, sizeof(buf), "%.32s(%.32s)",
_PyParser_TokenNames[lb->lb_type], lb->lb_str);
return buf;
}
}
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...