mailing list of musl libc
 help / color / mirror / code / Atom feed
* Implementation of GLOB_TILDE
@ 2017-01-17 15:44 Bernardo Pascoal Figueiredo
  2017-01-17 15:49 ` Bernardo Pascoal Figueiredo
  0 siblings, 1 reply; 5+ messages in thread
From: Bernardo Pascoal Figueiredo @ 2017-01-17 15:44 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1001 bytes --]

Hi,

I'm sending as attachment a a patch that implments the GLOB_TILDE 
extension to
the glob function.

This functions is helpful to compile some software that otherwise would 
not
compile(without patching) with musl like i3wm.

I tested the code(test file as attachment) and the results seem to be 
correct.

I have a few questions though:
  * How do I contribute to musl? Should I just send patches to this 
mailing list
    or should I make pull requests?

  * I defined GLOB_TILDE as 0x100, but I think this won't work on 
architectures
    that have sizeof(int) == 2, as the flags argument in glob is an int.

  * I think it's best to define GLOB_TILDE in glob.h inside a '#if
    defined(_GNU_SOURCE) || defined(_BSD_SOURCE)' what do you think?

  * I had to copy strlcat and strlcpy to glob.c so I could use them. I 
had to do
    this because musl isn't compile as _GNU_SOURCE or _BSD_SOURCE so 
string.h
    doesn't expose these functions. How should I fix this?

Thanks,
Bernardo Figueiredo

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test.c --]
[-- Type: text/x-c; name=test.c, Size: 581 bytes --]

#include <glob.h>

#include <stdbool.h>

#include <stdio.h>

int no_error(const char *p, int e) {
    return 0;
}


int test_glob(const char *p) {
    glob_t g;
    int result = false;
    result = glob(p, GLOB_TILDE, no_error, &g);
    printf("result:%d", result);
    if(result == 0) {
        for(int i = 0; i < g.gl_pathc; ++i) {
            printf(" '%s'", g.gl_pathv[i]);
        }
    }
    printf("\n");
}

int main(int argc, char **argv) {
	(void) argc; (void) argv;
    test_glob("~");
    test_glob("~/p*");
    test_glob("~bpf");
    test_glob("~bpf/p*");
	return 0;
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-01-20  9:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-17 15:44 Implementation of GLOB_TILDE Bernardo Pascoal Figueiredo
2017-01-17 15:49 ` Bernardo Pascoal Figueiredo
2017-01-17 19:39   ` Rich Felker
2017-01-18 19:51     ` Bernardo Pascoal Figueiredo
2017-01-20  9:56       ` Bernardo Pascoal Figueiredo

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).