Browse Source

* give an error message when including a file starting with an UTF-8 BOM
in a compilation module parsed using a different code page, because this
changes the default ansistring type and {$codepage xxx} is also not
allowed in the middle of a unit (mantis #21445)

git-svn-id: trunk@20488 -

Jonas Maebe 13 years ago
parent
commit
a6a43c71ec
4 changed files with 481 additions and 475 deletions
  1. 4 1
      compiler/msg/errore.msg
  2. 3 2
      compiler/msgidx.inc
  3. 467 472
      compiler/msgtxt.inc
  4. 7 0
      compiler/scanner.pas

+ 4 - 1
compiler/msg/errore.msg

@@ -135,7 +135,7 @@ general_f_oserror=01025_F_Operating system error: $1
 #
 # Scanner
 #
-# 02087 is the last used one
+# 02089 is the last used one
 #
 % \section{Scanner messages.}
 % This section lists the messages that the scanner emits. The scanner takes
@@ -374,6 +374,9 @@ scanner_w_illegal_warn_identifier=02087_W_Illegal identifier "$1" for $WARN dire
 scanner_e_illegal_alignment_directive=02088_E_Illegal alignment directive
 % The alignment directive is not valid. Either the alignment type is not known or the alignment
 % value is not a power of two.
+scanner_f_illegal_utf8_bom=02089_F_It is not possible to include a file that starts with an UTF-8 BOM in a module that uses a different code page
+% All source code that is part of a single compilation entity (program, library, unit) must be encoded
+% in the same code page
 % \end{description}
 #
 # Parser

+ 3 - 2
compiler/msgidx.inc

@@ -110,6 +110,7 @@ const
   scan_w_multiple_main_name_overrides=02086;
   scanner_w_illegal_warn_identifier=02087;
   scanner_e_illegal_alignment_directive=02088;
+  scanner_f_illegal_utf8_bom=02089;
   parser_e_syntax_error=03000;
   parser_e_dont_nest_interrupt=03004;
   parser_w_proc_directive_ignored=03005;
@@ -918,9 +919,9 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 62138;
+  MsgTxtSize = 62257;
 
   MsgIdxMax : array[1..20] of longint=(
-    26,89,315,109,85,55,116,26,202,63,
+    26,90,315,109,85,55,116,26,202,63,
     50,20,1,1,1,1,1,1,1,1
   );

File diff suppressed because it is too large
+ 467 - 472
compiler/msgtxt.inc


+ 7 - 0
compiler/scanner.pas

@@ -2657,6 +2657,13 @@ In case not, the value returned can be arbitrary.
                      (ord((inputpointer+1)^)=$bb) and
                      (ord((inputpointer+2)^)=$bf) then
                      begin
+                       (* we don't support including files with an UTF-8 bom
+                          inside another file that wasn't encoded as UTF-8
+                          already (we don't support {$codepage xxx} switches in
+                          the middle of a file either) *)
+                       if (current_settings.sourcecodepage<>CP_UTF8) and
+                          not current_module.in_global then
+                         Message(scanner_f_illegal_utf8_bom);
                        inc(inputpointer,3);
                        message(scan_c_switching_to_utf8);
                        current_settings.sourcecodepage:=CP_UTF8;

Some files were not shown because too many files changed in this diff