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.
 .
 gcl (2.6.14-14) unstable; urgency=medium
 .
   * Version_2_6_15pre13
Author: Camm Maguire <camm@debian.org>

---
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: 2025-02-13

--- gcl-2.6.14.orig/gcl-tk/tkMain.c
+++ gcl-2.6.14/gcl-tk/tkMain.c
@@ -36,7 +36,9 @@
 #include <stdlib.h>
 #include <tcl.h>
 #include <tk.h>
-
+#if TCL_MAJOR_VERSION >= 9
+#include <wordexp.h>
+#endif
 
 
 #if (TK_MINOR_VERSION==0 && TK_MAJOR_VERSION==4)
@@ -67,12 +69,12 @@ struct connection_state *dsfd;
  * file out of the Tk source directory to make their own modified versions).
  */
 
-/* extern void		exit _ANSI_ARGS_((int status)); */
+/* extern void		exit _ANSI_ARGS_((int status));
 extern int		isatty _ANSI_ARGS_((int fd));
-/*
 extern int		read _ANSI_ARGS_((int fd, char *buf, size_t size));
-*/
 extern char *		strrchr _ANSI_ARGS_((CONST char *string, int c));
+*/
+extern int Tcl_AppInit(Tcl_Interp *interp);
 
 /*
  * Global variables used by the main program:
@@ -331,11 +333,17 @@ TkX_Wish (argc, argv)
 	 */
 
 	if (tcl_RcFileName != NULL) {
-	    Tcl_DString buffer;
 	    char *fullName;
 	    FILE *f;
+#if TCL_MAJOR_VERSION >= 9
+	    wordexp_t exp_result;
+	    wordexp(tcl_RcFileName, &exp_result, WRDE_NOCMD);
+	    fullName = exp_result.we_wordv[0];
+#else
+	    Tcl_DString buffer;
     
 	    fullName = Tcl_TildeSubst(interp, tcl_RcFileName, &buffer);
+#endif
 	    if (fullName == NULL) {
 		fprintf(stderr, "%s\n", INTERP_RESULT(interp));
 	    } else {
@@ -348,12 +356,16 @@ TkX_Wish (argc, argv)
 		    fclose(f);
 		}
 	    }
+#if TCL_MAJOR_VERSION >= 9
+	    wordfree(&exp_result);
+#else
 	    Tcl_DStringFree(&buffer);
+#endif
 	}
 
 	dfprintf(stderr, "guis : Creating file handler for %d\n", dsfd->fd);
 #ifndef __MINGW32__	
-	Tk_CreateFileHandler(dsfd->fd, TK_READABLE, StdinProc, (ClientData) 0);
+	Tcl_CreateFileHandler(dsfd->fd, TCL_READABLE, StdinProc, (ClientData) 0);
 #endif        
     }
     fflush(stdout);
@@ -466,7 +478,7 @@ StdinProc(clientData, mask)
    */
   dfprintf(stderr, "\nguis : Disabling file handler for %d\n", dsfd->fd);
 
-/*  Tk_CreateFileHandler(dsfd->fd, 0, StdinProc, (ClientData) 0); */
+/*  Tcl_CreateFileHandler(dsfd->fd, 0, StdinProc, (ClientData) 0); */
 
   do
     { 
@@ -478,7 +490,7 @@ StdinProc(clientData, mask)
 	  /*dfprintf(stderr, "Yoo !!! Empty command\n"); */
 	  if (debug)perror("zero message");
 #ifndef __MINGW32__          
-	  Tk_CreateFileHandler(dsfd->fd, TK_READABLE, StdinProc, (ClientData) 0);
+	  Tcl_CreateFileHandler(dsfd->fd, TCL_READABLE, StdinProc, (ClientData) 0);
 #endif          
 	  return;
 	}
@@ -580,7 +592,7 @@ StdinProc(clientData, mask)
     } while (fNotDone > 0);
 
 
-  /* Tk_CreateFileHandler(dsfd->fd, TK_READABLE, StdinProc, (ClientData) 0); */
+  /* Tcl_CreateFileHandler(dsfd->fd, TCL_READABLE, StdinProc, (ClientData) 0); */
   if ((void *)msg != (void *) buf)
     free ((void *) msg);
 }
--- gcl-2.6.14.orig/git.tag
+++ gcl-2.6.14/git.tag
@@ -1 +1 @@
-"Version_2_6_15pre10"
+"Version_2_6_15pre13"
--- gcl-2.6.14.orig/h/pool.h
+++ gcl-2.6.14/h/pool.h
@@ -112,7 +112,7 @@ close_pool(void) {
   if (pool!=-1) {
     f.l_type=F_WRLCK;
     if (!fcntl(pool,F_SETLK,&f))
-      massert(!unlink(gcl_pool));
+      massert(!unlink(gcl_pool) || errno=ENOENT);
     register_pool(-1);
     massert(!close(pool));
     massert(!munmap(Pool,sizeof(struct pool)));
--- gcl-2.6.14.orig/lsp/gcl_sharp.lsp
+++ gcl-2.6.14/lsp/gcl_sharp.lsp
@@ -51,7 +51,7 @@
       (aset1 x i (patch-sharp (row-major-aref x i)))))
    (structure
     (let ((d (structure-def x))) 
-      (dotimes (i (structure-length x) x)
+      (dotimes (i (structure-length d) x)
 	(declare (fixnum i))
 	(structure-set x d i (patch-sharp (structure-ref x d i))))))
    (spice (let* ((y (gethash1 x (context-spice *sharp-eq-context*)))
--- gcl-2.6.14.orig/makefile
+++ gcl-2.6.14/makefile
@@ -269,12 +269,12 @@ $(HDIR)new_decl.h:
 $(HDIR)mcompdefs.h: $(HDIR)compdefs.h $(HDIR)new_decl.h
 	cat $< |\
 	$(AWK) 'BEGIN {print "#include \"include.h\"";print "#include \"cmponly.h\"";print "---"} {a=$$1;gsub("\\.\\.\\.","",a);print "\"#define " $$1 "\" " a}' |\
-	$(CC) -E -P -I./$(HDIR) - |\
+	$(CC) $(CFLAGS) -E -P -I./$(HDIR) - |\
 	$(AWK) '/^\-\-\-$$/ {i=1;next} {if (!i) next} {gsub("\"","");print}' >$@
 
 $(HDIR)cmpinclude.h: $(HDIR)mcompdefs.h $(CMPINCLUDE_FILES) $(HDIR)config.h
 	cp $< $(@F)
-	cat $(CMPINCLUDE_FILES) | $(CC) -E -I./$(HDIR) - | $(AWK) '/^# |^$$|^#pragma/ {next}{print}' >> $(@F)
+	cat $(CMPINCLUDE_FILES) | $(CC) $(CFLAGS) -E -I./$(HDIR) - | $(AWK) '/^# |^$$|^#pragma/ {next}{print}' >> $(@F)
 	./xbin/move-if-changed mv $(@F) $@
 	./xbin/move-if-changed cp $@ o/$(@F)
 
--- gcl-2.6.14.orig/o/gmp_big.c
+++ gcl-2.6.14/o/gmp_big.c
@@ -292,33 +292,6 @@ big_minus(object x)
 #endif
 
 
-/* static int */
-/* double_exponent(double d) { */
-  
-/*   union {double d;int i[2];} u; */
-  
-/*   if (d == 0.0) */
-/*     return(0); */
-
-/*   u.d=d; */
-/*   return (((u.i[HIND] & 0x7ff00000) >> 20) - 1022); */
-
-/* } */
-
-/* static double */
-/* set_exponent(double d, int e) { */
-
-/*   union {double d;int i[2];} u; */
-  
-/*   if (d == 0.0) */
-/*     return(0.0); */
-  
-/*   u.d=d; */
-/*   u.i[HIND]= (u.i[HIND] & 0x800fffff) | (((e + 1022) << 20) & 0x7ff00000); */
-/*   return(u.d); */
-
-/* } */
-	
 double
 big_to_double(object x) {
 
--- gcl-2.6.14.orig/o/makefile
+++ gcl-2.6.14/o/makefile
@@ -71,7 +71,7 @@ boot.h: boot.ini
 	rm $*.c
 
 $(DPP):	../bin/dpp.c
-	${CC} ${DEFS} -o $@ $<
+	${CC} $(CFLAGS) $(LDFLAGS) ${DEFS} -o $@ $<
 
 new_init.c: ${INI_FILES}
 	echo '#include "make-init.h"' > $@
--- gcl-2.6.14.orig/o/print.d
+++ gcl-2.6.14/o/print.d
@@ -484,6 +484,8 @@ bool shortp;
 	write_decimal(exp);
 }
 
+static object circle_table=Cnil;
+
 static void
 call_structure_print_function(x, level)
 object x;
@@ -569,12 +571,15 @@ ONCE_MORE:
 		goto L;
 	}
 
+	if (PRINTcircle) circle_table=PRINTvs_top[0];
+
 	ifuncall3(S_DATA(x->str.str_def)->print_function,
 		  x, PRINTstream, vs_head);
 	vs_popp;
 	eflag = FALSE;
 
 L:
+	circle_table=Cnil;
 	frs_pop();
 	bds_unwind(old_bds_top);
 
@@ -1525,6 +1530,11 @@ setupPRINTcircle(object x,int dogensyms)
   object *vp=vs_top,*v=vp,h;
   fixnum j;
 
+  if (circle_table!=Cnil) {
+    vs_push(circle_table);
+    return;
+  }
+
   travel(x,dogensyms,PRINTarray);
 
   h=vs_top>vp ? gcl_make_hash_table(sLeq) : Cnil;
