* Slightly more computationally efficient version of memfmout() that doesn't use...
authorArt Cancro <ajc@citadel.org>
Tue, 2 Mar 2010 20:10:40 +0000 (20:10 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 2 Mar 2010 20:10:40 +0000 (20:10 +0000)
citadel/msgbase.c
citadel/sysdep.c

index d189c77e392931cadd3e00a3ec87d392a87571f3..40635193ad286fe861b63eda2441e1489848901c 100644 (file)
@@ -931,12 +931,18 @@ void memfmout(
 ) {
        int column = 0;
        char ch = 0;
-       if (!mptr) return;
+       char outbuf[1024];
+       int len = 0;
+       int nllen = 0;
 
+       if (!mptr) return;
+       nllen = strlen(nl);
        while (ch=*(mptr++), ch > 0) {
 
                if (ch == '\n') {
-                       cprintf("%s", nl);
+                       client_write(outbuf, len);
+                       len = 0;
+                       client_write(nl, nllen);
                        column = 0;
                }
                else if (ch == '\r') {
@@ -944,20 +950,25 @@ void memfmout(
                }
                else if (isspace(ch)) {
                        if (column > 72) {              /* Beyond 72 columns, break on the next space */
-                               cprintf("%s", nl);
+                               client_write(outbuf, len);
+                               len = 0;
+                               client_write(nl, nllen);
                                column = 0;
                        }
                        else {
-                               cprintf("%c", ch);
+                               outbuf[len++] = ch;
+                               ++column;
                        }
                }
                else {
+                       outbuf[len++] = ch;
+                       ++column;
                        if (column > 1000) {            /* Beyond 1000 columns, break anywhere */
-                               cprintf("%s", nl);
+                               client_write(outbuf, len);
+                               len = 0;
+                               client_write(nl, nllen);
                                column = 0;
                        }
-                       cprintf("%c", ch);
-                       ++column;
                }
        }
 }
index d748de23a02a5bd7a109064c01af0079c92a14b8..ce584837b5f04eb34f324820a2bf15e6beeb90f6 100644 (file)
@@ -461,6 +461,8 @@ int client_write(const char *buf, int nbytes)
        CitContext *Ctx;
        int fdflags;
 
+       if (nbytes < 1) return(0);
+
 //     flush_client_inbuf();
        Ctx = CC;
        if (Ctx->redirect_buffer != NULL) {