annotate c/regexParser/word.c @ 116:66c633575b53 pairPro

remove error and warning
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Tue, 24 Nov 2015 17:07:08 +0900
parents ca30f8334741
children 166136236891
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
113
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <ctype.h>
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <string.h>
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <stdio.h>
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include <stdlib.h>
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 unsigned char* getWord(unsigned char *string) {
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 int wordSize = 0;
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 while (isalnum(string[wordSize])) {
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 wordSize++;
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 }
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 int allocateWordSize = wordSize + 1;
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 unsigned char *word = (unsigned char*)malloc(sizeof(unsigned char)*allocateWordSize);
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 strncpy((char*)word, (char*)string, allocateWordSize);
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 word[wordSize] = '\0';
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 return word;
ffef79514d3c add getWord
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 }