diff options
-rw-r--r-- | BitEdit.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -980,6 +980,7 @@ int main(int argc, char *argv[]) Widget w; Widget radio_group = NULL; XtPointer radio_data = NULL; + const char *filename = NULL; /* Handle args that don't require opening a display */ for (int a = 1; a < argc; a++) { @@ -1001,9 +1002,19 @@ int main(int argc, char *argv[]) top_widget = XtInitialize(NULL, "Bitmap", options, XtNumber(options), &argc, argv); - if (argc > 2) { - fputs(usage, stderr); - exit (0); + if (argc > 1) { + if ((argv[argc - 1][0] != '-') && (argv[argc - 1][0] != '+')) { + filename = argv[--argc]; + } + if (argc > 1) { + fputs("Unknown argument(s):", stderr); + for (int a = 1; a < argc; a++) { + fprintf(stderr, " %s", argv[a]); + } + fputs("\n\n", stderr); + fprintf(stderr, "usage: %s %s", argv[0], usage); + exit (1); + } } check_mark = XCreateBitmapFromData(XtDisplay(top_widget), @@ -1095,8 +1106,8 @@ int main(int argc, char *argv[]) bitmap_widget = XtCreateManagedWidget("bitmap", bitmapWidgetClass, pane_widget, NULL, 0); XtRealizeWidget(top_widget); - if (argc > 1) - if (BWReadFile(bitmap_widget, argv[1], NULL)) + if (filename != NULL) + BWReadFile(bitmap_widget, filename, NULL); wm_delete_window = XInternAtom(XtDisplay(top_widget), "WM_DELETE_WINDOW", False); |