From d610c7d623ece11799b7a3c136680f5218435761 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Wed, 11 Jun 1997 18:35:40 -0700
Subject: [PATCH] bugg in # fixed

Rev: src/modules/sprintf/sprintf.c:1.12
---
 src/modules/sprintf/sprintf.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/modules/sprintf/sprintf.c b/src/modules/sprintf/sprintf.c
index 5bca763687..85c9486d00 100644
--- a/src/modules/sprintf/sprintf.c
+++ b/src/modules/sprintf/sprintf.c
@@ -96,7 +96,7 @@
 */
 
 #include "global.h"
-RCSID("$Id: sprintf.c,v 1.11 1997/05/19 23:33:22 hubbe Exp $");
+RCSID("$Id: sprintf.c,v 1.12 1997/06/12 01:35:40 hubbe Exp $");
 #include "error.h"
 #include "array.h"
 #include "svalue.h"
@@ -349,27 +349,37 @@ INLINE static int do_one(struct format_info *f)
     col=f->width/(f->column_width+1);
     if(!f->column_width || col<1) col=1;
     rest=f->b;
-    for(d=0;*rest && d<col;d++)
+    for(d=0;rest && d<col;d++)
     {
 #if 0
       if(rest != f->b)
 	fix_field(" ",1,0,1," ",1,0);
 #endif
 
+      /* Find end of entry */
       for(e=0;rest[e] && rest[e]!='\n';e++);
+
       fix_field(rest,e,f->flags,f->column_width,
 		f->pad_string,f->pad_length,f->pos_pad);
 
-      for(e=0;*rest && e<mod;e++)
+      f->column_entries--;
+
+      /* Advance to after entry */
+      rest+=e;
+      if(!*rest) break;
+      rest++;
+
+      for(e=1;e<mod;e++)
       {
-	char *s;
-	s=STRCHR(rest,'\n');
+	char *s=STRCHR(rest,'\n');
 	if(s)
+	{
 	  rest=s+1;
-	else
- 	  rest+=strlen(rest);
+	}else{
+	  rest=0;
+	  break;
+	}
       }
-      f->column_entries--;
     }
     if(f->column_entries>0)
     {
-- 
GitLab