Fixes STR#3428: allows command line to specify alternate html file on Mac platform

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12568 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Greg Ercolano
2017-11-19 01:18:16 +00:00
parent a877466a21
commit 310c545179
+11 -16
View File
@@ -26,7 +26,8 @@
// //
#include <FL/Fl_Help_Dialog.H> #include <FL/Fl_Help_Dialog.H>
#include <stdio.h> #include <FL/filename.H> /* FL_PATH_MAX */
#include <string.h> /* strcpy(), etc */
// //
// 'main()' - Display the help GUI... // 'main()' - Display the help GUI...
@@ -37,27 +38,21 @@ main(int argc, // I - Number of command-line arguments
char *argv[]) // I - Command-line arguments char *argv[]) // I - Command-line arguments
{ {
Fl_Help_Dialog *help = new Fl_Help_Dialog; Fl_Help_Dialog *help = new Fl_Help_Dialog;
char htmlname[FL_PATH_MAX];
if (argc > 1) {
strcpy(htmlname, argv[1]);
} else {
#ifdef __APPLE__ #ifdef __APPLE__
// bundled apps do not set the current directory // bundled apps do not set the current directory
char htmlname[1000];
strcpy(htmlname, argv[0]); strcpy(htmlname, argv[0]);
char *slash = strrchr(htmlname, '/'); char *slash = strrchr(htmlname, '/');
if (slash) if (slash) strcpy(slash, "/../Resources/help_dialog.html");
strcpy(slash, "/../Resources/help_dialog.html"); #else
FILE *in = fl_fopen(htmlname, "r"); strcpy(htmlname, "help_dialog.html");
if (in) {
fclose(in);
help->load(htmlname);
} else
#endif #endif
}
if (argc <= 1) help->load(htmlname); // TODO: add error check (when load() returns int instead of void)
help->load("help_dialog.html");
else
help->load(argv[1]);
help->show(1, argv); help->show(1, argv);