lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <5ccfcadc6adc64bb563ae963a20aca1c3b27d6d4.1463058396.git.jani.nikula@intel.com>
Date:	Thu, 12 May 2016 16:15:42 +0300
From:	Jani Nikula <jani.nikula@...el.com>
To:	Jonathan Corbet <corbet@....net>, linux-kernel@...r.kernel.org,
	linux-doc@...r.kernel.org
Cc:	jani.nikula@...el.com
Subject: [PATCH 7/9] docproc: abstract terminating lines at first space

Cleaner code. Also fixes a bug when F or P directives didn't in fact
have space.

Signed-off-by: Jani Nikula <jani.nikula@...el.com>
---
 scripts/docproc.c | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/scripts/docproc.c b/scripts/docproc.c
index bc900310b431..a933e054402d 100644
--- a/scripts/docproc.c
+++ b/scripts/docproc.c
@@ -430,6 +430,21 @@ static void find_all_symbols(char *filename)
 	}
 }
 
+/*
+ * Terminate s at first space, if any. If there was a space, return pointer to
+ * the character after that. Otherwise, return pointer to the terminating NUL.
+ */
+static char *chomp(char *s)
+{
+	while (*s && !isspace(*s))
+		s++;
+
+	if (*s)
+		*s++ = '\0';
+
+	return s;
+}
+
 /* Return pointer to directive content, or NULL if not a directive. */
 static char *is_directive(char *line)
 {
@@ -460,27 +475,22 @@ static void parse_file(FILE *infile)
 			continue;
 		}
 
-		s = p + 1;
 		switch (*p++) {
 		case 'E':
-			while (*s && !isspace(*s)) s++;
-			*s = '\0';
+			chomp(p);
 			externalfunctions(p);
 			break;
 		case 'I':
-			while (*s && !isspace(*s)) s++;
-			*s = '\0';
+			chomp(p);
 			internalfunctions(p);
 			break;
 		case 'D':
-			while (*s && !isspace(*s)) s++;
-			*s = '\0';
+			chomp(p);
 			symbolsonly(p);
 			break;
 		case 'F':
 			/* filename */
-			while (*s && !isspace(*s)) s++;
-			*s++ = '\0';
+			s = chomp(p);
 			/* function names */
 			while (isspace(*s))
 				s++;
@@ -488,16 +498,14 @@ static void parse_file(FILE *infile)
 			break;
 		case 'P':
 			/* filename */
-			while (*s && !isspace(*s)) s++;
-			*s++ = '\0';
+			s = chomp(p);
 			/* DOC: section name */
 			while (isspace(*s))
 				s++;
 			docsection(p, s);
 			break;
 		case 'C':
-			while (*s && !isspace(*s)) s++;
-			*s = '\0';
+			chomp(p);
 			if (findall)
 				findall(p);
 			break;
-- 
2.1.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ