[PATCH]: Revised patch for fixinc on BeOS
Daniel Berlin
dberlin@cygnus.com
Mon Nov 27 14:16:00 GMT 2000
This adds the BeOS specific makefile, as requested by bruce.
It's essentially the same (besides the makefile/mkfixinc.sh change to use
it) as the last patch, except for two things:
1. We now flush stdout before closing it in applyfix. without this, our
output file ends up being empty.
2. Multiple fixes on the same include file work properly (involved using
a different command on BeOS than MSDOS).
--Dan
? Makefile.BEOS
Index: fixfixes.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixfixes.c,v
retrieving revision 1.36
diff -c -3 -p -w -B -b -r1.36 fixfixes.c
*** fixfixes.c 2000/11/22 02:23:40 1.36
--- fixfixes.c 2000/11/27 21:54:45
*************** Boston, MA 02111-1307, USA. */
*** 60,66 ****
#include "fixlib.h"
#define GTYPE_SE_CT 1
! #ifdef __MSDOS__
#include "fixincl.x"
#endif
--- 60,66 ----
#include "fixlib.h"
#define GTYPE_SE_CT 1
! #if defined(__MSDOS__) || defined(__BEOS__)
#include "fixincl.x"
#endif
*************** apply_fix( p_fixd, filname )
*** 729,735 ****
(*pfe->fix_proc)( filname, buf, p_fixd );
}
! #ifdef __MSDOS__
tSCC z_usage[] =
"USAGE: applyfix <fix-name> <file-to-fix> <file-source> <file-destination>\n";
tSCC z_reopen[] =
--- 729,735 ----
(*pfe->fix_proc)( filname, buf, p_fixd );
}
! #if defined(__MSDOS__) || defined(__BEOS__)
tSCC z_usage[] =
"USAGE: applyfix <fix-name> <file-to-fix> <file-source> <file-destination>\n";
tSCC z_reopen[] =
*************** main( argc, argv )
*** 784,789 ****
--- 783,789 ----
strcpy( pz_tmp_dot+1, "X" ); /* nuke the original extension */
else
strcat( pz_tmptmp, ".X" );
+
if (freopen( pz_tmptmp, "w", stdout ) != stdout)
{
fprintf( stderr, z_reopen, errno, strerror( errno ), pz_tmptmp, "out" );
*************** main( argc, argv )
*** 791,796 ****
--- 791,797 ----
}
apply_fix( pFix, argv[1] );
+ fflush(stdout);
close( STDOUT_FILENO );
close( STDIN_FILENO );
unlink( argv[4] );
Index: fixincl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.c,v
retrieving revision 1.42
diff -c -3 -p -w -B -b -r1.42 fixincl.c
*** fixincl.c 2000/11/17 04:16:55 1.42
--- fixincl.c 2000/11/27 21:54:46
*************** Boston, MA 02111-1307, USA. */
*** 30,36 ****
#endif
#include <signal.h>
! #ifndef __MSDOS__
#include "server.h"
#endif
--- 30,36 ----
#endif
#include <signal.h>
! #if !defined(__MSDOS__) && !defined(__BEOS__)
#include "server.h"
#endif
*************** Altering %5d of them\n";
*** 181,187 ****
}
#endif /* DO_STATS */
! # ifdef __MSDOS__
unlink( pz_temp_file );
# endif
return EXIT_SUCCESS;
--- 181,187 ----
}
#endif /* DO_STATS */
! # if defined(__MSDOS__) || defined(__BEOS__)
unlink( pz_temp_file );
# endif
return EXIT_SUCCESS;
*************** do_version ()
*** 201,207 ****
*/
run_compiles ();
sprintf (zBuf, zFmt, program_id);
! #ifndef __MSDOS__
puts (zBuf + 5);
exit (strcmp (run_shell (zBuf), program_id));
#else
--- 201,207 ----
*/
run_compiles ();
sprintf (zBuf, zFmt, program_id);
! #if !defined(__MSDOS__) && !defined(__BEOS__)
puts (zBuf + 5);
exit (strcmp (run_shell (zBuf), program_id));
#else
*************** ENV_TABLE
*** 297,303 ****
*/
run_compiles ();
! # ifdef __MSDOS__
/* 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" );
--- 297,303 ----
*/
run_compiles ();
! # if defined(__MSDOS__) || defined(__BEOS__)
/* 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" );
*************** int
*** 380,386 ****
machine_matches( p_fixd )
tFixDesc *p_fixd;
{
! # ifndef __MSDOS__
tSCC case_fmt[] = "case %s in\n"; /* 9 bytes, plus string */
tSCC esac_fmt[] =
" )\n echo %s ;;\n* ) echo %s ;;\nesac";/* 4 bytes */
--- 380,386 ----
machine_matches( p_fixd )
tFixDesc *p_fixd;
{
! # if !defined(__MSDOS__) && !defined(__BEOS__)
tSCC case_fmt[] = "case %s in\n"; /* 9 bytes, plus string */
tSCC esac_fmt[] =
" )\n echo %s ;;\n* ) echo %s ;;\nesac";/* 4 bytes */
*************** create_file ()
*** 610,616 ****
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__
int
test_test (p_test, pz_test_file)
tTestDesc *p_test;
--- 610,616 ----
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. */
! #if !defined(__MSDOS__) && !defined(__BEOS__)
int
test_test (p_test, pz_test_file)
tTestDesc *p_test;
*************** extract_quoted_files (pz_data, pz_fixed_
*** 805,811 ****
Somebody wrote a *_fix subroutine that we must call.
*/
! #ifndef __MSDOS__
int
internal_fix (read_fd, p_fixd)
int read_fd;
--- 805,811 ----
Somebody wrote a *_fix subroutine that we must call.
*/
! #if !defined(__MSDOS__) && !defined(__BEOS__)
int
internal_fix (read_fd, p_fixd)
int read_fd;
*************** internal_fix (read_fd, p_fixd)
*** 874,880 ****
#endif /* !__MSDOS__ */
! #ifdef __MSDOS__
static void
fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file)
tFixDesc* p_fixd;
--- 874,880 ----
#endif /* !__MSDOS__ */
! #if defined(__MSDOS__) || defined(__BEOS__)
static void
fix_with_system (p_fixd, pz_fix_file, pz_file_source, pz_temp_file)
tFixDesc* p_fixd;
*************** fix_with_system (p_fixd, pz_fix_file, pz
*** 923,929 ****
--- 923,936 ----
The following bizarre use of 'cat' only works on DOS boxes.
It is causing the file to be dropped into a temporary file for
'cat' to read (pipes do not work on DOS). */
+ #ifdef __MSDOS__
tSCC z_cmd_fmt[] = " %s | cat > %s";
+ #else
+ /* Positional printf arguments don't seem to work for some reason, which
+ * makes this more work than it should be, because we have to #ifdef
+ * below as well. */
+ 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 )
*************** fix_with_system (p_fixd, pz_fix_file, pz
*** 998,1004 ****
--- 1005,1015 ----
/*
* add the file machinations.
*/
+ #ifdef __BEOS__
+ sprintf( pz_scan, z_cmd_fmt, pz_file_source, pz_temp_file, pz_temp_file, pz_temp_file, pz_temp_file);
+ #else
sprintf( pz_scan, z_cmd_fmt, pz_file_source, pz_temp_file );
+ #endif
}
system( pz_cmd );
free( (void*)pz_cmd );
*************** fix_applies (p_fixd)
*** 1095,1101 ****
int test_ct;
tTestDesc *p_test;
! # ifdef __MSDOS__
/*
* 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
--- 1106,1112 ----
int test_ct;
tTestDesc *p_test;
! # if defined(__MSDOS__) || defined(__BEOS__)
/*
* 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
*************** process ()
*** 1302,1308 ****
tFixDesc *p_fixd = fixDescList;
int todo_ct = FIX_COUNT;
int read_fd = -1;
! # ifndef __MSDOS__
int num_children = 0;
# else /* is __MSDOS__ */
char* pz_file_source = pz_curr_file;
--- 1313,1319 ----
tFixDesc *p_fixd = fixDescList;
int todo_ct = FIX_COUNT;
int read_fd = -1;
! # if !defined(__MSDOS__) && !defined(__BEOS__)
int num_children = 0;
# else /* is __MSDOS__ */
char* pz_file_source = pz_curr_file;
*************** process ()
*** 1327,1333 ****
if (VLEVEL( VERB_PROGRESS ) && have_tty)
fprintf (stderr, "%6d %-50s \r", data_map_size, pz_curr_file );
! # ifndef __MSDOS__
process_chain_head = NOPROCESS;
/* For every fix in our fix list, ... */
--- 1338,1344 ----
if (VLEVEL( VERB_PROGRESS ) && have_tty)
fprintf (stderr, "%6d %-50s \r", data_map_size, pz_curr_file );
! # if !defined(__MSDOS__) && !defined(__BEOS__)
process_chain_head = NOPROCESS;
/* For every fix in our fix list, ... */
*************** process ()
*** 1410,1421 ****
}
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 );
!
# endif
UNLOAD_DATA();
}
--- 1421,1434 ----
}
read_fd = open( pz_temp_file, O_RDONLY );
+ if (read_fd > 0)
+ {
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();
}
Index: fixincl.sh
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.sh,v
retrieving revision 1.33
diff -c -3 -p -w -B -b -r1.33 fixincl.sh
Index: fixlib.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixlib.c,v
retrieving revision 1.14
diff -c -3 -p -w -B -b -r1.14 fixlib.c
*** fixlib.c 2000/11/17 04:16:55 1.14
--- fixlib.c 2000/11/27 21:54:47
*************** mn_get_regexps( label_re, name_re, who )
*** 244,250 ****
#endif
! #ifdef __MSDOS__
char*
make_raw_shell_str( pz_d, pz_s, smax )
--- 244,250 ----
#endif
! #if defined(__MSDOS__) || defined(__BEOS__)
char*
make_raw_shell_str( pz_d, pz_s, smax )
Index: fixlib.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixlib.h,v
retrieving revision 1.18
diff -c -3 -p -w -B -b -r1.18 fixlib.h
*** fixlib.h 2000/09/12 14:28:27 1.18
--- fixlib.h 2000/11/27 21:54:47
*************** void apply_fix PARAMS(( tFixDesc* p_
*** 209,215 ****
apply_fix_p_t
run_test PARAMS(( tCC* t_name, tCC* f_name, tCC* text ));
! #ifdef __MSDOS__
char* make_raw_shell_str
PARAMS(( char* pz_d, tCC* pz_s, size_t smax ));
#endif
--- 209,215 ----
apply_fix_p_t
run_test PARAMS(( tCC* t_name, tCC* f_name, tCC* text ));
! #if defined(__MSDOS__) || defined(__BEOS__)
char* make_raw_shell_str
PARAMS(( char* pz_d, tCC* pz_s, size_t smax ));
#endif
Index: mkfixinc.sh
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/mkfixinc.sh,v
retrieving revision 1.28
diff -c -3 -p -w -B -b -r1.28 mkfixinc.sh
*** mkfixinc.sh 2000/11/17 23:48:15 1.28
--- mkfixinc.sh 2000/11/27 21:54:48
*************** case $machine in
*** 35,40 ****
--- 35,43 ----
i?86-*-openbsd*)
fixincludes=fixinc.wrap
;;
+ *-*-beos*)
+ MAKE="${MAKE} -f ${srcdir}/Makefile.BEOS"
+ ;;
alpha*-*-winnt* | \
i?86-*-winnt3*)
*************** case $machine in
*** 55,61 ****
hppa1.1-*-bsd* | \
hppa1.0-*-bsd* | \
hppa*-*-lites* | \
! *-*-beos* | \
*-*-gnu* | \
i?86-moss-msdos* | i?86-*-moss* | \
i?86-*-osf1* | \
--- 58,64 ----
hppa1.1-*-bsd* | \
hppa1.0-*-bsd* | \
hppa*-*-lites* | \
! *-*-linux* | \
*-*-gnu* | \
i?86-moss-msdos* | i?86-*-moss* | \
i?86-*-osf1* | \
More information about the Gcc-patches
mailing list