Commit 283da1d3 by Daniel Berlin Committed by Bruce Korb

Prepare for fixincludes on BeOS

Co-Authored-By: Bruce Korb <bkorb@gnu.org>

From-SVN: r37959
parent 6864a6c6
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> 2000-12-02 Bruce Korb <bkorb@gnu.org>
From: 2000-11-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> From: 2000-11-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
# the DJGPP (aka MS-DOS) port of GCC. # the DJGPP (aka MS-DOS) port of GCC.
CFLAGS = -Wall -g -O2 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 CC = gcc
SHELL = /bin/sh SHELL = /bin/sh
......
...@@ -60,7 +60,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -60,7 +60,7 @@ Boston, MA 02111-1307, USA. */
#include "fixlib.h" #include "fixlib.h"
#define GTYPE_SE_CT 1 #define GTYPE_SE_CT 1
#ifdef __MSDOS__ #ifdef SEPARATE_FIX_PROC
#include "fixincl.x" #include "fixincl.x"
#endif #endif
...@@ -597,12 +597,20 @@ FIX_PROC_HEAD( machine_name_fix ) ...@@ -597,12 +597,20 @@ FIX_PROC_HEAD( machine_name_fix )
FIX_PROC_HEAD( wrap_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 ]; char z_fixname[ 64 ];
tCC* pz_src = p_fixd->fix_name; tCC* pz_src = p_fixd->fix_name;
tCC* pz_name = z_fixname; tCC* pz_name = z_fixname;
char* pz_dst = z_fixname; char* pz_dst = z_fixname;
int do_end = 0;
size_t len = 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 (;;) { for (;;) {
char ch = *(pz_src++); char ch = *(pz_src++);
...@@ -627,8 +635,16 @@ FIX_PROC_HEAD( wrap_fix ) ...@@ -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) if (p_fixd->patch_args[1] == (tCC*)NULL)
fputs( text, stdout ); fputs( text, stdout );
...@@ -640,7 +656,9 @@ FIX_PROC_HEAD( wrap_fix ) ...@@ -640,7 +656,9 @@ FIX_PROC_HEAD( wrap_fix )
fputs( p_fixd->patch_args[2], stdout ); 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) if (pz_name != z_fixname)
free( (void*)pz_name ); free( (void*)pz_name );
} }
...@@ -731,7 +749,7 @@ apply_fix( p_fixd, filname ) ...@@ -731,7 +749,7 @@ apply_fix( p_fixd, filname )
(*pfe->fix_proc)( filname, buf, p_fixd ); (*pfe->fix_proc)( filname, buf, p_fixd );
} }
#ifdef __MSDOS__ #ifdef SEPARATE_FIX_PROC
tSCC z_usage[] = tSCC z_usage[] =
"USAGE: applyfix <fix-name> <file-to-fix> <file-source> <file-destination>\n"; "USAGE: applyfix <fix-name> <file-to-fix> <file-source> <file-destination>\n";
tSCC z_reopen[] = tSCC z_reopen[] =
...@@ -750,7 +768,7 @@ main( argc, argv ) ...@@ -750,7 +768,7 @@ main( argc, argv )
if (argc != 5) if (argc != 5)
{ {
usage_failure: usage_failure:
fputs( z_usage, stderr ); fputs (z_usage, stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
...@@ -761,15 +779,15 @@ main( argc, argv ) ...@@ -761,15 +779,15 @@ main( argc, argv )
if (! ISDIGIT ( *pz )) if (! ISDIGIT ( *pz ))
goto usage_failure; goto usage_failure;
idx = strtol( pz, &pz, 10 ); idx = strtol (pz, &pz, 10);
if ((*pz != NUL) || ((unsigned)idx >= FIX_COUNT)) if ((*pz != NUL) || ((unsigned)idx >= FIX_COUNT))
goto usage_failure; goto usage_failure;
pFix = fixDescList + idx; 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; return EXIT_FAILURE;
} }
...@@ -783,23 +801,23 @@ main( argc, argv ) ...@@ -783,23 +801,23 @@ main( argc, argv )
pz_tmp_dot = strchr( pz_tmp_base, '.' ); pz_tmp_dot = strchr( pz_tmp_base, '.' );
if (pathconf( pz_tmptmp, _PC_NAME_MAX ) <= 12 /* is this DOS or Windows9X? */ if (pathconf( pz_tmptmp, _PC_NAME_MAX ) <= 12 /* is this DOS or Windows9X? */
&& pz_tmp_dot != (char*)NULL) && 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 else
strcat( pz_tmptmp, ".X" ); strcat (pz_tmptmp, ".X");
if (freopen( pz_tmptmp, "w", stdout ) != stdout) 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; return EXIT_FAILURE;
} }
apply_fix( pFix, argv[1] ); apply_fix (pFix, argv[1]);
close( STDOUT_FILENO ); fclose (stdout);
close( STDIN_FILENO ); fclose (stdin);
unlink( argv[4] ); unlink (argv[4]);
if (rename( pz_tmptmp, argv[4] ) != 0) if (rename (pz_tmptmp, argv[4]) != 0)
{ {
fprintf( stderr, "error %d (%s) renaming %s to %s\n", errno, fprintf (stderr, "error %d (%s) renaming %s to %s\n", errno,
strerror( errno ), pz_tmptmp, argv[4] ); strerror( errno ), pz_tmptmp, argv[4]);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
......
...@@ -30,7 +30,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -30,7 +30,7 @@ Boston, MA 02111-1307, USA. */
#endif #endif
#include <signal.h> #include <signal.h>
#ifndef __MSDOS__ #ifndef SEPARATE_FIX_PROC
#include "server.h" #include "server.h"
#endif #endif
...@@ -182,7 +182,7 @@ Altering %5d of them\n"; ...@@ -182,7 +182,7 @@ Altering %5d of them\n";
} }
#endif /* DO_STATS */ #endif /* DO_STATS */
# ifdef __MSDOS__ # ifdef SEPARATE_FIX_PROC
unlink( pz_temp_file ); unlink( pz_temp_file );
# endif # endif
return EXIT_SUCCESS; return EXIT_SUCCESS;
...@@ -202,7 +202,7 @@ do_version () ...@@ -202,7 +202,7 @@ do_version ()
*/ */
run_compiles (); run_compiles ();
sprintf (zBuf, zFmt, program_id); sprintf (zBuf, zFmt, program_id);
#ifndef __MSDOS__ #ifndef SEPARATE_FIX_PROC
puts (zBuf + 5); puts (zBuf + 5);
exit (strcmp (run_shell (zBuf), program_id)); exit (strcmp (run_shell (zBuf), program_id));
#else #else
...@@ -298,7 +298,7 @@ ENV_TABLE ...@@ -298,7 +298,7 @@ ENV_TABLE
*/ */
run_compiles (); run_compiles ();
# ifdef __MSDOS__ # ifdef SEPARATE_FIX_PROC
/* NULL as the first argument to `tempnam' causes it to DTRT /* NULL as the first argument to `tempnam' causes it to DTRT
wrt the temporary directory where the file will be created. */ wrt the temporary directory where the file will be created. */
pz_temp_file = tempnam( NULL, "fxinc" ); pz_temp_file = tempnam( NULL, "fxinc" );
...@@ -382,7 +382,7 @@ static int ...@@ -382,7 +382,7 @@ static int
machine_matches( p_fixd ) machine_matches( p_fixd )
tFixDesc *p_fixd; tFixDesc *p_fixd;
{ {
# ifndef __MSDOS__ # ifndef SEPARATE_FIX_PROC
tSCC case_fmt[] = "case %s in\n"; /* 9 bytes, plus string */ tSCC case_fmt[] = "case %s in\n"; /* 9 bytes, plus string */
tSCC esac_fmt[] = tSCC esac_fmt[] =
" )\n echo %s ;;\n* ) echo %s ;;\nesac";/* 4 bytes */ " )\n echo %s ;;\n* ) echo %s ;;\nesac";/* 4 bytes */
...@@ -449,7 +449,7 @@ machine_matches( p_fixd ) ...@@ -449,7 +449,7 @@ machine_matches( p_fixd )
} }
return BOOL_TRUE; return BOOL_TRUE;
# else /* is __MSDOS__ */ # else /* is SEPARATE_FIX_PROC */
const char **papz_machs = p_fixd->papz_machs; const char **papz_machs = p_fixd->papz_machs;
int invert = (p_fixd->fd_flags & FD_MACH_IFNOT) != 0; int invert = (p_fixd->fd_flags & FD_MACH_IFNOT) != 0;
for (;;) for (;;)
...@@ -613,7 +613,7 @@ create_file () ...@@ -613,7 +613,7 @@ create_file ()
the name of the file that we might want to fix the name of the file that we might want to fix
Result: APPLY_FIX or SKIP_FIX, depending on the result of the Result: APPLY_FIX or SKIP_FIX, depending on the result of the
shell script we run. */ shell script we run. */
#ifndef __MSDOS__ #ifndef SEPARATE_FIX_PROC
static int test_test PARAMS ((tTestDesc *, char *)); static int test_test PARAMS ((tTestDesc *, char *));
static int static int
test_test (p_test, pz_test_file) test_test (p_test, pz_test_file)
...@@ -812,7 +812,7 @@ extract_quoted_files (pz_data, pz_fixed_file, p_re_match) ...@@ -812,7 +812,7 @@ extract_quoted_files (pz_data, pz_fixed_file, p_re_match)
Somebody wrote a *_fix subroutine that we must call. 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 PARAMS ((int, tFixDesc *));
static int static int
internal_fix (read_fd, p_fixd) internal_fix (read_fd, p_fixd)
...@@ -879,10 +879,10 @@ internal_fix (read_fd, p_fixd) ...@@ -879,10 +879,10 @@ internal_fix (read_fd, p_fixd)
apply_fix (p_fixd, pz_curr_file); apply_fix (p_fixd, pz_curr_file);
exit (0); exit (0);
} }
#endif /* !__MSDOS__ */ #endif /* !SEPARATE_FIX_PROC */
#ifdef __MSDOS__ #ifdef SEPARATE_FIX_PROC
static void static void
fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file) fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file)
tFixDesc* p_fixd; tFixDesc* p_fixd;
...@@ -922,16 +922,25 @@ fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file) ...@@ -922,16 +922,25 @@ fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file)
else /* NOT an "internal" fix: */ else /* NOT an "internal" fix: */
{ {
size_t parg_size; size_t parg_size;
#ifdef __MSDOS__
/* Don't use the "src > dstX; rm -f dst; mv -f dstX dst" trick: /* 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 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 file by that name; and DOS's system(3) doesn't mind to
clobber existing file in redirection. Besides, with DOS 8+3 clobber existing file in redirection. Besides, with DOS 8+3
limited file namespace, we can easily lose if dst already has limited file namespace, we can easily lose if dst already has
an extension that is 3 or more characters long. 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). */ 'cat' to read (pipes do not work on DOS). */
tSCC z_cmd_fmt[] = " %s | cat > %s"; 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; tCC** ppArgs = p_fixd->patch_args;
argsize = sizeof( z_cmd_fmt ) + strlen( pz_temp_file ) 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) ...@@ -1006,7 +1015,12 @@ fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file)
/* /*
* add the file machinations. * 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 ); system( pz_cmd );
free( (void*)pz_cmd ); free( (void*)pz_cmd );
...@@ -1019,7 +1033,7 @@ fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file) ...@@ -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 its stdin and returns the new fd this process will use
for stdout. */ for stdout. */
#else /* is *NOT* __MSDOS__ */ #else /* is *NOT* SEPARATE_FIX_PROC */
static int start_fixer PARAMS ((int, tFixDesc *, char *)); static int start_fixer PARAMS ((int, tFixDesc *, char *));
static int static int
start_fixer (read_fd, p_fixd, pz_fix_file) start_fixer (read_fd, p_fixd, pz_fix_file)
...@@ -1105,7 +1119,7 @@ fix_applies (p_fixd) ...@@ -1105,7 +1119,7 @@ fix_applies (p_fixd)
int test_ct; int test_ct;
tTestDesc *p_test; tTestDesc *p_test;
# ifdef __MSDOS__ # ifdef SEPARATE_FIX_PROC
/* /*
* There is only one fix that uses a shell script as of this writing. * 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 * I hope to nuke it anyway, it does not apply to DOS and it would
...@@ -1314,9 +1328,9 @@ process () ...@@ -1314,9 +1328,9 @@ process ()
tFixDesc *p_fixd = fixDescList; tFixDesc *p_fixd = fixDescList;
int todo_ct = FIX_COUNT; int todo_ct = FIX_COUNT;
int read_fd = -1; int read_fd = -1;
# ifndef __MSDOS__ # ifndef SEPARATE_FIX_PROC
int num_children = 0; int num_children = 0;
# else /* is __MSDOS__ */ # else /* is SEPARATE_FIX_PROC */
char* pz_file_source = pz_curr_file; char* pz_file_source = pz_curr_file;
# endif # endif
...@@ -1339,7 +1353,7 @@ process () ...@@ -1339,7 +1353,7 @@ process ()
if (VLEVEL( VERB_PROGRESS ) && have_tty) if (VLEVEL( VERB_PROGRESS ) && have_tty)
fprintf (stderr, "%6d %-50s \r", data_map_size, pz_curr_file ); fprintf (stderr, "%6d %-50s \r", data_map_size, pz_curr_file );
# ifndef __MSDOS__ # ifndef SEPARATE_FIX_PROC
process_chain_head = NOPROCESS; process_chain_head = NOPROCESS;
/* For every fix in our fix list, ... */ /* For every fix in our fix list, ... */
...@@ -1400,7 +1414,7 @@ process () ...@@ -1400,7 +1414,7 @@ process ()
} while (--num_children > 0); } while (--num_children > 0);
} }
# else /* is __MSDOS__ */ # else /* is SEPARATE_FIX_PROC */
for (; todo_ct > 0; p_fixd++, todo_ct--) for (; todo_ct > 0; p_fixd++, todo_ct--)
{ {
...@@ -1421,12 +1435,20 @@ process () ...@@ -1421,12 +1435,20 @@ process ()
pz_file_source = pz_temp_file; pz_file_source = pz_temp_file;
} }
read_fd = open( pz_temp_file, O_RDONLY ); read_fd = open (pz_temp_file, O_RDONLY);
test_for_changes( read_fd ); if (read_fd < 0)
/* Unlinking a file while it is still open is a Bad Idea on {
DOS/Windows. */ fprintf (stderr, "error %d (%s) opening output (%s) for read\n",
close( read_fd ); errno, xstrerror (errno), pz_temp_file);
unlink( 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 # endif
UNLOAD_DATA(); UNLOAD_DATA();
......
...@@ -244,7 +244,7 @@ mn_get_regexps( label_re, name_re, who ) ...@@ -244,7 +244,7 @@ mn_get_regexps( label_re, name_re, who )
#endif #endif
#ifdef __MSDOS__ #ifdef SEPARATE_FIX_PROC
char* char*
make_raw_shell_str( pz_d, pz_s, smax ) make_raw_shell_str( pz_d, pz_s, smax )
......
...@@ -209,7 +209,7 @@ void apply_fix PARAMS(( tFixDesc* p_fixd, tCC* filname )); ...@@ -209,7 +209,7 @@ void apply_fix PARAMS(( tFixDesc* p_fixd, tCC* filname ));
apply_fix_p_t apply_fix_p_t
run_test PARAMS(( tCC* t_name, tCC* f_name, tCC* text )); run_test PARAMS(( tCC* t_name, tCC* f_name, tCC* text ));
#ifdef __MSDOS__ #ifdef SEPARATE_FIX_PROC
char* make_raw_shell_str char* make_raw_shell_str
PARAMS(( char* pz_d, tCC* pz_s, size_t smax )); PARAMS(( char* pz_d, tCC* pz_s, size_t smax ));
#endif #endif
......
...@@ -49,6 +49,12 @@ case $machine in ...@@ -49,6 +49,12 @@ case $machine in
MAKE="${MAKE} -f ${srcdir}/Makefile.DOS srcdir=${srcdir}" 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* | \ alpha*-dec-vms* | \
arm-semi-aout | armel-semi-aout | \ arm-semi-aout | armel-semi-aout | \
arm-semi-aof | armel-semi-aof | \ arm-semi-aof | armel-semi-aof | \
...@@ -59,7 +65,6 @@ case $machine in ...@@ -59,7 +65,6 @@ case $machine in
hppa1.1-*-bsd* | \ hppa1.1-*-bsd* | \
hppa1.0-*-bsd* | \ hppa1.0-*-bsd* | \
hppa*-*-lites* | \ hppa*-*-lites* | \
*-*-beos* | \
*-*-gnu* | \ *-*-gnu* | \
i?86-moss-msdos* | i?86-*-moss* | \ i?86-moss-msdos* | i?86-*-moss* | \
i?86-*-osf1* | \ i?86-*-osf1* | \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment