Browse Source

* also allow 'cpXXXX' in addition to 'CPXXXX' code page names (mantis #15169)

git-svn-id: trunk@26148 -
Jonas Maebe 11 years ago
parent
commit
cddc31a1a8
3 changed files with 21 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 10 0
      rtl/unix/unixcp.pp
  3. 10 0
      tests/tw15169.pp

+ 1 - 0
.gitattributes

@@ -12314,6 +12314,7 @@ tests/tstunits/Makefile.fpc svneol=native#text/plain
 tests/tstunits/erroru.pp svneol=native#text/plain
 tests/tstunits/popuperr.pp svneol=native#text/plain
 tests/tstunits/win32err.pp svneol=native#text/plain
+tests/tw15169.pp svneol=native#text/plain
 tests/utils/Makefile svneol=native#text/plain
 tests/utils/Makefile.fpc svneol=native#text/plain
 tests/utils/avx/asmtestgenerator.pas svneol=native#text/plain

+ 10 - 0
rtl/unix/unixcp.pp

@@ -681,6 +681,16 @@ begin
     ansistring (encoding names are always ascii) }
   SetCodePage(cpname,$ffff,false);
 
+  { Linux uses cpXXXX instead of CPXXXX }
+  if (length(cpname)>2) and
+     (cpname[1]='c') and
+     (cpname[2]='p') and
+     (cpname[3] in ['0'..'9']) then
+    begin
+      cpname[1]:='C';
+      cpname[2]:='P';
+    end;
+
   { simple linear scan, not a common operation and hence not worth
     building a separate array for -- start from index 1 rather than
     0, because 0 = fake "code page 0" that maps to UTF-8 as default

+ 10 - 0
tests/tw15169.pp

@@ -0,0 +1,10 @@
+{ %platform=darwin,linux,freebsd,openbsd,netbsd,solaris }
+
+uses
+  unixcp;
+begin
+  if GetCodepageByName('cp1250')<>1250 then
+    halt(1);
+  if GetCodepageByName('CP1250')<>1250 then
+    halt(2);
+end.