sprintf_s only works on MSVC. MinGW uses sprintf.
svn path=/trunk/externals/iem/comport/; revision=13132
This commit is contained in:
parent
331644089a
commit
1315bde6fb
1 changed files with 16 additions and 1 deletions
|
|
@ -457,13 +457,20 @@ static HANDLE open_serial(unsigned int com_num, t_comport *x)
|
||||||
post("comport number %d out of range (1-%d)", com_num, COMPORT_MAX);
|
post("comport number %d out of range (1-%d)", com_num, COMPORT_MAX);
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
#ifdef _MSC_VER
|
||||||
sprintf_s(buffer, MAX_PATH, "%s%d", x->serial_device_prefix, com_num);
|
sprintf_s(buffer, MAX_PATH, "%s%d", x->serial_device_prefix, com_num);
|
||||||
|
#else
|
||||||
|
sprintf(buffer, "%s%d", x->serial_device_prefix, com_num);
|
||||||
|
#endif
|
||||||
x->serial_device = gensym(buffer);
|
x->serial_device = gensym(buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
sprintf_s(buffer, MAX_PATH, "\\\\.\\%s", x->serial_device->s_name); /* assume the slashes were not prefixed by user */
|
sprintf_s(buffer, MAX_PATH, "\\\\.\\%s", x->serial_device->s_name); /* assume the slashes were not prefixed by user */
|
||||||
|
#else
|
||||||
|
sprintf(buffer, "\\\\.\\%s", x->serial_device->s_name); /* assume the slashes were not prefixed by user */
|
||||||
|
#endif
|
||||||
x->serial_device = gensym(buffer);
|
x->serial_device = gensym(buffer);
|
||||||
}
|
}
|
||||||
post("Opening %s", &x->serial_device->s_name[4]);/* skip slashes and dot */
|
post("Opening %s", &x->serial_device->s_name[4]);/* skip slashes and dot */
|
||||||
|
|
@ -1567,7 +1574,11 @@ static void comport_enum(t_comport *x)
|
||||||
DWORD dw;
|
DWORD dw;
|
||||||
for(i = 1; i < COMPORT_MAX; i++)
|
for(i = 1; i < COMPORT_MAX; i++)
|
||||||
{
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
sprintf_s(device_name, 10, "%s%d", x->serial_device_prefix, i);
|
sprintf_s(device_name, 10, "%s%d", x->serial_device_prefix, i);
|
||||||
|
#else
|
||||||
|
sprintf(device_name, "%s%d", x->serial_device_prefix, i);
|
||||||
|
#endif
|
||||||
fd = CreateFileA( device_name,
|
fd = CreateFileA( device_name,
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
0,
|
0,
|
||||||
|
|
@ -1631,7 +1642,11 @@ static void comport_ports(t_comport *x)
|
||||||
|
|
||||||
for(i = 1; i < COMPORT_MAX; i++)
|
for(i = 1; i < COMPORT_MAX; i++)
|
||||||
{
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
sprintf_s(device_name, 10, "%s%d", x->serial_device_prefix, i);
|
sprintf_s(device_name, 10, "%s%d", x->serial_device_prefix, i);
|
||||||
|
#else
|
||||||
|
sprintf(device_name, "%s%d", x->serial_device_prefix, i);
|
||||||
|
#endif
|
||||||
fd = CreateFileA( device_name,
|
fd = CreateFileA( device_name,
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
0,
|
0,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue