summaryrefslogtreecommitdiff
path: root/gcc/gensupport.c
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-12 18:43:33 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-12 18:43:33 +0000
commitbe46690ee3370d9008b0220bfa7074563edd7ded (patch)
tree041a0c07e04b7b1e912cc3fbfff87c4cb5742d5e /gcc/gensupport.c
parent0ef911744f03203291e910fd511fc5fbe17b692f (diff)
downloadgcc-be46690ee3370d9008b0220bfa7074563edd7ded.tar.gz
* gensupport.c (n_comma_elts): Moved here from genattrtab.c.
(scan_comma_elt): New function. Accepts whitespace in comma lists. * gensupport.h: Prototype new routines. * genattr.c (gen_attr): Use scan_comma_elt. Avoid unnecessary use of printf. * genattrtab.c (n_comma_elts): Moved to gensupport.c. (next_comma_elt): Use scan_comma_elt. * config/i386/i386.md: Use new attribute notation to break up long lines in define_attr forms. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53403 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gensupport.c')
-rw-r--r--gcc/gensupport.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/gcc/gensupport.c b/gcc/gensupport.c
index d7cb6732145..e6292d9981f 100644
--- a/gcc/gensupport.c
+++ b/gcc/gensupport.c
@@ -1,5 +1,5 @@
/* Support routines for the various generation passes.
- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GCC.
@@ -1099,3 +1099,51 @@ read_md_rtx (lineno, seqnr)
return desc;
}
+
+/* Given a string, return the number of comma-separated elements in it.
+ Return 0 for the null string. */
+int
+n_comma_elts (s)
+ const char *s;
+{
+ int n;
+
+ if (*s == '\0')
+ return 0;
+
+ for (n = 1; *s; s++)
+ if (*s == ',')
+ n++;
+
+ return n;
+}
+
+/* Given a pointer to a (char *), return a pointer to the beginning of the
+ next comma-separated element in the string. Advance the pointer given
+ to the end of that element. Return NULL if at end of string. Caller
+ is responsible for copying the string if necessary. White space between
+ a comma and an element is ignored. */
+
+const char *
+scan_comma_elt (pstr)
+ const char **pstr;
+{
+ const char *start;
+ const char *p = *pstr;
+
+ if (*p == ',')
+ p++;
+ while (ISSPACE(*p))
+ p++;
+
+ if (*p == '\0')
+ return NULL;
+
+ start = p;
+
+ while (*p != ',' && *p != '\0')
+ p++;
+
+ *pstr = p;
+ return start;
+}