Re: [AD] Patch for utod in .bat files

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Peter Wang wrote:
> Sven Sandberg <ssven.geo@xxxxxxxxxx> wrote:
> > fix*.bat. The problem was
> > that dos gets confused if a bat file is modified by utod while it is
> > running. 
> 
> Hmm, AFAICS, the same thing is happening even after applying your
> patches -- it just converts the batch files first, right?  

Dos' algorithm for running a bat file seems to be: Read a line from the
bat file; remember the offset in bytes to the end of that line; close
the bat file; run the command; reopen the file; seek to the position
that was remembered; continue over again. Therefore, it will work when
`utod *.bat' is on the first line, because then the offset which was
remembered will just point to the '\n' character of the first line,
which will be silently ignored. But if you do `utod *.bat' further down
in the bat file, then lots of '\r' characters will have been inserted
before that line so that the offset which dos stores points to some
random place in the file.

> Also, why hasn't anyone seen this before?

Probably because it would require someone to first convert the files to
unix format and then run fixdjgpp.bat. This is probably an unusual thing
to do, especially since none of fix*.* converts bat files to unix
format. Also, it doesn't really cause any problems: It just executes an
invalid command line which produces an error message and then continues
executing the bat file correctly. And if you try to reproduce it by
running fixdjgpp.bat again, it won't give an error because the file is
already in dos format at that time. So you may think that it was just a
temporary bug in dos or something :-)

Would it be a better idea to simply skip converting bat files? I
wouldn't be surprised if dos' behaviour was inconsistent across
different versions in some obscure way such that this patch doesn't
help. I guess it's not at all common to manually convert bat files to
unix format, and if someone does then maybe it doesn't matter all that
much if the script doesn't convert it back. Anyway, i attach a patch for
this as well (it's _not_ on top of the other patch) so you can choose.

Sven
diff -r -u diffs.original/fixdjgpp.bat diffs/fixdjgpp.bat
--- diffs.original/fixdjgpp.bat	Tue Dec 26 19:53:18 2000
+++ diffs/fixdjgpp.bat	Fri Dec 29 15:29:24 2000
@@ -10,7 +10,7 @@
 echo MAKEFILE_INC = makefile.dj >> makefile
 echo include makefile.all >> makefile
 
-utod *.bat .../*.c *.cfg .../*.h .../*.inc
+utod .../*.c *.cfg .../*.h .../*.inc
 utod .../*.s .../*.txt .../*._tx makefile.* readme.*
 
 echo Done!
diff -r -u diffs.original/fixmsvc.bat diffs/fixmsvc.bat
--- diffs.original/fixmsvc.bat	Tue Dec 26 19:53:18 2000
+++ diffs/fixmsvc.bat	Fri Dec 29 15:29:32 2000
@@ -10,7 +10,7 @@
 echo MAKEFILE_INC = makefile.vc >> makefile
 echo include makefile.all >> makefile
 
-utod *.bat .../*.c *.cfg .../*.h .../*.inc .../*.rc
+utod .../*.c *.cfg .../*.h .../*.inc .../*.rc
 utod .../*.s .../*.txt .../*._tx makefile.* readme.*
 
 echo Done!
diff -r -u diffs.original/fixwat.bat diffs/fixwat.bat
--- diffs.original/fixwat.bat	Tue Dec 26 19:53:18 2000
+++ diffs/fixwat.bat	Fri Dec 29 15:29:34 2000
@@ -10,7 +10,7 @@
 echo MAKEFILE_INC = makefile.wat >> makefile
 echo include makefile.all >> makefile
 
-utod *.bat .../*.c *.cfg .../*.h .../*.inc
+utod .../*.c *.cfg .../*.h .../*.inc
 utod .../*.s .../*.txt .../*._tx makefile.* readme.*
 
 echo Done!


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/