Debian Codegraph @

sstring.c

raw symbols SCIP
1 /* -*- Mode: C; c-file-style: "stroustrup" -*- */cxx . . $ `<file>/sstring.c`/
2 #include <string.h>
3 #include <stdlib.h>
4 #include <ctype.h>
5 #include "sstring.h"cxx . . $ `<file>/sstring.h`/
6
7
8 /* strtok/strtok_r is a disaster, so here's a more sane one */
9
10 /* if *tok is NULL space is allocated; if the *tok is not NULL, and
11 * the token is too large it is truncated; tok_len returns the length,
12 * a pointer to **tok is also returned
13 * if tok is NULL do not return the parsed value
14 */
15
16 char* sstrtokcxx . . $ sstrtok(149270f312b78365).( const char* str, const char* delim, char** tok, int tok_max,
17 int* tok_len, char** s )
18 {
19 char *end = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ;
20 int use = 0 ;
21
22 if ( delim == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) { return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; }
23 if ( str != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) { *s = (char*)str; }
24 if ( **s == '\0' ) { return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; } /* consumed last token */
25 end = strpbrkcxx . . $ strpbrk(a713fe7b9a57cf96).( *s, delim );
26 if ( end == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) {
27 *tok_len = strlencxx . . $ strlen(751346f8406fd082).(*s);
28 } else {
29 *tok_len = end - *s;
30 }
31
32 if ( tok ) {
33 if ( tok_max > 0 ) {
34 use = tok_max < *tok_len ? tok_max : *tok_len;
35 } else {
36 use = *tok_len;
37 }
38 if ( !*tok ) { *tok = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).( use+1 ); }
39 sstrncpycxx . . $ `sstring.h:3:9`!( *tok, *s, use );
40 }
41 *s += *tok_len + ( end == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? 0 : 1 );
42 return tok ? *tok : "";
43 }
44
45 void stolowercxx . . $ stolower(fda57c8427c60377).( char* str ) {
46 if ( !str ) { return; }
47 for ( ; *str; str++ ) {
48 *str = tolowercxx . . $ `<external>/17904084882347303253/ctype.h:220:11`!( *str );
49 }
50 }
51