summaryrefslogtreecommitdiff
path: root/test/colbrowser.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2020-08-21 18:54:40 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2020-08-21 18:54:40 +0200
commitd91160a9e06bd4ee341ca93509dbce9393d9168a (patch)
tree5fa6e3fb9483ce06f39ba638790eb58d81c13129 /test/colbrowser.cxx
parentf3005a44f87e30792acc410125113cd19b76a81a (diff)
Remove platform specific code from test apps
Test programs that open files don't use platform specific code. They don't open files from macOS bundles. Support files must either be in the current working directory or given on the command line. On macOS this requires a full path when using bundles.
Diffstat (limited to 'test/colbrowser.cxx')
-rw-r--r--test/colbrowser.cxx23
1 files changed, 7 insertions, 16 deletions
diff --git a/test/colbrowser.cxx b/test/colbrowser.cxx
index bcd1506d7..eedb5499f 100644
--- a/test/colbrowser.cxx
+++ b/test/colbrowser.cxx
@@ -47,29 +47,20 @@ static Fl_Value_Slider *rs, *gs, *bs;
static char dbname[FL_PATH_MAX];
static void create_form_cl(void);
-static int load_browser(char *);
+static int load_browser(const char *);
typedef struct { int r, g, b; } RGBdb;
static RGBdb rgbdb[MAX_RGB];
-int main(int argc, char *argv[])
-{
- Fl::args(argc, argv);
+int main(int argc, char *argv[]) {
+ int i;
+ if (!Fl::args(argc, argv, i)) Fl::fatal(Fl::help);
+ const char *dbname = (i < argc) ? argv[i] : "rgb.txt";
create_form_cl();
-#ifdef __APPLE__
- // Bundled apps do not set the current directory
- strcpy(dbname, argv[0]);
- char *slash = strrchr(dbname, '/');
- if (slash)
- strcpy(slash, "/../Resources/rgb.txt");
-#else
- strcpy(dbname, "rgb.txt");
-#endif
-
if (load_browser(dbname))
dbobj->label(dbname);
else
@@ -139,7 +130,7 @@ static int read_entry(FILE * fp, int *r, int *g, int *b, char *name)
}
-static int load_browser(char *fname)
+static int load_browser(const char *fname)
{
FILE *fp;
RGBdb *db = rgbdb, *dbs = db + MAX_RGB;
@@ -147,7 +138,7 @@ static int load_browser(char *fname)
char name[256], buf[300];
if (!(fp = fl_fopen(fname, "r"))) {
- fl_alert("%s\n%s\n%s","Load", fname, "Can't open");
+ fl_alert("Load:\nCan't open '%s'", fname);
return 0;
}