[comp.os.os2] extproc feature of cmd.exe

rommel@lan.informatik.tu-muenchen.dbp.de (Kai-Uwe Rommel) (03/12/90)

The GNU awk and GNU sed (stream editor) versions for OS/2 can support the
external batch processor feature of the OS/2 command interpreter CMD.EXE !

You can add a line containing "EXTPROC GAWK -f" or "EXTPROC SED -f" at the
top of your GAWK or SED scripts and rename them to have the .CMD extension.

If you rename TEST.AWK or TEST.SED to TEST.CMD and enter the command
"TEST FOO BAR", CMD.EXE automatically executes "GAWK -f TEST.CMD FOO BAR"
or "SED -f TEST.CMD FOO BAR", respectively.

Both GAWK and SED should then ignore the "EXTPROC ??? -f" line in the script.

This is the patch for GAWK 2.10beta to get it ignore the EXTPROC line.
Note that with this patch GAWK now ignores ANY line begining with "EXTPROC "
which is not exactly the desired effect. But I do not expect any AWK scripts
to exist which have lines beginning with "EXTPROC ". And this patch is VERY
simple:

*** awk_old.y	Tue Mar 06 22:25:08 1990
--- awk.y	Tue Mar 06 22:24:30 1990
***************
*** 1142,1147 ****
--- 1142,1153 ----
  		} else
  			lexptr = lexptr_begin = cbuf;

+         if ( strnicmp(lexptr, "extproc ", 8) == 0 ) {
+ 		while (*lexptr != '\n' && *lexptr != '\0')
+ 			lexptr++;
+ 		goto retry;
+         }
+
  	if (want_regexp) {
                want_regexp = 0;

If you do not have GNU bison to regenerate AWK_TAB.C you can apply this
patch also to AWK_TAB.C in the yylex() function.

This is the patch needed for GNU sed 1.06:

*** sed_old.c	Mon Jan 15 11:17:14 1990
--- sed.c	Wed Mar 07 17:42:04 1990
***************
*** 399,405 ****
  	if(str[0]=='-' && str[1]=='\0')
  		prog_file=stdin;
  	else
! 		prog_file=ck_fopen(str,"r");
  	ch=getc(prog_file);
  	if(ch=='#') {
  		ch=getc(prog_file);
--- 399,418 ----
  	if(str[0]=='-' && str[1]=='\0')
  		prog_file=stdin;
  	else
!                 prog_file=ck_fopen(str,"r");
!
! #ifdef OS2
!         if ( !isatty(fileno(prog_file)) )
!         {
!           char line[80];
!
!           fgets(line, sizeof(line), prog_file);
!
!           if ( strnicmp(line, "extproc ", 8) != 0 )
!             rewind(prog_file);
!         }
! #endif
!
  	ch=getc(prog_file);
  	if(ch=='#') {
  		ch=getc(prog_file);


Kai Uwe Rommel
Munich
rommel@lan.informatik.tu-muenchen.dbp.de