Prepare for fixincludes on BeOS
Co-Authored-By: Bruce Korb <bkorb@gnu.org> From-SVN: r37959
This commit is contained in:
parent
6864a6c66c
commit
283da1d32d
|
@ -1,3 +1,15 @@
|
|||
2000-12-02 Daniel Berlin <dberlin@redhat.com>
|
||||
Bruce Korb <bkorb@gnu.org>
|
||||
|
||||
* fixinc/*: global substitute /__MSDOS__/SEPARATE_FIX_PROC/
|
||||
* fixinc/mkfixinc.sh: prepare to use Makefile.BEOS for *-*-beos*
|
||||
* fixinc/Makefile.DOS: define SEPARATE_FIX_PROC for build
|
||||
* fixinc/fixfix.c(wrap_fix): avoid wrapping files that
|
||||
use the "__need_" hackery. It breaks them.
|
||||
* fixinc/fixincl.c(process - SEPARATE_FIX_PROC):
|
||||
Sometimes on DOS and BeOS the temp output file cannot be opened.
|
||||
Skip the file noisily. Ought to be fixed instead.
|
||||
|
||||
2000-12-02 Bruce Korb <bkorb@gnu.org>
|
||||
|
||||
From: 2000-11-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
# the DJGPP (aka MS-DOS) port of GCC.
|
||||
|
||||
CFLAGS = -Wall -g -O2
|
||||
FIXINC_DEFS = -DIN_GCC -D__MSDOS__ $(CFLAGS) $(CPPFLAGS) $(INCLUDES)
|
||||
FIXINC_DEFS = -DIN_GCC $(CFLAGS) $(CPPFLAGS) $(INCLUDES) \
|
||||
-D__MSDOS__ -DSEPARATE_FIX_PROC
|
||||
|
||||
CC = gcc
|
||||
SHELL = /bin/sh
|
||||
|
|
|
@ -60,7 +60,7 @@ Boston, MA 02111-1307, USA. */
|
|||
#include "fixlib.h"
|
||||
#define GTYPE_SE_CT 1
|
||||
|
||||
#ifdef __MSDOS__
|
||||
#ifdef SEPARATE_FIX_PROC
|
||||
#include "fixincl.x"
|
||||
#endif
|
||||
|
||||
|
@ -597,12 +597,20 @@ FIX_PROC_HEAD( machine_name_fix )
|
|||
|
||||
FIX_PROC_HEAD( wrap_fix )
|
||||
{
|
||||
tSCC z_no_wrap_pat[] = "^#if.*__need_";
|
||||
static regex_t no_wrapping_re = { NULL, 0, 0 };
|
||||
|
||||
char z_fixname[ 64 ];
|
||||
tCC* pz_src = p_fixd->fix_name;
|
||||
tCC* pz_name = z_fixname;
|
||||
char* pz_dst = z_fixname;
|
||||
int do_end = 0;
|
||||
size_t len = 0;
|
||||
|
||||
if (no_wrapping_re.allocated == 0)
|
||||
compile_re( z_no_wrap_pat, &no_wrapping_re, 0, "no-wrap pattern",
|
||||
"wrap-fix" );
|
||||
|
||||
for (;;) {
|
||||
char ch = *(pz_src++);
|
||||
|
||||
|
@ -627,8 +635,16 @@ FIX_PROC_HEAD( wrap_fix )
|
|||
}
|
||||
}
|
||||
|
||||
printf( "#ifndef FIXINC_%s_CHECK\n", pz_name );
|
||||
printf( "#define FIXINC_%s_CHECK 1\n\n", pz_name );
|
||||
/*
|
||||
* IF we do *not* match the no-wrap re, then we have a double negative.
|
||||
* A double negative means YES.
|
||||
*/
|
||||
if (regexec (&no_wrapping_re, text, 0, NULL, 0) != 0)
|
||||
{
|
||||
printf( "#ifndef FIXINC_%s_CHECK\n", pz_name );
|
||||
printf( "#define FIXINC_%s_CHECK 1\n\n", pz_name );
|
||||
do_end = 1;
|
||||
}
|
||||
|
||||
if (p_fixd->patch_args[1] == (tCC*)NULL)
|
||||
fputs( text, stdout );
|
||||
|
@ -640,7 +656,9 @@ FIX_PROC_HEAD( wrap_fix )
|
|||
fputs( p_fixd->patch_args[2], stdout );
|
||||
}
|
||||
|
||||
printf( "\n#endif /* FIXINC_%s_CHECK */\n", pz_name );
|
||||
if (do_end != 0)
|
||||
printf( "\n#endif /* FIXINC_%s_CHECK */\n", pz_name );
|
||||
|
||||
if (pz_name != z_fixname)
|
||||
free( (void*)pz_name );
|
||||
}
|
||||
|
@ -731,7 +749,7 @@ apply_fix( p_fixd, filname )
|
|||
(*pfe->fix_proc)( filname, buf, p_fixd );
|
||||
}
|
||||
|
||||
#ifdef __MSDOS__
|
||||
#ifdef SEPARATE_FIX_PROC
|
||||
tSCC z_usage[] =
|
||||
"USAGE: applyfix <fix-name> <file-to-fix> <file-source> <file-destination>\n";
|
||||
tSCC z_reopen[] =
|
||||
|
@ -750,7 +768,7 @@ main( argc, argv )
|
|||
if (argc != 5)
|
||||
{
|
||||
usage_failure:
|
||||
fputs( z_usage, stderr );
|
||||
fputs (z_usage, stderr);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -761,15 +779,15 @@ main( argc, argv )
|
|||
if (! ISDIGIT ( *pz ))
|
||||
goto usage_failure;
|
||||
|
||||
idx = strtol( pz, &pz, 10 );
|
||||
idx = strtol (pz, &pz, 10);
|
||||
if ((*pz != NUL) || ((unsigned)idx >= FIX_COUNT))
|
||||
goto usage_failure;
|
||||
pFix = fixDescList + idx;
|
||||
}
|
||||
|
||||
if (freopen( argv[3], "r", stdin ) != stdin)
|
||||
if (freopen (argv[3], "r", stdin) != stdin)
|
||||
{
|
||||
fprintf( stderr, z_reopen, errno, strerror( errno ), argv[3], "in" );
|
||||
fprintf (stderr, z_reopen, errno, strerror( errno ), argv[3], "in");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -783,23 +801,23 @@ main( argc, argv )
|
|||
pz_tmp_dot = strchr( pz_tmp_base, '.' );
|
||||
if (pathconf( pz_tmptmp, _PC_NAME_MAX ) <= 12 /* is this DOS or Windows9X? */
|
||||
&& pz_tmp_dot != (char*)NULL)
|
||||
strcpy( pz_tmp_dot+1, "X" ); /* nuke the original extension */
|
||||
strcpy (pz_tmp_dot+1, "X"); /* nuke the original extension */
|
||||
else
|
||||
strcat( pz_tmptmp, ".X" );
|
||||
if (freopen( pz_tmptmp, "w", stdout ) != stdout)
|
||||
strcat (pz_tmptmp, ".X");
|
||||
if (freopen (pz_tmptmp, "w", stdout) != stdout)
|
||||
{
|
||||
fprintf( stderr, z_reopen, errno, strerror( errno ), pz_tmptmp, "out" );
|
||||
fprintf (stderr, z_reopen, errno, strerror( errno ), pz_tmptmp, "out");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
apply_fix( pFix, argv[1] );
|
||||
close( STDOUT_FILENO );
|
||||
close( STDIN_FILENO );
|
||||
unlink( argv[4] );
|
||||
if (rename( pz_tmptmp, argv[4] ) != 0)
|
||||
apply_fix (pFix, argv[1]);
|
||||
fclose (stdout);
|
||||
fclose (stdin);
|
||||
unlink (argv[4]);
|
||||
if (rename (pz_tmptmp, argv[4]) != 0)
|
||||
{
|
||||
fprintf( stderr, "error %d (%s) renaming %s to %s\n", errno,
|
||||
strerror( errno ), pz_tmptmp, argv[4] );
|
||||
fprintf (stderr, "error %d (%s) renaming %s to %s\n", errno,
|
||||
strerror( errno ), pz_tmptmp, argv[4]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ Boston, MA 02111-1307, USA. */
|
|||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#ifndef __MSDOS__
|
||||
#ifndef SEPARATE_FIX_PROC
|
||||
#include "server.h"
|
||||
#endif
|
||||
|
||||
|
@ -182,7 +182,7 @@ Altering %5d of them\n";
|
|||
}
|
||||
#endif /* DO_STATS */
|
||||
|
||||
# ifdef __MSDOS__
|
||||
# ifdef SEPARATE_FIX_PROC
|
||||
unlink( pz_temp_file );
|
||||
# endif
|
||||
return EXIT_SUCCESS;
|
||||
|
@ -202,7 +202,7 @@ do_version ()
|
|||
*/
|
||||
run_compiles ();
|
||||
sprintf (zBuf, zFmt, program_id);
|
||||
#ifndef __MSDOS__
|
||||
#ifndef SEPARATE_FIX_PROC
|
||||
puts (zBuf + 5);
|
||||
exit (strcmp (run_shell (zBuf), program_id));
|
||||
#else
|
||||
|
@ -298,7 +298,7 @@ ENV_TABLE
|
|||
*/
|
||||
run_compiles ();
|
||||
|
||||
# ifdef __MSDOS__
|
||||
# ifdef SEPARATE_FIX_PROC
|
||||
/* NULL as the first argument to `tempnam' causes it to DTRT
|
||||
wrt the temporary directory where the file will be created. */
|
||||
pz_temp_file = tempnam( NULL, "fxinc" );
|
||||
|
@ -382,7 +382,7 @@ static int
|
|||
machine_matches( p_fixd )
|
||||
tFixDesc *p_fixd;
|
||||
{
|
||||
# ifndef __MSDOS__
|
||||
# ifndef SEPARATE_FIX_PROC
|
||||
tSCC case_fmt[] = "case %s in\n"; /* 9 bytes, plus string */
|
||||
tSCC esac_fmt[] =
|
||||
" )\n echo %s ;;\n* ) echo %s ;;\nesac";/* 4 bytes */
|
||||
|
@ -449,7 +449,7 @@ machine_matches( p_fixd )
|
|||
}
|
||||
|
||||
return BOOL_TRUE;
|
||||
# else /* is __MSDOS__ */
|
||||
# else /* is SEPARATE_FIX_PROC */
|
||||
const char **papz_machs = p_fixd->papz_machs;
|
||||
int invert = (p_fixd->fd_flags & FD_MACH_IFNOT) != 0;
|
||||
for (;;)
|
||||
|
@ -613,7 +613,7 @@ create_file ()
|
|||
the name of the file that we might want to fix
|
||||
Result: APPLY_FIX or SKIP_FIX, depending on the result of the
|
||||
shell script we run. */
|
||||
#ifndef __MSDOS__
|
||||
#ifndef SEPARATE_FIX_PROC
|
||||
static int test_test PARAMS ((tTestDesc *, char *));
|
||||
static int
|
||||
test_test (p_test, pz_test_file)
|
||||
|
@ -812,7 +812,7 @@ extract_quoted_files (pz_data, pz_fixed_file, p_re_match)
|
|||
|
||||
Somebody wrote a *_fix subroutine that we must call.
|
||||
*/
|
||||
#ifndef __MSDOS__
|
||||
#ifndef SEPARATE_FIX_PROC
|
||||
static int internal_fix PARAMS ((int, tFixDesc *));
|
||||
static int
|
||||
internal_fix (read_fd, p_fixd)
|
||||
|
@ -879,10 +879,10 @@ internal_fix (read_fd, p_fixd)
|
|||
apply_fix (p_fixd, pz_curr_file);
|
||||
exit (0);
|
||||
}
|
||||
#endif /* !__MSDOS__ */
|
||||
#endif /* !SEPARATE_FIX_PROC */
|
||||
|
||||
|
||||
#ifdef __MSDOS__
|
||||
#ifdef SEPARATE_FIX_PROC
|
||||
static void
|
||||
fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file)
|
||||
tFixDesc* p_fixd;
|
||||
|
@ -922,16 +922,25 @@ fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file)
|
|||
else /* NOT an "internal" fix: */
|
||||
{
|
||||
size_t parg_size;
|
||||
#ifdef __MSDOS__
|
||||
/* Don't use the "src > dstX; rm -f dst; mv -f dstX dst" trick:
|
||||
dst is a temporary file anyway, so we know there's no other
|
||||
file by that name; and DOS's system(3) doesn't mind to
|
||||
dst is a temporary file anyway, so we know there's no other
|
||||
file by that name; and DOS's system(3) doesn't mind to
|
||||
clobber existing file in redirection. Besides, with DOS 8+3
|
||||
limited file namespace, we can easily lose if dst already has
|
||||
an extension that is 3 or more characters long.
|
||||
The following bizarre use of 'cat' only works on DOS boxes.
|
||||
It is causing the file to be dropped into a temporary file for
|
||||
|
||||
I do not think the 8+3 issue is relevant because all the files
|
||||
we operate on are named "*.h", making 8+2 adequate. Anyway,
|
||||
the following bizarre use of 'cat' only works on DOS boxes.
|
||||
It causes the file to be dropped into a temporary file for
|
||||
'cat' to read (pipes do not work on DOS). */
|
||||
tSCC z_cmd_fmt[] = " %s | cat > %s";
|
||||
#else
|
||||
/* Don't use positional formatting arguments because some lame-o
|
||||
implementations cannot cope :-(. */
|
||||
tSCC z_cmd_fmt[] = " %s > %sX ; rm -f %s; mv -f %sX %s";
|
||||
#endif
|
||||
tCC** ppArgs = p_fixd->patch_args;
|
||||
|
||||
argsize = sizeof( z_cmd_fmt ) + strlen( pz_temp_file )
|
||||
|
@ -1006,7 +1015,12 @@ fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file)
|
|||
/*
|
||||
* add the file machinations.
|
||||
*/
|
||||
sprintf( pz_scan, z_cmd_fmt, pz_file_source, pz_temp_file );
|
||||
#ifdef SEPARATE_FIX_PROC
|
||||
sprintf (pz_scan, z_cmd_fmt, pz_file_source, pz_temp_file );
|
||||
#else
|
||||
sprintf (pz_scan, z_cmd_fmt, pz_file_source, pz_temp_file,
|
||||
pz_temp_file, pz_temp_file, pz_temp_file);
|
||||
#endif
|
||||
}
|
||||
system( pz_cmd );
|
||||
free( (void*)pz_cmd );
|
||||
|
@ -1019,7 +1033,7 @@ fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file)
|
|||
its stdin and returns the new fd this process will use
|
||||
for stdout. */
|
||||
|
||||
#else /* is *NOT* __MSDOS__ */
|
||||
#else /* is *NOT* SEPARATE_FIX_PROC */
|
||||
static int start_fixer PARAMS ((int, tFixDesc *, char *));
|
||||
static int
|
||||
start_fixer (read_fd, p_fixd, pz_fix_file)
|
||||
|
@ -1105,7 +1119,7 @@ fix_applies (p_fixd)
|
|||
int test_ct;
|
||||
tTestDesc *p_test;
|
||||
|
||||
# ifdef __MSDOS__
|
||||
# ifdef SEPARATE_FIX_PROC
|
||||
/*
|
||||
* There is only one fix that uses a shell script as of this writing.
|
||||
* I hope to nuke it anyway, it does not apply to DOS and it would
|
||||
|
@ -1314,9 +1328,9 @@ process ()
|
|||
tFixDesc *p_fixd = fixDescList;
|
||||
int todo_ct = FIX_COUNT;
|
||||
int read_fd = -1;
|
||||
# ifndef __MSDOS__
|
||||
# ifndef SEPARATE_FIX_PROC
|
||||
int num_children = 0;
|
||||
# else /* is __MSDOS__ */
|
||||
# else /* is SEPARATE_FIX_PROC */
|
||||
char* pz_file_source = pz_curr_file;
|
||||
# endif
|
||||
|
||||
|
@ -1339,7 +1353,7 @@ process ()
|
|||
if (VLEVEL( VERB_PROGRESS ) && have_tty)
|
||||
fprintf (stderr, "%6d %-50s \r", data_map_size, pz_curr_file );
|
||||
|
||||
# ifndef __MSDOS__
|
||||
# ifndef SEPARATE_FIX_PROC
|
||||
process_chain_head = NOPROCESS;
|
||||
|
||||
/* For every fix in our fix list, ... */
|
||||
|
@ -1400,7 +1414,7 @@ process ()
|
|||
} while (--num_children > 0);
|
||||
}
|
||||
|
||||
# else /* is __MSDOS__ */
|
||||
# else /* is SEPARATE_FIX_PROC */
|
||||
|
||||
for (; todo_ct > 0; p_fixd++, todo_ct--)
|
||||
{
|
||||
|
@ -1421,12 +1435,20 @@ process ()
|
|||
pz_file_source = pz_temp_file;
|
||||
}
|
||||
|
||||
read_fd = open( pz_temp_file, O_RDONLY );
|
||||
test_for_changes( read_fd );
|
||||
/* Unlinking a file while it is still open is a Bad Idea on
|
||||
DOS/Windows. */
|
||||
close( read_fd );
|
||||
unlink( pz_temp_file );
|
||||
read_fd = open (pz_temp_file, O_RDONLY);
|
||||
if (read_fd < 0)
|
||||
{
|
||||
fprintf (stderr, "error %d (%s) opening output (%s) for read\n",
|
||||
errno, xstrerror (errno), pz_temp_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
test_for_changes (read_fd);
|
||||
/* Unlinking a file while it is still open is a Bad Idea on
|
||||
DOS/Windows. */
|
||||
close (read_fd);
|
||||
unlink (pz_temp_file);
|
||||
}
|
||||
|
||||
# endif
|
||||
UNLOAD_DATA();
|
||||
|
|
|
@ -244,7 +244,7 @@ mn_get_regexps( label_re, name_re, who )
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef __MSDOS__
|
||||
#ifdef SEPARATE_FIX_PROC
|
||||
|
||||
char*
|
||||
make_raw_shell_str( pz_d, pz_s, smax )
|
||||
|
|
|
@ -209,7 +209,7 @@ void apply_fix PARAMS(( tFixDesc* p_fixd, tCC* filname ));
|
|||
apply_fix_p_t
|
||||
run_test PARAMS(( tCC* t_name, tCC* f_name, tCC* text ));
|
||||
|
||||
#ifdef __MSDOS__
|
||||
#ifdef SEPARATE_FIX_PROC
|
||||
char* make_raw_shell_str
|
||||
PARAMS(( char* pz_d, tCC* pz_s, size_t smax ));
|
||||
#endif
|
||||
|
|
|
@ -49,6 +49,12 @@ case $machine in
|
|||
MAKE="${MAKE} -f ${srcdir}/Makefile.DOS srcdir=${srcdir}"
|
||||
;;
|
||||
|
||||
*-*-beos* )
|
||||
MAKE="${MAKE} -f ${srcdir}/Makefile.BEOS srcdir=${srcdir}"
|
||||
# Remove the following line to enable fixincludes
|
||||
fixincludes=
|
||||
;;
|
||||
|
||||
alpha*-dec-vms* | \
|
||||
arm-semi-aout | armel-semi-aout | \
|
||||
arm-semi-aof | armel-semi-aof | \
|
||||
|
@ -59,7 +65,6 @@ case $machine in
|
|||
hppa1.1-*-bsd* | \
|
||||
hppa1.0-*-bsd* | \
|
||||
hppa*-*-lites* | \
|
||||
*-*-beos* | \
|
||||
*-*-gnu* | \
|
||||
i?86-moss-msdos* | i?86-*-moss* | \
|
||||
i?86-*-osf1* | \
|
||||
|
|
Loading…
Reference in New Issue