diff options
author | Ken Raeburn <raeburn@mit.edu> | 2011-09-04 23:52:34 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2011-09-04 23:52:34 +0000 |
commit | 4ba58f9b6b7ccb372f09e31ee3d302ffafd50b15 (patch) | |
tree | f0d339ede66f7af9153dd1fe016a46ee3aa5d372 /src/util/support/path.c | |
parent | 3b5d496d3d63b28ebd2e23242a3422b1fa838e18 (diff) | |
download | krb5-4ba58f9b6b7ccb372f09e31ee3d302ffafd50b15.tar.gz krb5-4ba58f9b6b7ccb372f09e31ee3d302ffafd50b15.tar.xz krb5-4ba58f9b6b7ccb372f09e31ee3d302ffafd50b15.zip |
Reindent per krb5-batch-reindent.el.
Some minor reformatting added in places to avoid exceeding 80 columns.
Used Emacs 22.1 built-in C mode.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25144 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/support/path.c')
-rw-r--r-- | src/util/support/path.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/src/util/support/path.c b/src/util/support/path.c index 221fb4a6a1..7a051abc9e 100644 --- a/src/util/support/path.c +++ b/src/util/support/path.c @@ -54,9 +54,9 @@ find_sep(const char *path) slash = strrchr(path, '/'); backslash = strrchr(path, '\\'); if (slash != NULL && backslash != NULL) - return (slash > backslash) ? slash : backslash; + return (slash > backslash) ? slash : backslash; else - return (slash != NULL) ? slash : backslash; + return (slash != NULL) ? slash : backslash; #else return strrchr(path, '/'); #endif @@ -70,50 +70,50 @@ k5_path_split(const char *path, char **parent_out, char **basename_out) char *parent = NULL, *basename = NULL; if (parent_out != NULL) - *parent_out = NULL; + *parent_out = NULL; if (basename_out != NULL) - *basename_out = NULL; + *basename_out = NULL; pathstart = path; #ifdef WINDOWS_PATHS if (*path != '\0' && path[1] == ':') - pathstart = path + 2; + pathstart = path + 2; #endif sep = find_sep(pathstart); if (sep != NULL) { - bstart = sep + 1; - /* Strip off excess separators before the one we found. */ - pend = sep; - while (pend > pathstart && IS_SEPARATOR(pend[-1])) - pend--; - /* But if we hit the start, keep the whole separator sequence. */ - if (pend == pathstart) - pend = sep + 1; + bstart = sep + 1; + /* Strip off excess separators before the one we found. */ + pend = sep; + while (pend > pathstart && IS_SEPARATOR(pend[-1])) + pend--; + /* But if we hit the start, keep the whole separator sequence. */ + if (pend == pathstart) + pend = sep + 1; } else { - bstart = pathstart; - pend = pathstart; + bstart = pathstart; + pend = pathstart; } if (parent_out) { - parent = malloc(pend - path + 1); - if (parent == NULL) - return ENOMEM; - memcpy(parent, path, pend - path); - parent[pend - path] = '\0'; + parent = malloc(pend - path + 1); + if (parent == NULL) + return ENOMEM; + memcpy(parent, path, pend - path); + parent[pend - path] = '\0'; } if (basename_out) { - basename = strdup(bstart); - if (basename == NULL) { - free(parent); - return ENOMEM; - } + basename = strdup(bstart); + if (basename == NULL) { + free(parent); + return ENOMEM; + } } if (parent_out) - *parent_out = parent; + *parent_out = parent; if (basename_out) - *basename_out = basename; + *basename_out = basename; return 0; } @@ -125,24 +125,24 @@ k5_path_join(const char *path1, const char *path2, char **path_out) *path_out = NULL; if (k5_path_isabs(path2) || *path1 == '\0') { - /* Discard path1 and return a copy of path2. */ - path = strdup(path2); - if (path == NULL) - return ENOMEM; + /* Discard path1 and return a copy of path2. */ + path = strdup(path2); + if (path == NULL) + return ENOMEM; } else { - /* - * Compose path1 and path2, adding a separator if path1 is non-empty - * there's no separator between them already. (*path2 can be a - * separator in the weird case where it starts with /: or \: on - * Windows, and Python doesn't insert a separator in this case.) - */ - c = path1[strlen(path1) - 1]; - if (IS_SEPARATOR(c) || IS_SEPARATOR(*path2)) - ret = asprintf(&path, "%s%s", path1, path2); - else - ret = asprintf(&path, "%s%c%s", path1, SEP, path2); - if (ret < 0) - return ENOMEM; + /* + * Compose path1 and path2, adding a separator if path1 is non-empty + * there's no separator between them already. (*path2 can be a + * separator in the weird case where it starts with /: or \: on + * Windows, and Python doesn't insert a separator in this case.) + */ + c = path1[strlen(path1) - 1]; + if (IS_SEPARATOR(c) || IS_SEPARATOR(*path2)) + ret = asprintf(&path, "%s%s", path1, path2); + else + ret = asprintf(&path, "%s%c%s", path1, SEP, path2); + if (ret < 0) + return ENOMEM; } *path_out = path; return 0; @@ -153,7 +153,7 @@ k5_path_isabs(const char *path) { #ifdef WINDOWS_PATHS if (*path != '\0' && path[1] == ':') - path += 2; + path += 2; return (*path == '/' || *path == '\\'); #else return (*path == '/'); |