home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega CD-ROM 1
/
megacd_rom_1.zip
/
megacd_rom_1
/
GNUISH
/
FUTIL14.ZIP
/
PATCHES
< prev
next >
Wrap
Text File
|
1990-09-24
|
118KB
|
4,473 lines
*** e:\tmp/RCSt1006574 Wed Sep 19 13:27:44 1990
--- argmatch.c Wed Sep 19 12:36:14 1990
***************
*** 17,26 ****
--- 17,43 ----
/* Written by David MacKenzie <djm@ai.mit.edu> */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fileutil/RCS/argmatch.c 1.4.0.2 90/09/19 12:27:25 tho Exp $
+ */
+
#include <stdio.h>
#ifdef STDC_HEADERS
#include <string.h>
#endif
+
+ #ifdef MSDOS
+ int argmatch (char *arg, char **optlist);
+ void invalid_arg (char *kind, char *value, int problem);
+ #endif /* MSDOS */
extern char *program_name;
*** e:\tmp/RCSt1006574 Wed Sep 19 13:27:46 1990
--- backupfi.c Wed Sep 19 12:36:34 1990
***************
*** 17,23 ****
--- 17,36 ----
/* David MacKenzie <djm@ai.mit.edu>.
Some algorithms adapted from GNU Emacs. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/backupfi.c 1.4.0.2 90/09/19 12:27:27 tho Exp $";
+ #endif /* MSDOS */
+
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
***************
*** 59,64 ****
--- 72,89 ----
char *malloc ();
#endif
+ #ifdef MSDOS
+ extern char *find_backup_file_name (char *file);
+ static int max_backup_version (char *file, char *dir);
+ static char *make_version_name (char *file, int version);
+ static int version_number (char *base, char *backup, int base_length);
+ static char *dirname (char *path);
+ static char *basename (char *name);
+ static char *concat (char *str1, char *str2);
+ static char *copystring (char *str);
+ static char *chop_filename (char *path, int n);
+ #endif /* MSDOS */
+
/* Which type of backup file names are generated. */
enum backup_type backup_type = none;
***************
*** 131,137 ****
--- 156,166 ----
while ((dp = readdir (dirp)) != 0)
{
+ #ifdef MSDOS
+ if (NLENGTH (dp) <= file_name_length)
+ #else /* not MSDOS */
if (dp->d_ino == 0 || NLENGTH (dp) <= file_name_length)
+ #endif /* not MSDOS */
continue;
this_version = version_number (file, dp->d_name, file_name_length);
***************
*** 142,147 ****
--- 171,180 ----
return highest_version;
}
+ #ifdef MSDOS
+ static char suffix[5];
+ #endif /* not MSDOS */
+
/* Return a string, allocated with malloc, containing
"FILE.~VERSION~". Return 0 if out of memory. */
***************
*** 150,155 ****
--- 183,192 ----
char *file;
int version;
{
+ #ifdef MSDOS
+ sprintf (suffix, ".~%.1d~", version);
+ return concat (file, suffix);
+ #else /* not MSDOS */
char *backup_name;
backup_name = malloc (strlen (file) + 16);
***************
*** 157,162 ****
--- 194,200 ----
return 0;
sprintf (backup_name, "%s.~%d~", file, version);
return backup_name;
+ #endif /* not MSDOS */
}
/* If BACKUP is a numbered backup of BASE, return its version number;
***************
*** 171,183 ****
{
int version;
char *p;
!
version = 0;
if (!strncmp (base, backup, base_length) && ISDIGIT (backup[base_length]))
{
for (p = &backup[base_length]; ISDIGIT (*p); ++p)
version = version * 10 + *p - '0';
if (p[0] != '~' || p[1])
version = 0;
}
return version;
--- 209,225 ----
{
int version;
char *p;
!
version = 0;
if (!strncmp (base, backup, base_length) && ISDIGIT (backup[base_length]))
{
for (p = &backup[base_length]; ISDIGIT (*p); ++p)
version = version * 10 + *p - '0';
+ #ifdef MSDOS
+ if (*p && *p != '~')
+ #else /* not MSDOS */
if (p[0] != '~' || p[1])
+ #endif /* not MSDOS */
version = 0;
}
return version;
***************
*** 231,241 ****
--- 273,300 ----
char *newstr;
char str1_length = strlen (str1);
+ #ifdef MSDOS
+ /* The MS-DOS version tries to squeeze the given string into a valid
+ MS-DOS patch name. STR1 is chopped and a leading period is removed
+ from STR2. Kludge: a leading period is counted in the length of STR2,
+ this is because we will know, that in this case a digit will be appended
+ afterwards. */
+ /* chop_filename () might add a '.', so allocate one more byte. */
+ newstr = malloc (str1_length + strlen (str2) + 2);
+ if (newstr == 0)
+ return 0;
+ strcpy (newstr, str1);
+ chop_filename (newstr, min (2, strlen(str2)));
+ if (*str2 == '.')
+ str2++;
+ strcat (newstr, str2);
+ #else /* not MSDOS */
newstr = malloc (str1_length + strlen (str2) + 1);
if (newstr == 0)
return 0;
strcpy (newstr, str1);
strcpy (newstr + str1_length, str2);
+ #endif /* not MSDOS */
return newstr;
}
***************
*** 253,255 ****
--- 312,343 ----
strcpy (newstr, str);
return newstr;
}
+
+
+ #ifdef MSDOS
+ /* Shorten a MS-DOS path to accomodate a backup suffix. */
+
+ char *
+ chop_filename (char *path, int n)
+ {
+ char *base;
+ char *suffix;
+
+ base = strrchr (path, '/');
+ if (base == (char *)0)
+ base = path;
+ else
+ base++;
+
+ suffix = strchr (base, '.');
+ if (suffix == (char *)0)
+ strcat (base, "."); /* is ok, since we have allocated enough! */
+ else if (strlen (suffix) >= 4 - n)
+ suffix[4-n] = '\0';
+
+ return path;
+ }
+ #endif /* MSDOS */
+
+
+
*** e:\tmp/RCSt1006574 Wed Sep 19 13:27:50 1990
--- cat.c Wed Sep 19 12:31:34 1990
***************
*** 14,19 ****
--- 14,44 ----
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/cat.c 1.4.0.2 90/09/19 11:17:40 tho Exp $";
+
+ static char Program_Id[] = "cat";
+ static char RCS_Revision[] = "$Revision: 1.4.0.2 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
/* Differences from the Unix cat:
* Always unbuffered, -u is ignored.
***************
*** 27,34 ****
--- 52,61 ----
#include <errno.h>
#include <sys/types.h>
#ifndef _POSIX_SOURCE
+ #ifndef MSDOS
#include <sys/ioctl.h>
#endif
+ #endif
#include "system.h"
#ifdef STDC_HEADERS
***************
*** 40,49 ****
extern int errno;
#endif
! #define max(h,i) ((h) > (i) ? (h) : (i))
! typedef unsigned char uchar;
char *copystring ();
void cat ();
void error ();
--- 67,92 ----
extern int errno;
#endif
! #ifdef MSDOS
! #include <string.h>
! #include <fcntl.h>
! #include <malloc.h>
! #include <io.h>
!
! extern void main (int, char **);
! extern void error (int status, int errnum, char *message, ...);
! extern void usage (char *);
! extern void simple_cat (unsigned char *, int);
! extern void cat (unsigned char *, int, unsigned char *,\
! int, int, int, int, int, int, int);
! extern void next_line_num (void);
! extern char *copystring (char *, char *);
!
! #else /* not MSDOS */
+ #define max(h,i) ((h) > (i) ? (h) : (i))
+
char *copystring ();
void cat ();
void error ();
***************
*** 50,55 ****
--- 93,102 ----
void next_line_num ();
void simple_cat ();
+ #endif /* not MSDOS */
+
+ typedef unsigned char uchar;
+
/* Name under which this program was invoked. */
char *program_name;
***************
*** 89,98 ****
--- 136,152 ----
if (reason != NULL)
fprintf (stderr, "%s: %s\n", program_name, reason);
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-benstuvABET] [+number] [+number-nonblank] [+squeeze-blank]\n\
+ [+show-nonprinting] [+show-ends] [+show-tabs] [+show-all] [+binary]\n\
+ [+copying] [+version] [file...]\n", program_name);
+ #else /* not MSDOS */
fprintf (stderr, "\
Usage: %s [-benstuvAET] [+number] [+number-nonblank] [+squeeze-blank]\n\
[+show-nonprinting] [+show-ends] [+show-tabs] [+show-all] [file...]\n",
program_name);
+ #endif /* not MSDOS */
exit (2);
}
***************
*** 140,148 ****
--- 194,210 ----
int output_tabs = 1;
int options = 0;
int longind;
+ #ifdef MSDOS
+ int binary = 0;
+ #endif
static struct option long_options[] =
{
+ #ifdef MSDOS
+ {"binary", 0, NULL, 'B'},
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"number-nonblank", 0, NULL, 'b'},
{"number", 0, NULL, 'n'},
{"squeeze-blank", 0, NULL, 's'},
***************
*** 157,163 ****
--- 219,229 ----
/* Parse command line options. */
+ #ifdef MSDOS
+ while ((c = getopt_long (argc, argv, "benstuvABET", long_options, &longind))
+ #else
while ((c = getopt_long (argc, argv, "benstuvAET", long_options, &longind))
+ #endif
!= EOF)
{
options++;
***************
*** 201,206 ****
--- 267,289 ----
output_tabs = 0;
break;
+ #ifdef MSDOS
+ case 'B':
+ binary++;
+ options--; /* stdout will be binary iff no other option! */
+ break;
+
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
+
case 'E':
mark_line_ends = 1;
break;
***************
*** 263,268 ****
--- 346,363 ----
}
}
+ #ifdef MSDOS
+ if (binary)
+ {
+ setmode (input_desc, O_BINARY);
+
+ /* We will not set the output to binary mode if we have
+ another (verbose) option active. */
+ if (options == 0)
+ setmode (output_desc, O_BINARY);
+ }
+ #endif
+
if (fstat (input_desc, &stat_buf) < 0)
{
error (0, errno, "%s", infile);
***************
*** 299,304 ****
--- 394,402 ----
}
else
{
+ #ifdef MSDOS /* the user wants it slow, he can get it! */
+ insize = outsize = 0x1000;
+ #endif
inbuf = (uchar *) malloc (insize + 1);
if (inbuf == NULL)
error (1, 0, "virtual memory exhausted");
*** e:\tmp/RCSt1006574 Wed Sep 19 13:27:52 1990
--- chmod.c Wed Sep 19 12:32:40 1990
***************
*** 15,20 ****
--- 15,45 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/chmod.c 1.4.0.2 90/09/19 11:17:44 tho Exp $";
+
+ static char Program_Id[] = "chmod";
+ static char RCS_Revision[] = "$Revision: 1.4.0.2 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
/* Usage: chmod [-Rcdfv] mode file...
mode is [ugoa...][[+-=][rwxXstugo...]...][,...] or octal number.
***************
*** 44,49 ****
--- 69,99 ----
extern int errno;
#endif
+ #ifdef MSDOS
+
+ #include <malloc.h>
+ #include <io.h>
+
+ #define lstat stat
+
+ extern void main (int argc, char **argv);
+ extern void filemodestring (struct stat *,char *);
+ extern void error (int status, int errnum, char *message, ...);
+ extern void mode_string (unsigned short mode, char *str);
+
+ static int change_file_mode (char *file, struct mode_change *changes);
+ static int change_dir_mode (char *dir, struct mode_change *changes,\
+ struct stat *statp);
+ extern char *savedir (char *dir, unsigned name_size);
+ static char *stpcpy (char *dest, char *source);
+ static void describe_change (char *file, unsigned short mode, int changed);
+ static char *xmalloc (unsigned int n);
+ static char *xrealloc (char *p, unsigned n);
+ static char *stp_cpy (char *dest, char *source);
+ static void usage (void);
+
+ #else /* not MSDOS */
+
int lstat ();
int stat ();
***************
*** 57,62 ****
--- 107,114 ----
void mode_string ();
void usage ();
+ #endif /* not MSDOS */
+
typedef enum
{
false = 0, true = 1
***************
*** 78,84 ****
--- 130,140 ----
boolean changes_only;
/* A pointer to either lstat or stat. */
+ #ifdef MSDOS
+ int (*xstat) (char *, struct stat *);
+ #else
int (*xstat) ();
+ #endif
/* Parse the ASCII mode given on the command line into a linked list
of `struce mode_change' and apply that to each file argument. */
***************
*** 103,109 ****
--- 159,169 ----
{
thisind = optind ? optind : 1;
+ #ifdef MSDOS
+ c = getopt (argc, argv, "RcdfvrwxXstugoa,+-=CV");
+ #else
c = getopt (argc, argv, "RcdfvrwxXstugoa,+-=");
+ #endif
if (c == EOF)
break;
***************
*** 143,148 ****
--- 203,218 ----
case 'v':
verbose = true;
break;
+ #ifdef MSDOS
+ case 'C':
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+ case 'V':
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
default:
usage ();
}
***************
*** 314,322 ****
--- 384,399 ----
void
usage ()
{
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-RcdfvCV] mode file...\n\
+ mode is [ugoa...][[+-=][rwxXstugo...]...][,...] or octal number\n",
+ program_name);
+ #else /* not MSDOS */
fprintf (stderr, "\
Usage: %s [-Rcdfv] mode file...\n\
mode is [ugoa...][[+-=][rwxXstugo...]...][,...] or octal number\n",
program_name);
+ #endif /* not MSDOS */
exit (1);
}
*** e:\tmp/RCSt1006574 Wed Sep 19 13:27:54 1990
--- cmp.c Wed Sep 19 12:34:26 1990
***************
*** 14,19 ****
--- 14,44 ----
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/cmp.c 1.4.0.2 90/09/19 11:17:46 tho Exp $";
+
+ static char Program_Id[] = "cmp";
+ static char RCS_Revision[] = "$Revision: 1.4.0.2 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
/* Differences from the Unix cmp:
* 6 - 40 - oo times faster.
***************
*** 38,43 ****
--- 63,82 ----
extern int errno;
#endif
+ #ifdef MSDOS
+ #include <io.h>
+ #include <gnulib.h>
+
+ extern void main (int, char **);
+ extern void usage (char *);
+ extern void cmp (void);
+ extern int bcmp2 (char *, char *);
+ extern int bcmp_cnt (int *count, char *p1, char *p2, unsigned char c);
+ extern int bread (int, char *, int);
+ extern void printc (FILE *fs, int width, unsigned int c);
+
+ #else /* not MSDOS */
+
#define max(h, i) ((h) > (i) ? (h) : (i))
#define min(l, o) ((l) < (o) ? (l) : (o))
***************
*** 48,53 ****
--- 87,94 ----
void printc ();
void error ();
+ #endif /* not MSDOS */
+
/* Name under which this program was invoked. */
char *program_name;
***************
*** 83,88 ****
--- 124,133 ----
struct option long_options[] =
{
+ #ifdef MSDOS
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"show-chars", 0, &flag_print_chars, 1},
{"silent", 0, &flag, 's'},
{"quiet", 0, &flag, 's'},
***************
*** 97,105 ****
--- 142,157 ----
if (reason != NULL)
fprintf (stderr, "%s: %s\n", program_name, reason);
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-cls] [+show-chars] [+verbose] [+silent] [+quiet]\n\
+ [+copying] [+version] file1 [file2]\n",
+ program_name);
+ #else /* not MSDOS */
fprintf (stderr, "\
Usage: %s [-cls] [+show-chars] [+verbose] [+silent] [+quiet] file1 [file2]\n",
program_name);
+ #endif /* not MSDOS */
exit (2);
}
***************
*** 139,144 ****
--- 191,208 ----
flag = c;
break;
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
+
default:
usage ((char *) 0);
}
***************
*** 233,238 ****
--- 297,307 ----
if (buf1 == NULL || buf2 == NULL)
error (2, 0, "virtual memory exhausted");
+ #ifdef MSDOS
+ setmode (file1_desc, O_BINARY);
+ setmode (file2_desc, O_BINARY);
+ #endif
+
cmp ();
}
***************
*** 426,431 ****
--- 495,501 ----
return p1c - p1;
}
+
/* Compare two blocks of memory P1 and P2 until they differ.
Assumes that P1 and P2 are aligned at long addresses!
If the blocks are not guaranteed to be different, put sentinels at the ends
***************
*** 508,514 ****
--- 578,589 ----
--width;
}
+ #ifdef MSDOS
+ putc ((int) c, fs);
+ #else
putc (c, fs);
+ #endif
+
while (--width > 0)
putc (' ', fs);
}
*** e:\tmp/RCSt1006574 Wed Sep 19 13:27:58 1990
--- cp-aux.c Wed Sep 19 12:37:08 1990
***************
*** 18,23 ****
--- 18,35 ----
Written by Torbjorn Granlund, Sweden (tege@sics.se).
*/
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fileutil/RCS/cp-aux.c 1.4.0.2 90/09/19 11:18:11 tho Exp $
+ */
+
#include <stdio.h>
#include "cp.h"
***************
*** 31,36 ****
--- 43,63 ----
if (reason != NULL)
fprintf (stderr, "%s: %s\n", program_name, reason);
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-bdfipruvxR] [-S backup-suffix] [-V {numbered,existing,simple}]\n\
+ [+backup] [+no-dereference] [+force] [+interactive] [+one-file-system]\n\
+ [+preserve] [+recursive] [+update] [+verbose] [+suffix backup-suffix]\n\
+ [+version-control {numbered,existing,simple}] [+copying] [+version]\n\
+ source dest\n\
+ \n\
+ %s [-bdfipruvxR] [-S backup-suffix] [-V {numbered,existing,simple}]\n\
+ [+backup] [+no-dereference] [+force] [+interactive] [+one-file-system]\n\
+ [+preserve] [+recursive] [+update] [+verbose] [+suffix backup-suffix]\n\
+ [+version-control {numbered,existing,simple}] [+copying] [+version]\n\
+ source... directory\n",
+ program_name, program_name);
+ #else /* not MSDOS */
fprintf (stderr, "\
Usage: %s [-bdfipruvxR] [-S backup-suffix] [-V {numbered,existing,simple}]\n\
[+backup] [+no-dereference] [+force] [+interactive] [+one-file-system]\n\
***************
*** 42,51 ****
--- 69,82 ----
[+preserve] [+recursive] [+update] [+verbose] [+suffix backup-suffix]\n\
[+version-control {numbered,existing,simple}] source... directory\n",
program_name, program_name);
+ #endif /* not MSDOS */
exit (2);
}
+ /* Use the one from gnulib */
+ #ifndef MSDOS
+
char *
xmalloc (size)
unsigned size;
***************
*** 67,72 ****
--- 98,105 ----
return x;
}
+ #endif /* not MSDOS */
+
char *
stpcpy (s1, s2)
char *s1;
***************
*** 89,94 ****
--- 122,130 ----
return c == 'y' || c == 'Y';
}
+
+ #ifndef MSDOS /* no links ... */
+
int
is_ancestor (sb, ancestors)
struct stat *sb;
***************
*** 103,108 ****
--- 139,145 ----
return 0;
}
+
/* Remove trailing slashes from PATH; they cause some system calls to fail. */
void
***************
*** 115,117 ****
--- 152,166 ----
while (last > 0 && path[last] == '/')
path[last--] = '\0';
}
+
+ #else /* MSDOS */
+
+ void
+ strip_trailing_slashes (char **path)
+ {
+ char *new_path = _fullpath (NULL, *path, 0);
+ free (*path);
+ *path = msdos_format_filename (new_path);
+ }
+
+ #endif /* MSDOS */
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:00 1990
--- cp.c Wed Sep 19 12:35:14 1990
***************
*** 17,22 ****
--- 17,45 ----
Written by Torbjorn Granlund and David MacKenzie. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/cp.c 1.4.0.2 90/09/19 11:18:06 tho Exp $";
+
+ static char Program_Id[] = "cp";
+ static char RCS_Revision[] = "$Revision: 1.4.0.2 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+
/* Yet to be done:
* Symlink translation. */
***************
*** 26,31 ****
--- 49,70 ----
#include "cp.h"
#include "backupfile.h"
+ #ifdef MSDOS
+ #include <assert.h>
+
+ extern enum backup_type get_version (char *version);
+ extern char *savedir (char *dir, unsigned name_size);
+
+ #define strip_trailing_slashes(path) strip_trailing_slashes (&path)
+ #define is_ancestor(statb, ancestors) 0
+ #define hash_init(module, size)
+ #define remember_copied(path, ino, dev) NULL
+ #define remember_created(path) 0
+ #define forget_all()
+ char new_file;
+
+ #endif
+
#ifdef MKFIFO_MISSING
/* This definition assumes that MODE has the S_IFIFO bit set. */
#define mkfifo(path, mode) (mknod ((path), (mode), 0))
***************
*** 42,48 ****
--- 81,91 ----
/* A pointer to either lstat or stat, depending on
whether dereferencing of symlinks is done. */
+ #ifdef MSDOS
+ int (*xstat) (char *, struct stat *);
+ #else
int (*xstat) ();
+ #endif
/* The invocation name of this program. */
char *program_name;
***************
*** 87,92 ****
--- 130,139 ----
struct option long_opts[] =
{
+ #ifdef MSDOS
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"backup", 0, NULL, 'b'},
{"force", 0, NULL, 'f'},
{"interactive", 0, NULL, 'i'},
***************
*** 123,129 ****
--- 170,180 ----
that created directories can be written, even if it would not
have been allowed with the mask this process was started with. */
+ #ifdef MSDOS /* not 100%ly correct ... */
+ umask_kill = 07777 ^ umask (0);
+ #else
umask_kill = 0777777 ^ umask (0);
+ #endif
while ((c = getopt_long (argc, argv, "bdfipruvxRS:V:", long_opts, &ind))
!= EOF)
***************
*** 185,190 ****
--- 236,253 ----
version = optarg;
break;
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
+
default:
usage ((char *) 0);
}
***************
*** 194,200 ****
--- 257,267 ----
backup_type = get_version (version);
if (flag_preserve == 1)
+ #ifdef MSDOS /* not 100%ly correct ... */
+ umask_kill = 07777;
+ #else
umask_kill = 0777777;
+ #endif
/* The key difference between -d (+no-dereference) and not is the version
of `stat' to call. */
***************
*** 280,285 ****
--- 347,359 ----
else
ap++;
dst_path = xmalloc (strlen (target) + strlen (ap) + 2);
+ #ifdef MSDOS
+ /* Here a trailing slash might still be present (needed for
+ stat()'ing root directories), take care of that. */
+ if (target[strlen(target) - 1] == '/')
+ stpcpy (stpcpy (dst_path, target), ap);
+ else
+ #endif /* MSDOS */
stpcpy (stpcpy (stpcpy (dst_path, target), "/"), ap);
ret |= copy (arg, dst_path, new_dst, 0, (struct dir_list *) 0);
***************
*** 317,323 ****
--- 391,401 ----
struct stat src_sb;
struct stat dst_sb;
int src_mode;
+ #ifdef MSDOS
+ unsigned int src_type;
+ #else /* not MSDOS */
int src_type;
+ #endif /* not MSDOS */
char *earlier_file;
char *dst_backup = NULL;
int dir_mode_changed = 0;
***************
*** 373,379 ****
else
{
/* The file exists already. */
!
if (src_sb.st_ino == dst_sb.st_ino && src_sb.st_dev == dst_sb.st_dev)
{
error (0, 0, "`%s' and `%s' are the same file",
--- 451,463 ----
else
{
/* The file exists already. */
! #ifdef MSDOS
! if (strcmp (dst_path, src_path) == 0)
! {
! error (0, 0, "`%s': can't copy file to itself", src_path);
! return 1;
! }
! #else /* not MSDOS */
if (src_sb.st_ino == dst_sb.st_ino && src_sb.st_dev == dst_sb.st_dev)
{
error (0, 0, "`%s' and `%s' are the same file",
***************
*** 380,385 ****
--- 464,470 ----
src_path, dst_path);
return 1;
}
+ #endif /* not MSDOS */
if (src_type != S_IFDIR)
{
***************
*** 496,501 ****
--- 581,587 ----
break;
#endif
+ #ifndef MSDOS
case S_IFBLK:
case S_IFCHR:
#ifdef S_IFSOCK
***************
*** 507,512 ****
--- 593,599 ----
goto un_backup;
}
break;
+ #endif /* not MSDOS */
case S_IFDIR:
{
***************
*** 526,531 ****
--- 613,623 ----
/* Insert the current directory in the list of parents. */
dir = (struct dir_list *) alloca (sizeof (struct dir_list));
+ #ifdef MSDOS /* always short of stack space ... */
+ if (!dir)
+ error (1, 0, "%s: stack overflow", src_path);
+ #endif
+
dir->parent = ancestors;
dir->ino = src_sb.st_ino;
dir->dev = src_sb.st_dev;
***************
*** 668,674 ****
--- 760,771 ----
int ret = 0;
errno = 0;
+ #ifdef MSDOS
+ assert (src_sb->st_size < 0xffffL);
+ name_space = savedir (src_path_in, (size_t) src_sb->st_size);
+ #else
name_space = savedir (src_path_in, src_sb->st_size);
+ #endif
if (name_space == 0)
{
if (errno)
***************
*** 728,734 ****
--- 825,835 ----
int *ip;
int last_write_made_hole = 0;
+ #ifdef MSDOS
+ source_desc = open (src_path, O_BINARY | O_RDONLY);
+ #else
source_desc = open (src_path, O_RDONLY);
+ #endif
if (source_desc < 0)
{
error (0, errno, "%s", src_path);
***************
*** 738,744 ****
--- 839,849 ----
/* Create the new regular file with small permissions initially,
to not create a security hole. */
+ #ifdef MSDOS
+ target_desc = open (dst_path, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0600);
+ #else
target_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+ #endif
if (target_desc < 0)
{
error (0, errno, "cannot create regular file `%s'", dst_path);
***************
*** 760,765 ****
--- 865,874 ----
/* Make a buffer with space for a sentinel at the end. */
buf = (char *) alloca (buf_size + sizeof (int));
+ #ifdef MSDOS
+ if (!buf)
+ error (2, 0, "%s: stack overflow", src_path);
+ #endif
for (;;)
{
***************
*** 773,779 ****
--- 882,892 ----
if (n_read == 0)
break;
+ #ifdef MSDOS
+ n_read_total += (long) n_read;
+ #else
n_read_total += n_read;
+ #endif
buf[n_read] = 1; /* Sentinel to stop loop. */
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:02 1990
--- cp.h Wed Sep 19 12:35:24 1990
***************
*** 17,22 ****
--- 17,34 ----
Written by Torbjorn Granlund, Sweden (tege@sics.se). */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fileutil/RCS/cp.h 1.4.0.2 90/09/19 12:27:43 tho Exp $
+ */
+
#include <sys/types.h>
#include "system.h"
***************
*** 48,53 ****
--- 60,77 ----
extern int exit_status;
extern struct htab *htab;
+ #ifdef MSDOS
+
+ #include <gnulib.h>
+
+ extern void forget_all (void);
+ extern int copy_reg (char *, char *);
+ extern void hash_init (unsigned int, unsigned int);
+ extern int remember_created (char *);
+ extern char *remember_copied (char *, unsigned short, short);
+
+ #else /* not MSDOS */
+
extern char *xmalloc ();
extern char *xrealloc ();
extern void forget_copied ();
***************
*** 57,66 ****
--- 81,106 ----
extern char *remember_copied ();
extern int remember_created ();
+ #endif /* not MSDOS */
+
/* For created inodes, a pointer in the search structure to this
character identifies that the inode as new. */
extern char new_file;
+ #ifdef MSDOS
+ extern void main (int, char **);
+ extern void usage (char *);
+ extern void error (int status, int errnum, char *message, ...);
+ extern int yesno (void);
+ extern char *stpcpy (char *, char *);
+ extern int user_confirm_overwriting (char *);
+ extern int member (int);
+ extern int do_copy (int, char **);
+ extern int copy (char *, char *, int, short, struct dir_list *);
+ extern int copy_dir(char *,char *,int,struct stat *,struct dir_list *);
+ extern void strip_trailing_slashes (char **path);
+ #endif /* MSDOS */
+
extern void error ();
extern void usage ();
extern char *savedir ();
***************
*** 73,78 ****
--- 113,136 ----
extern int is_ancestor ();
/* System calls. */
+
+ #ifdef MSDOS
+
+ #include <direct.h>
+ #include <io.h>
+ #include <malloc.h>
+ #include <pwd.h>
+
+ /* Very "interesting" system calls ... */
+ #define link(a, b) (-1)
+ #define chown(path, uid, gid) 0
+ #define mkdir(path, mode) mkdir (path)
+ #define ftruncate chsize
+
+ extern int eaccess_stat (struct stat *statp, int mode);
+
+ #else /* not MSDOS */
+
extern int mknod ();
#ifdef _POSIX_SOURCE
***************
*** 100,105 ****
--- 158,165 ----
extern int isatty ();
extern off_t lseek ();
#endif
+
+ #endif /* not MSDOS */
/* Library calls. */
#include <errno.h>
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:04 1990
--- cut.c Wed Sep 19 12:38:18 1990
***************
*** 62,67 ****
--- 62,92 ----
A FILE of `-' means standard input. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/cut.c 1.4.0.3 90/09/19 11:17:49 tho Exp $";
+
+ static char Program_Id[] = "cut";
+ static char RCS_Revision[] = "$Revision: 1.4.0.3 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
***************
*** 78,83 ****
--- 103,123 ----
extern int errno;
#endif
+ #ifdef MSDOS
+
+ #include <gnulib.h>
+
+ void main (int argc, char **argv);
+ int set_fields (char *fieldstr);
+ void cut_file (FILE * stream);
+ void cut_file_bytes (FILE * fno);
+ void cut_file_fields (FILE * fno);
+ void enlarge_line (int new_size);
+ void invalid_list (void);
+ void usage (void);
+
+ #else /* not MSDOS */
+
char *xmalloc ();
char *xrealloc ();
int set_fields ();
***************
*** 89,94 ****
--- 129,136 ----
void invalid_list ();
void usage ();
+ #endif /* not MSDOS */
+
/* The number of elements allocated for the input line
and the byte or field number.
Enlarged as necessary. */
***************
*** 138,143 ****
--- 180,189 ----
struct option longopts[] =
{
+ #ifdef MSDOS
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"bytes", 1, 0, 'b'},
{"characters", 1, 0, 'c'},
{"fields", 1, 0, 'f'},
***************
*** 211,216 ****
--- 257,274 ----
delimited_lines_only++;
break;
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
+
default:
usage ();
}
***************
*** 528,533 ****
--- 586,594 ----
line_size = new_size;
}
+
+ #ifndef MSDOS /* We have it in gnulib */
+
/* Allocate N bytes of memory dynamically, with error checking. */
char *
***************
*** 553,558 ****
--- 614,621 ----
return p;
}
+ #endif /* not MSDOS */
+
void
invalid_list ()
{
***************
*** 562,567 ****
--- 625,641 ----
void
usage ()
{
+
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s {-b byte-list,+bytes byte-list} [-n] [+copying]\n\
+ [+version] [file...]\n\
+ %s {-c character-list,+characters character-list} [+copying]\n\
+ [+version] [file...]\n\
+ %s {-f field-list,+fields field-list} [-d delim] [-s]\n\
+ [+delimiter delim] [+only-delimited] [+copying] [+version] [file...]\n",
+ program_name, program_name, program_name);
+ #else /* not MSDOS */
fprintf (stderr, "\
Usage: %s {-b byte-list,+bytes byte-list} [-n] [file...]\n\
%s {-c character-list,+characters character-list} [file...]\n\
***************
*** 568,572 ****
--- 642,647 ----
%s {-f field-list,+fields field-list} [-d delim] [-s]\n\
[+delimiter delim] [+only-delimited] [file...]\n",
program_name, program_name, program_name);
+ #endif /* not MSDOS */
exit (2);
}
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:08 1990
--- dd.c Wed Sep 19 12:41:20 1990
***************
*** 17,22 ****
--- 17,47 ----
/* Written by Paul Rubin and David MacKenzie. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/dd.c 1.4.0.2 90/09/19 11:17:53 tho Exp $";
+
+ static char Program_Id[] = "dd";
+ static char RCS_Revision[] = "$Revision: 1.4.0.2 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
/* Options:
Numbers can be followed by a multiplier:
***************
*** 53,58 ****
--- 78,90 ----
sync Pad every input block to size of ibs with
trailing NULs. */
+ #ifdef MSDOS
+ /*
+ im={text,binary} Input file translation mode (default: text)
+ om={text,binary} Output file translation mode (default: text)
+ */
+ #endif
+
#include <stdio.h>
#include <ctype.h>
#ifdef STDC_HEADERS
***************
*** 65,70 ****
--- 97,103 ----
#include <sys/types.h>
#include <signal.h>
#include "system.h"
+
#ifdef STDC_HEADERS
#include <errno.h>
#include <stdlib.h>
***************
*** 79,85 ****
--- 112,120 ----
#endif
#define equal(p, q) (strcmp ((p),(q)) == 0)
+ #ifndef MSDOS
#define max(a, b) ((a) > (b) ? (a) : (b))
+ #endif
/* Default input and output blocksize. */
#define DEFAULT_BLOCKSIZE 512
***************
*** 98,103 ****
--- 133,160 ----
/* Use separate input and output buffers, and combine partial input blocks. */
#define C_TWOBUFS 04000
+
+ #ifdef MSDOS
+
+ #include <io.h>
+ extern void error (int status, int errnum, char *message, ...);
+
+ extern void main (int argc, char **argv);
+ static void copy (void);
+ static void scanargs (int argc, char **argv);
+ static int parse_integer (char *str);
+ static void parse_conversion (char *str);
+ static void apply_translations (void);
+ static void translate_charset (unsigned char *new_trans);
+ static int bit_count (unsigned int i);
+ static void print_stats (void);
+ static void quit (int code);
+ static SIGTYPE interrupt_handler (void);
+ static char *xmalloc (unsigned short n);
+ static void usage (char *string, char *arg0, char *arg1);
+
+ #else /* not MSDOS */
+
char *xmalloc ();
SIGTYPE interrupt_handler ();
int bit_count ();
***************
*** 112,117 ****
--- 169,176 ----
void scanargs ();
void usage ();
+ #endif /* not MSDOS */
+
/* The name this program was run with. */
char *program_name;
***************
*** 128,146 ****
--- 187,221 ----
int output_fd = 1;
/* The number of bytes in which atomic reads are done. */
+ #ifdef MSDOS
+ int input_blocksize = -1;
+ #else
long input_blocksize = -1;
+ #endif
/* The number of bytes in which atomic writes are done. */
+ #ifdef MSDOS
+ int output_blocksize = -1;
+ #else
long output_blocksize = -1;
+ #endif
/* Conversion buffer size, in bytes. 0 prevents conversions. */
+ #ifdef MSDOS
+ int conversion_blocksize = 0;
+ #else
long conversion_blocksize = 0;
+ #endif
/* Skip this many records of `input_blocksize' bytes before input. */
int skip_records = 0;
/* Skip this many records of `output_blocksize' bytes before output. */
+ #ifdef MSDOS
+ int seek_record = 0;
+ #else
long seek_record = 0;
+ #endif
/* Copy only this many records. <0 means no limit. */
int max_record = -1;
***************
*** 163,168 ****
--- 238,249 ----
/* Records truncated by conv=block. */
unsigned r_truncate = 0;
+ #ifdef MSDOS
+ /* Translation modes */
+ int input_file_mode = O_TEXT;
+ int output_file_mode = O_TEXT;
+ #endif
+
/* Output representation of newline and space characters. */
unsigned char newline_character = '\n';
unsigned char space_character = ' ';
***************
*** 312,317 ****
--- 393,399 ----
for (i = 0; i < 256; i++)
trans_table[i] = i;
+
/* Decode arguments. */
scanargs (argc, argv);
apply_translations ();
***************
*** 333,339 ****
}
else
output_file = "standard output";
!
signal (SIGINT, interrupt_handler);
copy ();
}
--- 415,426 ----
}
else
output_file = "standard output";
!
! #ifdef MSDOS
! setmode (input_fd, input_file_mode);
! setmode (output_fd, output_file_mode);
! #endif
!
signal (SIGINT, interrupt_handler);
copy ();
}
***************
*** 369,375 ****
--- 456,466 ----
}
if ((in_stats.st_mode & S_IFMT) == S_IFREG)
{
+ #ifdef MSDOS
+ if (lseek (input_fd, skip_records * (long) input_blocksize, L_SET) < 0)
+ #else
if (lseek (input_fd, skip_records * input_blocksize, L_SET) < 0)
+ #endif
{
error (0, errno, "%s", input_file);
quit (1);
***************
*** 393,399 ****
--- 484,494 ----
}
if ((out_stats.st_mode & S_IFMT) == S_IFREG)
{
+ #ifdef MSDOS
+ if (lseek (output_fd, seek_record * (long) output_blocksize, L_SET) < 0)
+ #else
if (lseek (output_fd, seek_record * output_blocksize, L_SET) < 0)
+ #endif
{
error (0, errno, "%s", output_file);
quit (1);
***************
*** 643,648 ****
--- 738,755 ----
char *name, *val;
name = argv[i];
+ #ifdef MSDOS
+ if (equal (name, "copying"))
+ {
+ fprintf (stderr, COPYING);
+ exit (0);
+ }
+ else if (equal (name, "version"))
+ {
+ fprintf (stderr, VERSION);
+ exit (0);
+ }
+ #endif
val = index (name, '=');
if (val == NULL)
usage ("unrecognized option `%s'", name);
***************
*** 654,659 ****
--- 761,786 ----
output_file = val;
else if (equal (name, "conv"))
parse_conversion (val);
+ #ifdef MSDOS
+ else if (equal (name, "im"))
+ {
+ if (equal (val, "text"))
+ input_file_mode = O_TEXT;
+ else if (equal (val, "binary"))
+ input_file_mode = O_BINARY;
+ else
+ error (1, 0, "Input file mode must be text or binary");
+ }
+ else if (equal (name, "om"))
+ {
+ if (equal (val, "text"))
+ output_file_mode = O_TEXT;
+ else if (equal (val, "binary"))
+ output_file_mode = O_BINARY;
+ else
+ error (1, 0, "Output file mode must be text or binary");
+ }
+ #endif /* MSDOS */
else
{
n = parse_integer (val);
***************
*** 886,891 ****
--- 1013,1028 ----
fprintf (stderr, "%s: ", program_name);
fprintf (stderr, string, arg0, arg1);
fprintf (stderr, "\n");
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [if=file] [of=file] [ibs=bytes] [obs=bytes] [bs=bytes] [cbs=bytes]\n\
+ [skip=blocks] [seek=blocks] [count=blocks]\n\
+ [im={text,binary}] [om={text,binary}] [copying] [version]\n\
+ [conv={ascii,ebcdic,ibm,block,unblock,lcase,ucase,swab,noerror,sync}]\n\
+ Numbers can be followed by a multiplier:\n\
+ b=512, k=1024, w=2, xm=number m\n",
+ program_name);
+ #else /* not MSDOS */
fprintf (stderr, "\
Usage: %s [if=file] [of=file] [ibs=bytes] [obs=bytes] [bs=bytes] [cbs=bytes]\n\
[skip=blocks] [seek=blocks] [count=blocks]\n\
***************
*** 893,897 ****
--- 1030,1035 ----
Numbers can be followed by a multiplier:\n\
b=512, k=1024, w=2, xm=number m\n",
program_name);
+ #endif /* not MSDOS */
exit (1);
}
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:10 1990
--- eaccess.c Wed Sep 19 12:37:30 1990
***************
*** 17,33 ****
--- 17,55 ----
/* David MacKenzie and Torbjorn Granlund */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fileutil/RCS/eaccess.c 1.4.0.2 90/09/19 12:27:30 tho Exp $
+ */
+
#include <sys/types.h>
#include <sys/stat.h>
#ifdef _POSIX_SOURCE
#include <unistd.h>
#else
+ #ifdef MSDOS
+ #include <pwd.h>
+ #else /* not MSDOS */
#include <sys/param.h>
+ #endif /* not MSDOS */
#endif
#include <errno.h>
#if defined(EACCES) && !defined(EACCESS)
#define EACCESS EACCES
#endif
+
+ #ifdef MSDOS
+ #include <stdlib.h>
+ extern int eaccess (char *path, int mode);
+ extern int eaccess_stat (struct stat *statp, int mode);
+ #endif /* MSDOS */
#ifndef _POSIX_SOURCE
#define F_OK 0
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:14 1990
--- filemode.c Wed Sep 19 12:33:12 1990
***************
*** 14,19 ****
--- 14,31 ----
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fileutil/RCS/filemode.c 1.4.0.1 90/09/17 08:18:12 tho Exp $
+ */
#include <sys/types.h>
#include <sys/stat.h>
***************
*** 23,32 ****
--- 35,52 ----
#define S_IEXEC S_IXUSR
#endif
+ #ifdef MSDOS
+ extern void filemodestring (struct stat *, char *);
+ extern void mode_string (unsigned short mode, char *str);
+ static char ftypelet (unsigned short bits);
+ static void rwx (unsigned short, char *);
+ static void setst (unsigned short, char *);
+ #else /* not MSDOS */
void mode_string ();
static char ftypelet ();
static void rwx ();
static void setst ();
+ #endif /* not MSDOS */
/* filemodestring - fill in string STR with an ls-style ASCII
representation of the st_mode field of file stats block STATP.
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:16 1990
--- getdate.y Wed Sep 19 12:52:14 1990
***************
*** 5,10 ****
--- 5,24 ----
/* University of North Carolina at Chapel Hill */
/* @(#)getdate.y 2.17 11/30/87 */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/getdate.y 1.4.0.2 90/09/19 12:27:47 tho Exp $";
+ #endif /* MSDOS */
+
/* #include "defs.h" JF not used any more */
#include <sys/types.h>
#ifdef USG
***************
*** 39,44 ****
--- 53,74 ----
#endif
#endif
+ #ifdef MSDOS
+ #include <malloc.h>
+ int getdate_yyparse (void);
+ long getdate (char *p, struct timeb *now);
+ void ftime (struct timeb *timeb);
+ static long dateconv (int mm, int dd, int yy, int h, int m, int s, int mer,
+ int zone, int dayflag);
+ static long dayconv (int ord, int day, long now);
+ static long timeconv (int hh, int mm, int ss, int mer);
+ static long monthadd (long sdate, long relmonth);
+ static long daylcorr (long future, long now);
+ static int lookup (char *id);
+ static int yyerror (char *s);
+ static int yylex (void);
+ #endif /* MSDOS */
+
#ifndef NULL
#define NULL 0
#endif
***************
*** 604,609 ****
--- 634,640 ----
{
return 0;
}
+
#ifdef USG
static void
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:18 1990
--- getversi.c Wed Sep 19 12:37:46 1990
***************
*** 17,26 ****
--- 17,44 ----
/* Written by David MacKenzie <djm@ai.mit.edu> */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fileutil/RCS/getversi.c 1.4.0.2 90/09/19 12:27:31 tho Exp $
+ */
+
#include "backupfile.h"
+ #ifdef MSDOS
+ extern enum backup_type get_version (char *version);
+ extern int argmatch (char *arg, char **optlist);
+ extern void invalid_arg (char *kind, char *value, int problem);
+ #else /* not MSDOS */
int argmatch ();
void invalid_arg ();
+ #endif /* not MSDOS */
extern char *program_name;
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:20 1990
--- head.c Wed Sep 19 12:42:30 1990
***************
*** 15,20 ****
--- 15,45 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/head.c 1.4.0.3 90/09/19 11:17:59 tho Exp $";
+
+ static char Program_Id[] = "head";
+ static char RCS_Revision[] = "$Revision: 1.4.0.3 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
/* Usage: head [-b #] [-c #] [-n #] [-qv] [+blocks #] [+bytes #] [+lines #]
[+quiet] [+silent] [+verbose] [file...]
***************
*** 64,69 ****
--- 89,97 ----
#define BYTES 1 /* Head in bytes. */
#define BLOCKS 2 /* Head in blocks. */
#define HEADERS 4 /* Write filename headers. */
+ #ifdef MSDOS
+ #define BINARY 32 /* Suppress crlf translation. */
+ #endif
/* When to print the filename banners. */
enum header_mode
***************
*** 71,76 ****
--- 99,125 ----
multiple_files, always, never
};
+ #ifdef MSDOS
+
+ #include <string.h>
+ #include <stdarg.h>
+ #include <io.h>
+
+ #include <gnulib.h>
+
+ extern void main (int, char **);
+ extern int head_file (char *, int, long);
+ extern void write_header (char *);
+ extern int head (char *, int, int, long);
+ extern int head_bytes (char *, int, long);
+ extern int head_lines (char *, int, long);
+ extern void xwrite (int, char *, int);
+ extern long atou (char *);
+ extern char *basename (char *);
+ extern void usage (void);
+
+ #else /* not MSDOS */
+
int head ();
int head_bytes ();
int head_file ();
***************
*** 81,91 ****
--- 130,147 ----
void write_header ();
void xwrite ();
+ #endif /* MSDOS */
+
/* The name this program was run with. */
char *program_name;
struct option long_options[] =
{
+ #ifdef MSDOS
+ {"binary", 1, NULL, 'B'},
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"blocks", 1, NULL, 'b'},
{"bytes", 1, NULL, 'c'},
{"lines", 1, NULL, 'n'},
***************
*** 154,164 ****
--- 210,240 ----
argc--;
}
+ #ifdef MSDOS
+ while ((c = getopt_long (argc, argv, "Bb:c:n:qv", long_options, &longind))
+ #else
while ((c = getopt_long (argc, argv, "b:c:n:qv", long_options, &longind))
+ #endif
!= EOF)
{
switch (c)
{
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+
+ case 'B':
+ mode |= BINARY;
+ break;
+ #endif
+
case 'b':
mode |= BLOCKS;
mode &= ~BYTES;
***************
*** 274,283 ****
--- 350,382 ----
int mode;
long number;
{
+ #ifdef MSDOS
+ int errors;
+
+ if (mode & BINARY)
+ {
+ setmode (fileno (stdout), O_BINARY);
+ setmode (fd, O_BINARY);
+ }
+
+ if (mode & (BYTES | BLOCKS))
+ errors = head_bytes (filename, fd, number);
+ else
+ errors = head_lines (filename, fd, number);
+
+ if (mode & BINARY)
+ setmode (fileno (stdout), O_TEXT);
+
+ return errors;
+
+ #else /* not MSDOS */
+
if (mode & (BYTES | BLOCKS))
return head_bytes (filename, fd, number);
else
return head_lines (filename, fd, number);
+
+ #endif /* not MSDOS */
}
int
***************
*** 299,308 ****
--- 398,414 ----
}
if (bytes_read == 0)
break;
+ #ifdef MSDOS
+ if ((long) bytes_read > bytes_to_write)
+ bytes_read = (int) bytes_to_write;
+ xwrite (1, buffer, bytes_read);
+ bytes_to_write -= (long) bytes_read;
+ #else /* not MSDOS */
if (bytes_read > bytes_to_write)
bytes_read = bytes_to_write;
xwrite (1, buffer, bytes_read);
bytes_to_write -= bytes_read;
+ #endif /* not MSDOS */
}
return 0;
}
***************
*** 356,371 ****
atou (str)
char *str;
{
! int value;
for (value = 0; ISDIGIT (*str); ++str)
value = value * 10 + *str - '0';
! return *str ? -1 : value;
}
void
usage ()
{
fprintf (stderr, "\
Usage: %s [-b #] [-c #] [-n #] [-qv] [+blocks #] [+bytes #] [+lines #]\n\
[+quiet] [+silent] [+verbose] [file...]\n\
--- 462,486 ----
atou (str)
char *str;
{
! long value;
for (value = 0; ISDIGIT (*str); ++str)
value = value * 10 + *str - '0';
! return *str ? -1L : value;
}
void
usage ()
{
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-b #] [-c #] [-n #] [-qvB] [+blocks #] [+bytes #]\n\
+ [+lines #] [+quiet] [+silent] [+verbose] [+binary] [+version]\n\
+ [+copying] [file...]\n\
+ \n\
+ %s [-#bclqv] [file...]\n", program_name, program_name);
+ exit (1);
+ #else
fprintf (stderr, "\
Usage: %s [-b #] [-c #] [-n #] [-qv] [+blocks #] [+bytes #] [+lines #]\n\
[+quiet] [+silent] [+verbose] [file...]\n\
***************
*** 372,375 ****
--- 487,491 ----
\n\
%s [-#bclqv] [file...]\n", program_name, program_name);
exit (1);
+ #endif
}
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:24 1990
--- ls.c Wed Sep 19 12:39:12 1990
***************
*** 14,19 ****
--- 14,43 ----
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/ls.c 1.4.0.2 90/09/19 11:18:27 tho Exp $";
+
+ static char RCS_Revision[] = "$Revision: 1.4.0.2 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", PROGNAME, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
/* If the macro MULTI_COL is defined,
the multi-column format is the default regardless
***************
*** 36,45 ****
--- 60,73 ----
#ifdef _POSIX_SOURCE
#define S_IEXEC S_IXUSR
#else
+ #ifndef MSDOS
#include <sys/ioctl.h>
+ #endif /* not MSDOS */
#endif
#include <stdio.h>
+ #ifndef MSDOS
#include <grp.h>
+ #endif
#include <pwd.h>
#include <getopt.h>
#include "system.h"
***************
*** 65,70 ****
--- 93,150 ----
extern int errno;
#endif
+ #ifdef MSDOS
+ #include <string.h>
+ #include <io.h>
+
+ #include <gnulib.h>
+
+ extern int glob_match (char *, char *, int);
+ extern void mode_string (unsigned short mode, char *str);
+ extern void main (int, char **);
+ extern int argmatch (char *, char **);
+ extern int decode_switches (int, char **);
+ extern void invalid_arg (char *, char *, int);
+ extern void queue_directory (char *, char *);
+ extern void print_dir (char *, char *);
+ extern void add_ignore_pattern (char *);
+ extern int file_interesting (struct direct *);
+ extern void clear_files (void);
+ extern int gobble_file (char *, int, char *);
+ extern void extract_dirs_from_files (char *, int);
+ extern int is_not_dot_or_dotdot (char *);
+ extern void sort_files (void);
+ extern int compare_ctime (struct file *, struct file *);
+ extern int rev_cmp_ctime (struct file *, struct file *);
+ extern int compare_mtime (struct file *, struct file *);
+ extern int rev_cmp_mtime (struct file *, struct file *);
+ extern int compare_atime (struct file *, struct file *);
+ extern int rev_cmp_atime (struct file *, struct file *);
+ extern int compare_size (struct file *, struct file *);
+ extern int rev_cmp_size (struct file *, struct file *);
+ extern int compare_name (struct file *, struct file *);
+ extern int rev_cmp_name (struct file *, struct file *);
+ extern int compare_extension (struct file *file1, struct file *file2);
+ extern int rev_cmp_extension (struct file *file1, struct file *file2);
+ extern void print_current_files (void);
+ extern void print_long_format (struct file *);
+ extern void print_name_with_quoting (char *);
+ extern void print_file_name_and_frills (struct file *);
+ extern void print_type_indicator (unsigned int);
+ extern int length_of_file_name_and_frills (struct file *);
+ extern void print_many_per_line (void);
+ extern void print_horizontal (void);
+ extern void print_with_commas (void);
+ extern char *getuser (unsigned short);
+ extern char *getgroup (unsigned short);
+ extern void indent (int, int);
+ extern char *copystring (char *);
+ extern void attach (char *, char *, char *);
+ extern char *basename (char *);
+ extern void usage (void);
+
+ #else /* not MSDOS */
+
struct group *getgrgid ();
struct passwd *getpwuid ();
int glob_match ();
***************
*** 114,119 ****
--- 194,201 ----
void queue_directory ();
void sort_files ();
void usage ();
+
+ #endif /* not MSDOS */
enum filetype
{
***************
*** 376,383 ****
--- 458,484 ----
if (i < argc)
dir_defaulted = 0;
+
+ #ifdef MSDOS
+ for (; i < argc; i++)
+ {
+ if (strlen (argv[i]) == 2 && argv[i][1] == ':')
+ {
+ /* The user wants the cwd on another drive. Help
+ DOS by appending a `.'! (This allows to stat()
+ the directory.) */
+ char *temp = (char *) xmalloc (4);
+ strcpy (temp, argv[i]);
+ strcat (temp, ".");
+ argv[i] = temp;
+ }
+
+ gobble_file (argv[i], 1, "");
+ }
+ #else /* not MSDOS */
for (; i < argc; i++)
gobble_file (argv[i], 1, "");
+ #endif /* not MSDOS */
if (dir_defaulted)
{
***************
*** 420,425 ****
--- 521,530 ----
struct option long_options[] =
{
+ #ifdef MSDOS
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"all", 0, 0, 'a'},
{"escape", 0, 0, 'b'},
{"directory", 0, 0, 'd'},
***************
*** 726,732 ****
}
format = formats[longind];
break;
!
default:
usage ();
}
--- 831,849 ----
}
format = formats[longind];
break;
!
! #ifdef MSDOS
! case 30:
! fprintf (stderr, COPYING);
! exit (0);
! break;
!
! case 31:
! fprintf (stderr, VERSION);
! exit (0);
! break;
! #endif
!
default:
usage ();
}
***************
*** 989,998 ****
--- 1106,1117 ----
kilobyte_blocks);
if (blocks >= 10000 && block_size_size < 5)
block_size_size = 5;
+ #ifndef MSDOS
if (blocks >= 100000 && block_size_size < 6)
block_size_size = 6;
if (blocks >= 1000000 && block_size_size < 7)
block_size_size = 7;
+ #endif /* not MSDOS */
}
else
blocks = 0;
***************
*** 1380,1387 ****
--- 1499,1510 ----
else
printf ("%-8.8s ", getgroup (f->stat.st_gid));
+ #ifdef S_IFBLK
if ((f->stat.st_mode & S_IFMT) == S_IFCHR
|| (f->stat.st_mode & S_IFMT) == S_IFBLK)
+ #else /* not S_IFBLK */
+ if ((f->stat.st_mode & S_IFMT) == S_IFCHR)
+ #endif /* not S_IFBLK */
printf ("%3u, %3u ", major (f->stat.st_rdev), minor (f->stat.st_rdev));
else
printf ("%8lu ", f->stat.st_size);
***************
*** 1769,1774 ****
--- 1892,1898 ----
return tail->name;
pwent = getpwuid (uid);
+
tail = (struct userid *) xmalloc (sizeof (struct userid));
tail->uid = uid;
tail->next = user_alist;
***************
*** 1839,1844 ****
--- 1963,1970 ----
/* Low level subroutines of general use,
not specifically related to the task of listing a directory. */
+ #ifndef MSDOS
+
char *
xrealloc (obj, size)
char *obj;
***************
*** 1864,1869 ****
--- 1990,1997 ----
return val;
}
+ #endif /* MSDOS */
+
/* Return a newly allocated copy of `string'. */
char *
***************
*** 1904,1913 ****
--- 2032,2050 ----
[+numeric-uid-gid] [+hide-control-chars] [+reverse] [+size]\n\
[+width cols] [+tabsize cols] [+almost-all] [+ignore-backups]\n",
program_name);
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ [+classify] [+file-type] [+ignore pattern] [+dereference] [+literal]\n\
+ [+quote-name] [+recursive] [+sort {none,time,size,extension}]\n\
+ [+format {long,verbose,commas,across,vertical,single-column}]\n\
+ [+time {atime,access,use,ctime,status}] [+copying] [+version]\n\
+ [path...]\n");
+ #else /* not MSDOS */
fprintf (stderr, "\
[+classify] [+file-type] [+ignore pattern] [+dereference] [+literal]\n\
[+quote-name] [+recursive] [+sort {none,time,size,extension}]\n\
[+format {long,verbose,commas,across,vertical,single-column}]\n\
[+time {atime,access,use,ctime,status}] [path...]\n");
+ #endif /* not MSDOS */
exit (1);
}
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:28 1990
--- mkdir.c Wed Sep 19 12:45:00 1990
***************
*** 14,20 ****
--- 14,44 ----
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/mkdir.c 1.4.0.2 90/09/19 12:10:16 tho Exp $";
+
+ static char Program_Id[] = "mkdir";
+ static char RCS_Revision[] = "$Revision: 1.4.0.2 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
/* Usage: mkdir [-p] [-m mode] [+path] [+mode mode] dir...
Options:
***************
*** 42,52 ****
--- 66,94 ----
extern int errno;
#endif
+ #ifdef MSDOS
+
+ #include <direct.h>
+ #include <io.h>
+ #include <gnulib.h>
+
+ extern void main (int argc, char **argv);
+ static int make_path (char *path, unsigned short mode,\
+ unsigned short parent_mode);
+ static void strip_trailing_slashes (char *path);
+ static void usage (void);
+
+ #define mkdir(path, mode) mkdir (path)
+
+ #else /* not MSDOS */
+
int make_path ();
void error ();
void strip_trailing_slashes ();
void usage ();
+ #endif /* not MSDOS */
+
/* If nonzero, ensure that a path exists. */
int path_mode;
***************
*** 55,60 ****
--- 97,106 ----
struct option longopts[] =
{
+ #ifdef MSDOS
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"mode", 1, NULL, 'm'},
{"path", 0, &path_mode, 1},
{NULL, 0, NULL, 0}
***************
*** 89,94 ****
--- 135,150 ----
case 'm':
symbolic_mode = optarg;
break;
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
default:
usage ();
}
***************
*** 198,206 ****
void
usage ()
{
fprintf (stderr, "\
Usage: %s [-p] [-m mode] [+path] [+mode mode] dir...\n",
program_name);
exit (1);
}
-
--- 254,267 ----
void
usage ()
{
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-p] [-m mode] [+path] [+mode mode] [+copying] \n\
+ [+version] dir...\n", program_name);
+ #else
fprintf (stderr, "\
Usage: %s [-p] [-m mode] [+path] [+mode mode] dir...\n",
program_name);
+ #endif
exit (1);
}
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:30 1990
--- modechan.c Wed Sep 19 12:33:30 1990
***************
*** 15,20 ****
--- 15,32 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fileutil/RCS/modechan.c 1.4.0.1 90/09/17 09:27:41 tho Exp $
+ */
+
/* Written by David MacKenzie <djm@ai.mit.edu> */
/* The ASCII mode string is compiled into a linked list of `struct
***************
*** 27,32 ****
--- 39,50 ----
#include <sys/types.h>
#include <sys/stat.h>
#include "modechange.h"
+
+ #ifdef MSDOS
+ #include <stdio.h>
+ #include <io.h>
+ static int oatoi (char *s);
+ #endif
#ifdef STDC_HEADERS
#include <stdlib.h>
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:40 1990
--- mv.c Wed Sep 19 12:45:40 1990
***************
*** 14,20 ****
--- 14,44 ----
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/mv.c 1.4.0.2 90/09/19 12:11:15 tho Exp $";
+
+ static char Program_Id[] = "mv";
+ static char RCS_Revision[] = "$Revision: 1.4.0.2 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
/* Options:
-f, +force Assume a 'y' answer to all questions it would
normally ask, and not ask the questions.
***************
*** 52,57 ****
--- 76,105 ----
extern int errno;
#endif
+ #ifdef MSDOS
+
+ #include <io.h>
+ #include <gnulib.h>
+
+ extern void main (int argc, char **argv);
+ extern void error (int status, int errnum, char *message, ...);
+ extern int eaccess_stat (struct stat *statp, int mode);
+ extern enum backup_type get_version (char *version);
+ static int isdir (char *fn);
+ static int movefile (char *from, char *to);
+ static int do_move (char *from, char *to);
+ static int copy (char *from, char *to);
+ static int yesno (void );
+ static void strip_trailing_slashes (char **path);
+ static int force_unlink (char *filename);
+ static void usage (void );
+
+ #define unlink(name) force_unlink (name)
+ #define rename(from, to) (unlink (to) || rename (from, to))
+ #define strip_trailing_slashes(path) strip_trailing_slashes (&path)
+
+ #else /* not MSDOS */
+
enum backup_type get_version ();
int copy ();
int do_move ();
***************
*** 62,67 ****
--- 110,117 ----
void strip_trailing_slashes ();
void usage ();
+ #endif /* not MSDOS */
+
/* The name this program was run with. */
char *program_name;
***************
*** 77,82 ****
--- 127,136 ----
struct option long_options[] =
{
+ #ifdef MSDOS
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"backup", 0, NULL, 'b'},
{"force", 0, NULL, 'f'},
{"interactive", 0, NULL, 'i'},
***************
*** 134,139 ****
--- 188,203 ----
case 'V':
version = optarg;
break;
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
default:
usage ();
}
***************
*** 178,183 ****
--- 242,254 ----
cp = from;
newto = (char *) alloca (strlen (to) + 1 + strlen (cp) + 1);
+ #ifdef MSDOS
+ /* Here a trailing slash might still be present (needed for
+ stat()'ing root directories), take care of that. */
+ if (to[strlen(to) - 1] == '/')
+ sprintf (newto, "%s%s", to, cp);
+ else
+ #endif /* MSDOS */
sprintf (newto, "%s/%s", to, cp);
return do_move (from, newto);
}
***************
*** 206,211 ****
--- 277,289 ----
if (lstat (to, &to_stats) == 0)
{
+ #ifdef MSDOS
+ if (strcmp (to, from) == 0)
+ {
+ error (0, 0, "`%s': can't move file to itself", from);
+ return 1;
+ }
+ #else /* not MSDOS */
if (from_stats.st_dev == to_stats.st_dev
&& from_stats.st_ino == to_stats.st_ino)
{
***************
*** 212,217 ****
--- 290,296 ----
error (0, 0, "`%s' and `%s' are the same file", from, to);
return 1;
}
+ #endif /* not MSDOS */
if ((to_stats.st_mode & S_IFMT) == S_IFDIR)
{
***************
*** 324,336 ****
--- 403,424 ----
return 1;
}
+ #ifdef MSDOS
+ ifd = open (from, O_RDONLY | O_BINARY, 0);
+ #else /* not MSDOS */
ifd = open (from, O_RDONLY, 0);
+ #endif /* not MSDOS */
if (ifd < 0)
{
error (0, errno, "%s", from);
return 1;
}
+
+ #ifdef MSDOS
+ ofd = open (to, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0777);
+ #else /* not MSDOS */
ofd = open (to, O_WRONLY | O_CREAT | O_TRUNC, 0777);
+ #endif /* not MSDOS */
if (ofd < 0)
{
error (0, errno, "%s", to);
***************
*** 431,436 ****
--- 519,538 ----
/* Remove trailing slashes from PATH. */
+
+ #ifdef MSDOS
+ #undef strip_trailing_slashes
+
+ void
+ strip_trailing_slashes (char **path)
+ {
+ char *new_path = _fullpath (NULL, *path, 0);
+ free (*path);
+ *path = msdos_format_filename (new_path);
+ }
+
+ #else /* not MSDOS */
+
void
strip_trailing_slashes (path)
char *path;
***************
*** 442,450 ****
--- 544,567 ----
path[last--] = '\0';
}
+ #endif /* not MSDOS */
+
void
usage ()
{
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-bfiuv] [-S backup-suffix] [-V {numbered,existing,simple}]\n\
+ [+backup] [+force] [+interactive] [+update] [+verbose]\n\
+ [+suffix backup-suffix] [+version-control {numbered,existing,simple}]\n\
+ [+copying] [+version] source dest\n\
+ \n\
+ %s [-bfiuv] [-S backup-suffix] [-V {numbered,existing,simple}]\n\
+ [+backup] [+force] [+interactive] [+update] [+verbose]\n\
+ [+suffix backup-suffix] [+version-control {numbered,existing,simple}]\n\
+ [+copying] [+version] source... directory\n",
+ program_name, program_name);
+ #else /* not MSDOS */
fprintf (stderr, "\
Usage: %s [-bfiuv] [-S backup-suffix] [-V {numbered,existing,simple}]\n\
[+backup] [+force] [+interactive] [+update] [+verbose]\n\
***************
*** 456,460 ****
--- 573,600 ----
[+suffix backup-suffix] [+version-control {numbered,existing,simple}]\n\
source... directory\n",
program_name, program_name);
+ #endif /* not MSDOS */
exit (1);
}
+
+ #ifdef MSDOS
+ #undef unlink /* nasty tricks ... */
+
+ int
+ force_unlink (char *filename)
+ {
+ if (access (filename, 0)) /* file doesn't exist, pretend success */
+ return 0;
+ else
+ {
+ if (access (filename, 2) /* no write permission */
+ && chmod (filename, S_IREAD|S_IWRITE)) /* can't force it ... */
+ {
+ error (0, errno, "can't force write permission for %s", filename);
+ return -1;
+ }
+ else
+ return unlink (filename);
+ }
+ }
+ #endif /* MSDOS */
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:42 1990
--- paste.c Wed Sep 19 12:46:38 1990
***************
*** 40,46 ****
--- 40,70 ----
start again at its beginning.
A FILE of `-' means standard input.
If no FILEs are given, standard input is used. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/paste.c 1.4.0.3 90/09/19 12:11:19 tho Exp $";
+
+ static char Program_Id[] = "paste";
+ static char RCS_Revision[] = "$Revision: 1.4.0.3 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
***************
*** 57,62 ****
--- 81,98 ----
extern int errno;
#endif
+ #ifdef MSDOS
+
+ #include <gnulib.h>
+
+ void main (int argc, char **argv);
+ char *collapse_escapes (char *strptr);
+ int paste_parallel (int nfiles, char **fnamptr);
+ int paste_serial (int nfiles, char **fnamptr);
+ void usage (void);
+
+ #else /* not MSDOS */
+
char *collapse_escapes ();
char *xmalloc ();
char *xrealloc ();
***************
*** 65,70 ****
--- 101,109 ----
void error ();
void usage ();
+ #endif /* not MSDOS */
+
+
/* Indicates that no delimiter should be added in the current position. */
#define EMPTY_DELIM '\0'
***************
*** 89,94 ****
--- 128,137 ----
struct option longopts[] =
{
+ #ifdef MSDOS
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"serial", 0, 0, 's'},
{"delimiters", 1, 0, 'd'},
{0, 0, 0, 0}
***************
*** 124,129 ****
--- 167,184 ----
serial_merge++;
break;
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
+
default:
usage ();
}
***************
*** 438,443 ****
--- 493,500 ----
return errors;
}
+ #ifndef MSDOS /* We have it in gnulib */
+
/* Allocate N bytes of memory dynamically, with error checking. */
char *
***************
*** 463,474 ****
--- 520,540 ----
return p;
}
+ #endif /* not MSDOS */
+
void
usage ()
{
+
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-s] [-d delim-list] [+serial] [+delimiters delim-list]\n\
+ [+copying] [+version] [file...]\n",
+ #else /* not MSDOS */
fprintf (stderr, "\
Usage: %s [-s] [-d delim-list] [+serial] [+delimiters delim-list]\n\
[file...]\n",
+ #endif /* not MSDOS */
program_name);
exit (1);
}
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:44 1990
--- posixtim.y Wed Sep 19 12:54:42 1990
***************
*** 17,25 ****
--- 17,39 ----
/* Written by Jim Kingdon and David MacKenzie. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
%token digit
%{
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/posixtim.y 1.4.0.2 90/09/19 12:54:32 tho Exp $";
+ #endif /* MSDOS */
+
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
***************
*** 41,49 ****
time_t mktime ();
static int yylex ();
- #define yyparse posixtime_yyparse
static int yyerror ();
%}
%%
--- 55,70 ----
time_t mktime ();
+ #ifdef MSDOS
+ #include <malloc.h>
+ static int yyerror (void);
+ static int yylex (void);
+ #else /* not MSDOS */
static int yylex ();
static int yyerror ();
+ #endif /* not MSDOS */
+
+ #define yyparse posixtime_yyparse
%}
%%
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:46 1990
--- rm.c Wed Sep 19 12:47:36 1990
***************
*** 17,22 ****
--- 17,47 ----
/* Written by Paul Rubin, David MacKenzie, and Richard Stallman. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/rm.c 1.4.0.3 90/09/20 08:46:14 tho Exp $";
+
+ static char Program_Id[] = "rm";
+ static char RCS_Revision[] = "$Revision: 1.4.0.3 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
***************
*** 32,37 ****
--- 57,91 ----
extern int errno;
#endif
+ #ifdef MSDOS
+ #include <string.h>
+ #include <malloc.h>
+ #include <io.h>
+ #include <direct.h>
+
+ #include <gnulib.h>
+
+ extern void main (int argc, char **argv);
+ static int rm (void);
+ static int remove_file (struct stat *statp);
+ static int remove_dir (struct stat *statp);
+ static int clear_directory (struct stat *statp);
+ static int yesno (void);
+ static char *basename (char *name);
+ static char *stpcpy (char *dest, char *source);
+ static void usage (void);
+
+ extern int eaccess (char *path, int mode);
+ extern int eaccess_stat (struct stat *statp, int mode);
+
+ static void strip_trailing_slashes (char **path);
+ #define strip_trailing_slashes(path) strip_trailing_slashes (&path)
+ #define check_stack(stck, ino) 0
+ #define unlink(name) force_unlink (name)
+ static int force_unlink (char *filename);
+
+ #else /* not MSDOS */
+
char *basename ();
char *stpcpy ();
char *xmalloc ();
***************
*** 47,52 ****
--- 101,109 ----
void strip_trailing_slashes ();
void usage ();
+ #endif /* not MSDOS */
+
+
/* Path of file now being processed; extended as necessary. */
char *pathname;
***************
*** 80,85 ****
--- 137,146 ----
struct option long_opts[] =
{
+ #ifdef MSDOS
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"directory", 0, &unlink_dirs, 1},
{"force", 0, NULL, 'f'},
{"interactive", 0, NULL, 'i'},
***************
*** 101,108 ****
verbose = ignore_missing_files = recursive = interactive
= unlink_dirs = 0;
pnsize = 256;
- pathname = xmalloc (pnsize);
program_name = argv[0];
while ((c = getopt_long (argc, argv, "dfirvR", long_opts, &ind)) != EOF)
{
--- 162,169 ----
verbose = ignore_missing_files = recursive = interactive
= unlink_dirs = 0;
pnsize = 256;
program_name = argv[0];
+ pathname = xmalloc (pnsize);
while ((c = getopt_long (argc, argv, "dfirvR", long_opts, &ind)) != EOF)
{
***************
*** 128,133 ****
--- 189,204 ----
case 'v':
verbose = 1;
break;
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
default:
usage ();
}
***************
*** 136,141 ****
--- 207,213 ----
if (optind == argc)
usage ();
+ #ifndef MSDOS /* this fails at the root ... */
if (lstat (".", &stats))
error (1, errno, ".");
dot_dev = stats.st_dev;
***************
*** 144,149 ****
--- 216,222 ----
error (1, errno, "..");
dotdot_dev = stats.st_dev;
dotdot_ino = stats.st_ino;
+ #endif /* not MSDOS */
for (; optind < argc; optind++)
{
***************
*** 180,185 ****
--- 253,259 ----
return 1;
}
+ #ifndef MSDOS
if ((path_stats.st_dev == dot_dev && path_stats.st_ino == dot_ino)
|| (path_stats.st_dev == dotdot_dev && path_stats.st_ino == dotdot_ino))
{
***************
*** 186,191 ****
--- 260,266 ----
error (0, 0, "%s: cannot remove current directory or parent", pathname);
return 1;
}
+ #endif /* not MSDOS */
if ((path_stats.st_mode & S_IFMT) == S_IFDIR && !unlink_dirs)
return remove_dir (&path_stats);
***************
*** 329,341 ****
--- 404,425 ----
return 1;
}
+ #ifdef MSDOS /* stat () it ourselves ... */
+ statp->st_size = 0L;
+ for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp))
+ statp->st_size += strlen(dp->d_name) + 1;
+ seekdir(dirp, 0L);
+ #endif /* MSDOS */
+
name_size = statp->st_size;
name_space = (char *) xmalloc (name_size);
namep = name_space;
+ #ifndef MSDOS
inode_size = statp->st_size;
inode_space = (ino_t *) xmalloc (inode_size);
inodep = inode_space;
+ #endif /* not MSDOS */
while ((dp = readdir (dirp)) != NULL)
{
***************
*** 359,364 ****
--- 443,449 ----
}
namep = stpcpy (namep, dp->d_name) + 1;
+ #ifndef MSDOS
if (inodep == inode_space + inode_size)
{
ino_t *new_inode_space;
***************
*** 369,374 ****
--- 454,460 ----
inode_space = new_inode_space;
}
*inodep++ = dp->d_ino;
+ #endif /* not MSDOS */
}
}
*namep = '\0';
***************
*** 415,424 ****
--- 501,513 ----
pathstack = pathstack->next; /* Pop the stack. */
}
free (name_space);
+ #ifndef MSDOS
free (inode_space);
+ #endif /* not MSDOS */
return err;
}
+ #ifndef MSDOS
/* If STACK does not already have an entry with the same i-number as INUM,
return 0. Otherwise, ask the user whether to continue;
if yes, return 1, and if no, exit.
***************
*** 455,460 ****
--- 544,550 ----
}
return 0;
}
+ #endif /* !MSDOS */
/* Query the user for a line from the keyboard;
return 1 if yes, 0 otherwise. */
***************
*** 476,482 ****
--- 566,585 ----
/* Remove trailing slashes from PATH; they cause some system calls to fail. */
+ #ifdef MSDOS
+ #undef strip_trailing_slashes
+
void
+ strip_trailing_slashes (char **path)
+ {
+ char *new_path = _fullpath (NULL, *path, 0);
+ free (*path);
+ *path = msdos_format_filename (new_path);
+ }
+
+ #else /* not MSDOS */
+
+ void
strip_trailing_slashes (path)
char *path;
{
***************
*** 510,515 ****
--- 613,620 ----
return p;
}
+ #endif /* not MSDOS */
+
/* Return NAME with any leading path stripped off. */
char *
***************
*** 539,547 ****
--- 644,671 ----
void
usage ()
{
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-dfirvR] [+directory] [+force] [+interactive] [+recursive]\n\
+ [+verbose] [+copying] [+version] path...\n",
+ #else /* not MSDOS */
fprintf (stderr, "\
Usage: %s [-dfirvR] [+directory] [+force] [+interactive] [+recursive]\n\
[+verbose] path...\n",
+ #endif /* not MSDOS */
program_name);
exit (1);
}
+
+ #ifdef MSDOS
+ int
+ force_unlink(char *filename)
+ {
+ if (access( filename, 2)) /* read only */
+ if (chmod( filename, S_IREAD|S_IWRITE))
+ error (0, errno, "can't force write permission for %s", filename);
+
+ #undef unlink /* nasty tricks ... */
+ return unlink (filename);
+ }
+ #endif /* MSDOS */
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:50 1990
--- rmdir.c Wed Sep 19 12:48:32 1990
***************
*** 15,20 ****
--- 15,45 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/rmdir.c 1.4.0.2 90/09/19 12:09:14 tho Exp $";
+
+ static char Program_Id[] = "rmdir";
+ static char RCS_Revision[] = "$Revision: 1.4.0.2 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
/* Usage: rmdir [-p] [+path] dir...
Options:
***************
*** 36,46 ****
--- 61,85 ----
extern int errno;
#endif
+ #ifdef MSDOS
+
+ #include <direct.h>
+ #include <gnulib.h>
+
+ extern void main (int argc, char * *argv);
+ static void remove_parents (char *path);
+ static void strip_trailing_slashes (char *path);
+ static void usage (void);
+
+ #else /* not MSDOS */
+
void remove_parents ();
void error ();
void strip_trailing_slashes ();
void usage ();
+ #endif /* not MSDOS */
+
/* If nonzero, remove empty parent directories. */
int empty_paths;
***************
*** 49,54 ****
--- 88,97 ----
struct option longopts[] =
{
+ #ifdef MSDOS
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"path", 0, &empty_paths, 1},
{NULL, 0, NULL, 0}
};
***************
*** 74,79 ****
--- 117,132 ----
case 'p':
empty_paths = 1;
break;
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
default:
usage ();
}
***************
*** 136,142 ****
--- 189,199 ----
void
usage ()
{
+ #ifdef MSDOS
+ fprintf (stderr, "Usage: %s [-p] [+path] [+copying] [+version] dir...\n",
+ #else /* not MSDOS */
fprintf (stderr, "Usage: %s [-p] [+path] dir...\n",
+ #endif /* not MSDOS */
program_name);
exit (1);
}
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:50 1990
--- savedir.c Wed Sep 19 12:33:58 1990
***************
*** 17,23 ****
--- 17,36 ----
/* Written by David MacKenzie <djm@ai.mit.edu>. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fileutil/RCS/savedir.c 1.4.0.2 90/09/17 09:28:48 tho Exp $
+ */
+
#include <sys/types.h>
+
#ifdef DIRENT
#include <dirent.h>
#ifdef direct
***************
*** 50,55 ****
--- 63,74 ----
#endif
#endif
+ #ifdef MSDOS
+ #include <stdio.h>
+ extern char *savedir (char *dir, unsigned name_size);
+ static char *stpcpy (char *dest, char *source);
+ #endif /* MSDOS */
+
static char *stpcpy ();
/* Return a freshly allocated string containing the filenames
***************
*** 72,77 ****
--- 91,103 ----
dirp = opendir (dir);
if (dirp == NULL)
return NULL;
+
+ #ifdef MSDOS /* stat () it ourselves ... */
+ name_size = 0;
+ for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp))
+ name_size += strlen(dp->d_name) + 1;
+ seekdir(dirp, 0L);
+ #endif /* MSDOS */
name_space = (char *) malloc (name_size);
if (name_space == NULL)
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:52 1990
--- system.h Wed Sep 19 12:31:38 1990
***************
*** 17,22 ****
--- 17,34 ----
/* Include sys/types.h before this file. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/fileutil/RCS/system.h 1.4.0.2 90/09/19 12:27:45 tho Exp $
+ */
+
#include <sys/stat.h>
#ifdef _POSIX_SOURCE
***************
*** 25,36 ****
--- 37,54 ----
#else
#ifdef USG
+ #ifdef MSDOS
+ #include <time.h>
+ #else /* not MSDOS */
#include <sys/times.h>
+ #endif /* not MSDOS */
#else
#include <sys/time.h>
#endif
+ #ifndef MSDOS
#include <sys/param.h>
+ #endif /* not MSDOS */
#define _POSIX_PATH_MAX 255
#define _POSIX_NAME_MAX 14
***************
*** 67,73 ****
--- 85,96 ----
#define makedev(maj, min) (((maj) << 8) | (min))
#else
#ifdef USG
+ #ifdef MSDOS
+ #define major(dev) (((dev) >> 8) & 0xff)
+ #define minor(dev) ((dev) & 0xff)
+ #else /* not MSDOS */
#include <sys/sysmacros.h>
+ #endif /* not MSDOS */
#endif
#endif
***************
*** 79,84 ****
--- 102,110 ----
long actime;
long modtime;
};
+ #ifdef MSDOS
+ int utime(char *, struct utimbuf *);
+ #endif /* MSDOS */
#endif
#if defined(USG) || defined(STDC_HEADERS)
***************
*** 134,139 ****
--- 160,173 ----
#endif
#endif
+
+ #ifdef MSDOS
+
+ #define ST_BLKSIZE(statbuf) BLKSIZE
+ #define ST_NBLOCKS(statbuf) (((statbuf).st_size + DEV_BSIZE - 1) / DEV_BSIZE)
+
+ #else /* not MSDOS */
+
/* Extract data from a `struct stat'.
ST_BLKSIZE: Optimal I/O blocksize for the file.
ST_NBLOCKS: Number of blocks in the file (including indirect blocks). */
***************
*** 152,157 ****
--- 186,193 ----
#endif
#endif
+ #endif /* not MSDOS */
+
/* Convert B blocks of DEV_BSIZE bytes
to kilobytes if K is nonzero, otherwise to blocks of 512 bytes. */
***************
*** 181,186 ****
--- 217,226 ----
#ifdef sparc
#include <alloca.h>
#else
+ #ifdef MSDOS
+ #include <malloc.h>
+ #else
char *alloca ();
+ #endif
#endif
#endif
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:54 1990
--- tac.c Wed Sep 19 12:49:08 1990
***************
*** 18,23 ****
--- 18,48 ----
/* Written by Jay Lepreau (lepreau@cs.utah.edu).
GNU enhancements by David MacKenzie (djm@ai.mit.edu). */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/tac.c 1.4.0.3 90/09/19 12:09:16 tho Exp $";
+
+ static char Program_Id[] = "tac";
+ static char RCS_Revision[] = "$Revision: 1.4.0.3 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
/* Usage: tac [-br] [-s separator] [+before] [+regex] [+separator separator]
[file...]
***************
*** 67,72 ****
--- 92,121 ----
off_t lseek ();
#endif
+ #ifdef MSDOS
+
+ #include <gnulib.h>
+ #include <io.h>
+
+ /* We need a static malloc (with cleanup) here, so mask off
+ the one from gnulib */
+ #define xmalloc _xmalloc
+ #define xrealloc _xrealloc
+
+ static char *_xmalloc (unsigned int n);
+ static char *_xrealloc (char *p, unsigned int n);
+
+ extern void main (int argc, char **argv);
+ static int tac (int fd, char *file);
+ static int tac_file (char *file);
+ static int tac_stdin (void );
+ static void output (char *start, char *past_end);
+ static void save_stdin (void );
+ static void xwrite (int desc, char *buffer, int size);
+ static SIGTYPE cleanup (void );
+
+ #else /* not MSDOS */
+
SIGTYPE cleanup ();
int tac ();
int tac_file ();
***************
*** 77,82 ****
--- 126,132 ----
void error ();
void save_stdin ();
void xwrite ();
+ #endif /* not MSDOS */
/* The name this program was run with. */
char *program_name;
***************
*** 114,119 ****
--- 164,173 ----
struct option longopts[] =
{
+ #ifdef MSDOS
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"before", 0, &separator_ends_record, 0},
{"regex", 0, &sentinel_length, 0},
{"separator", 1, NULL, 's'},
***************
*** 120,126 ****
{NULL, 0, NULL, 0}
};
! int
main (argc, argv)
int argc;
char **argv;
--- 174,180 ----
{NULL, 0, NULL, 0}
};
! void
main (argc, argv)
int argc;
char **argv;
***************
*** 129,134 ****
--- 183,193 ----
int optc, longind, errors;
program_name = argv[0];
+ #ifdef MSDOS
+ setmode (0, O_BINARY);
+ setmode (1, O_BINARY);
+ #endif /* MSDOS */
+
errors = 0;
separator = "\n";
sentinel_length = 1;
***************
*** 152,161 ****
--- 211,236 ----
if (*separator == 0)
error (1, 0, "separator cannot be empty");
break;
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
default:
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-br] [-s separator] [+before] [+regex] [+separator separator]\n\
+ [+copying] [+version] [file...]\n",
+ #else /* not MSDOS */
fprintf (stderr, "\
Usage: %s [-br] [-s separator] [+before] [+regex] [+separator separator]\n\
[file...]\n",
+ #endif /* not MSDOS */
program_name);
exit (1);
}
***************
*** 164,170 ****
--- 239,250 ----
if (sentinel_length == 0)
{
compiled_separator.allocated = 100;
+ #ifdef MSDOS
+ compiled_separator.buffer
+ = xmalloc ((size_t) compiled_separator.allocated);
+ #else /* not MSDOS */
compiled_separator.buffer = xmalloc (compiled_separator.allocated);
+ #endif /* not MSDOS */
compiled_separator.fastmap = xmalloc (256);
compiled_separator.translate = 0;
error_message = re_compile_pattern (separator, strlen (separator),
***************
*** 235,243 ****
--- 315,325 ----
sigint = signal (SIGINT, SIG_IGN);
if (sigint != SIG_IGN)
signal (SIGINT, cleanup);
+ #ifdef SIGHUP
sighup = signal (SIGHUP, SIG_IGN);
if (sighup != SIG_IGN)
signal (SIGHUP, cleanup);
+ #endif
sigterm = signal (SIGTERM, SIG_IGN);
if (sigterm != SIG_IGN)
signal (SIGTERM, cleanup);
***************
*** 247,259 ****
--- 329,348 ----
unlink (tempfile);
signal (SIGINT, sigint);
+ #ifdef SIGHUP
signal (SIGHUP, sighup);
+ #endif
signal (SIGTERM, sigterm);
return errors;
}
+ #ifdef MSDOS
+ char template[] = "/tacXXXXXX";
+ char *workplate;
+ #else /* not MSDOS */
char template[] = "/tmp/tacXXXXXX";
char workplate[sizeof template];
+ #endif /* not MSDOS */
/* Make a copy of the standard input in `tempfile'. */
***************
*** 263,276 ****
--- 352,391 ----
int fd;
int bytes_read;
+ #ifdef MSDOS
+ char *p;
+
+ if ((p = getenv ("TMP")) || (p = getenv ("TEMP")))
+ {
+ int len = strlen (p);
+ workplate = (char *) xmalloc (sizeof (template) + len + 1);
+ strcpy (workplate, p);
+ p = workplate + len - 1;
+ if (*p == '/' || *p == '\\') /* strip trailing slash */
+ *p = '\0';
+ }
+ else
+ {
+ workplate = (char *) xmalloc (sizeof (template) + 2);
+ strcpy (workplate, ".");
+ }
+ strcat (workplate, template);
+ #else /* not MSDOS */
strcpy (workplate, template);
+ #endif /* not MSDOS */
tempfile = mktemp (workplate);
+
+ #ifdef MSDOS
+ fd = open (tempfile, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, S_IWRITE|S_IREAD);
+ #else /* not MSDOS */
fd = creat (tempfile, 0600);
+ #endif /* not MSDOS */
if (fd == -1)
{
error (0, errno, "%s", tempfile);
cleanup ();
}
+
while ((bytes_read = read (0, buffer, read_size)) > 0)
if (write (fd, buffer, bytes_read) != bytes_read)
{
***************
*** 294,300 ****
--- 409,419 ----
{
int fd, errors;
+ #ifdef MSDOS
+ fd = open (file, O_RDONLY|O_BINARY);
+ #else /* not MSDOS */
fd = open (file, 0);
+ #endif /* not MSDOS */
if (fd == -1)
{
error (0, errno, "%s", file);
***************
*** 340,346 ****
--- 459,469 ----
not always hold during the program run, but since it usually will, leave
it here for i/o efficiency (page/sector boundaries and all that).
Note: the efficiency gain has not been verified. */
+ #ifdef MSDOS
+ saved_record_size = (unsigned int) (file_pos % read_size);
+ #else /* not MSDOS */
saved_record_size = file_pos % read_size;
+ #endif /* not MSDOS */
if (saved_record_size == 0)
saved_record_size = read_size;
file_pos -= saved_record_size;
***************
*** 354,359 ****
--- 477,498 ----
return 1;
}
+ #ifdef MSDOS
+ /* Some loosing editors add one or more ^Z to the end of a text file and
+ loosing MS-DOS devices interpret this as End Of File. We turn them
+ into spaces and print a warning message. */
+ {
+ char *ctrl_z = buffer + saved_record_size - 1;
+ if (*ctrl_z == '\032')
+ {
+ *ctrl_z = ' ';
+ error (0, 0, "%s: trailing ^Z translated to space.", file);
+ while (*--ctrl_z == '\032')
+ *ctrl_z = ' ';
+ }
+ }
+ #endif /* MSDOS */
+
match_start = past_end = buffer + saved_record_size;
/* For non-regexp search, move past impossible positions for a match. */
if (sentinel_length)
***************
*** 430,436 ****
file_pos -= read_size;
else
{
! read_size = file_pos;
file_pos = 0;
}
lseek (fd, file_pos, L_SET);
--- 569,575 ----
file_pos -= read_size;
else
{
! read_size = (unsigned) file_pos;
file_pos = 0;
}
lseek (fd, file_pos, L_SET);
***************
*** 528,533 ****
--- 667,673 ----
cleanup ();
}
}
+
/* Allocate N bytes of memory dynamically, with error checking. */
*** e:\tmp/RCSt1006574 Wed Sep 19 13:28:58 1990
--- tail.c Wed Sep 19 12:50:58 1990
***************
*** 15,20 ****
--- 15,45 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/tail.c 1.4.0.4 90/09/19 12:09:20 tho Exp $";
+
+ static char Program_Id[] = "tail";
+ static char RCS_Revision[] = "$Revision: 1.4.0.4 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
/* Can display any amount of data, unlike the Unix version, which uses
a fixed size buffer and therefore can only deliver a limited number
of lines.
***************
*** 86,91 ****
--- 111,119 ----
#define FOREVER 4 /* Read from end of file forever. */
#define START 8 /* Count from start of file instead of end. */
#define HEADERS 16 /* Print filename headers. */
+ #ifdef MSDOS
+ #define BINARY 32 /* Suppress crlf translation. */
+ #endif
/* When to print the filename banners. */
enum header_mode
***************
*** 93,98 ****
--- 121,152 ----
multiple_files, always, never
};
+ #ifdef MSDOS
+
+ #include <io.h>
+ #include <string.h>
+
+ extern void main (int, char **);
+ extern void write_header (char *);
+ extern int tail (char *, int, int, long);
+ extern int tail_file (char *, int, long);
+ extern int tail_bytes (char *, int, int, long);
+ extern int tail_lines (char *, int, int, long);
+ extern int file_lines (char *, int, long, long);
+ extern int pipe_lines (char *, int, long);
+ extern int pipe_bytes (char *, int, long);
+ extern int start_bytes (char *, int, long);
+ extern int start_lines (char *, int, long);
+ extern void dump_remainder (char *, int, int);
+ extern void xwrite (int, char *, int);
+ extern char *xmalloc (int);
+ extern long atou (char *);
+ extern char *basename (char *);
+ extern void error (int status, int errnum, char *message, ...);
+ extern void usage (void);
+
+ #else /* not MSDOS */
+
char *xmalloc ();
int file_lines ();
int pipe_bytes ();
***************
*** 110,116 ****
void write_header ();
void xwrite ();
! extern int errno;
/* The name this program was run with. */
char *program_name;
--- 164,170 ----
void write_header ();
void xwrite ();
! #endif /* not MSDOS */
/* The name this program was run with. */
char *program_name;
***************
*** 117,122 ****
--- 171,181 ----
struct option long_options[] =
{
+ #ifdef MSDOS
+ {"binary", 1, NULL, 'B'},
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"blocks", 1, NULL, 'b'},
{"bytes", 1, NULL, 'c'},
{"follow", 0, NULL, 'f'},
***************
*** 200,210 ****
--- 259,289 ----
argc--;
}
+ #ifdef MSDOS
+ while ((c = getopt_long (argc, argv, "b:c:n:fqvB", long_options, &longind))
+ #else
while ((c = getopt_long (argc, argv, "b:c:n:fqv", long_options, &longind))
+ #endif
!= EOF)
{
switch (c)
{
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+
+ case 'B':
+ mode |= BINARY;
+ break;
+ #endif
+
case 'b':
mode |= BLOCKS;
mode &= ~BYTES;
***************
*** 236,242 ****
break;
case 'f':
! mode |= FOREVER;
break;
case 'n':
--- 315,323 ----
break;
case 'f':
! #ifndef MSDOS
! mode |= FOREVER;
! #endif /* not MSDOS */
break;
case 'n':
***************
*** 365,374 ****
--- 446,478 ----
int mode;
long number;
{
+ #ifdef MSDOS
+ int errors;
+
+ if (mode & BINARY)
+ {
+ setmode (fileno (stdout), O_BINARY);
+ setmode (fd, O_BINARY);
+ }
+
+ if (mode & (BYTES | BLOCKS))
+ errors = tail_bytes (filename, fd, mode, number);
+ else
+ errors = tail_lines (filename, fd, mode, number);
+
+ if (mode & BINARY)
+ setmode (fileno (stdout), O_TEXT);
+
+ return errors;
+
+ #else /* not MSDOS */
+
if (mode & (BYTES | BLOCKS))
return tail_bytes (filename, fd, mode, number);
else
return tail_lines (filename, fd, mode, number);
+
+ #endif /* not MSDOS */
}
/* Display the last part of file `filename', open for reading in`fd',
***************
*** 485,491 ****
--- 589,599 ----
/* Set `bytes_read' to the size of the last, probably partial, buffer;
0 < `bytes_read' <= `BUFSIZE'. */
+ #ifdef MSDOS /* shut up the compiler */
+ bytes_read = (int) (pos % (long) BUFSIZE);
+ #else
bytes_read = pos % BUFSIZE;
+ #endif
if (bytes_read == 0)
bytes_read = BUFSIZE;
/* Make `pos' a multiple of `BUFSIZE' (0 if the file is short), so that all
***************
*** 557,563 ****
typedef struct linebuffer LBUFFER;
LBUFFER *first, *last, *tmp;
int i; /* Index into buffers. */
! int total_lines = 0; /* Total number of newlines in all buffers. */
int errors = 0;
first = last = (LBUFFER *) xmalloc (sizeof (LBUFFER));
--- 665,671 ----
typedef struct linebuffer LBUFFER;
LBUFFER *first, *last, *tmp;
int i; /* Index into buffers. */
! long total_lines = 0; /* Total number of newlines in all buffers. */
int errors = 0;
first = last = (LBUFFER *) xmalloc (sizeof (LBUFFER));
***************
*** 637,643 ****
--- 745,755 ----
/* Skip `total_lines' - `number' newlines. We made sure that
`total_lines' - `number' <= `tmp->nlines'. */
cp = tmp->buffer;
+ #ifdef MSDOS /* shut up the compiler */
+ for (i = (int) (total_lines - number); i; --i)
+ #else
for (i = total_lines - number; i; --i)
+ #endif
while (*cp++ != '\n')
/* Do nothing. */ ;
i = cp - tmp->buffer;
***************
*** 678,684 ****
--- 790,800 ----
typedef struct charbuffer CBUFFER;
CBUFFER *first, *last, *tmp;
int i; /* Index into buffers. */
+ #ifdef MSDOS
+ long total_bytes = 0; /* Total characters in all buffers. */
+ #else
int total_bytes = 0; /* Total characters in all buffers. */
+ #endif
int errors = 0;
first = last = (CBUFFER *) xmalloc (sizeof (CBUFFER));
***************
*** 737,743 ****
--- 853,863 ----
/* Find the correct beginning, then print the rest of the file.
We made sure that `total_bytes' - `number' <= `tmp->nbytes'. */
if (total_bytes > number)
+ #ifdef MSDOS /* shut up the compiler */
+ i = (int) (total_bytes - number);
+ #else
i = total_bytes - number;
+ #endif
else
i = 0;
xwrite (1, &tmp->buffer[i], tmp->nbytes - i);
***************
*** 776,782 ****
--- 896,906 ----
return 1;
}
else if (number < 0)
+ #ifdef MSDOS /* |number| < 64k ??? */
+ xwrite (1, &buffer[bytes_read + number], (unsigned int) (-number));
+ #else
xwrite (1, &buffer[bytes_read + number], -number);
+ #endif
return 0;
}
***************
*** 829,839 ****
--- 953,965 ----
xwrite (1, buffer, bytes_read);
if (bytes_read == -1)
error (1, errno, "%s", filename);
+ #ifndef MSDOS
if (mode & FOREVER)
{
sleep (1);
goto output;
}
+ #endif
}
/* Write plus error check. */
***************
*** 874,885 ****
for (value = 0; ISDIGIT (*str); ++str)
value = value * 10 + *str - '0';
! return *str ? -1 : value;
}
void
usage ()
{
fprintf (stderr, "\
Usage: %s [-b [+]#] [-c [+]#] [-n [+]#] [-fqv] [+blocks [+]#]\n\
[+bytes [+]#] [+lines [+]#] [+follow] [+quiet] [+silent]\n\
--- 1000,1020 ----
for (value = 0; ISDIGIT (*str); ++str)
value = value * 10 + *str - '0';
! return *str ? -1L : value;
}
void
usage ()
{
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-b [+]#] [-c [+]#] [-n [+]#] [-fqvB] [+blocks [+]#]\n\
+ [+bytes [+]#] [+lines [+]#] [+follow] [+quiet] [+silent]\n\
+ [+verbose] [+binary] [+copying] [+version] [file...]\n\
+ \n\
+ %s [+/-#bcflqv] [file...]\n", program_name, program_name);
+ exit (1);
+ #else
fprintf (stderr, "\
Usage: %s [-b [+]#] [-c [+]#] [-n [+]#] [-fqv] [+blocks [+]#]\n\
[+bytes [+]#] [+lines [+]#] [+follow] [+quiet] [+silent]\n\
***************
*** 887,890 ****
--- 1022,1026 ----
\n\
%s [+/-#bcflqv] [file...]\n", program_name, program_name);
exit (1);
+ #endif
}
*** e:\tmp/RCSt1006574 Wed Sep 19 13:29:02 1990
--- touch.c Wed Sep 19 12:51:54 1990
***************
*** 15,20 ****
--- 15,45 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release. */
+
+ #ifdef MSDOS
+ static char RCS_Id[] =
+ "$Header: e:/gnu/fileutil/RCS/touch.c 1.4.0.2 90/09/19 12:09:27 tho Exp $";
+
+ static char Program_Id[] = "touch";
+ static char RCS_Revision[] = "$Revision: 1.4.0.2 $";
+
+ #define VERSION \
+ "GNU %s, Version %.*s (compiled %s %s for MS-DOS)\n", Program_Id, \
+ (sizeof RCS_Revision - 14), (RCS_Revision + 11), __DATE__, __TIME__
+
+ #define COPYING \
+ "This is free software, distributed under the terms of the\n" \
+ "GNU General Public License. For details, see the file COPYING.\n"
+ #endif /* MSDOS */
+
/* Usage: touch [-acm] [-r reference-file] [-t MMDDhhmm[[CC]YY][.ss]]
[-d time] [+time {atime,access,use,mtime,modify}] [+date time]
[+file reference-file] [+no-create] file...
***************
*** 58,63 ****
--- 83,104 ----
long lseek ();
#endif
+
+ #ifdef MSDOS
+
+ #include <io.h>
+ #include <gnulib.h>
+
+ extern int argmatch (char *arg, char **optlist);
+ extern void invalid_arg (char *kind, char *value, int problem);
+ extern time_t posixtime (char *s);
+ extern time_t getdate (char *p, struct timeb *now);
+ void main (int argc, char **argv);
+ int touch (char *file);
+ void usage (void);
+
+ #else /* not MSDOS */
+
int argmatch ();
int touch ();
time_t getdate ();
***************
*** 66,71 ****
--- 107,114 ----
void invalid_arg ();
void usage ();
+ #endif /* not MSDOS */
+
/* Bitmasks for `change_times'. */
#define CH_ATIME 1
#define CH_MTIME 2
***************
*** 104,109 ****
--- 147,156 ----
struct option longopts[] =
{
+ #ifdef MSDOS
+ {"copying", 0, NULL, 30},
+ {"version", 0, NULL, 31},
+ #endif
{"time", 1, 0, 130},
{"no-create", 0, 0, 'c'},
{"date", 1, 0, 'd'},
***************
*** 185,190 ****
--- 232,249 ----
change_times |= time_masks[longind];
break;
+ #ifdef MSDOS
+ case 30:
+ fprintf (stderr, COPYING);
+ exit (0);
+ break;
+
+ case 31:
+ fprintf (stderr, VERSION);
+ exit (0);
+ break;
+ #endif
+
default:
usage ();
}
***************
*** 335,340 ****
--- 394,401 ----
return 0;
}
+ /* Use the one from gnulib */
+ #ifndef MSDOS
/* Like malloc but get error if no storage available. */
***************
*** 363,375 ****
--- 424,445 ----
return val;
}
+ #endif /* not MSDOS */
+
void
usage ()
{
+ #ifdef MSDOS
+ fprintf (stderr, "\
+ Usage: %s [-acm] [-r reference-file] [-t MMDDhhmm[[CC]YY][.ss]]\n\
+ [-d time] [+time {atime,access,use,mtime,modify}] [+date time]\n\
+ [+file reference-file] [+no-create] [+copying] [+version] file...\n",
+ #else /* not MSDOS */
fprintf (stderr, "\
Usage: %s [-acm] [-r reference-file] [-t MMDDhhmm[[CC]YY][.ss]]\n\
[-d time] [+time {atime,access,use,mtime,modify}] [+date time]\n\
[+file reference-file] [+no-create] file...\n",
+ #endif /* not MSDOS */
program_name);
exit (1);
}