whereis.c (228991) | whereis.c (278616) |
---|---|
1/* 2 * Copyright �� 2002, J��rg Wunsch 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 18 unchanged lines hidden (view full) --- 27 * 4.3BSD UI-compatible whereis(1) utility. Rewritten from scratch 28 * since the original 4.3BSD version suffers legal problems that 29 * prevent it from being redistributed, and since the 4.4BSD version 30 * was pretty inferior in functionality. 31 */ 32 33#include <sys/types.h> 34 | 1/* 2 * Copyright �� 2002, J��rg Wunsch 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 18 unchanged lines hidden (view full) --- 27 * 4.3BSD UI-compatible whereis(1) utility. Rewritten from scratch 28 * since the original 4.3BSD version suffers legal problems that 29 * prevent it from being redistributed, and since the 4.4BSD version 30 * was pretty inferior in functionality. 31 */ 32 33#include <sys/types.h> 34 |
35__FBSDID("$FreeBSD: head/usr.bin/whereis/whereis.c 228991 2011-12-30 10:59:15Z uqs $"); | 35__FBSDID("$FreeBSD: head/usr.bin/whereis/whereis.c 278616 2015-02-12 05:35:00Z cperciva $"); |
36 37#include <sys/stat.h> 38#include <sys/sysctl.h> 39 40#include <dirent.h> 41#include <err.h> 42#include <errno.h> 43#include <locale.h> --- 216 unchanged lines hidden (view full) --- 260 struct stat sb; 261 struct dirent *dirp; 262 263 /* default to -bms if none has been specified */ 264 if (!opt_b && !opt_m && !opt_s) 265 opt_b = opt_m = opt_s = 1; 266 267 /* -b defaults to default path + /usr/libexec + | 36 37#include <sys/stat.h> 38#include <sys/sysctl.h> 39 40#include <dirent.h> 41#include <err.h> 42#include <errno.h> 43#include <locale.h> --- 216 unchanged lines hidden (view full) --- 260 struct stat sb; 261 struct dirent *dirp; 262 263 /* default to -bms if none has been specified */ 264 if (!opt_b && !opt_m && !opt_s) 265 opt_b = opt_m = opt_s = 1; 266 267 /* -b defaults to default path + /usr/libexec + |
268 * /usr/games + user's path */ | 268 * user's path */ |
269 if (!bindirs) { 270 if (sysctlbyname("user.cs_path", (void *)NULL, &s, 271 (void *)NULL, 0) == -1) 272 err(EX_OSERR, "sysctlbyname(\"user.cs_path\")"); 273 if ((b = malloc(s + 1)) == NULL) 274 abort(); 275 if (sysctlbyname("user.cs_path", b, &s, (void *)NULL, 0) == -1) 276 err(EX_OSERR, "sysctlbyname(\"user.cs_path\")"); 277 nele = 0; 278 decolonify(b, &bindirs, &nele); | 269 if (!bindirs) { 270 if (sysctlbyname("user.cs_path", (void *)NULL, &s, 271 (void *)NULL, 0) == -1) 272 err(EX_OSERR, "sysctlbyname(\"user.cs_path\")"); 273 if ((b = malloc(s + 1)) == NULL) 274 abort(); 275 if (sysctlbyname("user.cs_path", b, &s, (void *)NULL, 0) == -1) 276 err(EX_OSERR, "sysctlbyname(\"user.cs_path\")"); 277 nele = 0; 278 decolonify(b, &bindirs, &nele); |
279 bindirs = realloc(bindirs, (nele + 3) * sizeof(char *)); | 279 bindirs = realloc(bindirs, (nele + 2) * sizeof(char *)); |
280 if (bindirs == NULL) 281 abort(); 282 bindirs[nele++] = PATH_LIBEXEC; | 280 if (bindirs == NULL) 281 abort(); 282 bindirs[nele++] = PATH_LIBEXEC; |
283 bindirs[nele++] = PATH_GAMES; | |
284 bindirs[nele] = NULL; 285 if ((cp = getenv("PATH")) != NULL) { 286 /* don't destroy the original environment... */ 287 if ((b = malloc(strlen(cp) + 1)) == NULL) 288 abort(); 289 strcpy(b, cp); 290 decolonify(b, &bindirs, &nele); 291 } --- 401 unchanged lines hidden --- | 283 bindirs[nele] = NULL; 284 if ((cp = getenv("PATH")) != NULL) { 285 /* don't destroy the original environment... */ 286 if ((b = malloc(strlen(cp) + 1)) == NULL) 287 abort(); 288 strcpy(b, cp); 289 decolonify(b, &bindirs, &nele); 290 } --- 401 unchanged lines hidden --- |