SunOS 4.1.3/fixincludes
Bruce Korb
korb@datadesign.com
Thu Oct 15 10:24:00 GMT 1998
Jeffrey A Law wrote:
> In message < 36225270.7B701B83@data-design.com >you write:
> > Fixincludes always makes me crosseyed, so I am attaching *two* diffs:
> > the first is the diff of the definitions file, the second to what I generate as
> > the fixincludes replacement. I think it is right, but please check and
> > complain about or pass on the OS check and the regular expression used
> > to select the file in question.
> Seems reasonable to me.
> jeff
It seemed reasonable to me, too. It turns out my SunOS has fixed versions
of these files and, tho innocuous, we really ought not "fix" unbroken files.
Here is my proposed, "this ought to fix it" patch. It does *not* fix files that
contain parameters for __STDC__ (and, thus indirectly, for __cplusplus):
/*
* On *some* SunOS-es, rpc/auth.h, rpc/clnt.h, rpc/svc.h, and
* rpc/xdr.h need prototypes for its ops function pointers.
*/fix = {
hackname = sun_auth_proto;
files = rpc/auth.h;
files = rpc/clnt.h;
files = rpc/svc.h;
files = rpc/xdr.h;
mach = "*-sun-*";
/*
* Select those files containing '(*name)()' but *not*
* containing '(*name)(junk)'. The change would be innocuous
* but there is no point bothering if the fix is not needed.
*/
select = '\(\*[a-z][a-z_]*\)\(\)';
bypass = '\(\*[a-z][a-z_]*\)\(' "[ \t]*[a-z.].*" '\)';
sed = 's'
'/^\(.*(\*[a-z][a-z_]*)(\)' '\();.*\)'
"/\\\n"
"#ifdef __cplusplus\\\n"
'\1...\2' "\\\n"
"#else\\\n"
'\1\2' "\\\n"
"#endif"
"/";
};
This produces the script:
#
# Fix 73: Sun_Auth_Proto
#
case "$file" in ./rpc/auth.h | \
./rpc/clnt.h | \
./rpc/svc.h | \
./rpc/xdr.h )
case "$target_canonical" in *-sun-* )
if ( test -n "`egrep '\\(\\*[a-z][a-z_]*\\)\\(\\)' $file`" -a \
-z "`egrep '\\(\\*[a-z][a-z_]*\\)\\([ ]*[a-z.].*\\)' $file`"
) > /dev/null 2>&1 ; then
fixlist="${fixlist}
sun_auth_proto"
if [ ! -r ${DESTDIR}/$file ]
then infile=$file
else infile=${DESTDIR}/$file ; fi
sed -e 's/^\(.*(\*[a-z][a-z_]*)(\)\();.*\)/\
#ifdef __cplusplus\
\1...\2\
#else\
\1\2\
#endif/' \
< $infile > ${DESTDIR}/$file.
mv -f ${DESTDIR}/$file. ${DESTDIR}/$file
fi # end of selection 'if'
;; # case end for machine type test
esac
;; # case end for file name test
esac
I have tested this fix with both the programmatic and shell
versions of the output. They both 'do the right thing', I think:
typedef struct XDR {
enum xdr_op x_op; /* operation; fast additional param */
struct xdr_ops {
#ifdef __STDC__
bool_t (*x_getlong)(struct XDR *, long *);
/* get a long from underlying stream */
#else
bool_t (*x_getlong)(); /* get a long from underlying stream */
#endif
...
Remains unchanged. However:
typedef struct XDR {
enum xdr_op x_op; /* operation; fast additional param */
struct xdr_ops {
bool_t (*x_getlong)(); /* get a long from underlying stream */
...
is changed to:
typedef struct XDR {
enum xdr_op x_op; /* operation; fast additional param */
struct xdr_ops {
#ifdef __cplusplus
bool_t (*x_getlong)(...); /* get a long from underlying stream */
#else
bool_t (*x_getlong)(); /* get a long from underlying stream */
#endif
...
P.S. I will upload these changes tomorrow or early next week.
More information about the Gcc-bugs
mailing list