Hi all,

Here is a patch for gtkwave 1.3.81.Given the VCD file "whatever.vcd",
gtkwave with this patch will automatically load the SAV file
"whatever.sav".

Patch below.

Also, is there a CVS (or subversion/arch/darcs/whatever) repository
for the 1.3 version of gtkwave?

Cheers,
Erik

--- gtkwave-1.3.81/src/main.c   2005-11-18 15:39:54.000000000 +1100
+++ gtkwave/src/main.c  2006-01-13 10:47:35.000000000 +1100
@@ -169,7 +169,7 @@
 char opt_errors_encountered=0;
 
 char *fname=NULL;
-char *wname=NULL;
+char wname [512] ;
 char *override_rc=NULL;
 char *winname=NULL;
 static char *winprefix="GTKWave - ";
@@ -289,9 +289,8 @@
                        break;
 
                 case 'a':
-                       if(wname) free_2(wname);
-                       wname = malloc_2(strlen(optarg)+1);
-                       strcpy(wname, optarg);
+                       strncpy(wname, optarg, sizeof (wname));
+                       wname[sizeof (wname)-1] = 0;
                        break;
 
                 case 'r':
@@ -371,10 +370,10 @@
                        fname = malloc_2(strlen(argv[optind])+1);
                        strcpy(fname, argv[optind++]);
                        }
-               else if(!wname)
+               else if(wname [0] != 0)
                        {
-                       wname = malloc_2(strlen(argv[optind])+1);
-                       strcpy(wname, argv[optind++]);
+                       strncpy(wname, argv[optind++], sizeof (wname));
+                       wname[sizeof(wname)-1] = 0;
                        }
                else if(!override_rc)
                        {
@@ -396,7 +395,7 @@
 
 fprintf(stderr, "\n%s\n\n",WAVE_VERSION_INFO);
 
-if((!wname)&&(make_vcd_save_file))
+if((wname [0] == 0)&&(make_vcd_save_file))
        {
        vcd_save_handle=fopen(vcd_autosave_name,"wb");
        errno=0;        /* just in case */
@@ -500,14 +499,29 @@
 tims.marker=tims.lmbcache=-1;  /* uninitialized at first */
 tims.baseline=-1;              /* middle button toggle marker */
 
-if((wname)||(vcd_save_handle))
+if (wname [0] == 0)
+       {
+       char *cptr;
+       
+       strncpy (wname, fname, sizeof (wname));
+       wname [sizeof(wname) - 1] = 0;
+       
+       if ((cptr = strrchr (wname, '.')) != NULL)
+               strncpy (cptr, ".sav", sizeof (wname) - (cptr - wname) - 1);
+       
+       if (access (wname, R_OK) != 0)
+               wname [0] = 0;
+       }
+
+if((wname [0])||(vcd_save_handle))
        {
        int wave_is_compressed;
         char *str = NULL;
 
        if(vcd_save_handle)
                {
-               wname=vcd_autosave_name;
+               strncpy (wname, vcd_autosave_name, sizeof (wname));
+               wname[sizeof(wname)-1] = 0;
                do_initial_zoom_fit=1;
                }
 



-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
"I invented the term Object-Oriented, and I can tell you I
did not have C++ in mind." -- Alan Kay

Reply via email to