better message

git-svn-id: file:///raid/svn-personal/keine/trunk@7 a3977ea8-0dc0-2842-9144-a1a46b47fd40
This commit is contained in:
Nishi 2024-09-11 15:46:04 +00:00
parent f1b725437d
commit 74571efd2f
2 changed files with 14 additions and 14 deletions

View File

@ -50,7 +50,7 @@ void manpage_scan(const char* root) {
manpage_scan(path); manpage_scan(path);
} else { } else {
char* name = kn_strdup(nl[i]->d_name); char* name = kn_strdup(nl[i]->d_name);
char* desc = kn_strdup("dadsandasndasdsadmadsadmsmdsmdmdksmdkamdkmdksmdsmdmskdmdmsakdsdmsakdmskdmsdmsadkmsakdmdsdmsdkamdkmdkamdksmdksamkdsmdkmadmsakdmsakdmmdakmdsm"); char* desc = kn_strdup("<No description detected>");
int incr = 0; int incr = 0;
FILE* f = fopen(path, "r"); FILE* f = fopen(path, "r");
@ -60,24 +60,24 @@ void manpage_scan(const char* root) {
fclose(f); fclose(f);
int j; int j;
for(j = 0;; j++){ for(j = 0;; j++) {
if(b[j] == '\n' || b[j] == 0){ if(b[j] == '\n' || b[j] == 0) {
char* line = malloc(j - incr + 1); char* line = malloc(j - incr + 1);
line[j - incr] = 0; line[j - incr] = 0;
memcpy(line, b + incr, j - incr); memcpy(line, b + incr, j - incr);
int k; int k;
for(k = 0; line[k] != 0 && k < 4; k++){ for(k = 0; line[k] != 0 && k < 4; k++) {
if(line[k] == ' '){ if(line[k] == ' ') {
line[k] = 0; line[k] = 0;
if(strcasecmp(line, ".Nd") == 0){ if(strcasecmp(line, ".Nd") == 0) {
free(desc); free(desc);
desc = kn_strdup(line + k + 1); desc = kn_strdup(line + k + 1);
int l; int l;
for(l = 0; desc[l] != 0; l++){ for(l = 0; desc[l] != 0; l++) {
if(desc[l] == '\\'){ if(desc[l] == '\\') {
l++; l++;
if(desc[l] == '"'){ if(desc[l] == '"') {
l--; l--;
desc[l] = 0; desc[l] = 0;
break; break;
@ -97,7 +97,7 @@ void manpage_scan(const char* root) {
free(b); free(b);
if(strlen(desc) > 70){ if(strlen(desc) > 70) {
desc[70] = 0; desc[70] = 0;
desc[69] = '.'; desc[69] = '.';
desc[68] = '.'; desc[68] = '.';
@ -124,7 +124,7 @@ void list_manpages(void) {
#ifdef MANPAGE_DIRS #ifdef MANPAGE_DIRS
int i; int i;
const char* dirs[] = MANPAGE_DIRS; const char* dirs[] = MANPAGE_DIRS;
for(i = 0; i < sizeof(dirs) / sizeof(*dirs); i++){ for(i = 0; i < sizeof(dirs) / sizeof(*dirs); i++) {
manpage_scan(dirs[i]); manpage_scan(dirs[i]);
} }
#else #else
@ -185,7 +185,7 @@ void kn_parse_query(void) {
#ifdef MANPAGE_DIRS #ifdef MANPAGE_DIRS
int i; int i;
const char* dirs[] = MANPAGE_DIRS; const char* dirs[] = MANPAGE_DIRS;
for(i = 0; i < sizeof(dirs) / sizeof(*dirs); i++){ for(i = 0; i < sizeof(dirs) / sizeof(*dirs); i++) {
cond = (path = kn_find(dirs[i], kn_get_query("page"))) != NULL; cond = (path = kn_find(dirs[i], kn_get_query("page"))) != NULL;
if(cond) break; if(cond) break;
} }

View File

@ -47,9 +47,9 @@ bool kn_has_manpage(const char* str) {
#ifdef MANPAGE_DIRS #ifdef MANPAGE_DIRS
int i; int i;
const char* dirs[] = MANPAGE_DIRS; const char* dirs[] = MANPAGE_DIRS;
for(i = 0; i < sizeof(dirs) / sizeof(*dirs); i++){ for(i = 0; i < sizeof(dirs) / sizeof(*dirs); i++) {
char* pth = kn_find(dirs[i], str); char* pth = kn_find(dirs[i], str);
if(pth != NULL){ if(pth != NULL) {
free(pth); free(pth);
return true; return true;
} }