httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <jwool...@virginia.edu>
Subject Re: I WANT A GA release
Date Fri, 05 Apr 2002 19:34:47 GMT
On Fri, 5 Apr 2002, Jim Jagielski wrote:

> Ugly, but logically it looks right:

Ouch.  Yeah, I'd wondered about that problem.  The thing is it seems
really silly to me to be fighting with finding the '\0' when we already
know how many loop iterations it should be ('cause we counted them :).

How about this:

Index: apr_cpystrn.c
===================================================================
RCS file: /home/cvs/apr/strings/apr_cpystrn.c,v
retrieving revision 1.10
diff -u -d -r1.10 apr_cpystrn.c
--- apr_cpystrn.c       13 Mar 2002 20:39:26 -0000      1.10
+++ apr_cpystrn.c       5 Apr 2002 19:34:48 -0000
@@ -126,7 +126,7 @@
 {
     const char *cp;
     const char *ct;
-    int isquoted, numargs = 0;
+    int isquoted, numargs = 0, argnum;

 #define SKIP_WHITESPACE(cp) \
     for ( ; *cp == ' ' || *cp == '\t'; ) { \
@@ -171,25 +171,26 @@
     while (*ct != '\0') {
         CHECK_QUOTATION(ct, isquoted);
         DETERMINE_NEXTSTRING(ct, isquoted);
-        ct++;
+        if (*ct != '\0') {
+            ct++;
+        }
         numargs++;
         SKIP_WHITESPACE(ct);
     }
     *argv_out = apr_palloc(token_context, numargs * sizeof(char*));

     /*  determine first argument */
-    numargs = 0;
-    while (*cp != '\0') {
+    for (argnum = 0; argnum < (numargs-1); argnum++) {
         CHECK_QUOTATION(cp, isquoted);
         ct = cp;
         DETERMINE_NEXTSTRING(cp, isquoted);
         cp++;
-        (*argv_out)[numargs] = apr_palloc(token_context, cp - ct);
-        apr_cpystrn((*argv_out)[numargs], ct, cp - ct);
-        numargs++;
+        (*argv_out)[argnum] = apr_palloc(token_context, cp - ct);
+        apr_cpystrn((*argv_out)[argnum], ct, cp - ct);
+        argnum++;
         SKIP_WHITESPACE(cp);
     }
-    (*argv_out)[numargs] = NULL;
+    (*argv_out)[argnum] = NULL;

     return APR_SUCCESS;
 }


--------------------------------------------------------------
   Cliff Woolley
   cliffwoolley@yahoo.com
   Charlottesville, VA



Mime
View raw message