This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] ignore bad lines in prefs


This should never happen, but if a line gets corrupted in the preferences 
file, it will cause Insight to silently quit on startup.  This patch just 
skips any bad lines. I've checked it in. 

-- 
Martin Hunt
GDB Engineer
Red Hat, Inc.

2002-05-31  Martin M. Hunt  <hunt@redhat.com>

	* library/prefs.tcl (pref_read): If the regular expression
	cannot parse line, print debug message and skip it.


Index: gdbtk/library/prefs.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/prefs.tcl,v
retrieving revision 1.15
diff -u -r1.15 prefs.tcl
--- gdbtk/library/prefs.tcl	5 Mar 2002 22:22:19 -0000	1.15
+++ gdbtk/library/prefs.tcl	1 Jun 2002 06:36:21 -0000
@@ -54,7 +54,7 @@
     set file_opened 0
     if {[file exists $prefs_init_filename]} {
       if {[catch {open $prefs_init_filename r} fd]} {
-	debug "$fd"
+	dbug E "$fd"
 	return
       }
       set file_opened 1
@@ -62,7 +62,7 @@
       set name [file join $home $prefs_init_filename]
       if {[file exists $name]} {
 	if {[catch {open $name r} fd]} {
-	  debug "$fd"
+	  dbug E "$fd"
 	  return
 	}
 	set prefs_init_filename $name
@@ -98,28 +98,35 @@
 	  }
 
 	  default {
+	    set a ""
+	    set name ""
+	    set val ""
 	    regexp "\[ \t\n\]*\(.+\)=\(.+\)" $line a name val
-	    # Must unescape equal signs in val
-	    set val [unescape_value $val $version]
-	    if {$section == "gdb"} {
-	      pref setd gdb/$name $val
-	    } elseif {$section == "global" && [regexp "^font/" $name]} {
-	      set name [split $name /]
-	      set f global/
-	      append f [join [lrange $name 1 end] /]
-	      if {[lsearch [font names] $f] == -1} {
-		# new font
-		eval define_font $f $val
+	    if {$a == "" || $name == ""} {
+	      dbug W "Cannot parse line: $line"
+	    } else {
+	      # Must unescape equal signs in val
+	      set val [unescape_value $val $version]
+	      if {$section == "gdb"} {
+		pref setd gdb/$name $val
+	      } elseif {$section == "global" && [regexp "^font/" $name]} {
+		set name [split $name /]
+		set f global/
+		append f [join [lrange $name 1 end] /]
+		if {[lsearch [font names] $f] == -1} {
+		  # new font
+		  eval define_font $f $val
+		} else {
+		  # existing font
+		  pref set global/font/[join [lrange $name 1 end] /] $val
+		}
+	      } elseif {$section == "global"} {
+		pref setd $section/$name $val
 	      } else {
-		# existing font
-		pref set global/font/[join [lrange $name 1 end] /] $val
+		# backwards compatibility. recognize old src-font name
+		if {$val == "src-font"} {set val "global/fixed"}
+		pref setd gdb/$section/$name $val
 	      }
-	    } elseif {$section == "global"} {
-	      pref setd $section/$name $val
-	    } else {
-	      # backwards compatibility. recognize old src-font name
-	      if {$val == "src-font"} {set val "global/fixed"}
-	      pref setd gdb/$section/$name $val
 	    }
 	  }
 	}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]