Skip to content

Commit 8e791e3

Browse files
committed
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
1 parent 49fbc9f commit 8e791e3

11 files changed

Lines changed: 243 additions & 165 deletions

File tree

Lib/plat-riscos/riscospath.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,30 @@ def exists(p):
203203
"""
204204
Test whether a path exists.
205205
"""
206-
return swi.swi('OS_File', '5s;i', p)!=0
206+
try:
207+
return swi.swi('OS_File', '5s;i', p)!=0
208+
except swi.error:
209+
return 0
207210

208211

209212
def isdir(p):
210213
"""
211214
Is a path a directory? Includes image files.
212215
"""
213-
return swi.swi('OS_File', '5s;i', p) in [2, 3]
216+
try:
217+
return swi.swi('OS_File', '5s;i', p) in [2, 3]
218+
except swi.error:
219+
return 0
214220

215221

216222
def isfile(p):
217223
"""
218224
Test whether a path is a file, including image files.
219225
"""
220-
return swi.swi('OS_File', '5s;i', p) in [1, 3]
226+
try:
227+
return swi.swi('OS_File', '5s;i', p) in [1, 3]
228+
except swi.error:
229+
return 0
221230

222231

223232
def islink(p):

Modules/main.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@
2626
static char **orig_argv;
2727
static int orig_argc;
2828

29-
/* For my_readline when running under RISCOS */
30-
#ifdef RISCOS
29+
/* command line options */
30+
#define BASE_OPTS "c:diOStuUvxXhVW:"
31+
32+
#ifndef RISCOS
33+
#define PROGRAM_OPTS BASE_OPTS
34+
#else /*RISCOS*/
35+
/* extra option saying that we are running under a special task window
36+
frontend; especially my_readline will behave different */
37+
#define PROGRAM_OPTS BASE_OPTS "w"
38+
/* corresponding flag */
3139
extern int Py_RISCOSWimpFlag;
32-
#endif
40+
#endif /*RISCOS*/
3341

3442
/* Short usage message (with %s for argv0) */
3543
static char *usage_line =
@@ -115,11 +123,7 @@ Py_Main(int argc, char **argv)
115123

116124
PySys_ResetWarnOptions();
117125

118-
#ifdef RISCOS
119-
while ((c = getopt(argc, argv, "c:diOStuUvwxXhV")) != EOF) {
120-
#else
121-
while ((c = _PyOS_GetOpt(argc, argv, "c:diOStuUvxXhVW:")) != EOF) {
122-
#endif
126+
while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
123127
if (c == 'c') {
124128
/* -c is the last option; following arguments
125129
that look like options are left for the

Modules/timemodule.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,7 @@ floatsleep(double secs)
756756
#if defined(__WATCOMC__) && !defined(__QNX__)
757757
/* XXX Can't interrupt this sleep */
758758
Py_BEGIN_ALLOW_THREADS
759-
#ifndef RISCOS
760759
delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */
761-
#endif
762760
Py_END_ALLOW_THREADS
763761
#else /* !__WATCOMC__ || __QNX__ */
764762
#ifdef MSDOS
@@ -831,10 +829,20 @@ floatsleep(double secs)
831829
Py_END_ALLOW_THREADS
832830
}
833831
#else /* !__BEOS__ */
832+
#ifdef RISCOS
833+
if (secs <= 0.0)
834+
return 0;
835+
Py_BEGIN_ALLOW_THREADS
836+
/* This sleep *CAN BE* interrupted. */
837+
if ( sleep(secs) )
838+
return -1;
839+
Py_END_ALLOW_THREADS
840+
#else /* !RISCOS */
834841
/* XXX Can't interrupt this sleep */
835842
Py_BEGIN_ALLOW_THREADS
836843
sleep((int)secs);
837844
Py_END_ALLOW_THREADS
845+
#endif /* !RISCOS */
838846
#endif /* !__BEOS__ */
839847
#endif /* !PYOS_OS2 */
840848
#endif /* !MS_WIN32 */

Python/sysmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,11 @@ PySys_SetArgv(int argc, char **argv)
808808
if (argc > 0 && argv0 != NULL)
809809
p = strrchr(argv0, SEP);
810810
if (p != NULL) {
811+
#ifndef RISCOS
811812
n = p + 1 - argv0;
813+
#else /* don't include trailing separator */
814+
n = p - argv0;
815+
#endif /* RISCOS */
812816
#if SEP == '/' /* Special case for Unix filename syntax */
813817
if (n > 1)
814818
n--; /* Drop trailing separator */

0 commit comments

Comments
 (0)