ucx/string.c

changeset 148
c27c2425c0b1
parent 146
aa376dba1ba8
child 149
3bf87676d42d
equal deleted inserted replaced
147:1aa598f36872 148:c27c2425c0b1
109 109
110 sstr_t sstrchr(sstr_t s, int c) { 110 sstr_t sstrchr(sstr_t s, int c) {
111 for(size_t i=0;i<s.length;i++) { 111 for(size_t i=0;i<s.length;i++) {
112 if(s.ptr[i] == c) { 112 if(s.ptr[i] == c) {
113 return sstrsubs(s, i); 113 return sstrsubs(s, i);
114 }
115 }
116 sstr_t n;
117 n.ptr = NULL;
118 n.length = 0;
119 return n;
120 }
121
122 sstr_t sstrrchr(sstr_t s, int c) {
123 if (s.length > 0) {
124 for(size_t i=s.length-1;i>=0;i--) {
125 if(s.ptr[i] == c) {
126 return sstrsubs(s, i);
127 }
114 } 128 }
115 } 129 }
116 sstr_t n; 130 sstr_t n;
117 n.ptr = NULL; 131 n.ptr = NULL;
118 n.length = 0; 132 n.length = 0;

mercurial