Browse Source

fcl-db/dbase: cosmetic: reorganize struct comments so they show up browsing code

git-svn-id: trunk@24279 -
reiniero 12 years ago
parent
commit
3e2cedaf59
2 changed files with 19 additions and 51 deletions
  1. 14 46
      packages/fcl-db/src/dbase/dbf_lang.pas
  2. 5 5
      packages/fcl-db/src/dbase/dbf_struct.inc

+ 14 - 46
packages/fcl-db/src/dbase/dbf_lang.pas

@@ -123,7 +123,7 @@ const
   DbfLocale_Bul868     = $020000;
 
 //*************************************************************************//
-// DB3/DB4/FoxPro/Visual Foxpro Language ID to CodePage conversion table
+// DB3/DB4/FoxPro Language ID to CodePage conversion table
 // Visual FoxPro docs call language ID "code page mark"
 // or "code page identifier"
 //*************************************************************************//
@@ -165,6 +165,7 @@ const
 {F0}       0,    0,    0,    0,    0,    0,    0,    0,
 {F8}       0,    0,    0,    0,    0,    0,    0,    0);
 
+
 {$ifdef FPC_VERSION}
 {$ifdef VER1_0}
   LANG_ARABIC                          = $01;
@@ -469,6 +470,7 @@ const
 // reverse convert routines
 //*************************************************************************//
 
+// Visual DBaseVII specific; the IsFoxPro means a FoxPro codepage, which DB7 supports
 function ConstructLangName(CodePage: Integer; Locale: LCID; IsFoxPro: Boolean): string;
 
 function ConstructLangId(CodePage: Integer; Locale: LCID; IsFoxPro: Boolean): Byte;
@@ -521,7 +523,7 @@ begin
 end;
 
 const
-  // range of Dbase locales; these are INCLUSIVE (the rest are FoxPro?)
+  // range of Dbase locales; these are INCLUSIVE (the rest are FoxPro)
   dBase_RegionCount = 4;
   dBase_Regions: array[0..dBase_RegionCount*2-1] of Byte =
    ($00, $00,
@@ -529,9 +531,8 @@ const
     $69, $69, // a lonely dbf entry :-)
     $80, $90);
 
-function FindLangId(CodePage, Info2: Cardinal; Info2Table: PCardinal; IsFoxPro: Boolean): Byte;
-// Info2: desired locale
-// Info2Table: pointer to lookup array: language ID=>locale cardinal
+function FindLangId(CodePage, DesiredLocale: Cardinal; LanguageIDToLocaleTable: PCardinal; IsFoxPro: Boolean): Byte;
+// DesiredLocale: pointer to lookup array: language ID=>locale
 var
   LangID, Region, FoxRes, DbfRes: Integer;
 begin
@@ -549,7 +550,7 @@ begin
     // what a mess :-(
     //todo: verify this for visual foxpro; we never seem to get a result
     if ((LangId_To_CodePage[LangID] = CodePage) or (CodePage = 0)) and
-      (PCardinal(PChar(Info2Table)+(LangID*4))^ = Info2) then
+      (PCardinal(PChar(LanguageIDToLocaleTable)+(LangID*4))^ = DesiredLocale) then
       if LangID <= dBase_Regions[Region+1] then
         DbfRes := Byte(LangID)
       else
@@ -557,7 +558,7 @@ begin
   end;
   // if we can find langid in other set, use it
   if (DbfRes <> 0) and (not IsFoxPro or (FoxRes = 0)) then
-    Result := DbfRes //if not using foxpro
+    Result := DbfRes //... not using foxpro
   else  {(DbfRes = 0) or (IsFoxPro and (FoxRes <> 0)}
   if (FoxRes <> 0) {and (IsFoxPro or (DbfRes = 0)} then
     Result := FoxRes
@@ -565,45 +566,6 @@ begin
     Result := 0;
 end;
 
-{
-function FindLangId(CodePage, Info2: Cardinal; Info2Table: PCardinal; IsFoxPro: Boolean): Byte;
-var
-  I, Region, lEnd: Integer;
-  EndReached: Boolean;
-begin
-  Region := 0;
-  Result := 0;
-  repeat
-    // determine region to scan
-    if IsFoxPro then
-    begin
-      // foxpro, in between dbase regions
-      I := dBase_Regions[Region+1] + 1;
-      lEnd := dBase_Regions[Region+2] - 1;
-      EndReached := Region = dBase_RegionCount*2-4;
-    end else begin
-      // dBase, select regions
-      I := dBase_Regions[Region];
-      lEnd := dBase_Regions[Region+1];
-      EndReached := Region = dBase_RegionCount*2-2;
-    end;
-    // scan
-    repeat
-      // it seems delphi does not properly understand pointers?
-      // what a mess :-(
-      if (LangId_To_CodePage[I] = CodePage) and (PCardinal(PChar(Info2Table)+(I*4))^ = Info2) then
-        Result := Byte(I);
-      Inc(I);
-      // lEnd is included in range
-    until (Result <> 0) or (I > lEnd);
-    // goto next region
-    if (Result = 0) then
-      Inc(Region, 2);
-    // found or end?
-  until (Result <> 0) or EndReached;
-end;
-}
-
 function ConstructLangId(CodePage: Integer; Locale: LCID; IsFoxPro: Boolean): Byte;
 begin
   // locale: lower 16bits only, with default sorting
@@ -639,6 +601,12 @@ begin
   else
     CodePage := StrToInt(CodePageStr);
   // find lang id
+  //todo: debug, remove
+  writeln('');
+  writeln('getlangid_fromLangName');
+  writeln('codepagestr ',codepagestr);
+  writeln('subtype: ',subtype);
+  writeln('codepage: ',codepage);
   Result := FindLangId(CodePage, SubType, @LangId_To_LocaleStr[0], IsFoxPro);
 end;
 

+ 5 - 5
packages/fcl-db/src/dbase/dbf_struct.inc

@@ -31,10 +31,10 @@ type
     MultiUse    : Integer;  // 16-19
     LastUserID  : Integer;  // 20-23
     Dummy2      : array[24..27] of Byte;
-    MDXFlag     : Byte;     // 28 Flags:
     // $01: mdx (or cdx for VFP) index file present
     // $02: (Visual FoxPro): associated memo file?
     // $04: (Visual FoxPro): is this a dbc/database container
+    MDXFlag     : Byte;     // 28 Flags:
     Language    : Byte;     // 29 code page mark
     Dummy3      : Word;     // 30-31
   end;
@@ -59,25 +59,25 @@ type
     FieldOffset       : Integer; // 12..15
     FieldSize         : Byte;    // 16
     FieldPrecision    : Byte;    // 17, also known as decimal count
-    VisualFoxProFlags : Byte;    // 18 Field Flags; flags can be combined
     // $01: system solumn (not user-visible)
     // $02: column can store null values
     // $04: binary column, e.g. don't interpret codepage (char/memo fields)
     // $0C: column is autoincrementing (only integer fields)
-    AutoIncrementNext : Byte;    // 19 VFP only: autoincrement value
+    VisualFoxProFlags : Byte;    // 18 Field Flags; flags can be combined
     // (!!not the next value for a new record!!); the next is calculated by
     // adding AutoIncrementStep first.
     // Value covers bytes 19..22 (so no WorkAreaID,Reserved1 for VFP)
-    WorkAreaID        : Byte;    // 20
+    AutoIncrementNext : Byte;    // 19 VFP only: autoincrement value
     // WorkAreaID only for DBase III, is always $01
+    WorkAreaID        : Byte;    // 20
     Reserved1         : array[21..22] of Byte;
     AutoIncrementStep : Byte;    // 23 VFP only: step value for autoincrement
     Reserved2         : array[24..30] of Byte;
-    MDXIndexField     : Byte;    //31
     // DBase IV:
     // $00: no key for this field;
     // $01: key exists for this field in MDX index file
     // todo: implement this??
+    MDXIndexField     : Byte;    //31
   end;
 //====================================================================
 // OH 2000-11-15 dBase7 support. Header Update (add fields like Next AutoInc Value)