Skip to content

Instantly share code, notes, and snippets.

@usernameak
Created July 27, 2017 20:23
Show Gist options
  • Select an option

  • Save usernameak/f7e4589199b002c07ed07bb872c9813e to your computer and use it in GitHub Desktop.

Select an option

Save usernameak/f7e4589199b002c07ed07bb872c9813e to your computer and use it in GitHub Desktop.
size_t mlang_parse_string(char **p, char **sp) {
if(**p != '"') {
return 0;
}
(*p)++;
char *startp = *p;
do {
(*p)++;
if(**p == 0) return 0;
} while(**p != '"');
char *endp = *p;
*sp = malloc(endp - startp + 1);
(*sp)[endp - startp] = 0;
strncpy(*sp, startp, endp - startp);
(*p)++;
return endp - startp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment