summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2004-02-07 13:53:46 (GMT)
committerSkip Montanaro <skip@pobox.com>2004-02-07 13:53:46 (GMT)
commitdb6080507d7b507cfe9aa524d012a96b5dfefc2d (patch)
tree593e10c5f3aa003380b0a31a923dc0c181ae1298 /Objects
parentf1afe6682c34044547c13e4e6f1f848bada236d6 (diff)
downloadcpython-db6080507d7b507cfe9aa524d012a96b5dfefc2d.zip
cpython-db6080507d7b507cfe9aa524d012a96b5dfefc2d.tar.gz
cpython-db6080507d7b507cfe9aa524d012a96b5dfefc2d.tar.bz2
Remove support for --without-universal-newlines (see PEP 11).
Diffstat (limited to 'Objects')
-rw-r--r--Objects/fileobject.c35
1 files changed, 0 insertions, 35 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 66e5f28..05c9f4a 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -41,13 +41,11 @@
#define FUNLOCKFILE(f)
#endif
-#ifdef WITH_UNIVERSAL_NEWLINES
/* Bits in f_newlinetypes */
#define NEWLINE_UNKNOWN 0 /* No newline seen, yet */
#define NEWLINE_CR 1 /* \r newline seen */
#define NEWLINE_LF 2 /* \n newline seen */
#define NEWLINE_CRLF 4 /* \r\n newline seen */
-#endif
FILE *
PyFile_AsFile(PyObject *f)
@@ -119,11 +117,9 @@ fill_file_fields(PyFileObject *f, FILE *fp, char *name, char *mode,
f->f_softspace = 0;
f->f_binary = strchr(mode,'b') != NULL;
f->f_buf = NULL;
-#ifdef WITH_UNIVERSAL_NEWLINES
f->f_univ_newline = (strchr(mode, 'U') != NULL);
f->f_newlinetypes = NEWLINE_UNKNOWN;
f->f_skipnextlf = 0;
-#endif
Py_INCREF(Py_None);
f->f_encoding = Py_None;
@@ -165,17 +161,8 @@ open_the_file(PyFileObject *f, char *name, char *mode)
else
#endif
{
-#ifdef WITH_UNIVERSAL_NEWLINES
if (strcmp(mode, "U") == 0 || strcmp(mode, "rU") == 0)
mode = "rb";
-#else
- /* Compatibility: specifying U in a Python without universal
- ** newlines is allowed, and the file is opened as a normal text
- ** file.
- */
- if (strcmp(mode, "U") == 0 || strcmp(mode, "rU") == 0)
- mode = "r";
-#endif
#ifdef MS_WINDOWS
if (PyUnicode_Check(f->f_name)) {
PyObject *wmode;
@@ -494,9 +481,7 @@ file_seek(PyFileObject *f, PyObject *args)
clearerr(f->f_fp);
return NULL;
}
-#ifdef WITH_UNIVERSAL_NEWLINES
f->f_skipnextlf = 0;
-#endif
Py_INCREF(Py_None);
return Py_None;
}
@@ -629,7 +614,6 @@ file_tell(PyFileObject *f)
clearerr(f->f_fp);
return NULL;
}
-#ifdef WITH_UNIVERSAL_NEWLINES
if (f->f_skipnextlf) {
int c;
c = GETC(f->f_fp);
@@ -638,7 +622,6 @@ file_tell(PyFileObject *f)
f->f_skipnextlf = 0;
} else if (c != EOF) ungetc(c, f->f_fp);
}
-#endif
#if !defined(HAVE_LARGEFILE_SUPPORT)
return PyInt_FromLong(pos);
#else
@@ -1070,18 +1053,12 @@ get_line(PyFileObject *f, int n)
size_t used_v_size; /* # used slots in buffer */
size_t increment; /* amount to increment the buffer */
PyObject *v;
-#ifdef WITH_UNIVERSAL_NEWLINES
int newlinetypes = f->f_newlinetypes;
int skipnextlf = f->f_skipnextlf;
int univ_newline = f->f_univ_newline;
-#endif
#if defined(USE_FGETS_IN_GETLINE)
-#ifdef WITH_UNIVERSAL_NEWLINES
if (n <= 0 && !univ_newline )
-#else
- if (n <= 0)
-#endif
return getline_via_fgets(fp);
#endif
total_v_size = n > 0 ? n : 100;
@@ -1094,7 +1071,6 @@ get_line(PyFileObject *f, int n)
for (;;) {
Py_BEGIN_ALLOW_THREADS
FLOCKFILE(fp);
-#ifdef WITH_UNIVERSAL_NEWLINES
if (univ_newline) {
c = 'x'; /* Shut up gcc warning */
while ( buf != end && (c = GETC(fp)) != EOF ) {
@@ -1123,17 +1099,14 @@ get_line(PyFileObject *f, int n)
if ( c == EOF && skipnextlf )
newlinetypes |= NEWLINE_CR;
} else /* If not universal newlines use the normal loop */
-#endif
while ((c = GETC(fp)) != EOF &&
(*buf++ = c) != '\n' &&
buf != end)
;
FUNLOCKFILE(fp);
Py_END_ALLOW_THREADS
-#ifdef WITH_UNIVERSAL_NEWLINES
f->f_newlinetypes = newlinetypes;
f->f_skipnextlf = skipnextlf;
-#endif
if (c == '\n')
break;
if (c == EOF) {
@@ -1677,7 +1650,6 @@ get_closed(PyFileObject *f, void *closure)
{
return PyBool_FromLong((long)(f->f_fp == 0));
}
-#ifdef WITH_UNIVERSAL_NEWLINES
static PyObject *
get_newlines(PyFileObject *f, void *closure)
{
@@ -1706,14 +1678,11 @@ get_newlines(PyFileObject *f, void *closure)
return NULL;
}
}
-#endif
static PyGetSetDef file_getsetlist[] = {
{"closed", (getter)get_closed, NULL, "True if the file is closed"},
-#ifdef WITH_UNIVERSAL_NEWLINES
{"newlines", (getter)get_newlines, NULL,
"end-of-line convention used in this file"},
-#endif
{0},
};
@@ -1931,7 +1900,6 @@ PyDoc_STR(
"If the buffering argument is given, 0 means unbuffered, 1 means line\n"
"buffered, and larger numbers specify the buffer size.\n"
)
-#ifdef WITH_UNIVERSAL_NEWLINES
PyDoc_STR(
"Add a 'U' to mode to open the file for input with universal newline\n"
"support. Any line ending in the input file will be seen as a '\\n'\n"
@@ -1941,7 +1909,6 @@ PyDoc_STR(
"\n"
"'U' cannot be combined with 'w' or '+' mode.\n"
)
-#endif /* WITH_UNIVERSAL_NEWLINES */
PyDoc_STR(
"\n"
"Note: open() is an alias for file()."
@@ -2181,7 +2148,6 @@ int PyObject_AsFileDescriptor(PyObject *o)
return fd;
}
-#ifdef WITH_UNIVERSAL_NEWLINES
/* From here on we need access to the real fgets and fread */
#undef fgets
#undef fread
@@ -2359,4 +2325,3 @@ Py_UniversalNewlineFread(char *buf, size_t n,
f->f_skipnextlf = skipnextlf;
return dst - buf;
}
-#endif
T(configure())); addAction(configAction); addAction(quitAction); setContextMenuPolicy(Qt::ActionsContextMenu); setWindowTitle(tr("Traffic Info Oslo")); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(updateTimeInformation())); timer->start(1000*60*5); const QSettings settings("Qt Software", "trafficinfo"); m_station = StationInformation(settings.value("stationId", "03012130").toString(), settings.value("stationName", "Nydalen [T-bane] (OSL)").toString()); m_lines = settings.value("lines", QStringList()).toStringList(); updateTimeInformation(); } MainWindow::~MainWindow() { QSettings settings("Qt Software", "trafficinfo"); settings.setValue("stationId", m_station.id()); settings.setValue("stationName", m_station.name()); settings.setValue("lines", m_lines); } QSize MainWindow::sizeHint() const { return QSize(300, 200); } void MainWindow::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() & Qt::LeftButton) { move(event->globalPos() - m_dragPosition); event->accept(); } } void MainWindow::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { m_dragPosition = event->globalPos() - frameGeometry().topLeft(); event->accept(); } } void MainWindow::paintEvent(QPaintEvent*) { QLinearGradient gradient(QPoint(width()/2, 0), QPoint(width()/2, height())); const QColor qtGreen(102, 176, 54); gradient.setColorAt(0, qtGreen.dark()); gradient.setColorAt(0.5, qtGreen); gradient.setColorAt(1, qtGreen.dark()); QPainter p(this); p.fillRect(0, 0, width(), height(), gradient); QFont headerFont("Sans Serif", 12, QFont::Bold); QFont normalFont("Sans Serif", 9, QFont::Normal); // draw it twice for shadow effect p.setFont(headerFont); QRect headerRect(1, 1, width(), 25); p.setPen(Qt::black); p.drawText(headerRect, Qt::AlignCenter, m_station.name()); headerRect.moveTopLeft(QPoint(0, 0)); p.setPen(Qt::white); p.drawText(headerRect, Qt::AlignCenter, m_station.name()); p.setFont(normalFont); int pos = 40; for (int i = 0; i < m_times.count() && i < 9; ++i) { p.setPen(Qt::black); p.drawText(51, pos + 1, m_times.at(i).time()); p.drawText(101, pos + 1, m_times.at(i).direction()); p.setPen(Qt::white); p.drawText(50, pos, m_times.at(i).time()); p.drawText(100, pos, m_times.at(i).direction()); pos += 18; } } void MainWindow::resizeEvent(QResizeEvent*) { QBitmap maskBitmap(width(), height()); maskBitmap.clear(); QPainter p(&maskBitmap); p.setBrush(Qt::black); p.drawRoundRect(0, 0, width(), height(), 20, 30); p.end(); setMask(maskBitmap); } void MainWindow::updateTimeInformation() { TimeQuery query; m_times = query.query(m_station.id(), m_lines, QDateTime::currentDateTime()); update(); } void MainWindow::configure() { StationDialog dlg(m_station.name(), m_lines, this); if (dlg.exec()) { m_station = dlg.selectedStation(); m_lines = dlg.lineNumbers(); updateTimeInformation(); } }