Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Nov 2008 13:44:07 +0000 (UTC)
From:      Dag-Erling Smorgrav <des@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r184630 - projects/quota64/lib/libutil
Message-ID:  <200811041344.mA4Di7BG097980@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: des
Date: Tue Nov  4 13:44:07 2008
New Revision: 184630
URL: http://svn.freebsd.org/changeset/base/184630

Log:
  Avoid assigning a const char * to a char *.
  
  MFC after:	3 weeks

Modified:
  projects/quota64/lib/libutil/login_class.c

Modified: projects/quota64/lib/libutil/login_class.c
==============================================================================
--- projects/quota64/lib/libutil/login_class.c	Tue Nov  4 12:30:31 2008	(r184629)
+++ projects/quota64/lib/libutil/login_class.c	Tue Nov  4 13:44:07 2008	(r184630)
@@ -142,14 +142,13 @@ substvar(const char * var, const struct 
 	int	tildes = 0;
 	int	dollas = 0;
 	char	*p;
+	const char *q;
 
 	if (pwd != NULL) {
-	    /* Count the number of ~'s in var to substitute */
-	    for (p = (char *)var; (p = strchr(p, '~')) != NULL; p++)
-		++tildes;
-	    /* Count the number of $'s in var to substitute */
-	    for (p = (char *)var; (p = strchr(p, '$')) != NULL; p++)
-		++dollas;
+	    for (q = var; *q != '\0'; ++q) {
+		tildes += (*q == '~');
+		dollas += (*q == '$');
+	    }
 	}
 
 	np = malloc(strlen(var) + (dollas * nlen)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811041344.mA4Di7BG097980>