glob

Florian Weimer fweimer@redhat.com
Fri Jan 16 09:17:56 GMT 2026


* chenzhelu:

> Found 3 files matching pattern *.c:
> * (null)
> * a.c
> * b.c
>
>
> why the c.c is not output because there are 3 C files in the current dir ?

You need to add the offset when you are indexing through gl_pathv:

     ‘gl_pathc’
          The number of elements in the vector, excluding the initial
          null entries if the GLOB_DOOFFS flag is used (see gl_offs
          below).

I don't know why gl_offs even exists, it does not seem very useful.
(The caller cannot supply its own buffer via gl_pathv, and the prefix
is overwritten by null pointers.)

Thanks,
Florian



More information about the Libc-help mailing list