/* 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; .GLOBAL _strxfrm; .GLOBAL ___strxfrmDD; _strxfrm: ___strxfrmDD: transform_core: R0=R0-R0, FETCH_RETURN /* Clear result register */ R8=PASS R8; /* Test for NULL s2 */ IF EQ JUMP (PC, restore_state); /* Return with 0 result */ R12=PASS R12; /* Test for length of zero */ IF EQ JUMP (PC, dm_to_dm_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 */ dm_to_dm_xform: R12=PASS R12, dm_ptr=R4; /* Point to s1 */ IF EQ JUMP (PC, return_dm_len) (DB); /* Return the length of input*/ R2=R8-R4, R0=dm_0; /* Get difference between in/out*/ R12=PASS R12, dm_mdf=R2; /* Used to modify pointers */ IF EQ JUMP (PC, dm_dm); /* Write out NULL only */ LCNTR=R12, DO dm_dm UNTIL LCE; /* Copy n-1 characters at most */ IF NE R0=R0+1, R2=DM(dm_mdf, dm_ptr); /* Read in char */ dm_dm: IF NE R2=PASS R2, DM(dm_ptr, dm_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: RETURN (DB); RESTORE_STACK RESTORE_FRAME return_dm_len: R0=PASS R8, dm_ptr=R8; /* Hold string start */ DO find_dm_end UNTIL EQ; /* Loop until NULL */ find_dm_end: IF NE R8=PASS R8, R8=DM(dm_ptr,dm_1); R0=R0+1, MODIFY(dm_ptr, dm_M1); /* Back up to NULL */ JUMP (PC, restore_state) (DB); /* Return length */ R8=dm_ptr; R0=R8-R0, MODIFY(dm_ptr, dm_M1);/* Compute length */ .ENDSEG;