mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
f7cf76fc80
into mysql.com:/home/my/mysql-5.1 BitKeeper/deleted/.del-innodb_notembedded.test: Delete: mysql-test/t/innodb_notembedded.test BitKeeper/deleted/.del-sp_notembedded.test: Delete: mysql-test/t/sp_notembedded.test BitKeeper/deleted/.del-subselect_notembedded.test: Delete: mysql-test/t/subselect_notembedded.test BitKeeper/deleted/.del-ctype_cp932_notembedded.result: Delete: mysql-test/r/ctype_cp932_notembedded.result BitKeeper/deleted/.del-innodb_notembedded.result: Delete: mysql-test/r/innodb_notembedded.result BitKeeper/deleted/.del-sp_notembedded.result: Delete: mysql-test/r/sp_notembedded.result BitKeeper/deleted/.del-subselect_notembedded.result: Delete: mysql-test/r/subselect_notembedded.result configure.in: Auto merged include/mysql.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/emb_qcache.cc: Auto merged libmysqld/embedded_priv.h: Auto merged libmysqld/libmysqld.c: Auto merged mysql-test/extra/binlog_tests/blackhole.test: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/innodb.result: Auto merged mysql-test/r/mysqltest.result: Auto merged mysql-test/r/query_cache.result: Auto merged mysql-test/r/query_cache_notembedded.result: Auto merged mysql-test/r/sp-error.result: Auto merged mysql-test/r/sp.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/view.result: Auto merged mysql-test/r/view_grant.result: Auto merged mysql-test/t/backup.test: Auto merged mysql-test/t/compress.test: Auto merged mysql-test/t/delayed.test: Auto merged mysql-test/t/handler.test: Auto merged mysql-test/t/mysql.test: Auto merged mysql-test/t/mysql_client_test.test: Auto merged mysql-test/t/mysqltest.test: Auto merged mysql-test/t/query_cache.test: Auto merged mysql-test/t/query_cache_notembedded.test: Auto merged mysql-test/t/read_only.test: Auto merged mysql-test/t/skip_grants.test: Auto merged mysql-test/t/sp-destruct.test: Auto merged mysql-test/t/sp-error.test: Auto merged mysql-test/t/sp-threads.test: Auto merged mysql-test/t/sp.test: Auto merged mysql-test/t/temp_table.test: Auto merged mysql-test/t/view_grant.test: Auto merged mysql-test/t/wait_timeout.test: Auto merged mysys/mf_dirname.c: Auto merged sql/field.cc: Auto merged sql/handler.h: Auto merged sql/item.h: Auto merged sql/log_event.h: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged sql/protocol.cc: Auto merged sql/protocol.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_cursor.cc: Auto merged sql/sql_db.cc: Auto merged sql-common/client.c: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.h: Auto merged sql/table.h: Auto merged sql/tztime.cc: Auto merged sql/tztime.h: Auto merged storage/ndb/include/ndbapi/NdbDictionary.hpp: Auto merged tests/mysql_client_test.c: Auto merged libmysqld/lib_sql.cc: Manual merge mysql-test/extra/binlog_tests/binlog.test: Manual merge mysql-test/extra/binlog_tests/ctype_cp932.test: No changes mysql-test/r/binlog_stm_binlog.result: Manual merge mysql-test/r/binlog_stm_ctype_cp932.result: No changes mysql-test/t/innodb.test: Manual merge mysql-test/t/view.test: Manual merge mysys/my_bitmap.c: Manual merge scripts/mysql_fix_privilege_tables.sql: Manual merge sql/item.cc: Manual merge sql/sql_cache.h: Manual merge sql/sql_class.h: Manual merge sql/sql_update.cc: Manual merge
154 lines
4 KiB
C
154 lines
4 KiB
C
/* Copyright (C) 2000 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#include "mysys_priv.h"
|
|
#include <m_string.h>
|
|
|
|
/* Functions definied in this file */
|
|
|
|
uint dirname_length(const char *name)
|
|
{
|
|
register my_string pos,gpos;
|
|
#ifdef BASKSLASH_MBTAIL
|
|
CHARSET_INFO *fs= fs_character_set();
|
|
#endif
|
|
#ifdef FN_DEVCHAR
|
|
if ((pos=(char*)strrchr(name,FN_DEVCHAR)) == 0)
|
|
#endif
|
|
pos=(char*) name-1;
|
|
|
|
gpos= pos++;
|
|
for ( ; *pos ; pos++) /* Find last FN_LIBCHAR */
|
|
{
|
|
#ifdef BASKSLASH_MBTAIL
|
|
uint l;
|
|
if (use_mb(fs) && (l= my_ismbchar(fs, pos, pos + 3)))
|
|
{
|
|
pos+= l - 1;
|
|
continue;
|
|
}
|
|
#endif
|
|
if (*pos == FN_LIBCHAR || *pos == '/'
|
|
#ifdef FN_C_AFTER_DIR
|
|
|| *pos == FN_C_AFTER_DIR || *pos == FN_C_AFTER_DIR_2
|
|
#endif
|
|
)
|
|
gpos=pos;
|
|
}
|
|
return ((uint) (uint) (gpos+1-(char*) name));
|
|
}
|
|
|
|
|
|
/* Gives directory part of filename. Directory ends with '/' */
|
|
/* Returns length of directory part */
|
|
|
|
uint dirname_part(my_string to, const char *name)
|
|
{
|
|
uint length;
|
|
DBUG_ENTER("dirname_part");
|
|
DBUG_PRINT("enter",("'%s'",name));
|
|
|
|
length=dirname_length(name);
|
|
convert_dirname(to, name, name+length);
|
|
DBUG_RETURN(length);
|
|
} /* dirname */
|
|
|
|
|
|
/*
|
|
Convert directory name to use under this system
|
|
|
|
SYNPOSIS
|
|
convert_dirname()
|
|
to Store result here
|
|
from Original filename. May be == to
|
|
from_end Pointer at end of filename (normally end \0)
|
|
|
|
IMPLEMENTATION
|
|
If MSDOS converts '/' to '\'
|
|
If VMS converts '<' to '[' and '>' to ']'
|
|
Adds a FN_LIBCHAR to end if the result string if there isn't one
|
|
and the last isn't dev_char.
|
|
Copies data from 'from' until ASCII(0) for until from == from_end
|
|
If you want to use the whole 'from' string, just send NullS as the
|
|
last argument.
|
|
|
|
If the result string is larger than FN_REFLEN -1, then it's cut.
|
|
|
|
RETURN
|
|
Returns pointer to end \0 in to
|
|
*/
|
|
|
|
#ifndef FN_DEVCHAR
|
|
#define FN_DEVCHAR '\0' /* For easier code */
|
|
#endif
|
|
|
|
char *convert_dirname(char *to, const char *from, const char *from_end)
|
|
{
|
|
char *to_org=to;
|
|
#ifdef BACKSLASH_MBTAIL
|
|
CHARSET_INFO *fs= fs_character_set();
|
|
#endif
|
|
DBUG_ENTER("convert_dirname");
|
|
|
|
/* We use -2 here, becasue we need place for the last FN_LIBCHAR */
|
|
if (!from_end || (from_end - from) > FN_REFLEN-2)
|
|
from_end=from+FN_REFLEN -2;
|
|
|
|
#if FN_LIBCHAR != '/' || defined(FN_C_BEFORE_DIR_2)
|
|
{
|
|
for (; from != from_end && *from ; from++)
|
|
{
|
|
if (*from == '/')
|
|
*to++= FN_LIBCHAR;
|
|
#ifdef FN_C_BEFORE_DIR_2
|
|
else if (*from == FN_C_BEFORE_DIR_2)
|
|
*to++= FN_C_BEFORE_DIR;
|
|
else if (*from == FN_C_AFTER_DIR_2)
|
|
*to++= FN_C_AFTER_DIR;
|
|
#endif
|
|
else
|
|
{
|
|
#ifdef BACKSLASH_MBTAIL
|
|
uint l;
|
|
if (use_mb(fs) && (l= my_ismbchar(fs, from, from + 3)))
|
|
{
|
|
memmove(to, from, l);
|
|
to+= l;
|
|
from+= l - 1;
|
|
to_org= to; /* Don't look inside mbchar */
|
|
}
|
|
else
|
|
#endif
|
|
{
|
|
*to++= *from;
|
|
}
|
|
}
|
|
}
|
|
*to=0;
|
|
}
|
|
#else
|
|
/* This is ok even if to == from, becasue we need to cut the string */
|
|
to= strmake(to, from, (uint) (from_end-from));
|
|
#endif
|
|
|
|
/* Add FN_LIBCHAR to the end of directory path */
|
|
if (to != to_org && (to[-1] != FN_LIBCHAR && to[-1] != FN_DEVCHAR))
|
|
{
|
|
*to++=FN_LIBCHAR;
|
|
*to=0;
|
|
}
|
|
DBUG_RETURN(to); /* Pointer to end of dir */
|
|
} /* convert_dirname */
|