Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Modules/termios.c

    r2 r391  
    4545static int fdconv(PyObject* obj, void* p)
    4646{
    47         int fd;
    48 
    49         fd = PyObject_AsFileDescriptor(obj);
    50         if (fd >= 0) {
    51                 *(int*)p = fd;
    52                 return 1;
    53         }
    54         return 0;
     47    int fd;
     48
     49    fd = PyObject_AsFileDescriptor(obj);
     50    if (fd >= 0) {
     51        *(int*)p = fd;
     52        return 1;
     53    }
     54    return 0;
    5555}
    5656
     
    6969termios_tcgetattr(PyObject *self, PyObject *args)
    7070{
    71         int fd;
    72         struct termios mode;
    73         PyObject *cc;
    74         speed_t ispeed, ospeed;
    75         PyObject *v;
    76         int i;
    77         char ch;
    78 
    79         if (!PyArg_ParseTuple(args, "O&:tcgetattr",
    80                               fdconv, (void*)&fd))
    81                 return NULL;
    82 
    83         if (tcgetattr(fd, &mode) == -1)
    84                 return PyErr_SetFromErrno(TermiosError);
    85 
    86         ispeed = cfgetispeed(&mode);
    87         ospeed = cfgetospeed(&mode);
    88 
    89         cc = PyList_New(NCCS);
    90         if (cc == NULL)
    91                 return NULL;
    92         for (i = 0; i < NCCS; i++) {
    93                 ch = (char)mode.c_cc[i];
    94                 v = PyString_FromStringAndSize(&ch, 1);
    95                 if (v == NULL)
    96                         goto err;
    97                 PyList_SetItem(cc, i, v);
    98         }
    99 
    100         /* Convert the MIN and TIME slots to integer.  On some systems, the
    101            MIN and TIME slots are the same as the EOF and EOL slots.  So we
    102            only do this in noncanonical input mode.  */
    103         if ((mode.c_lflag & ICANON) == 0) {
    104                 v = PyInt_FromLong((long)mode.c_cc[VMIN]);
    105                 if (v == NULL)
    106                         goto err;
    107                 PyList_SetItem(cc, VMIN, v);
    108                 v = PyInt_FromLong((long)mode.c_cc[VTIME]);
    109                 if (v == NULL)
    110                         goto err;
    111                 PyList_SetItem(cc, VTIME, v);
    112         }
    113 
    114         if (!(v = PyList_New(7)))
    115                 goto err;
    116 
    117         PyList_SetItem(v, 0, PyInt_FromLong((long)mode.c_iflag));
    118         PyList_SetItem(v, 1, PyInt_FromLong((long)mode.c_oflag));
    119         PyList_SetItem(v, 2, PyInt_FromLong((long)mode.c_cflag));
    120         PyList_SetItem(v, 3, PyInt_FromLong((long)mode.c_lflag));
    121         PyList_SetItem(v, 4, PyInt_FromLong((long)ispeed));
    122         PyList_SetItem(v, 5, PyInt_FromLong((long)ospeed));
    123         PyList_SetItem(v, 6, cc);
    124         if (PyErr_Occurred()){
    125                 Py_DECREF(v);
    126                 goto err;
    127         }
    128         return v;
     71    int fd;
     72    struct termios mode;
     73    PyObject *cc;
     74    speed_t ispeed, ospeed;
     75    PyObject *v;
     76    int i;
     77    char ch;
     78
     79    if (!PyArg_ParseTuple(args, "O&:tcgetattr",
     80                          fdconv, (void*)&fd))
     81        return NULL;
     82
     83    if (tcgetattr(fd, &mode) == -1)
     84        return PyErr_SetFromErrno(TermiosError);
     85
     86    ispeed = cfgetispeed(&mode);
     87    ospeed = cfgetospeed(&mode);
     88
     89    cc = PyList_New(NCCS);
     90    if (cc == NULL)
     91        return NULL;
     92    for (i = 0; i < NCCS; i++) {
     93        ch = (char)mode.c_cc[i];
     94        v = PyString_FromStringAndSize(&ch, 1);
     95        if (v == NULL)
     96            goto err;
     97        PyList_SetItem(cc, i, v);
     98    }
     99
     100    /* Convert the MIN and TIME slots to integer.  On some systems, the
     101       MIN and TIME slots are the same as the EOF and EOL slots.  So we
     102       only do this in noncanonical input mode.  */
     103    if ((mode.c_lflag & ICANON) == 0) {
     104        v = PyInt_FromLong((long)mode.c_cc[VMIN]);
     105        if (v == NULL)
     106            goto err;
     107        PyList_SetItem(cc, VMIN, v);
     108        v = PyInt_FromLong((long)mode.c_cc[VTIME]);
     109        if (v == NULL)
     110            goto err;
     111        PyList_SetItem(cc, VTIME, v);
     112    }
     113
     114    if (!(v = PyList_New(7)))
     115        goto err;
     116
     117    PyList_SetItem(v, 0, PyInt_FromLong((long)mode.c_iflag));
     118    PyList_SetItem(v, 1, PyInt_FromLong((long)mode.c_oflag));
     119    PyList_SetItem(v, 2, PyInt_FromLong((long)mode.c_cflag));
     120    PyList_SetItem(v, 3, PyInt_FromLong((long)mode.c_lflag));
     121    PyList_SetItem(v, 4, PyInt_FromLong((long)ispeed));
     122    PyList_SetItem(v, 5, PyInt_FromLong((long)ospeed));
     123    PyList_SetItem(v, 6, cc);
     124    if (PyErr_Occurred()){
     125        Py_DECREF(v);
     126        goto err;
     127    }
     128    return v;
    129129  err:
    130         Py_DECREF(cc);
    131         return NULL;
     130    Py_DECREF(cc);
     131    return NULL;
    132132}
    133133
     
    146146termios_tcsetattr(PyObject *self, PyObject *args)
    147147{
    148         int fd, when;
    149         struct termios mode;
    150         speed_t ispeed, ospeed;
    151         PyObject *term, *cc, *v;
    152         int i;
    153 
    154         if (!PyArg_ParseTuple(args, "O&iO:tcsetattr",
    155                               fdconv, &fd, &when, &term))
    156                 return NULL;
    157         if (!PyList_Check(term) || PyList_Size(term) != 7) {
    158                 PyErr_SetString(PyExc_TypeError,
    159                              "tcsetattr, arg 3: must be 7 element list");
    160                 return NULL;
    161         }
    162 
    163         /* Get the old mode, in case there are any hidden fields... */
    164         if (tcgetattr(fd, &mode) == -1)
    165                 return PyErr_SetFromErrno(TermiosError);
    166         mode.c_iflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 0));
    167         mode.c_oflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 1));
    168         mode.c_cflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 2));
    169         mode.c_lflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 3));
    170         ispeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 4));
    171         ospeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 5));
    172         cc = PyList_GetItem(term, 6);
    173         if (PyErr_Occurred())
    174                 return NULL;
    175 
    176         if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) {
    177                 PyErr_Format(PyExc_TypeError,
    178                         "tcsetattr: attributes[6] must be %d element list",
    179                              NCCS);
    180                 return NULL;
    181         }
    182 
    183         for (i = 0; i < NCCS; i++) {
    184                 v = PyList_GetItem(cc, i);
    185 
    186                 if (PyString_Check(v) && PyString_Size(v) == 1)
    187                         mode.c_cc[i] = (cc_t) * PyString_AsString(v);
    188                 else if (PyInt_Check(v))
    189                         mode.c_cc[i] = (cc_t) PyInt_AsLong(v);
    190                 else {
    191                         PyErr_SetString(PyExc_TypeError,
     148    int fd, when;
     149    struct termios mode;
     150    speed_t ispeed, ospeed;
     151    PyObject *term, *cc, *v;
     152    int i;
     153
     154    if (!PyArg_ParseTuple(args, "O&iO:tcsetattr",
     155                          fdconv, &fd, &when, &term))
     156        return NULL;
     157    if (!PyList_Check(term) || PyList_Size(term) != 7) {
     158        PyErr_SetString(PyExc_TypeError,
     159                     "tcsetattr, arg 3: must be 7 element list");
     160        return NULL;
     161    }
     162
     163    /* Get the old mode, in case there are any hidden fields... */
     164    if (tcgetattr(fd, &mode) == -1)
     165        return PyErr_SetFromErrno(TermiosError);
     166    mode.c_iflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 0));
     167    mode.c_oflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 1));
     168    mode.c_cflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 2));
     169    mode.c_lflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 3));
     170    ispeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 4));
     171    ospeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 5));
     172    cc = PyList_GetItem(term, 6);
     173    if (PyErr_Occurred())
     174        return NULL;
     175
     176    if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) {
     177        PyErr_Format(PyExc_TypeError,
     178            "tcsetattr: attributes[6] must be %d element list",
     179                 NCCS);
     180        return NULL;
     181    }
     182
     183    for (i = 0; i < NCCS; i++) {
     184        v = PyList_GetItem(cc, i);
     185
     186        if (PyString_Check(v) && PyString_Size(v) == 1)
     187            mode.c_cc[i] = (cc_t) * PyString_AsString(v);
     188        else if (PyInt_Check(v))
     189            mode.c_cc[i] = (cc_t) PyInt_AsLong(v);
     190        else {
     191            PyErr_SetString(PyExc_TypeError,
    192192     "tcsetattr: elements of attributes must be characters or integers");
    193                         return NULL;
    194                 }
    195         }
    196 
    197         if (cfsetispeed(&mode, (speed_t) ispeed) == -1)
    198                 return PyErr_SetFromErrno(TermiosError);
    199         if (cfsetospeed(&mode, (speed_t) ospeed) == -1)
    200                 return PyErr_SetFromErrno(TermiosError);
    201         if (tcsetattr(fd, when, &mode) == -1)
    202                 return PyErr_SetFromErrno(TermiosError);
    203 
    204         Py_INCREF(Py_None);
    205         return Py_None;
     193                        return NULL;
     194                }
     195    }
     196
     197    if (cfsetispeed(&mode, (speed_t) ispeed) == -1)
     198        return PyErr_SetFromErrno(TermiosError);
     199    if (cfsetospeed(&mode, (speed_t) ospeed) == -1)
     200        return PyErr_SetFromErrno(TermiosError);
     201    if (tcsetattr(fd, when, &mode) == -1)
     202        return PyErr_SetFromErrno(TermiosError);
     203
     204    Py_INCREF(Py_None);
     205    return Py_None;
    206206}
    207207
     
    216216termios_tcsendbreak(PyObject *self, PyObject *args)
    217217{
    218         int fd, duration;
    219 
    220         if (!PyArg_ParseTuple(args, "O&i:tcsendbreak",
    221                               fdconv, &fd, &duration))
    222                 return NULL;
    223         if (tcsendbreak(fd, duration) == -1)
    224                 return PyErr_SetFromErrno(TermiosError);
    225 
    226         Py_INCREF(Py_None);
    227         return Py_None;
     218    int fd, duration;
     219
     220    if (!PyArg_ParseTuple(args, "O&i:tcsendbreak",
     221                          fdconv, &fd, &duration))
     222        return NULL;
     223    if (tcsendbreak(fd, duration) == -1)
     224        return PyErr_SetFromErrno(TermiosError);
     225
     226    Py_INCREF(Py_None);
     227    return Py_None;
    228228}
    229229
     
    236236termios_tcdrain(PyObject *self, PyObject *args)
    237237{
    238         int fd;
    239 
    240         if (!PyArg_ParseTuple(args, "O&:tcdrain",
    241                               fdconv, &fd))
    242                 return NULL;
    243         if (tcdrain(fd) == -1)
    244                 return PyErr_SetFromErrno(TermiosError);
    245 
    246         Py_INCREF(Py_None);
    247         return Py_None;
     238    int fd;
     239
     240    if (!PyArg_ParseTuple(args, "O&:tcdrain",
     241                          fdconv, &fd))
     242        return NULL;
     243    if (tcdrain(fd) == -1)
     244        return PyErr_SetFromErrno(TermiosError);
     245
     246    Py_INCREF(Py_None);
     247    return Py_None;
    248248}
    249249
     
    259259termios_tcflush(PyObject *self, PyObject *args)
    260260{
    261         int fd, queue;
    262 
    263         if (!PyArg_ParseTuple(args, "O&i:tcflush",
    264                               fdconv, &fd, &queue))
    265                 return NULL;
    266         if (tcflush(fd, queue) == -1)
    267                 return PyErr_SetFromErrno(TermiosError);
    268 
    269         Py_INCREF(Py_None);
    270         return Py_None;
     261    int fd, queue;
     262
     263    if (!PyArg_ParseTuple(args, "O&i:tcflush",
     264                          fdconv, &fd, &queue))
     265        return NULL;
     266    if (tcflush(fd, queue) == -1)
     267        return PyErr_SetFromErrno(TermiosError);
     268
     269    Py_INCREF(Py_None);
     270    return Py_None;
    271271}
    272272
     
    282282termios_tcflow(PyObject *self, PyObject *args)
    283283{
    284         int fd, action;
    285 
    286         if (!PyArg_ParseTuple(args, "O&i:tcflow",
    287                               fdconv, &fd, &action))
    288                 return NULL;
    289         if (tcflow(fd, action) == -1)
    290                 return PyErr_SetFromErrno(TermiosError);
    291 
    292         Py_INCREF(Py_None);
    293         return Py_None;
     284    int fd, action;
     285
     286    if (!PyArg_ParseTuple(args, "O&i:tcflow",
     287                          fdconv, &fd, &action))
     288        return NULL;
     289    if (tcflow(fd, action) == -1)
     290        return PyErr_SetFromErrno(TermiosError);
     291
     292    Py_INCREF(Py_None);
     293    return Py_None;
    294294}
    295295
    296296static PyMethodDef termios_methods[] =
    297297{
    298         {"tcgetattr", termios_tcgetattr,
    299         METH_VARARGS, termios_tcgetattr__doc__},
    300         {"tcsetattr", termios_tcsetattr,
    301         METH_VARARGS, termios_tcsetattr__doc__},
    302         {"tcsendbreak", termios_tcsendbreak,
    303         METH_VARARGS, termios_tcsendbreak__doc__},
    304         {"tcdrain", termios_tcdrain,
    305         METH_VARARGS, termios_tcdrain__doc__},
    306         {"tcflush", termios_tcflush,
    307         METH_VARARGS, termios_tcflush__doc__},
    308         {"tcflow", termios_tcflow,
    309         METH_VARARGS, termios_tcflow__doc__},
    310         {NULL, NULL}
     298    {"tcgetattr", termios_tcgetattr,
     299    METH_VARARGS, termios_tcgetattr__doc__},
     300    {"tcsetattr", termios_tcsetattr,
     301    METH_VARARGS, termios_tcsetattr__doc__},
     302    {"tcsendbreak", termios_tcsendbreak,
     303    METH_VARARGS, termios_tcsendbreak__doc__},
     304    {"tcdrain", termios_tcdrain,
     305    METH_VARARGS, termios_tcdrain__doc__},
     306    {"tcflush", termios_tcflush,
     307    METH_VARARGS, termios_tcflush__doc__},
     308    {"tcflow", termios_tcflow,
     309    METH_VARARGS, termios_tcflow__doc__},
     310    {NULL, NULL}
    311311};
    312312
     
    321321
    322322static struct constant {
    323         char *name;
    324         long value;
     323    char *name;
     324    long value;
    325325} termios_constants[] = {
    326         /* cfgetospeed(), cfsetospeed() constants */
    327         {"B0", B0},
    328         {"B50", B50},
    329         {"B75", B75},
    330         {"B110", B110},
    331         {"B134", B134},
    332         {"B150", B150},
    333         {"B200", B200},
    334         {"B300", B300},
    335         {"B600", B600},
    336         {"B1200", B1200},
    337         {"B1800", B1800},
    338         {"B2400", B2400},
    339         {"B4800", B4800},
    340         {"B9600", B9600},
    341         {"B19200", B19200},
    342         {"B38400", B38400},
     326    /* cfgetospeed(), cfsetospeed() constants */
     327    {"B0", B0},
     328    {"B50", B50},
     329    {"B75", B75},
     330    {"B110", B110},
     331    {"B134", B134},
     332    {"B150", B150},
     333    {"B200", B200},
     334    {"B300", B300},
     335    {"B600", B600},
     336    {"B1200", B1200},
     337    {"B1800", B1800},
     338    {"B2400", B2400},
     339    {"B4800", B4800},
     340    {"B9600", B9600},
     341    {"B19200", B19200},
     342    {"B38400", B38400},
    343343#ifdef B57600
    344         {"B57600", B57600},
     344    {"B57600", B57600},
    345345#endif
    346346#ifdef B115200
    347         {"B115200", B115200},
     347    {"B115200", B115200},
    348348#endif
    349349#ifdef B230400
    350         {"B230400", B230400},
     350    {"B230400", B230400},
    351351#endif
    352352#ifdef CBAUDEX
    353         {"CBAUDEX", CBAUDEX},
    354 #endif
    355 
    356         /* tcsetattr() constants */
    357         {"TCSANOW", TCSANOW},
    358         {"TCSADRAIN", TCSADRAIN},
    359         {"TCSAFLUSH", TCSAFLUSH},
    360 
    361         /* tcflush() constants */
    362         {"TCIFLUSH", TCIFLUSH},
    363         {"TCOFLUSH", TCOFLUSH},
    364         {"TCIOFLUSH", TCIOFLUSH},
    365 
    366         /* tcflow() constants */
    367         {"TCOOFF", TCOOFF},
    368         {"TCOON", TCOON},
    369         {"TCIOFF", TCIOFF},
    370         {"TCION", TCION},
    371 
    372         /* struct termios.c_iflag constants */
    373         {"IGNBRK", IGNBRK},
    374         {"BRKINT", BRKINT},
    375         {"IGNPAR", IGNPAR},
    376         {"PARMRK", PARMRK},
    377         {"INPCK", INPCK},
    378         {"ISTRIP", ISTRIP},
    379         {"INLCR", INLCR},
    380         {"IGNCR", IGNCR},
    381         {"ICRNL", ICRNL},
     353    {"CBAUDEX", CBAUDEX},
     354#endif
     355
     356    /* tcsetattr() constants */
     357    {"TCSANOW", TCSANOW},
     358    {"TCSADRAIN", TCSADRAIN},
     359    {"TCSAFLUSH", TCSAFLUSH},
     360#ifdef TCSASOFT
     361    {"TCSASOFT", TCSASOFT},
     362#endif
     363
     364    /* tcflush() constants */
     365    {"TCIFLUSH", TCIFLUSH},
     366    {"TCOFLUSH", TCOFLUSH},
     367    {"TCIOFLUSH", TCIOFLUSH},
     368
     369    /* tcflow() constants */
     370    {"TCOOFF", TCOOFF},
     371    {"TCOON", TCOON},
     372    {"TCIOFF", TCIOFF},
     373    {"TCION", TCION},
     374
     375    /* struct termios.c_iflag constants */
     376    {"IGNBRK", IGNBRK},
     377    {"BRKINT", BRKINT},
     378    {"IGNPAR", IGNPAR},
     379    {"PARMRK", PARMRK},
     380    {"INPCK", INPCK},
     381    {"ISTRIP", ISTRIP},
     382    {"INLCR", INLCR},
     383    {"IGNCR", IGNCR},
     384    {"ICRNL", ICRNL},
    382385#ifdef IUCLC
    383         {"IUCLC", IUCLC},
    384 #endif
    385         {"IXON", IXON},
    386         {"IXANY", IXANY},
    387         {"IXOFF", IXOFF},
     386    {"IUCLC", IUCLC},
     387#endif
     388    {"IXON", IXON},
     389    {"IXANY", IXANY},
     390    {"IXOFF", IXOFF},
    388391#ifdef IMAXBEL
    389         {"IMAXBEL", IMAXBEL},
    390 #endif
    391 
    392         /* struct termios.c_oflag constants */
    393         {"OPOST", OPOST},
     392    {"IMAXBEL", IMAXBEL},
     393#endif
     394
     395    /* struct termios.c_oflag constants */
     396    {"OPOST", OPOST},
    394397#ifdef OLCUC
    395         {"OLCUC", OLCUC},
     398    {"OLCUC", OLCUC},
    396399#endif
    397400#ifdef ONLCR
    398         {"ONLCR", ONLCR},
     401    {"ONLCR", ONLCR},
    399402#endif
    400403#ifdef OCRNL
    401         {"OCRNL", OCRNL},
     404    {"OCRNL", OCRNL},
    402405#endif
    403406#ifdef ONOCR
    404         {"ONOCR", ONOCR},
     407    {"ONOCR", ONOCR},
    405408#endif
    406409#ifdef ONLRET
    407         {"ONLRET", ONLRET},
     410    {"ONLRET", ONLRET},
    408411#endif
    409412#ifdef OFILL
    410         {"OFILL", OFILL},
     413    {"OFILL", OFILL},
    411414#endif
    412415#ifdef OFDEL
    413         {"OFDEL", OFDEL},
     416    {"OFDEL", OFDEL},
    414417#endif
    415418#ifdef NLDLY
    416         {"NLDLY", NLDLY},
     419    {"NLDLY", NLDLY},
    417420#endif
    418421#ifdef CRDLY
    419         {"CRDLY", CRDLY},
     422    {"CRDLY", CRDLY},
    420423#endif
    421424#ifdef TABDLY
    422         {"TABDLY", TABDLY},
     425    {"TABDLY", TABDLY},
    423426#endif
    424427#ifdef BSDLY
    425         {"BSDLY", BSDLY},
     428    {"BSDLY", BSDLY},
    426429#endif
    427430#ifdef VTDLY
    428         {"VTDLY", VTDLY},
     431    {"VTDLY", VTDLY},
    429432#endif
    430433#ifdef FFDLY
    431         {"FFDLY", FFDLY},
    432 #endif
    433 
    434         /* struct termios.c_oflag-related values (delay mask) */
     434    {"FFDLY", FFDLY},
     435#endif
     436
     437    /* struct termios.c_oflag-related values (delay mask) */
    435438#ifdef NL0
    436         {"NL0", NL0},
     439    {"NL0", NL0},
    437440#endif
    438441#ifdef NL1
    439         {"NL1", NL1},
     442    {"NL1", NL1},
    440443#endif
    441444#ifdef CR0
    442         {"CR0", CR0},
     445    {"CR0", CR0},
    443446#endif
    444447#ifdef CR1
    445         {"CR1", CR1},
     448    {"CR1", CR1},
    446449#endif
    447450#ifdef CR2
    448         {"CR2", CR2},
     451    {"CR2", CR2},
    449452#endif
    450453#ifdef CR3
    451         {"CR3", CR3},
     454    {"CR3", CR3},
    452455#endif
    453456#ifdef TAB0
    454         {"TAB0", TAB0},
     457    {"TAB0", TAB0},
    455458#endif
    456459#ifdef TAB1
    457         {"TAB1", TAB1},
     460    {"TAB1", TAB1},
    458461#endif
    459462#ifdef TAB2
    460         {"TAB2", TAB2},
     463    {"TAB2", TAB2},
    461464#endif
    462465#ifdef TAB3
    463         {"TAB3", TAB3},
     466    {"TAB3", TAB3},
    464467#endif
    465468#ifdef XTABS
    466         {"XTABS", XTABS},
     469    {"XTABS", XTABS},
    467470#endif
    468471#ifdef BS0
    469         {"BS0", BS0},
     472    {"BS0", BS0},
    470473#endif
    471474#ifdef BS1
    472         {"BS1", BS1},
     475    {"BS1", BS1},
    473476#endif
    474477#ifdef VT0
    475         {"VT0", VT0},
     478    {"VT0", VT0},
    476479#endif
    477480#ifdef VT1
    478         {"VT1", VT1},
     481    {"VT1", VT1},
    479482#endif
    480483#ifdef FF0
    481         {"FF0", FF0},
     484    {"FF0", FF0},
    482485#endif
    483486#ifdef FF1
    484         {"FF1", FF1},
    485 #endif
    486 
    487         /* struct termios.c_cflag constants */
    488         {"CSIZE", CSIZE},
    489         {"CSTOPB", CSTOPB},
    490         {"CREAD", CREAD},
    491         {"PARENB", PARENB},
    492         {"PARODD", PARODD},
    493         {"HUPCL", HUPCL},
    494         {"CLOCAL", CLOCAL},
     487    {"FF1", FF1},
     488#endif
     489
     490    /* struct termios.c_cflag constants */
     491    {"CSIZE", CSIZE},
     492    {"CSTOPB", CSTOPB},
     493    {"CREAD", CREAD},
     494    {"PARENB", PARENB},
     495    {"PARODD", PARODD},
     496    {"HUPCL", HUPCL},
     497    {"CLOCAL", CLOCAL},
    495498#ifdef CIBAUD
    496         {"CIBAUD", CIBAUD},
     499    {"CIBAUD", CIBAUD},
    497500#endif
    498501#ifdef CRTSCTS
    499         {"CRTSCTS", (long)CRTSCTS},
    500 #endif
    501 
    502         /* struct termios.c_cflag-related values (character size) */
    503         {"CS5", CS5},
    504         {"CS6", CS6},
    505         {"CS7", CS7},
    506         {"CS8", CS8},
    507 
    508         /* struct termios.c_lflag constants */
    509         {"ISIG", ISIG},
    510         {"ICANON", ICANON},
     502    {"CRTSCTS", (long)CRTSCTS},
     503#endif
     504
     505    /* struct termios.c_cflag-related values (character size) */
     506    {"CS5", CS5},
     507    {"CS6", CS6},
     508    {"CS7", CS7},
     509    {"CS8", CS8},
     510
     511    /* struct termios.c_lflag constants */
     512    {"ISIG", ISIG},
     513    {"ICANON", ICANON},
    511514#ifdef XCASE
    512         {"XCASE", XCASE},
    513 #endif
    514         {"ECHO", ECHO},
    515         {"ECHOE", ECHOE},
    516         {"ECHOK", ECHOK},
    517         {"ECHONL", ECHONL},
     515    {"XCASE", XCASE},
     516#endif
     517    {"ECHO", ECHO},
     518    {"ECHOE", ECHOE},
     519    {"ECHOK", ECHOK},
     520    {"ECHONL", ECHONL},
    518521#ifdef ECHOCTL
    519         {"ECHOCTL", ECHOCTL},
     522    {"ECHOCTL", ECHOCTL},
    520523#endif
    521524#ifdef ECHOPRT
    522         {"ECHOPRT", ECHOPRT},
     525    {"ECHOPRT", ECHOPRT},
    523526#endif
    524527#ifdef ECHOKE
    525         {"ECHOKE", ECHOKE},
     528    {"ECHOKE", ECHOKE},
    526529#endif
    527530#ifdef FLUSHO
    528         {"FLUSHO", FLUSHO},
    529 #endif
    530         {"NOFLSH", NOFLSH},
    531         {"TOSTOP", TOSTOP},
     531    {"FLUSHO", FLUSHO},
     532#endif
     533    {"NOFLSH", NOFLSH},
     534    {"TOSTOP", TOSTOP},
    532535#ifdef PENDIN
    533         {"PENDIN", PENDIN},
    534 #endif
    535         {"IEXTEN", IEXTEN},
    536 
    537         /* indexes into the control chars array returned by tcgetattr() */
    538         {"VINTR", VINTR},
    539         {"VQUIT", VQUIT},
    540         {"VERASE", VERASE},
    541         {"VKILL", VKILL},
    542         {"VEOF", VEOF},
    543         {"VTIME", VTIME},
    544         {"VMIN", VMIN},
     536    {"PENDIN", PENDIN},
     537#endif
     538    {"IEXTEN", IEXTEN},
     539
     540    /* indexes into the control chars array returned by tcgetattr() */
     541    {"VINTR", VINTR},
     542    {"VQUIT", VQUIT},
     543    {"VERASE", VERASE},
     544    {"VKILL", VKILL},
     545    {"VEOF", VEOF},
     546    {"VTIME", VTIME},
     547    {"VMIN", VMIN},
    545548#ifdef VSWTC
    546         /* The #defines above ensure that if either is defined, both are,
    547          * but both may be omitted by the system headers.  ;-(  */
    548         {"VSWTC", VSWTC},
    549         {"VSWTCH", VSWTCH},
    550 #endif
    551         {"VSTART", VSTART},
    552         {"VSTOP", VSTOP},
    553         {"VSUSP", VSUSP},
    554         {"VEOL", VEOL},
     549    /* The #defines above ensure that if either is defined, both are,
     550     * but both may be omitted by the system headers.  ;-(  */
     551    {"VSWTC", VSWTC},
     552    {"VSWTCH", VSWTCH},
     553#endif
     554    {"VSTART", VSTART},
     555    {"VSTOP", VSTOP},
     556    {"VSUSP", VSUSP},
     557    {"VEOL", VEOL},
    555558#ifdef VREPRINT
    556         {"VREPRINT", VREPRINT},
     559    {"VREPRINT", VREPRINT},
    557560#endif
    558561#ifdef VDISCARD
    559         {"VDISCARD", VDISCARD},
     562    {"VDISCARD", VDISCARD},
    560563#endif
    561564#ifdef VWERASE
    562         {"VWERASE", VWERASE},
     565    {"VWERASE", VWERASE},
    563566#endif
    564567#ifdef VLNEXT
    565         {"VLNEXT", VLNEXT},
     568    {"VLNEXT", VLNEXT},
    566569#endif
    567570#ifdef VEOL2
    568         {"VEOL2", VEOL2},
     571    {"VEOL2", VEOL2},
    569572#endif
    570573
    571574
    572575#ifdef B460800
    573         {"B460800", B460800},
     576    {"B460800", B460800},
    574577#endif
    575578#ifdef CBAUD
    576         {"CBAUD", CBAUD},
     579    {"CBAUD", CBAUD},
    577580#endif
    578581#ifdef CDEL
    579         {"CDEL", CDEL},
     582    {"CDEL", CDEL},
    580583#endif
    581584#ifdef CDSUSP
    582         {"CDSUSP", CDSUSP},
     585    {"CDSUSP", CDSUSP},
    583586#endif
    584587#ifdef CEOF
    585         {"CEOF", CEOF},
     588    {"CEOF", CEOF},
    586589#endif
    587590#ifdef CEOL
    588         {"CEOL", CEOL},
     591    {"CEOL", CEOL},
    589592#endif
    590593#ifdef CEOL2
    591         {"CEOL2", CEOL2},
     594    {"CEOL2", CEOL2},
    592595#endif
    593596#ifdef CEOT
    594         {"CEOT", CEOT},
     597    {"CEOT", CEOT},
    595598#endif
    596599#ifdef CERASE
    597         {"CERASE", CERASE},
     600    {"CERASE", CERASE},
    598601#endif
    599602#ifdef CESC
    600         {"CESC", CESC},
     603    {"CESC", CESC},
    601604#endif
    602605#ifdef CFLUSH
    603         {"CFLUSH", CFLUSH},
     606    {"CFLUSH", CFLUSH},
    604607#endif
    605608#ifdef CINTR
    606         {"CINTR", CINTR},
     609    {"CINTR", CINTR},
    607610#endif
    608611#ifdef CKILL
    609         {"CKILL", CKILL},
     612    {"CKILL", CKILL},
    610613#endif
    611614#ifdef CLNEXT
    612         {"CLNEXT", CLNEXT},
     615    {"CLNEXT", CLNEXT},
    613616#endif
    614617#ifdef CNUL
    615         {"CNUL", CNUL},
     618    {"CNUL", CNUL},
    616619#endif
    617620#ifdef COMMON
    618         {"COMMON", COMMON},
     621    {"COMMON", COMMON},
    619622#endif
    620623#ifdef CQUIT
    621         {"CQUIT", CQUIT},
     624    {"CQUIT", CQUIT},
    622625#endif
    623626#ifdef CRPRNT
    624         {"CRPRNT", CRPRNT},
     627    {"CRPRNT", CRPRNT},
    625628#endif
    626629#ifdef CSTART
    627         {"CSTART", CSTART},
     630    {"CSTART", CSTART},
    628631#endif
    629632#ifdef CSTOP
    630         {"CSTOP", CSTOP},
     633    {"CSTOP", CSTOP},
    631634#endif
    632635#ifdef CSUSP
    633         {"CSUSP", CSUSP},
     636    {"CSUSP", CSUSP},
    634637#endif
    635638#ifdef CSWTCH
    636         {"CSWTCH", CSWTCH},
     639    {"CSWTCH", CSWTCH},
    637640#endif
    638641#ifdef CWERASE
    639         {"CWERASE", CWERASE},
     642    {"CWERASE", CWERASE},
    640643#endif
    641644#ifdef EXTA
    642         {"EXTA", EXTA},
     645    {"EXTA", EXTA},
    643646#endif
    644647#ifdef EXTB
    645         {"EXTB", EXTB},
     648    {"EXTB", EXTB},
    646649#endif
    647650#ifdef FIOASYNC
    648         {"FIOASYNC", FIOASYNC},
     651    {"FIOASYNC", FIOASYNC},
    649652#endif
    650653#ifdef FIOCLEX
    651         {"FIOCLEX", FIOCLEX},
     654    {"FIOCLEX", FIOCLEX},
    652655#endif
    653656#ifdef FIONBIO
    654         {"FIONBIO", FIONBIO},
     657    {"FIONBIO", FIONBIO},
    655658#endif
    656659#ifdef FIONCLEX
    657         {"FIONCLEX", FIONCLEX},
     660    {"FIONCLEX", FIONCLEX},
    658661#endif
    659662#ifdef FIONREAD
    660         {"FIONREAD", FIONREAD},
     663    {"FIONREAD", FIONREAD},
    661664#endif
    662665#ifdef IBSHIFT
    663         {"IBSHIFT", IBSHIFT},
     666    {"IBSHIFT", IBSHIFT},
    664667#endif
    665668#ifdef INIT_C_CC
    666         {"INIT_C_CC", INIT_C_CC},
     669    {"INIT_C_CC", INIT_C_CC},
    667670#endif
    668671#ifdef IOCSIZE_MASK
    669         {"IOCSIZE_MASK", IOCSIZE_MASK},
     672    {"IOCSIZE_MASK", IOCSIZE_MASK},
    670673#endif
    671674#ifdef IOCSIZE_SHIFT
    672         {"IOCSIZE_SHIFT", IOCSIZE_SHIFT},
     675    {"IOCSIZE_SHIFT", IOCSIZE_SHIFT},
    673676#endif
    674677#ifdef NCC
    675         {"NCC", NCC},
     678    {"NCC", NCC},
    676679#endif
    677680#ifdef NCCS
    678         {"NCCS", NCCS},
     681    {"NCCS", NCCS},
    679682#endif
    680683#ifdef NSWTCH
    681         {"NSWTCH", NSWTCH},
     684    {"NSWTCH", NSWTCH},
    682685#endif
    683686#ifdef N_MOUSE
    684         {"N_MOUSE", N_MOUSE},
     687    {"N_MOUSE", N_MOUSE},
    685688#endif
    686689#ifdef N_PPP
    687         {"N_PPP", N_PPP},
     690    {"N_PPP", N_PPP},
    688691#endif
    689692#ifdef N_SLIP
    690         {"N_SLIP", N_SLIP},
     693    {"N_SLIP", N_SLIP},
    691694#endif
    692695#ifdef N_STRIP
    693         {"N_STRIP", N_STRIP},
     696    {"N_STRIP", N_STRIP},
    694697#endif
    695698#ifdef N_TTY
    696         {"N_TTY", N_TTY},
     699    {"N_TTY", N_TTY},
    697700#endif
    698701#ifdef TCFLSH
    699         {"TCFLSH", TCFLSH},
     702    {"TCFLSH", TCFLSH},
    700703#endif
    701704#ifdef TCGETA
    702         {"TCGETA", TCGETA},
     705    {"TCGETA", TCGETA},
    703706#endif
    704707#ifdef TCGETS
    705         {"TCGETS", TCGETS},
     708    {"TCGETS", TCGETS},
    706709#endif
    707710#ifdef TCSBRK
    708         {"TCSBRK", TCSBRK},
     711    {"TCSBRK", TCSBRK},
    709712#endif
    710713#ifdef TCSBRKP
    711         {"TCSBRKP", TCSBRKP},
     714    {"TCSBRKP", TCSBRKP},
    712715#endif
    713716#ifdef TCSETA
    714         {"TCSETA", TCSETA},
     717    {"TCSETA", TCSETA},
    715718#endif
    716719#ifdef TCSETAF
    717         {"TCSETAF", TCSETAF},
     720    {"TCSETAF", TCSETAF},
    718721#endif
    719722#ifdef TCSETAW
    720         {"TCSETAW", TCSETAW},
     723    {"TCSETAW", TCSETAW},
    721724#endif
    722725#ifdef TCSETS
    723         {"TCSETS", TCSETS},
     726    {"TCSETS", TCSETS},
    724727#endif
    725728#ifdef TCSETSF
    726         {"TCSETSF", TCSETSF},
     729    {"TCSETSF", TCSETSF},
    727730#endif
    728731#ifdef TCSETSW
    729         {"TCSETSW", TCSETSW},
     732    {"TCSETSW", TCSETSW},
    730733#endif
    731734#ifdef TCXONC
    732         {"TCXONC", TCXONC},
     735    {"TCXONC", TCXONC},
    733736#endif
    734737#ifdef TIOCCONS
    735         {"TIOCCONS", TIOCCONS},
     738    {"TIOCCONS", TIOCCONS},
    736739#endif
    737740#ifdef TIOCEXCL
    738         {"TIOCEXCL", TIOCEXCL},
     741    {"TIOCEXCL", TIOCEXCL},
    739742#endif
    740743#ifdef TIOCGETD
    741         {"TIOCGETD", TIOCGETD},
     744    {"TIOCGETD", TIOCGETD},
    742745#endif
    743746#ifdef TIOCGICOUNT
    744         {"TIOCGICOUNT", TIOCGICOUNT},
     747    {"TIOCGICOUNT", TIOCGICOUNT},
    745748#endif
    746749#ifdef TIOCGLCKTRMIOS
    747         {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS},
     750    {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS},
    748751#endif
    749752#ifdef TIOCGPGRP
    750         {"TIOCGPGRP", TIOCGPGRP},
     753    {"TIOCGPGRP", TIOCGPGRP},
    751754#endif
    752755#ifdef TIOCGSERIAL
    753         {"TIOCGSERIAL", TIOCGSERIAL},
     756    {"TIOCGSERIAL", TIOCGSERIAL},
    754757#endif
    755758#ifdef TIOCGSOFTCAR
    756         {"TIOCGSOFTCAR", TIOCGSOFTCAR},
     759    {"TIOCGSOFTCAR", TIOCGSOFTCAR},
    757760#endif
    758761#ifdef TIOCGWINSZ
    759         {"TIOCGWINSZ", TIOCGWINSZ},
     762    {"TIOCGWINSZ", TIOCGWINSZ},
    760763#endif
    761764#ifdef TIOCINQ
    762         {"TIOCINQ", TIOCINQ},
     765    {"TIOCINQ", TIOCINQ},
    763766#endif
    764767#ifdef TIOCLINUX
    765         {"TIOCLINUX", TIOCLINUX},
     768    {"TIOCLINUX", TIOCLINUX},
    766769#endif
    767770#ifdef TIOCMBIC
    768         {"TIOCMBIC", TIOCMBIC},
     771    {"TIOCMBIC", TIOCMBIC},
    769772#endif
    770773#ifdef TIOCMBIS
    771         {"TIOCMBIS", TIOCMBIS},
     774    {"TIOCMBIS", TIOCMBIS},
    772775#endif
    773776#ifdef TIOCMGET
    774         {"TIOCMGET", TIOCMGET},
     777    {"TIOCMGET", TIOCMGET},
    775778#endif
    776779#ifdef TIOCMIWAIT
    777         {"TIOCMIWAIT", TIOCMIWAIT},
     780    {"TIOCMIWAIT", TIOCMIWAIT},
    778781#endif
    779782#ifdef TIOCMSET
    780         {"TIOCMSET", TIOCMSET},
     783    {"TIOCMSET", TIOCMSET},
    781784#endif
    782785#ifdef TIOCM_CAR
    783         {"TIOCM_CAR", TIOCM_CAR},
     786    {"TIOCM_CAR", TIOCM_CAR},
    784787#endif
    785788#ifdef TIOCM_CD
    786         {"TIOCM_CD", TIOCM_CD},
     789    {"TIOCM_CD", TIOCM_CD},
    787790#endif
    788791#ifdef TIOCM_CTS
    789         {"TIOCM_CTS", TIOCM_CTS},
     792    {"TIOCM_CTS", TIOCM_CTS},
    790793#endif
    791794#ifdef TIOCM_DSR
    792         {"TIOCM_DSR", TIOCM_DSR},
     795    {"TIOCM_DSR", TIOCM_DSR},
    793796#endif
    794797#ifdef TIOCM_DTR
    795         {"TIOCM_DTR", TIOCM_DTR},
     798    {"TIOCM_DTR", TIOCM_DTR},
    796799#endif
    797800#ifdef TIOCM_LE
    798         {"TIOCM_LE", TIOCM_LE},
     801    {"TIOCM_LE", TIOCM_LE},
    799802#endif
    800803#ifdef TIOCM_RI
    801         {"TIOCM_RI", TIOCM_RI},
     804    {"TIOCM_RI", TIOCM_RI},
    802805#endif
    803806#ifdef TIOCM_RNG
    804         {"TIOCM_RNG", TIOCM_RNG},
     807    {"TIOCM_RNG", TIOCM_RNG},
    805808#endif
    806809#ifdef TIOCM_RTS
    807         {"TIOCM_RTS", TIOCM_RTS},
     810    {"TIOCM_RTS", TIOCM_RTS},
    808811#endif
    809812#ifdef TIOCM_SR
    810         {"TIOCM_SR", TIOCM_SR},
     813    {"TIOCM_SR", TIOCM_SR},
    811814#endif
    812815#ifdef TIOCM_ST
    813         {"TIOCM_ST", TIOCM_ST},
     816    {"TIOCM_ST", TIOCM_ST},
    814817#endif
    815818#ifdef TIOCNOTTY
    816         {"TIOCNOTTY", TIOCNOTTY},
     819    {"TIOCNOTTY", TIOCNOTTY},
    817820#endif
    818821#ifdef TIOCNXCL
    819         {"TIOCNXCL", TIOCNXCL},
     822    {"TIOCNXCL", TIOCNXCL},
    820823#endif
    821824#ifdef TIOCOUTQ
    822         {"TIOCOUTQ", TIOCOUTQ},
     825    {"TIOCOUTQ", TIOCOUTQ},
    823826#endif
    824827#ifdef TIOCPKT
    825         {"TIOCPKT", TIOCPKT},
     828    {"TIOCPKT", TIOCPKT},
    826829#endif
    827830#ifdef TIOCPKT_DATA
    828         {"TIOCPKT_DATA", TIOCPKT_DATA},
     831    {"TIOCPKT_DATA", TIOCPKT_DATA},
    829832#endif
    830833#ifdef TIOCPKT_DOSTOP
    831         {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP},
     834    {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP},
    832835#endif
    833836#ifdef TIOCPKT_FLUSHREAD
    834         {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD},
     837    {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD},
    835838#endif
    836839#ifdef TIOCPKT_FLUSHWRITE
    837         {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE},
     840    {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE},
    838841#endif
    839842#ifdef TIOCPKT_NOSTOP
    840         {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP},
     843    {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP},
    841844#endif
    842845#ifdef TIOCPKT_START
    843         {"TIOCPKT_START", TIOCPKT_START},
     846    {"TIOCPKT_START", TIOCPKT_START},
    844847#endif
    845848#ifdef TIOCPKT_STOP
    846         {"TIOCPKT_STOP", TIOCPKT_STOP},
     849    {"TIOCPKT_STOP", TIOCPKT_STOP},
    847850#endif
    848851#ifdef TIOCSCTTY
    849         {"TIOCSCTTY", TIOCSCTTY},
     852    {"TIOCSCTTY", TIOCSCTTY},
    850853#endif
    851854#ifdef TIOCSERCONFIG
    852         {"TIOCSERCONFIG", TIOCSERCONFIG},
     855    {"TIOCSERCONFIG", TIOCSERCONFIG},
    853856#endif
    854857#ifdef TIOCSERGETLSR
    855         {"TIOCSERGETLSR", TIOCSERGETLSR},
     858    {"TIOCSERGETLSR", TIOCSERGETLSR},
    856859#endif
    857860#ifdef TIOCSERGETMULTI
    858         {"TIOCSERGETMULTI", TIOCSERGETMULTI},
     861    {"TIOCSERGETMULTI", TIOCSERGETMULTI},
    859862#endif
    860863#ifdef TIOCSERGSTRUCT
    861         {"TIOCSERGSTRUCT", TIOCSERGSTRUCT},
     864    {"TIOCSERGSTRUCT", TIOCSERGSTRUCT},
    862865#endif
    863866#ifdef TIOCSERGWILD
    864         {"TIOCSERGWILD", TIOCSERGWILD},
     867    {"TIOCSERGWILD", TIOCSERGWILD},
    865868#endif
    866869#ifdef TIOCSERSETMULTI
    867         {"TIOCSERSETMULTI", TIOCSERSETMULTI},
     870    {"TIOCSERSETMULTI", TIOCSERSETMULTI},
    868871#endif
    869872#ifdef TIOCSERSWILD
    870         {"TIOCSERSWILD", TIOCSERSWILD},
     873    {"TIOCSERSWILD", TIOCSERSWILD},
    871874#endif
    872875#ifdef TIOCSER_TEMT
    873         {"TIOCSER_TEMT", TIOCSER_TEMT},
     876    {"TIOCSER_TEMT", TIOCSER_TEMT},
    874877#endif
    875878#ifdef TIOCSETD
    876         {"TIOCSETD", TIOCSETD},
     879    {"TIOCSETD", TIOCSETD},
    877880#endif
    878881#ifdef TIOCSLCKTRMIOS
    879         {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS},
     882    {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS},
    880883#endif
    881884#ifdef TIOCSPGRP
    882         {"TIOCSPGRP", TIOCSPGRP},
     885    {"TIOCSPGRP", TIOCSPGRP},
    883886#endif
    884887#ifdef TIOCSSERIAL
    885         {"TIOCSSERIAL", TIOCSSERIAL},
     888    {"TIOCSSERIAL", TIOCSSERIAL},
    886889#endif
    887890#ifdef TIOCSSOFTCAR
    888         {"TIOCSSOFTCAR", TIOCSSOFTCAR},
     891    {"TIOCSSOFTCAR", TIOCSSOFTCAR},
    889892#endif
    890893#ifdef TIOCSTI
    891         {"TIOCSTI", TIOCSTI},
     894    {"TIOCSTI", TIOCSTI},
    892895#endif
    893896#ifdef TIOCSWINSZ
    894         {"TIOCSWINSZ", TIOCSWINSZ},
     897    {"TIOCSWINSZ", TIOCSWINSZ},
    895898#endif
    896899#ifdef TIOCTTYGSTRUCT
    897         {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT},
    898 #endif
    899 
    900         /* sentinel */
    901         {NULL, 0}
     900    {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT},
     901#endif
     902
     903    /* sentinel */
     904    {NULL, 0}
    902905};
    903906
     
    906909PyInit_termios(void)
    907910{
    908         PyObject *m;
    909         struct constant *constant = termios_constants;
    910 
    911         m = Py_InitModule4("termios", termios_methods, termios__doc__,
    912                            (PyObject *)NULL, PYTHON_API_VERSION);
    913         if (m == NULL)
    914                 return;
    915 
    916         if (TermiosError == NULL) {
    917                 TermiosError = PyErr_NewException("termios.error", NULL, NULL);
    918         }
    919         Py_INCREF(TermiosError);
    920         PyModule_AddObject(m, "error", TermiosError);
    921 
    922         while (constant->name != NULL) {
    923                 PyModule_AddIntConstant(m, constant->name, constant->value);
    924                 ++constant;
    925         }
     911    PyObject *m;
     912    struct constant *constant = termios_constants;
     913
     914    m = Py_InitModule4("termios", termios_methods, termios__doc__,
     915                       (PyObject *)NULL, PYTHON_API_VERSION);
     916    if (m == NULL)
     917        return;
     918
     919    if (TermiosError == NULL) {
     920        TermiosError = PyErr_NewException("termios.error", NULL, NULL);
     921    }
     922    Py_INCREF(TermiosError);
     923    PyModule_AddObject(m, "error", TermiosError);
     924
     925    while (constant->name != NULL) {
     926        PyModule_AddIntConstant(m, constant->name, constant->value);
     927        ++constant;
     928    }
    926929}
Note: See TracChangeset for help on using the changeset viewer.