[sword-svn] r3751 - in trunk: include src/modules/common

scribe at crosswire.org scribe at crosswire.org
Thu Jul 9 17:36:19 EDT 2020


Author: scribe
Date: 2020-07-09 17:36:19 -0400 (Thu, 09 Jul 2020)
New Revision: 3751

Modified:
   trunk/include/swcomprs.h
   trunk/src/modules/common/lzsscomprs.cpp
   trunk/src/modules/common/swcomprs.cpp
   trunk/src/modules/common/zipcomprs.cpp
Log:
Refactoring: GetChars / SendChars


Modified: trunk/include/swcomprs.h
===================================================================
--- trunk/include/swcomprs.h	2020-07-09 21:29:59 UTC (rev 3750)
+++ trunk/include/swcomprs.h	2020-07-09 21:36:19 UTC (rev 3751)
@@ -41,8 +41,8 @@
   virtual ~ SWCompress ();
   virtual char *Buf (const char *buf = 0, unsigned long *len = 0);
   virtual char *zBuf (unsigned long *len, char *buf = 0);
-  virtual unsigned long GetChars (char *buf, unsigned long len);	// override for other than buffer compression
-  virtual unsigned long SendChars (char *buf, unsigned long len);	// override for other than buffer compression
+  virtual unsigned long getChars (char *buf, unsigned long len);	// override for other than buffer compression
+  virtual unsigned long sendChars (char *buf, unsigned long len);	// override for other than buffer compression
   virtual void encode (void);	// override to provide compression algorythm
   virtual void decode (void);	// override to provide compression algorythm
   virtual void setLevel(int l) {level = l;};

Modified: trunk/src/modules/common/lzsscomprs.cpp
===================================================================
--- trunk/src/modules/common/lzsscomprs.cpp	2020-07-09 21:29:59 UTC (rev 3750)
+++ trunk/src/modules/common/lzsscomprs.cpp	2020-07-09 21:36:19 UTC (rev 3751)
@@ -421,7 +421,7 @@
 	// This function loads the buffer with X characters and returns
 	// the actual amount loaded.
 
-	len = GetChars((char *) &(p->m_ring_buffer[r]), F);
+	len = getChars((char *) &(p->m_ring_buffer[r]), F);
 
 	// Make sure there is something to be compressed.
 
@@ -491,7 +491,7 @@
 			// code_buf is the buffer of characters to be output.
 			// code_buf_pos is the number of characters it contains.
 
-			SendChars((char *) code_buf, code_buf_pos);
+			sendChars((char *) code_buf, code_buf_pos);
 
 			// Reset for next buffer...
 
@@ -507,7 +507,7 @@
 		for (i = 0; i < last_match_length; i++) {
 			// Get next character...
 
-			if (GetChars((char *) &c, 1) != 1)
+			if (getChars((char *) &c, 1) != 1)
 				break;
 
 			// Delete "old strings"
@@ -591,7 +591,7 @@
 		// code_buf is the encoded string to send.
 		// code_buf_ptr is the number of characters.
 
-		SendChars((char *) code_buf, code_buf_pos);
+		sendChars((char *) code_buf, code_buf_pos);
 	}
 
 
@@ -647,7 +647,7 @@
 		else {
 			// Next byte must be a flag.
 
-			if (GetChars((char *) &flags, 1) != 1)
+			if (getChars((char *) &flags, 1) != 1)
 				break;
 
 			// Set the flag counter.  While at first it might appear
@@ -662,10 +662,10 @@
 		// that the next byte is a single, unencoded character.
 
 		if (flags & 1) {
-			if (GetChars((char *) c, 1) != 1)
+			if (getChars((char *) c, 1) != 1)
 				break;
 
-			if (SendChars((char *) c, 1) != 1) {
+			if (sendChars((char *) c, 1) != 1) {
 				break;
 			}
 			totalLen++;
@@ -693,7 +693,7 @@
 			// have changed the variable names to something more
 			// obvious.
 
-			if (GetChars((char *) c, 2) != 2)
+			if (getChars((char *) c, 2) != 2)
 				break;
 
 			// Convert these two characters into the position and
@@ -720,7 +720,7 @@
 
 			// Add the "len" :characters to the output stream.
 
-			if (SendChars((char *) c, len) != (unsigned int)len) {
+			if (sendChars((char *) c, len) != (unsigned int)len) {
 				break;
 			}
 			totalLen += len;

Modified: trunk/src/modules/common/swcomprs.cpp
===================================================================
--- trunk/src/modules/common/swcomprs.cpp	2020-07-09 21:29:59 UTC (rev 3750)
+++ trunk/src/modules/common/swcomprs.cpp	2020-07-09 21:36:19 UTC (rev 3751)
@@ -115,7 +115,7 @@
 }
 
 
-unsigned long SWCompress::GetChars(char *ibuf, unsigned long len)
+unsigned long SWCompress::getChars(char *ibuf, unsigned long len)
 {
 	if (direct) {
 		len = (((zlen - zpos) > (unsigned)len) ? len : zlen - zpos);
@@ -136,7 +136,7 @@
 }
 	
 
-unsigned long SWCompress::SendChars(char *ibuf, unsigned long len)
+unsigned long SWCompress::sendChars(char *ibuf, unsigned long len)
 {
 	if (direct) {
 		if (buf) {
@@ -201,9 +201,9 @@
 	unsigned long len, totlen = 0;
 
 	do {
-		len = GetChars(buf, 1024);
+		len = getChars(buf, 1024);
 		if (len)
-			totlen += SendChars(buf, len);
+			totlen += sendChars(buf, len);
 	} while (len == 1024);
 
 	zlen = slen = totlen;

Modified: trunk/src/modules/common/zipcomprs.cpp
===================================================================
--- trunk/src/modules/common/zipcomprs.cpp	2020-07-09 21:29:59 UTC (rev 3750)
+++ trunk/src/modules/common/zipcomprs.cpp	2020-07-09 21:36:19 UTC (rev 3751)
@@ -86,7 +86,7 @@
 	char *chunkbuf = buf;
 	unsigned long chunklen;
 	unsigned long len = 0;
-	while((chunklen = GetChars(chunk, 1023))) {
+	while((chunklen = getChars(chunk, 1023))) {
 		memcpy(chunkbuf, chunk, chunklen);
 		len += chunklen;
 		if (chunklen < 1023)
@@ -106,7 +106,7 @@
 			printf("ERROR in compression\n");
 		}
 		else {
-			SendChars(zbuf, zlen);
+			sendChars(zbuf, zlen);
 		}
 	}
 	else
@@ -153,7 +153,7 @@
 	char *chunkbuf = zbuf;
 	int chunklen;
 	unsigned long zlen = 0;
-	while((chunklen = (int)GetChars(chunk, 1023))) {
+	while((chunklen = (int)getChars(chunk, 1023))) {
 		memcpy(chunkbuf, chunk, chunklen);
 		zlen += chunklen;
 		if (chunklen < 1023)
@@ -169,7 +169,7 @@
 		//printf("Doing decompress {%s}\n", zbuf);
 		slen = 0;
 		switch (uncompress((Bytef*)buf, &blen, (Bytef*)zbuf, zlen)){
-			case Z_OK: SendChars(buf, blen); slen = blen; break;
+			case Z_OK: sendChars(buf, blen); slen = blen; break;
 			case Z_MEM_ERROR: fprintf(stderr, "ERROR: not enough memory during decompression.\n"); break;
 			case Z_BUF_ERROR: fprintf(stderr, "ERROR: not enough room in the out buffer during decompression.\n"); break;
 			case Z_DATA_ERROR: fprintf(stderr, "ERROR: corrupt data during decompression.\n"); break;



More information about the sword-cvs mailing list