strxfrm.c 439 B

123456789101112131415161718192021222324
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Id$ */
  6. #include <string.h>
  7. size_t
  8. strxfrm(register char *s1, register const char *save, register size_t n)
  9. {
  10. register const char *s2 = save;
  11. while (*s2) {
  12. if (n > 1) {
  13. n--;
  14. *s1++ = *s2++;
  15. } else
  16. s2++;
  17. }
  18. if (n > 0)
  19. *s1++ = '\0';
  20. return s2 - save;
  21. }