Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
4cd3a16f
Commit
4cd3a16f
authored
Oct 04, 2007
by
Dan Kegel
Committed by
Alexandre Julliard
Oct 05, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Improve CR CR LF handling.
parent
75c13b8e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
file.c
dlls/msvcrt/file.c
+11
-4
file.c
dlls/msvcrt/tests/file.c
+18
-0
No files found.
dlls/msvcrt/file.c
View file @
4cd3a16f
...
...
@@ -1639,15 +1639,21 @@ int CDECL _rmtmp(void)
/*********************************************************************
* (internal) remove_cr
*
*
Remove all \r
inplace.
*
Translate all \r\n to \n
inplace.
* return the number of \r removed
* Corner cases required by some apps:
* \r\r\n -> \r\n
* BUG: should save state across calls somehow, so CR LF that
* straddles buffer boundary gets recognized properly?
*/
static
unsigned
int
remove_cr
(
char
*
buf
,
unsigned
int
count
)
{
unsigned
int
i
,
j
;
for
(
i
=
0
;
i
<
count
;
i
++
)
if
(
buf
[
i
]
==
'\r'
)
break
;
for
(
j
=
i
+
1
;
j
<
count
;
j
++
)
if
(
buf
[
j
]
!=
'\r'
)
buf
[
i
++
]
=
buf
[
j
];
for
(
i
=
0
,
j
=
0
;
j
<
count
;
j
++
)
if
((
buf
[
j
]
!=
'\r'
)
||
((
j
+
1
)
<
count
&&
buf
[
j
+
1
]
!=
'\n'
))
buf
[
i
++
]
=
buf
[
j
];
return
count
-
i
;
}
...
...
@@ -2210,7 +2216,8 @@ int CDECL MSVCRT_fgetc(MSVCRT_FILE* file)
j
=
*
i
;
}
else
j
=
MSVCRT__filbuf
(
file
);
if
(
!
(
MSVCRT_fdesc
[
file
->
_file
].
wxflag
&
WX_TEXT
)
||
(
j
!=
'\r'
))
if
(
!
(
MSVCRT_fdesc
[
file
->
_file
].
wxflag
&
WX_TEXT
)
||
((
j
!=
'\r'
)
||
(
file
->
_cnt
&&
((
char
*
)
file
->
_ptr
)[
0
]
!=
'\n'
)))
return
j
;
}
while
(
1
);
}
...
...
dlls/msvcrt/tests/file.c
View file @
4cd3a16f
...
...
@@ -271,6 +271,23 @@ static void test_readmode( BOOL ascii_mode )
unlink
(
"fdopen.tst"
);
}
static
void
test_asciimode
(
void
)
{
FILE
*
fp
;
char
buf
[
64
];
/* Simple test of CR CR LF handling. Test both fgets and fread code paths, they're different! */
fp
=
fopen
(
"ascii.tst"
,
"wb"
);
fputs
(
"
\r\r\n
"
,
fp
);
fclose
(
fp
);
fp
=
fopen
(
"ascii.tst"
,
"rt"
);
ok
(
fgets
(
buf
,
sizeof
(
buf
),
fp
)
!=
NULL
,
"fgets
\n
"
);
ok
(
0
==
strcmp
(
buf
,
"
\r\n
"
),
"CR CR LF not read as CR LF
\n
"
);
rewind
(
fp
);
ok
((
fread
(
buf
,
1
,
sizeof
(
buf
),
fp
)
==
2
)
&&
(
0
==
strcmp
(
buf
,
"
\r\n
"
)),
"CR CR LF not read as CR LF
\n
"
);
fclose
(
fp
);
unlink
(
"ascii.tst"
);
}
static
WCHAR
*
AtoW
(
const
char
*
p
)
{
...
...
@@ -996,6 +1013,7 @@ START_TEST(file)
test_fdopen
();
test_fopen_fclose_fcloseall
();
test_fileops
();
test_asciimode
();
test_readmode
(
FALSE
);
/* binary mode */
test_readmode
(
TRUE
);
/* ascii mode */
test_fgetc
();
...
...
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