/* This C language subroutine transform a string from one locale to another. Since there is only one locale defined here, this is basically just a strcpy clone. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 4/30/90 Updated on 5/94 by AS Updated on 3/95 by AS - separated polymorphic functions #include
size_t strxfrm(char *s1, const char *s2, size_t size); */ #include "lib_glob.h" #include "str_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .EXTERN ___lib_strlendm, ___lib_strlenpm; .GLOBAL ___strxfrmPP; ___strxfrmPP: transform_core: R8=PASS R8, R0=dm_0; /* Test for NULL s2, Clr result reg*/ IF EQ JUMP (PC, restore_state); /* Return with 0 result */ R12=PASS R12; /* Test for length of zero */ IF EQ JUMP (PC, pm_to_pm_xform) (DB); R0=R0-1; /* Set return to -1 for error */ R4=PASS R4; /* Test for NULL s1 */ IF EQ JUMP (PC, restore_state); /* NULL s1, return -1 */ pm_to_pm_xform: R12=PASS R12, pm_ptr=R4; /* Point to s1 */ IF EQ JUMP (PC, return_pm_len) (DB); /* Return the length of input*/ R2=R8-R4, R0=pm_0; /* Get difference between in/out*/ R12=PASS R12, pm_mdf=R2; /* Used to modify pointers */ IF EQ JUMP (PC, pm_pm); /* Write out NULL only */ LCNTR=R12, DO pm_pm UNTIL LCE; /* Copy n-1 characters at most */ IF NE R0=R0+1, R2=PM(pm_mdf, pm_ptr); /* Read in char */ pm_pm: IF NE R2=PASS R2, PM(pm_ptr, pm_1)=R2; /* Write char */ IF EQ R0=R0-1; /* Remove NULL from count */ R4=R4-R4, MODIFY(dm_ptr, dm_M1);/* Backup pointer to last write */ R2=PASS R2, DM(dm_ptr, dm_1)=R4;/* Write out NULL, test write */ IF NE R0=R0+1; /* Increment count for error */ restore_state: FETCH_RETURN RETURN (DB); RESTORE_STACK RESTORE_FRAME return_pm_len: R0=PASS R8, pm_ptr=R8; /* Hold string start */ DO find_pm_end UNTIL EQ; /* Loop until NULL */ find_pm_end: IF NE R8=PASS R8, R8=PM(pm_ptr,pm_1); R0=R0+1, MODIFY(pm_ptr, pm_M1); /* Back up to NULL */ JUMP (PC, restore_state) (DB); R8=pm_ptr; R0=R8-R0, MODIFY(pm_ptr, pm_M1);/* Compute length */ .ENDSEG;