/* $OpenLDAP$ */
-/*
- * Copyright 2002-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2008 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
*/
#include "portable.h"
ptr = (char *)fmt;
s2 = str;
fm2[0] = '%';
- if (n)
+ if (n) {
end = str + n;
- else
+ } else {
end = NULL;
+ }
for (pct = strchr(ptr, '%'); pct; pct = strchr(ptr, '%')) {
len = pct-ptr;
if (len < pct-ptr) return -1;
for (pct++, f2 = fm2+1; isdigit(*pct);) *f2++ = *pct++;
if (*pct == 'l') *f2++ = *pct++;
- if (*pct == '%') *s2++ = '%';
- else {
+ if (*pct == '%') {
+ *s2++ = '%';
+ } else {
*f2++ = *pct;
*f2 = '\0';
if (*pct == 's') {
} else {
s2 += sprintf(s2, fm2, ss);
}
- } else
+ } else {
s2 += sprintf(s2, fm2, va_arg(ap, int));
+ }
}
ptr = pct + 1;
}