diff utils.c @ 18:c08a947d8f30

deal with macro parameters
author David A. Holland
date Mon, 20 Dec 2010 01:51:47 -0500
parents 9dda765ee85c
children 40748b097655
line wrap: on
line diff
--- a/utils.c	Mon Dec 20 01:15:43 2010 -0500
+++ b/utils.c	Mon Dec 20 01:51:47 2010 -0500
@@ -108,3 +108,26 @@
 	return ret;
 }
 
+size_t
+notrailingws(char *buf, size_t len)
+{
+	while (len > 0 && strchr(ws, buf[len-1])) {
+		buf[--len] = '\0';
+	}
+	return len;
+}
+
+bool
+is_identifier(const char *str)
+{
+	size_t len;
+
+	len = strlen(str);
+	if (len != strspn(str, alnum)) {
+		return false;
+	}
+	if (str[0] >= '0' && str[0] <= '9') {
+		return false;
+	}
+	return true;
+}