if (*arg != '-') { lookup(arg, ls, want); /* * The lookup mask ("want") is cumulative and it's * resetable only when it has been already used. * * whereis -b -m foo :'foo' mask=BIN|MAN * whereis -b foo bar :'foo' and 'bar' mask=BIN|MAN * whereis -b foo -m bar :'foo' mask=BIN; 'bar' mask=MAN */ want_resetable = 1; continue; } for (++arg; arg && *arg; arg++) { DBG(ARGV, ul_debug(" arg: %s", arg)); switch (*arg) { case 'f': break; case 'u': uflag = 1; break; case 'B': if (*(arg + 1)) usage(stderr); i++; free_dirlist(&ls, BIN_DIR); construct_dirlist_from_argv( &ls, &i, argc, argv, BIN_DIR); break; case 'M': if (*(arg + 1)) usage(stderr); i++; free_dirlist(&ls, MAN_DIR); construct_dirlist_from_argv( &ls, &i, argc, argv, MAN_DIR); break; case 'S': if (*(arg + 1)) usage(stderr); i++; free_dirlist(&ls, SRC_DIR); construct_dirlist_from_argv( &ls, &i, argc, argv, SRC_DIR); break; case 'b': if (want_resetable) { want = ALL_DIRS; want_resetable = 0; } want = want == ALL_DIRS ? BIN_DIR : want | BIN_DIR; break; case 'm': if (want_resetable) { want = ALL_DIRS; want_resetable = 0; } want = want == ALL_DIRS ? MAN_DIR : want | MAN_DIR; break; case 's': if (want_resetable) { want = ALL_DIRS; want_resetable = 0; } want = want == ALL_DIRS ? SRC_DIR : want | SRC_DIR; break; case 'l': list_dirlist(ls); break; case 'V': printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': usage(stdout); default: usage(stderr); } if (arg_i < i)/* moved to the next argv[] item */ break; } } free_dirlist(&ls, ALL_DIRS); return EXIT_SUCCESS; }
|