Commit 401cd90a by Jakub Jelinek Committed by Jakub Jelinek

ftell.c (ftell, FTELL_SUB): Add unlock_unit call.

	* intrinsics/ftell.c (ftell, FTELL_SUB): Add unlock_unit call.
	* intrinsics/fget.c (fgetc, fputs): Likewise.
	* intrinsics/tty.c (ttynam): Likewise.

From-SVN: r107595
parent 07a3df01
2005-11-28 Jakub Jelinek <jakub@redhat.com>
* intrinsics/ftell.c (ftell, FTELL_SUB): Add unlock_unit call.
* intrinsics/fget.c (fgetc, fputs): Likewise.
* intrinsics/tty.c (ttynam): Likewise.
2005-11-27 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2005-11-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/25109 PR libgfortran/25109
......
...@@ -54,6 +54,7 @@ PREFIX(fgetc) (const int * unit, char * c, gfc_charlen_type c_len) ...@@ -54,6 +54,7 @@ PREFIX(fgetc) (const int * unit, char * c, gfc_charlen_type c_len)
s = 1; s = 1;
memset (c, ' ', c_len); memset (c, ' ', c_len);
ret = sread (u->s, c, &s); ret = sread (u->s, c, &s);
unlock_unit (u);
if (ret != 0) if (ret != 0)
return ret; return ret;
...@@ -118,13 +119,16 @@ PREFIX(fputc) (const int * unit, char * c, ...@@ -118,13 +119,16 @@ PREFIX(fputc) (const int * unit, char * c,
gfc_charlen_type c_len __attribute__((unused))) gfc_charlen_type c_len __attribute__((unused)))
{ {
size_t s; size_t s;
int ret;
gfc_unit * u = find_unit (*unit); gfc_unit * u = find_unit (*unit);
if (u == NULL) if (u == NULL)
return -1; return -1;
s = 1; s = 1;
return swrite (u->s, c, &s); ret = swrite (u->s, c, &s);
unlock_unit (u);
return ret;
} }
......
...@@ -42,10 +42,12 @@ size_t ...@@ -42,10 +42,12 @@ size_t
PREFIX(ftell) (int * unit) PREFIX(ftell) (int * unit)
{ {
gfc_unit * u = find_unit (*unit); gfc_unit * u = find_unit (*unit);
size_t ret;
if (u == NULL) if (u == NULL)
return ((size_t) -1); return ((size_t) -1);
else ret = (size_t) stream_offset (u->s);
return ((size_t) stream_offset (u->s)); unlock_unit (u);
return ret;
} }
#define FTELL_SUB(kind) \ #define FTELL_SUB(kind) \
...@@ -58,7 +60,10 @@ PREFIX(ftell) (int * unit) ...@@ -58,7 +60,10 @@ PREFIX(ftell) (int * unit)
if (u == NULL) \ if (u == NULL) \
*offset = -1; \ *offset = -1; \
else \ else \
*offset = stream_offset (u->s); \ { \
*offset = stream_offset (u->s); \
unlock_unit (u); \
} \
} }
FTELL_SUB(1) FTELL_SUB(1)
......
...@@ -121,8 +121,10 @@ ttynam (char ** name, gfc_charlen_type * name_len, int unit) ...@@ -121,8 +121,10 @@ ttynam (char ** name, gfc_charlen_type * name_len, int unit)
{ {
*name_len = strlen (*name); *name_len = strlen (*name);
*name = strdup (*name); *name = strdup (*name);
unlock_unit (u);
return; return;
} }
unlock_unit (u);
} }
*name_len = 0; *name_len = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment