s_nappend.c 314 B

123456789101112131415161718
  1. #include <u.h>
  2. #include <libc.h>
  3. #include "String.h"
  4. /* append a char array ( of up to n characters) to a String */
  5. String *
  6. s_nappend(String *to, char *from, int n)
  7. {
  8. if (to == 0)
  9. to = s_new();
  10. if (from == 0)
  11. return to;
  12. for(; n && *from; from++, n--)
  13. s_putc(to, *from);
  14. s_terminate(to);
  15. return to;
  16. }