# httpd-dev mailing list archives

##### Site index · List index
Message view
Top
From Brian Behlendorf <br...@hyperreal.com>
Subject fix for instoppable loop in mod_imap.c (code)
Date Thu, 06 Jun 1996 10:58:59 GMT
```
oops, here it is.

*** mod_imap.c~	Thu Jun  6 03:19:47 1996
--- mod_imap.c	Thu Jun  6 03:20:09 1996
***************
*** 441,446 ****
--- 441,447 ----
if ((string_pos = strrchr(directory, '/')))
*string_pos = '\0';
clen = strlen (directory);
+ 	      if (clen == 0) break;
}

value += 2;      /* jump over the '..' that we found in the value */

While we're at it, I also fixed pointinrect() such that the points can be
any two points in the rectangle in any order, not just upper-left to
lower-right.  I'm sure there's a neater way to do this, all you C purists
get yer emacs sessions ready!  Let's have a contest to see who can code
this in the least number of bytes possible....  (and yes, I consider this
a bugfix, since nothing in the docs say the points have to be upper-left
and lower-right)

*** mod_imap.c~	Thu Jun  6 03:20:09 1996
--- mod_imap.c	Thu Jun  6 03:53:48 1996
***************
*** 158,165 ****

int pointinrect(double point[2], double coords[MAXVERTS][2])
{
!     return ((point[X] >= coords[0][X] && point[X] <= coords[1][X]) &&
! 	    (point[Y] >= coords[0][Y] && point[Y] <= coords[1][Y]));
}

int pointincircle(double point[2], double coords[MAXVERTS][2])
--- 158,182 ----

int pointinrect(double point[2], double coords[MAXVERTS][2])
{
!     double max[2], min[2];
!     if (coords[0][X] > coords[1][X]) {
!         max[0] = coords[0][X];
!         min[0] = coords[1][X];
!     } else {
!         max[0] = coords[1][X];
!         min[0] = coords[0][X];
!     }
!
!     if (coords[0][Y] > coords[1][Y]) {
!         max[1] = coords[0][Y];
!         min[1] = coords[1][Y];
!     } else {
!         max[1] = coords[1][Y];
!         min[1] = coords[0][Y];
!     }
!
!     return ((point[X] >= min[0] && point[X] <= max[0]) &&
! 	    (point[Y] >= min[1] && point[Y] <= max[1]));
}

int pointincircle(double point[2], double coords[MAXVERTS][2])

As always, let me know what you think.

```
Mime
View raw message