Leaked source code of windows server 2003
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.

68 lines
2.1 KiB

  1. /***
  2. *wcscspn.c - find length of initial substring of wide characters
  3. * not in a control string
  4. *
  5. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  6. *
  7. *Purpose:
  8. * defines wcscspn()- finds the length of the initial substring of
  9. * a string consisting entirely of characters not in a control string
  10. * (wide-character strings).
  11. *
  12. *Revision History:
  13. * 11-04-91 ETC Created with source from crtdll.
  14. * 04-07-92 KRS Updated and ripped out _INTL switches.
  15. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  16. * 02-07-94 CFW POSIXify.
  17. * 02-27-98 RKP Added 64 bit support.
  18. *
  19. *******************************************************************************/
  20. #ifndef _POSIX_
  21. #include <cruntime.h>
  22. #include <string.h>
  23. /***
  24. *size_t wcscspn(string, control) - search for init substring w/o control wchars
  25. *
  26. *Purpose:
  27. * returns the index of the first character in string that belongs
  28. * to the set of characters specified by control. This is equivalent
  29. * to the length of the length of the initial substring of string
  30. * composed entirely of characters not in control. Null chars not
  31. * considered (wide-character strings).
  32. *
  33. *Entry:
  34. * wchar_t *string - string to search
  35. * wchar_t *control - set of characters not allowed in init substring
  36. *
  37. *Exit:
  38. * returns the index of the first wchar_t in string
  39. * that is in the set of characters specified by control.
  40. *
  41. *Exceptions:
  42. *
  43. *******************************************************************************/
  44. size_t __cdecl wcscspn (
  45. const wchar_t * string,
  46. const wchar_t * control
  47. )
  48. {
  49. wchar_t *str = (wchar_t *) string;
  50. wchar_t *wcset;
  51. /* 1st char in control string stops search */
  52. while (*str) {
  53. for (wcset = (wchar_t *)control; *wcset; wcset++) {
  54. if (*wcset == *str) {
  55. return (size_t)(str - string);
  56. }
  57. }
  58. str++;
  59. }
  60. return (size_t)(str - string);
  61. }
  62. #endif /* _POSIX_ */