- Timestamp:
- 07/09/2017 01:36:31 PM (7 years ago)
- Branches:
- master
- Children:
- 0292fbb
- Parents:
- 002f873
- Location:
- libsm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
libsm/memccpy.c
r002f873 r5c13d64 4 4 Version 1 -- 1987-06-12 5 5 6 Copy s2 to s1, stopping if character c is copied.6 Copy vp2 to vp1, stopping if character c is copied. 7 7 Copy no more than n bytes. 8 8 Return a pointer to the byte after character c in the copy, … … 11 11 */ 12 12 13 char *memccpy(char *s1, char *s2, char c, int n)13 void *memccpy(void *vp1, void *vp2, char c, int n) 14 14 { 15 while (--n >= 0) 16 if ((*s1++ = *s2++) == c) 17 return(s1); 18 return((char *)0); 15 char *cp1 = vp1; 16 char *cp2 = vp2; 17 18 while (--n >= 0) 19 if ((*cp1++ = *cp2++) == c) 20 return(cp1); 21 22 return((void *)0); 19 23 } -
libsm/memchr.c
r002f873 r5c13d64 4 4 Version 1 -- 1987-06-12 5 5 6 Return the ptr in sp at which the character c appears;6 Return the ptr in vp at which the character c appears; 7 7 NULL if not found in n chars; don't stop at \0. 8 8 ============================================================================= 9 9 */ 10 10 11 char *memchr(char *sp, char c, int n)11 void *memchr(void *vp, char c, int n) 12 12 { 13 while (--n >= 0) 14 if (*sp++ == c) 15 return(--sp); 16 return((char *)0); 13 char *cp = vp; 14 15 while (--n >= 0) 16 if (*cp++ == c) 17 return(--cp); 18 19 return((void *)0); 17 20 } -
libsm/memcmp.c
r002f873 r5c13d64 4 4 Version 2 -- 1987-06-15 5 5 6 Compare n bytes: s1>s2: >0 s1==s2: 0 s1<s2: <06 Compare n bytes: vp1>vp2: >0 vp1==vp2: 0 vp1<vp2: <0 7 7 ============================================================================= 8 8 */ 9 9 10 int memcmp( char *s1, char *s2, int n)10 int memcmp(void *vp1, void *vp2, int n) 11 11 { 12 char *cp1 = vp1; 13 char *cp2 = vp2; 12 14 register int diff; 13 15 14 if (s1 != s2) 15 while (--n >= 0) 16 if (diff = *s1++ - *s2++) 17 return(diff); 18 return(0); 16 if (cp1 != cp2) 17 while (--n >= 0) 18 if (diff = *cp1++ - *cp2++) 19 return(diff); 20 21 return(0); 19 22 } -
libsm/memcmpu.c
r002f873 r5c13d64 8 8 #include "ctype.h" 9 9 10 int memcmpu( char *s1, char *s2, int n)10 int memcmpu(void *vp1, void *vp2, int n) 11 11 { 12 char *cp1 = vp1; 13 char *cp2 = vp2; 12 14 register char c1, c2; 13 15 14 16 while (n) { 15 17 16 c1 = * s1++;17 c2 = * s2++;18 c1 = *cp1++; 19 c2 = *cp2++; 18 20 19 21 if (isascii(c1) && islower(c1)) -
libsm/memcpy.c
r002f873 r5c13d64 4 4 Version 1 -- 1987-06-12 5 5 6 Copy s2 to s1, always copy n bytes.7 Return s1.6 Copy vp2 to vp1, always copy n bytes. 7 Return vp1. 8 8 ============================================================================= 9 9 */ 10 10 11 char *memcpy(char *s1, char *s2, int n)11 void *memcpy(void *vp1, void *vp2, int n) 12 12 { 13 register char *os1 = s1; 13 char *cp1 = vp1; 14 char *cp2 = vp2; 14 15 15 while (--n >= 0) 16 *s1++ = *s2++; 17 return (os1); 16 while (--n >= 0) 17 *cp1++ = *cp2++; 18 19 return(vp1); 18 20 } -
libsm/memcpyw.c
r002f873 r5c13d64 4 4 Version 2 -- 1987-06-15 -- D.N. Lynx Crowe 5 5 6 Copy s2 to s1, always copy n words.7 Return pointer to s1.6 Copy vp2 to vp1, always copy n words. 7 Return pointer to vp1. 8 8 ============================================================================= 9 9 */ 10 10 11 short *memcpyw(short *s1, short *s2, int n)11 void *memcpyw(void *vp1, void *vp2, int n) 12 12 { 13 register short *os1 = s1; 13 short *sp1 = vp1; 14 short *sp2 = vp2; 14 15 15 while (--n >= 0) 16 *s1++ = *s2++; 17 return (os1); 16 while (--n >= 0) 17 *sp1++ = *sp2++; 18 19 return(vp1); 18 20 } -
libsm/memset.c
r002f873 r5c13d64 4 4 Version 1 -- 1987-06-12 5 5 6 Set an array of n chars starting at sp to the character c.7 Return sp.6 Set an array of n chars starting at vp to the character c. 7 Return vp. 8 8 ============================================================================= 9 9 */ 10 10 11 char *memset(char *sp, char c, int n)11 void *memset(void *vp, char c, int n) 12 12 { 13 register char *sp0 = sp;13 char *cp = vp; 14 14 15 16 *sp++ = c;15 while (--n >= 0) 16 *cp++ = c; 17 17 18 return(sp0);18 return(vp); 19 19 } -
libsm/memsetw.c
r002f873 r5c13d64 4 4 Version 1 -- 1987-03-18 -- D.N. Lynx Crowe 5 5 6 Set an array of n shorts starting at sp to the short w.7 Return pointer to sp.6 Set an array of n shorts starting at vp to the short s. 7 Return pointer to vp. 8 8 ============================================================================= 9 9 */ 10 10 11 short *memsetw(short *sp, short w, short n)11 void *memsetw(void *vp, short s, short n) 12 12 { 13 register short *sp0 = sp;13 short *sp = vp; 14 14 15 16 *sp++ = w;15 while (--n >= 0) 16 *sp++ = s; 17 17 18 return(sp0);18 return(vp); 19 19 }
Note:
See TracChangeset
for help on using the changeset viewer.