Re: std.stdio.stderr

2017-06-10 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2017-06-10 at 16:45 +, Antonio Corbi via Digitalmars-d-
learn wrote:
> […]
> 
> It seems to work for me with a dumb example:
[…]

Spurred on by your report of success, I discovered my error. D treats a
char[1024] as 1024 characters when using the %s format specifier. I had
to use fromStringz using a cast to get the %s to get the null
terminated string.

The problems of idiomatic C code (crap) converted to D code (good, but
with hacks).

Thanks for your reply, it was most helpful.

-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

signature.asc
Description: This is a digitally signed message part


Re: std.stdio.stderr

2017-06-10 Thread Antonio Corbi via Digitalmars-d-learn

On Saturday, 10 June 2017 at 16:10:18 UTC, Russel Winder wrote:
It appears that std.stdio.stderr does not wor exactly as stdio 
stderr

does. In particular std.stdio.stderr.writef(…) does not work as
fprintf(stderr…) does.

Some code I am porting from C++ to D makes use of ANSI escape 
codes to go up a line and overwrite what was there, as well as 
change colours. This work fine in the C++ code but fails in the 
D code. The codes are definitely all the same, the only 
difference is in the writing functions.


Is this problem to be expected or should it work?


Hi Russel,

It seems to work for me with a dumb example:

```
import std.stdio;

void main()
{
  writefln("stdout: %s", "Edit source/app.d to start your 
project.");
  stderr.writefln("stderr: %s", "Edit source/app.d to 
start your project.");
  stderr.writefln("stderr: %s", "Edit source/app.d to 
start your project.");


  stderr.writefln("%s", "");
}
```
Before copy/paste take into account that in sequences like "[7m", 
etc... there's a hidden ESC char at the beginning, something 
like: "\033[7m", and I can't see it in the preview of my posting.


Antonio