Skip to content

Commit

Permalink
Make C source table data writer cognizant of new ASSIGNED/ASSIGNED16 …
Browse files Browse the repository at this point in the history
…split.
  • Loading branch information
tpn committed Jan 19, 2023
1 parent b7172c7 commit 362573c
Showing 1 changed file with 47 additions and 14 deletions.
61 changes: 47 additions & 14 deletions src/PerfectHash/Chm01FileWorkCSourceTableDataFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ SaveCSourceTableDataFileChm01(
PCHAR Base;
PCHAR Output;
ULONG Value;
USHORT Value16;
ULONG Count;
PULONG Long;
PULONG Seed;
PGRAPH Graph;
PULONG Source;
PUSHORT Source16;
ULONG NumberOfSeeds;
PCSTRING Name;
PCSTRING Upper;
Expand Down Expand Up @@ -69,6 +71,7 @@ SaveCSourceTableDataFileChm01(
Graph = (PGRAPH)Context->SolvedContext;
NumberOfSeeds = Graph->NumberOfSeeds;
Source = Graph->Assigned;
Source16 = Graph->Assigned16;
Output = Base = (PCHAR)File->BaseAddress;

//
Expand Down Expand Up @@ -165,28 +168,58 @@ SaveCSourceTableDataFileChm01(
OUTPUT_INT(TotalNumberOfElements);
OUTPUT_RAW("] = {\n\n //\n // 1st half.\n //\n\n");

for (Index = 0, Count = 0; Index < TotalNumberOfElements; Index++) {
if (!IsUsingAssigned16(Graph)) {

if (Count == 0) {
INDENT();
}
for (Index = 0, Count = 0; Index < TotalNumberOfElements; Index++) {

Value = *Source++;
if (Count == 0) {
INDENT();
}

OUTPUT_HEX(Value);
Value = *Source++;

*Output++ = ',';
OUTPUT_HEX(Value);

if (++Count == 4) {
Count = 0;
*Output++ = '\n';
} else {
*Output++ = ' ';
*Output++ = ',';

if (++Count == 4) {
Count = 0;
*Output++ = '\n';
} else {
*Output++ = ' ';
}

if (Index == NumberOfElements-1) {
OUTPUT_RAW("\n //\n // 2nd half.\n //\n\n");
}
}

if (Index == NumberOfElements-1) {
OUTPUT_RAW("\n //\n // 2nd half.\n //\n\n");
} else {

for (Index = 0, Count = 0; Index < TotalNumberOfElements; Index++) {

if (Count == 0) {
INDENT();
}

Value16 = *Source16++;

OUTPUT_HEX(Value16);

*Output++ = ',';

if (++Count == 4) {
Count = 0;
*Output++ = '\n';
} else {
*Output++ = ' ';
}

if (Index == NumberOfElements-1) {
OUTPUT_RAW("\n //\n // 2nd half.\n //\n\n");
}
}

}

//
Expand Down

0 comments on commit 362573c

Please sign in to comment.