Commit graph

229 commits

Author SHA1 Message Date
Daniel Murphy
13f343334c Remove cases where an array is used in a boolean context 2013-11-27 18:23:07 +11:00
Simen Kjærås
ac9fcce808 Better fix for bug 11390 :p 2013-10-31 00:37:46 +01:00
Simen Kjærås
0c5a439e93 Fix bug 11390 2013-10-30 22:47:09 +01:00
Andrej Mitrovic
ce23685c0b Merge pull request #1538 from dymk/win64-fileio
Fix Issue 10227: Add missing file I/O functions for Win64 DMD and Windows LDC
2013-10-24 14:43:43 -07:00
Andrej Mitrovic
6924d3e6db Merge pull request #1483 from monarchdodra/chunksAmbiguity
Solve conflicting "chunks" declaration
2013-10-01 18:13:48 -07:00
Dylan Knutson
c0501952db Add missing file I/O functions for Win64 DMD and Windows LDC 2013-08-31 16:18:40 -07:00
Dmitry Olshansky
ba9c8fc3bf fix locking text writer postblit/dtor
Both should handle T.init correctly
Fix issue 10898
2013-08-28 23:35:19 +04:00
Nick Treleaven
6de39acc16 Change foreach byLine example to use take
Also remove 'If Char is mutable' because (currently) Char can't be
immutable.
2013-08-19 15:24:01 +01:00
Nick Treleaven
dad4b53686 Don't let ByLine degenerate to a ByLineImpl 2013-08-19 15:23:59 +01:00
Nick Treleaven
ec1f0fdb9d Fix Issue 9599 - File.byLine doesn't function properly with take
Calling take could wrongly pop an extra line from the range.
Solved by making ByLine use reference-counting.

Note: Just changing ByLine not to eagerly read the next line was not
sufficient to handle all cases properly (plus that makes empty() less
efficient).

Note: ByLine was documented until recently.
2013-08-19 15:23:57 +01:00
Nick Treleaven
8ff4bff0da Fix unreferencing ByLine.file once empty
The file handle was not released for an empty text file.
Also, do not pretend empty() is const.
2013-08-19 15:23:53 +01:00
Nick Treleaven
4c2a8bea35 Add unittest for issue 9599, plus some other byLine cases 2013-08-19 14:45:09 +01:00
monarchdodra
8226fe6555 make ChunksImpl private 2013-08-16 22:27:48 +02:00
monarchdodra
26cc34840f Solve conflicting "chunks" declaration 2013-08-16 20:23:40 +02:00
Andrei Alexandrescu
0f6d9e9c60 Merge pull request #1448 from ntrel/stdio-range-doc
Improve byChunk, lockingTextWriter doc
2013-08-11 21:09:30 -07:00
Nick Treleaven
6c1800bccc Use ElementEncodingType!Terminator instead of typeof(terminator[0]) 2013-08-10 11:41:15 +01:00
Nick Treleaven
fa974e3033 lockingTextWriter should not be a @property 2013-08-09 16:41:45 +01:00
Nick Treleaven
f03bfb0588 Ensure terminator string has Char element type 2013-08-09 14:38:08 +01:00
Nick Treleaven
e168cd70c0 Fix calling ByLine(file) with default args 2013-08-09 13:33:34 +01:00
Nick Treleaven
abcc305a3b Add comments for ranges that are no longer documented 2013-08-08 15:28:00 +01:00
Nick Treleaven
7f76586e16 Fix Issue 5378 - Make File.byLine accept a string terminator
Add an overload of byLine without a default argument for terminator.
Before, byLine!string tried to instantiate "string terminator = '\n'",
which is invalid.

Note: This removes the default arguments from ByLine.this, but the
constructor was never documented anyway (unlike the range primitives).
2013-08-08 15:01:36 +01:00
monarch dodra
1086f29554 Merge pull request #1296 from M-frankied/readln-nonbmp
fix Issue 10125 Unicode non-BMP decoding to dchar in stdio readln

Merged.
2013-08-04 23:59:36 -07:00
Nick Treleaven
6c1aa8d1cc Improve byChunk, lockingTextWriter doc
Make byChunk, lockingTextWriter return opaque types (but keep those
types public for backward compatibility).
Add byChunk range example.
Also document that ByLine's primitives can throw StdioException.
2013-08-02 17:48:38 +01:00
Nick Treleaven
6824abda7f s/forward range/input range/ plus minor fixes 2013-07-12 17:49:32 +01:00
Nick Treleaven
1a2eaf8d09 Make byLine return an opaque type
File.ByLine is still visible for backwards compatibility, but no longer
documented.
2013-07-11 16:09:47 +01:00
Nick Treleaven
a12ecdfaab Improve byLine doc
Move byLine examples from ByLine to byLine.
Fix LinesReader typo.
Explain that lines will not persist when using a mutable type for Char.
Document parameters.
2013-07-10 16:36:40 +01:00
Nick Treleaven
f0f02d70b6 Simplify File.readln(buf) example using a single output string
This is probably more performant than an array of idup'ped strings.
(Suggested by Steven Schveighoffer).
2013-07-08 17:10:15 +01:00
Nick Treleaven
9e5346049c Change File.readln(buf) example not to idup each line
Now lines starting with '#' are ignored.
Lines starting with 'q' no longer end the program.
2013-07-08 15:24:48 +01:00
Nick Treleaven
ad003aa618 Fix note about retaining buffer contents 2013-07-08 15:07:38 +01:00
Nick Treleaven
e90c141a78 Change 'is reused' to 'you can reuse' for clarity 2013-07-06 12:46:40 +01:00
Nick Treleaven
f7bec656d2 Use 'void main' instead of 'int main' in examples 2013-07-06 12:38:04 +01:00
Nick Treleaven
f34b41f33f Fix & improve readln, File.readln docs
Purge phantom fp parameter.
Add missing parameters and throws info.
Fix File.readln(buf) example to use char[] buf for reuse, not string.
Fix swapped readln() and File.readln() examples.
Separate readln() and readln(buf) docs because the behaviour and
return types are different.
2013-07-06 12:38:02 +01:00
unknown
30790ee53c Fixup readln.
Fixes an issue where `readln!S` did not forward the type "S" in `stdin.readln()` => `stdin.readln!S()` (that was my mistake, sorry)

Fixes an issue where `File.readln!S` assumed S was an "immutable string type". This should work:

char[] buf;
buf = myFile.readln!(char[])();

While buf is not reused after each call, there should be nothing preventing the user for mutating if he so (explicitly) wishes.

Added/improved unittests a wee little bit.
2013-07-03 15:10:24 +02:00
monarch dodra
3cd2060e21 Improve restraints for readln 2013-07-02 09:00:25 +02:00
monarch dodra
73cd4b90f7 Improve iteration scheme for wchar/dchar 2013-07-02 08:37:48 +02:00
monarch dodra
738a7879d4 Fix wchar/dchar issue
Just cause a file is nativelly treated as UTF16 (or something), doesn't mean you can iterate wchars.
2013-07-01 19:15:45 +02:00
monarch dodra
97cec336a1 Fix Issue 10517 - readln(Char)(Char[] buf) accepts non-mutable buffers
Also templatizes a global readln
2013-07-01 19:14:48 +02:00
k-hara
2f21ff0c74 More fix for issue 313 & 314 2013-06-25 17:01:52 +09:00
k-hara
03a32d6fa4 Fix issue 313 & 314 2013-06-25 08:38:30 +09:00
Andrei Alexandrescu
383c029e2c nits 2013-05-31 19:26:20 -04:00
Ferdinand Majerech
4c713c311d DDoc: std.stdio.byLine documentation fix and examples.
Removed the redundant /// ditto and added two examples to make it obvious to a newcomer how a range is useful here.
2013-06-01 00:33:15 +03:00
Frank van Dijk
a9eb2008cb combine some statements 2013-05-29 19:29:06 +02:00
Frank van Dijk
8f401a9199 fix Issue 10125 Unicode non-BMP decoding to dchar in stdio readln
strings were first decoded to wchars, each wchar was then separately
decoded to dchar, resulting in 2 dchars in the surrogate block instead
of 1 correct dchar.

added unit test to verify readln decoding of non-ASCII characters
2013-05-20 14:26:22 +02:00
Frank van Dijk
a34861d80c [10116] stdio.File.byLine repeats last line forever, readln(ref C[],R) returns bad data
byLine expects readln to return with an empty buffer on end-of-stream,
which readln does not do for wchar and dchar. Also, the readln variant
that takes a terminator range returns incorrect concatenations of
lines because of the same issue. Fixed by setting buffer.length=0 in
readln for this case. Unit test updated to detect this issue.
2013-05-19 11:06:12 +02:00
Tim Keating
db6b492af3 Fix some borkage with documentation of File.readln variants; add a better example for File.readln(buf) that emphasizes the need to copy the buffer, since it is overwritten when read 2013-05-10 00:27:38 -05:00
Lars T. Kyllingstad
aa57a2a161 Renamed File.isPipe to isPopened
Now that std.process will support pipe creation, the name isPipe will
only cause confusion, as it will in fact be false for "normal" anonymous
pipes.  It is only true for files opened by popen(), and its purpose is
simply to ensure they are closed with pclose().
2013-04-30 21:07:33 +02:00
Lars T. Kyllingstad
28abab44cf StdioException: No system error msg when errno==0 2013-04-30 21:05:28 +02:00
Lars T. Kyllingstad
8a95cadf29 Make std.stdio.File 'package' accessible
This is required in the new std.process.
2013-04-30 21:03:56 +02:00
Andrei Alexandrescu
176976a57b Merge pull request #1238 from denis-sh/add-note-about-Issue-7648
Add note about Issue 7648 to `std.stdio.File`.
2013-04-17 13:13:01 -07:00
Ferdinand Majerech
402af9d0c4 DDoc -std.stdio: exceptions thrown by C-like API.
Updated documentation for all the C-like member functions \
(and the File ctor) to specify exactly what gets thrown when. 

(note: Exceptions in std.stdio are a mess and should be made 
 more consistent. Also, it seems some member functions that 
 should check if the file is opened do not, but I don't know
 if that might be intentional (as the C functions should fail 
 anyway, resulting in a throw))
2013-04-10 23:36:27 +03:00