[sword-cvs] sword/src/modules/filters utf8html.cpp,1.5,1.6 utf8latin1.cpp,1.5,1.6

sword@www.crosswire.org sword@www.crosswire.org
Wed, 26 Feb 2003 12:54:06 -0700


Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv15132

Modified Files:
	utf8html.cpp utf8latin1.cpp 
Log Message:
changed to swbuf


Index: utf8html.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/utf8html.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** utf8html.cpp	1 Oct 2002 19:52:40 -0000	1.5
--- utf8html.cpp	26 Feb 2003 19:54:04 -0000	1.6
***************
*** 16,22 ****
  
  
! char UTF8HTML::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
  {
! 	unsigned char *to, *from;
  	int len;
          char digit[10];
--- 16,22 ----
  
  
! char UTF8HTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
  {
! 	unsigned char *from;
  	int len;
          char digit[10];
***************
*** 25,40 ****
  		return -1;
  
! 	len = strlenw(text) + 2;						// shift string to right of buffer
! 	if (len < maxlen) {
! 	        memmove(&text[maxlen - len], text, len);
! 		from = (unsigned char*)&text[maxlen - len];
! 	}
! 	else	from = (unsigned char*)text;
  	// -------------------------------
! 	for (to = (unsigned char*)text; *from; from++) {
  	  ch = 0;
            if ((*from & 128) != 128) {
  //          	if (*from != ' ')
! 	       *to++ = *from;
                 continue;
            }
--- 25,39 ----
  		return -1;
  
! 	len = strlenw(text.c_str()) + 2;						// shift string to right of buffer
! 
! 	SWBuf orig = text;
!   from = (unsigned char *)orig.c_str();
! 
  	// -------------------------------
! 	for (text = ""; *from; from++) {
  	  ch = 0;
            if ((*from & 128) != 128) {
  //          	if (*from != ' ')
! 	       text += *from;
                 continue;
            }
***************
*** 58,70 ****
            ch |= (((short)*from) << (((6*subsequent)+significantFirstBits)-8));
            from += subsequent;
!           *to++ = '&';
!           *to++ = '#';
  	  sprintf(digit, "%d", ch);
  		for (char *dig = digit; *dig; dig++)
! 			*to++ = *dig;
! 		*to++ = ';';
  	}
- 	*to++ = 0;
- 	*to = 0;
  	return 0;
  }
--- 57,67 ----
            ch |= (((short)*from) << (((6*subsequent)+significantFirstBits)-8));
            from += subsequent;
!           text += '&';
!           text += '#';
  	  sprintf(digit, "%d", ch);
  		for (char *dig = digit; *dig; dig++)
! 			text += *dig;
! 		text += ';';
  	}
  	return 0;
  }

Index: utf8latin1.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/utf8latin1.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** utf8latin1.cpp	1 Oct 2002 19:52:40 -0000	1.5
--- utf8latin1.cpp	26 Feb 2003 19:54:04 -0000	1.6
***************
*** 16,23 ****
  
  
! char UTF8Latin1::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
  {
    unsigned char *from;
-   unsigned short *to;
  
    int len;
--- 16,22 ----
  
  
! char UTF8Latin1::processText(SWBuf &text, const SWKey *key, const SWModule *module)
  {
    unsigned char *from;
  
    int len;
***************
*** 27,42 ****
  	 if ((unsigned long)key < 2)	// hack, we're en(1)/de(0)ciphering
  		return -1;
!   len = strlen(text) + 1;						// shift string to right of buffer
!   if (len < maxlen) {
!     memmove(&text[maxlen - len], text, len);
!     from = (unsigned char*)&text[maxlen - len];
!   }
!   else
!     from = (unsigned char*)text;
!   
    
    // -------------------------------
    
!   for (to = (unsigned short*)text; *from; from++) {
      uchar = 0;
      if ((*from & 128) != 128) {
--- 26,38 ----
  	 if ((unsigned long)key < 2)	// hack, we're en(1)/de(0)ciphering
  		return -1;
!   len = strlen(text.c_str()) + 1;						// shift string to right of buffer
! 
! 	SWBuf orig = text;
!   from = (unsigned char*)orig.c_str();
! 
    
    // -------------------------------
    
!   for (text = ""; *from; from++) {
      uchar = 0;
      if ((*from & 128) != 128) {
***************
*** 65,77 ****
  
      if (uchar < 0xff) {
!         *to++ = (unsigned char)uchar;
      }
      else {
!         *to++ = replacementChar;
      }
    }
-   *to++ = 0;
-   *to = 0;
- 
    return 0;
  }
--- 61,70 ----
  
      if (uchar < 0xff) {
!         text += (unsigned char)uchar;
      }
      else {
!         text += replacementChar;
      }
    }
    return 0;
  }