diff options
author | unknown <monty@mysql.com> | 2005-07-03 14:17:52 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-07-03 14:17:52 +0300 |
commit | 1e0d23f2afb7882bf54d93df475216737d652f34 (patch) | |
tree | bf06496ea5d097316e5972a5cf4c4d5f674fb90b /mysys | |
parent | 91d786af84abf43a0c5961da813616998b9ce1f7 (diff) | |
parent | a69ba9cd8fffc14d1f6d2d48e12758daab11262b (diff) | |
download | mariadb-git-1e0d23f2afb7882bf54d93df475216737d652f34.tar.gz |
Merge with 4.1
Makefile.am:
Auto merged
myisam/mi_create.c:
Auto merged
myisam/mi_open.c:
Auto merged
mysql-test/r/ctype_utf8.result:
Auto merged
mysys/thr_alarm.c:
Auto merged
VC++Files/sql/mysqld.dsp:
Keep old
client/mysqldump.c:
Manual merge
client/mysqltest.c:
Automatic merge
configure.in:
Manual merge
mysql-test/r/ctype_ucs.result:
Auto merge
mysql-test/r/func_str.result:
Auto merge
mysql-test/r/group_by.result:
Auto merge
mysql-test/r/insert_select.result:
Auto merge
mysql-test/r/insert_update.result:
Auto merge
mysql-test/r/lowercase_table2.result:
Auto merge
mysql-test/r/select.result:
Manual merge
mysql-test/r/variables.result:
Auto merge
mysql-test/t/ctype_ucs.test:
Auto merge
mysql-test/t/func_str.test:
Auto merge
mysql-test/t/group_by.test:
Auto merge
mysql-test/t/insert_select.test:
Auto merge
mysql-test/t/insert_update.test:
Auto merge
mysql-test/t/ndb_alter_table.test:
Auto merge
mysql-test/t/select.test:
Auto merge
mysql-test/t/variables.test:
Auto merge
mysys/my_access.c:
Auto merge
scripts/make_win_src_distribution.sh:
Auto merge
sql/field.cc:
Manual merge
sql/ha_ndbcluster.cc:
Auto merge
sql/handler.cc:
Auto merge
sql/item.cc:
Auto merge
sql/item.h:
Manual merge
sql/item_cmpfunc.h:
Auto merge
sql/item_strfunc.cc:
Auto merge
sql/item_strfunc.h:
Auto merge
sql/mysql_priv.h:
manual merge
sql/mysqld.cc:
manual merge
sql/opt_range.cc:
manual merge
sql/set_var.cc:
Auto merge
sql/sql_base.cc:
manual merge
Restore processing of ON DUPLICATE KEY UPDATE
sql/sql_insert.cc:
manual merge
Restore processing of ON DUPLICATE KEY UPDATE
Simplify mysql_prepare_insert by using local variable for select_lex and save old values just before they are changed
sql/sql_parse.cc:
Restore processing of ON DUPLICATE KEY UPDATE
sql/sql_prepare.cc:
New ON DUPLICATE KEY UPDATE handling
sql/sql_select.cc:
manual merge
sql/sql_table.cc:
auto merge
sql/sql_yacc.yy:
auto merge
strings/ctype-ucs2.c:
auto merge
strings/ctype-utf8.c:
auto merge
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_access.c | 9 | ||||
-rw-r--r-- | mysys/my_fopen.c | 84 |
2 files changed, 53 insertions, 40 deletions
diff --git a/mysys/my_access.c b/mysys/my_access.c index c01031827c0..256749ed447 100644 --- a/mysys/my_access.c +++ b/mysys/my_access.c @@ -98,17 +98,16 @@ int check_if_legal_filename(const char *path) for (reserved_name= reserved_names; *reserved_name; reserved_name++) { + const char *reserved= *reserved_name; /* never empty */ const char *name= path; - const char *current_reserved_name= *reserved_name; - while (name != end && *current_reserved_name) + do { - if (*current_reserved_name != my_toupper(&my_charset_latin1, *name)) + if (*reserved != my_toupper(&my_charset_latin1, *name)) break; - current_reserved_name++; if (++name == end) DBUG_RETURN(1); /* Found wrong path */ - } + } while (*++reserved); } DBUG_RETURN(0); } diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c index 002e5ca0f06..f07beec9f39 100644 --- a/mysys/my_fopen.c +++ b/mysys/my_fopen.c @@ -19,27 +19,36 @@ #include <errno.h> #include "mysys_err.h" -static void make_ftype(my_string to,int flag); +static void make_ftype(my_string to,int flag); - /* Open a file as stream */ +/* + Open a file as stream -FILE *my_fopen(const char *FileName, int Flags, myf MyFlags) - /* Path-name of file */ - /* Read | write .. */ - /* Special flags */ + SYNOPSIS + my_fopen() + FileName Path-name of file + Flags Read | write | append | trunc (like for open()) + MyFlags Flags for handling errors + + RETURN + 0 Error + # File handler +*/ + +FILE *my_fopen(const char *filename, int flags, myf MyFlags) { FILE *fd; char type[5]; DBUG_ENTER("my_fopen"); - DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d", - FileName, Flags, MyFlags)); + DBUG_PRINT("my",("Name: '%s' flags: %d MyFlags: %d", + filename, flags, MyFlags)); /* if we are not creating, then we need to use my_access to make sure the file exists since Windows doesn't handle files like "com1.sym" very well */ #ifdef __WIN__ - if (check_if_legal_filename(FileName)) + if (check_if_legal_filename(filename)) { errno= EACCES; fd= 0; @@ -47,8 +56,8 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags) else #endif { - make_ftype(type,Flags); - fd = fopen(FileName, type); + make_ftype(type,flags); + fd = fopen(filename, type); } if (fd != 0) @@ -65,7 +74,7 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags) } pthread_mutex_lock(&THR_LOCK_open); if ((my_file_info[fileno(fd)].name = (char*) - my_strdup(FileName,MyFlags))) + my_strdup(filename,MyFlags))) { my_stream_opened++; my_file_info[fileno(fd)].type = STREAM_BY_FOPEN; @@ -81,9 +90,9 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags) my_errno=errno; DBUG_PRINT("error",("Got error %d on open",my_errno)); if (MyFlags & (MY_FFNF | MY_FAE | MY_WME)) - my_error((Flags & O_RDONLY) || (Flags == O_RDONLY ) ? EE_FILENOTFOUND : + my_error((flags & O_RDONLY) || (flags == O_RDONLY ) ? EE_FILENOTFOUND : EE_CANTCREATEFILE, - MYF(ME_BELL+ME_WAITTANG), FileName,my_errno); + MYF(ME_BELL+ME_WAITTANG), filename, my_errno); DBUG_RETURN((FILE*) 0); } /* my_fopen */ @@ -158,33 +167,39 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags) DBUG_RETURN(fd); } /* my_fdopen */ + /* - make_ftype - Make a filehandler-open-typestring from ordinary inputflags + Make a fopen() typestring from a open() type bitmap + + SYNOPSIS + make_ftype() + to String for fopen() is stored here + flag Flag used by open() - Note: This routine attempts to find the best possible match - between a numeric option and a string option that could be - fed to fopen. There is not a 1 to 1 mapping between the two. + IMPLEMENTATION + This routine attempts to find the best possible match + between a numeric option and a string option that could be + fed to fopen. There is not a 1 to 1 mapping between the two. - r == O_RDONLY - w == O_WRONLY|O_TRUNC|O_CREAT - a == O_WRONLY|O_APPEND|O_CREAT - r+ == O_RDWR - w+ == O_RDWR|O_TRUNC|O_CREAT - a+ == O_RDWR|O_APPEND|O_CREAT + NOTE + On Unix, O_RDONLY is usually 0 + + MAPPING + r == O_RDONLY + w == O_WRONLY|O_TRUNC|O_CREAT + a == O_WRONLY|O_APPEND|O_CREAT + r+ == O_RDWR + w+ == O_RDWR|O_TRUNC|O_CREAT + a+ == O_RDWR|O_APPEND|O_CREAT */ + static void make_ftype(register my_string to, register int flag) { -#if FILE_BINARY - /* If we have binary-files */ - reg3 int org_flag=flag; -#endif - flag&= ~FILE_BINARY; /* remove binary bit */ - /* check some possible invalid combinations */ - DBUG_ASSERT(flag & (O_TRUNC|O_APPEND) != O_TRUNC|O_APPEND); + DBUG_ASSERT((flag & (O_TRUNC | O_APPEND)) != (O_TRUNC | O_APPEND)); + DBUG_ASSERT((flag & (O_WRONLY | O_RDWR)) != (O_WRONLY | O_RDWR)); - if (flag & (O_RDONLY|O_WRONLY) == O_WRONLY) + if ((flag & (O_RDONLY|O_WRONLY)) == O_WRONLY) *to++= (flag & O_APPEND) ? 'a' : 'w'; else if (flag & O_RDWR) { @@ -201,9 +216,8 @@ static void make_ftype(register my_string to, register int flag) *to++= 'r'; #if FILE_BINARY /* If we have binary-files */ - if (org_flag & FILE_BINARY) + if (flag & FILE_BINARY) *to++='b'; #endif *to='\0'; } /* make_ftype */ - |