Commits

Fred Drake committed dca9bdf

Remove requirement for strdup() since it causes so many troubles for too many
platforms. Argh!

Comments (0)

Files changed (1)

Modules/parsermodule.c

 					/* ISTERMINAL() / ISNONTERMINAL() */
 #include "compile.h"			/* PyNode_Compile()		  */
 
-#ifndef MS_WINDOWS
-char *strdup();
-#endif
 
 /*  String constants used to initialize module attributes.
  *
 	    if (check_terminal_tuple(elem)) {
 		PyObject *temp = PySequence_GetItem(elem, 1);
 
-		strn = strdup(PyString_AsString(temp));
+		/* check_terminal_tuple() already verified it's a string */
+		strn = (char *)malloc(PyString_GET_SIZE(temp) + 1);
+		if (strn != NULL)
+		    strcpy(strn, PyString_AS_STRING(temp));
 		Py_XDECREF(temp);
 
 		if (PyObject_Length(elem) == 3) {