opnsense-ports/devel/gperf/files/patch-offsetof
Franco Fichtner 8cb1a96ede ports: pull in a snapshot of the FreeBSD ports tree
Taken from:	https://github.com/freebsd/freebsd-ports.git
Commit id:	5070672073b68be364139bc6b3a89100bd17d331
2014-11-09 14:03:21 +01:00

26 lines
971 B
Text

--- src/output.cc 2007-03-31 08:16:05.000000000 -0700
+++ src/output.cc 2008-05-27 16:07:01.000000000 -0700
@@ -1106,9 +1106,7 @@ output_keyword_entry (KeywordExt *temp,
if (option[TYPE])
printf ("{");
if (option[SHAREDLIB])
- printf ("(int)(long)&((struct %s_t *)0)->%s_str%d",
- option.get_stringpool_name (), option.get_stringpool_name (),
- stringpool_index);
+ printf("offsetof(struct %s_t, %s_str%d)", option.get_stringpool_name (), option.get_stringpool_name (), stringpool_index);
else
output_string (temp->_allchars, temp->_allchars_length);
if (option[TYPE])
@@ -2035,8 +2033,11 @@ Output::output ()
printf ("%s\n", _struct_decl);
}
- if (option[INCLUDE])
+ if (option[INCLUDE]) {
printf ("#include <string.h>\n"); /* Declare strlen(), strcmp(), strncmp(). */
+ if (option[SHAREDLIB])
+ printf("#include <stddef.h>\n"); /* Declare offsetof() */
+ }
if (!option[ENUM])
{