diff options
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 9 | ||||
| -rw-r--r-- | lib-src/ebrowse.c | 19 |
2 files changed, 19 insertions, 9 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 0e4cf0b2833..62ee45aac51 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2013-06-21 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Use C99-style flexible array members if available. | ||
| 4 | * ebrowse.c (struct member, struct alias, struct sym): | ||
| 5 | Use FLEXIBLE_ARRAY_MEMBER. | ||
| 6 | (add_sym, add_member, make_namespace, register_namespace_alias): | ||
| 7 | Use offsetof (struct, flex_array_member), not sizeof (struct), as | ||
| 8 | that ports better to pre-C99 non-GCC. | ||
| 9 | |||
| 1 | 2013-05-29 Eli Zaretskii <eliz@gnu.org> | 10 | 2013-05-29 Eli Zaretskii <eliz@gnu.org> |
| 2 | 11 | ||
| 3 | * Makefile.in (mostlyclean): Remove *.res files. | 12 | * Makefile.in (mostlyclean): Remove *.res files. |
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c index 3a237daf5f8..81d0cf0a19e 100644 --- a/lib-src/ebrowse.c +++ b/lib-src/ebrowse.c | |||
| @@ -237,7 +237,7 @@ struct member | |||
| 237 | char *def_regexp; /* Regular expression matching definition. */ | 237 | char *def_regexp; /* Regular expression matching definition. */ |
| 238 | const char *def_filename; /* File name of definition. */ | 238 | const char *def_filename; /* File name of definition. */ |
| 239 | int def_pos; /* Buffer position of definition. */ | 239 | int def_pos; /* Buffer position of definition. */ |
| 240 | char name[1]; /* Member name. */ | 240 | char name[FLEXIBLE_ARRAY_MEMBER]; /* Member name. */ |
| 241 | }; | 241 | }; |
| 242 | 242 | ||
| 243 | /* Structures of this type are used to connect class structures with | 243 | /* Structures of this type are used to connect class structures with |
| @@ -256,7 +256,7 @@ struct alias | |||
| 256 | struct alias *next; /* Next in list. */ | 256 | struct alias *next; /* Next in list. */ |
| 257 | struct sym *namesp; /* Namespace in which defined. */ | 257 | struct sym *namesp; /* Namespace in which defined. */ |
| 258 | struct link *aliasee; /* List of aliased namespaces (A::B::C...). */ | 258 | struct link *aliasee; /* List of aliased namespaces (A::B::C...). */ |
| 259 | char name[1]; /* Alias name. */ | 259 | char name[FLEXIBLE_ARRAY_MEMBER]; /* Alias name. */ |
| 260 | }; | 260 | }; |
| 261 | 261 | ||
| 262 | /* The structure used to describe a class in the symbol table, | 262 | /* The structure used to describe a class in the symbol table, |
| @@ -280,7 +280,7 @@ struct sym | |||
| 280 | const char *filename; /* File in which it can be found. */ | 280 | const char *filename; /* File in which it can be found. */ |
| 281 | const char *sfilename; /* File in which members can be found. */ | 281 | const char *sfilename; /* File in which members can be found. */ |
| 282 | struct sym *namesp; /* Namespace in which defined. . */ | 282 | struct sym *namesp; /* Namespace in which defined. . */ |
| 283 | char name[1]; /* Name of the class. */ | 283 | char name[FLEXIBLE_ARRAY_MEMBER]; /* Name of the class. */ |
| 284 | }; | 284 | }; |
| 285 | 285 | ||
| 286 | /* Experimental: Print info for `--position-info'. We print | 286 | /* Experimental: Print info for `--position-info'. We print |
| @@ -567,8 +567,8 @@ add_sym (const char *name, struct sym *nested_in_class) | |||
| 567 | puts (name); | 567 | puts (name); |
| 568 | } | 568 | } |
| 569 | 569 | ||
| 570 | sym = (struct sym *) xmalloc (sizeof *sym + strlen (name)); | 570 | sym = xmalloc (offsetof (struct sym, name) + strlen (name) + 1); |
| 571 | memset (sym, 0, sizeof *sym); | 571 | memset (sym, 0, offsetof (struct sym, name)); |
| 572 | strcpy (sym->name, name); | 572 | strcpy (sym->name, name); |
| 573 | sym->namesp = scope; | 573 | sym->namesp = scope; |
| 574 | sym->next = class_table[h]; | 574 | sym->next = class_table[h]; |
| @@ -852,7 +852,8 @@ add_global_decl (char *name, char *regexp, int pos, unsigned int hash, int var, | |||
| 852 | static struct member * | 852 | static struct member * |
| 853 | add_member (struct sym *cls, char *name, int var, int sc, unsigned int hash) | 853 | add_member (struct sym *cls, char *name, int var, int sc, unsigned int hash) |
| 854 | { | 854 | { |
| 855 | struct member *m = (struct member *) xmalloc (sizeof *m + strlen (name)); | 855 | struct member *m = xmalloc (offsetof (struct member, name) |
| 856 | + strlen (name) + 1); | ||
| 856 | struct member **list; | 857 | struct member **list; |
| 857 | struct member *p; | 858 | struct member *p; |
| 858 | struct member *prev; | 859 | struct member *prev; |
| @@ -962,8 +963,8 @@ mark_inherited_virtual (void) | |||
| 962 | static struct sym * | 963 | static struct sym * |
| 963 | make_namespace (char *name, struct sym *context) | 964 | make_namespace (char *name, struct sym *context) |
| 964 | { | 965 | { |
| 965 | struct sym *s = (struct sym *) xmalloc (sizeof *s + strlen (name)); | 966 | struct sym *s = xmalloc (offsetof (struct sym, name) + strlen (name) + 1); |
| 966 | memset (s, 0, sizeof *s); | 967 | memset (s, 0, offsetof (struct sym, name)); |
| 967 | strcpy (s->name, name); | 968 | strcpy (s->name, name); |
| 968 | s->next = all_namespaces; | 969 | s->next = all_namespaces; |
| 969 | s->namesp = context; | 970 | s->namesp = context; |
| @@ -1046,7 +1047,7 @@ register_namespace_alias (char *new_name, struct link *old_name) | |||
| 1046 | if (streq (new_name, al->name) && (al->namesp == current_namespace)) | 1047 | if (streq (new_name, al->name) && (al->namesp == current_namespace)) |
| 1047 | return; | 1048 | return; |
| 1048 | 1049 | ||
| 1049 | al = (struct alias *) xmalloc (sizeof *al + strlen (new_name)); | 1050 | al = xmalloc (offsetof (struct alias, name) + strlen (new_name) + 1); |
| 1050 | strcpy (al->name, new_name); | 1051 | strcpy (al->name, new_name); |
| 1051 | al->next = namespace_alias_table[h]; | 1052 | al->next = namespace_alias_table[h]; |
| 1052 | al->namesp = current_namespace; | 1053 | al->namesp = current_namespace; |