[srvx-commits] CVS: services/src helpfile.c,1.64,1.65
                
                Brought to you by:
                
                    entrope
                    
                
            
            
        
        
        
    | 
     
      
      
      From: Entrope <en...@us...> - 2003-10-10 02:41:04
      
     
   | 
Update of /cvsroot/srvx/services/src
In directory sc8-pr-cvs1:/tmp/cvs-serv10018/src
Modified Files:
	helpfile.c 
Log Message:
don't send extra spaces at the end of lines in tables
Index: helpfile.c
===================================================================
RCS file: /cvsroot/srvx/services/src/helpfile.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -r1.64 -r1.65
*** helpfile.c	26 Sep 2003 15:18:02 -0000	1.64
--- helpfile.c	10 Oct 2003 02:41:01 -0000	1.65
***************
*** 104,108 ****
           * in a row. */
          for (pos=ii=0; ii<((table.flags & TABLE_REPEAT_HEADERS)?nreps:1); ii++) {
!             for (jj=0; jj<table.width; jj++) {
                  len = strlen(table.contents[0][jj]);
                  spaces = max_width[jj] - len;
--- 104,108 ----
           * in a row. */
          for (pos=ii=0; ii<((table.flags & TABLE_REPEAT_HEADERS)?nreps:1); ii++) {
!             for (jj=0; 1; ) {
                  len = strlen(table.contents[0][jj]);
                  spaces = max_width[jj] - len;
***************
*** 110,124 ****
                  memcpy(line+pos, table.contents[0][jj], len);
                  pos += len;
                  if (!(table.flags & TABLE_PAD_LEFT)) while (spaces--) line[pos++] = ' ';
                  line[pos++] = ' ';
              }
          }
!         line[--pos] = 0;
          irc_send(from, to, line);
          ii = 1;
      }
      /* Send the table. */
!     for (pos=0, reps=0; ii<table.length; ) {
!         for (jj=0; jj<table.width; jj++) {
              len = strlen(table.contents[ii][jj]);
              spaces = max_width[jj] - len;
--- 110,125 ----
                  memcpy(line+pos, table.contents[0][jj], len);
                  pos += len;
+                 if (++jj == table.width) break;
                  if (!(table.flags & TABLE_PAD_LEFT)) while (spaces--) line[pos++] = ' ';
                  line[pos++] = ' ';
              }
          }
!         line[pos] = 0;
          irc_send(from, to, line);
          ii = 1;
      }
      /* Send the table. */
!     for (jj=0, pos=0, reps=0; ii<table.length; ) {
!         while (1) {
              len = strlen(table.contents[ii][jj]);
              spaces = max_width[jj] - len;
***************
*** 126,137 ****
              memcpy(line+pos, table.contents[ii][jj], len);
              pos += len;
              if (!(table.flags & TABLE_PAD_LEFT)) while (spaces--) line[pos++] = ' ';
              line[pos++] = ' ';
-         }
-         ++ii; ++reps;
-         if ((reps == nreps) || (ii==table.length)) {
-             line[--pos] = 0;
-             irc_send(from, to, line);
-             pos = reps = 0;
          }
      }
--- 127,141 ----
              memcpy(line+pos, table.contents[ii][jj], len);
              pos += len;
+             if (++jj == table.width) {
+                 jj = 0, ++ii, ++reps;
+                 if ((reps == nreps) || (ii == table.length)) {
+                     line[pos] = 0;
+                     irc_send(from, to, line);
+                     pos = reps = 0;
+                     break;
+                 }
+             }
              if (!(table.flags & TABLE_PAD_LEFT)) while (spaces--) line[pos++] = ' ';
              line[pos++] = ' ';
          }
      }
 |