comparison src/intl-win32.c @ 3648:3e7493e76dc7

[xemacs-hg @ 2006-11-01 20:25:48 by adrian] fix for ffap crash on Windows (was: [Bug: 21.5-b27] [CRASH] (file-name-directory "1:")) -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2006-11-01 Adrian Aichner <adrian@xemacs.org> * sysdep.c (wcslen): Check for NULL pointer. * sysdep.c (strlwr): Ditto. * nt.c (mswindows_getdcwd): Ditto (actual cause of reported crash). * intl-win32.c (wcscmp): Ditto. * intl-win32.c (wcslen): Ditto. * intl-win32.c (wcsncpy): Ditto. * intl-win32.c (wcscpy): Ditto. * intl-win32.c (wcsdup): Ditto. * fileio.c (Ffile_name_directory): Return Qnil when mswindows_getdcwd returns NULL working directory.
author adrian
date Wed, 01 Nov 2006 20:25:50 +0000
parents 9905c1e522b8
children 6b2ef948e140
comparison
equal deleted inserted replaced
3647:510e0d6cee7e 3648:3e7493e76dc7
1567 #ifndef HAVE_WCSCMP 1567 #ifndef HAVE_WCSCMP
1568 1568
1569 int 1569 int
1570 wcscmp (const wchar_t *s1, const wchar_t *s2) 1570 wcscmp (const wchar_t *s1, const wchar_t *s2)
1571 { 1571 {
1572 if (s1 == NULL || s2 == NULL) return NULL;
1572 while (*s1 != '\0' && *s1 == *s2) 1573 while (*s1 != '\0' && *s1 == *s2)
1573 { 1574 {
1574 s1++; 1575 s1++;
1575 s2++; 1576 s2++;
1576 } 1577 }
1583 #ifndef HAVE_WCSLEN 1584 #ifndef HAVE_WCSLEN
1584 1585
1585 size_t 1586 size_t
1586 wcslen (const wchar_t *str) 1587 wcslen (const wchar_t *str)
1587 { 1588 {
1589 if (str == NULL) return NULL;
1588 const wchar_t *start = str; 1590 const wchar_t *start = str;
1589 1591
1590 while (*str) 1592 while (*str)
1591 str++; 1593 str++;
1592 1594
1596 #endif /* not HAVE_WCSLEN */ 1598 #endif /* not HAVE_WCSLEN */
1597 1599
1598 wchar_t * 1600 wchar_t *
1599 wcsncpy (wchar_t *dst0, const wchar_t *src0, size_t count) 1601 wcsncpy (wchar_t *dst0, const wchar_t *src0, size_t count)
1600 { 1602 {
1603 if (dst0 == NULL || src0 == NULL) return NULL;
1601 wchar_t *dscan; 1604 wchar_t *dscan;
1602 const wchar_t *sscan; 1605 const wchar_t *sscan;
1603 1606
1604 dscan = dst0; 1607 dscan = dst0;
1605 sscan = src0; 1608 sscan = src0;
1616 } 1619 }
1617 1620
1618 wchar_t * 1621 wchar_t *
1619 wcscpy (wchar_t *dst0, const wchar_t *src0) 1622 wcscpy (wchar_t *dst0, const wchar_t *src0)
1620 { 1623 {
1624 if (dst0 == NULL || src0 == NULL) return NULL;
1621 wchar_t *s = dst0; 1625 wchar_t *s = dst0;
1622 1626
1623 while ((*dst0++ = *src0++)) 1627 while ((*dst0++ = *src0++))
1624 ; 1628 ;
1625 1629
1627 } 1631 }
1628 1632
1629 wchar_t * 1633 wchar_t *
1630 wcsdup (const wchar_t *str) 1634 wcsdup (const wchar_t *str)
1631 { 1635 {
1636 if (str == NULL) return NULL;
1632 int len = wcslen (str) + 1; 1637 int len = wcslen (str) + 1;
1633 wchar_t *val = xnew_array (wchar_t, len); 1638 wchar_t *val = xnew_array (wchar_t, len);
1634 1639
1635 if (val == 0) return 0; 1640 if (val == 0) return 0;
1636 return (wchar_t *) memcpy (val, str, len * sizeof (wchar_t)); 1641 return (wchar_t *) memcpy (val, str, len * sizeof (wchar_t));