summaryrefslogtreecommitdiffstats
path: root/doc/gets.n
diff options
context:
space:
mode:
Diffstat (limited to 'doc/gets.n')
-rw-r--r--doc/gets.n49
1 files changed, 4 insertions, 45 deletions
diff --git a/doc/gets.n b/doc/gets.n
index 29355a4..fd1b87a 100644
--- a/doc/gets.n
+++ b/doc/gets.n
@@ -4,7 +4,7 @@
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
+'\"
.TH gets n 7.5 Tcl "Tcl Built-In Commands"
.so man.macros
.BS
@@ -35,55 +35,18 @@ returned.
.PP
If end of file occurs while scanning for an end of
line, the command returns whatever input is available up to the end of file.
-If \fIchannelId\fR is in non-blocking mode and there is not a full
+If \fIchannelId\fR is in nonblocking mode and there is not a full
line of input available, the command returns an empty string and
does not consume any input.
If \fIvarName\fR is specified and an empty string is returned in
\fIvarName\fR because of end-of-file or because of insufficient
-data in non-blocking mode, then the return count is -1.
+data in nonblocking mode, then the return count is -1.
Note that if \fIvarName\fR is not specified then the end-of-file
and no-full-line-available cases can
produce the same results as if there were an input line consisting
only of the end-of-line character(s).
The \fBeof\fR and \fBfblocked\fR commands can be used to distinguish
these three cases.
-.SH "ENCODING ERRORS"
-.PP
-Encoding errors may exist, if the encoding profile \fBstrict\fR is used.
-Encoding errors are special, as an eventual introspection or recovery is
-possible by changing to an encoding which accepts the data.
-An encoding error is reported by the POSIX error code \fBEILSEQ\fR.
-The file pointer is unchanged in the error case.
-.PP
-Here is an example with an encoding error in UTF-8 encoding, which is then
-introspected by a switch to the binary encoding. The test file contains a not
-continued multi-byte sequence at position 1 (\fBA \\xC3 B\fR):
-.PP
-File creation for example
-.CS
-% set f [open test_A_195_B.txt wb]; puts -nonewline $f A\\xC3B; close $f
-.CE
-Encoding error example
-.CS
-% set f [open test_A_195_B.txt r]
-file384b6a8
-% fconfigure $f -encoding utf-8 -profile strict
-% catch {gets $f} e d
-1
-% set d
--code 1 -level 0
--errorstack {INNER {invokeStk1 gets file384b6a8}}
--errorcode {POSIX EILSEQ {invalid or incomplete multibyte or wide character}}
--errorinfo {...} -errorline 1
-% tell $f
-0
-% fconfigure $f -encoding binary -profile strict
-% gets $f
-AÃB
-.CE
-Compared to \fBread\fR, any already decoded data is not consumed.
-The file position is still at 0 and the recovery \fBgets\fR returns also the
-already well decoded leading data.
.SH "EXAMPLE"
This example reads a file one line at a time and prints it out with
the current line number attached to the start of each line.
@@ -101,8 +64,4 @@ close $chan
file(n), eof(n), fblocked(n), Tcl_StandardChannels(3)
.SH KEYWORDS
-blocking, channel, end of file, end of line, line, non-blocking, read
-'\" Local Variables:
-'\" mode: nroff
-'\" fill-column: 78
-'\" End:
+blocking, channel, end of file, end of line, line, nonblocking, read