diff --git a/ChangeLog b/ChangeLog index f66ac253c..2de6a47c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-12-14 Vladimir Serbinenko + + Do not use TCHAR string functions as they are not available on cygwin. + 2013-12-14 Vladimir Serbinenko Workaround windows bug when querying EFI system partition parameters. diff --git a/grub-core/osdep/windows/getroot.c b/grub-core/osdep/windows/getroot.c index c81372d22..661d95461 100644 --- a/grub-core/osdep/windows/getroot.c +++ b/grub-core/osdep/windows/getroot.c @@ -49,12 +49,6 @@ #include #include -#if SIZEOF_TCHAR == 1 -#define tcsnicmp strncasecmp -#elif SIZEOF_TCHAR == 2 -#define tcsnicmp wcsnicmp -#endif - TCHAR * grub_get_mount_point (const TCHAR *path) { @@ -191,6 +185,31 @@ grub_guess_root_devices (const char *dir) return os_dev; } +static int tcharncasecmp (LPCTSTR a, const char *b, size_t sz) +{ + for (; sz; sz--, a++, b++) + { + char ac, bc; + if(*a >= 0x80) + return +1; + if (*b & 0x80) + return -1; + if (*a == '\0' && *b == '\0') + return 0; + ac = *a; + bc = *b; + if (ac >= 'A' && ac <= 'Z') + ac -= 'A' - 'a'; + if (bc >= 'A' && bc <= 'Z') + bc -= 'A' - 'a'; + if (ac > bc) + return +1; + if (ac < bc) + return -1; + } + return 0; +} + char * grub_util_part_to_disk (const char *os_dev, struct stat *st __attribute__ ((unused)), @@ -206,8 +225,8 @@ grub_util_part_to_disk (const char *os_dev, ((name[1] == '/') || (name[1] == '\\')) && ((name[2] == '.') || (name[2] == '?')) && ((name[3] == '/') || (name[3] == '\\')) - && (tcsnicmp (name + 4, TEXT("PhysicalDrive"), sizeof ("PhysicalDrive") - 1) == 0 - || tcsnicmp (name + 4, TEXT("Harddisk"), sizeof ("Harddisk") - 1) == 0 + && (tcharncasecmp (name + 4, "PhysicalDrive", sizeof ("PhysicalDrive") - 1) == 0 + || tcharncasecmp (name + 4, "Harddisk", sizeof ("Harddisk") - 1) == 0 || ((name[4] == 'A' || name[4] == 'a' || name[4] == 'B' || name[4] == 'b') && name[5] == ':' && name[6] == '\0'))) { @@ -277,8 +296,8 @@ grub_util_find_partition_start_os (const char *os_dev) ((name[1] == '/') || (name[1] == '\\')) && ((name[2] == '.') || (name[2] == '?')) && ((name[3] == '/') || (name[3] == '\\')) - && (tcsnicmp (name + 4, TEXT("PhysicalDrive"), sizeof ("PhysicalDrive") - 1) == 0 - || tcsnicmp (name + 4, TEXT("Harddisk"), sizeof ("Harddisk") - 1) == 0 + && (tcharncasecmp (name + 4, "PhysicalDrive", sizeof ("PhysicalDrive") - 1) == 0 + || tcharncasecmp (name + 4, "Harddisk", sizeof ("Harddisk") - 1) == 0 || ((name[4] == 'A' || name[4] == 'a' || name[4] == 'B' || name[4] == 'b') && name[5] == ':' && name[6] == '\0'))) { diff --git a/grub-core/osdep/windows/relpath.c b/grub-core/osdep/windows/relpath.c index b9e2cac45..cb0861744 100644 --- a/grub-core/osdep/windows/relpath.c +++ b/grub-core/osdep/windows/relpath.c @@ -33,11 +33,14 @@ #include #include -#if SIZEOF_TCHAR == 1 -#define tclen strlen -#elif SIZEOF_TCHAR == 2 -#define tclen wcslen -#endif +static size_t +tclen (const TCHAR *s) +{ + const TCHAR *s0 = s; + while (*s) + s++; + return s - s0; +} char * grub_make_system_path_relative_to_its_root (const char *path)