From 92ff7f21ad0b167f8d742a9d7b5f93704a57619c Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Thu, 24 Apr 2008 02:02:49 +0000 Subject: Major coding style cleanup. Updated all shared code from my other projects. The configure option requesting AFS kaserver support (and thus building kasetkey) is now --with-kaserver instead of --with-afs. If KRB5_CONFIG was explicitly set in the environment, don't use a different krb5-config based on --with-krb4 or --with-krb5. If krb5-config isn't executable, don't use it. This allows one to force library probing by setting KRB5_CONFIG to point to a nonexistent file. Sanity-check the results of krb5-config before proceeding and error out in configure if they don't work. Stop setting Stanford-specific compile-time defaults for the wallet server and port. --- util/concat.c | 75 +++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 33 deletions(-) (limited to 'util/concat.c') diff --git a/util/concat.c b/util/concat.c index 65ca04c..1d08e08 100644 --- a/util/concat.c +++ b/util/concat.c @@ -1,39 +1,42 @@ -/* $Id$ -** -** Concatenate strings with dynamic memory allocation. -** -** Written by Russ Allbery -** This work is hereby placed in the public domain by its author. -** -** Usage: -** -** string = concat(string1, string2, ..., (char *) 0); -** path = concatpath(base, name); -** -** Dynamically allocates (using xmalloc) sufficient memory to hold all of -** the strings given and then concatenates them together into that -** allocated memory, returning a pointer to it. Caller is responsible for -** freeing. Assumes xmalloc is available. The last argument must be a -** null pointer (to a char *, if you actually find a platform where it -** matters). -** -** concatpath is similar, except that it only takes two arguments. If the -** second argument begins with / or ./, a copy of it is returned; -** otherwise, the first argument, a slash, and the second argument are -** concatenated together and returned. This is useful for building file -** names where names that aren't fully qualified are qualified with some -** particular directory. -*/ +/* $Id$ + * + * Concatenate strings with dynamic memory allocation. + * + * Usage: + * + * string = concat(string1, string2, ..., (char *) 0); + * path = concatpath(base, name); + * + * Dynamically allocates (using xmalloc) sufficient memory to hold all of the + * strings given and then concatenates them together into that allocated + * memory, returning a pointer to it. Caller is responsible for freeing. + * Assumes xmalloc is available. The last argument must be a null pointer (to + * a char *, if you actually find a platform where it matters). + * + * concatpath is similar, except that it only takes two arguments. If the + * second argument begins with / or ./, a copy of it is returned; otherwise, + * the first argument, a slash, and the second argument are concatenated + * together and returned. This is useful for building file names where names + * that aren't fully qualified are qualified with some particular directory. + * + * Written by Russ Allbery + * This work is hereby placed in the public domain by its author. + */ #include -#include +#include #include /* Abbreviation for cleaner code. */ -#define VA_NEXT(var, type) ((var) = (type) va_arg(args, type)) +#define VA_NEXT(var, type) ((var) = (type) va_arg(args, type)) -/* ANSI C requires at least one named parameter. */ + +/* + * Concatenate all of the arguments into a newly allocated string. ANSI C + * requires at least one named parameter, but it's not treated any different + * than the rest. + */ char * concat(const char *first, ...) { @@ -49,10 +52,12 @@ concat(const char *first, ...) va_end(args); length++; - /* Create the string. Doing the copy ourselves avoids useless string - traversals of result, if using strcat, or string, if using strlen to - increment a pointer into result, at the cost of losing the native - optimization of strcat if any. */ + /* + * Create the string. Doing the copy ourselves avoids useless string + * traversals of result, if using strcat, or string, if using strlen to + * increment a pointer into result, at the cost of losing the native + * optimization of strcat if any. + */ result = xmalloc(length); p = result; va_start(args, first); @@ -66,6 +71,10 @@ concat(const char *first, ...) } +/* + * Concatenate name with base, unless name begins with / or ./. Return the + * new string in newly allocated memory. + */ char * concatpath(const char *base, const char *name) { -- cgit v1.2.3