cvs commit: apache-1.3/src/main alloc.c buff.c

1998-03-30 Thread dgaudet
dgaudet 98/03/29 17:22:53

  Modified:.STATUS
   src  CHANGES
   src/ap   ap_snprintf.c
   src/include ap.h
   src/main alloc.c buff.c
  Log:
  Satisfy the naming police.  I prefer ap_ anyhow.  I would be a lot happier
  with a single prefix as already noted in STATUS.
  
  Revision  ChangesPath
  1.237 +2 -2  apache-1.3/STATUS
  
  Index: STATUS
  ===
  RCS file: /export/home/cvs/apache-1.3/STATUS,v
  retrieving revision 1.236
  retrieving revision 1.237
  diff -u -r1.236 -r1.237
  --- STATUS1998/03/30 01:14:34 1.236
  +++ STATUS1998/03/30 01:22:43 1.237
  @@ -119,7 +119,7 @@
   * Fix for symlink check in mod_rewrite's ``RewriteCond ... -l'', PR#2010
   * Fix: SIGXCPU and SIGXFSZ are now reset to SIG_DFL at boot-time
   * Dean's remove of HAVE_SNPRINTF
  -* Dean's mutation of ap_snprintf() code into apapi_vformatter()
  +* Dean's mutation of ap_snprintf() code into ap_vformatter()
   * Lars' fix for "Options +Includes" and "+IncludesNoExec" merging
   * Jim's fix for inconsistent usage of TCC and CC in Configure
   * Jim's fix for IRIX which needs the -n32 flag iff using 'cc', PR#1901
  @@ -285,7 +285,7 @@
  machine. Could be OS problems..
   
 * vformatter TODO:
  -- double check logic in apapi_vformatter(), and especially psprintf()
  +- double check logic in ap_vformatter(), and especially psprintf()
   - add in and use the inaddr formatting codes that started the whole
 debate last october
   - ... so that we can finally start fixing all the log messages that
  
  
  
  1.749 +1 -1  apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===
  RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.748
  retrieving revision 1.749
  diff -u -r1.748 -r1.749
  --- CHANGES   1998/03/29 19:11:54 1.748
  +++ CHANGES   1998/03/30 01:22:45 1.749
  @@ -30,7 +30,7 @@
 *) "Options +Includes" wasn't correctly merged if "+IncludesNoExec"
was defined in a parent directory. [Lars Eilebrecht]
   
  -  *) API: ap_snprintf() code mutated into apapi_vformatter(), which is
  +  *) API: ap_snprintf() code mutated into ap_vformatter(), which is
a generic printf-style routine that can call arbitrary output
routines.  Use this to replace http_bprintf.c.  Add new routines
psprintf(), pvsprintf() which allocate the exact amount of memory
  
  
  
  1.17  +7 -7  apache-1.3/src/ap/ap_snprintf.c
  
  Index: ap_snprintf.c
  ===
  RCS file: /export/home/cvs/apache-1.3/src/ap/ap_snprintf.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ap_snprintf.c 1998/03/29 09:35:40 1.16
  +++ ap_snprintf.c 1998/03/30 01:22:47 1.17
  @@ -504,8 +504,8 @@
   /*
* Do format conversion placing the output in buffer
*/
  -API_EXPORT(int) apapi_vformatter(int (*flush_func)(apapi_vformatter_buff *),
  -apapi_vformatter_buff *vbuff, const char *fmt, va_list ap)
  +API_EXPORT(int) ap_vformatter(int (*flush_func)(ap_vformatter_buff *),
  +ap_vformatter_buff *vbuff, const char *fmt, va_list ap)
   {
   register char *sp;
   register char *bep;
  @@ -878,7 +878,7 @@
   }
   
   
  -static int snprintf_flush(apapi_vformatter_buff *vbuff)
  +static int snprintf_flush(ap_vformatter_buff *vbuff)
   {
   return -1;
   }
  @@ -888,7 +888,7 @@
   {
   int cc;
   va_list ap;
  -apapi_vformatter_buff vbuff;
  +ap_vformatter_buff vbuff;
   
   if (len == 0)
return 0;
  @@ -897,7 +897,7 @@
   vbuff.curpos = buf;
   vbuff.endpos = buf + len - 1;
   va_start(ap, format);
  -cc = apapi_vformatter(snprintf_flush, &vbuff, format, ap);
  +cc = ap_vformatter(snprintf_flush, &vbuff, format, ap);
   va_end(ap);
   *vbuff.curpos = '\0';
   return (cc == -1) ? len : cc;
  @@ -908,7 +908,7 @@
 va_list ap)
   {
   int cc;
  -apapi_vformatter_buff vbuff;
  +ap_vformatter_buff vbuff;
   
   if (len == 0)
return 0;
  @@ -916,7 +916,7 @@
   /* save one byte for nul terminator */
   vbuff.curpos = buf;
   vbuff.endpos = buf + len - 1;
  -cc = apapi_vformatter(snprintf_flush, &vbuff, format, ap);
  +cc = ap_vformatter(snprintf_flush, &vbuff, format, ap);
   *vbuff.curpos = '\0';
   return (cc == -1) ? len : cc;
   }
  
  
  
  1.10  +10 -10apache-1.3/src/include/ap.h
  
  Index: ap.h
  ===
  RCS file: /export/home/cvs/apache-1.3/src/include/ap.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ap.h  1998/03/29 09:35:41 1.9
  +++

cvs commit: apache-1.3/src/main alloc.c buff.c

1998-03-29 Thread dgaudet
dgaudet 98/03/29 01:35:44

  Modified:src/ap   ap_snprintf.c
   src/include ap.h
   src/main alloc.c buff.c
  Log:
  Revamp the apapi_vformatter interface to reduce copies.  In this interface
  the callers hand apapi_vformatter pointers into their own private buffers,
  and are called back for flushing when appropriate.  This is more efficient
  and seems somewhat more clean.
  
  Revision  ChangesPath
  1.16  +23 -44apache-1.3/src/ap/ap_snprintf.c
  
  Index: ap_snprintf.c
  ===
  RCS file: /export/home/cvs/apache-1.3/src/ap/ap_snprintf.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ap_snprintf.c 1998/03/28 21:58:38 1.15
  +++ ap_snprintf.c 1998/03/29 09:35:40 1.16
  @@ -266,10 +266,11 @@
   #define INS_CHAR(c, sp, bep, cc) \
{   \
if (sp == bep) {\
  - if (write_func(write_data, staging_buf, \
  - sizeof(staging_buf)) != 0)  \
  + vbuff->curpos = sp; \
  + if (flush_func(vbuff))  \
return -1;  \
  - sp = staging_buf;   \
  + sp = vbuff->curpos; \
  + bep = vbuff->endpos;\
}   \
*sp++ = (c);\
cc++;   \
  @@ -503,9 +504,8 @@
   /*
* Do format conversion placing the output in buffer
*/
  -API_EXPORT(int) apapi_vformatter(
  -int (*write_func)(void *, const char *, size_t),
  -void *write_data, const char *fmt, va_list ap)
  +API_EXPORT(int) apapi_vformatter(int (*flush_func)(apapi_vformatter_buff *),
  +apapi_vformatter_buff *vbuff, const char *fmt, va_list ap)
   {
   register char *sp;
   register char *bep;
  @@ -531,8 +531,6 @@
   char num_buf[NUM_BUF_SIZE];
   char char_buf[2];/* for printing %% and % */
   
  -char staging_buf[MAX_STRING_LEN];
  -
   /*
* Flag variables
*/
  @@ -544,8 +542,8 @@
   boolean_e adjust_width;
   bool_int is_negative;
   
  -sp = staging_buf;
  -bep = sp + sizeof(staging_buf);
  +sp = vbuff->curpos;
  +bep = vbuff->endpos;
   
   while (*fmt) {
if (*fmt != '%') {
  @@ -875,33 +873,14 @@
}
fmt++;
   }
  -if (sp > staging_buf) {
  - if (write_func(write_data, staging_buf, sp - staging_buf) != 0) {
  - return -1;
  - }
  -}
  +vbuff->curpos = sp;
   return cc;
   }
   
   
  -struct snprintf_write_data {
  -char *strp;
  -char *end_buf;
  -};
  -
  -static int snprintf_write(void *vdata, const char *inp, size_t len)
  +static int snprintf_flush(apapi_vformatter_buff *vbuff)
   {
  -struct snprintf_write_data *wd;
  -size_t amt;
  -
  -wd = vdata;
  -amt = wd->end_buf - wd->strp;
  -if (len > amt) {
  - len = amt;
  -}
  -memcpy(wd->strp, inp, len);
  -wd->strp += len;
  -return 0;
  +return -1;
   }
   
   
  @@ -909,19 +888,19 @@
   {
   int cc;
   va_list ap;
  -struct snprintf_write_data wd;
  +apapi_vformatter_buff vbuff;
   
   if (len == 0)
return 0;
   
   /* save one byte for nul terminator */
  -wd.strp = buf;
  -wd.end_buf = buf + len - 1;
  +vbuff.curpos = buf;
  +vbuff.endpos = buf + len - 1;
   va_start(ap, format);
  -cc = apapi_vformatter(snprintf_write, &wd, format, ap);
  -*wd.strp = '\0';
  +cc = apapi_vformatter(snprintf_flush, &vbuff, format, ap);
   va_end(ap);
  -return (cc);
  +*vbuff.curpos = '\0';
  +return (cc == -1) ? len : cc;
   }
   
   
  @@ -929,15 +908,15 @@
 va_list ap)
   {
   int cc;
  -struct snprintf_write_data wd;
  +apapi_vformatter_buff vbuff;
   
   if (len == 0)
return 0;
   
   /* save one byte for nul terminator */
  -wd.strp = buf;
  -wd.end_buf = buf + len - 1;
  -cc = apapi_vformatter(snprintf_write, &wd, format, ap);
  -*wd.strp = '\0';
  -return (cc);
  +vbuff.curpos = buf;
  +vbuff.endpos = buf + len - 1;
  +cc = apapi_vformatter(snprintf_flush, &vbuff, format, ap);
  +*vbuff.curpos = '\0';
  +return (cc == -1) ? len : cc;
   }
  
  
  
  1.9   +41 -11apache-1.3/src/include/ap.h
  
  Index: ap.h
  ===
  RCS file: /export/home/cvs/apache-1.3/src/include/ap.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff