[PATCH] Remove deprecated access to tcl internal variables

Roland Schwingel <[email protected]> Mon, 19 Mar 2012 12:45:55 +0100
Newsgroups gmane.comp.debugging.insight
Message-ID <[email protected]>
Hi...

Since tcl 8.6 access to some internal variables has been removed from 
the code. It was already deprecated since many years. Attached you find 
2 patches replacing the deprecated stuff with the current official way. 
This is also backward compatible to insight's tcl 8.4 version checkin in 
to sourceware.org.

Changelog:

2012-03-19  Roland Schwingel <[email protected]>

         * generic/gdbtk.c: (gdbtk_init,tk_command): Replace deprecated 
access
         to tcl interpreter result string with Tcl_GetStringResult().
         * generic/gdbtk-hooks.c (gdbtk_read,gdbtk_readline,gdbtk_load_hash)
         (gdbtk_query): Likewise

Any comments? Is this ok?

Roland
tcl_compat_gdbtk.c.patch (text/plain, 1.5 KB)
--- gdbtk_orig/generic/gdbtk.c	2012-03-19 11:21:15.542232400 +0100
+++ gdbtk/generic/gdbtk.c	2012-03-19 11:23:12.099170600 +0100
@@ -494,17 +494,17 @@
   make_final_cleanup (gdbtk_cleanup, NULL);
 
   if (Tcl_Init (gdbtk_interp) != TCL_OK)
-    error ("Tcl_Init failed: %s", gdbtk_interp->result);
+    error ("Tcl_Init failed: %s", Tcl_GetStringResult(gdbtk_interp));
 
   /* Initialize the Paths variable.  */
   if (ide_initialize_paths (gdbtk_interp, "") != TCL_OK)
-    error ("ide_initialize_paths failed: %s", gdbtk_interp->result);
+    error ("ide_initialize_paths failed: %s", Tcl_GetStringResult(gdbtk_interp));
 
   if (Tk_Init (gdbtk_interp) != TCL_OK)
-    error ("Tk_Init failed: %s", gdbtk_interp->result);
+    error ("Tk_Init failed: %s", Tcl_GetStringResult(gdbtk_interp));
 
   if (Tktable_Init (gdbtk_interp) != TCL_OK)
-    error ("Tktable_Init failed: %s", gdbtk_interp->result);
+    error ("Tktable_Init failed: %s", Tcl_GetStringResult(gdbtk_interp));
 
   Tcl_StaticPackage (gdbtk_interp, "Tktable", Tktable_Init,
 		     (Tcl_PackageInitProc *) NULL);
@@ -560,7 +560,7 @@
 
   if (Gdbtk_Init (gdbtk_interp) != TCL_OK)
     {
-      error ("Gdbtk_Init failed: %s", gdbtk_interp->result);
+      error ("Gdbtk_Init failed: %s", Tcl_GetStringResult(gdbtk_interp));
     }
 
   Tcl_StaticPackage (gdbtk_interp, "Insight", Gdbtk_Init, NULL);
@@ -740,7 +740,7 @@
 
   retval = Tcl_Eval (gdbtk_interp, cmd);
 
-  result = xstrdup (gdbtk_interp->result);
+  result = xstrdup (Tcl_GetStringResult(gdbtk_interp));
 
   old_chain = make_cleanup (free, result);
tcl_compat_gdbtk-hooks.c.patch (text/plain, 1.5 KB)
--- gdbtk_orig/generic/gdbtk-hooks.c	2012-01-03 13:26:56.000000000 +0100
+++ gdbtk/generic/gdbtk-hooks.c	2012-03-05 11:47:03.340565000 +0100
@@ -254,17 +254,22 @@
 	{
 	  report_error ();
 	  actual_len = 0;
+	  buf[0] = '\0';
+	  return 0;
 	}
       else
-        actual_len = strlen (gdbtk_interp->result);
+      {
+      	const char *tclResult = Tcl_GetStringResult(gdbtk_interp);
+        actual_len = strlen (tclResult);
 
       /* Truncate the string if it is too big for the caller's buffer.  */
       if (actual_len >= sizeof_buf)
 	actual_len = sizeof_buf - 1;
       
-      memcpy (buf, gdbtk_interp->result, actual_len);
+      memcpy (buf,tclResult, actual_len);
       buf[actual_len] = '\0';
       return actual_len;
+     }
     }
   else
     {
@@ -507,11 +512,11 @@
 
   if (result == TCL_OK)
     {
-      return (xstrdup (gdbtk_interp->result));
+      return (xstrdup (Tcl_GetStringResult(gdbtk_interp)));
     }
   else
     {
-      gdbtk_fputs (gdbtk_interp->result, gdb_stdout);
+      gdbtk_fputs (Tcl_GetStringResult(gdbtk_interp), gdb_stdout);
       gdbtk_fputs ("\n", gdb_stdout);
       return (NULL);
     }
@@ -635,7 +640,7 @@
     report_error ();
   free(buf);
 
-  return atoi (gdbtk_interp->result);
+  return atoi (Tcl_GetStringResult(gdbtk_interp));
 }
 
 
@@ -689,7 +694,7 @@
   gdbtk_two_elem_cmd ("gdbtk_tcl_query", buf);
   free(buf);
 
-  val = atol (gdbtk_interp->result);
+  val = atol (Tcl_GetStringResult(gdbtk_interp));
   return val;
 }