httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject [PATCH] Re: ap_snprintf()
Date Sun, 19 Jan 1997 21:29:49 GMT
On Sun, 19 Jan 1997, Randy Terbush wrote:
> I deleted your patch thinking that was something that Jim would
> have to comment on. However, I'm thinking that we should perhaps
> apply it to give this a proper test.

I redid it against the latest version in the repository.

These are just changes to improve portability.  Remove __ identifiers
since they're claimed by ansi/posix for the c library and system files. 
Remove any prototypes.  Fix #includes.  This compiles fine with -DHAVE_CVT
or without.

BTW, I'm running with the buffer patches too (except mod_fastcgi.c has
been seriously changed in the repository such that the buffer-len patches
don't patch against it at all), but using Linux's native snprintf. 

Dean

Index: util_snprintf.c
===================================================================
RCS file: /export/home/cvs/apache/src/util_snprintf.c,v
retrieving revision 1.2
diff -u -r1.2 util_snprintf.c
--- util_snprintf.c	1997/01/18 21:28:15	1.2
+++ util_snprintf.c	1997/01/19 21:26:26
@@ -63,6 +63,9 @@
 #include <ctype.h>
 #include <sys/types.h>
 #include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
 
 #ifdef HAVE_CVT
 
@@ -77,9 +80,6 @@
  * from GNU libc-4.6.27
  */
 
-#include <stdlib.h>
-#include <math.h>
-
 /*
  *    ap_ecvt converts to decimal
  *      the number of digits is specified by ndigit
@@ -273,12 +273,12 @@
 /*
  * Descriptor for buffer area
  */
-struct __buf_area {
+struct buf_area {
     char *buf_end;
     char *nextb;		/* pointer to next byte to read/write   */
 };
 
-typedef struct __buf_area __buffy;
+typedef struct buf_area buffy;
 
 /*
  * The INS_CHAR macro inserts a character in the buffer and writes
@@ -416,8 +416,6 @@
     register char *s = buf;
     register char *p;
     int decimal_point;
-    extern char *ap_ecvt(), *ap_fcvt();
-    char *strcpy(char *, const char *);
 
     if (format == 'f')
 	p = ap_fcvt(num, precision, &decimal_point, is_negative);
@@ -528,7 +526,7 @@
 /*
  * Do format conversion placing the output in buffer
  */
-static int __format_converter(register __buffy * odp, const char *fmt,
+static int format_converter(register buffy * odp, const char *fmt,
 			      va_list ap)
 {
     register char *sp;
@@ -566,11 +564,6 @@
     boolean_e adjust_width;
     bool_int is_negative;
 
-    extern char *ap_gcvt();
-    char *strchr(const char *, int);
-    int isascii(int);
-
-
     sp = odp->nextb;
     bep = odp->buf_end;
 
@@ -847,7 +840,7 @@
 		 * We print %<char> to help the user identify what
 		 * option is not understood.
 		 * This is also useful in case the user wants to pass
-		 * the output of __format_converter to another function
+		 * the output of format_converter to another function
 		 * that understands some other %<char> (like syslog).
 		 * Note that we can't point s inside fmt because the
 		 * unknown <char> could be preceded by width etc.
@@ -900,7 +893,7 @@
 static void strx_printv(int *ccp, char *buf, size_t len, const char *format,
 			va_list ap)
 {
-    __buffy od;
+    buffy od;
     int cc;
 
     /*
@@ -914,7 +907,7 @@
     /*
      * Do the conversion
      */
-    cc = __format_converter(&od, format, ap);
+    cc = format_converter(&od, format, ap);
     if (len == 0 || od.nextb <= od.buf_end)
 	*(od.nextb) = '\0';
     if (ccp)



Mime
View raw message