diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-05 18:52:45 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-05 18:55:44 -0800 |
commit | 03579181022489d95b6a1361a1d3568a1d4b47e0 (patch) | |
tree | e3938555fa3d647f47d7e076bb34513c173598ae | |
parent | a53f6c680d78e41e17e1b6af05d588f5d0083f2d (diff) |
bitmap: Print which option was in error along with usage message
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-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); |