%@lines doesn't count last line without cr/lf at eof

Jun 2, 2008
21
0
TCC 17.00.51 x64 Windows 2008R2 [Version 6.1.7601]
TCC Build 51 Windows 2008R2 Build 7601 Service Pack 1

Using swedish keyboard and Regional and Language Options: Swedish

Counting lines in an Unicode/ANSI file with %@lines is incorrect if last line doesn't end with cr/lf.
With cr/lf at eof the counting is correct.

Example 1:
Create an Unicode or ANSI file containing 1 line with letter A (1 character long).
Add CR/LF and close the file. %@lines[file] returns 0. Correct.

Example 2:
Create an Unicode/ANSI file containing 1 line with letter A (1 character long) and close the file.
%@lines[file] returns -1. Wrong.

This is working correct in TCMD version 16.

Reproducible: Always.

Best regard
Berndt Berg
 
Similar threads
Thread starter Title Forum Replies Date
old coot Spurious errors (triggered by "for" construct?) when adding/removing "echo" lines Support 2
vefatica Continued lines (^) in a library routine? Support 5
R Lines between COMMENT & ENDCOMMENT not ignored Support 7
A TCMD - Dir Command puts out blank lines? Support 16
T FFind - can we display n number of lines after the find? Support 2
T WAD Difference between TCC and CMD in handling multi-command lines Support 6
JohnQSmith Weird DIR output (missing lines) Support 1
fpefpe Documentation Comment lines? Support 2
nickles Fixed Executing long command lines in a batch generates file name errors Support 16
nikbackm How to? Find duplicate lines in text file Support 0
S Documentation HELP nit: @LINES Support 5
B Select and run lines from Command Input panel? Support 1
D WAD New envars for @LINES are not hidden Support 8
T Documentation @LINE[CON,n] @LINES[CON] not documented (bug?) Support 4
M How to? Parsing lines containing double quotes... Support 3
Stefano Piccardi echoerr truncates long lines Support 9
M Just an out-of-curiosity question the List command vs. the @Lines function... Support 13
samintz How to? Pull out multiple matching lines Support 5
W Copy+Paste without breaking long lines as default? Support 1
L "for" in multiple lines Support 2
vefatica @LINES, long lines, TCC disappears Support 7
D Blank lines in jpstree.idx Support 3
T @Word from Lines with Pipes Support 3
vefatica @LINES[]? Support 1
J Extra blank lines during paste Support 6
vefatica How many lines are in this file? Support 17
nikbackm Trim last N lines from a file Support 6
T How do you echo lines with special characters to file? Support 4
B @lines: first line in the file is numbered 1 Support 0
R Reading an Unicode file with more than 8191 lines Support 1
vefatica Setting array variable ignores leading spaces (and @execarray doesn't) Support 4
MickeyF Why doesn't my python program get executed without specifying its path? Support 2
gworley Virtual network drive filename completion doesn’t get directories Support 0
vefatica Win10's ANSI doesn't like 2>NUL Support 10
vefatica Win10, alternative screen buffer, cursor doesn't blink Support 11
M Trying to use ffind with a @file.lst doesn't work Support 4
Charles Dye Ctrl-Shift-Up doesn't update directory history Support 1
gschizas Take Command (Environment) doesn't show v2 ANSI colors Support 30
vefatica Fixed JOBS /K doesn't work Support 2
E Fixed SHRALIAS doesn't work / SHRALIAS.EXE is missing in v20.11.35 Support 2
D WAD Reboot doesn't shutdown or restart Support 13
M Documentation Q.Search doesn't support selection? Support 1
R Fixed 7ZIP Compression Method Option Doesn't Work Support 1
T Regex engine doesn't recognize native DOS line endings Support 2
E Fixed DEDUPE doesn't handle filenames with whitespace properly when symlinking Support 1
D Docking doesn't persist Support 5
E WAD DESCRIBE under TCC 19 doesn't work with diacritics Support 14
C VIEW PRINT /Wrap doesn't work Support 0
D CD doesn't always find everything Support 8
M View doesn't recognize Ctrl+End and Ctrl+Pos1 Support 2

Similar threads