Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
26f796a0
Commit
26f796a0
authored
Mar 23, 1992
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved error handling.
parent
5e6d23f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
Modules/imgfile.c
Modules/imgfile.c
+19
-2
No files found.
Modules/imgfile.c
View file @
26f796a0
...
@@ -43,6 +43,15 @@ static object * ImgfileError;
...
@@ -43,6 +43,15 @@ static object * ImgfileError;
static
char
gfname
[
1024
];
static
char
gfname
[
1024
];
static
IMAGE
*
image
;
static
IMAGE
*
image
;
static
int
error_called
;
static
imgfile_error
(
str
)
char
*
str
;
{
err_setstr
(
ImgfileError
,
str
);
error_called
=
1
;
return
;
/* To imglib, which will return a failure indictaor */
}
static
static
imgfile_open
(
args
)
imgfile_open
(
args
)
...
@@ -52,13 +61,17 @@ imgfile_open(args)
...
@@ -52,13 +61,17 @@ imgfile_open(args)
if
(
!
getargs
(
args
,
"s"
,
&
fname
)
)
if
(
!
getargs
(
args
,
"s"
,
&
fname
)
)
return
0
;
return
0
;
i_seterror
(
imgfile_error
);
error_called
=
0
;
if
(
image
!=
NULL
&&
strcmp
(
fname
,
gfname
)
!=
0
)
{
if
(
image
!=
NULL
&&
strcmp
(
fname
,
gfname
)
!=
0
)
{
iclose
(
image
);
iclose
(
image
);
image
=
NULL
;
image
=
NULL
;
gfname
[
0
]
=
'\0'
;
gfname
[
0
]
=
'\0'
;
}
}
if
(
(
image
=
iopen
(
fname
,
"r"
))
==
NULL
)
{
if
(
(
image
=
iopen
(
fname
,
"r"
))
==
NULL
)
{
err_setstr
(
ImgfileError
,
"Cannot open image file"
);
/* Error may already be set by imgfile_error */
if
(
!
error_called
)
err_setstr
(
ImgfileError
,
"Cannot open image file"
);
return
0
;
return
0
;
}
}
strcpy
(
gfname
,
fname
);
strcpy
(
gfname
,
fname
);
...
@@ -103,7 +116,7 @@ imgfile_read(self, args)
...
@@ -103,7 +116,7 @@ imgfile_read(self, args)
return
NULL
;
return
NULL
;
cdatap
=
getstringvalue
(
rv
);
cdatap
=
getstringvalue
(
rv
);
idatap
=
(
long
*
)
cdatap
;
idatap
=
(
long
*
)
cdatap
;
for
(
y
=
0
;
y
<
ysize
;
y
++
)
{
for
(
y
=
0
;
y
<
ysize
&&
!
error_called
;
y
++
)
{
if
(
zsize
==
1
)
{
if
(
zsize
==
1
)
{
getrow
(
image
,
rs
,
y
,
0
);
getrow
(
image
,
rs
,
y
,
0
);
for
(
x
=
0
;
x
<
xsize
;
x
++
)
for
(
x
=
0
;
x
<
xsize
;
x
++
)
...
@@ -118,6 +131,10 @@ imgfile_read(self, args)
...
@@ -118,6 +131,10 @@ imgfile_read(self, args)
((
bs
[
x
]
&
0xff
)
<<
16
);
((
bs
[
x
]
&
0xff
)
<<
16
);
}
}
}
}
if
(
error_called
)
{
DECREF
(
rv
);
return
NULL
;
}
return
rv
;
return
rv
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment