Skip to content

tsoding/shlex.h

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shlex.h

Python's shlex but in C.

Quick Start

Splitting

#include <stdio.h>
#define SHLEX_IMPLEMENTATION
#include "shlex.h"

int main(void)
{
    const char *source = "-C link-args=\"-lm -L.\"";
    Shlex s = {0};
    shlex_init(&s, source, source + strlen(source));
    while (shlex_next(&s)) {
        printf("%s\n", s.string);
    }
    shlex_free(&s);
    return 0;
}

Joining

#include <stdio.h>
#define SHLEX_IMPLEMENTATION
#include "shlex.h"

int main(void)
{
    Shlex s = {0};
    shlex_append_quoted(&s, "-C");
    shlex_append_quoted(&s, "link-args=-lm -L.");
    printf("%s\n", shlex_join(&s));
    shlex_free(&s);
    return 0;
}

References

About

Python's shlex but in C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published