applied Borys chages ;)
This commit is contained in:
parent
cdb06c4c44
commit
fa96a5d3b9
|
@ -73,7 +73,7 @@ bool is_delim(char c, const char *delims) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *simple_strtok(char *str, const char *delims) {
|
char *simple_strtok(char *str, const char *delims) {
|
||||||
char *static_str = (char *) NULL; // Przechowuje wskaźnik do bieżącej pozycji w ciągu
|
static char *static_str = (char *) NULL;
|
||||||
|
|
||||||
if (str !=(char *) NULL) {
|
if (str !=(char *) NULL) {
|
||||||
static_str = str;
|
static_str = str;
|
||||||
|
@ -83,7 +83,6 @@ char *simple_strtok(char *str, const char *delims) {
|
||||||
return (char *)NULL;
|
return (char *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip initial delimiters
|
|
||||||
while (*static_str && is_delim(*static_str, delims)) {
|
while (*static_str && is_delim(*static_str, delims)) {
|
||||||
static_str++;
|
static_str++;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +93,6 @@ char *simple_strtok(char *str, const char *delims) {
|
||||||
|
|
||||||
char *token_start = static_str;
|
char *token_start = static_str;
|
||||||
|
|
||||||
// Find the end of the token
|
|
||||||
while (*static_str && !is_delim(*static_str, delims)) {
|
while (*static_str && !is_delim(*static_str, delims)) {
|
||||||
static_str++;
|
static_str++;
|
||||||
}
|
}
|
||||||
|
@ -109,11 +107,8 @@ char *simple_strtok(char *str, const char *delims) {
|
||||||
|
|
||||||
char buf[1000];
|
char buf[1000];
|
||||||
struct model * p = (struct model *) buf; //p[1]
|
struct model * p = (struct model *) buf; //p[1]
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> mpabi
|
|
||||||
|
|
||||||
|
/*
|
||||||
int alg(char *ptr) {
|
int alg(char *ptr) {
|
||||||
const char *delims = " ,.!?:;\n\t";
|
const char *delims = " ,.!?:;\n\t";
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
@ -123,11 +118,26 @@ int alg(char *ptr) {
|
||||||
p[pos].ptr = token;
|
p[pos].ptr = token;
|
||||||
p[pos].len = strlen(token);
|
p[pos].len = strlen(token);
|
||||||
++pos;
|
++pos;
|
||||||
token = simple_strtok((char *)NULL, delims); // Set ptr to NULL after the first call to continue tokenizing the same string
|
token = simple_strtok((char *)NULL, delims);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
int alg(char *ptr) {
|
||||||
|
const char *delims = " ,.!?:;\n\t";
|
||||||
|
int pos = 0;
|
||||||
|
|
||||||
|
char *token = simple_strtok(ptr, delims);
|
||||||
|
while (token != (char *)NULL) {
|
||||||
|
p[pos].len = strlen(token);
|
||||||
|
++pos;
|
||||||
|
token = simple_strtok((char *)NULL, delims);
|
||||||
|
}
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
char *str = " Success is often defined as the ability to reach your goals in life, whatever those goals may be. In some ways, a better word for success might be attainment, accomplishment, or progress. It is not necessarily a destination but a journey that helps develop the skills and resources you need to thrive.";
|
char *str = " Success is often defined as the ability to reach your goals in life, whatever those goals may be. In some ways, a better word for success might be attainment, accomplishment, or progress. It is not necessarily a destination but a journey that helps develop the skills and resources you need to thrive.";
|
||||||
|
|
Loading…
Reference in New Issue