Continuation() sometimes does not work well in multibyte environment

monyo at home.monyo.com monyo at home.monyo.com
Tue Dec 14 18:09:01 GMT 1999


Hi.

I've found a problem in samba-2.0.6 and also latest SAMBA_2_0 CVS Head
branch. Under Japanese environment, continuation() at
source/param/params.c sometimes does not work well in multibyte
environment. Because under some mutibyte environment, an ASCII
character '\' (0x5c) occurs at a 2nd byte of the 2byte character code
and Continuation() cannot recognize if a '\' is one ASCII character or
a 2nd byte of the 2byte character. 

If '\' is a 2nd byte char., we have to treat it as a (part of) normal
character, not a line-continuation character.

This problem can occur in "coding system = SJIS" and maybe occur in
JIS, KS C5601 (7bit), GB 2312, Big5.

And this is the patch to solve this problem.

*** params.org.c        Sun Dec 12 15:26:56 1999
--- params.c    Mon Dec 13 00:36:48 1999
***************
*** 173,183 ****
     * ------------------------------------------------------------------------ **
     */
    {
    pos--;
    while( (pos >= 0) && isspace(line[pos]) )
       pos--;
  
!   return( ((pos >= 0) && ('\\' == line[pos])) ? pos : -1 );
    } /* Continuation */
  
  
--- 173,196 ----
     * ------------------------------------------------------------------------ **
     */
    {
+   int pos2 = 0;
    pos--;
    while( (pos >= 0) && isspace(line[pos]) )
       pos--;
  
!   /* we should recognize if `\` is part of a multibyte character or not. */
!   while(pos2 <= pos) {
!     size_t skip = 0;
!     skip = skip_multibyte_char(*line);
!     if (skip)
!         pos2 += skip;
!     else if (pos = pos2) {
!         return( ((pos >= 0) && ('\\' == line[pos])) ? pos : -1 );
!     }
!     else 
!         pos2++;
!   }
!   return (-1);
    } /* Continuation */

-----
Motonobu TAKAHASHI                    mailto:monyo at home.monyo.com
                                      http://home.monyo.com/




More information about the samba-technical mailing list