mirror of
https://github.com/cc65/cc65.git
synced 2025-02-12 21:31:10 +00:00
moved code to convert filename to uppercase into its own file/object
git-svn-id: svn://svn.cc65.org/cc65/trunk@1143 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
6b654255ba
commit
22567de635
@ -4,8 +4,6 @@
|
||||
; int open(const char *name,int flags,...);
|
||||
;
|
||||
|
||||
UCASE_FILENAME = 1 ; comment it out if filename shouldn't be uppercased
|
||||
|
||||
.include "atari.inc"
|
||||
.include "../common/fmode.inc"
|
||||
.include "../common/errno.inc"
|
||||
@ -14,11 +12,12 @@ UCASE_FILENAME = 1 ; comment it out if filename shouldn't be uppercased
|
||||
.import fddecusage,newfd
|
||||
.import findfreeiocb
|
||||
.import __do_oserror,__seterrno,incsp4
|
||||
.import ldaxysp,addysp,subysp
|
||||
.import _strupr,__oserror
|
||||
.importzp tmp4,tmp2,sp
|
||||
.import ldaxysp,addysp
|
||||
.import __oserror
|
||||
.importzp tmp4,tmp2
|
||||
.ifdef UCASE_FILENAME
|
||||
.importzp tmp3,ptr4
|
||||
.importzp tmp3
|
||||
.import ucase_fn
|
||||
.endif
|
||||
|
||||
.proc _open
|
||||
@ -71,50 +70,13 @@ cont: ldy #3
|
||||
jsr ldaxysp
|
||||
|
||||
.ifdef UCASE_FILENAME
|
||||
; we make sure that the filename doesn't contain lowercase letters
|
||||
; we copy the filename we got onto the stack, uppercase it and use this
|
||||
; one to open the iocb
|
||||
; we're using tmp3, ptr4
|
||||
|
||||
; save the original pointer
|
||||
sta ptr4
|
||||
stx ptr4+1
|
||||
|
||||
; now we need the length of the name
|
||||
ldy #0
|
||||
loop: lda (ptr4),y
|
||||
beq str_end
|
||||
cmp #ATEOL ; we also accept Atari EOF char as end of string
|
||||
beq str_end
|
||||
iny
|
||||
bne loop ; not longer than 255 chars (127 real limit)
|
||||
toolong:lda #<EINVAL ; file name is too long
|
||||
jsr ucase_fn
|
||||
bcc ucok1
|
||||
lda #<EINVAL ; file name is too long
|
||||
ldx #>EINVAL
|
||||
jmp seterr
|
||||
|
||||
str_end:iny ; room for terminating zero
|
||||
cpy #128 ; we only can handle lenght < 128
|
||||
bcs toolong
|
||||
sty tmp3 ; save size
|
||||
jsr subysp ; make room on the stack
|
||||
|
||||
; copy filename to the temp. place on the stack
|
||||
lda #0 ; end-of-string
|
||||
sta (sp),y ; Y still contains length + 1
|
||||
dey
|
||||
loop2: lda (ptr4),y
|
||||
sta (sp),y
|
||||
dey
|
||||
bpl loop2 ; bpl: this way we only support a max. length of 127
|
||||
|
||||
; uppercase the temp. filename
|
||||
ldx sp+1
|
||||
lda sp
|
||||
jsr _strupr
|
||||
|
||||
; leave X and Y pointing to the modified filename
|
||||
lda sp
|
||||
ldx sp+1
|
||||
ucok1:
|
||||
|
||||
.endif ; defined UCASE_FILENAME
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
;
|
||||
; int remove (const char* name);
|
||||
;
|
||||
UCASE_FILENAME = 1 ; comment it out if filename shouldn't be uppercased
|
||||
|
||||
.include "atari.inc"
|
||||
.include "../common/errno.inc"
|
||||
@ -11,8 +10,9 @@ UCASE_FILENAME = 1 ; comment it out if filename shouldn't be uppercased
|
||||
.import popax,__oserror,__seterrno
|
||||
.importzp tmp1
|
||||
.ifdef UCASE_FILENAME
|
||||
.import addysp,_strupr,subysp
|
||||
.importzp tmp3,ptr4,sp
|
||||
.importzp tmp3
|
||||
.import addysp
|
||||
.import ucase_fn
|
||||
.endif
|
||||
.export _remove
|
||||
|
||||
@ -35,51 +35,13 @@ iocbok: ;stx tmp1 ; remember IOCB index
|
||||
jsr popax
|
||||
|
||||
.ifdef UCASE_FILENAME
|
||||
;@@@TODO merge with almost same code in open.s
|
||||
; we make sure that the filename doesn't contain lowercase letters
|
||||
; we copy the filename we got onto the stack, uppercase it and use this
|
||||
; one to open the iocb
|
||||
; we're using tmp3, ptr4
|
||||
|
||||
; save the original pointer
|
||||
sta ptr4
|
||||
stx ptr4+1
|
||||
|
||||
; now we need the length of the name
|
||||
ldy #0
|
||||
loop: lda (ptr4),y
|
||||
beq str_end
|
||||
cmp #ATEOL ; we also accept Atari EOF char as end of string
|
||||
beq str_end
|
||||
iny
|
||||
bne loop ; not longer than 255 chars (127 real limit)
|
||||
toolong:lda #<EINVAL ; file name is too long
|
||||
jsr ucase_fn
|
||||
bcc ucok1
|
||||
lda #<EINVAL ; file name is too long
|
||||
ldx #>EINVAL
|
||||
jmp seterr
|
||||
|
||||
str_end:iny ; room for terminating zero
|
||||
cpy #128 ; we only can handle lenght < 128
|
||||
bcs toolong
|
||||
sty tmp3 ; save size
|
||||
jsr subysp ; make room on the stack
|
||||
|
||||
; copy filename to the temp. place on the stack
|
||||
lda #0 ; end-of-string
|
||||
sta (sp),y ; Y still contains length + 1
|
||||
dey
|
||||
loop2: lda (ptr4),y
|
||||
sta (sp),y
|
||||
dey
|
||||
bpl loop2 ; bpl: this way we only support a max. length of 127
|
||||
|
||||
; uppercase the temp. filename
|
||||
ldx sp+1
|
||||
lda sp
|
||||
jsr _strupr
|
||||
|
||||
; leave X and Y pointing to the modified filename
|
||||
lda sp
|
||||
ldx sp+1
|
||||
ucok1:
|
||||
|
||||
.endif ; defined UCASE_FILENAME
|
||||
|
||||
@ -103,14 +65,12 @@ loop2: lda (ptr4),y
|
||||
jsr CIOV
|
||||
|
||||
.ifdef UCASE_FILENAME
|
||||
; php
|
||||
tya
|
||||
pha
|
||||
ldy tmp3 ; get size
|
||||
jsr addysp ; free used space on the stack
|
||||
pla
|
||||
tay
|
||||
; plp
|
||||
.endif ; defined UCASE_FILENAME
|
||||
|
||||
bmi cioerr
|
||||
|
73
libsrc/atari/ucase_fn.s
Normal file
73
libsrc/atari/ucase_fn.s
Normal file
@ -0,0 +1,73 @@
|
||||
;
|
||||
; Christian Groessler, Dec-2001
|
||||
;
|
||||
; ucase_fn
|
||||
; helper routine to convert a string (file name) to uppercase
|
||||
; used by open.s and remove.s
|
||||
;
|
||||
; Calling parameters:
|
||||
; AX - points to filename
|
||||
; Return parameters:
|
||||
; C - 0/1 for OK/Error (filename too long)
|
||||
; AX - points to uppercased version of the filename on the stack
|
||||
; tmp3 - amount of bytes used on the stack (needed for cleanup)
|
||||
; Uses:
|
||||
; ptr4 - scratch pointer used to remember original AX pointer
|
||||
;
|
||||
;
|
||||
|
||||
.include "atari.inc"
|
||||
|
||||
.importzp tmp3,ptr4,sp
|
||||
.import _strupr,subysp
|
||||
.export ucase_fn
|
||||
|
||||
ucase_fn: .proc
|
||||
|
||||
; we make sure that the filename doesn't contain lowercase letters
|
||||
; we copy the filename we got onto the stack, uppercase it and use this
|
||||
; one to open the iocb
|
||||
; we're using tmp3, ptr4
|
||||
|
||||
; save the original pointer
|
||||
sta ptr4
|
||||
stx ptr4+1
|
||||
|
||||
; now we need the length of the name
|
||||
ldy #0
|
||||
loop: lda (ptr4),y
|
||||
beq str_end
|
||||
cmp #ATEOL ; we also accept Atari EOF char as end of string
|
||||
beq str_end
|
||||
iny
|
||||
bne loop ; not longer than 255 chars (127 real limit)
|
||||
toolong:sec ; indicate error
|
||||
rts
|
||||
|
||||
str_end:iny ; room for terminating zero
|
||||
cpy #128 ; we only can handle lenght < 128
|
||||
bcs toolong
|
||||
sty tmp3 ; save size
|
||||
jsr subysp ; make room on the stack
|
||||
|
||||
; copy filename to the temp. place on the stack
|
||||
lda #0 ; end-of-string
|
||||
sta (sp),y ; Y still contains length + 1
|
||||
dey
|
||||
loop2: lda (ptr4),y
|
||||
sta (sp),y
|
||||
dey
|
||||
bpl loop2 ; bpl: this way we only support a max. length of 127
|
||||
|
||||
; uppercase the temp. filename
|
||||
ldx sp+1
|
||||
lda sp
|
||||
jsr _strupr
|
||||
|
||||
; leave X and Y pointing to the modified filename
|
||||
lda sp
|
||||
ldx sp+1
|
||||
clc ; indicate success
|
||||
rts
|
||||
|
||||
ucase_fn: .endproc
|
Loading…
x
Reference in New Issue
Block a user