Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

Location:
python/vendor/current/RISCOS
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/RISCOS/Makefile

    r2 r388  
    136136        @.Python.o.dynload_riscos\
    137137        @.Python.o.getcwd_riscos\
    138         @.Python.o.getmtime_riscos\
    139138        @.o.unixstuff
    140139
  • python/vendor/current/RISCOS/Modules/config.c

    r2 r388  
    5050struct _inittab _PyImport_Inittab[] = {
    5151
    52         {"riscos", initriscos},
     52    {"riscos", initriscos},
    5353
    5454/* -- ADDMODULE MARKER 2 -- */
    5555
    56         /* This module "lives in" with marshal.c */
    57         {"marshal", PyMarshal_Init},
     56    /* This module "lives in" with marshal.c */
     57    {"marshal", PyMarshal_Init},
    5858
    59         /* This lives it with import.c */
    60         {"imp", initimp},
     59    /* This lives it with import.c */
     60    {"imp", initimp},
    6161
    62         /* These entries are here for sys.builtin_module_names */
    63         {"__main__", NULL},
    64         {"__builtin__", NULL},
    65         {"sys", NULL},
    66         {"exceptions", NULL},
     62    /* These entries are here for sys.builtin_module_names */
     63    {"__main__", NULL},
     64    {"__builtin__", NULL},
     65    {"sys", NULL},
     66    {"exceptions", NULL},
    6767
    68         /* This lives in gcmodule.c */
    69         {"gc", initgc},
     68    /* This lives in gcmodule.c */
     69    {"gc", initgc},
    7070
    71         /* Sentinel */
    72         {0, 0}
     71    /* Sentinel */
     72    {0, 0}
    7373};
  • python/vendor/current/RISCOS/Modules/getpath_riscos.c

    r2 r388  
    66static void
    77calculate_path()
    8 { 
    9         char *pypath = getenv("Python$Path");
    10         if (pypath) {
    11                 int pathlen = strlen(pypath);
    12                 module_search_path = malloc(pathlen + 1);
    13                 if (module_search_path)
    14                         strncpy(module_search_path, pypath, pathlen + 1);
    15                 else {
    16                         fprintf(stderr,
    17                                 "Not enough memory for dynamic PYTHONPATH.\n"
    18                                 "Using default static PYTHONPATH.\n");
    19                 }
    20         }
    21         if (!module_search_path)
    22                 module_search_path = "<Python$Dir>.Lib";
    23         prefix = "<Python$Dir>";
    24         exec_prefix = prefix;
    25         progpath = Py_GetProgramName();
     8{
     9    char *pypath = getenv("Python$Path");
     10    if (pypath) {
     11        int pathlen = strlen(pypath);
     12        module_search_path = malloc(pathlen + 1);
     13        if (module_search_path)
     14            strncpy(module_search_path, pypath, pathlen + 1);
     15        else {
     16            fprintf(stderr,
     17                "Not enough memory for dynamic PYTHONPATH.\n"
     18                "Using default static PYTHONPATH.\n");
     19        }
     20    }
     21    if (!module_search_path)
     22        module_search_path = "<Python$Dir>.Lib";
     23    prefix = "<Python$Dir>";
     24    exec_prefix = prefix;
     25    progpath = Py_GetProgramName();
    2626}
    2727
     
    3131Py_GetPath()
    3232{
    33         if (!module_search_path)
    34                 calculate_path();
    35         return module_search_path;
     33    if (!module_search_path)
     34        calculate_path();
     35    return module_search_path;
    3636}
    3737
     
    3939Py_GetPrefix()
    4040{
    41         if (!module_search_path)
    42                 calculate_path();
    43         return prefix;
     41    if (!module_search_path)
     42        calculate_path();
     43    return prefix;
    4444}
    4545
     
    4747Py_GetExecPrefix()
    4848{
    49         if (!module_search_path)
    50                 calculate_path();
    51         return exec_prefix;
     49    if (!module_search_path)
     50        calculate_path();
     51    return exec_prefix;
    5252}
    5353
     
    5555Py_GetProgramFullPath()
    5656{
    57         if (!module_search_path)
    58                 calculate_path();
    59         return progpath;
     57    if (!module_search_path)
     58        calculate_path();
     59    return progpath;
    6060}
  • python/vendor/current/RISCOS/Modules/riscosmodule.c

    r2 r388  
    2020static PyObject *riscos_error(char *s)
    2121{
    22         PyErr_SetString(PyExc_OSError, s);
    23         return NULL;
     22    PyErr_SetString(PyExc_OSError, s);
     23    return NULL;
    2424}
    2525
    2626static PyObject *riscos_oserror(void)
    2727{
    28         return riscos_error(e->errmess);
     28    return riscos_error(e->errmess);
    2929}
    3030
     
    3636{
    3737    char *path1;
    38         if (!PyArg_ParseTuple(args, "s:remove", &path1)) return NULL;
    39         if (remove(path1)) return PyErr_SetFromErrno(PyExc_OSError);
    40         Py_INCREF(Py_None);
    41         return Py_None;
     38    if (!PyArg_ParseTuple(args, "s:remove", &path1)) return NULL;
     39    if (remove(path1)) return PyErr_SetFromErrno(PyExc_OSError);
     40    Py_INCREF(Py_None);
     41    return Py_None;
    4242}
    4343
     
    4545riscos_rename(PyObject *self, PyObject *args)
    4646{
    47         char *path1, *path2;
    48         if (!PyArg_ParseTuple(args, "ss:rename", &path1, &path2))
    49         return NULL;
    50         if (rename(path1,path2)) return PyErr_SetFromErrno(PyExc_OSError);
    51         Py_INCREF(Py_None);
    52         return Py_None;
     47    char *path1, *path2;
     48    if (!PyArg_ParseTuple(args, "ss:rename", &path1, &path2))
     49    return NULL;
     50    if (rename(path1,path2)) return PyErr_SetFromErrno(PyExc_OSError);
     51    Py_INCREF(Py_None);
     52    return Py_None;
    5353}
    5454
     
    5656riscos_system(PyObject *self, PyObject *args)
    5757{
    58         char *command;
    59         if (!PyArg_ParseTuple(args, "s:system", &command)) return NULL;
    60         return PyInt_FromLong(system(command));
     58    char *command;
     59    if (!PyArg_ParseTuple(args, "s:system", &command)) return NULL;
     60    return PyInt_FromLong(system(command));
    6161}
    6262
     
    6464riscos_chdir(PyObject *self, PyObject *args)
    6565{
    66         char *path;
    67         if (!PyArg_ParseTuple(args, "s:chdir", &path)) return NULL;
    68         e=xosfscontrol_dir(path);
    69         if(e) return riscos_oserror();
    70         Py_INCREF(Py_None);
    71         return Py_None;
     66    char *path;
     67    if (!PyArg_ParseTuple(args, "s:chdir", &path)) return NULL;
     68    e=xosfscontrol_dir(path);
     69    if(e) return riscos_oserror();
     70    Py_INCREF(Py_None);
     71    return Py_None;
    7272}
    7373
     
    9999riscos_expand(PyObject *self, PyObject *args)
    100100{
    101         char *path;
    102         if (!PyArg_ParseTuple(args, "s:expand", &path)) return NULL;
    103         return canon(path);
     101    char *path;
     102    if (!PyArg_ParseTuple(args, "s:expand", &path)) return NULL;
     103    return canon(path);
    104104}
    105105
     
    107107riscos_mkdir(PyObject *self, PyObject *args)
    108108{
    109         char *path;
     109    char *path;
    110110    int mode;
    111111    if (!PyArg_ParseTuple(args, "s|i:mkdir", &path, &mode)) return NULL;
    112112    e=xosfile_create_dir(path,0);
    113113    if(e) return riscos_oserror();
    114         Py_INCREF(Py_None);
    115         return Py_None;
     114    Py_INCREF(Py_None);
     115    return Py_None;
    116116}
    117117
     
    119119riscos_listdir(PyObject *self, PyObject *args)
    120120{
    121         char *path,buf[256];
     121    char *path,buf[256];
    122122    PyObject *d, *v;
    123123    int c=0,count;
    124         if (!PyArg_ParseTuple(args, "s:listdir", &path)) return NULL;
    125         d=PyList_New(0);
    126         if(!d) return NULL;
    127         for(;;)
    128         { e=xosgbpb_dir_entries(path,(osgbpb_string_list*)buf,
    129                                      1,c,256,0,&count,&c);
    130           if(e)
    131           { Py_DECREF(d);return riscos_oserror();
    132           }
    133           if(count)
    134           { v=PyString_FromString(buf);
    135             if(!v) { Py_DECREF(d);return 0;}
    136             if(PyList_Append(d,v)) {Py_DECREF(d);Py_DECREF(v);return 0;}
    137           }
    138           if(c==-1) break;
    139         }
    140         return d;
     124    if (!PyArg_ParseTuple(args, "s:listdir", &path)) return NULL;
     125    d=PyList_New(0);
     126    if(!d) return NULL;
     127    for(;;)
     128    { e=xosgbpb_dir_entries(path,(osgbpb_string_list*)buf,
     129                                 1,c,256,0,&count,&c);
     130      if(e)
     131      { Py_DECREF(d);return riscos_oserror();
     132      }
     133      if(count)
     134      { v=PyString_FromString(buf);
     135        if(!v) { Py_DECREF(d);return 0;}
     136        if(PyList_Append(d,v)) {Py_DECREF(d);Py_DECREF(v);return 0;}
     137      }
     138      if(c==-1) break;
     139    }
     140    return d;
    141141}
    142142
     
    152152
    153153static PyStructSequence_Field stat_result_fields[] = {
    154         { "st_mode",  "protection bits" },
    155         { "st_ino",   "inode" },
    156         { "st_dev",   "device" },
    157         { "st_nlink", "number of hard links" },
    158         { "st_uid",   "user ID of owner" },
    159         { "st_gid",   "group ID of owner" },
    160         { "st_size",  "total size, in bytes" },
    161         { "st_atime", "time of last access" },
    162         { "st_mtime", "time of last modification" },
    163         { "st_ctime", "time of last change" },
    164         { "st_ftype", "file type" },
    165         { "st_attrs", "attributes" },
    166         { "st_obtype", "object type" },
    167         { 0 }
     154    { "st_mode",  "protection bits" },
     155    { "st_ino",   "inode" },
     156    { "st_dev",   "device" },
     157    { "st_nlink", "number of hard links" },
     158    { "st_uid",   "user ID of owner" },
     159    { "st_gid",   "group ID of owner" },
     160    { "st_size",  "total size, in bytes" },
     161    { "st_atime", "time of last access" },
     162    { "st_mtime", "time of last modification" },
     163    { "st_ctime", "time of last change" },
     164    { "st_ftype", "file type" },
     165    { "st_attrs", "attributes" },
     166    { "st_obtype", "object type" },
     167    { 0 }
    168168};
    169169
    170170static PyStructSequence_Desc stat_result_desc = {
    171         "riscos.stat_result",
    172         stat_result__doc__,
    173         stat_result_fields,
    174         13
     171    "riscos.stat_result",
     172    stat_result__doc__,
     173    stat_result_fields,
     174    13
    175175};
    176176
     
    179179static PyObject *
    180180riscos_stat(PyObject *self, PyObject *args)
    181 {       
    182         PyObject *v;
    183         char *path;
    184         int ob,len;
    185         bits t=0;
    186         bits ld,ex,at,ft,mode;
    187         if (!PyArg_ParseTuple(args, "s:stat", &path)) return NULL;
    188         e=xosfile_read_stamped_no_path(path,&ob,&ld,&ex,&len,&at,&ft);
    189         if(e) return riscos_oserror();
    190         switch (ob)
    191         { case osfile_IS_FILE:mode=0100000;break;  /* OCTAL */
    192           case osfile_IS_DIR:mode=040000;break;
    193           case osfile_IS_IMAGE:mode=0140000;break;
    194           default:return riscos_error("Not found");
    195         }
    196         if(ft!=-1) t=unixtime(ld,ex);
    197         mode|=(at&7)<<6;
    198         mode|=((at&112)*9)>>4;
    199 
    200         v = PyStructSequence_New(&StatResultType);
    201 
    202         PyStructSequence_SET_ITEM(v, 0,
    203                                   PyInt_FromLong((long) mode)); /*st_mode*/
    204         PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long) 0)); /*st_ino*/
    205         PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long) 0)); /*st_dev*/
    206         PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long) 0)); /*st_nlink*/
    207         PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long) 0)); /*st_uid*/
    208         PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long) 0)); /*st_gid*/
    209         PyStructSequence_SET_ITEM(v, 6,
    210                                   PyInt_FromLong((long) len)); /*st_size*/
    211         PyStructSequence_SET_ITEM(v, 7, PyInt_FromLong((long) t)); /*st_atime*/
    212         PyStructSequence_SET_ITEM(v, 8, PyInt_FromLong((long) t)); /*st_mtime*/
    213         PyStructSequence_SET_ITEM(v, 9, PyInt_FromLong((long) t)); /*st_ctime*/
    214         PyStructSequence_SET_ITEM(v, 10,
    215                                   PyInt_FromLong((long) ft)); /*file type*/
    216         PyStructSequence_SET_ITEM(v, 11,
    217                                   PyInt_FromLong((long) at)); /*attributes*/
    218         PyStructSequence_SET_ITEM(v, 12,
    219                                   PyInt_FromLong((long) ob)); /*object type*/
    220 
    221         if (PyErr_Occurred()) {
    222                 Py_DECREF(v);
    223                 return NULL;
    224         }
    225 
    226         return v;
     181{
     182    PyObject *v;
     183    char *path;
     184    int ob,len;
     185    bits t=0;
     186    bits ld,ex,at,ft,mode;
     187    if (!PyArg_ParseTuple(args, "s:stat", &path)) return NULL;
     188    e=xosfile_read_stamped_no_path(path,&ob,&ld,&ex,&len,&at,&ft);
     189    if(e) return riscos_oserror();
     190    switch (ob)
     191    { case osfile_IS_FILE:mode=0100000;break;  /* OCTAL */
     192      case osfile_IS_DIR:mode=040000;break;
     193      case osfile_IS_IMAGE:mode=0140000;break;
     194      default:return riscos_error("Not found");
     195    }
     196    if(ft!=-1) t=unixtime(ld,ex);
     197    mode|=(at&7)<<6;
     198    mode|=((at&112)*9)>>4;
     199
     200    v = PyStructSequence_New(&StatResultType);
     201
     202    PyStructSequence_SET_ITEM(v, 0,
     203                              PyInt_FromLong((long) mode)); /*st_mode*/
     204    PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long) 0)); /*st_ino*/
     205    PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long) 0)); /*st_dev*/
     206    PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long) 0)); /*st_nlink*/
     207    PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long) 0)); /*st_uid*/
     208    PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long) 0)); /*st_gid*/
     209    PyStructSequence_SET_ITEM(v, 6,
     210                              PyInt_FromLong((long) len)); /*st_size*/
     211    PyStructSequence_SET_ITEM(v, 7, PyInt_FromLong((long) t)); /*st_atime*/
     212    PyStructSequence_SET_ITEM(v, 8, PyInt_FromLong((long) t)); /*st_mtime*/
     213    PyStructSequence_SET_ITEM(v, 9, PyInt_FromLong((long) t)); /*st_ctime*/
     214    PyStructSequence_SET_ITEM(v, 10,
     215                              PyInt_FromLong((long) ft)); /*file type*/
     216    PyStructSequence_SET_ITEM(v, 11,
     217                              PyInt_FromLong((long) at)); /*attributes*/
     218    PyStructSequence_SET_ITEM(v, 12,
     219                              PyInt_FromLong((long) ob)); /*object type*/
     220
     221    if (PyErr_Occurred()) {
     222        Py_DECREF(v);
     223        return NULL;
     224    }
     225
     226    return v;
    227227}
    228228
     
    230230riscos_chmod(PyObject *self,PyObject *args)
    231231{
    232         char *path;
     232    char *path;
    233233    bits mode;
    234234    bits attr;
    235235    attr=(mode&0x700)>>8;
    236236    attr|=(mode&7)<<4;
    237         if (!PyArg_ParseTuple(args, "si:chmod", &path,(int*)&mode)) return NULL;
    238         e=xosfile_write_attr(path,attr);
     237    if (!PyArg_ParseTuple(args, "si:chmod", &path,(int*)&mode)) return NULL;
     238    e=xosfile_write_attr(path,attr);
     239    if(e) return riscos_oserror();
     240    Py_INCREF(Py_None);
     241    return Py_None;
     242}
     243
     244
     245static PyObject *
     246riscos_utime(PyObject *self, PyObject *args)
     247{
     248    char *path;
     249    long atime, mtime;
     250    PyObject* arg;
     251
     252    if (!PyArg_ParseTuple(args, "sO:utime", &path, &arg))
     253        return NULL;
     254
     255    if (arg == Py_None) {
     256        /* optional time values not given */
     257        Py_BEGIN_ALLOW_THREADS
     258        e=xosfile_stamp(path);
     259        Py_END_ALLOW_THREADS
    239260        if(e) return riscos_oserror();
    240         Py_INCREF(Py_None);
    241         return Py_None;
    242 }
    243 
    244 
    245 static PyObject *
    246 riscos_utime(PyObject *self, PyObject *args)
    247 {
    248         char *path;
    249         long atime, mtime;
    250         PyObject* arg;
    251 
    252         if (!PyArg_ParseTuple(args, "sO:utime", &path, &arg))
    253                 return NULL;
    254 
    255         if (arg == Py_None) {
    256                 /* optional time values not given */
    257                 Py_BEGIN_ALLOW_THREADS
    258                 e=xosfile_stamp(path);
    259                 Py_END_ALLOW_THREADS
    260                 if(e) return riscos_oserror();
    261         }
    262         else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) {
    263                 PyErr_SetString(PyExc_TypeError,
    264                                 "utime() arg 2 must be a tuple (atime, mtime)");
    265                 return NULL;
    266         }
    267         else {
    268                 /* catalogue info*/
    269                 fileswitch_object_type obj_type;
    270                 bits load_addr, exec_addr;
    271                 int size;
    272                 fileswitch_attr attr;
    273 
    274                 /* read old catalogue info */
    275                 Py_BEGIN_ALLOW_THREADS
    276                 e=xosfile_read_no_path(path, &obj_type, &load_addr, &exec_addr, &size, &attr);
    277                 Py_END_ALLOW_THREADS
    278                 if(e) return riscos_oserror();
    279 
    280                 /* check if load and exec address really contain filetype and date */
    281                 if ( (load_addr & 0xFFF00000U) != 0xFFF00000U)
    282                         return riscos_error("can't set date for object with load and exec addresses");
    283 
    284                 /* convert argument mtime to RISC OS load and exec address */
    285                 if(acorntime(&exec_addr, &load_addr, (time_t) mtime))
    286                         return riscos_oserror();
    287 
    288                 /* write new load and exec address */
    289                 Py_BEGIN_ALLOW_THREADS
    290                 e = xosfile_write(path, load_addr, exec_addr, attr);
    291                 Py_END_ALLOW_THREADS
    292                 if(e) return riscos_oserror();
    293         }
    294 
    295         Py_INCREF(Py_None);
    296         return Py_None;
     261    }
     262    else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) {
     263        PyErr_SetString(PyExc_TypeError,
     264                        "utime() arg 2 must be a tuple (atime, mtime)");
     265        return NULL;
     266    }
     267    else {
     268        /* catalogue info*/
     269        fileswitch_object_type obj_type;
     270        bits load_addr, exec_addr;
     271        int size;
     272        fileswitch_attr attr;
     273
     274        /* read old catalogue info */
     275        Py_BEGIN_ALLOW_THREADS
     276        e=xosfile_read_no_path(path, &obj_type, &load_addr, &exec_addr, &size, &attr);
     277        Py_END_ALLOW_THREADS
     278        if(e) return riscos_oserror();
     279
     280        /* check if load and exec address really contain filetype and date */
     281        if ( (load_addr & 0xFFF00000U) != 0xFFF00000U)
     282            return riscos_error("can't set date for object with load and exec addresses");
     283
     284        /* convert argument mtime to RISC OS load and exec address */
     285        if(acorntime(&exec_addr, &load_addr, (time_t) mtime))
     286            return riscos_oserror();
     287
     288        /* write new load and exec address */
     289        Py_BEGIN_ALLOW_THREADS
     290        e = xosfile_write(path, load_addr, exec_addr, attr);
     291        Py_END_ALLOW_THREADS
     292        if(e) return riscos_oserror();
     293    }
     294
     295    Py_INCREF(Py_None);
     296    return Py_None;
    297297}
    298298
     
    300300riscos_settype(PyObject *self, PyObject *args)
    301301{
    302         char *path,*name;
     302    char *path,*name;
    303303    int type;
    304         if (!PyArg_ParseTuple(args, "si:settype", &path,&type))
    305         {
     304    if (!PyArg_ParseTuple(args, "si:settype", &path,&type))
     305    {
    306306      PyErr_Clear();
    307           if (!PyArg_ParseTuple(args, "ss:settype", &path,&name)) return NULL;
    308           e=xosfscontrol_file_type_from_string(name,(bits*)&type);
    309           if(e) return riscos_oserror();
    310         }
     307      if (!PyArg_ParseTuple(args, "ss:settype", &path,&name)) return NULL;
     308      e=xosfscontrol_file_type_from_string(name,(bits*)&type);
     309      if(e) return riscos_oserror();
     310    }
    311311    e=xosfile_set_type(path,type);
    312312    if(e) return riscos_oserror();
    313         Py_INCREF(Py_None);
    314         return Py_None;
     313    Py_INCREF(Py_None);
     314    return Py_None;
    315315}
    316316
     
    369369  /* XXX This part ignores errors */
    370370  while(!xos_read_var_val(which,value,sizeof(value)-1,(int)context,
    371          os_VARTYPE_EXPANDED,&size,(int *)&context,0))
     371     os_VARTYPE_EXPANDED,&size,(int *)&context,0))
    372372  { PyObject *v;
    373373    value[size]='\0';
     
    382382static PyMethodDef riscos_methods[] = {
    383383
    384         {"unlink",      riscos_remove, METH_VARARGS},
     384    {"unlink",          riscos_remove, METH_VARARGS},
    385385    {"remove",  riscos_remove, METH_VARARGS},
    386         {"rename",      riscos_rename, METH_VARARGS},
    387         {"system",      riscos_system, METH_VARARGS},
    388         {"rmdir",       riscos_remove, METH_VARARGS},
    389         {"chdir",       riscos_chdir,  METH_VARARGS},
    390         {"getcwd",      riscos_getcwd, METH_NOARGS},
    391         {"expand",  riscos_expand, METH_VARARGS},
    392         {"mkdir",       riscos_mkdir,  METH_VARARGS},
    393         {"listdir",     riscos_listdir, METH_VARARGS},
    394         {"stat",        riscos_stat,   METH_VARARGS},
    395         {"lstat",       riscos_stat,   METH_VARARGS},
    396     {"chmod",   riscos_chmod,  METH_VARARGS},
    397         {"utime",       riscos_utime,  METH_VARARGS},
    398         {"settype",     riscos_settype, METH_VARARGS},
    399         {"getenv",  riscos_getenv, METH_VARARGS},
    400         {"putenv",  riscos_putenv, METH_VARARGS},
    401         {"delenv",  riscos_delenv, METH_VARARGS},
    402         {"getenvdict", riscos_getenvdict, METH_VARARGS},
    403         {NULL,          NULL}            /* Sentinel */
     386    {"rename",          riscos_rename, METH_VARARGS},
     387    {"system",          riscos_system, METH_VARARGS},
     388    {"rmdir",           riscos_remove, METH_VARARGS},
     389    {"chdir",           riscos_chdir,  METH_VARARGS},
     390    {"getcwd",          riscos_getcwd, METH_NOARGS},
     391    {"expand",  riscos_expand, METH_VARARGS},
     392    {"mkdir",           riscos_mkdir,  METH_VARARGS},
     393    {"listdir",         riscos_listdir, METH_VARARGS},
     394    {"stat",            riscos_stat,   METH_VARARGS},
     395    {"lstat",           riscos_stat,   METH_VARARGS},
     396    {"chmod",   riscos_chmod,  METH_VARARGS},
     397    {"utime",           riscos_utime,  METH_VARARGS},
     398    {"settype",         riscos_settype, METH_VARARGS},
     399    {"getenv",  riscos_getenv, METH_VARARGS},
     400    {"putenv",  riscos_putenv, METH_VARARGS},
     401    {"delenv",  riscos_delenv, METH_VARARGS},
     402    {"getenvdict", riscos_getenvdict, METH_VARARGS},
     403    {NULL,              NULL}            /* Sentinel */
    404404};
    405405
     
    407407ins(PyObject *module, char *symbol, long value)
    408408{
    409         return PyModule_AddIntConstant(module, symbol, value);
     409    return PyModule_AddIntConstant(module, symbol, value);
    410410}
    411411
     
    415415{
    416416#ifdef F_OK
    417         if (ins(d, "F_OK", (long)F_OK)) return -1;
     417    if (ins(d, "F_OK", (long)F_OK)) return -1;
    418418#endif
    419419#ifdef R_OK
    420         if (ins(d, "R_OK", (long)R_OK)) return -1;
     420    if (ins(d, "R_OK", (long)R_OK)) return -1;
    421421#endif
    422422#ifdef W_OK
    423         if (ins(d, "W_OK", (long)W_OK)) return -1;
     423    if (ins(d, "W_OK", (long)W_OK)) return -1;
    424424#endif
    425425#ifdef X_OK
    426         if (ins(d, "X_OK", (long)X_OK)) return -1;
     426    if (ins(d, "X_OK", (long)X_OK)) return -1;
    427427#endif
    428428#ifdef NGROUPS_MAX
    429         if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1;
     429    if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1;
    430430#endif
    431431#ifdef TMP_MAX
    432         if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1;
     432    if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1;
    433433#endif
    434434#ifdef WCONTINUED
    435         if (ins(d, "WCONTINUED", (long)WCONTINUED)) return -1;
     435    if (ins(d, "WCONTINUED", (long)WCONTINUED)) return -1;
    436436#endif
    437437#ifdef WNOHANG
    438         if (ins(d, "WNOHANG", (long)WNOHANG)) return -1;
     438    if (ins(d, "WNOHANG", (long)WNOHANG)) return -1;
    439439#endif
    440440#ifdef WUNTRACED
    441         if (ins(d, "WUNTRACED", (long)WUNTRACED)) return -1;
     441    if (ins(d, "WUNTRACED", (long)WUNTRACED)) return -1;
    442442#endif
    443443#ifdef O_RDONLY
    444         if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1;
     444    if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1;
    445445#endif
    446446#ifdef O_WRONLY
    447         if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1;
     447    if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1;
    448448#endif
    449449#ifdef O_RDWR
    450         if (ins(d, "O_RDWR", (long)O_RDWR)) return -1;
     450    if (ins(d, "O_RDWR", (long)O_RDWR)) return -1;
    451451#endif
    452452#ifdef O_NDELAY
    453         if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1;
     453    if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1;
    454454#endif
    455455#ifdef O_NONBLOCK
    456         if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1;
     456    if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1;
    457457#endif
    458458#ifdef O_APPEND
    459         if (ins(d, "O_APPEND", (long)O_APPEND)) return -1;
     459    if (ins(d, "O_APPEND", (long)O_APPEND)) return -1;
    460460#endif
    461461#ifdef O_DSYNC
    462         if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1;
     462    if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1;
    463463#endif
    464464#ifdef O_RSYNC
    465         if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1;
     465    if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1;
    466466#endif
    467467#ifdef O_SYNC
    468         if (ins(d, "O_SYNC", (long)O_SYNC)) return -1;
     468    if (ins(d, "O_SYNC", (long)O_SYNC)) return -1;
    469469#endif
    470470#ifdef O_NOCTTY
    471         if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1;
     471    if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1;
    472472#endif
    473473#ifdef O_CREAT
    474         if (ins(d, "O_CREAT", (long)O_CREAT)) return -1;
     474    if (ins(d, "O_CREAT", (long)O_CREAT)) return -1;
    475475#endif
    476476#ifdef O_EXCL
    477         if (ins(d, "O_EXCL", (long)O_EXCL)) return -1;
     477    if (ins(d, "O_EXCL", (long)O_EXCL)) return -1;
    478478#endif
    479479#ifdef O_TRUNC
    480         if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1;
     480    if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1;
    481481#endif
    482482#ifdef O_BINARY
    483         if (ins(d, "O_BINARY", (long)O_BINARY)) return -1;
     483    if (ins(d, "O_BINARY", (long)O_BINARY)) return -1;
    484484#endif
    485485#ifdef O_TEXT
    486         if (ins(d, "O_TEXT", (long)O_TEXT)) return -1;
     486    if (ins(d, "O_TEXT", (long)O_TEXT)) return -1;
    487487#endif
    488488#ifdef O_LARGEFILE
    489         if (ins(d, "O_LARGEFILE", (long)O_LARGEFILE)) return -1;
     489    if (ins(d, "O_LARGEFILE", (long)O_LARGEFILE)) return -1;
    490490#endif
    491491
    492492/* MS Windows */
    493493#ifdef O_NOINHERIT
    494         /* Don't inherit in child processes. */
    495         if (ins(d, "O_NOINHERIT", (long)O_NOINHERIT)) return -1;
     494    /* Don't inherit in child processes. */
     495    if (ins(d, "O_NOINHERIT", (long)O_NOINHERIT)) return -1;
    496496#endif
    497497#ifdef _O_SHORT_LIVED
    498         /* Optimize for short life (keep in memory). */
    499         /* MS forgot to define this one with a non-underscore form too. */
    500         if (ins(d, "O_SHORT_LIVED", (long)_O_SHORT_LIVED)) return -1;
     498    /* Optimize for short life (keep in memory). */
     499    /* MS forgot to define this one with a non-underscore form too. */
     500    if (ins(d, "O_SHORT_LIVED", (long)_O_SHORT_LIVED)) return -1;
    501501#endif
    502502#ifdef O_TEMPORARY
    503         /* Automatically delete when last handle is closed. */
    504         if (ins(d, "O_TEMPORARY", (long)O_TEMPORARY)) return -1;
     503    /* Automatically delete when last handle is closed. */
     504    if (ins(d, "O_TEMPORARY", (long)O_TEMPORARY)) return -1;
    505505#endif
    506506#ifdef O_RANDOM
    507         /* Optimize for random access. */
    508         if (ins(d, "O_RANDOM", (long)O_RANDOM)) return -1;
     507    /* Optimize for random access. */
     508    if (ins(d, "O_RANDOM", (long)O_RANDOM)) return -1;
    509509#endif
    510510#ifdef O_SEQUENTIAL
    511         /* Optimize for sequential access. */
    512         if (ins(d, "O_SEQUENTIAL", (long)O_SEQUENTIAL)) return -1;
     511    /* Optimize for sequential access. */
     512    if (ins(d, "O_SEQUENTIAL", (long)O_SEQUENTIAL)) return -1;
    513513#endif
    514514
    515515/* GNU extensions. */
    516516#ifdef O_DIRECT
    517         /* Direct disk access. */
    518         if (ins(d, "O_DIRECT", (long)O_DIRECT)) return -1;
     517    /* Direct disk access. */
     518    if (ins(d, "O_DIRECT", (long)O_DIRECT)) return -1;
    519519#endif
    520520#ifdef O_DIRECTORY
    521         /* Must be a directory. */
    522         if (ins(d, "O_DIRECTORY", (long)O_DIRECTORY)) return -1;
     521    /* Must be a directory.      */
     522    if (ins(d, "O_DIRECTORY", (long)O_DIRECTORY)) return -1;
    523523#endif
    524524#ifdef O_NOFOLLOW
    525         /* Do not follow links. */
    526         if (ins(d, "O_NOFOLLOW", (long)O_NOFOLLOW)) return -1;
    527 #endif
    528 
    529         /* These come from sysexits.h */
     525    /* Do not follow links.      */
     526    if (ins(d, "O_NOFOLLOW", (long)O_NOFOLLOW)) return -1;
     527#endif
     528
     529    /* These come from sysexits.h */
    530530#ifdef EX_OK
    531         if (ins(d, "EX_OK", (long)EX_OK)) return -1;
     531    if (ins(d, "EX_OK", (long)EX_OK)) return -1;
    532532#endif /* EX_OK */
    533533#ifdef EX_USAGE
    534         if (ins(d, "EX_USAGE", (long)EX_USAGE)) return -1;
     534    if (ins(d, "EX_USAGE", (long)EX_USAGE)) return -1;
    535535#endif /* EX_USAGE */
    536536#ifdef EX_DATAERR
    537         if (ins(d, "EX_DATAERR", (long)EX_DATAERR)) return -1;
     537    if (ins(d, "EX_DATAERR", (long)EX_DATAERR)) return -1;
    538538#endif /* EX_DATAERR */
    539539#ifdef EX_NOINPUT
    540         if (ins(d, "EX_NOINPUT", (long)EX_NOINPUT)) return -1;
     540    if (ins(d, "EX_NOINPUT", (long)EX_NOINPUT)) return -1;
    541541#endif /* EX_NOINPUT */
    542542#ifdef EX_NOUSER
    543         if (ins(d, "EX_NOUSER", (long)EX_NOUSER)) return -1;
     543    if (ins(d, "EX_NOUSER", (long)EX_NOUSER)) return -1;
    544544#endif /* EX_NOUSER */
    545545#ifdef EX_NOHOST
    546         if (ins(d, "EX_NOHOST", (long)EX_NOHOST)) return -1;
     546    if (ins(d, "EX_NOHOST", (long)EX_NOHOST)) return -1;
    547547#endif /* EX_NOHOST */
    548548#ifdef EX_UNAVAILABLE
    549         if (ins(d, "EX_UNAVAILABLE", (long)EX_UNAVAILABLE)) return -1;
     549    if (ins(d, "EX_UNAVAILABLE", (long)EX_UNAVAILABLE)) return -1;
    550550#endif /* EX_UNAVAILABLE */
    551551#ifdef EX_SOFTWARE
    552         if (ins(d, "EX_SOFTWARE", (long)EX_SOFTWARE)) return -1;
     552    if (ins(d, "EX_SOFTWARE", (long)EX_SOFTWARE)) return -1;
    553553#endif /* EX_SOFTWARE */
    554554#ifdef EX_OSERR
    555         if (ins(d, "EX_OSERR", (long)EX_OSERR)) return -1;
     555    if (ins(d, "EX_OSERR", (long)EX_OSERR)) return -1;
    556556#endif /* EX_OSERR */
    557557#ifdef EX_OSFILE
    558         if (ins(d, "EX_OSFILE", (long)EX_OSFILE)) return -1;
     558    if (ins(d, "EX_OSFILE", (long)EX_OSFILE)) return -1;
    559559#endif /* EX_OSFILE */
    560560#ifdef EX_CANTCREAT
    561         if (ins(d, "EX_CANTCREAT", (long)EX_CANTCREAT)) return -1;
     561    if (ins(d, "EX_CANTCREAT", (long)EX_CANTCREAT)) return -1;
    562562#endif /* EX_CANTCREAT */
    563563#ifdef EX_IOERR
    564         if (ins(d, "EX_IOERR", (long)EX_IOERR)) return -1;
     564    if (ins(d, "EX_IOERR", (long)EX_IOERR)) return -1;
    565565#endif /* EX_IOERR */
    566566#ifdef EX_TEMPFAIL
    567         if (ins(d, "EX_TEMPFAIL", (long)EX_TEMPFAIL)) return -1;
     567    if (ins(d, "EX_TEMPFAIL", (long)EX_TEMPFAIL)) return -1;
    568568#endif /* EX_TEMPFAIL */
    569569#ifdef EX_PROTOCOL
    570         if (ins(d, "EX_PROTOCOL", (long)EX_PROTOCOL)) return -1;
     570    if (ins(d, "EX_PROTOCOL", (long)EX_PROTOCOL)) return -1;
    571571#endif /* EX_PROTOCOL */
    572572#ifdef EX_NOPERM
    573         if (ins(d, "EX_NOPERM", (long)EX_NOPERM)) return -1;
     573    if (ins(d, "EX_NOPERM", (long)EX_NOPERM)) return -1;
    574574#endif /* EX_NOPERM */
    575575#ifdef EX_CONFIG
    576         if (ins(d, "EX_CONFIG", (long)EX_CONFIG)) return -1;
     576    if (ins(d, "EX_CONFIG", (long)EX_CONFIG)) return -1;
    577577#endif /* EX_CONFIG */
    578578#ifdef EX_NOTFOUND
    579         if (ins(d, "EX_NOTFOUND", (long)EX_NOTFOUND)) return -1;
     579    if (ins(d, "EX_NOTFOUND", (long)EX_NOTFOUND)) return -1;
    580580#endif /* EX_NOTFOUND */
    581581
    582         return 0;
     582    return 0;
    583583}
    584584
     
    587587initriscos()
    588588{
    589         PyObject *m, *d, *stat_m;
    590 
    591         m = Py_InitModule("riscos", riscos_methods);
    592 
    593         if (all_ins(m))
    594                 return;
    595 
    596         d = PyModule_GetDict(m);
    597 
    598         Py_INCREF(PyExc_OSError);
    599         PyModule_AddObject(m, "error", PyExc_OSError);
    600 
    601         PyStructSequence_InitType(&StatResultType, &stat_result_desc);
    602         PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType);
    603 }
     589    PyObject *m, *d, *stat_m;
     590
     591    m = Py_InitModule("riscos", riscos_methods);
     592
     593    if (all_ins(m))
     594        return;
     595
     596    d = PyModule_GetDict(m);
     597
     598    Py_INCREF(PyExc_OSError);
     599    PyModule_AddObject(m, "error", PyExc_OSError);
     600
     601    PyStructSequence_InitType(&StatResultType, &stat_result_desc);
     602    PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType);
     603}
  • python/vendor/current/RISCOS/Python/dynload_riscos.c

    r2 r388  
    4040
    4141const struct filedescr _PyImport_DynLoadFiletab[] = {
    42         {"/pyd", "rb", C_EXTENSION},
    43         {0, 0}
     42    {"/pyd", "rb", C_EXTENSION},
     43    {0, 0}
    4444};
    4545
     
    4949
    5050dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
    51                                     char *pathname, FILE *fp)
     51                                    char *pathname, FILE *fp)
    5252{
    53         int err;
    54         char errstr[256];
    55         void (*init_function)(void);
     53    int err;
     54    char errstr[256];
     55    void (*init_function)(void);
    5656
    57         err = dlk_load_no_init(pathname, &init_function);
    58         if (err) {
    59             PyOS_snprintf(errstr, sizeof(errstr), "dlk failure %d", err);
    60             PyErr_SetString(PyExc_ImportError, errstr);
    61         }
    62         return init_function;
     57    err = dlk_load_no_init(pathname, &init_function);
     58    if (err) {
     59        PyOS_snprintf(errstr, sizeof(errstr), "dlk failure %d", err);
     60        PyErr_SetString(PyExc_ImportError, errstr);
     61    }
     62    return init_function;
    6363}
  • python/vendor/current/RISCOS/sleep.c

    r2 r388  
    1010int riscos_sleep(double delay)
    1111{
    12         os_t starttime, endtime, time; /* monotonic times (centiseconds) */
    13         int *pollword, ret;
    14         osbool claimed;
     12    os_t starttime, endtime, time; /* monotonic times (centiseconds) */
     13    int *pollword, ret;
     14    osbool claimed;
    1515
    16         /* calculate end time */
    17         starttime = os_read_monotonic_time();
    18         if (starttime + 100.0*delay >INT_MAX)
    19                 endtime = INT_MAX;
    20         else
    21                 endtime = (os_t)(starttime + 100.0*delay);
     16    /* calculate end time */
     17    starttime = os_read_monotonic_time();
     18    if (starttime + 100.0*delay >INT_MAX)
     19        endtime = INT_MAX;
     20    else
     21        endtime = (os_t)(starttime + 100.0*delay);
    2222
    23         /* allocate (in RMA) and set pollword for xupcall_sleep */
    24         pollword = osmodule_alloc(4);
    25         *pollword = 1;
     23    /* allocate (in RMA) and set pollword for xupcall_sleep */
     24    pollword = osmodule_alloc(4);
     25    *pollword = 1;
    2626
    27         time = starttime;
    28         ret = 0;
    29         while ( time<endtime && time>=starttime ) {
    30                 xupcall_sleep (pollword, &claimed);
    31                 if (PyErr_CheckSignals()) {
    32                         ret = 1;
    33                         break;
    34                 }
    35                 time = os_read_monotonic_time();
    36         }
     27    time = starttime;
     28    ret = 0;
     29    while ( time<endtime && time>=starttime ) {
     30        xupcall_sleep (pollword, &claimed);
     31        if (PyErr_CheckSignals()) {
     32            ret = 1;
     33            break;
     34        }
     35        time = os_read_monotonic_time();
     36    }
    3737
    38         /* deallocate pollword */
    39         osmodule_free(pollword);
    40         return ret;
     38    /* deallocate pollword */
     39    osmodule_free(pollword);
     40    return ret;
    4141}
Note: See TracChangeset for help on using the changeset viewer.