Explorar o código

+ Use __setlocale_mb_len_max_32 for netbsd as suggested by linker warning

git-svn-id: trunk@23696 -
pierre %!s(int64=12) %!d(string=hai) anos
pai
achega
f4b6625145
Modificáronse 2 ficheiros con 27 adicións e 4 borrados
  1. 7 1
      rtl/unix/clocale.pp
  2. 20 3
      rtl/unix/cwstring.pp

+ 7 - 1
rtl/unix/clocale.pp

@@ -88,8 +88,14 @@ Const
  _NL_MONETARY_CRNCYSTR = (__INT_CURR_SYMBOL)+15;
  {$endif}
 
-
+{$ifdef netbsd}
+  { NetBSD has a new setlocale function defined in /usr/include/locale.h
+    that should be used }
+function setlocale(category: cint; locale: pchar): pchar; cdecl; external clib name '__setlocale_mb_len_max_32';
+{$else}
 function setlocale(category: cint; locale: pchar): pchar; cdecl; external clib name 'setlocale';
+{$endif}
+
 function nl_langinfo(__item: cint):Pchar;cdecl;external clib name 'nl_langinfo';
 
 procedure GetFormatSettings(out fmts: TFormatSettings);

+ 20 - 3
rtl/unix/cwstring.pp

@@ -27,14 +27,25 @@ implementation
 
 {$linklib c}
 
-{$if not defined(linux) and not defined(solaris)}  // Linux (and maybe glibc platforms in general), have iconv in glibc.
+// Linux (and maybe glibc platforms in general), have iconv in glibc.
+{$if defined(linux) or defined(solaris)}
+  {$define iconv_is_in_libc}
+{$endif}
+
+{$ifdef netbsd}
+  {$ifdef TEST_ICONV_LIBC}
+    {$define iconv_is_in_libc}
+  {$endif}
+{$endif}
+
+{$ifndef iconv_is_in_libc}
  {$if defined(haiku)}
    {$linklib textencoding}
  {$else}
    {$linklib iconv}
  {$endif}
  {$define useiconv}
-{$endif linux}
+{$endif not iconv_is_in_libc}
 
 Uses
   BaseUnix,
@@ -70,7 +81,13 @@ function towupper(__wc:wint_t):wint_t;cdecl;external clib name 'towupper';
 
 function wcscoll (__s1:pwchar_t; __s2:pwchar_t):cint;cdecl;external clib name 'wcscoll';
 function strcoll (__s1:pchar; __s2:pchar):cint;cdecl;external clib name 'strcoll';
+{$ifdef netbsd}
+  { NetBSD has a new setlocale function defined in /usr/include/locale.h
+    that should be used }
+function setlocale(category: cint; locale: pchar): pchar; cdecl; external clib name '__setlocale_mb_len_max_32';
+{$else}
 function setlocale(category: cint; locale: pchar): pchar; cdecl; external clib name 'setlocale';
+{$endif}
 {$ifndef beos}
 function mbrtowc(pwc: pwchar_t; const s: pchar; n: size_t; ps: pmbstate_t): size_t; cdecl; external clib name 'mbrtowc';
 function wcrtomb(s: pchar; wc: wchar_t; ps: pmbstate_t): size_t; cdecl; external clib name 'wcrtomb';
@@ -169,7 +186,7 @@ type
   {$endif}
 {$endif}
 
-{$if (not defined(bsd) and not defined(beos)) or (defined(darwin) and not defined(cpupowerpc32))}
+{$if (not defined(bsd) and not defined(beos)) or defined(iconv_is_in_libc) or (defined(darwin) and not defined(cpupowerpc32))}
 function iconv_open(__tocode:pchar; __fromcode:pchar):iconv_t;cdecl;external libiconvname name 'iconv_open';
 function iconv(__cd:iconv_t; __inbuf:ppchar; __inbytesleft:psize_t; __outbuf:ppchar; __outbytesleft:psize_t):size_t;cdecl;external libiconvname name 'iconv';
 function iconv_close(__cd:iconv_t):cint;cdecl;external libiconvname name 'iconv_close';