summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makefile8
-rw-r--r--obj/.gitignore (renamed from build/.gitignore)0
-rw-r--r--readme.txt10
-rw-r--r--src/bundles-containers.adb7
-rw-r--r--src/election.adb12
-rw-r--r--src/preferences.adb2
-rw-r--r--src/stv.adb12
-rw-r--r--stv.gpr2
8 files changed, 25 insertions, 28 deletions
diff --git a/makefile b/makefile
deleted file mode 100644
index fc27148..0000000
--- a/makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-all: stv
-
-
-stv:
- gnatmake src/stv.adb -Isrc -D build -o bin/stv
-
diff --git a/build/.gitignore b/obj/.gitignore
index fc50a55..fc50a55 100644
--- a/build/.gitignore
+++ b/obj/.gitignore
diff --git a/readme.txt b/readme.txt
index 74ddcbc..69e8090 100644
--- a/readme.txt
+++ b/readme.txt
@@ -7,16 +7,12 @@ algorithm on it to calculate election outcomes.
To compile this program, the following dependencies are needed:
- gnat (of course)
- gnu make
- gmp
+ GNAT
+ GMP
-Note however that make isn't strictly necessary if you have a look in the
-makefile to see the compilation commands required.
-
-Compilation is done by 'make all'. Further instruction on how to use this
+Compilation is done by 'gprbuild stv.gpr'. Further instruction on how to use this
program can be obtained from the '--help' switch, once compiled.
diff --git a/src/bundles-containers.adb b/src/bundles-containers.adb
index 1e566fa..a3e2ef0 100644
--- a/src/bundles-containers.adb
+++ b/src/bundles-containers.adb
@@ -65,8 +65,11 @@ package body Bundles.Containers is
while not End_Of_File (Input_File) loop
Current_Record := My_CSV.Parse_Line (Get_Line (Input_File));
if Integer (Current_Record.Length) > 0 then
- Current_Prefs := Given_Prefs.Parse_Preferences (SU.To_String (Current_Record.Last_Element));
- if Current_Prefs (Given_Prefs.Preference_Range'First) /= Candidates.No_Candidate then
+ Current_Prefs := Given_Prefs.Parse_Preferences
+ (SU.To_String (Current_Record.Last_Element));
+ if Current_Prefs (Given_Prefs.Preference_Range'First) /=
+ Candidates.No_Candidate
+ then
Add_To_Map (Result, Current_Prefs);
end if;
end if;
diff --git a/src/election.adb b/src/election.adb
index 181da64..6a7892f 100644
--- a/src/election.adb
+++ b/src/election.adb
@@ -467,7 +467,8 @@ package body Election is
Fractional_Loss => Fractional_Loss,
Exhausted_Loss => Exhausted_Loss);
- Pref_Data.Reference (This_Transfer.From).Delete (Pref_Data.Reference (This_Transfer.From).First_Index);
+ Pref_Data.Reference (This_Transfer.From).Delete
+ (Pref_Data.Reference (This_Transfer.From).First_Index);
Fractional.Paper_Change := Fractional.Paper_Change + Fractional_Loss;
Exhausted.Paper_Change := Exhausted.Paper_Change + Exhausted_Loss;
@@ -478,13 +479,13 @@ package body Election is
Entry_Ref : Entry_Vectors.Reference_Type :=
Entries.Reference (This_Transfer.Position);
begin
- Entry_Ref.Paper_Change := - Entry_Ref.Total_Papers;
+ Entry_Ref.Paper_Change := -Entry_Ref.Total_Papers;
Entry_Ref.Total_Papers := 0;
if Entry_Ref.Status = Elected then
Entry_Ref.Vote_Change := Quota - Entry_Ref.Total_Votes;
Entry_Ref.Total_Votes := Quota;
else
- Entry_Ref.Vote_Change := - Entry_Ref.Total_Votes;
+ Entry_Ref.Vote_Change := -Entry_Ref.Total_Votes;
Entry_Ref.Total_Votes := 0;
end if;
end;
@@ -557,14 +558,15 @@ package body Election is
for R in Running.Iterate loop
Votes_To_Be_Excluded := Running.Reference (R).Total_Votes;
- exit when Number_Excluded > 0 and Votes_Excluded + Votes_To_Be_Excluded > Applied_Breakpoint;
+ exit when Number_Excluded > 0 and
+ Votes_Excluded + Votes_To_Be_Excluded > Applied_Breakpoint;
Working_Position := Running.Reference (R).Index;
Working_ID := Entries.Reference (Working_Position).ID;
Entries.Reference (Working_Position).Status := Excluded;
Entries.Reference (Working_Position).Changed := True;
- Transfers.Append ( (From => Working_ID, Position => Working_Position, Value => 1 / 1) );
+ Transfers.Append ((From => Working_ID, Position => Working_Position, Value => 1 / 1));
Votes_Excluded := Votes_Excluded + Votes_To_Be_Excluded;
Number_Excluded := Number_Excluded + 1;
end loop;
diff --git a/src/preferences.adb b/src/preferences.adb
index 36cc5ea..6868042 100644
--- a/src/preferences.adb
+++ b/src/preferences.adb
@@ -63,7 +63,7 @@ package body Preferences is
Pref_Loop :
for I in Above_Range loop
Above_IC (Above_Input, Integer (I), Working_Index, Working_Count);
- exit when Working_Count /= 1;
+ exit Pref_Loop when Working_Count /= 1;
Extracted := Extracted + 1;
for C of Above_Ballot.Element (Integer (Working_Index)) loop
exit Pref_Loop when Formal_Index > Preference_Range'Last;
diff --git a/src/stv.adb b/src/stv.adb
index a83689f..2facffa 100644
--- a/src/stv.adb
+++ b/src/stv.adb
@@ -154,7 +154,8 @@ begin
return;
end if;
if File.Kind (Candidate_File.all) /= File.Ordinary_File then
- Put_Line ("Candidate data file name appears to refer to a directory or special file." & ASCII.LF & Further_Help);
+ Put_Line ("Candidate data file name appears to refer to a directory or special file." &
+ ASCII.LF & Further_Help);
ACom.Set_Exit_Status (ACom.Failure);
return;
end if;
@@ -172,7 +173,8 @@ begin
return;
end if;
if File.Kind (Preference_File.all) /= File.Ordinary_File then
- Put_Line ("Preference data file name appears to refer to a directory or special file." & ASCII.LF & Further_Help);
+ Put_Line ("Preference data file name appears to refer to a directory or special file." &
+ ASCII.LF & Further_Help);
ACom.Set_Exit_Status (ACom.Failure);
return;
end if;
@@ -204,7 +206,8 @@ begin
State := Candidates.State_Name'Value (State_String.all);
exception
when Constraint_Error =>
- Put_Line ("Invalid State/Territory or State/Territory not provided." & ASCII.LF & Further_Help);
+ Put_Line ("Invalid State/Territory or State/Territory not provided." &
+ ASCII.LF & Further_Help);
ACom.Set_Exit_Status (ACom.Failure);
return;
end;
@@ -214,7 +217,8 @@ begin
File.Create_Directory (Output_Dir.all);
Start_Time := Simple_Time.Now;
Main_Log := SU.To_Unbounded_String (Output_Dir.all & "/" & "log.txt");
- Log_Msg := SU.To_Unbounded_String ("Started election count at " & Simple_Time.To_String (Start_Time));
+ Log_Msg := SU.To_Unbounded_String ("Started election count at " &
+ Simple_Time.To_String (Start_Time));
Create (Log_File, Append_File, SU.To_String (Main_Log));
Put_Line (Log_File, SU.To_String (Log_Msg));
Close (Log_File);
diff --git a/stv.gpr b/stv.gpr
index 9f40ed8..dd040f8 100644
--- a/stv.gpr
+++ b/stv.gpr
@@ -7,7 +7,7 @@ project STV is
for Source_Dirs use ("src/**");
- for Object_Dir use "build";
+ for Object_Dir use "obj";
for Exec_Dir use "bin";
for Main use ("stv.adb");