(info): Polish output for ambigous topic argument.
This commit is contained in:
parent
5686a080ce
commit
0ad644b11b
1 changed files with 30 additions and 9 deletions
|
@ -79,6 +79,8 @@ info(void)
|
||||||
s_char last[256];
|
s_char last[256];
|
||||||
DIR *info_dp;
|
DIR *info_dp;
|
||||||
int nmatch = 0;
|
int nmatch = 0;
|
||||||
|
int width = 0;
|
||||||
|
char sep;
|
||||||
|
|
||||||
name = player->argp[1];
|
name = player->argp[1];
|
||||||
if (name) {
|
if (name) {
|
||||||
|
@ -110,9 +112,18 @@ info(void)
|
||||||
if (nmatch == 1) {
|
if (nmatch == 1) {
|
||||||
snprintf(last, sizeof(last), "%s", dp->d_name);
|
snprintf(last, sizeof(last), "%s", dp->d_name);
|
||||||
} else {
|
} else {
|
||||||
if (nmatch == 2)
|
if (nmatch == 2) {
|
||||||
pr("The following info topics were found %s", last);
|
pr("`%s' is ambiguous. The following topics match:\n%s",
|
||||||
pr(", %s", dp->d_name);
|
name, last);
|
||||||
|
width = strlen(last);
|
||||||
|
}
|
||||||
|
width += 2 + strlen(dp->d_name);
|
||||||
|
sep = ' ';
|
||||||
|
if (width > 75) {
|
||||||
|
sep = '\n';
|
||||||
|
width = strlen(dp->d_name);
|
||||||
|
}
|
||||||
|
pr(",%c%s", sep, dp->d_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(info_dp);
|
closedir(info_dp);
|
||||||
|
@ -120,7 +131,7 @@ info(void)
|
||||||
pr("Sorry, there is no info on %s\n", name);
|
pr("Sorry, there is no info on %s\n", name);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
} else if (nmatch > 1) {
|
} else if (nmatch > 1) {
|
||||||
pr("\n");
|
pr(".\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
snprintf(filename, sizeof(filename), "%s/%s", infodir,
|
snprintf(filename, sizeof(filename), "%s/%s", infodir,
|
||||||
|
@ -275,6 +286,8 @@ info(void)
|
||||||
s_char filename[1024];
|
s_char filename[1024];
|
||||||
s_char last[256];
|
s_char last[256];
|
||||||
int nmatch = 0;
|
int nmatch = 0;
|
||||||
|
int width = 0;
|
||||||
|
char sep;
|
||||||
|
|
||||||
name = player->argp[1];
|
name = player->argp[1];
|
||||||
if (name) {
|
if (name) {
|
||||||
|
@ -327,10 +340,18 @@ info(void)
|
||||||
if (nmatch == 1) {
|
if (nmatch == 1) {
|
||||||
_snprintf(last, sizeof(last), "%s", fData.cFileName);
|
_snprintf(last, sizeof(last), "%s", fData.cFileName);
|
||||||
} else {
|
} else {
|
||||||
if (nmatch == 2)
|
if (nmatch == 2) {
|
||||||
pr("The following info topics were found %s",
|
pr("`%s' is ambiguous. The following topics match:\n%s",
|
||||||
last);
|
name, last);
|
||||||
pr(", %s", fData.cFileName);
|
width = strlen(last);
|
||||||
|
}
|
||||||
|
width += 2 + strlen(fData.cFileName);
|
||||||
|
sep = ' ';
|
||||||
|
if (width > 75) {
|
||||||
|
sep = '\n';
|
||||||
|
width = strlen(fData.cFileName);
|
||||||
|
}
|
||||||
|
pr(",%c%s", sep, fData.cFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (FindNextFile(hDir, &fData));
|
} while (FindNextFile(hDir, &fData));
|
||||||
|
@ -339,7 +360,7 @@ info(void)
|
||||||
pr("Sorry, there is no info on %s\n", name);
|
pr("Sorry, there is no info on %s\n", name);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
} else if (nmatch > 1) {
|
} else if (nmatch > 1) {
|
||||||
pr("\n");
|
pr(".\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
_snprintf(filename, sizeof(filename), "%s/%s",
|
_snprintf(filename, sizeof(filename), "%s/%s",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue