summaryrefslogtreecommitdiff
blob: c706da77641534d4fc5abe7e16785b6252ba5b24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
diff -Naur mysql-5.1.7-beta.a/include/my_sys.h mysql-5.1.7-beta.b/include/my_sys.h
--- mysql-5.1.7-beta.a/include/my_sys.h	2006-02-27 21:25:08.000000000 +0000
+++ mysql-5.1.7-beta.b/include/my_sys.h	2006-04-12 16:43:44.000000000 +0000
@@ -601,6 +601,11 @@
 				    const char *sFile, uint uLine,
 				    myf MyFlag);
 
+/* implemented in my_memmem.c */
+extern void *my_memmem(const void *haystack, size_t haystacklen,
+    const void *needle, size_t needlelen);
+
+
 #ifdef __WIN__
 extern int my_access(const char *path, int amode);
 extern File my_sopen(const char *path, int oflag, int shflag, int pmode);
diff -Naur mysql-5.1.7-beta.a/mysql-test/t/mysql_client_test.opt mysql-5.1.7-beta.b/mysql-test/t/mysql_client_test.opt
--- mysql-5.1.7-beta.a/mysql-test/t/mysql_client_test.opt	1970-01-01 00:00:00.000000000 +0000
+++ mysql-5.1.7-beta.b/mysql-test/t/mysql_client_test.opt	2006-04-12 16:43:44.000000000 +0000
@@ -0,0 +1 @@
+--log
diff -Naur mysql-5.1.7-beta.a/mysys/Makefile.am mysql-5.1.7-beta.b/mysys/Makefile.am
--- mysql-5.1.7-beta.a/mysys/Makefile.am	2006-02-27 21:25:08.000000000 +0000
+++ mysql-5.1.7-beta.b/mysys/Makefile.am	2006-04-12 16:43:44.000000000 +0000
@@ -56,6 +56,7 @@
 			charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
 			my_gethostbyname.c rijndael.c my_aes.c sha1.c \
 			my_handler.c my_netware.c my_largepage.c \
+			my_memmem.c \
 			my_windac.c my_access.c base64.c
 EXTRA_DIST =		thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
 			thr_mutex.c thr_rwlock.c
diff -Naur mysql-5.1.7-beta.a/mysys/Makefile.in mysql-5.1.7-beta.b/mysys/Makefile.in
--- mysql-5.1.7-beta.a/mysys/Makefile.in	2006-02-27 21:26:51.000000000 +0000
+++ mysql-5.1.7-beta.b/mysys/Makefile.in	2006-04-12 16:43:44.000000000 +0000
@@ -515,6 +515,7 @@
 			charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
 			my_gethostbyname.c rijndael.c my_aes.c sha1.c \
 			my_handler.c my_netware.c my_largepage.c \
+			my_memmem.c \
 			my_windac.c my_access.c base64.c
 
 EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
diff -Naur mysql-5.1.7-beta.a/mysys/mf_iocache2.c mysql-5.1.7-beta.b/mysys/mf_iocache2.c
--- mysql-5.1.7-beta.a/mysys/mf_iocache2.c	2006-02-27 21:24:53.000000000 +0000
+++ mysql-5.1.7-beta.b/mysys/mf_iocache2.c	2006-04-12 16:43:44.000000000 +0000
@@ -252,6 +252,10 @@
 uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
 {
   uint out_length=0;
+  uint minimum_width; /* as yet unimplemented */
+  uint minimum_width_sign;
+  uint precision; /* as yet unimplemented for anything but %b */
+  const char* backtrack;
 
   for (; *fmt ; fmt++)
   {
@@ -272,17 +276,53 @@
       fmt++;
       /* Found one '%' */
     }
+    backtrack= fmt;
+
+    minimum_width= 0;
+    precision= 0;
+    minimum_width_sign= 1;
     /* Skip if max size is used (to be compatible with printf) */
-    while (my_isdigit(&my_charset_latin1, *fmt) || *fmt == '.' || *fmt == '-')
+    while (*fmt == '-') { fmt++; minimum_width_sign= -1; }
+    if (*fmt == '*') {
+      precision= (int) va_arg(args, int);
+      fmt++;
+    } else {
+      while (my_isdigit(&my_charset_latin1, *fmt)) {
+        minimum_width=(minimum_width * 10) + (*fmt - '0');
+        fmt++;
+      }
+    }
+    minimum_width*= minimum_width_sign;
+
+    if (*fmt == '.') {
       fmt++;
+      if (*fmt == '*') {
+        precision= (int) va_arg(args, int);
+        fmt++;
+      } else {
+        while (my_isdigit(&my_charset_latin1, *fmt)) {
+          precision=(precision * 10) + (*fmt - '0');
+          fmt++;
+        }
+      }
+    }
+
     if (*fmt == 's')				/* String parameter */
     {
       reg2 char *par = va_arg(args, char *);
       uint length = (uint) strlen(par);
+      /* TODO: implement minimum width and precision */
       out_length+=length;
       if (my_b_write(info, par, length))
 	goto err;
     }
+    else if (*fmt == 'b')				/* Sized buffer parameter, only precision makes sense */
+    {
+      reg2 char *par = va_arg(args, char *);
+      out_length+=precision;
+      if (my_b_write(info, par, precision))
+        goto err;
+    }
     else if (*fmt == 'd' || *fmt == 'u')	/* Integer parameter */
     {
       register int iarg;
@@ -320,6 +360,9 @@
       if (my_b_write(info, "%", 1))
 	goto err;
       out_length++;
+      if (my_b_write(info, backtrack, fmt-backtrack))
+        goto err;
+      out_length+= fmt-backtrack;
     }
   }
   return out_length;
diff -Naur mysql-5.1.7-beta.a/mysys/my_memmem.c mysql-5.1.7-beta.b/mysys/my_memmem.c
--- mysql-5.1.7-beta.a/mysys/my_memmem.c	1970-01-01 00:00:00.000000000 +0000
+++ mysql-5.1.7-beta.b/mysys/my_memmem.c	2006-04-12 16:43:44.000000000 +0000
@@ -0,0 +1,21 @@
+#include "my_base.h"
+
+/*
+ *   my_memmem, port of a GNU extension.
+ *
+ *     Returns a pointer to the beginning of the substring, needle, or NULL if the
+ *       substring is not found in haystack.
+ *       */
+void *my_memmem(const void *haystack, size_t haystacklen,
+    const void *needle, size_t needlelen)
+{
+  const void *cursor;
+  const void *end_of_search_beginning = haystack + haystacklen - needlelen;
+
+  for (cursor = haystack; cursor <= end_of_search_beginning; cursor++) {
+    if (memcmp(needle, cursor, needlelen) == 0) {
+      return((void *) cursor);
+    }
+  }
+  return(NULL);
+}
diff -Naur mysql-5.1.7-beta.a/strings/my_vsnprintf.c mysql-5.1.7-beta.b/strings/my_vsnprintf.c
--- mysql-5.1.7-beta.a/strings/my_vsnprintf.c	2006-02-27 21:24:52.000000000 +0000
+++ mysql-5.1.7-beta.b/strings/my_vsnprintf.c	2006-04-12 16:43:44.000000000 +0000
@@ -27,6 +27,7 @@
     %#[l]d
     %#[l]u
     %#[l]x
+    %#.#b 	Local format; note first # is ignored and second is REQUIRED
     %#.#s	Note first # is ignored
     
   RETURN
@@ -38,9 +39,18 @@
   char *start=to, *end=to+n-1;
   uint length, width, pre_zero, have_long;
 
+  const char *backtrack;  
+  /* 
+   For the special case when we discover that we shouldn't have been
+   interpreting a percent-format. 
+
+   This is here so we can be forgiving about our special local formats.
+   */
+
   for (; *fmt ; fmt++)
   {
-    if (fmt[0] != '%')
+    backtrack = fmt;
+    if (*fmt != '%')
     {
       if (to == end)			/* End of buffer */
 	break;
@@ -95,6 +105,12 @@
       to=strnmov(to,par,plen);
       continue;
     }
+    else if (*fmt == 'b')				/* Buffer parameter */
+    {
+      reg2 char *par = va_arg(ap, char *);
+      to=memmove(to, par, abs(width));
+      continue;
+    }
     else if (*fmt == 'd' || *fmt == 'u'|| *fmt== 'x')	/* Integer parameter */
     {
       register long larg;
diff -Naur mysql-5.1.7-beta.a/tests/Makefile.am mysql-5.1.7-beta.b/tests/Makefile.am
--- mysql-5.1.7-beta.a/tests/Makefile.am	2006-02-27 21:24:57.000000000 +0000
+++ mysql-5.1.7-beta.b/tests/Makefile.am	2006-04-12 16:43:44.000000000 +0000
@@ -42,7 +42,7 @@
 LIBS =			@CLIENT_LIBS@
 LDADD =			@CLIENT_EXTRA_LDFLAGS@ \
                         $(top_builddir)/libmysql/libmysqlclient.la
-mysql_client_test_LDADD= $(LDADD) $(CXXLDFLAGS)
+mysql_client_test_LDADD= $(LDADD) $(CXXLDFLAGS) -lmysys -L../mysys
 mysql_client_test_SOURCES= mysql_client_test.c $(yassl_dummy_link_fix)
 insert_test_SOURCES=       insert_test.c $(yassl_dummy_link_fix)
 select_test_SOURCES=       select_test.c $(yassl_dummy_link_fix)
diff -Naur mysql-5.1.7-beta.a/tests/Makefile.in mysql-5.1.7-beta.b/tests/Makefile.in
--- mysql-5.1.7-beta.a/tests/Makefile.in	2006-02-27 21:27:19.000000000 +0000
+++ mysql-5.1.7-beta.b/tests/Makefile.in	2006-04-12 16:43:44.000000000 +0000
@@ -420,7 +420,7 @@
 LDADD = @CLIENT_EXTRA_LDFLAGS@ \
                         $(top_builddir)/libmysql/libmysqlclient.la
 
-mysql_client_test_LDADD = $(LDADD) $(CXXLDFLAGS)
+mysql_client_test_LDADD = $(LDADD) $(CXXLDFLAGS) -lmysys -L../mysys
 mysql_client_test_SOURCES = mysql_client_test.c $(yassl_dummy_link_fix)
 insert_test_SOURCES = insert_test.c $(yassl_dummy_link_fix)
 select_test_SOURCES = select_test.c $(yassl_dummy_link_fix)