diff --git a/CImg.h b/CImg.h index 4b82e8ea..1e759661 100644 --- a/CImg.h +++ b/CImg.h @@ -25741,12 +25741,18 @@ namespace cimg_library { // Forward search if (step>0) { - while (ptr::is_nan(val)) + while (ptr::is_nan(*ptr)) ptr+=step; + else + while (ptr=ptre?-1.:(double)(ptr - ptrb); } // Backward search. - while (ptr>=ptrb && *ptr!=val) ptr+=step; + if (cimg::type::is_nan(val)) + while (ptr>=ptrb && !cimg::type::is_nan(*ptr)) ptr+=step; + else + while (ptr>=ptrb && *ptr!=val) ptr+=step; return ptr0) { do { - while (ptr1::is_nan(*ptr2b)) + while (ptr1::is_nan(*ptr1)) ptr1+=step; + else + while (ptr1=ptr1e) return -1.; p1 = ptr1 + 1; p2 = ptr2b + 1; - while (p1::is_nan(*p1) && cimg::type::is_nan(*p2)) || *p1==*p2)) { ++p1; ++p2; } } while (p2=ptr1b && *ptr1!=*ptr2b) ptr1+=step; + if (cimg::type::is_nan(*ptr2b)) + while (ptr1>=ptr1b && !cimg::type::is_nan(*ptr1)) ptr1+=step; + else + while (ptr1>=ptr1b && *ptr1!=*ptr2b) ptr1+=step; if (ptr1::is_nan(*p1) && cimg::type::is_nan(*p2)) || *p1==*p2)) { ++p1; ++p2; } } while (p2=ptr1b); return p2