summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-10-25 11:04:57 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-10-25 11:04:57 -0700
commit436c80aa9fe73824b6438934897c4f810e52f6e7 (patch)
tree0f43920cda193fcb28519e57799f126f7fb53692
parent3f1a7aac4b4c91e0d7b3c355b4148245ab8eb24d (diff)
If opening argv[1] + ".txt" fails, try opening argv[1] without suffix
Previously, running "showrgb /usr/share/X11/rgb.txt" would give the confusing error message: showrgb: unable to open rgb database "/usr/share/X11/rgb.txt" since it was really looking for rgb.txt.txt. Now it just works, allowing users to use filename completion. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--showrgb.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/showrgb.c b/showrgb.c
index 4796c5a..8f3fb81 100644
--- a/showrgb.c
+++ b/showrgb.c
@@ -135,7 +135,7 @@ dumprgb (const char *filename)
strcat(path, ".txt");
#endif
- if (!(rgb = fopen(path, "r"))) {
+ if (!(rgb = fopen(path, "r")) && !(rgb = fopen(filename, "r"))) {
fprintf (stderr, "%s: unable to open rgb database \"%s\"\n",
ProgramName, filename);
free(path);