Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
11c6c532
Commit
11c6c532
authored
13 years ago
by
Piotr Caban
Committed by
Alexandre Julliard
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
msvcrt: Make FILE reading functions thread safe.
parent
f2d425b7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/msvcrt/file.c
+37
-3
37 additions, 3 deletions
dlls/msvcrt/file.c
with
37 additions
and
3 deletions
dlls/msvcrt/file.c
+
37
−
3
View file @
11c6c532
...
...
@@ -2686,12 +2686,16 @@ int CDECL MSVCRT_fgetc(MSVCRT_FILE* file)
{
unsigned
char
*
i
;
unsigned
int
j
;
MSVCRT__lock_file
(
file
);
if
(
file
->
_cnt
>
0
)
{
file
->
_cnt
--
;
i
=
(
unsigned
char
*
)
file
->
_ptr
++
;
j
=
*
i
;
}
else
j
=
MSVCRT__filbuf
(
file
);
MSVCRT__unlock_file
(
file
);
return
j
;
}
...
...
@@ -2714,6 +2718,8 @@ char * CDECL MSVCRT_fgets(char *s, int size, MSVCRT_FILE* file)
TRACE
(
":file(%p) fd (%d) str (%p) len (%d)
\n
"
,
file
,
file
->
_file
,
s
,
size
);
MSVCRT__lock_file
(
file
);
while
((
size
>
1
)
&&
(
cc
=
MSVCRT_fgetc
(
file
))
!=
MSVCRT_EOF
&&
cc
!=
'\n'
)
{
*
s
++
=
(
char
)
cc
;
...
...
@@ -2722,12 +2728,14 @@ char * CDECL MSVCRT_fgets(char *s, int size, MSVCRT_FILE* file)
if
((
cc
==
MSVCRT_EOF
)
&&
(
s
==
buf_start
))
/* If nothing read, return 0*/
{
TRACE
(
":nothing read
\n
"
);
MSVCRT__unlock_file
(
file
);
return
NULL
;
}
if
((
cc
!=
MSVCRT_EOF
)
&&
(
size
>
1
))
*
s
++
=
cc
;
*
s
=
'\0'
;
TRACE
(
":got %s
\n
"
,
debugstr_a
(
buf_start
));
MSVCRT__unlock_file
(
file
);
return
buf_start
;
}
...
...
@@ -2741,6 +2749,7 @@ MSVCRT_wint_t CDECL MSVCRT_fgetwc(MSVCRT_FILE* file)
{
int
c
;
MSVCRT__lock_file
(
file
);
if
(
!
(
msvcrt_get_ioinfo
(
file
->
_file
)
->
wxflag
&
WX_TEXT
))
{
MSVCRT_wchar_t
wc
;
...
...
@@ -2763,11 +2772,15 @@ MSVCRT_wint_t CDECL MSVCRT_fgetwc(MSVCRT_FILE* file)
{
file
->
_flag
|=
(
file
->
_cnt
==
0
)
?
MSVCRT__IOEOF
:
MSVCRT__IOERR
;
file
->
_cnt
=
0
;
MSVCRT__unlock_file
(
file
);
return
MSVCRT_WEOF
;
}
wcp
[
i
]
=
j
;
}
}
MSVCRT__unlock_file
(
file
);
return
wc
;
}
...
...
@@ -2776,6 +2789,8 @@ MSVCRT_wint_t CDECL MSVCRT_fgetwc(MSVCRT_FILE* file)
{
FIXME
(
"Treat Multibyte characters
\n
"
);
}
MSVCRT__unlock_file
(
file
);
if
(
c
==
MSVCRT_EOF
)
return
MSVCRT_WEOF
;
else
...
...
@@ -2791,14 +2806,19 @@ int CDECL MSVCRT__getw(MSVCRT_FILE* file)
int
i
,
k
;
unsigned
int
j
;
ch
=
(
char
*
)
&
i
;
MSVCRT__lock_file
(
file
);
for
(
j
=
0
;
j
<
sizeof
(
int
);
j
++
)
{
k
=
MSVCRT_fgetc
(
file
);
if
(
k
==
MSVCRT_EOF
)
{
file
->
_flag
|=
MSVCRT__IOEOF
;
MSVCRT__unlock_file
(
file
);
return
EOF
;
}
ch
[
j
]
=
k
;
}
MSVCRT__unlock_file
(
file
);
return
i
;
}
...
...
@@ -2837,6 +2857,8 @@ MSVCRT_wchar_t * CDECL MSVCRT_fgetws(MSVCRT_wchar_t *s, int size, MSVCRT_FILE* f
TRACE
(
":file(%p) fd (%d) str (%p) len (%d)
\n
"
,
file
,
file
->
_file
,
s
,
size
);
MSVCRT__lock_file
(
file
);
while
((
size
>
1
)
&&
(
cc
=
MSVCRT_fgetwc
(
file
))
!=
MSVCRT_WEOF
&&
cc
!=
'\n'
)
{
*
s
++
=
(
char
)
cc
;
...
...
@@ -2845,12 +2867,14 @@ MSVCRT_wchar_t * CDECL MSVCRT_fgetws(MSVCRT_wchar_t *s, int size, MSVCRT_FILE* f
if
((
cc
==
MSVCRT_WEOF
)
&&
(
s
==
buf_start
))
/* If nothing read, return 0*/
{
TRACE
(
":nothing read
\n
"
);
MSVCRT__unlock_file
(
file
);
return
NULL
;
}
if
((
cc
!=
MSVCRT_WEOF
)
&&
(
size
>
1
))
*
s
++
=
cc
;
*
s
=
0
;
TRACE
(
":got %s
\n
"
,
debugstr_w
(
buf_start
));
MSVCRT__unlock_file
(
file
);
return
buf_start
;
}
...
...
@@ -3104,13 +3128,16 @@ int CDECL _fputchar(int c)
* fread (MSVCRT.@)
*/
MSVCRT_size_t
CDECL
MSVCRT_fread
(
void
*
ptr
,
MSVCRT_size_t
size
,
MSVCRT_size_t
nmemb
,
MSVCRT_FILE
*
file
)
{
MSVCRT_size_t
rcnt
=
size
*
nmemb
;
{
MSVCRT_size_t
rcnt
=
size
*
nmemb
;
MSVCRT_size_t
read
=
0
;
int
pread
=
0
;
if
(
!
rcnt
)
return
0
;
MSVCRT__lock_file
(
file
);
/* first buffered data */
if
(
file
->
_cnt
>
0
)
{
int
pcnt
=
(
rcnt
>
file
->
_cnt
)
?
file
->
_cnt
:
rcnt
;
...
...
@@ -3123,8 +3150,10 @@ MSVCRT_size_t CDECL MSVCRT_fread(void *ptr, MSVCRT_size_t size, MSVCRT_size_t nm
}
else
if
(
!
(
file
->
_flag
&
MSVCRT__IOREAD
))
{
if
(
file
->
_flag
&
MSVCRT__IORW
)
{
file
->
_flag
|=
MSVCRT__IOREAD
;
}
else
return
0
;
}
else
{
MSVCRT__unlock_file
(
file
);
return
0
;
}
}
while
(
rcnt
>
0
)
{
...
...
@@ -3169,6 +3198,7 @@ MSVCRT_size_t CDECL MSVCRT_fread(void *ptr, MSVCRT_size_t size, MSVCRT_size_t nm
if
(
i
<
1
)
break
;
}
read
+=
pread
;
MSVCRT__unlock_file
(
file
);
return
read
/
size
;
}
...
...
@@ -3396,6 +3426,7 @@ char * CDECL MSVCRT_gets(char *buf)
int
cc
;
char
*
buf_start
=
buf
;
MSVCRT__lock_file
(
MSVCRT_stdin
);
for
(
cc
=
MSVCRT_fgetc
(
MSVCRT_stdin
);
cc
!=
MSVCRT_EOF
&&
cc
!=
'\n'
;
cc
=
MSVCRT_fgetc
(
MSVCRT_stdin
))
if
(
cc
!=
'\r'
)
*
buf
++
=
(
char
)
cc
;
...
...
@@ -3403,6 +3434,7 @@ char * CDECL MSVCRT_gets(char *buf)
*
buf
=
'\0'
;
TRACE
(
"got '%s'
\n
"
,
buf_start
);
MSVCRT__unlock_file
(
MSVCRT_stdin
);
return
buf_start
;
}
...
...
@@ -3414,6 +3446,7 @@ MSVCRT_wchar_t* CDECL MSVCRT__getws(MSVCRT_wchar_t* buf)
MSVCRT_wint_t
cc
;
MSVCRT_wchar_t
*
ws
=
buf
;
MSVCRT__lock_file
(
MSVCRT_stdin
);
for
(
cc
=
MSVCRT_fgetwc
(
MSVCRT_stdin
);
cc
!=
MSVCRT_WEOF
&&
cc
!=
'\n'
;
cc
=
MSVCRT_fgetwc
(
MSVCRT_stdin
))
{
...
...
@@ -3423,6 +3456,7 @@ MSVCRT_wchar_t* CDECL MSVCRT__getws(MSVCRT_wchar_t* buf)
*
buf
=
'\0'
;
TRACE
(
"got %s
\n
"
,
debugstr_w
(
ws
));
MSVCRT__unlock_file
(
MSVCRT_stdin
);
return
ws
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment