summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorigor@rurik.mysql.com <>2003-07-16 13:35:34 -0700
committerigor@rurik.mysql.com <>2003-07-16 13:35:34 -0700
commit26ecd865391c2b7b5ccd65bc0e66264ce7c5bac4 (patch)
tree7cda3f32b4df3b70ba418601d183b2f3265e1fff /mysys
parent42e1296e9d83b8299fe6c8391ece71e88c7019c1 (diff)
parenta35fff5bc38732d48472a64a4504bcead010a379 (diff)
downloadmariadb-git-26ecd865391c2b7b5ccd65bc0e66264ce7c5bac4.tar.gz
Conflict resolution
Diffstat (limited to 'mysys')
-rw-r--r--mysys/mf_loadpath.c11
-rw-r--r--mysys/my_getopt.c61
-rw-r--r--mysys/my_symlink.c12
3 files changed, 47 insertions, 37 deletions
diff --git a/mysys/mf_loadpath.c b/mysys/mf_loadpath.c
index 291ad62e297..a46b43c34d4 100644
--- a/mysys/mf_loadpath.c
+++ b/mysys/mf_loadpath.c
@@ -28,6 +28,7 @@ my_string my_load_path(my_string to, const char *path,
const char *own_path_prefix)
{
char buff[FN_REFLEN];
+ int is_cur;
DBUG_ENTER("my_load_path");
DBUG_PRINT("enter",("path: %s prefix: %s",path,
own_path_prefix ? own_path_prefix : ""));
@@ -35,14 +36,16 @@ my_string my_load_path(my_string to, const char *path,
if ((path[0] == FN_HOMELIB && path[1] == FN_LIBCHAR) ||
test_if_hard_path(path))
VOID(strmov(buff,path));
- else if ((path[0] == FN_CURLIB && path[1] == FN_LIBCHAR) ||
+ else if ((is_cur=(path[0] == FN_CURLIB && path[1] == FN_LIBCHAR)) ||
(is_prefix((gptr) path,FN_PARENTDIR)) ||
! own_path_prefix)
{
- if (! my_getwd(buff,(uint) (FN_REFLEN-strlen(path)),MYF(0)))
- VOID(strcat(buff,path));
+ if (is_cur)
+ is_cur=2; /* Remove current dir */
+ if (! my_getwd(buff,(uint) (FN_REFLEN-strlen(path)+is_cur),MYF(0)))
+ VOID(strcat(buff,path+is_cur));
else
- VOID(strmov(buff,path));
+ VOID(strmov(buff,path)); /* Return org file name */
}
else
VOID(strxmov(buff,own_path_prefix,path,NullS));
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 83ba8b98843..d539489cf1e 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -32,7 +32,7 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err);
static ulonglong getopt_ull(char *arg, const struct my_option *optp,
int *err);
static void init_variables(const struct my_option *options);
-static int setval(const struct my_option *opts, char *argument,
+static int setval(const struct my_option *opts, gptr *value, char *argument,
my_bool set_maximum_value);
static char *check_struct_option(char *cur_arg, char *key_name);
@@ -68,9 +68,9 @@ my_bool my_getopt_print_errors= 1;
one. Call function 'get_one_option()' once for each option.
*/
-static gptr* (*getopt_get_addr)(char *, uint, const struct my_option *);
+static gptr* (*getopt_get_addr)(const char *, uint, const struct my_option *);
-void my_getopt_register_get_addr(gptr* (*func_addr)(char *, uint,
+void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint,
const struct my_option *))
{
getopt_get_addr= func_addr;
@@ -395,7 +395,8 @@ int handle_options(int *argc, char ***argv,
/* the other loop will break, because *optend + 1 == 0 */
}
}
- if ((error= setval(optp, argument, set_maximum_value)))
+ if ((error= setval(optp, optp->value, argument,
+ set_maximum_value)))
{
fprintf(stderr,
"%s: Error while setting value '%s' to '%s'\n",
@@ -417,7 +418,7 @@ int handle_options(int *argc, char ***argv,
(*argc)--; /* option handled (short), decrease argument count */
continue;
}
- if ((error= setval(optp, argument, set_maximum_value)))
+ if ((error= setval(optp, value, argument, set_maximum_value)))
{
fprintf(stderr,
"%s: Error while setting value '%s' to '%s'\n",
@@ -473,13 +474,13 @@ static char *check_struct_option(char *cur_arg, char *key_name)
if (end - ptr > 1)
{
uint len= ptr - cur_arg;
- strnmov(key_name, cur_arg, len);
- key_name[len]= '\0';
+ set_if_smaller(len, FN_REFLEN-1);
+ strmake(key_name, cur_arg, len);
return ++ptr;
}
else
{
- key_name= 0;
+ key_name[0]= 0;
return cur_arg;
}
}
@@ -491,15 +492,15 @@ static char *check_struct_option(char *cur_arg, char *key_name)
Will set the option value to given value
*/
-static int setval(const struct my_option *opts, char *argument,
+static int setval(const struct my_option *opts, gptr *value, char *argument,
my_bool set_maximum_value)
{
int err= 0;
- if (opts->value && argument)
+ if (value && argument)
{
gptr *result_pos= ((set_maximum_value) ?
- opts->u_max_value : opts->value);
+ opts->u_max_value : value);
if (!result_pos)
return EXIT_NO_PTR_TO_VARIABLE;
@@ -692,43 +693,45 @@ static void init_variables(const struct my_option *options)
{
for (; options->name; options++)
{
- if (options->value)
+ gptr *value= (options->var_type & GET_ASK_ADDR ?
+ (*getopt_get_addr)("", 0, options) : options->value);
+ if (value)
{
switch ((options->var_type & GET_TYPE_MASK)) {
case GET_BOOL:
if (options->u_max_value)
*((my_bool*) options->u_max_value)= (my_bool) options->max_value;
- *((my_bool*) options->value)= (my_bool) options->def_value;
+ *((my_bool*) value)= (my_bool) options->def_value;
break;
case GET_INT:
if (options->u_max_value)
*((int*) options->u_max_value)= (int) options->max_value;
- *((int*) options->value)= (int) options->def_value;
+ *((int*) value)= (int) options->def_value;
break;
case GET_UINT:
if (options->u_max_value)
*((uint*) options->u_max_value)= (uint) options->max_value;
- *((uint*) options->value)= (uint) options->def_value;
+ *((uint*) value)= (uint) options->def_value;
break;
case GET_LONG:
if (options->u_max_value)
*((long*) options->u_max_value)= (long) options->max_value;
- *((long*) options->value)= (long) options->def_value;
+ *((long*) value)= (long) options->def_value;
break;
case GET_ULONG:
if (options->u_max_value)
*((ulong*) options->u_max_value)= (ulong) options->max_value;
- *((ulong*) options->value)= (ulong) options->def_value;
+ *((ulong*) value)= (ulong) options->def_value;
break;
case GET_LL:
if (options->u_max_value)
*((longlong*) options->u_max_value)= (longlong) options->max_value;
- *((longlong*) options->value)= (longlong) options->def_value;
+ *((longlong*) value)= (longlong) options->def_value;
break;
case GET_ULL:
if (options->u_max_value)
*((ulonglong*) options->u_max_value)= (ulonglong) options->max_value;
- *((ulonglong*) options->value)= (ulonglong) options->def_value;
+ *((ulonglong*) value)= (ulonglong) options->def_value;
break;
default: /* dummy default to avoid compiler warnings */
break;
@@ -831,7 +834,9 @@ void my_print_variables(const struct my_option *options)
printf("--------------------------------- -----------------------------\n");
for (optp= options; optp->id; optp++)
{
- if (optp->value)
+ gptr *value= (optp->var_type & GET_ASK_ADDR ?
+ (*getopt_get_addr)("", 0, optp) : optp->value);
+ if (value)
{
printf("%s", optp->name);
length= strlen(optp->name);
@@ -840,29 +845,29 @@ void my_print_variables(const struct my_option *options)
switch ((optp->var_type & GET_TYPE_MASK)) {
case GET_STR:
case GET_STR_ALLOC: /* fall through */
- printf("%s\n", *((char**) optp->value) ? *((char**) optp->value) :
+ printf("%s\n", *((char**) value) ? *((char**) value) :
"(No default value)");
break;
case GET_BOOL:
- printf("%s\n", *((my_bool*) optp->value) ? "TRUE" : "FALSE");
+ printf("%s\n", *((my_bool*) value) ? "TRUE" : "FALSE");
break;
case GET_INT:
- printf("%d\n", *((int*) optp->value));
+ printf("%d\n", *((int*) value));
break;
case GET_UINT:
- printf("%d\n", *((uint*) optp->value));
+ printf("%d\n", *((uint*) value));
break;
case GET_LONG:
- printf("%lu\n", *((long*) optp->value));
+ printf("%lu\n", *((long*) value));
break;
case GET_ULONG:
- printf("%lu\n", *((ulong*) optp->value));
+ printf("%lu\n", *((ulong*) value));
break;
case GET_LL:
- printf("%s\n", llstr(*((longlong*) optp->value), buff));
+ printf("%s\n", llstr(*((longlong*) value), buff));
break;
case GET_ULL:
- longlong2str(*((ulonglong*) optp->value), buff, 10);
+ longlong2str(*((ulonglong*) value), buff, 10);
printf("%s\n", buff);
break;
default: /* dummy default to avoid compiler warnings */
diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c
index abef0096e28..b9468d42cfc 100644
--- a/mysys/my_symlink.c
+++ b/mysys/my_symlink.c
@@ -123,20 +123,22 @@ int my_realpath(char *to, const char *filename,
}
else
{
- /* Realpath didn't work; Use original name */
+ /*
+ Realpath didn't work; Use my_load_path() which is a poor substitute
+ original name but will at least be able to resolve paths that starts
+ with '.'.
+ */
DBUG_PRINT("error",("realpath failed with errno: %d", errno));
my_errno=errno;
if (MyFlags & MY_WME)
my_error(EE_REALPATH, MYF(0), filename, my_errno);
- if (to != filename)
- strmov(to,filename);
+ my_load_path(to, filename, NullS);
result= -1;
}
}
DBUG_RETURN(result);
#else
- if (to != filename)
- strmov(to,filename);
+ my_load_path(to, filename, NullS);
return 0;
#endif
}