diff --git a/src/utils/misc.c b/src/utils/misc.c index ab82e377129f6463d4734338d60e2c0647a4fb8b..5a3c267e01152e18e0894fbf75adff9776803c86 100644 --- a/src/utils/misc.c +++ b/src/utils/misc.c @@ -11,22 +11,22 @@ void misc_getioerrmsg(char *s, long i) { - sprintf(s, "misc_getioerrmsg Error number %ld", i); + sprintf(s, "misc_getioerrmsg Error number %ld", i); } #if defined __FreeBSD__ || defined __bsdi__ char *cuserid(char *s) { - char *sp; - static char sbuf[L_cuserid + 1]; + char *sp; + static char sbuf[L_cuserid + 1]; - if ((sp = getenv("USER")) == NULL) { - if (s != NULL) - s[0] = '\0'; - return NULL; - } - return strncpy(s != NULL ? s : sbuf, sp, L_cuserid); + if ((sp = getenv("USER")) == NULL) { + if (s != NULL) + s[0] = '\0'; + return NULL; + } + return strncpy(s != NULL ? s : sbuf, sp, L_cuserid); } #endif @@ -40,33 +40,33 @@ char *cuserid(char *s) */ char *tilde_expand(char *s) { -char *name; -char *ret = NULL; -size_t len = 0; -struct passwd *pw; + char *name; + char *ret = NULL; + size_t len = 0; + struct passwd *pw; - if (*s == '~') { - if (strlen(s) > 1) - len = strcspn(s+1, "/"); - if (len > 0) { - name = (char *) Malloc(len + 1); - strncpy(name, s+1, len); - name[len] = '\0'; - pw = getpwnam(name); - Free(name); - } else { - pw = getpwuid( geteuid() ); - } - if (pw != NULL) { - ret = (char *) Malloc(strlen(pw->pw_dir) + strlen(s) - len); - strcpy(ret,pw->pw_dir); - if (strlen(s) > len + 1) - strcat(ret, s + len + 1); - } - } - if (ret == NULL) - ret = strdup(s); - return ret; + if (*s == '~') { + if (strlen(s) > 1) + len = strcspn(s+1, "/"); + if (len > 0) { + name = (char *) Malloc(len + 1); + strncpy(name, s+1, len); + name[len] = '\0'; + pw = getpwnam(name); + Free(name); + } else { + pw = getpwuid( geteuid() ); + } + if (pw != NULL) { + ret = (char *) Malloc(strlen(pw->pw_dir) + strlen(s) - len); + strcpy(ret,pw->pw_dir); + if (strlen(s) > len + 1) + strcat(ret, s + len + 1); + } + } + if (ret == NULL) + ret = strdup(s); + return ret; } #else @@ -76,19 +76,19 @@ struct passwd *pw; */ char *tilde_expand(char *s) { -char *hp; -char *ret = NULL; + char *hp; + char *ret = NULL; - if (*s == '~' && (hp = getenv("HOME")) != NULL) { - if ((ret = (char *) Malloc(strlen(hp) + strlen(s))) != NULL) { - strcpy(ret, hp); - if (strlen(s) > 1) - strcat(ret, s + 1); - } - } - if (ret == NULL) - ret = strdup(s); - return ret; + if (*s == '~' && (hp = getenv("HOME")) != NULL) { + if ((ret = (char *) Malloc(strlen(hp) + strlen(s))) != NULL) { + strcpy(ret, hp); + if (strlen(s) > 1) + strcat(ret, s + 1); + } + } + if (ret == NULL) + ret = strdup(s); + return ret; } #endif