From 9a5834ae8dc3c4b6bb29ee487186a85b89378985 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Sun, 12 May 2002 18:43:33 +0000 Subject: gensupport.c (n_comma_elts): Moved here from genattrtab.c. * 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. From-SVN: r53403 --- gcc/gensupport.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'gcc/gensupport.c') diff --git a/gcc/gensupport.c b/gcc/gensupport.c index d7cb673..e6292d9 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; +} -- cgit v1.1