[Python-checkins] python/dist/src/Python bltinmodule.c,2.262,2.263

loewis@users.sourceforge.net loewis@users.sourceforge.net
Wed, 14 Aug 2002 08:46:04 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv28831/Python

Modified Files:
	bltinmodule.c 
Log Message:
Patch #550192: Set softspace to 0 in raw_input().


Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.262
retrieving revision 2.263
diff -C2 -d -r2.262 -r2.263
*** bltinmodule.c	11 Aug 2002 12:23:04 -0000	2.262
--- bltinmodule.c	14 Aug 2002 15:46:02 -0000	2.263
***************
*** 1290,1299 ****
  {
  	PyObject *v = NULL;
! 	PyObject *f;
  
  	if (!PyArg_ParseTuple(args, "|O:[raw_]input", &v))
  		return NULL;
! 	if (PyFile_AsFile(PySys_GetObject("stdin")) == stdin &&
! 	    PyFile_AsFile(PySys_GetObject("stdout")) == stdout &&
  	    isatty(fileno(stdin)) && isatty(fileno(stdout))) {
  		PyObject *po;
--- 1290,1312 ----
  {
  	PyObject *v = NULL;
! 	PyObject *fin = PySys_GetObject("stdin");
! 	PyObject *fout = PySys_GetObject("stdout");
  
  	if (!PyArg_ParseTuple(args, "|O:[raw_]input", &v))
  		return NULL;
! 
! 	if (fin == NULL) {
! 		PyErr_SetString(PyExc_RuntimeError, "lost sys.stdin");
! 		return NULL;
! 	}
! 	if (fout == NULL) {
! 		PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
! 		return NULL;
! 	}
! 	if (PyFile_SoftSpace(fout, 0)) {
! 		if (PyFile_WriteString(" ", fout) != 0)
! 			return NULL;
! 	}
! 	if (PyFile_AsFile(fin) == stdin && PyFile_AsFile(fout) == stdout &&
  	    isatty(fileno(stdin)) && isatty(fileno(stdout))) {
  		PyObject *po;
***************
*** 1326,1334 ****
  			size_t len = strlen(s);
  			if (len > INT_MAX) {
! 				PyErr_SetString(PyExc_OverflowError, "input too long");
  				result = NULL;
  			}
  			else {
! 				result = PyString_FromStringAndSize(s, (int)(len-1));
  			}
  		}
--- 1339,1349 ----
  			size_t len = strlen(s);
  			if (len > INT_MAX) {
! 				PyErr_SetString(PyExc_OverflowError,
! 						"input too long");
  				result = NULL;
  			}
  			else {
! 				result = PyString_FromStringAndSize(s,
! 								(int)(len-1));
  			}
  		}
***************
*** 1337,1355 ****
  	}
  	if (v != NULL) {
! 		f = PySys_GetObject("stdout");
! 		if (f == NULL) {
! 			PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
! 			return NULL;
! 		}
! 		if (Py_FlushLine() != 0 ||
! 		    PyFile_WriteObject(v, f, Py_PRINT_RAW) != 0)
  			return NULL;
  	}
! 	f = PySys_GetObject("stdin");
! 	if (f == NULL) {
! 		PyErr_SetString(PyExc_RuntimeError, "lost sys.stdin");
! 		return NULL;
! 	}
! 	return PyFile_GetLine(f, -1);
  }
  
--- 1352,1359 ----
  	}
  	if (v != NULL) {
! 		if (PyFile_WriteObject(v, fout, Py_PRINT_RAW) != 0)
  			return NULL;
  	}
! 	return PyFile_GetLine(fin, -1);
  }