Browse Source

fcl-res: fix LANGUAGE attribute

Reintegrate fpcres-rc branch by Martok

git-svn-id: trunk@46385 -
svenbarth 5 years ago
parent
commit
8008f314b1

+ 1 - 1
packages/fcl-res/src/rcparser.pas

@@ -266,7 +266,7 @@ begin
          yyval := yyv[yysp-1];
          yyval := yyv[yysp-1];
        end;
        end;
   63 : begin
   63 : begin
-         aktresource.LangID:= MakeLangID(yyv[yysp-2].yyrcnumtype.v, yyv[yysp-0].yyrcnumtype.v); 
+         change_lang_id(MakeLangID(yyv[yysp-2].yyrcnumtype.v, yyv[yysp-0].yyrcnumtype.v)); 
        end;
        end;
   64 : begin
   64 : begin
          aktresource.Characteristics:= yyv[yysp-0].yyrcnumtype.v; 
          aktresource.Characteristics:= yyv[yysp-0].yyrcnumtype.v; 

+ 1 - 1
packages/fcl-res/src/rcparser.y

@@ -145,7 +145,7 @@ suboptions
     ;
     ;
 
 
 suboption
 suboption
-    : _LANGUAGE numpos ',' numpos                  { aktresource.LangID:= MakeLangID($2.v, $4.v); }
+    : _LANGUAGE numpos ',' numpos                  { change_lang_id(MakeLangID($2.v, $4.v)); }
     | _CHARACTERISTICS numpos                      { aktresource.Characteristics:= $2.v; }
     | _CHARACTERISTICS numpos                      { aktresource.Characteristics:= $2.v; }
     | _VERSION numpos                              { aktresource.Version:= $2.v; }
     | _VERSION numpos                              { aktresource.Version:= $2.v; }
     | _MOVEABLE                                    { aktresource.MemoryFlags:= aktresource.MemoryFlags or MF_MOVEABLE; }
     | _MOVEABLE                                    { aktresource.MemoryFlags:= aktresource.MemoryFlags or MF_MOVEABLE; }

+ 8 - 0
packages/fcl-res/src/rcparserfn.inc

@@ -295,6 +295,14 @@ begin
   create_resource(aId, nil, cls);
   create_resource(aId, nil, cls);
 end;
 end;
 
 
+procedure change_lang_id(newlang: TLangID);
+begin
+  // cannot change a language id while it is contained in a list, so remove and re-add
+  aktresources.Remove(aktresource);
+  aktresource.LangID:= newlang;
+  aktresources.Add(aktresource);
+end;
+
 procedure raw_write_string(Stream: TMemoryStream; str: rcstrtype);
 procedure raw_write_string(Stream: TMemoryStream; str: rcstrtype);
 var
 var
   i: integer;
   i: integer;