[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] view.pike improvements
From: |
Gunnar Farnebäck |
Subject: |
[gnugo-devel] view.pike improvements |
Date: |
Sun, 13 Mar 2005 21:14:47 +0100 |
User-agent: |
EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/21.3 (sparc-sun-solaris2.9) MULE/5.0 (SAKAKI) |
This patch adds two improvements to view.pike. The first one is to
give an error message if the path to a new engine does not even point
to a file, instead of crashing. The second one tweaks the heuristics
to find a suitable font, looking for the shortest filename rather than
the shortest full path. It would be nice to have a more proper
solution there, but this is at least an improvement on one computer
I'm using. Hopefully it doesn't make things worse for anyone else.
- revised heuristics to find a font file in view.pike
- avoid crashing on bad engine paths when starting a new engine in
view.pike
/Gunnar
Index: regression/view.pike
===================================================================
RCS file: /cvsroot/gnugo/gnugo/regression/view.pike,v
retrieving revision 1.15
diff -u -r1.15 view.pike
--- regression/view.pike 7 Jan 2005 22:36:49 -0000 1.15
+++ regression/view.pike 13 Mar 2005 20:06:26 -0000
@@ -488,15 +488,21 @@
werror("and point to it from the environment variable GNUGO_FONT.\n");
return 0;
}
+
+ // Compute the length of the filename proper, i.e. without the
+ // path to the file.
+ int fontlength(string s) {
+ return sizeof((s / "/")[-1]);
+ };
// Choose the one with shortest name (arbitrary but may avoid e.g.
// italic fonts).
font_filename = font_files[0];
foreach (font_files[1..], string font_file)
{
- if (sizeof(font_filename) > sizeof(font_file))
+ if (fontlength(font_filename) > fontlength(font_file))
font_filename = font_file;
- else if (sizeof(font_filename) == sizeof(font_file)
+ else if (fontlength(font_filename) == fontlength(font_file)
&& has_value(lower_case(font_filename), "mono"))
font_filename = font_file;
}
@@ -1588,6 +1594,12 @@
static void select_new_engine()
{
string new_engine_path = engine_path_entry->get_text();
+ if (!Stdio.is_file(new_engine_path)) {
+ viewers->clist->clear();
+ viewers->clist->append(({"The engine path does not point to a
file.\n", "", ""}));
+ return;
+ }
+
SimpleGtp new_engine = SimpleGtp((new_engine_path + " --quiet --mode
gtp -w -t -d0x101840") / " ");
if (!new_engine)
werror("Failed to start new engine.\n");
- [gnugo-devel] view.pike improvements,
Gunnar Farnebäck <=