summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/charset.c61
-rw-r--r--mysys/default.c3
-rw-r--r--mysys/my_bitmap.c6
-rw-r--r--mysys/my_chsize.c2
-rw-r--r--mysys/my_compress.c2
-rw-r--r--mysys/my_getopt.c4
-rw-r--r--mysys/my_handler.c8
-rw-r--r--mysys/my_init.c10
-rw-r--r--mysys/my_lock.c10
-rw-r--r--mysys/my_netware.c2
-rw-r--r--mysys/my_pthread.c22
-rw-r--r--mysys/sha1.c2
12 files changed, 104 insertions, 28 deletions
diff --git a/mysys/charset.c b/mysys/charset.c
index e58c851cf7c..d801fcdbd76 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -466,7 +466,8 @@ static my_bool init_available_charsets(myf myflags)
if (*cs)
{
set_max_sort_char(*cs);
- init_state_maps(*cs);
+ if (cs[0]->ctype)
+ init_state_maps(*cs);
}
}
@@ -622,3 +623,61 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name,
DBUG_RETURN(cs);
}
+
+
+ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
+ const char *from, ulong length)
+{
+ const char *to_start= to;
+ const char *end;
+#ifdef USE_MB
+ my_bool use_mb_flag= use_mb(charset_info);
+#endif
+ for (end= from + length; from != end; from++)
+ {
+#ifdef USE_MB
+ int l;
+ if (use_mb_flag && (l= my_ismbchar(charset_info, from, end)))
+ {
+ while (l--)
+ *to++= *from++;
+ from--;
+ continue;
+ }
+#endif
+ switch (*from) {
+ case 0: /* Must be escaped for 'mysql' */
+ *to++= '\\';
+ *to++= '0';
+ break;
+ case '\n': /* Must be escaped for logs */
+ *to++= '\\';
+ *to++= 'n';
+ break;
+ case '\r':
+ *to++= '\\';
+ *to++= 'r';
+ break;
+ case '\\':
+ *to++= '\\';
+ *to++= '\\';
+ break;
+ case '\'':
+ *to++= '\\';
+ *to++= '\'';
+ break;
+ case '"': /* Better safe than sorry */
+ *to++= '\\';
+ *to++= '"';
+ break;
+ case '\032': /* This gives problems on Win32 */
+ *to++= '\\';
+ *to++= 'Z';
+ break;
+ default:
+ *to++= *from;
+ }
+ }
+ *to= 0;
+ return (ulong) (to - to_start);
+}
diff --git a/mysys/default.c b/mysys/default.c
index af67520322f..056f686e16f 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -479,6 +479,7 @@ static char *remove_end_comment(char *ptr)
return ptr;
}
+#include <help_start.h>
void print_defaults(const char *conf_file, const char **groups)
{
@@ -531,3 +532,5 @@ void print_defaults(const char *conf_file, const char **groups)
--defaults-file=# Only read default options from the given file #\n\
--defaults-extra-file=# Read this file after the global files are read");
}
+
+#include <help_end.h>
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index da16457c299..0f8984e6b3d 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -104,7 +104,7 @@ void bitmap_set_bit(MY_BITMAP *map, uint bitmap_bit)
{
DBUG_ASSERT(map->bitmap && bitmap_bit < map->bitmap_size*8);
bitmap_lock(map);
- map->bitmap[bitmap_bit / 8] |= (1 << (bitmap_bit & 7));
+ bitmap_fast_set_bit(map, bitmap_bit);
bitmap_unlock(map);
}
@@ -144,7 +144,7 @@ void bitmap_clear_bit(MY_BITMAP *map, uint bitmap_bit)
{
DBUG_ASSERT(map->bitmap && bitmap_bit < map->bitmap_size*8);
bitmap_lock(map);
- map->bitmap[bitmap_bit / 8] &= ~ (1 << (bitmap_bit & 7));
+ bitmap_fast_clear_bit(map, bitmap_bit);
bitmap_unlock(map);
}
@@ -220,7 +220,7 @@ my_bool bitmap_is_set_all(const MY_BITMAP *map)
my_bool bitmap_is_set(const MY_BITMAP *map, uint bitmap_bit)
{
DBUG_ASSERT(map->bitmap && bitmap_bit < map->bitmap_size*8);
- return map->bitmap[bitmap_bit / 8] & (1 << (bitmap_bit & 7));
+ return bitmap_fast_is_set(map, bitmap_bit);
}
diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c
index 653ea569172..cf26428d65f 100644
--- a/mysys/my_chsize.c
+++ b/mysys/my_chsize.c
@@ -89,7 +89,7 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
We should never come here on any modern machine
*/
VOID(my_seek(fd, newlength, MY_SEEK_SET, MYF(MY_WME+MY_FAE)));
- swap(my_off_t, newlength, oldsize);
+ swap_variables(my_off_t, newlength, oldsize);
}
#endif
diff --git a/mysys/my_compress.c b/mysys/my_compress.c
index dd076311188..0e37d2fef9b 100644
--- a/mysys/my_compress.c
+++ b/mysys/my_compress.c
@@ -68,7 +68,7 @@ byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen)
DBUG_PRINT("note",("Packet got longer on compression; Not compressed"));
return 0;
}
- swap(ulong, *len, *complen); /* *len is now packet length */
+ swap_variables(ulong, *len, *complen); /* *len is now packet length */
return compbuf;
}
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index efd5789968c..8d0b05d55f7 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -790,6 +790,8 @@ static void init_variables(const struct my_option *options)
Print help for all options and variables.
*/
+#include <help_start.h>
+
void my_print_help(const struct my_option *options)
{
uint col, name_space= 22, comment_space= 57;
@@ -920,3 +922,5 @@ void my_print_variables(const struct my_option *options)
}
}
}
+
+#include <help_end.h>
diff --git a/mysys/my_handler.c b/mysys/my_handler.c
index 35f620ccbcb..de0fba56d21 100644
--- a/mysys/my_handler.c
+++ b/mysys/my_handler.c
@@ -331,7 +331,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
if (keyseg->flag & HA_REVERSE_SORT)
{
- swap(uchar*,a,b);
+ swap_variables(uchar*, a, b);
swap_flag=1; /* Remember swap of a & b */
end= a+ (int) (end-b);
}
@@ -356,8 +356,8 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
if (*b != '-')
return -1;
a++; b++;
- swap(uchar*,a,b);
- swap(int,alength,blength);
+ swap_variables(uchar*, a, b);
+ swap_variables(int, alength, blength);
swap_flag=1-swap_flag;
alength--; blength--;
end=a+alength;
@@ -385,7 +385,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
}
if (swap_flag) /* Restore pointers */
- swap(uchar*,a,b);
+ swap_variables(uchar*, a, b);
break;
}
#ifdef HAVE_LONG_LONG
diff --git a/mysys/my_init.c b/mysys/my_init.c
index fc178b0308b..da0e6caf96d 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -353,14 +353,16 @@ static my_bool win32_init_tcp_ip()
#ifdef __NETWARE__
-/****************************************************************************
- Do basic initialisation for netware needed by most programs
-****************************************************************************/
+/*
+ Basic initialisation for netware
+*/
static void netware_init()
{
char cwd[PATH_MAX], *name;
+ DBUG_ENTER("netware_init");
+
/* init only if we are not a client library */
if (my_progname)
{
@@ -398,5 +400,7 @@ static void netware_init()
}
}
}
+
+ DBUG_VOID_RETURN;
}
#endif /* __NETWARE__ */
diff --git a/mysys/my_lock.c b/mysys/my_lock.c
index 5058c301adb..8f915d6003a 100644
--- a/mysys/my_lock.c
+++ b/mysys/my_lock.c
@@ -117,10 +117,12 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
#if defined(HAVE_FCNTL)
{
struct flock lock;
- lock.l_type= (short) locktype;
- lock.l_whence=0L;
- lock.l_start=(long) start;
- lock.l_len=(long) length;
+
+ lock.l_type= (short) locktype;
+ lock.l_whence= SEEK_SET;
+ lock.l_start= (off_t) start;
+ lock.l_len= (off_t) length;
+
if (MyFlags & MY_DONT_WAIT)
{
if (fcntl(fd,F_SETLK,&lock) != -1) /* Check if we can lock */
diff --git a/mysys/my_netware.c b/mysys/my_netware.c
index e41dbd0a029..9c604778c2d 100644
--- a/mysys/my_netware.c
+++ b/mysys/my_netware.c
@@ -15,7 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
- Function specific to netware
+ Functions specific to netware
*/
#include <mysys_priv.h>
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index f10a2210064..2667c0670d8 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -102,16 +102,20 @@ void my_pthread_exit(void *status)
NXContext_t ctx;
char name[PATH_MAX] = "";
- NXThreadGetContext(tid, &ctx);
- NXContextGetName(ctx, name, PATH_MAX);
-
- /*
- "MYSQLD.NLM's LibC Reaper" or "MYSQLD.NLM's main thread"
- with a debug build of LibC the reaper can have different names
- */
- if (!strindex(name, "\'s"))
+ /* Do not call pthread_exit if it is not a LibC thread */
+ if (tid != 0)
{
- pthread_exit(status);
+ NXThreadGetContext(tid, &ctx);
+ NXContextGetName(ctx, name, PATH_MAX);
+
+ /*
+ "MYSQLD.NLM's LibC Reaper" or "MYSQLD.NLM's main thread"
+ with a debug build of LibC the reaper can have different names
+ */
+ if (!strindex(name, "\'s"))
+ {
+ pthread_exit(status);
+ }
}
}
#endif
diff --git a/mysys/sha1.c b/mysys/sha1.c
index 5271b369b6c..d93b4571baf 100644
--- a/mysys/sha1.c
+++ b/mysys/sha1.c
@@ -342,7 +342,7 @@ static void SHA1ProcessMessageBlock(SHA1_CONTEXT *context)
*/
-void SHA1PadMessage(SHA1_CONTEXT *context)
+static void SHA1PadMessage(SHA1_CONTEXT *context)
{
/*
Check to see if the current message block is too small to hold