[Midnightbsd-cvs] src [6528] trunk/sbin/sysctl/sysctl.c: strsep

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Dec 22 16:48:28 EST 2013


Revision: 6528
          http://svnweb.midnightbsd.org/src/?rev=6528
Author:   laffer1
Date:     2013-12-22 16:48:28 -0500 (Sun, 22 Dec 2013)
Log Message:
-----------
strsep

Modified Paths:
--------------
    trunk/sbin/sysctl/sysctl.c

Modified: trunk/sbin/sysctl/sysctl.c
===================================================================
--- trunk/sbin/sysctl/sysctl.c	2013-12-22 21:45:05 UTC (rev 6527)
+++ trunk/sbin/sysctl/sysctl.c	2013-12-22 21:48:28 UTC (rev 6528)
@@ -62,7 +62,7 @@
 static int	Nflag, nflag, oflag, qflag, xflag, warncount;
 
 static int	oidfmt(int *, int, char *, u_int *);
-static void	parse(char *);
+static void	parse(const char *);
 static int	show_var(int *, int);
 static int	sysctl_all(int *oid, int len);
 static int	name2oid(char *, int *);
@@ -161,7 +161,7 @@
  * Set a new value if requested.
  */
 static void
-parse(char *string)
+parse(const char *string)
 {
 	int len, i, j;
 	void *newval = 0;
@@ -176,12 +176,11 @@
 	char *cp, *bufp, buf[BUFSIZ], *endptr, fmt[BUFSIZ];
 	u_int kind;
 
-	bufp = buf;
+	cp = buf;
 	if (snprintf(buf, BUFSIZ, "%s", string) >= BUFSIZ)
 		errx(1, "oid too long: '%s'", string);
-	if ((cp = strchr(string, '=')) != NULL) {
-		*strchr(buf, '=') = '\0';
-		*cp++ = '\0';
+	bufp = strsep(&cp, "=");
+	if (cp != NULL) {
 		while (isspace(*cp))
 			cp++;
 		newval = cp;



More information about the Midnightbsd-cvs mailing list