diff options
author | H.J. Lu <hongjiu.lu@intel.com> | 2014-07-29 15:19:22 +0000 |
---|---|---|
committer | H.J. Lu <hjl@gcc.gnu.org> | 2014-07-29 08:19:22 -0700 |
commit | 20e3f942cca8ab06dda66be598b3166066679234 (patch) | |
tree | d8cfda64985649cf37e145db703ca2375d6d98bb /gcc | |
parent | b8e6830b3446b34cb3aee27d94bca490546c7d07 (diff) | |
download | gcc-20e3f942cca8ab06dda66be598b3166066679234.zip gcc-20e3f942cca8ab06dda66be598b3166066679234.tar.gz gcc-20e3f942cca8ab06dda66be598b3166066679234.tar.bz2 |
Replace strtok with strtoken
PR bootstrap/61914
* gengtype.c (strtoken): New function.
(create_user_defined_type): Replace strtok with strtoken.
From-SVN: r213213
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/gengtype.c | 39 |
2 files changed, 43 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 64191a7..891fc92 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-07-29 H.J. Lu <hongjiu.lu@intel.com> + + PR bootstrap/61914 + * gengtype.c (strtoken): New function. + (create_user_defined_type): Replace strtok with strtoken. + 2014-07-29 Nathan Sidwell <nathan@acm.org> * gcov-io.c (gcov_var): Make hidden. diff --git a/gcc/gengtype.c b/gcc/gengtype.c index ffe3f94..e66941b 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -569,6 +569,40 @@ do_scalar_typedef (const char *s, struct fileloc *pos) do_typedef (s, &scalar_nonchar, pos); } +/* Similar to strtok_r. */ + +static char * +strtoken (char *str, const char *delim, char **next) +{ + char *p; + + if (str == NULL) + str = *next; + + /* Skip the leading delimiters. */ + str += strspn (str, delim); + if (*str == '\0') + /* This is an empty token. */ + return NULL; + + /* The current token. */ + p = str; + + /* Find the next delimiter. */ + str += strcspn (str, delim); + if (*str == '\0') + /* This is the last token. */ + *next = str; + else + { + /* Terminate the current token. */ + *str = '\0'; + /* Advance to the next token. */ + *next = str + 1; + } + + return p; +} /* Define TYPE_NAME to be a user defined type at location POS. */ @@ -599,7 +633,8 @@ create_user_defined_type (const char *type_name, struct fileloc *pos) comma-separated list of strings, implicitly assumed to be type names, potentially with "*" characters. */ char *arg = open_bracket + 1; - char *type_id = strtok (arg, ",>"); + char *next; + char *type_id = strtoken (arg, ",>", &next); pair_p fields = 0; while (type_id) { @@ -628,7 +663,7 @@ create_user_defined_type (const char *type_name, struct fileloc *pos) arg_type = resolve_typedef (field_name, pos); fields = create_field_at (fields, arg_type, field_name, 0, pos); - type_id = strtok (0, ",>"); + type_id = strtoken (0, ",>", &next); } /* Associate the field list to TY. */ |