mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2024-06-20 11:29:32 +00:00
Add strcoll and strxfrm functions.
This is currently a minimalistic implementation in which strcoll always sorts strings the same way as strcmp.
This commit is contained in:
parent
512fadeff0
commit
3a847d245e
66
string.asm
66
string.asm
|
@ -763,6 +763,31 @@ lb4 long M
|
||||||
rtl
|
rtl
|
||||||
end
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* int strcoll(const char *s1, const char *s2);
|
||||||
|
*
|
||||||
|
* Compare *s1 to *s2 based on current locale's collation order.
|
||||||
|
* If *s1 < *s2 then return a negative number; if they are
|
||||||
|
* equal, return 0; otherwise, return a positive number.
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* s1 - first string ptr
|
||||||
|
* s2 - second string ptr
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* A - result
|
||||||
|
*
|
||||||
|
* Notes:
|
||||||
|
* The current implementation assumes all supported locales
|
||||||
|
* have the same collation order as given by strcmp.
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
strcoll start
|
||||||
|
jml strcmp
|
||||||
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
* strcpy - string copy
|
* strcpy - string copy
|
||||||
|
@ -1790,3 +1815,44 @@ lb10 ldx set+2 get the return value
|
||||||
|
|
||||||
isp ds 4 internal state pointer (isp)
|
isp ds 4 internal state pointer (isp)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
* size_t strxfrm(char *s1, const char *s2, size_t n);
|
||||||
|
*
|
||||||
|
* Transform string *s2 into *s1, such that two output strings
|
||||||
|
* from strxfrm will compare the same way with strcmp that the
|
||||||
|
* input strings would with strcoll. Writes at most n bytes.
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* s1 - output string pointer
|
||||||
|
* s2 - input string pointer
|
||||||
|
* n - max length to write
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* *s1 - transformed output string (if it fits)
|
||||||
|
* A - length of full transformed string
|
||||||
|
* (not including terminating null)
|
||||||
|
*
|
||||||
|
* Notes:
|
||||||
|
* The current implementation assumes all supported locales
|
||||||
|
* have the same collation order as given by strcmp.
|
||||||
|
*
|
||||||
|
****************************************************************
|
||||||
|
*
|
||||||
|
strxfrm start
|
||||||
|
|
||||||
|
csubroutine (4:s1,4:s2,4:n),4
|
||||||
|
len equ 1 length of s2
|
||||||
|
|
||||||
|
ph4 s2 len = strlen(s2)
|
||||||
|
jsl strlen
|
||||||
|
sta len
|
||||||
|
stx len+2
|
||||||
|
cmpl len,n if len < n
|
||||||
|
bge ret
|
||||||
|
ph4 s2
|
||||||
|
ph4 s1
|
||||||
|
jsl strcpy strcpy(s1,s2)
|
||||||
|
ret creturn 4:len return len
|
||||||
|
end
|
||||||
|
|
|
@ -555,3 +555,15 @@
|
||||||
&l bne *+5
|
&l bne *+5
|
||||||
brl &bp
|
brl &bp
|
||||||
mend
|
mend
|
||||||
|
macro
|
||||||
|
&l cmpl &n1,&n2
|
||||||
|
lclb &yistwo
|
||||||
|
&l ~setm
|
||||||
|
~lda.h &n1
|
||||||
|
~op.h cmp,&n2
|
||||||
|
bne ~a&SYSCNT
|
||||||
|
~lda &n1
|
||||||
|
~op cmp,&n2
|
||||||
|
~a&SYSCNT anop
|
||||||
|
~restm
|
||||||
|
mend
|
||||||
|
|
Loading…
Reference in New Issue
Block a user