httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grega...@locus.apache.org
Subject cvs commit: apache-2.0/src/main http_protocol.c
Date Mon, 16 Oct 2000 22:10:42 GMT
gregames    00/10/16 15:10:42

  Modified:    src/main http_protocol.c
  Log:
  simplify bookkeeping in getline() to make it run a little faster, and
  (hopefully) be easier to understand in the future.
  
  Revision  Changes    Path
  1.178     +11 -14    apache-2.0/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
  retrieving revision 1.177
  retrieving revision 1.178
  diff -u -r1.177 -r1.178
  --- http_protocol.c	2000/10/16 20:08:14	1.177
  +++ http_protocol.c	2000/10/16 22:10:41	1.178
  @@ -1063,6 +1063,8 @@
   static int getline(char *s, int n, conn_rec *c, int fold)
   {
       char *pos = s;
  +    char *last_char;
  +    char *beyond_buff = s + n;
       const char *temp;
       int retval;
       int total = 0;
  @@ -1093,7 +1095,8 @@
               break;
           }
   
  -        if (length <= n) {
  +        last_char = pos + length - 1;
  +        if (last_char < beyond_buff) {
               memcpy(pos, temp, length);
               AP_BUCKET_REMOVE(e);
               ap_bucket_destroy(e);
  @@ -1115,18 +1118,12 @@
    *	     && (retval = e->read(e, ) 
    *	     && ((next == ' ') || (next == '\t')));
    */
  -        /* length is the number of characters read, not including NUL    */
  +        pos = last_char;        /* Point at the last character           */
   
  -        n -= length;            /* Keep track of how much of s is full   */
  -        pos += (length - 1);    /* and where s ends                      */
  -        total += length;        /* and how long s has become             */
  -
           if (*pos == '\n') {     /* Did we get a full line of input?      */
                   
               if (pos > s && *(pos - 1) == '\r') {
                   --pos;          /* zap optional CR before LF             */
  -                --total;
  -                ++n;
               }
                   
               /*
  @@ -1138,16 +1135,16 @@
               while (pos > (s + 1) && (*(pos - 1) == ' '
   				     || *(pos - 1) == '\t')) {
                   --pos;          /* trim extra trailing spaces or tabs    */
  -                --total;        /* but not one at the beginning of line  */
  -                ++n;
               }
  -            *pos = '\0';
  -            --total;
  -            ++n;
  +            *pos = '\0';        /* zap end of string                     */
  +            total = pos - s; 
               break;
           }
           else {
  -            pos++;              /* bump past end of incomplete line      */
  +            /* bump past last character read,   
  +             * and set total in case we bail before finding a LF   
  +             */
  +            total = ++pos - s;    
           }
       }
       ap_brigade_destroy(b);
  
  
  

Mime
View raw message