June 23, 2011
On 2011-06-23 07:36, Andrej Mitrovic wrote:
> Hmm it's a bit problematic though:
>
> szLabel.indexOf("(")
> szLabel.indexOf""
>
> Well I'll just have to manually merge these changes then one by one.
> Well it's better than nothing.

If every string looks like this:

TEXT ("Acoustic Bass Drum")

Then you can use a regexp like this:

TEXT \("(.+?)"\)

And replace with:

"$1"

You don't need a script for this, just put it in an editor with search & replace with support for regexp.

-- 
/Jacob Carlborg
June 23, 2011
Andrej Mitrovic Wrote:

> I just ran into some odd stdout corruption issue while doing parallel builds, take a look:
> 
> http://i.imgur.com/pgC4o.png
> 
> I've tried building again and it was gone, it looks like an appearance of a heisenbug. There might be some bug lurking somewhere in std.parallelism, but it's hard to say when I can't recreate it.

console output is unbuffered and stdio loves to call putch. Usually this is ok since one doesn't run multiple applications on the same console simultaneously. And if it does, a program usually makes it in time. It's strange to see interwined characters as if it can't write a character in a context switch time frame. May be a bug in console2?
June 23, 2011
On Thu, Jun 23, 2011 at 2:56 AM, Kagamin <spam@here.lot> wrote:

> Andrej Mitrovic Wrote:
>
> > I just ran into some odd stdout corruption issue while doing parallel builds, take a look:
> >
> > http://i.imgur.com/pgC4o.png
> >
> > I've tried building again and it was gone, it looks like an appearance of a heisenbug. There might be some bug lurking somewhere in std.parallelism, but it's hard to say when I can't recreate it.
>
> console output is unbuffered and stdio loves to call putch. Usually this is ok since one doesn't run multiple applications on the same console simultaneously. And if it does, a program usually makes it in time. It's strange to see interwined characters as if it can't write a character in a context switch time frame. May be a bug in console2?
>

I don't think console output is unbuffered.  I think it's line-buffered by default.  Although it does differ and vary; I think on Windows std.stdio.write("hello\n") doesn't flush but on Linux it does.


June 23, 2011
Jimmy Cao Wrote:

> I don't think console output is unbuffered.  I think it's line-buffered by default.  Although it does differ and vary; I think on Windows std.stdio.write("hello\n") doesn't flush but on Linux it does.

LOL, MS resource compiler doesn't use symantec C runtime.
In fact sc runtime didn't flush, but this was fixed, though I don't remember where, in phobos or in sc.
June 23, 2011
On Thu, Jun 23, 2011 at 6:06 AM, Kagamin <spam@here.lot> wrote:

> Jimmy Cao Wrote:
>
> > I don't think console output is unbuffered.  I think it's line-buffered
> by
> > default.  Although it does differ and vary; I think on Windows std.stdio.write("hello\n") doesn't flush but on Linux it does.
>
> LOL, MS resource compiler doesn't use symantec C runtime.
> In fact sc runtime didn't flush, but this was fixed, though I don't
> remember where, in phobos or in sc.
>

I've tested it out with DMD 2.053 on Windows XP.

import std.stdio;
import core.thread;


void main()
{
    version(WIDE)  // Will flush during write
        wstring mystr = "Hello\n"w;
    else // Will not flush
        string mystr = "Hello\n";

    write(mystr);

    Thread.sleep( 70_000_000 );  // 7 sec
    stdout.flush();
}


Also, there's nothing in the C standard that says, stdout must be buffered this way or that way or even buffered at all.  I believe you can safely assume that stdout is line-buffered in Linux, though, but I'm not sure.


June 23, 2011
On 23.06.2011 9:58, Andrej Mitrovic wrote:
> Fixed: https://github.com/AndrejMitrovic/DWindowsProgramming/commit/42228c9012c2c75d2638fab52277f21427b2ed01
>
> Quite a huge list of stray parens. Good thing I had Beyond Compare for
> the diffs.
Seems like I'm late for regex party :(
Still, this works in D2, and is somewhat intelligent ;)

import std.regex, std.file;

void main(string[] args)
{
    auto r = regex(`(\W\s*)\(("(?:[^"]|\\")*")\)`,"g");
    foreach(arg; args[1..$])
    {
        auto data = cast(string)read(arg);
        auto replaced = replace(data, r, `$1$2`);
        std.file.write(arg, replaced);
    }
}

-- 
Dmitry Olshansky

June 23, 2011
On 6/23/11, Dmitry Olshansky <dmitry.olsh@gmail.com> wrote:
> On 23.06.2011 9:58, Andrej Mitrovic wrote:
>> Fixed: https://github.com/AndrejMitrovic/DWindowsProgramming/commit/42228c9012c2c75d2638fab52277f21427b2ed01
>>
>> Quite a huge list of stray parens. Good thing I had Beyond Compare for the diffs.
> Seems like I'm late for regex party :(
> Still, this works in D2, and is somewhat intelligent ;)
>
> import std.regex, std.file;
>
> void main(string[] args)
> {
>      auto r = regex(`(\W\s*)\(("(?:[^"]|\\")*")\)`,"g");
>      foreach(arg; args[1..$])
>      {
>          auto data = cast(string)read(arg);
>          auto replaced = replace(data, r, `$1$2`);
>          std.file.write(arg, replaced);
>      }
> }
>
> --
> Dmitry Olshansky
>
>

Thanks, goes into my d_tips.txt file. :)
June 23, 2011
On 6/23/2011 4:27 AM, Jimmy Cao wrote:
> Also, there's nothing in the C standard that says, stdout must be buffered this
> way or that way or even buffered at all.  I believe you can safely assume that
> stdout is line-buffered in Linux, though, but I'm not sure.

Even so, stdout buffering is done on a global, shared basis. There is not a per-thread buffer.

DMC++ buffers stdout by line if the output is a tty. This is normal practice.
June 23, 2011
On Thu, Jun 23, 2011 at 12:46 PM, Walter Bright <newshound2@digitalmars.com>wrote:

> On 6/23/2011 4:27 AM, Jimmy Cao wrote:
>
>> Also, there's nothing in the C standard that says, stdout must be buffered
>> this
>> way or that way or even buffered at all.  I believe you can safely assume
>> that
>> stdout is line-buffered in Linux, though, but I'm not sure.
>>
>
>
> DMC++ buffers stdout by line if the output is a tty. This is normal practice.
>

But that's not possible (to set it to line-buffering) on Windows, right?


June 23, 2011
On 6/23/2011 11:48 AM, Jimmy Cao wrote:
> But that's not possible (to set it to line-buffering) on Windows, right?

Sure it is, using the usual C functions. This is not a Windows thing, it's a C runtime library thing.