From d94fb9f7d23aaab326139cdbcc8bd063930c9d05 Mon Sep 17 00:00:00 2001
From: Etienne Brateau <etienne.brateau@ensiie.fr>
Date: Wed, 23 Jan 2019 22:10:43 +0100
Subject: [PATCH] chpage: change parameter type to log_page

---
 include/log_action.h |  2 +-
 include/page.h       |  2 +-
 src/log.c            | 16 ++++++++--------
 src/page.c           |  8 ++++----
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/log_action.h b/include/log_action.h
index 887727a..4467ffa 100644
--- a/include/log_action.h
+++ b/include/log_action.h
@@ -114,7 +114,7 @@ typedef struct log_hooks_t
 	void (*enderror) ();
 	void (*redraw) ();   /*redraw drawing area*/
 	void (*redrawscreen) ();   /*redraw entire screen*/
-	void (*change) (int pg);
+	void (*change) (log_page *page);
 	void (*newgate) (log_grec **g, int gt);
 	void (*copygate) (log_grec *old, log_grec **g);
 	void (*disposegate) (log_grec **g);
diff --git a/include/page.h b/include/page.h
index 8b818bb..102cc17 100644
--- a/include/page.h
+++ b/include/page.h
@@ -26,7 +26,7 @@ typedef struct log_page {
 	int pagechanged;
 } log_page;
 
-void chpage(short pg);
+void chpage(log_page *page);
 
 void chpageplace(short pg, short x1, short y1, short x2, short y2);
 
diff --git a/src/log.c b/src/log.c
index d830402..7be162c 100644
--- a/src/log.c
+++ b/src/log.c
@@ -5147,7 +5147,7 @@ static void openhoriz()
 
 			if (gg.incircuit && *gg.func == '\0')
 			{
-				chpage((int)gg.curpage);
+				chpage(gg.pages[gg.curpage]);
 				vw = gg.pages[gg.curpage - 1]->vwbase;
 				flag = false;
 				while (vw != NULL)
@@ -5316,7 +5316,7 @@ static void openvert()
 			remcursor();
 			if (gg.incircuit && *gg.func == '\0')
 			{
-				chpage((int)gg.curpage);
+				chpage(gg.pages[gg.curpage]);
 				hw = gg.pages[gg.curpage - 1]->hwbase;
 				flag = false;
 
@@ -5484,7 +5484,7 @@ static void closehoriz()
 			remcursor();
 			if (gg.incircuit && *gg.func == '\0')
 			{
-				chpage((int)gg.curpage);
+				chpage(gg.pages[gg.curpage]);
 				vw = gg.pages[gg.curpage - 1]->vwbase;
 				flag = false;
 				while (vw != NULL)
@@ -5728,7 +5728,7 @@ static void closevert()
 			remcursor();
 			if (gg.incircuit && *gg.func == '\0')
 			{
-				chpage((int)gg.curpage);
+				chpage(gg.pages[gg.curpage]);
 				hw = gg.pages[gg.curpage - 1]->hwbase;
 				flag = false;
 				while (hw != NULL)
@@ -8182,7 +8182,7 @@ end;  */
 						}
 					}
 					stamp(attrstamp);
-					chpage((int)gg.curpage);
+					chpage(gg.pages[gg.curpage]);
 				}
 				else if (ch == '\b')
 				{
@@ -8272,7 +8272,7 @@ end;  */
 						}
 					}
 					stamp(attrstamp);
-					chpage((int)gg.curpage);
+					chpage(gg.pages[gg.curpage]);
 				}
 				else
 				{
@@ -8520,7 +8520,7 @@ end;  */
 						break;
 				}
 				stamp(attrstamp);
-				chpage((int)gg.curpage);
+				chpage(gg.pages[gg.curpage]);
 				drawvalue(V.p, false, &V);
 			}
 		} while (!exitflag);
@@ -8914,7 +8914,7 @@ static void setgattr(log_grec *g, short num, char *value_)
 				g1 = g1->next;
 		}
 		if (g1 != NULL)
-			chpage(pg);
+			chpage(gg.pages[pg]);
 	}
 	gg.acttool = saveacttool;
 }
diff --git a/src/page.c b/src/page.c
index df219aa..8ac31da 100644
--- a/src/page.c
+++ b/src/page.c
@@ -6,13 +6,13 @@
 #include "utils.h"
 #include "page.h"
 
-void chpage(short pg)
+void chpage(log_page *page)
 {
 	log_regrec *region;
 
-	stamp(&gg.pages[pg - 1]->pagestamp);
-	gg.pages[pg - 1]->pagechanged = true;
-	region = gg.pages[pg - 1]->pageregions;
+	stamp(&page->pagestamp);
+	page->pagechanged = true;
+	region = page->pageregions;
 	while (region != NULL)
 	{
 		stamp(&region->regstamp);
-- 
GitLab