comparison Python/pythonrun.c @ 65696:e8c8400caa99 3.1

Merged revisions 85817,85904 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85817 | benjamin.peterson | 2010-10-23 22:41:46 -0500 (Sat, 23 Oct 2010) | 1 line tighten loop ........ r85904 | benjamin.peterson | 2010-10-28 22:28:14 -0500 (Thu, 28 Oct 2010) | 1 line decrement offset when it points to a newline (#10186 followup) ........
author Benjamin Peterson <benjamin@python.org>
date Fri, 29 Oct 2010 04:02:30 +0000
parents 53639e57ba40
children b03779f00739
comparison
equal deleted inserted replaced
65690:c6d86439aa91 65696:e8c8400caa99
1297 static void 1297 static void
1298 print_error_text(PyObject *f, int offset, const char *text) 1298 print_error_text(PyObject *f, int offset, const char *text)
1299 { 1299 {
1300 char *nl; 1300 char *nl;
1301 if (offset >= 0) { 1301 if (offset >= 0) {
1302 if (offset > 0 && offset == strlen(text) && text[offset - 1] == '\n')
1303 offset--;
1302 for (;;) { 1304 for (;;) {
1303 nl = strchr(text, '\n'); 1305 nl = strchr(text, '\n');
1304 if (nl == NULL || nl-text >= offset) 1306 if (nl == NULL || nl-text >= offset)
1305 break; 1307 break;
1306 offset -= (int)(nl+1-text); 1308 offset -= (int)(nl+1-text);
1316 if (*text == '\0' || text[strlen(text)-1] != '\n') 1318 if (*text == '\0' || text[strlen(text)-1] != '\n')
1317 PyFile_WriteString("\n", f); 1319 PyFile_WriteString("\n", f);
1318 if (offset == -1) 1320 if (offset == -1)
1319 return; 1321 return;
1320 PyFile_WriteString(" ", f); 1322 PyFile_WriteString(" ", f);
1321 offset--; 1323 while (--offset > 0)
1322 while (offset > 0) {
1323 PyFile_WriteString(" ", f); 1324 PyFile_WriteString(" ", f);
1324 offset--;
1325 }
1326 PyFile_WriteString("^\n", f); 1325 PyFile_WriteString("^\n", f);
1327 } 1326 }
1328 1327
1329 static void 1328 static void
1330 handle_system_exit(void) 1329 handle_system_exit(void)