diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2012-12-11 22:31:21 -0600 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2012-12-19 16:57:30 -0600 |
| commit | 7fcec8342890031a0d22f0d013833badd81091e8 (patch) | |
| tree | 9b09ab2eb1d111d5662a1f0f0b7fa13df07587d0 /src/util.c | |
| parent | 5c3c86b06e84ac70735b2629209de2dcc0e09034 (diff) | |
| download | libgit2-7fcec8342890031a0d22f0d013833badd81091e8.tar.gz | |
fetchhead reading/iterating
Diffstat (limited to 'src/util.c')
| -rw-r--r-- | src/util.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 6df32b1c3..059e55dd7 100644 --- a/src/util.c +++ b/src/util.c @@ -276,6 +276,24 @@ char *git__strtok(char **end, const char *sep) return NULL; } +/* Similar to strtok, but does not collapse repeated tokens. */ +char *git__strsep(char **end, const char *sep) +{ + char *start = *end, *ptr = *end; + + while (*ptr && !strchr(sep, *ptr)) + ++ptr; + + if (*ptr) { + *end = ptr + 1; + *ptr = '\0'; + + return start; + } + + return NULL; +} + void git__hexdump(const char *buffer, size_t len) { static const size_t LINE_WIDTH = 16; |
