aboutsummaryrefslogtreecommitdiff
path: root/gcc/system.h
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2021-10-04 14:06:14 +0200
committerMartin Liska <mliska@suse.cz>2021-10-19 08:51:32 +0200
commitdf592811f950301ed3b10a08e476dad0f2eff26a (patch)
treec216102d4300a4d9c094dd51fbf023c31369debf /gcc/system.h
parent38f6ee6bfc4633175ca6f6d29e597d379ccae820 (diff)
downloadgcc-df592811f950301ed3b10a08e476dad0f2eff26a.zip
gcc-df592811f950301ed3b10a08e476dad0f2eff26a.tar.gz
gcc-df592811f950301ed3b10a08e476dad0f2eff26a.tar.bz2
target: support spaces in target attribute.
PR target/102374 gcc/ChangeLog: * config/i386/i386-options.c (ix86_valid_target_attribute_inner_p): Strip whitespaces. * system.h (strip_whilespaces): New function. gcc/testsuite/ChangeLog: * gcc.target/i386/pr102374.c: New test.
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 */