[sword-cvs] sword/src/modules/filters unicodertf.cpp,1.10,1.11

sword@www.crosswire.org sword@www.crosswire.org
Wed, 26 Feb 2003 12:41:59 -0700


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

Modified Files:
	unicodertf.cpp 
Log Message:
changed to swbuf


Index: unicodertf.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/unicodertf.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** unicodertf.cpp	1 Oct 2002 19:52:40 -0000	1.10
--- unicodertf.cpp	26 Feb 2003 19:41:57 -0000	1.11
***************
*** 16,42 ****
  
  
! char UnicodeRTF::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
  {
! 	unsigned char *to, *from, *maxto;
  	int len;
  	char digit[10];
  	short ch;	// must be signed per unicode spec (negative is ok for big numbers > 32768)
  
! 	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;
! 	maxto =(unsigned char*)text + maxlen;
  
  	// -------------------------------
  	bool lastUni = false;
! 	for (to = (unsigned char*)text; *from && (to <= maxto); from++) {
  		ch = 0;
  		if ((*from & 128) != 128) {
  //			if ((*from == ' ') && (lastUni))
  //				*to++ = ' ';
! 			*to++ = *from;
  			lastUni = false;
  			continue;
--- 16,40 ----
  
  
! char UnicodeRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module)
  {
! 	unsigned char *from;
  	int len;
  	char digit[10];
  	short ch;	// must be signed per unicode spec (negative is ok for big numbers > 32768)
  
! 	SWBuf orig = text;
! 
! 	len = strlenw(text.c_str()) + 2;						// shift string to right of buffer
! #warning is this right? I needed to cast "const" away.
! 	from = (unsigned char*)orig.c_str();
  
  	// -------------------------------
  	bool lastUni = false;
! 	for (text = ""; *from; from++) {
  		ch = 0;
  		if ((*from & 128) != 128) {
  //			if ((*from == ' ') && (lastUni))
  //				*to++ = ' ';
! 			text += *from;
  			lastUni = false;
  			continue;
***************
*** 61,77 ****
  		ch |= (((short)*from) << (((6*subsequent)+significantFirstBits)-8));
  		from += subsequent;
! 		*to++ = '\\';
! 		*to++ = 'u';
  		sprintf(digit, "%d", ch);
  		for (char *dig = digit; *dig; dig++)
! 			*to++ = *dig;
! 		*to++ = '?';
  		lastUni = true;
  	}
  	   
- 	if (to != maxto) {
- 		*to++ = 0;
- 	}
- 	*to = 0;
  	return 0;
  }
--- 59,71 ----
  		ch |= (((short)*from) << (((6*subsequent)+significantFirstBits)-8));
  		from += subsequent;
! 		text += '\\';
! 		text += 'u';
  		sprintf(digit, "%d", ch);
  		for (char *dig = digit; *dig; dig++)
! 			text += *dig;
! 		text += '?';
  		lastUni = true;
  	}
  	   
  	return 0;
  }