/[man-db]/man-db/src/man.c
ViewVC logotype

Diff of /man-db/src/man.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.89 by cjwatson, Sun Apr 6 20:40:13 2003 UTC revision 1.90 by cjwatson, Mon Apr 7 08:13:04 2003 UTC
# Line 861  static int local_man_loop (const char *a Line 861  static int local_man_loop (const char *a
861    
862  int main (int argc, char *argv[])  int main (int argc, char *argv[])
863  {  {
864          int argc_env, status = 0, exit_status = OK;          int argc_env, exit_status = OK;
865          char **argv_env;          char **argv_env;
866          const char *tmp;          const char *tmp;
867          char *multiple_locale = NULL;          char *multiple_locale = NULL;
# Line 1073  int main (int argc, char *argv[]) Line 1073  int main (int argc, char *argv[])
1073  #endif /* MAN_DB_UPDATES */  #endif /* MAN_DB_UPDATES */
1074    
1075          while (optind < argc) {          while (optind < argc) {
1076                    int status = OK;
1077                    int found = 0;
1078                  static int maybe_section = 0;                  static int maybe_section = 0;
1079                  const char *nextarg = argv[optind++];                  const char *nextarg = argv[optind++];
1080    
# Line 1102  int main (int argc, char *argv[]) Line 1104  int main (int argc, char *argv[])
1104    
1105                  /* this is where we actually start looking for the man page */                  /* this is where we actually start looking for the man page */
1106                  skip = 0;                  skip = 0;
1107                  status = man (nextarg);                  status = man (nextarg, &found);
1108    
1109                  /* clean out the cache of database lookups for each man page */                  /* clean out the cache of database lookups for each man page */
1110                  hash_free (db_hash);                  hash_free (db_hash);
1111                  db_hash = NULL;                  db_hash = NULL;
1112    
1113                  if (section && maybe_section) {                  if (section && maybe_section) {
1114                          if (!status && !catman) {                          if (status != OK && !catman) {
1115                                  /* Maybe the section wasn't a section after                                  /* Maybe the section wasn't a section after
1116                                   * all? e.g. 'man 9wm fvwm'.                                   * all? e.g. 'man 9wm fvwm'.
1117                                   */                                   */
# Line 1119  int main (int argc, char *argv[]) Line 1121  int main (int argc, char *argv[])
1121                                                   "name\n", section);                                                   "name\n", section);
1122                                  tmp = section;                                  tmp = section;
1123                                  section = NULL;                                  section = NULL;
1124                                  status = man (tmp);                                  status = man (tmp, &found);
1125                                  hash_free (db_hash);                                  hash_free (db_hash);
1126                                  db_hash = NULL;                                  db_hash = NULL;
1127                                  /* ... but don't gripe about it if it doesn't                                  /* ... but don't gripe about it if it doesn't
1128                                   * work!                                   * work!
1129                                   */                                   */
1130                                  if (status) {                                  if (status == OK) {
1131                                          /* It was a name after all, so arrange                                          /* It was a name after all, so arrange
1132                                           * to try the next page again with a                                           * to try the next page again with a
1133                                           * null section.                                           * null section.
# Line 1138  int main (int argc, char *argv[]) Line 1140  int main (int argc, char *argv[])
1140                          }                          }
1141                  }                  }
1142    
1143                  if (!status && !catman) {                  if (status != OK && !catman) {
1144                          if (!skip) {                          if (!skip) {
1145                                  if (strchr (nextarg, '/'))                                  exit_status = status;
                                         exit_status = local_man_loop (nextarg);  
                                 else  
                                         exit_status = NOT_FOUND;  
1146                                  if (exit_status == NOT_FOUND) {                                  if (exit_status == NOT_FOUND) {
1147                                          if (!section && maybe_section &&                                          if (!section && maybe_section &&
1148                                              isdigit (nextarg[0]))                                              isdigit (nextarg[0]))
# Line 1154  int main (int argc, char *argv[]) Line 1153  int main (int argc, char *argv[])
1153                          }                          }
1154                  } else {                  } else {
1155                          if (debug)                          if (debug)
1156                                  fprintf(stderr,                                  fprintf (stderr,
1157                                          "\nFound %d man pages\n", status);                                           "\nFound %d man pages\n", found);
1158                          if (catman) {                          if (catman) {
1159                                  printf ("%s", nextarg);                                  printf ("%s", nextarg);
1160                                  if (section)                                  if (section)
# Line 3325  static int display_pages (struct candida Line 3324  static int display_pages (struct candida
3324   * being used, only look for the man page source file.   * being used, only look for the man page source file.
3325   *   *
3326   */   */
3327  static int man (const char *name)  static int man (const char *name, int *found)
3328  {  {
3329          struct candidate *candidates = NULL;          struct candidate *candidates = NULL;
         int found = 0;  
3330    
3331            *found = 0;
3332          fflush (stdout);          fflush (stdout);
3333    
3334            if (strchr (name, '/')) {
3335                    int status = local_man_loop (name);
3336                    if (status == OK)
3337                            *found = 1;
3338                    return status;
3339            }
3340    
3341          if (section) {          if (section) {
3342                  char **mp;                  char **mp;
3343    
3344                  for (mp = manpathlist; *mp; mp++)                  for (mp = manpathlist; *mp; mp++)
3345                          found += locate_page (*mp, section, name, &candidates);                          *found += locate_page (*mp, section, name, &candidates);
3346          } else {          } else {
3347                  char **sp;                  char **sp;
3348    
# Line 3344  static int man (const char *name) Line 3350  static int man (const char *name)
3350                          char **mp;                          char **mp;
3351    
3352                          for (mp = manpathlist; *mp; mp++)                          for (mp = manpathlist; *mp; mp++)
3353                                  found += locate_page (*mp, *sp, name,                                  *found += locate_page (*mp, *sp, name,
3354                                                        &candidates);                                                         &candidates);
3355                  }                  }
3356          }          }
3357    
3358          if (found)          if (*found)
3359                  found = display_pages (candidates);                  *found = display_pages (candidates);
3360    
3361          return found;          return *found ? OK : NOT_FOUND;
3362  }  }
3363    
3364    

Legend:
Removed from v.1.89  
changed lines
  Added in v.1.90

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26