mirror of
https://github.com/elliotnunn/sys7.1-doc-wip.git
synced 2024-12-27 12:31:11 +00:00
158 lines
4.7 KiB
Plaintext
158 lines
4.7 KiB
Plaintext
;
|
|
; File: OSUTILS.a
|
|
;
|
|
; Implements the C interface for the OS Utilities register based traps.
|
|
; Note: routines appear in same order as "Inside Macintosh"
|
|
; Written by Dan Smith 15-Nov-84 (converted version of the pascal interface)
|
|
;
|
|
;
|
|
; Copyright: © 1984-1992 by Apple Computer, Inc., all rights reserved.
|
|
;
|
|
; Change History (most recent first):
|
|
;
|
|
; <3> 7/6/92 DCL Added Support for new synonyms.
|
|
; <2> 10/2/90 JAL Removed old/commented out code.
|
|
; Modifications:
|
|
; 4 Feb 88 KLH added debugstr.
|
|
; 11 Feb 88 KLH Changed C headers to work with new C compiler:
|
|
; Changed to using standard glue in Interface.o, so
|
|
; much glue removed from CInterface.o.
|
|
; *** MPW 3.0d4 ***
|
|
; 19 Oct 88 KLH Check equalstring to make sure both strings are not
|
|
; the same so c2pstr won't happen twice on the same string.
|
|
; Suggested by Steve Lurya.
|
|
; *** MPW 3.0a2 ***
|
|
; 4 Dec 89 JAL Moved equalstring and debugstr to Runtime.o
|
|
|
|
|
|
|
|
include 'macintosh.a'
|
|
|
|
|
|
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
;
|
|
; String Comparison
|
|
;
|
|
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
;----------------------------------------------------------------------
|
|
;
|
|
; FUNCTION relstring(str1,str2: Str255; caseSens, diacSens: Boolean): integer;
|
|
;
|
|
; Just like _CmpString, except it indicates sorting order of strings,
|
|
; _CmpString only tells whether or not they're equal.
|
|
;
|
|
;
|
|
; Arguments:
|
|
; str1 the first string
|
|
; str2 the second string
|
|
; caseSens case sensitive?
|
|
; diacSens sensitive to diacriticals?
|
|
;
|
|
; Entry:
|
|
; A0 - points to first character of first string
|
|
; A1 - points to first character of second string
|
|
; D0 (Hi Word) length of first string
|
|
; D0 (Lo Word) length of second string
|
|
;
|
|
; Exit:
|
|
; D0.L - -1 if first string sorts before second string
|
|
; 0 if strings are equal
|
|
; 1 if first string sorts after second string
|
|
;
|
|
|
|
relstring FUNC EXPORT
|
|
import p2cstr ; p2cstr(s) char *s;
|
|
import c2pstr ; c2pstr(s) char *s;
|
|
|
|
LINK A6, #0 ; allocate stack frame
|
|
|
|
; Convert strings to pascal format
|
|
move.l 8(a6),-(sp) ; address of str1
|
|
jsr c2pstr ; convert to pascal string
|
|
addq #4,sp ; pop parameter
|
|
move.l 12(a6),-(sp) ; address of str2
|
|
jsr c2pstr ; convert to pascal string
|
|
addq #4,sp ; pop parameter
|
|
MOVE.L 8(A6),A0 ;ptr to str1
|
|
MOVE.L 12(A6),A1 ;ptr to str2
|
|
MOVEQ #0,D0
|
|
MOVE.B (A0)+,D0 ;str1 length
|
|
SWAP D0
|
|
MOVE.B (A1)+,D0 ;str2 length
|
|
|
|
;depending on value of booleans, make proper call
|
|
TST.B 20(A6) ;value of diacSens
|
|
BEQ.S @2 ;strip diacriticals
|
|
TST.B 16(A6) ;value of caseSens
|
|
BEQ.S @1 ;ignore case
|
|
_RelString ,CASE ;both diacritical and case sensitive
|
|
BRA.S @4
|
|
|
|
@1 _RelString ;diacritical sensitive,map to upper case
|
|
BRA.S @4
|
|
|
|
;strip diacriticals
|
|
@2 TST.B 16(A6) ;case sensitive?
|
|
BEQ.S @3
|
|
_RelString ,MARKS,CASE ;ignore diacrits, case sensitive
|
|
BRA.S @4
|
|
|
|
@3 _RelString ,MARKS ;ignore diacrits and map to upper case
|
|
|
|
@4 move.w d0,-(sp) ; save result
|
|
|
|
; Convert strings back to C format
|
|
move.l 8(a6),-(sp) ; address of str1
|
|
jsr p2cstr ; convert to c string
|
|
addq #4,sp ; pop paramter
|
|
move.l 12(a6),-(sp) ; address of str2
|
|
jsr p2cstr ; convert to c string
|
|
addq #4,sp ; pop paramter
|
|
|
|
move.w (sp)+,d0 ; restore result
|
|
ext.w d0
|
|
ext.l d0
|
|
|
|
UNLK A6 ; restore stack
|
|
rts ; return
|
|
|
|
;-------------------------------------------------------------------------------
|
|
;
|
|
; void uprstring(theString,diacSens)
|
|
; char *theString;
|
|
; Boolean diacSens;
|
|
;
|
|
|
|
uprstring proc EXPORT
|
|
|
|
move.l 4(sp),d0 ; ptr to string to canonize
|
|
beq.s @4 ; bail out if nil
|
|
|
|
move.l d0,a0 ; get ptr to string
|
|
move.l a0,a1 ; copy of ptr to string
|
|
@1 tst.b (a1)+ ; test for zero terminator
|
|
bne.s @1
|
|
|
|
sub.l a0,a1 ; subtract ptrs to get length + 1
|
|
subq #1,a1 ; string length
|
|
move.l a1,d0 ; string length
|
|
beq.s @4
|
|
|
|
; decide which flavor of uprString to call and call it
|
|
move.l d2,-(sp) ; save register d2
|
|
tst.l 12(sp) ; diacritical sensitivity bool
|
|
beq.s @2 ; ignore diacriticals
|
|
_UprString ; keep diacriticals
|
|
bra.s @3
|
|
|
|
@2 _UprString ,MARKS
|
|
@3 move.l (sp)+,d2 ; restore register d2
|
|
|
|
@4 rts
|
|
|
|
|
|
|
|
END
|