mirror of
https://github.com/gungwald/prodos-more.git
synced 2024-12-23 13:31:03 +00:00
Improve error handling
This commit is contained in:
parent
0e5401934f
commit
1fbb9f7c5f
5
.gitignore
vendored
5
.gitignore
vendored
@ -1 +1,4 @@
|
||||
*.swp
|
||||
MORE
|
||||
MORE.dsk
|
||||
_FileInformation.txt
|
||||
|
||||
|
11
Makefile
11
Makefile
@ -25,8 +25,8 @@ endif
|
||||
# the PowerBook G4 and iBook G3. This version only requires Java 1.3.
|
||||
AC=java -jar AppleCommander-1.3.5-ac.jar
|
||||
SRC=more.s
|
||||
PGM=more
|
||||
BASE_DSK=prodos-2.0.3-boot.dsk
|
||||
PGM=MORE
|
||||
BASE_DSK=prodos-2.0.3.dsk
|
||||
VOL=$(PGM)
|
||||
DSK=$(PGM).dsk
|
||||
|
||||
@ -35,12 +35,13 @@ DSK=$(PGM).dsk
|
||||
# disk instead.
|
||||
#$(AC) -pro140 $(DSK) $(VOL)
|
||||
|
||||
$(DSK): $(PGM)
|
||||
$(DSK): $(PGM) test.txt
|
||||
$(COPY) $(BASE_DSK) $(DSK)
|
||||
$(AC) -p $(DSK) $(PGM) BIN 0x8000 < $(PGM)
|
||||
$(AC) -p $(DSK) $(PGM) BIN 0x2000 < $(PGM)
|
||||
cat test.txt | tr '\n' '\r' | $(AC) -p $(DSK) TEST TXT
|
||||
|
||||
$(PGM): $(SRC) Makefile
|
||||
merlin32 --verbose $(SRC)
|
||||
merlin32 $(SRC)
|
||||
|
||||
clean:
|
||||
$(RM) $(DSK) $(PGM) *.zip _FileInformation.txt $(PGM)_Output.txt
|
||||
|
112
more.S
112
more.S
@ -23,14 +23,16 @@ COUT .EQ $FDED
|
||||
PRBYTE .EQ $FDDA
|
||||
*
|
||||
* SUBROUTINES IN BASIC.SYSTEM ROM:
|
||||
*
|
||||
GETBUFR .EQ $BEF5 ;ALLOCATE BUFFER, DESTROYS X & Y
|
||||
FREEBUFR .EQ $BEF8 ;FREE BUFFER
|
||||
*
|
||||
|
||||
GETBUFR EQU $BEF5 ;BCC=OKAY & A=HIBYTE OF BUF
|
||||
;BCS=FAIL & A=ERRCODE
|
||||
;X & Y ARE DESTROYED
|
||||
FREEBUFR EQU $BEF8 ;FREE BUFFER
|
||||
|
||||
* PRODOS ENTRY POINT
|
||||
*
|
||||
MLI .EQ $BF00
|
||||
*
|
||||
|
||||
PRODOS EQU $BF00 ;MACHINE LANG IFACE (MLI)
|
||||
|
||||
* MEMORY LOCATIONS
|
||||
*
|
||||
OURCH .EQ $057B ;80-COL HORIZ CURSOR POSITION
|
||||
@ -174,21 +176,20 @@ MAIN CLD ;CLEAR DECIMAL FLG, AVOID CRASH
|
||||
*
|
||||
LDA #4 ;FOUR 256 BYTE PAGES = 1KB
|
||||
JSR GETBUFR ;GET BUF FROM BASIC.SYSTEM
|
||||
BCS ERRFWDR ;CARRY SET INDICATES AN ERROR
|
||||
BCS :OBUFERR ;CARRY CLEAR MEANS NO ERROR
|
||||
STA OBUFADDR+1 ;GETBUFR RETURNS HIBYTE IN A
|
||||
LDA #0 ;PREPARE
|
||||
STA OBUFADDR ;LOBYTE IS 0 B/C ADDR OF PAGE
|
||||
*
|
||||
* OPEN FILE
|
||||
*
|
||||
JSR MLI
|
||||
:OPENFILE JSR PRODOS
|
||||
DB OPENCMD
|
||||
DA OPENPRMS
|
||||
BNE ERRFWDR
|
||||
BEQ :OPEN_OK
|
||||
JSR ERRPROC
|
||||
JMP :FREEOBUF
|
||||
*
|
||||
* COPY FILE NUMBER FROM OPEN PARAMETERS TO READ AND CLOSE
|
||||
*
|
||||
LDA OPENFNUM
|
||||
:OPEN_OK LDA OPENFNUM
|
||||
STA READFNUM
|
||||
STA CLOSFNUM
|
||||
*
|
||||
@ -196,47 +197,30 @@ MAIN CLD ;CLEAR DECIMAL FLG, AVOID CRASH
|
||||
*
|
||||
LDA #1 ;ONE 256 BYTE BUFFER
|
||||
JSR GETBUFR ;CALL BASIC.SYSTEM SUB
|
||||
BCS ERRFWDR ;CARRY SET MEANS ERROR
|
||||
STA RBADDR+1 ;STORE HI-BYTE
|
||||
STA ZP.A1H ;AGAIN, FOR 0-PAGE INDIRECTION
|
||||
BCC :RBUF_OK ;CARRY CLR MEANS NO ERROR
|
||||
JSR ERRPROC
|
||||
JMP :CLOSFILE
|
||||
:RBUF_OK STA RBADDR+1 ;STORE HI-BYTE
|
||||
LDA #0 ;0 FOR LO-BYTE
|
||||
STA RBADDR ;STORE IT
|
||||
STA ZP.A1L ;AGAIN, FOR 0-PAGE INDIRECTION
|
||||
*
|
||||
* PRINT THE FILE
|
||||
*
|
||||
JSR VIEWFILE ;MUST CLOSE BEFORE ERR HANDLING
|
||||
JSR VIEWFILE
|
||||
*
|
||||
* FREE READ BUFFER
|
||||
* CLEANUP
|
||||
*
|
||||
JSR FREEBUFR
|
||||
*
|
||||
* CLOSE FILE
|
||||
*
|
||||
JSR MLI
|
||||
:FREERBUF JSR FREEBUFR ;FREE READ BUFFER
|
||||
:CLOSFILE JSR PRODOS ;CLOSE THE FILE
|
||||
DB CLOSCMD
|
||||
DA CLOSPRMS
|
||||
STA CLOSERR
|
||||
*
|
||||
* FREE FILE BUFFER USED IN OPEN CALL
|
||||
*
|
||||
JSR FREEBUFR
|
||||
*
|
||||
* CHECK FOR ERRORS
|
||||
*
|
||||
LDA READERR ;RELOAD THE READ RESULT CODE
|
||||
CMP EOFERR ;WAS IT AN EOF "ERROR"
|
||||
BEQ END ;EOF IS NOT REALLY AN ERROR
|
||||
CMP #0
|
||||
BNE ERRFWDR
|
||||
LDA CLOSERR
|
||||
BNE ERRFWDR
|
||||
JMP END
|
||||
*
|
||||
* FINISH
|
||||
*
|
||||
ERRFWDR JSR ERRPROC
|
||||
END NOP
|
||||
BCC FREEOBUF
|
||||
:OPENERR JSR ERRPROC
|
||||
:FREEOBUF JSR FREEBUFR ;FREE OPEN I/O BUFFER
|
||||
JMP :END
|
||||
:OBUFERR JSR ERRPROC
|
||||
:END NOP
|
||||
RTS
|
||||
|
||||
********************************
|
||||
@ -250,18 +234,18 @@ VIEWFILE
|
||||
>PUTS ENVIEW
|
||||
FIN
|
||||
|
||||
>SET1 LINENUM ;INIT LINE NUMBER
|
||||
.1 JSR MLI ;CALL PRODOS TO READ FILE
|
||||
SET1 LINENUM ;INIT LINE NUMBER
|
||||
:LOOP JSR PRODOS ;CALL PRODOS TO READ FILE
|
||||
DB READCMD ;SPECIFY PRODOS READ COMMAND
|
||||
DA READPRMS ;READ PARAMETERS
|
||||
STA READERR ;SAVE RESULT OF READ OPERATION
|
||||
BNE .2 ;IF ERROR THEN END SUB
|
||||
BNE :READERR
|
||||
JSR WRITEBUF ;WRITE TO SCREEN WHAT WAS READ
|
||||
LDA #1 ;PREPARE FOR NEXT OP
|
||||
CMP USRQUIT ;IF USER WANTS TO QUIT, THEN
|
||||
BEQ .2 ;EXIT THE LOOP
|
||||
JMP .1 ;ELSE, GET THE NEXT BUFFER
|
||||
.2 NOP
|
||||
BEQ :ENDLOOP ;EXIT THE LOOP
|
||||
JMP :LOOP ;ELSE, GET THE NEXT BUFFER
|
||||
:READERR JSR ERRPROC
|
||||
:ENDLOOP NOP
|
||||
RTS
|
||||
|
||||
********************************
|
||||
@ -387,14 +371,22 @@ ERASEBAR
|
||||
********************************
|
||||
* *
|
||||
* ERROR HANDLER *
|
||||
* INPUT PARAM: ERRCODE *
|
||||
* *
|
||||
********************************
|
||||
|
||||
ERRPROC STA ERRCODE
|
||||
>PUTS ERRTXT
|
||||
JSR PRBYTE
|
||||
JSR CROUT
|
||||
RTS
|
||||
ERRPROC
|
||||
LDA ERRCODE
|
||||
CMP #0
|
||||
BEQ :NOERR
|
||||
CMP #EOFERR
|
||||
BEQ :NOERR
|
||||
PUTS ERRTXT
|
||||
LDA ERRCODE
|
||||
JSR PRBYTE
|
||||
JSR CROUT
|
||||
:NOERR NOP
|
||||
RTS
|
||||
|
||||
********************************
|
||||
* *
|
||||
@ -452,5 +444,7 @@ CLOSFNUM .BS 1
|
||||
* CONSUME ALL BYTES UP TO THE NEXT PAGE BOUNDRY
|
||||
*FILLER DS \,$00
|
||||
* MUST START ON PAGE BOUNDRY
|
||||
*OPENBUF .BS 1024
|
||||
*READBUF .BS BUFSIZE
|
||||
*OPENBUF DS 1024
|
||||
*READBUF DS BUFSIZE
|
||||
|
||||
:
|
||||
|
Binary file not shown.
195
test.txt
Normal file
195
test.txt
Normal file
@ -0,0 +1,195 @@
|
||||
MORE(1) User Commands MORE(1)
|
||||
|
||||
NAME
|
||||
more - display the contents of a file in a terminal
|
||||
|
||||
SYNOPSIS
|
||||
more [options] file ...
|
||||
|
||||
DESCRIPTION
|
||||
more is a filter for paging through text one screenful at a time. This
|
||||
version is especially primitive. Users should realize that less(1)
|
||||
provides more(1) emulation plus extensive enhancements.
|
||||
|
||||
OPTIONS
|
||||
Options are also taken from the environment variable MORE (make sure to
|
||||
precede them with a dash (-)) but command-line options will override
|
||||
those.
|
||||
|
||||
-d, --silent
|
||||
Prompt with "[Press space to continue, 'q' to quit.]", and display
|
||||
"[Press 'h' for instructions.]" instead of ringing the bell when an
|
||||
illegal key is pressed.
|
||||
|
||||
-l, --logical
|
||||
Do not pause after any line containing a ^L (form feed).
|
||||
|
||||
-e, --exit-on-eof
|
||||
Exit on End-Of-File, enabled by default if POSIXLY_CORRECT
|
||||
environment variable is not set or if not executed on terminal.
|
||||
|
||||
-f, --no-pause
|
||||
Count logical lines, rather than screen lines (i.e., long lines are
|
||||
not folded).
|
||||
|
||||
-p, --print-over
|
||||
Do not scroll. Instead, clear the whole screen and then display the
|
||||
text. Notice that this option is switched on automatically if the
|
||||
executable is named page.
|
||||
|
||||
-c, --clean-print
|
||||
Do not scroll. Instead, paint each screen from the top, clearing
|
||||
the remainder of each line as it is displayed.
|
||||
|
||||
-s, --squeeze
|
||||
Squeeze multiple blank lines into one.
|
||||
|
||||
-u, --plain
|
||||
Suppress underlining. This option is silently ignored as backwards
|
||||
compatibility.
|
||||
|
||||
-n, --lines number
|
||||
Specify the number of lines per screenful. The number argument is a
|
||||
positive decimal integer. The --lines option shall override any
|
||||
values obtained from any other source, such as number of lines
|
||||
reported by terminal.
|
||||
|
||||
-number
|
||||
A numeric option means the same as --lines option argument.
|
||||
|
||||
+number
|
||||
Start displaying each file at line number.
|
||||
|
||||
+/string
|
||||
The string to be searched in each file before starting to display
|
||||
it.
|
||||
|
||||
-h, --help
|
||||
Display help text and exit.
|
||||
|
||||
-V, --version
|
||||
Print version and exit.
|
||||
|
||||
COMMANDS
|
||||
Interactive commands for more are based on vi(1). Some commands may be
|
||||
preceded by a decimal number, called k in the descriptions below. In
|
||||
the following descriptions, ^X means control-X.
|
||||
|
||||
h or ?
|
||||
Help; display a summary of these commands. If you forget all other
|
||||
commands, remember this one.
|
||||
|
||||
SPACE
|
||||
Display next k lines of text. Defaults to current screen size.
|
||||
|
||||
z
|
||||
Display next k lines of text. Defaults to current screen size.
|
||||
Argument becomes new default.
|
||||
|
||||
RETURN
|
||||
Display next k lines of text. Defaults to 1. Argument becomes new
|
||||
default.
|
||||
|
||||
d or ^D
|
||||
Scroll k lines. Default is current scroll size, initially 11.
|
||||
Argument becomes new default.
|
||||
|
||||
q or Q or INTERRUPT
|
||||
Exit.
|
||||
|
||||
s
|
||||
Skip forward k lines of text. Defaults to 1.
|
||||
|
||||
f
|
||||
Skip forward k screenfuls of text. Defaults to 1.
|
||||
|
||||
b or ^B
|
||||
Skip backwards k screenfuls of text. Defaults to 1. Only works with
|
||||
files, not pipes.
|
||||
|
||||
'
|
||||
Go to the place where the last search started.
|
||||
|
||||
=
|
||||
Display current line number.
|
||||
|
||||
/pattern
|
||||
Search for kth occurrence of regular expression. Defaults to 1.
|
||||
|
||||
n
|
||||
Search for kth occurrence of last regular expression. Defaults to
|
||||
1.
|
||||
|
||||
!command or :!command
|
||||
Execute command in a subshell.
|
||||
|
||||
v
|
||||
Start up an editor at current line. The editor is taken from the
|
||||
environment variable VISUAL if defined, or EDITOR if VISUAL is not
|
||||
defined, or defaults to vi(1) if neither VISUAL nor EDITOR is
|
||||
defined.
|
||||
|
||||
^L
|
||||
Redraw screen.
|
||||
|
||||
:n
|
||||
Go to kth next file. Defaults to 1.
|
||||
|
||||
:p
|
||||
Go to kth previous file. Defaults to 1.
|
||||
|
||||
:f
|
||||
Display current file name and line number.
|
||||
|
||||
.
|
||||
Repeat previous command.
|
||||
|
||||
ENVIRONMENT
|
||||
The more command respects the following environment variables, if they
|
||||
exist:
|
||||
|
||||
MORE
|
||||
This variable may be set with favored options to more.
|
||||
|
||||
SHELL
|
||||
Current shell in use (normally set by the shell at login time).
|
||||
|
||||
TERM
|
||||
The terminal type used by more to get the terminal characteristics
|
||||
necessary to manipulate the screen.
|
||||
|
||||
VISUAL
|
||||
The editor the user prefers. Invoked when command key v is pressed.
|
||||
|
||||
EDITOR
|
||||
The editor of choice when VISUAL is not specified.
|
||||
|
||||
POSIXLY_CORRECT
|
||||
Disable exit-on-eof (see option -e for more details).
|
||||
|
||||
HISTORY
|
||||
The more command appeared in 3.0BSD. This man page documents more
|
||||
version 5.19 (Berkeley 6/29/88), which is currently in use in the Linux
|
||||
community. Documentation was produced using several other versions of
|
||||
the man page, and extensive inspection of the source code.
|
||||
|
||||
AUTHORS
|
||||
Eric Shienbrood, UC Berkeley.
|
||||
|
||||
Modified by Geoff Peck, UCB to add underlining, single spacing.
|
||||
|
||||
Modified by John Foderaro, UCB to add -c and MORE environment variable.
|
||||
|
||||
SEE ALSO
|
||||
less(1), vi(1)
|
||||
|
||||
REPORTING BUGS
|
||||
For bug reports, use the issue tracker at
|
||||
https://github.com/util-linux/util-linux/issues.
|
||||
|
||||
AVAILABILITY
|
||||
The more command is part of the util-linux package which can be
|
||||
downloaded from Linux Kernel Archive
|
||||
<https://www.kernel.org/pub/linux/utils/util-linux/>.
|
||||
|
||||
util-linux 2.39.3 2023-11-21 MORE(1)
|
Loading…
Reference in New Issue
Block a user