[syslinux] rosh patch V2, isspace

Geert Stappers stappers at stappers.nl
Sun Apr 12 02:47:59 PDT 2009


Op 20090306 om 21:41 schreef Keith Schincke:
> Here is a second version of my patch from last night.
> 
> It uses the provided ctype function isspace and does the same readdir().
> I remove the rosh_issp() function. I admit to being a bit liberal with my
> use of braces and spaces.
> 
> We all of the habit of knowing we can invent a more perfect wheel.
> 
> Let me know if you have any questions.
> 
> Keith

As reminder, the isspace part

diff --git a/com32/rosh/rosh.c b/com32/rosh/rosh.c
index 5eaa47d..b42af58 100644
--- a/com32/rosh/rosh.c
+++ b/com32/rosh/rosh.c
@@ -54,21 +54,6 @@ void rosh_help(int type)
 	}
 }
 
-/* Determine if a character is whitespace
- *	inc	input character
- *	returns	0 if not whitespace
- */
-int rosh_issp(char inc)
-{
-	int rv;
-	switch (inc){
-	case ' ': case '\t':
-		rv = 1;	break;
-	default: rv = 0;
-	}
-	return rv;
-}	/* ros_issp */
-
 /* Search a string for first non-space (' ') character, starting at ipos
  *	istr	input string to parse
  *	ipos	input position to start at
@@ -80,7 +65,7 @@ int rosh_search_nonsp(const char *istr, const int ipos)
 
 	curpos = ipos;
 	c = istr[curpos];
-	while (rosh_issp(c) && c != 0)
+	while (isspace(c) && c != 0)
 		c = istr[++curpos];
 	return curpos;
 }
@@ -97,7 +82,7 @@ int rosh_search_sp(const char *istr, const int ipos)
 
 	curpos = ipos;
 	c = istr[curpos];
-	while (!(rosh_issp(c)) && c != 0)
+	while (!(isspace(c)) && c != 0)
 		c = istr[++curpos];
 	return curpos;
 }
diff --git a/com32/rosh/rosh.h b/com32/rosh/rosh.h
index d7296e1..1eb03cc 100644
--- a/com32/rosh/rosh.h
+++ b/com32/rosh/rosh.h
@@ -37,6 +37,7 @@
 #include <unistd.h>	/* getcwd() */
 #include <errno.h>	/* errno; error macros */
 #include <netinet/in.h>	/* For htonl/ntohl/htons/ntohs */
+#include <ctype.h> 	/* needed for charecter checking */
 
 #include <getkey.h>
 #include <consoles.h>




More information about the Syslinux mailing list