Jody, All, On 2015-01-04 10:04 -0500, Jody Bruchon spake thusly: > I was looking at the code for strstr(s1, s2) and I do not understand how it > does what it's supposed to do. The only exit points return NULL or the > original pointer to s1. How does strstr() return the pointer to the > substring it's supposed to be looking for?
You're missing line 35: 23 do { 24 if (!*p) { 25 return (Wchar *) s1;; 26 } 27 if (*p == *s) { 28 ++p; 29 ++s; 30 } else { 31 p = s2; 32 if (!*s) { 33 return NULL; 34 } 35 s = ++s1; <-- here, we modify s1. 36 } 37 } while (1); Regards, Yann E. MORIN. -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ uClibc mailing list uClibc@uclibc.org http://lists.busybox.net/mailman/listinfo/uclibc