From owner-svn-src-all@freebsd.org Wed Jul 15 18:49:16 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A67549A2AB9; Wed, 15 Jul 2015 18:49:16 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 968741D7A; Wed, 15 Jul 2015 18:49:16 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svnmir.geo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6FInGS2011896; Wed, 15 Jul 2015 18:49:16 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by svnmir.geo.freebsd.org (8.14.9/8.14.9/Submit) id t6FInGBg011895; Wed, 15 Jul 2015 18:49:16 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201507151849.t6FInGBg011895@svnmir.geo.freebsd.org> X-Authentication-Warning: svnmir.geo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Wed, 15 Jul 2015 18:49:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285610 - head/usr.bin/calendar X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jul 2015 18:49:16 -0000 Author: bapt Date: Wed Jul 15 18:49:15 2015 New Revision: 285610 URL: https://svnweb.freebsd.org/changeset/base/285610 Log: Fix trimming spaces writing at index -1 if an empty string is passed Submitted by: Gennady Proskurin Modified: head/usr.bin/calendar/io.c Modified: head/usr.bin/calendar/io.c ============================================================================== --- head/usr.bin/calendar/io.c Wed Jul 15 18:18:07 2015 (r285609) +++ head/usr.bin/calendar/io.c Wed Jul 15 18:49:15 2015 (r285610) @@ -87,11 +87,16 @@ static void trimlr(char **buf) { char *walk = *buf; + char *last; while (isspace(*walk)) walk++; - while (isspace(walk[strlen(walk) -1])) - walk[strlen(walk) -1] = '\0'; + if (*walk != '\0') { + last = walk + strlen(walk) - 1; + while (last > walk && isspace(*last)) + last--; + *(last+1) = 0; + } *buf = walk; }