Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 cdecl (2.5-14) UNRELEASED; urgency=medium
 .
   * Fix gcc-14 build issues (closes: #1074872)
Author: Fredrik Hallenberg <hallon@debian.org>
Bug-Debian: https://bugs.debian.org/1074872

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2024-11-23

--- cdecl-2.5.orig/Makefile
+++ cdecl-2.5/Makefile
@@ -15,9 +15,9 @@
 #
 # add -DUSE_READLINE	To compile in support for the GNU readline library.
 
-CFLAGS= -s -O2 -DUSE_READLINE
+CFLAGS= -g -O2 -DUSE_READLINE
 CC= gcc
-LIBS= -lreadline -ltermcap
+LIBS= -lreadline
 ALLFILES= makefile cdgram.y cdlex.l cdecl.c cdecl.1 testset testset++
 BINDIR= /usr/bin
 MANDIR= /usr/man/man1
@@ -25,11 +25,13 @@ CATDIR= /usr/man/cat1
 INSTALL= install -c
 INSTALL_DATA= install -c -m 644
 
+LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
+
 cdecl: c++decl
-	ln c++decl cdecl
+	ln -s c++decl cdecl
 
 c++decl: cdgram.c cdlex.c cdecl.c
-	$(CC) $(CFLAGS) -o c++decl cdecl.c $(LIBS)
+	$(CC) $(CFLAGS) -o c++decl cdecl.c $(LIBS) $(LDFLAGS)
 	rm -f cdecl
 
 cdlex.c: cdlex.l
@@ -44,7 +46,7 @@ test:
 
 install: cdecl
 	$(INSTALL) cdecl $(BINDIR)
-	ln $(BINDIR)/cdecl $(BINDIR)/c++decl
+	ln -s cdecl $(BINDIR)/c++decl
 	$(INSTALL_DATA) cdecl.1 $(MANDIR)
 	$(INSTALL_DATA) c++decl.1 $(MANDIR)
 
--- cdecl-2.5.orig/cdecl.1
+++ cdecl-2.5/cdecl.1
@@ -274,7 +274,7 @@ NL means the new-line or semi-colon char
 	<modifier>	::= short | long | unsigned | signed | <ptrmod>
 	<ptrmodlist>	::= <ptrmod> <ptrmodlist> | NOTHING
 	<ptrmod>	::= const | volatile | noalias
-	<storage>	::= auto | extern | register | auto
+	<storage>	::= auto | extern | register | static
 	<optstorage>	::= NOTHING | <storage>
 	<options>	::= NOTHING | <options>
 		| create | nocreate
--- cdecl-2.5.orig/cdecl.c
+++ cdecl-2.5/cdecl.c
@@ -67,6 +67,7 @@ char cdeclsccsid[] = "@(#)cdecl.c	2.5 1/
 # include <stddef.h>
 # include <string.h>
 # include <stdarg.h>
+# include <errno.h>
 #else
 # ifndef NOVARARGS
 #  include <varargs.h>
@@ -89,11 +90,12 @@ void free(), exit(), perror();
 
 #ifdef USE_READLINE
 # include <readline/readline.h>
+# include <readline/history.h>
   /* prototypes for functions related to readline() */
-  char * getline();
-  char ** attempt_completion(char *, int, int);
+  char * get_line();
+  char ** attempt_completion(const char *, int, int);
   char * keyword_completion(char *, int);
-  char * command_completion(char *, int);
+  char * command_completion(const char *, int);
 #endif
 
 /* maximum # of chars from progname to display in prompt */
@@ -124,7 +126,6 @@ char real_prompt[MAX_NAME+3];
 
 #if __STDC__
   char *ds(char *), *cat(char *, ...), *visible(int);
-  int getopt(int,char **,char *);
   int main(int, char **);
   int yywrap(void);
   int dostdin(void);
@@ -241,7 +242,7 @@ struct
 /* for unsupported combinations of types. */
 void mbcheck()
 {
-    register int i, j, restrict;
+    register int i, j, restriction;
     char *t1, *t2;
 
     /* Loop through the types */
@@ -258,26 +259,26 @@ void mbcheck()
 		if (!(modbits & crosstypes[j].bit))
 		    continue;
 		/* check the type of restriction */
-		restrict = crosscheck[i][j];
-		if (restrict == ALWAYS)
+		restriction = crosscheck[i][j];
+		if (restriction == ALWAYS)
 		    continue;
 		t1 = crosstypes[i].name;
 		t2 = crosstypes[j].name;
-		if (restrict == NEVER)
+		if (restriction == NEVER)
 		    {
 		    notsupported("", t1, t2);
 		    }
-		else if (restrict == RITCHIE)
+		else if (restriction == RITCHIE)
 		    {
 		    if (RitchieFlag)
 			notsupported(" (Ritchie Compiler)", t1, t2);
 		    }
-		else if (restrict == PREANSI)
+		else if (restriction == PREANSI)
 		    {
 		    if (PreANSIFlag || RitchieFlag)
 			notsupported(" (Pre-ANSI Compiler)", t1, t2);
 		    }
-		else if (restrict == ANSI)
+		else if (restriction == ANSI)
 		    {
 		    if (!RitchieFlag && !PreANSIFlag)
 			notsupported(" (ANSI Compiler)", t1, t2);
@@ -286,7 +287,7 @@ void mbcheck()
 		    {
 		    (void) fprintf (stderr,
 			"%s: Internal error in crosscheck[%d,%d]=%d!\n",
-			progname, i, j, restrict);
+			progname, i, j, restriction);
 		    exit(1); /* NOTREACHED */
 		    }
 		}
@@ -375,7 +376,7 @@ char *options[] = {
 static char *line_read = NULL;
 
 /* Read a string, and return a pointer to it.  Returns NULL on EOF. */
-char * getline ()
+char * get_line ()
 {
   /* If the buffer has already been allocated, return the memory
      to the free pool. */
@@ -395,16 +396,16 @@ char * getline ()
   return (line_read);
 }
 
-char ** attempt_completion(char *text, int start, int end)
+char ** attempt_completion(const char *text, int start, int end)
 {
   char **matches = NULL;
 
-  if (start == 0) matches = completion_matches(text, command_completion);
+  if (start == 0) matches = rl_completion_matches(text, command_completion);
 
   return matches;
 }
 
-char * command_completion(char *text, int flag)
+char * command_completion(const char *text, int flag)
 {
   static int index, len;
   char *command;
@@ -887,7 +888,7 @@ int dostdin()
 
 	if (!quiet) (void) printf("Type `help' or `?' for help\n");
 	ret = 0;
-	while ((line = getline())) {
+	while ((line = get_line())) {
 	    if (!strcmp(line, "quit") || !strcmp(line, "exit")) {
 		free(line);
 		return ret;
@@ -1251,8 +1252,8 @@ char **argv;
 
 #ifdef USE_READLINE
     /* install completion handlers */
-    rl_attempted_completion_function = (CPPFunction *)attempt_completion;
-    rl_completion_entry_function = (Function *)keyword_completion;
+    rl_attempted_completion_function = (rl_completion_func_t *)attempt_completion;
+    rl_completion_entry_function = (rl_compentry_func_t *)keyword_completion;
 #endif
 
     setprogname(argv[0]);
