Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-20 Thread Don
Jonathan M Davis wrote: On Saturday 19 March 2011 18:04:57 Don wrote: Jonathan M Davis wrote: On Saturday 19 March 2011 17:11:56 Don wrote: Here's the task: Given a .d source file, strip out all of the unittest {} blocks, including everything inside them. Strip out all comments as well. Print

Re: How do I iteratively replace lines in a file?

2011-03-20 Thread Ali Çehreli
On 03/19/2011 04:51 PM, Andrej Mitrovic wrote: I'm trying to do something like the following: File inputfile; foreach (string name; dirEntries(r.\subdir\, SpanMode.shallow)) { if (!(isFile(name) getExt(name) == d)) { continue; } inputfile = File(name, a+);

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-20 Thread Jonathan M Davis
Jonathan M Davis wrote: On Saturday 19 March 2011 18:04:57 Don wrote: Jonathan M Davis wrote: On Saturday 19 March 2011 17:11:56 Don wrote: Here's the task: Given a .d source file, strip out all of the unittest {} blocks, including everything inside them. Strip out all comments as

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-20 Thread Don
Jonathan M Davis wrote: Jonathan M Davis wrote: On Saturday 19 March 2011 18:04:57 Don wrote: Jonathan M Davis wrote: On Saturday 19 March 2011 17:11:56 Don wrote: Here's the task: Given a .d source file, strip out all of the unittest {} blocks, including everything inside them. Strip out

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-20 Thread Jonathan M Davis
Jonathan M Davis wrote: Jonathan M Davis wrote: On Saturday 19 March 2011 18:04:57 Don wrote: Jonathan M Davis wrote: On Saturday 19 March 2011 17:11:56 Don wrote: Here's the task: Given a .d source file, strip out all of the unittest {} blocks, including everything inside them.

Re: How do I iteratively replace lines in a file?

2011-03-20 Thread Kai Meyer
On 03/19/2011 05:51 PM, Andrej Mitrovic wrote: I'm trying to do something like the following: File inputfile; foreach (string name; dirEntries(r.\subdir\, SpanMode.shallow)) { if (!(isFile(name) getExt(name) == d)) { continue; } inputfile = File(name, a+);

Other integral literals?

2011-03-20 Thread bearophile
Do you ever desire literals for byte, ubyte, short and ushort integrals (beside the currently present for int, uint, long, ulong that are 10, 10U, 10L, 10UL)? Because of the more strict typing of templates in some situations I have had to write things like: cast(ubyte)100 Possible literals

Re: How do I iteratively replace lines in a file?

2011-03-20 Thread Andrej Mitrovic
Yeah, I've already done exactly as you guys proposed. Note however that `inputfile` and `outputfile` should be declared inside the foreach loop. Either that or you have to call `close()` explicitly. If you don't do that, file handles don't get released, and you'll eventually get back a stdio error

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-20 Thread Tyro[a.c.edwards]
Not very elegant but this should get the job done: 000 module strip; 001 import std.algoritm : countUntil; 002 import std.array: strip; 003 import std.file : read; 004 import std.string : splitlines; 005 import std.stdio: writeln; 006 007 void main(string[] args) 008 { 009 bool

Re: Problem with associative arrays

2011-03-20 Thread Jesse Phillips
Piotr Szturmaj Wrote: Yes, I already used pointers but in other way: uint[]* temp = aa[5]; // copy uint[] reference and it worked the same as using 'in'. However, I wasn't sure it's completely safe. Depends on what you mean by safe. In your example if 5 is not a key then a Range

Re: Other integral literals?

2011-03-20 Thread Kagamin
http://d.puremagic.com/issues/show_bug.cgi?id=4870

Re: Other integral literals?

2011-03-20 Thread spir
On 03/20/2011 04:40 PM, bearophile wrote: Do you ever desire literals for byte, ubyte, short and ushort integrals (beside the currently present for int, uint, long, ulong that are 10, 10U, 10L, 10UL)? Because of the more strict typing of templates in some situations I have had to write things

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-20 Thread Tyro[a.c.edwards]
The following patch addresses the following issues: 1) fixed improper handling of nested and multiline comments that do not take up a complete line. 2) eliminate extra blank lines where unit tests and comments are removed. Replace lines 31 32 with: # auto n = countUntil(line, +/); # if(n !=

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-20 Thread Tyro[a.c.edwards]
Messed that up again: see embeded change. Wish I could just copy and pase but that's not possible with my current setup. == Quote from Tyro[a.c.edwards] (nos...@home.com)'s article The following patch addresses the following issues: 1) fixed improper handling of nested and multiline comments

Re: Other integral literals?

2011-03-20 Thread Simen kjaeraas
On Sun, 20 Mar 2011 19:37:45 +0100, spir denis.s...@gmail.com wrote: * ideally, I would use the sign to tell signed types apart (1 is unsigned, +1 is signed) I hope you messed that one up. An unadorned int literal should be signed. Period. * get rid of 01 octal bug! Oh gods, yes.

Re: How do I iteratively replace lines in a file?

2011-03-20 Thread Kai Meyer
On 03/20/2011 09:46 AM, Andrej Mitrovic wrote: Yeah, I've already done exactly as you guys proposed. Note however that `inputfile` and `outputfile` should be declared inside the foreach loop. Either that or you have to call `close()` explicitly. If you don't do that, file handles don't get

Re: Using D libs in C

2011-03-20 Thread Dainius (GreatEmerald)
Now I'm trying to do something more complicated, and it seems that while importing works (it compiles and links fine), actually using the imported things or pretty much anything that D offers makes the program crash. For instance, in the D part: --- module dpart; import std.stdio;

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-20 Thread Kai Meyer
On 03/19/2011 06:11 PM, Don wrote: Here's the task: Given a .d source file, strip out all of the unittest {} blocks, including everything inside them. Strip out all comments as well. Print out the resulting file. Motivation: Bug reports frequently come with very large test cases. Even ones

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-20 Thread Zirneklis
On 20/03/2011 19:55, Kai Meyer wrote: On 03/19/2011 06:11 PM, Don wrote: Here's the task: Given a .d source file, strip out all of the unittest {} blocks, including everything inside them. Strip out all comments as well. Print out the resulting file. Motivation: Bug reports frequently come

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-20 Thread Ary Manzana
On 3/19/11 9:11 PM, Don wrote: Here's the task: Given a .d source file, strip out all of the unittest {} blocks, including everything inside them. Strip out all comments as well. Print out the resulting file. Motivation: Bug reports frequently come with very large test cases. Even ones which