comparison Modules/parsermodule.c @ 6469:dca9bdf5ea08 legacy-trunk

Remove requirement for strdup() since it causes so many troubles for too many platforms. Argh!
author Fred Drake <fdrake@acm.org>
date Thu, 09 Oct 1997 16:29:31 +0000
parents c142eb533fb9
children f42b757755eb
comparison
equal deleted inserted replaced
6468:103c63983cdf 6469:dca9bdf5ea08
24 #include "node.h" /* internal parser structure */ 24 #include "node.h" /* internal parser structure */
25 #include "token.h" /* token definitions */ 25 #include "token.h" /* token definitions */
26 /* ISTERMINAL() / ISNONTERMINAL() */ 26 /* ISTERMINAL() / ISNONTERMINAL() */
27 #include "compile.h" /* PyNode_Compile() */ 27 #include "compile.h" /* PyNode_Compile() */
28 28
29 #ifndef MS_WINDOWS
30 char *strdup();
31 #endif
32 29
33 /* String constants used to initialize module attributes. 30 /* String constants used to initialize module attributes.
34 * 31 *
35 */ 32 */
36 static char* 33 static char*
745 } 742 }
746 if (ISTERMINAL(type)) { 743 if (ISTERMINAL(type)) {
747 if (check_terminal_tuple(elem)) { 744 if (check_terminal_tuple(elem)) {
748 PyObject *temp = PySequence_GetItem(elem, 1); 745 PyObject *temp = PySequence_GetItem(elem, 1);
749 746
750 strn = strdup(PyString_AsString(temp)); 747 /* check_terminal_tuple() already verified it's a string */
748 strn = (char *)malloc(PyString_GET_SIZE(temp) + 1);
749 if (strn != NULL)
750 strcpy(strn, PyString_AS_STRING(temp));
751 Py_XDECREF(temp); 751 Py_XDECREF(temp);
752 752
753 if (PyObject_Length(elem) == 3) { 753 if (PyObject_Length(elem) == 3) {
754 PyObject* temp = PySequence_GetItem(elem, 2); 754 PyObject* temp = PySequence_GetItem(elem, 2);
755 *line_num = PyInt_AsLong(temp); 755 *line_num = PyInt_AsLong(temp);