Simplify and improve Guile FILE * in typemap
Fix incorrect special variable $name and remove unnecessary temporary variable.
This commit is contained in:
parent
3f9d7ed416
commit
04b9037c70
1 changed files with 19 additions and 22 deletions
|
|
@ -21,33 +21,30 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%typemap(in, doc="$NAME is a file port or a FILE * pointer") FILE *
|
%typemap(in, doc="$NAME is a file port or a FILE * pointer") FILE *
|
||||||
( int closep )
|
|
||||||
{
|
{
|
||||||
if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) == 0) {
|
if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) != 0) {
|
||||||
closep = 0;
|
if (!(SCM_FPORTP($input))) {
|
||||||
}
|
scm_wrong_type_arg("$symname", $argnum, $input);
|
||||||
else if(!(SCM_FPORTP($input)))
|
} else {
|
||||||
scm_wrong_type_arg("$name", $argnum, $input);
|
int fd;
|
||||||
else {
|
if (SCM_OUTPUT_PORT_P($input)) {
|
||||||
int fd;
|
scm_force_output($input);
|
||||||
if (SCM_OUTPUT_PORT_P($input))
|
}
|
||||||
scm_force_output($input);
|
fd=dup(SCM_FPORT_FDES($input));
|
||||||
fd=dup(SCM_FPORT_FDES($input));
|
if (fd==-1) {
|
||||||
if(fd==-1)
|
scm_misc_error("$symname", strerror(errno), SCM_EOL);
|
||||||
scm_misc_error("$name", strerror(errno), SCM_EOL);
|
}
|
||||||
$1=fdopen(fd,
|
$1=fdopen(fd, SCM_OUTPUT_PORT_P($input) ? (SCM_INPUT_PORT_P($input) ? "r+" : "w") : "r");
|
||||||
SCM_OUTPUT_PORT_P($input)
|
if ($1==NULL) {
|
||||||
? (SCM_INPUT_PORT_P($input)
|
scm_misc_error("$symname", strerror(errno), SCM_EOL);
|
||||||
? "r+" : "w")
|
}
|
||||||
: "r");
|
}
|
||||||
if($1==NULL)
|
|
||||||
scm_misc_error("$name", strerror(errno), SCM_EOL);
|
|
||||||
closep = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(freearg) FILE* {
|
%typemap(freearg) FILE* {
|
||||||
if (closep$argnum)
|
if ($1) {
|
||||||
fclose($1);
|
fclose($1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue