Source code of Windows XP (NT5)
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.

76 lines
2.2 KiB

  1. /************************************************************************/
  2. /* */
  3. /* RCPP - Resource Compiler Pre-Processor for NT system */
  4. /* */
  5. /* RCPPTIL.C - Utility routines for RCPP */
  6. /* */
  7. /* 27-Nov-90 w-BrianM Update for NT from PM SDK RCPP */
  8. /* */
  9. /************************************************************************/
  10. #include "rc.h"
  11. extern void error(int);
  12. extern CHAR Msg_Text[];
  13. extern PCHAR Msg_Temp;
  14. /************************************************************************
  15. * PSTRDUP - Create a duplicate of string s and return a pointer to it.
  16. ************************************************************************/
  17. WCHAR *
  18. pstrdup(
  19. WCHAR *s
  20. )
  21. {
  22. return(wcscpy((WCHAR *)MyAlloc((wcslen(s) + 1) * sizeof(WCHAR)), s));
  23. }
  24. /************************************************************************
  25. ** pstrndup : copies n bytes from the string to a newly allocated
  26. ** near memory location.
  27. ************************************************************************/
  28. WCHAR *
  29. pstrndup(
  30. WCHAR *s,
  31. int n
  32. )
  33. {
  34. WCHAR *r;
  35. WCHAR *res;
  36. r = res = (WCHAR *) MyAlloc((n+1) * sizeof(WCHAR));
  37. if (res == NULL) {
  38. strcpy (Msg_Text, GET_MSG (1002));
  39. error(1002);
  40. return NULL;
  41. }
  42. __try {
  43. for (; n--; r++, s++) {
  44. *r = *s;
  45. }
  46. } __except(EXCEPTION_EXECUTE_HANDLER) {
  47. n++;
  48. while (n--) {
  49. *r++ = L'\0';
  50. }
  51. }
  52. *r = L'\0';
  53. return(res);
  54. }
  55. /************************************************************************
  56. ** strappend : appends src to the dst,
  57. ** returns a ptr in dst to the null terminator.
  58. ************************************************************************/
  59. WCHAR *
  60. strappend(
  61. register WCHAR *dst,
  62. register WCHAR *src
  63. )
  64. {
  65. while ((*dst++ = *src++) != 0);
  66. return(--dst);
  67. }