annotate Parser/listnode.c @ 65221:faa4e22aaba7 2.7

Blocked revisions 85322,85326 via svnmerge ........ r85322 | r.david.murray | 2010-10-08 11:55:28 -0400 (Fri, 08 Oct 2010) | 8 lines #4661: add bytes parsing and generation to email (email version bump to 5.1.0) The work on this is not 100% complete, but everything is present to allow real-world testing of the code. The only remaining major todo item is to (hopefully!) enhance the handling of non-ASCII bytes in headers converted to unicode by RFC2047 encoding them rather than replacing them with '?'s. ........ r85326 | r.david.murray | 2010-10-08 17:37:39 -0400 (Fri, 08 Oct 2010) | 2 lines What's new entry for email 5.1. ........
author R. David Murray <rdmurray@bitdance.com>
date Tue, 12 Oct 2010 14:16:46 +0000
parents fd25030223b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
1
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 /* List a node on a file */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
4 #include "pgenheaders.h"
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #include "token.h"
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 #include "node.h"
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
8 /* Forward */
13447
a89f7f268de4 Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents: 13256
diff changeset
9 static void list1node(FILE *, node *);
a89f7f268de4 Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents: 13256
diff changeset
10 static void listnode(FILE *, node *);
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
11
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
12 void
13659
e78153e179fb Mass ANSIfication.
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
13 PyNode_ListTree(node *n)
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
14 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
15 listnode(stdout, n);
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
16 }
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
17
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 static int level, atbol;
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
19
1318
92e6a8cf14be * pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
20 static void
13659
e78153e179fb Mass ANSIfication.
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
21 listnode(FILE *fp, node *n)
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
22 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
23 level = 0;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
24 atbol = 1;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
25 list1node(fp, n);
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
26 }
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 6
diff changeset
27
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 static void
13659
e78153e179fb Mass ANSIfication.
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
29 list1node(FILE *fp, node *n)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
31 if (n == 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
32 return;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
33 if (ISNONTERMINAL(TYPE(n))) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
34 int i;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
35 for (i = 0; i < NCH(n); i++)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
36 list1node(fp, CHILD(n, i));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
37 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
38 else if (ISTERMINAL(TYPE(n))) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
39 switch (TYPE(n)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
40 case INDENT:
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
41 ++level;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
42 break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
43 case DEDENT:
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
44 --level;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
45 break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
46 default:
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
47 if (atbol) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
48 int i;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
49 for (i = 0; i < level; ++i)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
50 fprintf(fp, "\t");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
51 atbol = 0;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
52 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
53 if (TYPE(n) == NEWLINE) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
54 if (STR(n) != NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
55 fprintf(fp, "%s", STR(n));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
56 fprintf(fp, "\n");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
57 atbol = 1;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
58 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
59 else
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
60 fprintf(fp, "%s ", STR(n));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
61 break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
62 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
63 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
64 else
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 14375
diff changeset
65 fprintf(fp, "? ");
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 }