www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Possible bug in std.file.listdir (Linux)

reply Timo Gransch <timo gransch.de> writes:
Hi!

Maybe I'm wrong, but I think I discovered a bug in std.file.listdir.

-- [snip] --

import std.file;
import std.path;
import std.stdio;

int main(char[][] args)
{
        char Files[][]=listdir(curdir);
        
        foreach(char File[]; Files)
        {
                writefln(File);
        }

        return 0;
}

-- [snip] --

This works fine unless there is a file with a '%' in it's name in the
current folder. If I put a file called for example "now_i_test%dmd" there,
the program prints

now_i_testError: std.format

and exits.

I have only tested it on Linux (Ubuntu 6.10 x86).

Best regards,
Timo
Jan 31 2007
parent reply Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Timo Gransch wrote:
 Hi!
 
 Maybe I'm wrong, but I think I discovered a bug in std.file.listdir.
 

                 writefln(File);

 
 This works fine unless there is a file with a '%' in it's name in the
 current folder. If I put a file called for example "now_i_test%dmd" there,
 the program prints
 
 now_i_testError: std.format
 
 and exits.
 
 I have only tested it on Linux (Ubuntu 6.10 x86).

Nothing to do with std.file.listdir, just with your use of writefln. writefln treats strings as format strings, except when a previous format string told it to treat it literally. Try this one: writefln("%s", File); There have long been requests for write & writeln (without the 'f') that just print out everything using the default formatting, but so far they haven't been implemented[1]. [1]: At least, in Phobos. I don't know about Ares/Mango/Tango.
Jan 31 2007
next sibling parent Timo Gransch <timo.gransch gmx.de> writes:
Frits van Bommel wrote:

 (...) Try this one:
 writefln("%s", File);

Sorry, I was blind. Works fine now. :) Thanks for your fast reply, Frits. Best regards, Timo
Jan 31 2007
prev sibling parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Frits van Bommel wrote:

 There have long been requests for write & writeln (without the 'f') that 
  just print out everything using the default formatting, but so far they 
 haven't been implemented[1].

I think you mean "it hasn't been deemed fit for inclusion", it has been implemented multiple times by third parties. Basically it's a boolean... It's a pity that writeln and readln didn't make into DMD 1.0, I think. --anders
Jan 31 2007
next sibling parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Anders F Björklund wrote:
 Frits van Bommel wrote:
 
 There have long been requests for write & writeln (without the 'f') 
 that  just print out everything using the default formatting, but so 
 far they haven't been implemented[1].

I think you mean "it hasn't been deemed fit for inclusion", it has been implemented multiple times by third parties. Basically it's a boolean... It's a pity that writeln and readln didn't make into DMD 1.0, I think.

Speaking of the underwhelming maintenance effort being put into the current standard library, what about our hope for salvation? The one that will have us all doing latin dances in the hallways? Yes, the one they call "TANGO"! Wasn't it supposed to be hitting the streets about now? Any updates on the ETA if it ain't gonna be today? --bb
Jan 31 2007
prev sibling parent Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Anders F Björklund wrote:
 Frits van Bommel wrote:
 
 There have long been requests for write & writeln (without the 'f') 
 that  just print out everything using the default formatting, but so 
 far they haven't been implemented[1].

I think you mean "it hasn't been deemed fit for inclusion", it has been implemented multiple times by third parties. Basically it's a boolean... It's a pity that writeln and readln didn't make into DMD 1.0, I think.

Right, now that you mention it I *do* remember someone having written a patch. What was probably fresh in my mind as I wrote that was that just yesterday DMD caught me leaving out the 'f' again and complained about an unknown identifier :(.
Jan 31 2007