diff options
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/mf_tempfile.c | 14 | ||||
-rw-r--r-- | mysys/my_getopt.c | 16 | ||||
-rw-r--r-- | mysys/my_init.c | 2 |
3 files changed, 31 insertions, 1 deletions
diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c index c1108f85054..9460f27b104 100644 --- a/mysys/mf_tempfile.c +++ b/mysys/mf_tempfile.c @@ -59,12 +59,26 @@ File create_temp_file(char *to, const char *dir, const char *prefix, myf MyFlags __attribute__((unused))) { File file= -1; +#ifdef __WIN__ + TCHAR path_buf[MAX_PATH-14]; +#endif DBUG_ENTER("create_temp_file"); DBUG_PRINT("enter", ("dir: %s, prefix: %s", dir, prefix)); #if defined (__WIN__) /* + Use GetTempPath to determine path for temporary files. + This is because the documentation for GetTempFileName + has the following to say about this parameter: + "If this parameter is NULL, the function fails." + */ + if (!dir) + { + if(GetTempPath(sizeof(path_buf), path_buf) > 0) + dir = path_buf; + } + /* Use GetTempFileName to generate a unique filename, create the file and release it's handle - uses up to the first three letters from prefix diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 623c48b2e55..71630e1b4c2 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -19,6 +19,7 @@ #include <my_sys.h> #include <mysys_err.h> #include <my_getopt.h> +#include <errno.h> static void default_reporter(enum loglevel level, const char *format, ...); my_error_reporter my_getopt_error_reporter= &default_reporter; @@ -693,7 +694,15 @@ static longlong eval_num_suffix (char *argument, int *error, char *option_name) longlong num; *error= 0; + errno= 0; num= strtoll(argument, &endchar, 10); + if (errno == ERANGE) + { + my_getopt_error_reporter(ERROR_LEVEL, + "Incorrect integer value: '%s'", argument); + *error= 1; + return 0; + } if (*endchar == 'k' || *endchar == 'K') num*= 1024L; else if (*endchar == 'm' || *endchar == 'M') @@ -730,7 +739,14 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err) num= eval_num_suffix(arg, err, (char*) optp->name); if (num > 0 && (ulonglong) num > (ulonglong) optp->max_value && optp->max_value) /* if max value is not set -> no upper limit */ + { + char buf[22]; + my_getopt_error_reporter(WARNING_LEVEL, + "Truncated incorrect %s value: '%s'", + optp->name, llstr(num, buf)); + num= (ulonglong) optp->max_value; + } num= ((num - optp->sub_size) / block_size); num= (longlong) (num * block_size); return max(num, optp->min_value); diff --git a/mysys/my_init.c b/mysys/my_init.c index 32d3f07fd31..8154a5fce51 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -286,7 +286,7 @@ int handle_rtc_failure(int err_type, const char *file, int line, return 0; /* Error is handled */ } -#pragma runtime_checks("", on) +#pragma runtime_checks("", restore) #endif |