You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9 KiB

26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
  1. /* Copyright (C) 2002 MySQL AB
  2. This library is free software; you can redistribute it and/or
  3. modify it under the terms of the GNU Library General Public
  4. License as published by the Free Software Foundation; version 2
  5. of the License.
  6. This library is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9. Library General Public License for more details.
  10. You should have received a copy of the GNU Library General Public
  11. License along with this library; if not, write to the Free
  12. Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  13. MA 02111-1307, USA */
  14. /* File : strxnmov.c
  15. Author : Richard A. O'Keefe.
  16. Updated: 2 June 1984
  17. Defines: strxnmov()
  18. strxnmov(dst, len, src1, ..., srcn, NullS)
  19. moves the first len characters of the concatenation of src1,...,srcn
  20. to dst and add a closing NUL character.
  21. It is just like strnmov except that it concatenates multiple sources.
  22. Beware: the last argument should be the null character pointer.
  23. Take VERY great care not to omit it! Also be careful to use NullS
  24. and NOT to use 0, as on some machines 0 is not the same size as a
  25. character pointer, or not the same bit pattern as NullS.
  26. NOTE
  27. strxnmov is like strnmov in that it moves up to len
  28. characters; dst will be padded on the right with one '\0' character.
  29. if total-string-length >= length then dst[length] will be set to \0
  30. */
  31. #include <my_global.h>
  32. #include "m_string.h"
  33. #include <stdarg.h>
  34. char *strxnmov(char *dst,uint len, const char *src, ...)
  35. {
  36. va_list pvar;
  37. char *end_of_dst=dst+len;
  38. va_start(pvar,src);
  39. while (src != NullS)
  40. {
  41. do
  42. {
  43. if (dst == end_of_dst)
  44. goto end;
  45. }
  46. while ((*dst++ = *src++));
  47. dst--;
  48. src = va_arg(pvar, char *);
  49. }
  50. end:
  51. *dst=0;
  52. va_end(pvar);
  53. return dst;
  54. }