Commit 62a99405 by Bruce Korb

Implement, but leave disabled, MSDOS functionality

From-SVN: r35479
parent d6777972
2000-08-04 Bruce Korb <bkorb@gnu.org>
* fixinc/: Verified that the MSDOS patch does not break
the UNIX functionality and applied the next three patches
from July:
2000-07-28 Eli Zaretskii <eliz@is.elta.co.il>
* fixinc/fixfixes.c (main) [__MSDOS__]: Avoid overwriting the
output file with the temporary one by appending ".X" to generate
the temporary fuile's name. If the output file already has an
extension, replace it with ".X".
* fixinc/fixincl.c (fix_with_system) [__MSDOS__]: Use $ORIGDIR,
not $DESTDIR, to find applyfix. Use sprintf instead of snprintf;
reallocate the command buffer while copying the command-line
argument. Redirect the output directly to the temporary file,
instead of going through another temporary file.
(process): Close the temporary file before unlinking it.
(machine_matches) [__MSDOS__]: If the machine doesn't match, set
the FD_SKIP_TEST flag. Pay attention to the FD_MACH_IFNOT flag.
(run_compiles): Pass p_fixd argument to machine_matches, as it
expects.
* fixinc/fixincl.sh: Export ORIGDIR. If $DJDIR is set in the
environment, assume there are no symlinks in the include
directory. When cleaning up the DONE files, look for them
case-insensitively. Don't try to remove symlinks if they aren't
there.
* fixinc/fixlib.c (make_raw_shell_str): Accept new argument smax;
all callers changed. Declare pz "const char *", to avoid compiler
warnings.
* fixinc/fixlib.h (ENV_TABLE): Get ORIGDIR from the environment.
Change prototype of make_raw_shell_str.
2000-07-27 Eli Zaretskii <eliz@is.elta.co.il>
* fixinc/fixincl.c [__MSDOS__]: Don't include "server.h".
(initialize) [__MSDOS__]: Use tempnam.
(initialize): Don't use SIGPIPE if it is not defined.
* fixinc/fixfixes.c (main) [__MSDOS__]: freopen for stdout should
return stdout.
2000-07-25 Bruce Korb <bkorb@gnu.org>
* fixinc/fix*.[ch]: substantially reworked to make it possible
to run this program without using fork(2) or pipe(2) (i.e. in
a DOS environment).
2000-08-04 Joseph S. Myers <jsm28@cam.ac.uk> 2000-08-04 Joseph S. Myers <jsm28@cam.ac.uk>
* cppdefault.h (WINT_TYPE): Define. * cppdefault.h (WINT_TYPE): Define.
......
...@@ -67,7 +67,7 @@ Here are the rules for making fixes in the inclhack.def file: ...@@ -67,7 +67,7 @@ Here are the rules for making fixes in the inclhack.def file:
It is nice if: It is nice if:
3. The expression is as simple as possible to both 3. The expression is as simple as possible to both
process and uderstand by people. :-) process and understand by people. :-)
Please take advantage of the fact AutoGen will glue Please take advantage of the fact AutoGen will glue
together string fragments. It helps. Also take note together string fragments. It helps. Also take note
......
...@@ -19,8 +19,9 @@ SRCDIR=`pwd`/inc ...@@ -19,8 +19,9 @@ SRCDIR=`pwd`/inc
FIND_BASE='.' FIND_BASE='.'
VERBOSE=1 VERBOSE=1
INPUT=`pwd` INPUT=`pwd`
ORIGDIR=${INPUT}
export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE INPUT export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE INPUT ORIGDIR
rm -rf ${DESTDIR} ${SRCDIR} rm -rf ${DESTDIR} ${SRCDIR}
mkdir ${DESTDIR} ${SRCDIR} mkdir ${DESTDIR} ${SRCDIR}
......
...@@ -60,6 +60,10 @@ Boston, MA 02111-1307, USA. */ ...@@ -60,6 +60,10 @@ Boston, MA 02111-1307, USA. */
#include "fixlib.h" #include "fixlib.h"
#define GTYPE_SE_CT 1 #define GTYPE_SE_CT 1
#ifdef __MSDOS__
#include "fixincl.x"
#endif
tSCC zNeedsArg[] = "fixincl error: `%s' needs %s argument (c_fix_arg[%d])\n"; tSCC zNeedsArg[] = "fixincl error: `%s' needs %s argument (c_fix_arg[%d])\n";
typedef struct { typedef struct {
...@@ -725,3 +729,79 @@ apply_fix( p_fixd, filname ) ...@@ -725,3 +729,79 @@ apply_fix( p_fixd, filname )
buf = load_file_data (stdin); buf = load_file_data (stdin);
(*pfe->fix_proc)( filname, buf, p_fixd ); (*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[] =
"FS error %d (%s) reopening %s as std%s\n";
int
main( argc, argv )
int argc;
char** argv;
{
tFixDesc* pFix;
char* pz_tmptmp;
char* pz_tmp_base;
char* pz_tmp_dot;
if (argc != 5)
{
usage_failure:
fputs( z_usage, stderr );
return EXIT_FAILURE;
}
{
char* pz = argv[1];
long idx;
if (! isdigit( *pz ))
goto usage_failure;
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)
{
fprintf( stderr, z_reopen, errno, strerror( errno ), argv[3], "in" );
return EXIT_FAILURE;
}
pz_tmptmp = (char*)xmalloc( strlen( argv[4] ) + 5 );
strcpy( pz_tmptmp, argv[4] );
/* Don't lose because "12345678" and "12345678X" map to the same
file under DOS restricted 8+3 file namespace. Note that DOS
doesn't allow more than one dot in the trunk of a file name. */
pz_tmp_base = basename( pz_tmptmp );
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 */
else
strcat( pz_tmptmp, ".X" );
if (freopen( pz_tmptmp, "w", stdout ) != stdout)
{
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)
{
fprintf( stderr, "error %d (%s) renaming %s to %s\n", errno,
strerror( errno ), pz_tmptmp, argv[4] );
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
#endif
...@@ -95,6 +95,7 @@ esac ...@@ -95,6 +95,7 @@ esac
# Original directory. # Original directory.
ORIGDIR=`${PWDCMD}` ORIGDIR=`${PWDCMD}`
export ORIGDIR
FIXINCL=${ORIGDIR}/fixinc/fixincl FIXINCL=${ORIGDIR}/fixinc/fixincl
export FIXINCL export FIXINCL
...@@ -111,7 +112,9 @@ if test $VERBOSE -gt 0 ...@@ -111,7 +112,9 @@ if test $VERBOSE -gt 0
then echo Fixing headers into ${LIB} for ${target_canonical} target ; fi then echo Fixing headers into ${LIB} for ${target_canonical} target ; fi
# Determine whether this system has symbolic links. # Determine whether this system has symbolic links.
if ln -s X $LIB/ShouldNotExist 2>/dev/null; then if test -n "$DJDIR"; then
LINKS=false
elif ln -s X $LIB/ShouldNotExist 2>/dev/null; then
rm -f $LIB/ShouldNotExist rm -f $LIB/ShouldNotExist
LINKS=true LINKS=true
elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then elif ln -s X /tmp/ShouldNotExist 2>/dev/null; then
...@@ -422,7 +425,9 @@ done ...@@ -422,7 +425,9 @@ done
if test $VERBOSE -gt 2 if test $VERBOSE -gt 2
then echo 'Cleaning up DONE files.' ; fi then echo 'Cleaning up DONE files.' ; fi
cd $LIB cd $LIB
find . -name DONE -exec rm -f '{}' ';' # Look for files case-insensitively, for the benefit of
# DOS/Windows filesystems.
find . -name '[Dd][Oo][Nn][Ee]' -exec rm -f '{}' ';'
if test $VERBOSE -gt 1 if test $VERBOSE -gt 1
then echo 'Cleaning up unneeded directories:' ; fi then echo 'Cleaning up unneeded directories:' ; fi
...@@ -435,20 +440,25 @@ for file in $all_dirs; do ...@@ -435,20 +440,25 @@ for file in $all_dirs; do
fi fi
done 2> /dev/null done 2> /dev/null
test $VERBOSE -gt 2 && echo "Removing unused symlinks" # On systems which don't support symlinks, `find' may barf
# if called with "-type l" predicate. So only use that if
# we know we should look for symlinks.
if $LINKS; then
test $VERBOSE -gt 2 && echo "Removing unused symlinks"
all_dirs=`find . -type l -print` all_dirs=`find . -type l -print`
for file in $all_dirs for file in $all_dirs
do do
if ls -lLd $file > /dev/null if ls -lLd $file > /dev/null
then : then :
else rm -f $file else rm -f $file
test $VERBOSE -gt 3 && echo " removed $file" test $VERBOSE -gt 3 && echo " removed $file"
rmdir `dirname $file` > /dev/null && \ rmdir `dirname $file` > /dev/null && \
test $VERBOSE -gt 3 && \ test $VERBOSE -gt 3 && \
echo " removed `dirname $file`" echo " removed `dirname $file`"
fi fi
done 2> /dev/null done 2> /dev/null
fi
if test $VERBOSE -gt 0 if test $VERBOSE -gt 0
then echo fixincludes is done ; fi then echo fixincludes is done ; fi
......
...@@ -245,3 +245,57 @@ mn_get_regexps( label_re, name_re, who ) ...@@ -245,3 +245,57 @@ mn_get_regexps( label_re, name_re, who )
*name_re = &mn_name_re; *name_re = &mn_name_re;
} }
#endif #endif
#ifdef __MSDOS__
char*
make_raw_shell_str( pz_d, pz_s, smax )
char* pz_d;
tCC* pz_s;
size_t smax;
{
tSCC zQ[] = "'\\''";
size_t dtaSize;
char* pz_d_start = pz_d;
smax--; /* adjust for trailing NUL */
dtaSize = strlen( pz_s ) + 3;
{
const char* pz = pz_s - 1;
for (;;) {
pz = strchr( pz+1, '\'' );
if (pz == (char*)NULL)
break;
dtaSize += sizeof( zQ )-1;
}
}
if (dtaSize > smax)
return (char*)NULL;
*(pz_d++) = '\'';
for (;;) {
if (pz_d - pz_d_start >= smax)
return (char*)NULL;
switch (*(pz_d++) = *(pz_s++)) {
case NUL:
goto loopDone;
case '\'':
if (pz_d - pz_d_start >= smax - sizeof( zQ )-1)
return (char*)NULL;
strcpy( pz_d-1, zQ );
pz_d += sizeof( zQ )-2;
}
} loopDone:;
pz_d[-1] = '\'';
*pz_d = NUL;
return pz_d;
}
#endif
...@@ -100,6 +100,9 @@ typedef int apply_fix_p_t; /* Apply Fix Predicate Type */ ...@@ -100,6 +100,9 @@ typedef int apply_fix_p_t; /* Apply Fix Predicate Type */
_ENV_( pz_machine, BOOL_TRUE, "TARGET_MACHINE", \ _ENV_( pz_machine, BOOL_TRUE, "TARGET_MACHINE", \
"output from config.guess" ) \ "output from config.guess" ) \
\ \
_ENV_( pz_orig_dir, BOOL_TRUE, "ORIGDIR", \
"directory of fixincl and applyfix" ) \
\
_ENV_( pz_src_dir, BOOL_TRUE, "SRCDIR", \ _ENV_( pz_src_dir, BOOL_TRUE, "SRCDIR", \
"directory of original files" ) \ "directory of original files" ) \
\ \
...@@ -204,6 +207,10 @@ void compile_re _P_(( tCC* pat, regex_t* re, int match, ...@@ -204,6 +207,10 @@ void compile_re _P_(( tCC* pat, regex_t* re, int match,
void apply_fix _P_(( tFixDesc* p_fixd, tCC* filname )); void apply_fix _P_(( tFixDesc* p_fixd, tCC* filname ));
apply_fix_p_t run_test _P_((tCC* t_name, tCC* f_name, tCC* text )); apply_fix_p_t run_test _P_((tCC* t_name, tCC* f_name, tCC* text ));
#ifdef __MSDOS__
char* make_raw_shell_str _P_(( char* pz_d, tCC* pz_s, size_t smax ));
#endif
#ifdef MN_NAME_PAT #ifdef MN_NAME_PAT
void mn_get_regexps _P_(( regex_t** label_re, regex_t** name_re, void mn_get_regexps _P_(( regex_t** label_re, regex_t** name_re,
tCC *who )); tCC *who ));
......
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