* [patch] ignore bad lines in prefs
@ 2002-05-31 23:40 Martin M. Hunt
0 siblings, 0 replies; only message in thread
From: Martin M. Hunt @ 2002-05-31 23:40 UTC (permalink / raw)
To: insight
[-- Attachment #1: Type: text/plain, Size: 399 bytes --]
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.
[-- Attachment #2: p --]
[-- Type: text/x-diff, Size: 2496 bytes --]
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
}
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-06-01 6:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-31 23:40 [patch] ignore bad lines in prefs Martin M. Hunt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).