aboutsummaryrefslogtreecommitdiff
path: root/gcc/system.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/system.h')
-rw-r--r--gcc/system.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/system.h b/gcc/system.h
index adde3e2..17a6a55 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1305,4 +1305,25 @@ startswith (const char *str, const char *prefix)
return strncmp (str, prefix, strlen (prefix)) == 0;
}
+/* Strip white spaces from STRING with LEN length.
+ A stripped string is returned and LEN is updated accordingly. */
+
+static inline char *
+strip_whitespaces (char *string, size_t *len)
+{
+ while (string[0] == ' ' || string[0] == '\t')
+ {
+ --(*len);
+ ++string;
+ }
+
+ while (string[*len - 1] == ' ' || string[*len - 1] == '\t')
+ {
+ string[*len - 1] = '\0';
+ --(*len);
+ }
+
+ return string;
+}
+
#endif /* ! GCC_SYSTEM_H */