shithub: pprolog

Download patch

ref: 77c7fea4cee74562ad60c7ce96ca830a7ebda8b7
parent: 2bda2a9d61ff3c713beff623aceea143d0f814c6
author: Peter Mikkelsen <[email protected]>
date: Thu Jul 22 15:18:33 EDT 2021

Use addgoals to add the goal in catch/3 to the goalstack, allowing mod:pred goals too

--- a/builtins.c
+++ b/builtins.c
@@ -622,13 +622,7 @@
 	catchframe->next = goalstack;
 	goalstack = catchframe;
 
-	Goal *g = gmalloc(sizeof(Goal));
-	g->goal = catchgoal;
-	g->module = module;
-	g->catcher = nil;
-	g->next = goalstack;
-	goalstack = g;
-
+	goalstack = addgoals(goalstack, catchgoal, module);
 	return 1;
 }
 
--- a/loader.pl
+++ b/loader.pl
@@ -21,7 +21,7 @@
 
 run_initialization_goals(Module) :-
 	( retract(initialization_goals(Module, Goal)),
-	  Module:catch(Goal, E, loader:print_initialization_goal_error(Module, Goal, E)),
+	  catch(Module:Goal, E, print_initialization_goal_error(Module, Goal, E)),
 	  fail % Backtrack to find more goals
 	; true
 	).