summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dsimple.c2
-rw-r--r--dsimple.h2
-rw-r--r--xlsfonts.c31
3 files changed, 24 insertions, 11 deletions
diff --git a/dsimple.c b/dsimple.c
index 2ec899c..67e59c0 100644
--- a/dsimple.c
+++ b/dsimple.c
@@ -75,7 +75,7 @@ Get_Display_Name(int *pargc/* MODIFIED */, char **argv/* MODIFIED */)
char *arg = argv[i];
if (!strcmp (arg, "-display") || !strcmp (arg, "-d")) {
- if (++i >= argc) usage ();
+ if (++i >= argc) usage ("-display requires an argument");
displayname = argv[i];
*pargc -= 2;
diff --git a/dsimple.h b/dsimple.h
index 0ecd10f..41a1e1c 100644
--- a/dsimple.h
+++ b/dsimple.h
@@ -62,7 +62,7 @@ extern int screen; /* The current screen */
void Setup_Display_And_Screen(int *, char **);
void Close_Display(void);
-void usage(void) _X_NORETURN;
+void usage(const char *errmsg) _X_NORETURN;
#define X_USAGE "[host:display]" /* X arguments handled by
Get_Display_Name */
diff --git a/xlsfonts.c b/xlsfonts.c
index e262cb6..0f45450 100644
--- a/xlsfonts.c
+++ b/xlsfonts.c
@@ -73,8 +73,11 @@ static void ComputeFontType(XFontStruct *fs);
static void print_character_metrics(register XFontStruct *info);
static void do_query_font (Display *dpy, char *name);
-void usage(void)
+void usage(const char *errmsg)
{
+ if (errmsg != NULL)
+ fprintf (stderr, "%s: %s\n\n", program_name, errmsg);
+
fprintf (stderr, "usage: %s [-options] [-fn pattern]\n%s", program_name,
"where options include:\n"
" -l[l[l]] give long info about each font\n"
@@ -103,7 +106,8 @@ int main(int argc, char **argv)
for (argv++, argc--; argc; argv++, argc--) {
if (argv[0][0] == '-') {
- if (argcnt > 0) usage ();
+ if (argcnt > 0)
+ usage ("options may not be specified after font names");
for (i=1; argv[0][i]; i++)
switch(argv[0][i]) {
case 'l':
@@ -119,19 +123,23 @@ int main(int argc, char **argv)
columns = 1;
break;
case 'f': /* "-fn" */
- if (--argc <= 0) usage ();
- if (argv[0][i+1] != 'n') usage ();
+ if (argv[0][i+1] != 'n') {
+ fprintf (stderr, "%s: unrecognized argument %s\n\n",
+ program_name, argv[0]);
+ usage(NULL);
+ }
+ if (--argc <= 0) usage ("-fn requires an argument");
argcnt++;
argv++;
get_list(argv[0]);
goto next;
case 'w':
- if (--argc <= 0) usage ();
+ if (--argc <= 0) usage ("-w requires an argument");
argv++;
max_output_line_width = atoi(argv[0]);
goto next;
case 'n':
- if (--argc <= 0) usage ();
+ if (--argc <= 0) usage ("-n requires an argument");
argv++;
columns = atoi(argv[0]);
goto next;
@@ -142,11 +150,16 @@ int main(int argc, char **argv)
sort_output = False;
break;
default:
- usage();
+ fprintf (stderr, "%s: unrecognized argument -%c\n\n",
+ program_name, argv[0][i]);
+ usage(NULL);
break;
}
- if (i == 1)
- usage();
+ if (i == 1) {
+ fprintf (stderr, "%s: unrecognized argument %s\n\n",
+ program_name, argv[0]);
+ usage(NULL);
+ }
} else {
argcnt++;
get_list(argv[0]);