Skip to content

Commit a1be37b

Browse files
committed
Applied comment on manual.
1 parent d3f0a5a commit a1be37b

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

man/checkers/ftellTextModeFile.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
This checker detects the use of ftell() on a file open in text (or translate) mode. The text mode is not consistent
1111
in between Linux and Windows system and may cause ftell() to return the wrong offset inside a text file.
1212

13+
See section 7.21.9.4p2 of the C11 standard regarding the ftell function states for a text stream:
14+
15+
- For a text stream, its file position indicator contains unspecified information, usable by the fseek function for returning the file position indicator for the stream to its position at the time of the ftell call; the difference between two such return values is not necessarily a meaningful measure of the number of characters written or read.
16+
1317
This warning helps improve code quality by:
1418
- Making the intent clear that the use of ftell() in "t" mode may cause portability problem.
1519

@@ -26,12 +30,8 @@ Before:
2630
FILE *f = fopen("Example.txt", "rt");
2731
if (f)
2832
{
29-
int position;
30-
struct stat st;
31-
32-
// Wrong way to get the file size
3333
fseek(f, 0, SEEK_END);
34-
printf( "File size %d\n, ftell(f));
34+
printf( "File size %d\n", ftell(f));
3535
fclose(f);
3636
}
3737

@@ -44,7 +44,7 @@ After:
4444
if (f)
4545
{
4646
fseek(f, 0, SEEK_END);
47-
printf( "Offset %d\n", ftell(f);
47+
printf( "File size %d\n", ftell(f));
4848
fclose(f);
4949
}
5050

0 commit comments

Comments
 (0)