Mercurial > cpython-lru_cache-weakref
annotate Parser/pgenmain.c @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | fd25030223b0 |
| children |
| rev | line source |
|---|---|
| 145 | 1 |
| 6 | 2 /* Parser generator main program */ |
| 3 | |
| 86 | 4 /* This expects a filename containing the grammar as argv[1] (UNIX) |
| 5 or asks the console for such a file name (THINK C). | |
| 6 It writes its output on two files in the current directory: | |
| 7 - "graminit.c" gets the grammar as a bunch of initialized data | |
| 8 - "graminit.h" gets the grammar's non-terminals as #defines. | |
| 9 Error messages and status info during the generation process are | |
| 10 written to stdout, or sometimes to stderr. */ | |
| 6 | 11 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
12 /* XXX TO DO: |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
13 - check for duplicate definitions of names (instead of fatal err) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
14 */ |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
15 |
|
23029
8291473fde3e
Mass checkin of universal newline support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19867
diff
changeset
|
16 #include "Python.h" |
| 86 | 17 #include "pgenheaders.h" |
| 6 | 18 #include "grammar.h" |
| 19 #include "node.h" | |
| 20 #include "parsetok.h" | |
| 21 #include "pgen.h" | |
| 22 | |
|
5379
1c9a84e0981d
Another directory quickly renamed.
Guido van Rossum <guido@python.org>
parents:
4577
diff
changeset
|
23 int Py_DebugFlag; |
|
7963
afd54f895dc3
Add dummy Py_VerboseFlag now that it's referenced in parsetok.c.
Guido van Rossum <guido@python.org>
parents:
5379
diff
changeset
|
24 int Py_VerboseFlag; |
|
23593
c844fcc3c952
Add definition of Py_IgnoreEnvironmentFlag (needed at least in debug
Guido van Rossum <guido@python.org>
parents:
23029
diff
changeset
|
25 int Py_IgnoreEnvironmentFlag; |
| 6 | 26 |
| 86 | 27 /* Forward */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
28 grammar *getgrammar(char *filename); |
| 6 | 29 |
|
1319
cd397266dc1c
* Makefile: added all: and default: targets.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
30 void |
| 13659 | 31 Py_Exit(int sts) |
|
1319
cd397266dc1c
* Makefile: added all: and default: targets.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
32 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
33 exit(sts); |
|
1319
cd397266dc1c
* Makefile: added all: and default: targets.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
34 } |
|
cd397266dc1c
* Makefile: added all: and default: targets.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
35 |
| 86 | 36 int |
| 13659 | 37 main(int argc, char **argv) |
| 6 | 38 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
39 grammar *g; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
40 FILE *fp; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
41 char *filename, *graminit_h, *graminit_c; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
42 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
43 if (argc != 4) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
44 fprintf(stderr, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
45 "usage: %s grammar graminit.h graminit.c\n", argv[0]); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
46 Py_Exit(2); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
47 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
48 filename = argv[1]; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
49 graminit_h = argv[2]; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
50 graminit_c = argv[3]; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
51 g = getgrammar(filename); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
52 fp = fopen(graminit_c, "w"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
53 if (fp == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
54 perror(graminit_c); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
55 Py_Exit(1); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
56 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
57 if (Py_DebugFlag) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
58 printf("Writing %s ...\n", graminit_c); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
59 printgrammar(g, fp); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
60 fclose(fp); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
61 fp = fopen(graminit_h, "w"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
62 if (fp == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
63 perror(graminit_h); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
64 Py_Exit(1); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
65 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
66 if (Py_DebugFlag) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
67 printf("Writing %s ...\n", graminit_h); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
68 printnonterminals(g, fp); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
69 fclose(fp); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
70 Py_Exit(0); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
71 return 0; /* Make gcc -Wall happy */ |
| 6 | 72 } |
| 73 | |
| 86 | 74 grammar * |
| 13659 | 75 getgrammar(char *filename) |
| 86 | 76 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
77 FILE *fp; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
78 node *n; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
79 grammar *g0, *g; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
80 perrdetail err; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
81 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
82 fp = fopen(filename, "r"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
83 if (fp == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
84 perror(filename); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
85 Py_Exit(1); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
86 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
87 g0 = meta_grammar(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
88 n = PyParser_ParseFile(fp, filename, g0, g0->g_start, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
89 (char *)NULL, (char *)NULL, &err); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
90 fclose(fp); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
91 if (n == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
92 fprintf(stderr, "Parsing error %d, line %d.\n", |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
93 err.error, err.lineno); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
94 if (err.text != NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
95 size_t i; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
96 fprintf(stderr, "%s", err.text); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
97 i = strlen(err.text); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
98 if (i == 0 || err.text[i-1] != '\n') |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
99 fprintf(stderr, "\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
100 for (i = 0; i < err.offset; i++) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
101 if (err.text[i] == '\t') |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
102 putc('\t', stderr); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
103 else |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
104 putc(' ', stderr); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
105 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
106 fprintf(stderr, "^\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
107 PyObject_FREE(err.text); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
108 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
109 Py_Exit(1); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
110 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
111 g = pgen(n); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
112 if (g == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
113 printf("Bad grammar.\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
114 Py_Exit(1); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
115 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
116 return g; |
| 86 | 117 } |
| 118 | |
|
35666
b8e571e6de2e
- Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
31471
diff
changeset
|
119 /* Can't happen in pgen */ |
|
b8e571e6de2e
- Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
31471
diff
changeset
|
120 PyObject* |
|
b8e571e6de2e
- Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
31471
diff
changeset
|
121 PyErr_Occurred() |
|
b8e571e6de2e
- Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
31471
diff
changeset
|
122 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
123 return 0; |
|
35666
b8e571e6de2e
- Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
31471
diff
changeset
|
124 } |
|
b8e571e6de2e
- Fix segfault with invalid coding.
Neal Norwitz <nnorwitz@gmail.com>
parents:
31471
diff
changeset
|
125 |
| 6 | 126 void |
|
24155
9456a2ccda61
The Py_REF_DEBUG/COUNT_ALLOCS/Py_TRACE_REFS macro minefield: added
Tim Peters <tim.peters@gmail.com>
parents:
23593
diff
changeset
|
127 Py_FatalError(const char *msg) |
| 6 | 128 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
129 fprintf(stderr, "pgen: FATAL ERROR: %s\n", msg); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
130 Py_Exit(1); |
| 6 | 131 } |
| 132 | |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
133 /* No-nonsense my_readline() for tokenizer.c */ |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
134 |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
135 char * |
|
25929
def9609d9369
Change PyOS_Readline declaration to match the recent change to myreadline.c
Skip Montanaro <skip@pobox.com>
parents:
24155
diff
changeset
|
136 PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
137 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
138 size_t n = 1000; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
139 char *p = (char *)PyMem_MALLOC(n); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
140 char *q; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
141 if (p == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
142 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
143 fprintf(stderr, "%s", prompt); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
144 q = fgets(p, n, sys_stdin); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
145 if (q == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
146 *p = '\0'; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
147 return p; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
148 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
149 n = strlen(p); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
150 if (n > 0 && p[n-1] != '\n') |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
151 p[n-1] = '\n'; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
152 return (char *)PyMem_REALLOC(p, n+1); |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
153 } |
|
9046
91d0860746fc
Add a version of PySys_WriteStderr() that writes to stderr, so we can
Guido van Rossum <guido@python.org>
parents:
7963
diff
changeset
|
154 |
|
23029
8291473fde3e
Mass checkin of universal newline support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19867
diff
changeset
|
155 /* No-nonsense fgets */ |
|
8291473fde3e
Mass checkin of universal newline support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19867
diff
changeset
|
156 char * |
|
8291473fde3e
Mass checkin of universal newline support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19867
diff
changeset
|
157 Py_UniversalNewlineFgets(char *buf, int n, FILE *stream, PyObject *fobj) |
|
8291473fde3e
Mass checkin of universal newline support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19867
diff
changeset
|
158 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
159 return fgets(buf, n, stream); |
|
23029
8291473fde3e
Mass checkin of universal newline support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19867
diff
changeset
|
160 } |
|
8291473fde3e
Mass checkin of universal newline support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19867
diff
changeset
|
161 |
|
8291473fde3e
Mass checkin of universal newline support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19867
diff
changeset
|
162 |
|
9046
91d0860746fc
Add a version of PySys_WriteStderr() that writes to stderr, so we can
Guido van Rossum <guido@python.org>
parents:
7963
diff
changeset
|
163 #include <stdarg.h> |
|
91d0860746fc
Add a version of PySys_WriteStderr() that writes to stderr, so we can
Guido van Rossum <guido@python.org>
parents:
7963
diff
changeset
|
164 |
|
91d0860746fc
Add a version of PySys_WriteStderr() that writes to stderr, so we can
Guido van Rossum <guido@python.org>
parents:
7963
diff
changeset
|
165 void |
|
91d0860746fc
Add a version of PySys_WriteStderr() that writes to stderr, so we can
Guido van Rossum <guido@python.org>
parents:
7963
diff
changeset
|
166 PySys_WriteStderr(const char *format, ...) |
|
91d0860746fc
Add a version of PySys_WriteStderr() that writes to stderr, so we can
Guido van Rossum <guido@python.org>
parents:
7963
diff
changeset
|
167 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
168 va_list va; |
|
9046
91d0860746fc
Add a version of PySys_WriteStderr() that writes to stderr, so we can
Guido van Rossum <guido@python.org>
parents:
7963
diff
changeset
|
169 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
170 va_start(va, format); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
171 vfprintf(stderr, format, va); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
37606
diff
changeset
|
172 va_end(va); |
|
9046
91d0860746fc
Add a version of PySys_WriteStderr() that writes to stderr, so we can
Guido van Rossum <guido@python.org>
parents:
7963
diff
changeset
|
173 } |
