From f25da8d01f8d783fff627a95628a73b037526245 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 10 Mar 2000 08:24:48 +0000 Subject: * string/argz-stringify.c (__argz_stringify): Fix loop termination conditions so as not to clobber the final '\0' when there is only one element in the vector. --- ChangeLog | 6 ++++++ string/argz-stringify.c | 9 ++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e9b7ff..ef6d64c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-02-23 Roland McGrath + + * string/argz-stringify.c (__argz_stringify): Fix loop termination + conditions so as not to clobber the final '\0' when there is only one + element in the vector. + 2000-03-09 Roland McGrath * io/sys/stat.h: Fix inverted sense of `defined __S_IFSOCK' test, diff --git a/string/argz-stringify.c b/string/argz-stringify.c index 0bbc807..83ff119 100644 --- a/string/argz-stringify.c +++ b/string/argz-stringify.c @@ -1,7 +1,7 @@ /* Routines for dealing with '\0' separated arg vectors. - Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. + Copyright (C) 1995,96,97,2000 Free Software Foundation, Inc. This file is part of the GNU C Library. - Written by Miles Bader + Written by Miles Bader The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -27,15 +27,14 @@ void __argz_stringify (char *argz, size_t len, int sep) { if (len > 0) - do + while (1) { size_t part_len = strnlen (argz, len); argz += part_len; len -= part_len; - if (len == 0) + if (len-- <= 1) /* includes final '\0' we want to stop at */ break; *argz++ = sep; } - while (--len > 0); } weak_alias (__argz_stringify, argz_stringify) -- cgit v1.1