mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8295017: Remove Windows specific workaround in JLI_Snprintf
Reviewed-by: dholmes
This commit is contained in:
parent
fdb74ed452
commit
2b4830a395
2 changed files with 2 additions and 34 deletions
|
@ -81,6 +81,8 @@ JLI_GetAppArgIndex();
|
|||
#define JLI_StrCSpn(p1, p2) strcspn((p1), (p2))
|
||||
#define JLI_StrPBrk(p1, p2) strpbrk((p1), (p2))
|
||||
|
||||
#define JLI_Snprintf snprintf
|
||||
|
||||
/* On Windows lseek() is in io.h rather than the location dictated by POSIX. */
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -88,7 +90,6 @@ JLI_GetAppArgIndex();
|
|||
#include <process.h>
|
||||
#define JLI_StrCaseCmp(p1, p2) stricmp((p1), (p2))
|
||||
#define JLI_StrNCaseCmp(p1, p2, p3) strnicmp((p1), (p2), (p3))
|
||||
int JLI_Snprintf(char *buffer, size_t size, const char *format, ...);
|
||||
int JLI_Open(const char* name, int flags);
|
||||
JNIEXPORT void JNICALL
|
||||
JLI_CmdToArgs(char *cmdline);
|
||||
|
@ -98,7 +99,6 @@ JLI_CmdToArgs(char *cmdline);
|
|||
#include <strings.h>
|
||||
#define JLI_StrCaseCmp(p1, p2) strcasecmp((p1), (p2))
|
||||
#define JLI_StrNCaseCmp(p1, p2, p3) strncasecmp((p1), (p2), (p3))
|
||||
#define JLI_Snprintf snprintf
|
||||
#define JLI_Open open
|
||||
#ifdef __linux__
|
||||
#define _LARGFILE64_SOURCE
|
||||
|
|
|
@ -475,38 +475,6 @@ jlong CurrentTimeMicros()
|
|||
return (jlong)(count.QuadPart * 1000 * 1000 / counterFrequency.QuadPart);
|
||||
}
|
||||
|
||||
/*
|
||||
* windows snprintf does not guarantee a null terminator in the buffer,
|
||||
* if the computed size is equal to or greater than the buffer size,
|
||||
* as well as error conditions. This function guarantees a null terminator
|
||||
* under all these conditions. An unreasonable buffer or size will return
|
||||
* an error value. Under all other conditions this function will return the
|
||||
* size of the bytes actually written minus the null terminator, similar
|
||||
* to ansi snprintf api. Thus when calling this function the caller must
|
||||
* ensure storage for the null terminator.
|
||||
*/
|
||||
int
|
||||
JLI_Snprintf(char* buffer, size_t size, const char* format, ...) {
|
||||
int rc;
|
||||
va_list vl;
|
||||
if (size == 0 || buffer == NULL)
|
||||
return -1;
|
||||
buffer[0] = '\0';
|
||||
va_start(vl, format);
|
||||
rc = vsnprintf(buffer, size, format, vl);
|
||||
va_end(vl);
|
||||
/* force a null terminator, if something is amiss */
|
||||
if (rc < 0) {
|
||||
/* apply ansi semantics */
|
||||
buffer[size - 1] = '\0';
|
||||
return (int)size;
|
||||
} else if (rc == size) {
|
||||
/* force a null terminator */
|
||||
buffer[size - 1] = '\0';
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static errno_t convert_to_unicode(const char* path, const wchar_t* prefix, wchar_t** wpath) {
|
||||
int unicode_path_len;
|
||||
size_t prefix_len, wpath_len;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue