changeset 1329:76b1793dbd1c

Merge now supports -z
author boisy
date Sat, 06 Sep 2003 22:51:41 +0000
parents 4f37bc455854
children 4f42a5a604d3
files level1/ChangeLog level1/cmds/merge.asm level1/sys/merge.hp level2/cmds/makefile level2/coco3/ChangeLog level2/coco3_6309/ChangeLog
diffstat 6 files changed, 96 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/level1/ChangeLog	Fri Sep 05 17:45:35 2003 +0000
+++ b/level1/ChangeLog	Sat Sep 06 22:51:41 2003 +0000
@@ -1,4 +1,5 @@
 OS-9 Level One V03.01.05:
+- Merge now supports -z to get a list of files from standard input.
 - The serial printer driver and Speech-Sound Pak driver have been back-ported
   from OS-9 Level Two.
 - OS-9 Level One now has a REL module similar to OS-9 Level Two.
--- a/level1/cmds/merge.asm	Fri Sep 05 17:45:35 2003 +0000
+++ b/level1/cmds/merge.asm	Sat Sep 06 22:51:41 2003 +0000
@@ -8,6 +8,9 @@
 * ------------------------------------------------------------------
 *   4      ????/??/??
 * From Tandy OS-9 Level One VR 02.00.00.
+*
+*   5      2003/09/06
+* Added -z option to read files from stdin
 
          nam   Merge
          ttl   Merge files into one file
@@ -19,7 +22,7 @@
 tylg     set   Prgrm+Objct   
 atrv     set   ReEnt+rev
 rev      set   $00
-edition  set   4
+edition  set   5
 
          mod   eom,name,tylg,atrv,start,size
 
@@ -28,13 +31,17 @@
 param    rmb   2
 d.ptr    rmb   2
 d.size   rmb   2
+d.buff   rmb   128
 d.buffer rmb   2496       should reserve 7k, leaving some room for parameters
 size     equ   .
 
 name     fcs   /Merge/
          fcb   edition    change to 6, as merge 5 has problems?
 
-start    pshs  u          save start address of memory
+start    subd  #$0001     if this becomes zero,
+         beq   Exit       we have no parameters
+
+         pshs  u          save start address of memory
          stx   <param     and parameter area start
          tfr   x,d
          subd  #$0107     take out 1 bytes in DP, and 1 page for the stack
@@ -43,16 +50,41 @@
          leau  d.buffer,u point to some data
          stu   <d.ptr     save another pointer
 
-do.file  ldx   <param     get first filename
-         bsr   space
+do.opts  ldx   <param     get first option
+do.opts2 lbsr  space
 
-         clrb  
          cmpa  #C$CR      was the character a CR?
-         beq   Exit       yes, exit
+         beq   do.file    yes, parse files
+
+         cmpa  #'-        was the character a dash?
+         beq   do.dash    yes, parse option
+         lbsr  nonspace   else skip nonspace chars
+
+         cmpa  #C$CR      end of line?
+         beq   do.file    branch if so
+         bra   do.opts2   else continue parsing for options
+
+do.file  ldx   <param
+         lbsr  space
+
+         cmpa  #C$CR      CR?
+         beq   Exit       exit if so
 
-         lda   #READ.
+         cmpa  #'-        option?
+         bne   itsfile
+
+         bsr   nonspace
+
+         cmpa  #C$CR      CR?
+         beq   Exit       exit if so
+
+itsfile  bsr   readfile
+         bcs   Error
+         bra   do.file
+
+readfile lda   #READ.
          os9   I$Open     open the file for reading
-         bcs   Exit       crap out if error
+         bcs   read.ex    crap out if error
          sta   <path      save path number
          stx   <param     and save new address of parameter area
 
@@ -65,16 +97,53 @@
          lda   #$01       to STDOUT
          os9   I$Write    dump it out in one shot
          bcc   read.lp    loop if no errors
-         bra   Exit       otherwise exit ungracefully
+read.ex  rts
 
 chk.err  cmpb  #E$EOF     end of the file?
-         bne   Error      no, error out
+         bne   read.ex    no, error out
+ 
          lda   <path      otherwise get the current path number
          os9   I$Close    close it
-         bcc   do.file    if no error, go get next filename
+         rts              return to caller
 
 Error    coma             set carry
-Exit     os9   F$Exit     and exit
+         fcb   $21        skip next byte
+Exit     clrb
+         os9   F$Exit     and exit
+
+do.dash  leax  1,x        skip over dash
+         lda   ,x+        get char after dash
+         cmpa  #C$CR      CR?
+         beq   Exit       yes, exit
+
+         anda  #$DF       make uppercase
+         cmpa  #'Z        input from stdin?
+         bne   Exit
+
+* read from stdin until eof or blank line
+* skip lines that begin with * (these are comments)
+do.z     leax  d.buff,u
+         ldy   #127
+         clra             stdin
+         os9   I$ReadLn
+         bcc   do.z2
+         cmpb  #E$EOF     end-of-file?
+         bne   Error      nope, exit with error
+
+do.z2    lda   ,x
+         cmpa  #'*        asterisk? (comment)
+         beq   do.z       yep, ignore and get next line
+         bsr   space      skip space at X
+         cmpa  #C$CR      end of line?
+         beq   Exit       yup, we're done
+
+* X points to a filename...
+         pshs  x
+         bsr   readfile    read contents of file and send to stdout
+         puls  x
+         bcc   do.z        branch if ok
+         bra   Error 
+
 
 space    lda   ,x+        grab a character
          cmpa  #C$SPAC    space?
@@ -82,6 +151,14 @@
          leax  -1,x       otherwise point to last non-space
          rts
 
+nonspace lda   ,x+        grab a character
+         cmpa  #C$CR      cr?
+         beq   nospacex   yes, skip it
+         cmpa  #C$SPAC    nonspace?
+         bne   nonspace   yes, skip it
+nospacex leax  -1,x       otherwise point to last space
+         rts
+
          emod
 eom      equ   *
          end
--- a/level1/sys/merge.hp	Fri Sep 05 17:45:35 2003 +0000
+++ b/level1/sys/merge.hp	Sat Sep 06 22:51:41 2003 +0000
@@ -1,3 +1,6 @@
 @MERGE
 Syntax: Merge <path> [<path> [...]]
 Usage : Copies multiple input files to standard output
+Opts  :
+  -z = get list of files from standard input
+
--- a/level2/cmds/makefile	Fri Sep 05 17:45:35 2003 +0000
+++ b/level2/cmds/makefile	Sat Sep 06 22:51:41 2003 +0000
@@ -18,7 +18,7 @@
 
 SHELLMODS	= shellplus date deiniz echo iniz link load save unlink
 UTILPAK1	= attr build copy del deldir dir display list makdir mdir \
-		merge mfree procs rename sleep tee tmode
+		merge mfree procs rename sleep tmode
 
 ALLOBJS		= $(CMDS) $(SUBS)
 
--- a/level2/coco3/ChangeLog	Fri Sep 05 17:45:35 2003 +0000
+++ b/level2/coco3/ChangeLog	Sat Sep 06 22:51:41 2003 +0000
@@ -1,4 +1,5 @@
 OS-9 Level Two V03.01.05:
+- Merge now supports -z to get a list of files from standard input.
 - CC3Go has been renamed to SysGo.
 - The clock module has been divided into two modules: clock and clock2.
   clock_60hz and clock_50hz support 60Hz and 50Hz power configurations.
--- a/level2/coco3_6309/ChangeLog	Fri Sep 05 17:45:35 2003 +0000
+++ b/level2/coco3_6309/ChangeLog	Sat Sep 06 22:51:41 2003 +0000
@@ -1,4 +1,5 @@
 OS-9 Level Two V03.01.05:
+- Merge now supports -z to get a list of files from standard input.
 - CC3Go has been renamed to SysGo.
 - The clock module has been divided into two modules: clock and clock2.
   clock_60hz and clock_50hz support 60Hz and 50Hz power configurations.