Re: D man pages

2019-09-22 Thread Jarek via Digitalmars-d-learn

On Saturday, 5 January 2019 at 21:59:27 UTC, kdevel wrote:
For years I missed the man pages of the C++ standard library 
and now found out that some Linux distros provide them as extra 
package. The man pages are not generated by a default during a 
GCC bootstrap install but need an explicit make doc-install-man 
in the corresponding doc directory of libstdc++.


Is there any such mechanism to generate man pages for D/Phobos?

Stefan


Hello,
I have the same question. Where to find something similar to man 
pages from C?
I would like to use core.sys.posix.dirent and don't know where to 
find manuals about it.
Reading dirent.h or man opendir is a lot easier than reading 
dirent.d from

/usr/lib64/gcc/x86_64-slackware-linux/9.2.0/include/d/core/sys/posix
If I read dirent.d, then I see something like:
else version (CRuntime_Bionic)
{
}
else version (CRuntime_Musl)
{
}
else version (CRuntime_UClibc)
{
void   seekdir(DIR*, c_long);
c_long telldir(DIR*);
}
else
{
static assert(false, "Unsupported platform");
}
does it mean that I can't use seekdir() on systems with Musl? 
(Alpine linux)?




Re: D man pages

2019-10-10 Thread Jarek via Digitalmars-d-learn

On Monday, 23 September 2019 at 12:31:16 UTC, Adam D. Ruppe wrote:

On Monday, 23 September 2019 at 06:06:05 UTC, Jarek wrote:
I have the same question. Where to find something similar to 
man pages from C?


They are the same functions, so the idea is you can just use 
the C man pages directly. There's just the pattern of the D 
module name to know.


but...

does it mean that I can't use seekdir() on systems with Musl? 
(Alpine linux)?


it is possibly just not copied in there, I'd say to just try it 
and see if it triggers the static assert down there.


the man page says

CONFORMING TO
   4.3BSD, POSIX.1-2001.

so it probably should work with the core.sys.posix header 
there, maybe it just isn't verified as to the type of the 
argument (the notes section warns it has changed, so the D devs 
are surely being extra cautious about which one it actually has 
in there, waiting for someone to verify it before putting in 
the file)


Hello,
thanks for reply.
This is my first dlang work:
import std.stdio;
import std.conv;
import core.sys.posix.dirent;

int main(string[] args)
{
DIR* proc;
dirent *ent;
proc = opendir("/proc");
if(proc == null){
stderr.writeln("Open /proc error");
return 1;
}
stdout.writeln("proc opened");
while((ent = readdir(proc)) != null){
if(ent.d_type != DT_DIR){
continue;
}
stdout.writeln("Subdir: ", to!string(ent.d_name));
}
if(closedir(proc) == -1){
stderr.writeln("Close dir error");
return 1;
}
return 0;
}

How to handle ent.d_name? When I writeln it with to!string() 
conversion then it doesn't print well.

As a result I got something like this:
(...)
Subdir: 8�
10�11�12�13�14�15�17�18�19�
10�11�12�13�14�15�17�18�19�22�
Subdir: 10�11�12�13�14�15�17�18�19�22�23�
ubdir: 11�12�13�14�15�17�18�19�22�23�24�K
Subdir: 12�13�14�15�17�18�19�22�23�24�K25�L
Subdir: 13�14�15�17�18�19�22�23�24�K25�L73�M
Subdir: 14�15�17�18�19�22�23�24�K25�L73�M74�N
Subdir: 15�17�18�19�22�23�24�K25�L73�M74�N75�O
Subdir: 17�18�19�22�23�24�K25�L73�M74�N75�O76�Q
Subdir: 18�19�22�23�24�K25�L73�M74�N75�O76�Q77�R
Subdir: 19�22�23�24�K25�L73�M74�N75�O76�Q77�R79�S
Subdir: 22�23�24�K25�L73�M74�N75�O76�Q77�R79�S80�T
Subdir: 23�24�K25�L73�M74�N75�O76�Q77�R79�S80�T81�U
(...)
to!string() doesn't work?
thanks for help


Re: D man pages

2019-10-11 Thread Jarek via Digitalmars-d-learn

On Thursday, 10 October 2019 at 19:19:42 UTC, Daniel Kozak wrote:

On Thursday, 10 October 2019 at 18:52:32 UTC, Jarek wrote:
On Monday, 23 September 2019 at 12:31:16 UTC, Adam D. Ruppe 
wrote:

[...]


Hello,
thanks for reply.
This is my first dlang work:
import std.stdio;
import std.conv;
import core.sys.posix.dirent;

[...]


You should use fromStringZ: 
https://dlang.org/phobos/std_string.html#.fromStringz


Thanks,
now it works.