Date: Fri, 13 Dec 2013 18:23:14 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r259320 - stable/10/contrib/gperf/src Message-ID: <201312131823.rBDINETh063470@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Fri Dec 13 18:23:14 2013 New Revision: 259320 URL: http://svnweb.freebsd.org/changeset/base/259320 Log: MFC r258115 (partial); gperf: bring a small update from Apple Developers tools 4.4 From [1] offset.patch Makes use the C offsetof() macro. We are not merging the size_type.patch as it raises some (apparently) bogus warnings and is not really used. [1] http://opensource.apple.com/source/gperf/gperf-9/patches/ Modified: stable/10/contrib/gperf/src/output.cc Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/gperf/src/output.cc ============================================================================== --- stable/10/contrib/gperf/src/output.cc Fri Dec 13 18:21:27 2013 (r259319) +++ stable/10/contrib/gperf/src/output.cc Fri Dec 13 18:23:14 2013 (r259320) @@ -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]) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201312131823.rBDINETh063470>