forked from pool/gap-xgap
360 lines
13 KiB
Diff
360 lines
13 KiB
Diff
From cb04e1a6c29359fe48b7cde15290d41e97c1481d Mon Sep 17 00:00:00 2001
|
||
From: Jan Engelhardt <jengelh@inai.de>
|
||
Date: Wed, 18 Jun 2025 20:51:26 +0200
|
||
Subject: [PATCH] Resolve build failure under gcc 15/-std=c23
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
References: https://github.com/gap-packages/xgap/pull/33
|
||
|
||
```
|
||
../../src.x11/gaptext.c: In function ‘DoSelection’:
|
||
../../src.x11/gaptext.c:156:13: error: too many arguments to function ‘gap->gap.input_callback’; expected 0, have 2
|
||
156 | gap->gap.input_callback( buf, 2 );
|
||
../../src.x11/gaptext.h:99:27: note: declared here
|
||
99 | void (*input_callback)();
|
||
../../src.x11/gaptext.c: In function ‘GapTextSelectStart’:
|
||
../../src.x11/gaptext.c:341:25: error: too many arguments to function ‘gap->gap.check_caret_pos’; expected 0, have 2
|
||
341 | newPos = oldPos+gap->gap.check_caret_pos(gap->text.insertPos,oldPos);
|
||
../../src.x11/gaptext.h:102:27: note: declared here
|
||
102 | Int (*check_caret_pos)();
|
||
(and others that are more obvious)
|
||
```
|
||
|
||
It is unclear how x.input_callback and x.check_caret_pos ever get
|
||
assigned. Due to the use of unspecified argument lists previously,
|
||
`check_caret_pos` would be called with arguments of type
|
||
XawTextPosition (which are `long`!) whereas `input_callback` would be
|
||
called with an `int` (which is not so long).
|
||
|
||
It is conceivable that the actual function behind some
|
||
`input_callback` pointer is expecting XawTextPosition and, because
|
||
the function is not getting it, there has been (and continues to do
|
||
with this change) illegal memory access past the end of the
|
||
arguments-on-stack.
|
||
---
|
||
src.x11/gaptext.c | 18 ++++++-------
|
||
src.x11/gaptext.h | 4 +--
|
||
src.x11/pty.c | 2 +-
|
||
src.x11/selfile.c | 34 ++++++++++++------------
|
||
src.x11/xgap.c | 68 +++++++++++++++++++++++------------------------
|
||
src.x11/xgap.h | 2 +-
|
||
6 files changed, 64 insertions(+), 64 deletions(-)
|
||
|
||
diff --git a/src.x11/gaptext.c b/src.x11/gaptext.c
|
||
index acdc800..3179072 100644
|
||
--- a/src.x11/gaptext.c
|
||
+++ b/src.x11/gaptext.c
|
||
@@ -14,11 +14,11 @@
|
||
#include "utils.h"
|
||
#include "gaptext.h"
|
||
|
||
-extern void _XawTextPrepareToUpdate();
|
||
-extern int _XawTextReplace();
|
||
-extern void _XawTextSetScrollBars();
|
||
-extern void _XawTextCheckResize();
|
||
-extern void _XawTextExecuteUpdate();
|
||
+extern void _XawTextPrepareToUpdate(GapTextWidget);
|
||
+extern int _XawTextReplace(GapTextWidget, Int, Int, XawTextBlock *);
|
||
+extern void _XawTextSetScrollBars(GapTextWidget);
|
||
+extern void _XawTextCheckResize(GapTextWidget);
|
||
+extern void _XawTextExecuteUpdate(GapTextWidget);
|
||
|
||
|
||
/****************************************************************************
|
||
@@ -666,7 +666,7 @@ static XawTextPosition GapSrcReadText (
|
||
Widget w,
|
||
XawTextPosition pos,
|
||
XawTextBlock * text,
|
||
- unsigned long length )
|
||
+ int length )
|
||
{
|
||
GapSrcObject src = (GapSrcObject) w;
|
||
|
||
@@ -913,9 +913,9 @@ GapSrcClassRec gapSrcClassRec =
|
||
/* extension */ NULL
|
||
},
|
||
{ /* textSrc_class fields */
|
||
- /* Read */ (XawTextPosition (*)())GapSrcReadText,
|
||
- /* Replace */ (int (*)()) GapSrcReplaceText,
|
||
- /* Scan */ (XawTextPosition (*)()) GapSrcScan,
|
||
+ /* Read */ GapSrcReadText,
|
||
+ /* Replace */ GapSrcReplaceText,
|
||
+ /* Scan */ GapSrcScan,
|
||
/* Search */ XtInheritSearch,
|
||
/* SetSelection */ XtInheritSetSelection,
|
||
/* ConvertSelection */ XtInheritConvertSelection
|
||
diff --git a/src.x11/gaptext.h b/src.x11/gaptext.h
|
||
index 812535f..34a3a3a 100644
|
||
--- a/src.x11/gaptext.h
|
||
+++ b/src.x11/gaptext.h
|
||
@@ -96,10 +96,10 @@ extern GapTextClassRec gapTextClassRec;
|
||
typedef struct
|
||
{
|
||
/* function to call when receiving input */
|
||
- void (*input_callback)();
|
||
+ void (*input_callback)(const char *, int);
|
||
|
||
/* function to position caret */
|
||
- Int (*check_caret_pos)();
|
||
+ Int (*check_caret_pos)(XawTextPosition, XawTextPosition);
|
||
|
||
/* input buffer for unprocessed input */
|
||
String buffer;
|
||
diff --git a/src.x11/pty.c b/src.x11/pty.c
|
||
index 483881d..e914bfb 100644
|
||
--- a/src.x11/pty.c
|
||
+++ b/src.x11/pty.c
|
||
@@ -1272,7 +1272,7 @@ static UInt OpenPty(int * master, int * slave)
|
||
**
|
||
*F StartGapProcess( <name>, <argv> ) . . . start a gap subprocess using ptys
|
||
*/
|
||
-static void GapStatusHasChanged ()
|
||
+static void GapStatusHasChanged (int signo)
|
||
{
|
||
int w;
|
||
|
||
diff --git a/src.x11/selfile.c b/src.x11/selfile.c
|
||
index e8ba10e..32bda81 100644
|
||
--- a/src.x11/selfile.c
|
||
+++ b/src.x11/selfile.c
|
||
@@ -111,28 +111,28 @@ typedef struct {
|
||
} SFDir;
|
||
|
||
static void
|
||
- SFenterList(),
|
||
- SFleaveList(),
|
||
- SFmotionList(),
|
||
- SFbuttonPressList(),
|
||
- SFbuttonReleaseList();
|
||
+ SFenterList(Widget, long, XEnterWindowEvent *),
|
||
+ SFleaveList(Widget, int, XEvent *),
|
||
+ SFmotionList(Widget, int, XMotionEvent *),
|
||
+ SFbuttonPressList(Widget, int, XButtonPressedEvent *),
|
||
+ SFbuttonReleaseList(Widget, int, XButtonReleasedEvent *);
|
||
|
||
static void
|
||
- SFvSliderMovedCallback(),
|
||
- SFvFloatSliderMovedCallback(),
|
||
- SFhSliderMovedCallback(),
|
||
- SFpathSliderMovedCallback(),
|
||
- SFvAreaSelectedCallback(),
|
||
- SFhAreaSelectedCallback(),
|
||
- SFpathAreaSelectedCallback();
|
||
+ SFvSliderMovedCallback(Widget, long, int),
|
||
+ SFvFloatSliderMovedCallback(Widget, int, float *),
|
||
+ SFhSliderMovedCallback(Widget, int, float *),
|
||
+ SFpathSliderMovedCallback(Widget, XtPointer, float *),
|
||
+ SFvAreaSelectedCallback(Widget, int, int),
|
||
+ SFhAreaSelectedCallback(Widget, int, int),
|
||
+ SFpathAreaSelectedCallback(Widget, XtPointer, int);
|
||
|
||
-static Boolean SFworkProc();
|
||
+static Boolean SFworkProc(XtPointer);
|
||
|
||
-static int SFcompareEntries();
|
||
+static int SFcompareEntries(const void *, const void *);
|
||
|
||
-static void SFdirModTimer();
|
||
+static void SFdirModTimer(XtPointer, XtIntervalId *);
|
||
|
||
-static char SFstatChar();
|
||
+static char SFstatChar(struct stat *);
|
||
|
||
|
||
/* BSD 4.3 errno.h does not declare errno */
|
||
@@ -1157,7 +1157,7 @@ SFpathAreaSelectedCallback(Widget w, XtPointer client_data, int pnew)
|
||
}
|
||
|
||
static Boolean
|
||
-SFworkProc()
|
||
+SFworkProc(XtPointer xxx)
|
||
{
|
||
register SFDir *dir;
|
||
register SFEntry *entry;
|
||
diff --git a/src.x11/xgap.c b/src.x11/xgap.c
|
||
index e04fceb..1783cbd 100644
|
||
--- a/src.x11/xgap.c
|
||
+++ b/src.x11/xgap.c
|
||
@@ -255,8 +255,8 @@ static char *FallbackResources[] =
|
||
*V GapMenu . . . . . . . . . . . . . . . . . . . . . . . . xgap's "GAP" menu
|
||
**
|
||
*/
|
||
-static void MenuQuitGap () { KeyboardInput( "@C@A@Kquit;\nquit;\n", 18 ); }
|
||
-static void MenuKillGap () { KillGap(); }
|
||
+static void MenuQuitGap (const TypeMenuItem *mi) { KeyboardInput( "@C@A@Kquit;\nquit;\n", 18 ); }
|
||
+static void MenuKillGap (const TypeMenuItem *mi) { KillGap(); }
|
||
|
||
#ifdef DEBUG_ON
|
||
static void MenuResyncGap ()
|
||
@@ -341,14 +341,14 @@ static TypeMenuItem GapMenu[] =
|
||
*V HelpMenu . . . . . . . . . . . . . . . . . . . . . . xgap's "Help" menu
|
||
**
|
||
*/
|
||
-static void MenuChapters () { SimulateInput( "?Chapters\n" ); }
|
||
-static void MenuSections () { SimulateInput( "?Sections\n" ); }
|
||
-static void MenuCopyright () { SimulateInput( "?Copyright\n" );}
|
||
-static void MenuHelp () { SimulateInput( "?Help\n" ); }
|
||
-static void MenuNextHelp () { SimulateInput( "?>\n" ); }
|
||
-static void MenuNextChapter () { SimulateInput( "?>>\n" ); }
|
||
-static void MenuPrevChapter () { SimulateInput( "?<<\n" ); }
|
||
-static void MenuPrevHelp () { SimulateInput( "?<\n" ); }
|
||
+static void MenuChapters (const TypeMenuItem *mi) { SimulateInput( "?Chapters\n" ); }
|
||
+static void MenuSections (const TypeMenuItem *mi) { SimulateInput( "?Sections\n" ); }
|
||
+static void MenuCopyright (const TypeMenuItem *mi) { SimulateInput( "?Copyright\n" );}
|
||
+static void MenuHelp (const TypeMenuItem *mi) { SimulateInput( "?Help\n" ); }
|
||
+static void MenuNextHelp (const TypeMenuItem *mi) { SimulateInput( "?>\n" ); }
|
||
+static void MenuNextChapter (const TypeMenuItem *mi) { SimulateInput( "?>>\n" ); }
|
||
+static void MenuPrevChapter (const TypeMenuItem *mi) { SimulateInput( "?<<\n" ); }
|
||
+static void MenuPrevHelp (const TypeMenuItem *mi) { SimulateInput( "?<\n" ); }
|
||
|
||
|
||
static TypeMenuItem HelpMenu[] =
|
||
@@ -372,11 +372,11 @@ static TypeMenuItem HelpMenu[] =
|
||
*V RunMenu . . . . . . . . . . . . . . . . . . . . . . . . xgap's "Run" menu
|
||
**
|
||
*/
|
||
-static void MenuInterrupt () { InterruptGap(); }
|
||
-static void MenuQuitBreak () { SimulateInput( "quit;\n" ); }
|
||
-static void MenuContBreak () { SimulateInput( "return;\n" ); }
|
||
-static void MenuGarbColl () { SimulateInput( "GASMAN(\"collect\");\n" ); }
|
||
-static void MenuGarbMesg () { SimulateInput( "GASMAN(\"message\");\n" ); }
|
||
+static void MenuInterrupt (const TypeMenuItem *mi) { InterruptGap(); }
|
||
+static void MenuQuitBreak (const TypeMenuItem *mi) { SimulateInput( "quit;\n" ); }
|
||
+static void MenuContBreak (const TypeMenuItem *mi) { SimulateInput( "return;\n" ); }
|
||
+static void MenuGarbColl (const TypeMenuItem *mi) { SimulateInput( "GASMAN(\"collect\");\n" ); }
|
||
+static void MenuGarbMesg (const TypeMenuItem *mi) { SimulateInput( "GASMAN(\"message\");\n" ); }
|
||
|
||
static TypeMenuItem RunMenu[] =
|
||
{
|
||
@@ -483,7 +483,7 @@ static void MenuSelected (
|
||
caddr_t dummy )
|
||
{
|
||
if ( item->click != 0 )
|
||
- (*(item->click))(item);
|
||
+ item->click(item);
|
||
else
|
||
{
|
||
fputs( "Warning: menu item ", stderr );
|
||
@@ -806,11 +806,11 @@ static void CreateGapWindow ( void )
|
||
|
||
*F MyErrorHandler(<dis>) . . . . . . . . . . . . kill gap in case of X error
|
||
*/
|
||
-static int (*OldErrorHandler)();
|
||
+static int (*OldErrorHandler)(Display *, XErrorEvent *);
|
||
|
||
static int MyErrorHandler ( dis, evt )
|
||
Display * dis;
|
||
- XErrorEvent evt;
|
||
+ XErrorEvent * evt;
|
||
{
|
||
# ifdef DEBUG_ON
|
||
fputs( "killing gap because of X error\n", stderr );
|
||
@@ -824,7 +824,7 @@ static int MyErrorHandler ( dis, evt )
|
||
**
|
||
*F MyIOErrorHandler(<dis>) . . . . . . . . . . . kill gap in case of X error
|
||
*/
|
||
-static int (*OldIOErrorHandler)();
|
||
+static int (*OldIOErrorHandler)(Display *);
|
||
|
||
static int MyIOErrorHandler ( dis )
|
||
Display * dis;
|
||
@@ -843,50 +843,50 @@ static int MyIOErrorHandler ( dis )
|
||
*/
|
||
#ifdef DEBUG_ON
|
||
|
||
-static void (*OldSignalHandlerHUP)();
|
||
-static void (*OldSignalHandlerINT)();
|
||
-static void (*OldSignalHandlerQUIT)();
|
||
-static void (*OldSignalHandlerILL)();
|
||
-static void (*OldSignalHandlerIOT)();
|
||
-static void (*OldSignalHandlerBUS)();
|
||
-static void (*OldSignalHandlerSEGV)();
|
||
+static void (*OldSignalHandlerHUP)(int);
|
||
+static void (*OldSignalHandlerINT)(int);
|
||
+static void (*OldSignalHandlerQUIT)(int);
|
||
+static void (*OldSignalHandlerILL)(int);
|
||
+static void (*OldSignalHandlerIOT)(int);
|
||
+static void (*OldSignalHandlerBUS)(int);
|
||
+static void (*OldSignalHandlerSEGV)(int);
|
||
|
||
-static void MySignalHandlerHUP ()
|
||
+static void MySignalHandlerHUP (int signo)
|
||
{
|
||
fputs( "killing gap because of signal HUP\n", stderr );
|
||
KillGap();
|
||
OldSignalHandlerHUP();
|
||
exit(1);
|
||
}
|
||
-static void MySignalHandlerINT ()
|
||
+static void MySignalHandlerINT (int signo)
|
||
{
|
||
fputs( "killing gap because of signal INT\n", stderr );
|
||
KillGap();
|
||
OldSignalHandlerINT();
|
||
exit(1);
|
||
}
|
||
-static void MySignalHandlerQUIT ()
|
||
+static void MySignalHandlerQUIT (int signo)
|
||
{
|
||
fputs( "killing gap because of signal QUIT\n", stderr );
|
||
KillGap();
|
||
OldSignalHandlerQUIT();
|
||
exit(1);
|
||
}
|
||
-static void MySignalHandlerILL ()
|
||
+static void MySignalHandlerILL (int signo)
|
||
{
|
||
fputs( "killing gap because of signal ILL\n", stderr );
|
||
KillGap();
|
||
OldSignalHandlerILL();
|
||
exit(1);
|
||
}
|
||
-static void MySignalHandlerIOT ()
|
||
+static void MySignalHandlerIOT (int signo)
|
||
{
|
||
fputs( "killing gap because of signal IOT\n", stderr );
|
||
KillGap();
|
||
OldSignalHandlerIOT();
|
||
exit(1);
|
||
}
|
||
-static void MySignalHandlerBUS ()
|
||
+static void MySignalHandlerBUS (int signo)
|
||
{
|
||
fputs( "killing gap because of signal BUS\n", stderr );
|
||
KillGap();
|
||
@@ -894,7 +894,7 @@ static void MySignalHandlerBUS ()
|
||
exit(1);
|
||
}
|
||
|
||
-static void MySignalHandlerSEGV ()
|
||
+static void MySignalHandlerSEGV (int signo)
|
||
{
|
||
fputs( "killing gap because of signal SEGV\n", stderr );
|
||
KillGap();
|
||
@@ -904,7 +904,7 @@ static void MySignalHandlerSEGV ()
|
||
|
||
#else
|
||
|
||
-static void MySignalHandler ()
|
||
+static void MySignalHandler (int signo)
|
||
{
|
||
KillGap();
|
||
exit(1);
|
||
diff --git a/src.x11/xgap.h b/src.x11/xgap.h
|
||
index aabc989..f66b7b0 100644
|
||
--- a/src.x11/xgap.h
|
||
+++ b/src.x11/xgap.h
|
||
@@ -25,7 +25,7 @@
|
||
typedef struct _menu_item
|
||
{
|
||
char * label;
|
||
- void (*click)();
|
||
+ void (*click)(const struct _menu_item *);
|
||
int sensitive;
|
||
Widget entry;
|
||
}
|
||
--
|
||
2.49.0
|
||
|