mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 05:22:59 +01:00 
			
		
		
		
	* fixed previous commit
git-svn-id: trunk@3949 -
This commit is contained in:
		
							parent
							
								
									f32b1ccbe0
								
							
						
					
					
						commit
						e92cc059a7
					
				@ -126,13 +126,13 @@ procedure Wide2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt);
 | 
			
		||||
    destpos: pchar;
 | 
			
		||||
    mynil : pchar;
 | 
			
		||||
    my0 : size_t;
 | 
			
		||||
    iconv : iconv_t;
 | 
			
		||||
    conv : iconv_t;
 | 
			
		||||
  begin
 | 
			
		||||
    { conversion descriptors aren't thread safe }
 | 
			
		||||
    if IsMultithreaded then
 | 
			
		||||
      iconv:=iconv_open(nl_langinfo(CODESET),unicode_encoding)
 | 
			
		||||
    if IsMultithread then
 | 
			
		||||
      conv:=iconv_open(nl_langinfo(CODESET),unicode_encoding)
 | 
			
		||||
    else
 | 
			
		||||
      iconv:=iconv_wide2ansi;
 | 
			
		||||
      conv:=iconv_wide2ansi;
 | 
			
		||||
    mynil:=nil;
 | 
			
		||||
    my0:=0;
 | 
			
		||||
    { rought estimation }
 | 
			
		||||
@ -142,7 +142,7 @@ procedure Wide2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt);
 | 
			
		||||
    srcpos:=source;
 | 
			
		||||
    destpos:=pchar(dest);
 | 
			
		||||
    outleft:=outlength;
 | 
			
		||||
    while iconv(iconv,@srcpos,@srclen,@destpos,@outleft)=size_t(-1) do
 | 
			
		||||
    while iconv(conv,@srcpos,@srclen,@destpos,@outleft)=size_t(-1) do
 | 
			
		||||
      begin
 | 
			
		||||
        case fpgetCerrno of
 | 
			
		||||
          ESysEILSEQ:
 | 
			
		||||
@ -154,7 +154,7 @@ procedure Wide2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt);
 | 
			
		||||
              inc(destpos);
 | 
			
		||||
              dec(outleft);
 | 
			
		||||
              { reset }
 | 
			
		||||
              iconv(iconv,@mynil,@my0,@mynil,@my0);
 | 
			
		||||
              iconv(conv,@mynil,@my0,@mynil,@my0);
 | 
			
		||||
            end;
 | 
			
		||||
          ESysE2BIG:
 | 
			
		||||
            begin
 | 
			
		||||
@ -172,8 +172,8 @@ procedure Wide2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt);
 | 
			
		||||
      end;
 | 
			
		||||
    // truncate string
 | 
			
		||||
    setlength(dest,length(dest)-outleft);
 | 
			
		||||
    if IsMultithreaded then
 | 
			
		||||
      iconv_close(iconv);
 | 
			
		||||
    if IsMultithread then
 | 
			
		||||
      iconv_close(conv);
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -186,13 +186,13 @@ procedure Ansi2WideMove(source:pchar;var dest:widestring;len:SizeInt);
 | 
			
		||||
    destpos: pchar;
 | 
			
		||||
    mynil : pchar;
 | 
			
		||||
    my0 : size_t;
 | 
			
		||||
    iconv : iconv_t;
 | 
			
		||||
    conv : iconv_t;
 | 
			
		||||
  begin
 | 
			
		||||
    { conversion descriptors aren't thread safe }
 | 
			
		||||
    if IsMultithreaded then
 | 
			
		||||
      iconv:=iconv_open(unicode_encoding,nl_langinfo(CODESET));
 | 
			
		||||
    if IsMultithread then
 | 
			
		||||
      conv:=iconv_open(unicode_encoding,nl_langinfo(CODESET))
 | 
			
		||||
    else
 | 
			
		||||
      iconv:=iconv_ansi2wide;
 | 
			
		||||
      conv:=iconv_ansi2wide;
 | 
			
		||||
    mynil:=nil;
 | 
			
		||||
    my0:=0;
 | 
			
		||||
    // extra space
 | 
			
		||||
@ -202,7 +202,7 @@ procedure Ansi2WideMove(source:pchar;var dest:widestring;len:SizeInt);
 | 
			
		||||
    srcpos:=source;
 | 
			
		||||
    destpos:=pchar(dest);
 | 
			
		||||
    outleft:=outlength*2;
 | 
			
		||||
    while iconv(iconv,@srcpos,@len,@destpos,@outleft)=size_t(-1) do
 | 
			
		||||
    while iconv(conv,@srcpos,@len,@destpos,@outleft)=size_t(-1) do
 | 
			
		||||
      begin
 | 
			
		||||
        case fpgetCerrno of
 | 
			
		||||
         ESysEILSEQ:
 | 
			
		||||
@ -213,7 +213,7 @@ procedure Ansi2WideMove(source:pchar;var dest:widestring;len:SizeInt);
 | 
			
		||||
              inc(destpos,2);
 | 
			
		||||
              dec(outleft,2);
 | 
			
		||||
              { reset }
 | 
			
		||||
              iconv(iconv,@mynil,@my0,@mynil,@my0);
 | 
			
		||||
              iconv(conv,@mynil,@my0,@mynil,@my0);
 | 
			
		||||
            end;
 | 
			
		||||
          ESysE2BIG:
 | 
			
		||||
            begin
 | 
			
		||||
@ -231,8 +231,8 @@ procedure Ansi2WideMove(source:pchar;var dest:widestring;len:SizeInt);
 | 
			
		||||
      end;
 | 
			
		||||
    // truncate string
 | 
			
		||||
    setlength(dest,length(dest)-outleft div 2);
 | 
			
		||||
    if IsMultithreaded then
 | 
			
		||||
      iconv_close(iconv);
 | 
			
		||||
    if IsMultithread then
 | 
			
		||||
      iconv_close(conv);
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -265,13 +265,13 @@ procedure Ansi2UCS4Move(source:pchar;var dest:UCS4String;len:SizeInt);
 | 
			
		||||
    destpos: pchar;
 | 
			
		||||
    mynil : pchar;
 | 
			
		||||
    my0 : size_t;
 | 
			
		||||
    iconv : iconv_t;
 | 
			
		||||
    conv : iconv_t;
 | 
			
		||||
  begin
 | 
			
		||||
    { conversion descriptors aren't thread safe }
 | 
			
		||||
    if IsMultithreaded then
 | 
			
		||||
      iconv:=iconv_open('UCS4',nl_langinfo(CODESET));
 | 
			
		||||
    if IsMultithread then
 | 
			
		||||
      conv:=iconv_open('UCS4',nl_langinfo(CODESET))
 | 
			
		||||
    else
 | 
			
		||||
      iconv:=iconv_ansi2ucs4;
 | 
			
		||||
      conv:=iconv_ansi2ucs4;
 | 
			
		||||
    mynil:=nil;
 | 
			
		||||
    my0:=0;
 | 
			
		||||
    // extra space
 | 
			
		||||
@ -281,7 +281,7 @@ procedure Ansi2UCS4Move(source:pchar;var dest:UCS4String;len:SizeInt);
 | 
			
		||||
    srcpos:=source;
 | 
			
		||||
    destpos:=pchar(dest);
 | 
			
		||||
    outleft:=outlength*4;
 | 
			
		||||
    while iconv(iconv,@srcpos,@len,@destpos,@outleft)=size_t(-1) do
 | 
			
		||||
    while iconv(conv,@srcpos,@len,@destpos,@outleft)=size_t(-1) do
 | 
			
		||||
      begin
 | 
			
		||||
        case fpgetCerrno of
 | 
			
		||||
          ESysE2BIG:
 | 
			
		||||
@ -300,8 +300,8 @@ procedure Ansi2UCS4Move(source:pchar;var dest:UCS4String;len:SizeInt);
 | 
			
		||||
      end;
 | 
			
		||||
    // truncate string
 | 
			
		||||
    setlength(dest,length(dest)-outleft div 4);
 | 
			
		||||
    if IsMultithreaded then
 | 
			
		||||
      iconv_close(iconv);
 | 
			
		||||
    if IsMultithread then
 | 
			
		||||
      iconv_close(conv);
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user