* Re: configuration scripts
1997-09-10 1:50 configuration scripts Smith, Eric
@ 1997-09-15 18:42 ` Mikey
0 siblings, 0 replies; 3+ messages in thread
From: Mikey @ 1997-09-15 18:42 UTC (permalink / raw)
To: Smith, Eric, gnu-win32
[-- Attachment #1: Type: text/plain, Size: 2015 bytes --]
if you haven't done this yet stop,
remount all filesystems -b
and then reinstall from cdk.exe
and user.exe
the shell scripts/headers/sources would only have cr\lf
if you were mounted without -b to start with
or if you used winzip to install.
attached is a utility to convert all the files in a dir to \n from \r\n and vica/versa
after building put in path and do
ln -s dtou.exe utod
to convert \r\n to \n do
dtou * (under bash)
to convert \n to \r\n do
utod * (under bash)
no checking is done for utod so if you use it on the same file
multiple times you will get \r\r\r\r\r\n.
to recursively fix all files in a tree use dtoutree
WARNING
no check for binary files, this is meant for source trees
and include trees only
On Tue, 9 Sep 1997 12:21:47 -0400, you wrote:
>To all,
>
>Thank you for the responses.
>
>I have resigned myself to the long and arduous task of using Borland's
>FCONVERT.EXE to convert all of my configuration scripts from ANSI to OEM
>format (strip out <CR>). For the number of files I have, this appears
>to be a long task.
>
>This closes out one problem, but makes me wonder, why do the GNU scripts
>from the .tar.gz files at the main ftp site have <CR><LF> in them
>instead of just <LF>. They are identified as UNIX scripts, but appear
>to have a PC flavor to them. Since I haven't edited them ("cat
>{filename} | more" instead) I can't figure out where the <CR> came from
>unless it is there to start.
>
>Eric M. Smith
>telephone : (423) 229-2254
>profs/officevision : XGIB003
>internet -- business : erics@eastman.com
>internet -- personal : burnsun@tricon.net
>
>Do not meddle in the affairs of wizards, for they are quick to anger.
>Do not meddle in the affairs of dragons, for you are crunchy and taste
>good with ketchup.
>
>-
>For help on using this list (especially unsubscribing), send a message to
>"gnu-win32-request@cygnus.com" with one line of text: "help".
>
(jeffdbREMOVETHIS@netzone.com)
delete REMOVETHIS from the above to reply
Mikey
[-- Attachment #2: dtou.c --]
[-- Type: text/x-c, Size: 2815 bytes --]
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
/* modified for unixish paths, and direct conversion by
jeffdb@netzone.com Mikey */
#include <stdio.h>
#include <sys/types.h>
#include <utime.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#define BUFFSIZE 4096
#ifndef O_BINARY
# define O_BINARY 0
#endif
static int
cvt(char *fname, int is_dtou)
{
int sf, df, il, ol, end;
register char *iptr, *optr;
char ibuf[BUFFSIZE], obuf[BUFFSIZE * 2 + 1], ctrlz[1];
char tfname[FILENAME_MAX];
struct utimbuf ftime;
struct stat *mystat, oldstat;
mystat = &oldstat;
if (*fname == '-')
{
sf = 0;
df = 1;
}
else
{
sprintf(tfname, "cvt$$");
sf = open(fname, O_RDONLY|O_BINARY); /* O_TEXT dosen't work in cygwin32 b17.1 w/binary mounted filesystems so we have to do it all ourselves. */
if (sf < 1)
{
perror(fname);
return 1;
}
df = open(tfname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644);
if (df < 1)
{
perror(tfname);
close(sf);
return 1;
}
}
end = 0;
while (((il=read(sf, ibuf, BUFFSIZE)) > 0) && (!end))
{
iptr = &ibuf;
optr = &obuf;
/* if (is_dtou)
il++; */
ol = il;
if (is_dtou)
{
while(il > 0)
{
switch (*iptr)
{
case '\r':
*iptr++;
ol--;
il--;
break;
case '\032':
*optr++ = '\n';
ol -= il;
il = 0;
end++;
break;
default:
*optr++ = *iptr++;
il--;
break;
}
}
}
else
{
while(il > 0)
{
while ((*iptr != '\n') && (il > 0))
{
*optr++ = *iptr++;
il--;
}
if (il)
{
*optr++ = '\r';
*optr++ = *iptr++;
ol++;
il--;
}
}
}
write(df, obuf, ol);
}
if (*fname != '-')
{
fstat(sf, mystat);
ftime.actime = oldstat.st_atime;
ftime.modtime = oldstat.st_mtime;
utime(tfname, &ftime);
close(sf);
close(df);
remove(fname);
rename(tfname, fname);
}
return 0;
}
int
main(int argc, char **argv)
{
int i;
int is_dtou = 0;
int rv = 0;
char *temp, *progname;
progname = argv[0];
temp = strrchr(progname, '/');
if (temp == NULL)
{
temp = progname;
}
else
{
++temp;
}
if (strlen (temp) >= 4 && strcmp (temp + strlen (temp) - 4, ".exe") == 0)
*(temp + strlen (temp) - 4) = '\0'; /* dump .exe suffix if necessary */
if (strcmp (temp + strlen (temp) - 4, "dtou") == 0)
is_dtou = 1;
if (argc == 1)
{
rv += cvt((char *)"-\0", is_dtou);
return rv;
}
for (argc--, argv++; argc; argc--, argv++)
rv += cvt(*argv, is_dtou);
return rv;
}
[-- Attachment #3: dtoutree --]
[-- Type: text/x-shellscript, Size: 124 bytes --]
#!/bin/sh
for file in *;do
if [ -d $file ];then
pushd $file
dtoutree
popd
else
dtou $file;
fi;
done
^ permalink raw reply [flat|nested] 3+ messages in thread