Skip to content

Commit 9eca63e

Browse files
committed
Linux: replace str*_s defines for system
1 parent ff0d32c commit 9eca63e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/Common/PlatformLinux.inl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -276,18 +276,18 @@ typedef dirent DirEntryType;
276276
#define lstrcpy strcpy
277277
#define stricmp strcasecmp
278278
#define strupr SDL_strupr
279-
279+
// error code numbers from original MS strcpy_s return value
280280
inline int strcpy_s(char *dest, size_t num, const char *source)
281281
{
282282
if(!num)
283-
return 22;
283+
return EINVAL;
284284
if(!dest)
285-
return 22;
285+
return EINVAL;
286286

287287
if(!source)
288288
{
289289
dest[0] = '\0';
290-
return 22;
290+
return EINVAL;
291291
}
292292

293293
size_t i;
@@ -297,7 +297,7 @@ inline int strcpy_s(char *dest, size_t num, const char *source)
297297
return 0;
298298
}
299299
dest[0] = '\0';
300-
return 34;
300+
return ERANGE;
301301
}
302302

303303
template <std::size_t num>
@@ -314,7 +314,7 @@ inline int strncpy_s(char * dest, size_t dst_size, const char * source, size_t n
314314
}
315315

316316
if (!dest || !source || (0 == dst_size))
317-
return 22;
317+
return EINVAL;
318318

319319
size_t i, end;
320320
if(num < dst_size)
@@ -333,7 +333,7 @@ inline int strncpy_s(char * dest, size_t dst_size, const char * source, size_t n
333333

334334
dest[0] = '\0';
335335

336-
return 22;
336+
return EINVAL;
337337
}
338338

339339
template <std::size_t dst_sz>
@@ -342,12 +342,12 @@ inline int strncpy_s(char (&dest)[dst_sz], const char * source, size_t num) { re
342342
inline int strcat_s(char * dest, size_t num, const char * source)
343343
{
344344
if(!dest || (0 == num))
345-
return 22;
345+
return EINVAL;
346346

347347
if(!source)
348348
{
349349
dest[0] = '\0';
350-
return 22;
350+
return EINVAL;
351351
}
352352

353353
size_t i, j;
@@ -364,18 +364,18 @@ inline int strcat_s(char * dest, size_t num, const char * source)
364364
}
365365

366366
dest[0] = '\0';
367-
return 34;
367+
return ERANGE;
368368
}
369369

370370
inline int strncat_s(char * dest, size_t num, const char * source, size_t count)
371371
{
372372
if (!dest || (0 == num))
373-
return 22;
373+
return EINVAL;
374374

375375
if (!source)
376376
{
377377
dest[0] = '\0';
378-
return 22;
378+
return EINVAL;
379379
}
380380

381381
size_t i, j;
@@ -395,7 +395,7 @@ inline int strncat_s(char * dest, size_t num, const char * source, size_t count)
395395
}
396396

397397
dest[0] = '\0';
398-
return 34;
398+
return ERANGE;
399399
}
400400

401401
#define _vsnprintf vsnprintf

0 commit comments

Comments
 (0)