Re: [Freedos-devel] troubles with redirection with singlestepping?

2006-08-23 Thread Markus Laire
On 8/23/06, Arkady V.Belousov [EMAIL PROTECTED] wrote:
 Hi!

 type test.bat
 echo echotest

 command /y /c test
 test [Yes=ENTER, No=ESC] ? y
 echo echotest
 echo echotest [Yes=ENTER, No=ESC] ? y

 type test
 echo

 All looks fine. How to reproduce bug in FreeCOM with redirection at
 singlestepping?

I'm able to reproduce this in qemu:

type test.bat
if not errorlevel 4 echo abc  temp

command /y /c test.bat
test.bat [Yes=ENTER, No=ESC] ?
if not errorlevel 4 echo abc  temp
if not errorlevel 4 echo abc  temp [Yes=ENTER, No=ESC] ?
# I need to press Enter twice at the line above

type temp
C:\echo abc  [Yes=ENTER, No=ESC] ?
abc

-- 
Markus Laire

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] troubles with redirection with singlestepping?

2006-08-23 Thread Arkady V.Belousov
Hi!

23-Авг-2006 10:16 [EMAIL PROTECTED] (Markus Laire) wrote to
freedos-devel@lists.sourceforge.net:

 All looks fine. How to reproduce bug in FreeCOM with redirection at
 singlestepping?
ML I'm able to reproduce this in qemu:
type test.bat
ML if not errorlevel 4 echo abc  temp
command /y /c test.bat
test.bat [Yes=ENTER, No=ESC] ?
if not errorlevel 4 echo abc  temp
if not errorlevel 4 echo abc  temp [Yes=ENTER, No=ESC] ?
ML # I need to press Enter twice at the line above

 This is right. I mean, MS-command.com also ask twice: one time for
complete command line, second time for echo. Bug in FreeCOM is that it not
shows prompt for second command, redirecting it to file.

 type temp
C:\echo abc  [Yes=ENTER, No=ESC] ?
ML abc

 Yes, now I see. But wait, MS-command.com also have similar trouble: if
you run this batch file under MS-command.com, then before abc you get line
with Y (answer from user - notwithstanding if pressed Enter or y)! :)

 Anyway, I just try to fix this (not need for FreeCOM be same unusable
as MS-command.com, or, worser, more buggy). :)

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] troubles with redirection with singlestepping?

2006-08-23 Thread Arkady V.Belousov
Hi!

23--2006 10:16 [EMAIL PROTECTED] (Markus Laire) wrote to
freedos-devel@lists.sourceforge.net:

 All looks fine. How to reproduce bug in FreeCOM with redirection at
 singlestepping?
ML I'm able to reproduce this in qemu:

 Fixed - see patch in attachment. Blair?
diff -rup -x config.mak OLD/# NEW/#
--- OLD/#   2006-08-23 00:55:36.0 +
+++ NEW/#   2006-08-23 17:50:04.0 +
@@ -158,3 +158,8 @@ Error exec.c 72: Unknown preprocessor di
 
 11. Fixed bug in LFNFUNCS.C library, which prevents redirection (because
 this bug prevents to create non-existed files).
+
+12. Fixed bug with redirection and single-stepping (option /Y) - with nested
+redirected commands (if errorlevel 1 echo donetempouttempin) FreeCOM
+was outputs its prompts (for all, except first command) to tempout and
+tries to read answers from tempin.
diff -rup -x config.mak OLD/shell/command.c NEW/shell/command.c
--- OLD/shell/command.c 2006-08-07 12:17:26.0 +
+++ NEW/shell/command.c 2006-08-23 17:44:42.0 +
@@ -382,13 +382,25 @@ void parsecommandline(char *s, int redir
   { /* Question after the variables expansion
and make sure _all_ executed commands will
honor the trace mode */
+/* Commands may be nested (if errorlevel 1 echo donetest). To
+   prevent redirecting FreeCOM prompts to user file, temporarily
+   revert redirection.
+*/
+int redir_fdin = -1, redir_fdout = -1, answer;
+if (oldinfd  != -1) { redir_fdin  = dup (0); dup2 (oldinfd,  0); }
+if (oldoutfd != -1) { redir_fdout = dup (1); dup2 (oldoutfd, 1); }
+
 printprompt();
 fputs(s, stdout);
 /* If the user hits ^Break, it has the same effect as
usually: If he is in a batch file, he is asked if
to abort all the batchfiles or just the current one */
-   if(userprompt(PROMPT_YES_NO) != 1)
-  /* Pressed either No or ^Break */
+answer = userprompt(PROMPT_YES_NO);
+
+if (redir_fdin  != -1) { dup2 (redir_fdin,  0); close (redir_fdin);  }
+if (redir_fdout != -1) { dup2 (redir_fdout, 1); close (redir_fdout); }
+
+if (answer != 1)   /* No or ^Break   */
   return;
   }
 
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] troubles with redirection with singlestepping?

2006-08-23 Thread Arkady V.Belousov
Hi!

ML I'm able to reproduce this in qemu:

 BTW, revised previous patch (for LFNFUNCS.C), because TC doesn't
support MS-like names for attributes.
diff -rup -x config.mak OLD/# NEW/#
--- OLD/#   2006-08-22 20:04:52.0 +
+++ NEW/#   2006-08-23 00:55:36.0 +
@@ -155,3 +155,6 @@ Error exec.c 72: Unknown preprocessor di
 - name with drive letter (d:) or absolute path (\cmd, \dir\cmd)
   now NOT searched through path; name with relative path (dir\cmd) DO
   searched through PATH.
+
+11. Fixed bug in LFNFUNCS.C library, which prevents redirection (because
+this bug prevents to create non-existed files).
diff -rup -x config.mak OLD/lib/lfnfuncs.c NEW/lib/lfnfuncs.c
--- OLD/lib/lfnfuncs.c  2006-08-07 12:04:22.0 +
+++ NEW/lib/lfnfuncs.c  2006-08-23 16:12:58.0 +
@@ -6,11 +6,13 @@
 
 #include dir.h   /* findfirst, findnext */
 #include fcntl.h /* O_WRONLY, O_CREAT */
+#include sys/stat.h  /* S_IWRITE */
 #include errno.h /* errno */
 #include string.h/* strchr, memcpy */
 #include stdarg.h
 #include io.h
 
+#include dfn.h   /* _A_NORMAL, _A_RDONLY */
 #include suppl.h
 #define __LFNFUNCS_C
 #include ../include/lfnfuncs.h
@@ -145,8 +147,9 @@ int lfnopen( const char *filename, int a
 
 if( access  O_CREAT ) {
 access = ~O_CREAT; /* Remove the O_CREAT bit */
-
-__creat_or_truncate( filename, va_arg( vargs, unsigned ) );
+__creat_or_truncate (filename,
+(va_arg (vargs, unsigned)  S_IWRITE)
+   ? _A_NORMAL : _A_RDONLY);
 }
 va_end( vargs );
 
diff -rup -x config.mak OLD/suppl/dfn.h NEW/suppl/dfn.h
--- OLD/suppl/dfn.h 2006-08-07 14:59:48.0 +
+++ NEW/suppl/dfn.h 2006-08-23 16:30:22.0 +
@@ -51,6 +51,20 @@
 #define dfnfullpath2 dfnufullpath2
 #endif
 
+#if defined __TURBOC__  !defined __BORLANDC__
+
+/* MSC names for file attributes */
+
+#define _A_NORMAL  0   /* Normal file, no attributes */
+#define _A_RDONLY  FA_RDONLY   /* Read only attribute */
+#define _A_HIDDEN  FA_HIDDEN   /* Hidden file */
+#define _A_SYSTEM  FA_SYSTEM   /* System file */
+#define _A_VOLID   FA_LABEL/* Volume label */
+#define _A_SUBDIR  FA_DIREC/* Directory */
+#define _A_ARCHFA_ARCH /* Archive */
+
+#endif
+
 #define DFN_FILE   0x4000
 #define DFN_LFN0x2000
 #define DFN_SHARABLE   0x0080
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] troubles with redirection with singlestepping?

2006-08-23 Thread Arkady V.Belousov
Hi!

23--2006 10:16 [EMAIL PROTECTED] (Markus Laire) wrote to
freedos-devel@lists.sourceforge.net:

 All looks fine. How to reproduce bug in FreeCOM with redirection at
 singlestepping?
ML I'm able to reproduce this in qemu:

 Oops, sorry. Before patch not accepted yet, let me replace it by
slightly more optimized one.
diff -rup -x config.mak OLD/# NEW/#
--- OLD/#   2006-08-23 00:55:36.0 +
+++ NEW/#   2006-08-23 17:50:04.0 +
@@ -158,3 +158,8 @@ Error exec.c 72: Unknown preprocessor di
 
 11. Fixed bug in LFNFUNCS.C library, which prevents redirection (because
 this bug prevents to create non-existed files).
+
+12. Fixed bug with redirection and single-stepping (option /Y) - with nested
+redirected commands (if errorlevel 1 echo donetempouttempin) FreeCOM
+was outputs its prompts (for all, except first command) to tempout and
+tries to read answers from tempin.
diff -rup -x config.mak OLD/shell/command.c NEW/shell/command.c
--- OLD/shell/command.c 2006-08-07 12:17:26.0 +
+++ NEW/shell/command.c 2006-08-23 18:11:00.0 +
@@ -382,13 +382,25 @@ void parsecommandline(char *s, int redir
   { /* Question after the variables expansion
and make sure _all_ executed commands will
honor the trace mode */
+/* Commands may be nested (if errorlevel 1 echo donetest). To
+   prevent redirecting FreeCOM prompts to user file, temporarily
+   revert redirection.
+*/
+int redir_fdin, redir_fdout, answer;
+if (oldinfd  != -1) { redir_fdin  = dup (0); dup2 (oldinfd,  0); }
+if (oldoutfd != -1) { redir_fdout = dup (1); dup2 (oldoutfd, 1); }
+
 printprompt();
 fputs(s, stdout);
 /* If the user hits ^Break, it has the same effect as
usually: If he is in a batch file, he is asked if
to abort all the batchfiles or just the current one */
-   if(userprompt(PROMPT_YES_NO) != 1)
-  /* Pressed either No or ^Break */
+answer = userprompt(PROMPT_YES_NO);
+
+if (oldinfd  != -1) { dup2 (redir_fdin,  0); close (redir_fdin);  }
+if (oldoutfd != -1) { dup2 (redir_fdout, 1); close (redir_fdout); }
+
+if (answer != 1)   /* No or ^Break   */
   return;
   }
 
-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel