Mercurial > hg > Applications > Grep
diff c/regexParser/word.c @ 115:ca30f8334741 pairPro
rename createRegexParser.cc to regexParser.cc
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Nov 2015 14:38:26 +0900 |
parents | c/getWord/word.c@ffef79514d3c |
children | 166136236891 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c/regexParser/word.c Tue Nov 24 14:38:26 2015 +0900 @@ -0,0 +1,17 @@ +#include <ctype.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +unsigned char* getWord(unsigned char *string) { + int wordSize = 0; + while (isalnum(string[wordSize])) { + wordSize++; + } + + int allocateWordSize = wordSize + 1; + unsigned char *word = (unsigned char*)malloc(sizeof(unsigned char)*allocateWordSize); + strncpy((char*)word, (char*)string, allocateWordSize); + word[wordSize] = '\0'; + return word; +}