cvs commit: apachen/src/modules/standard mod_imap.c

1998-01-22 Thread coar
coar98/01/22 15:18:08

  Modified:src/modules/standard mod_imap.c
  Log:
Clean up (marginally) some longer-than-80-character lines, and
do some other indenting.
  
  Revision  ChangesPath
  1.39  +186 -106  apachen/src/modules/standard/mod_imap.c
  
  Index: mod_imap.c
  ===
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_imap.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- mod_imap.c1998/01/21 19:06:13 1.38
  +++ mod_imap.c1998/01/22 23:18:07 1.39
  @@ -136,7 +136,8 @@
   imap_conf_rec *add = (imap_conf_rec *) addv;
   
   new-imap_menu = add-imap_menu ? add-imap_menu : base-imap_menu;
  -new-imap_default = add-imap_default ? add-imap_default : 
base-imap_default;
  +new-imap_default = add-imap_default ? add-imap_default
  +  : base-imap_default;
   new-imap_base = add-imap_base ? add-imap_base : base-imap_base;
   
   return new;
  @@ -215,9 +216,11 @@
   p = (double *) pgon + 1;
   if ((y = ty) != (*p = ty)) {
   
  -if ((xflag0 = (pgon[numverts - 1][X] = tx)) == (*(double *) pgon = 
tx)) {
  -if (xflag0)
  + xflag0 = (pgon[numverts - 1][X] = tx);
  +if (xflag0 == (*(double *) pgon = tx)) {
  +if (xflag0) {
   crossings++;
  + }
   }
   else {
   crossings += (pgon[numverts - 1][X] - (y - ty) *
  @@ -232,15 +235,18 @@
   
   if (y = ty) {
   
  -while ((p  stop)  (*p = ty))
  +while ((p  stop)  (*p = ty)) {
   p += 2;
  + }
   
  -if (p = stop)
  +if (p = stop) {
   break;
  -if ((xflag0 = (*(p - 3) = tx)) == (*(p - 1) = tx)) {
  +}
  + if ((xflag0 = (*(p - 3) = tx)) == (*(p - 1) = tx)) {
   
  -if (xflag0)
  +if (xflag0) {
   crossings++;
  + }
   }
   else {
   crossings += (*(p - 3) - (*(p - 2) - ty) *
  @@ -248,15 +254,18 @@
   }
   }
   else {
  -while ((p  stop)  (*p  ty))
  +while ((p  stop)  (*p  ty)) {
   p += 2;
  + }
   
  -if (p = stop)
  +if (p = stop) {
   break;
  + }
   
   if ((xflag0 = (*(p - 3) = tx)) == (*(p - 1) = tx)) {
  -if (xflag0)
  +if (xflag0) {
   crossings++;
  + }
   }
   else {
   crossings += (*(p - 3) - (*(p - 2) - ty) *
  @@ -270,21 +279,25 @@
   }
   
   
  -static int is_closer(const double point[2], double coords[MAXVERTS][2], 
double *closest)
  +static int is_closer(const double point[2], double coords[MAXVERTS][2],
  + double *closest)
   {
  -double dist_squared = ((point[X] - coords[0][X]) * (point[X] - 
coords[0][X]))
  -+ ((point[Y] - coords[0][Y]) * (point[Y] - coords[0][Y]));
  +double dist_squared = ((point[X] - coords[0][X])
  +   * (point[X] - coords[0][X]))
  +  + ((point[Y] - coords[0][Y])
  + * (point[Y] - coords[0][Y]));
   
  -if (point[X]  0 || point[Y]  0)
  -return (0); /* don't mess around with negative 
coordinates */
  +if (point[X]  0 || point[Y]  0) {
  +return (0);  /* don't mess around with negative coordinates 
*/
  +}
   
   if (*closest  0 || dist_squared  *closest) {
   *closest = dist_squared;
  -return (1); /* if this is the first point or is the 
closest yet
  -   set 'closest' equal to this distance^2 */
  +return (1);  /* if this is the first point or is the closest 
yet
  +set 'closest' equal to this distance^2 */
   }
   
  -return (0); /* if it's not the first or closest */
  +return (0);  /* if it's not the first or closest */
   
   }
   
  @@ -293,18 +306,23 @@
   char *endptr;   /* we want it non-null */
   double x_coord = -1;/* -1 is returned if no coordinate is given 
*/
   
  -if (args == NULL)
  +if (args == NULL) {
   return (-1);/* in case we aren't passed anything */
  +}
   
  -while (*args  !isdigit(*args)  *args != ',')
  -args++; /* jump to the first digit, but not past a 
comma or end */
  +while (*args  !isdigit(*args)  *args != ',') {
  +args++; /* jump to the first digit, but not past
  +   a comma or end */
  +}
   
   x_coord = strtod(args, 

cvs commit: apachen/src/modules/standard mod_imap.c

1998-01-21 Thread coar
coar98/01/21 11:06:13

  Modified:.STATUS
   src  CHANGES
   src/modules/standard mod_imap.c
  Log:
Another patch (consts in mod_imap.c) noted.
  
  Revision  ChangesPath
  1.110 +1 -0  apachen/STATUS
  
  Index: STATUS
  ===
  RCS file: /export/home/cvs/apachen/STATUS,v
  retrieving revision 1.109
  retrieving revision 1.110
  diff -u -r1.109 -r1.110
  --- STATUS1998/01/21 18:25:24 1.109
  +++ STATUS1998/01/21 19:06:09 1.110
  @@ -96,6 +96,7 @@
 misplacement.
   * Ken's addition of src/ap/ap.h for prototypes of routines in libap.a
   * Ken's addition of #ifndef wrappers to src/main/*.h header files
  +* Ken's removal of problem-causing consts from mod_imap.c
   
   Available Patches:
   
  
  
  
  1.573 +4 -0  apachen/src/CHANGES
  
  Index: CHANGES
  ===
  RCS file: /export/home/cvs/apachen/src/CHANGES,v
  retrieving revision 1.572
  retrieving revision 1.573
  diff -u -r1.572 -r1.573
  --- CHANGES   1998/01/21 18:23:42 1.572
  +++ CHANGES   1998/01/21 19:06:11 1.573
  @@ -1,5 +1,9 @@
   Changes with Apache 1.3b4
   
  +  *) Some const declarations in mod_imap.c that were added for debugging
  + purposes caused some compilers heartburn without adding any
  + significant value, so they've been removed.  [Ken Coar]
  +
 *) The src/main/*.h header files have had #ifndef wrappers added to
insulate them against duplicate calls if they get included through
multiple paths (e.g., in .c files as well as other .h files).
  
  
  
  1.38  +4 -4  apachen/src/modules/standard/mod_imap.c
  
  Index: mod_imap.c
  ===
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_imap.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- mod_imap.c1998/01/07 22:23:33 1.37
  +++ mod_imap.c1998/01/21 19:06:13 1.38
  @@ -157,7 +157,7 @@
   {NULL}
   };
   
  -static int pointinrect(const double point[2], const double 
coords[MAXVERTS][2])
  +static int pointinrect(const double point[2], double coords[MAXVERTS][2])
   {
   double max[2], min[2];
   if (coords[0][X]  coords[1][X]) {
  @@ -182,7 +182,7 @@
   (point[Y] = min[1]  point[Y] = max[1]));
   }
   
  -static int pointincircle(const double point[2], const double 
coords[MAXVERTS][2])
  +static int pointincircle(const double point[2], double coords[MAXVERTS][2])
   {
   double radius1, radius2;
   
  @@ -195,7 +195,7 @@
   return (radius2 = radius1);
   }
   
  -static int pointinpoly(const double point[2], const double pgon[MAXVERTS][2])
  +static int pointinpoly(const double point[2], double pgon[MAXVERTS][2])
   {
   int i, numverts, inside_flag, xflag0;
   int crossings;
  @@ -270,7 +270,7 @@
   }
   
   
  -static int is_closer(const double point[2], const double 
coords[MAXVERTS][2], double *closest)
  +static int is_closer(const double point[2], double coords[MAXVERTS][2], 
double *closest)
   {
   double dist_squared = ((point[X] - coords[0][X]) * (point[X] - 
coords[0][X]))
   + ((point[Y] - coords[0][Y]) * (point[Y] - coords[0][Y]));
  
  
  


cvs commit: apachen/src/modules/standard mod_imap.c

1998-01-07 Thread dgaudet
dgaudet 98/01/07 14:23:34

  Modified:src/modules/standard mod_imap.c
  Log:
  This is a bit large, but that's deliberate because I took the opportunity
  to do the crap that we've been wanting done to mod_imap.
  
  - liberal use of const to help find stack assignments
  
  - remove all constant sized char arrays except input[]; replaced by pool
  string functions or by pointers into tokens inside the input[]
  array
  
  - in particular, the use of read_quoted() had a stack overrun potential.
  Eliminated.
  
  - These changes can chew memory when generating a menu.  I don't care,
  I'd rather have them do that than have them overrun the stack.  It
  shouldn't chew more than approx the size of the map file though.
  
  - better error handling
  
  Reviewed by:  Jim Jagielski, Martin Kraemer
  
  Revision  ChangesPath
  1.37  +165 -153  apachen/src/modules/standard/mod_imap.c
  
  Index: mod_imap.c
  ===
  RCS file: /export/home/cvs/apachen/src/modules/standard/mod_imap.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- mod_imap.c1998/01/07 16:46:50 1.36
  +++ mod_imap.c1998/01/07 22:23:33 1.37
  @@ -97,8 +97,6 @@
   #include util_script.h
   
   #define IMAP_MAGIC_TYPE application/x-httpd-imap
  -#define LARGEBUF 500
  -#define SMALLBUF 256
   #define MAXVERTS 100
   #define X 0
   #define Y 1
  @@ -159,7 +157,7 @@
   {NULL}
   };
   
  -static int pointinrect(double point[2], double coords[MAXVERTS][2])
  +static int pointinrect(const double point[2], const double 
coords[MAXVERTS][2])
   {
   double max[2], min[2];
   if (coords[0][X]  coords[1][X]) {
  @@ -184,7 +182,7 @@
   (point[Y] = min[1]  point[Y] = max[1]));
   }
   
  -static int pointincircle(double point[2], double coords[MAXVERTS][2])
  +static int pointincircle(const double point[2], const double 
coords[MAXVERTS][2])
   {
   double radius1, radius2;
   
  @@ -197,11 +195,12 @@
   return (radius2 = radius1);
   }
   
  -static int pointinpoly(double point[2], double pgon[MAXVERTS][2])
  +static int pointinpoly(const double point[2], const double pgon[MAXVERTS][2])
   {
   int i, numverts, inside_flag, xflag0;
   int crossings;
  -double *p, *stop;
  +double *p;
  +const double *stop;
   double tx, ty, y;
   
   for (i = 0; pgon[i][X] != -1  i  MAXVERTS; i++);
  @@ -271,7 +270,7 @@
   }
   
   
  -static int is_closer(double point[2], double coords[MAXVERTS][2], double 
*closest)
  +static int is_closer(const double point[2], const double 
coords[MAXVERTS][2], double *closest)
   {
   double dist_squared = ((point[X] - coords[0][X]) * (point[X] - 
coords[0][X]))
   + ((point[Y] - coords[0][Y]) * (point[Y] - coords[0][Y]));
  @@ -289,7 +288,7 @@
   
   }
   
  -static double get_x_coord(char *args)
  +static double get_x_coord(const char *args)
   {
   char *endptr;   /* we want it non-null */
   double x_coord = -1;/* -1 is returned if no coordinate is given 
*/
  @@ -308,7 +307,7 @@
   return (-1);/* else if no conversion was made, or if no 
args was given */
   }
   
  -static double get_y_coord(char *args)
  +static double get_y_coord(const char *args)
   {
   char *endptr;   /* we want it non-null */
   char *start_of_y = NULL;
  @@ -336,107 +335,98 @@
   }
   
   
  -static int read_quoted(char *string, char *quoted_part)
  +/* See if string has a quoted part, and if so set *quoted_part to
  + * the first character of the quoted part, then hammer a \0 onto the
  + * trailing quote, and set *string to point at the first character
  + * past the second quote.
  + *
  + * Otherwise set *quoted_part to NULL, and leave *string alone.
  + */
  +static void read_quoted(char **string, char **quoted_part)
   {
  -char *starting_pos = string;
  +char *strp = *string;
   
  -while (isspace(*string))
  -string++;   /* go along string until non-whitespace */
  +/* assume there's no quoted part */
  +*quoted_part = NULL;
   
  -if (*string == '') {   /* if that character is a double quote */
  +while (isspace(*strp))
  +strp++;  /* go along string until non-whitespace 
*/
   
  -string++;   /* step over it */
  +if (*strp == '') {  /* if that character is a double quote 
*/
  +strp++;  /* step over it */
  + *quoted_part = strp;/* note where the quoted part begins */
   
  -while (*string  *string != '') {
  -*quoted_part++ = *string++; /* copy the quoted portion */
  +while (*strp  *strp != '') {
  + ++strp; /* skip the quoted portion */
   }
   
  -*quoted_part = '\0';/* end the string with a SNUL */
  +*strp = '\0';