X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Fliblber%2Fstdio.c;h=bebfb50a3120eda001fc5499307a087a4c077f7b;hb=966cef8c9a3238efe0c482ad0ee08fd98944d112;hp=7188ccf887c16d29b4072217c56f52eaf6594fb7;hpb=a231098e281d26a7a2fdeedc0bf441ffc2134f8b;p=openldap diff --git a/libraries/liblber/stdio.c b/libraries/liblber/stdio.c index 7188ccf887..bebfb50a31 100644 --- a/libraries/liblber/stdio.c +++ b/libraries/liblber/stdio.c @@ -1,7 +1,16 @@ /* $OpenLDAP$ */ -/* - * Copyright 2002-2003 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2011 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 + * . */ #include "portable.h" @@ -128,10 +137,11 @@ int ber_pvt_vsnprintf( char *str, size_t n, const char *fmt, va_list ap ) 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; @@ -145,8 +155,9 @@ int ber_pvt_vsnprintf( char *str, size_t n, const char *fmt, va_list ap ) 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') { @@ -166,8 +177,9 @@ int ber_pvt_vsnprintf( char *str, size_t n, const char *fmt, va_list ap ) } else { s2 += sprintf(s2, fm2, ss); } - } else + } else { s2 += sprintf(s2, fm2, va_arg(ap, int)); + } } ptr = pct + 1; }