svn commit: samba r2577 - in branches/SAMBA_4_0/source: client lib
tridge at samba.org
tridge at samba.org
Fri Sep 24 01:21:21 GMT 2004
Author: tridge
Date: 2004-09-24 01:21:21 +0000 (Fri, 24 Sep 2004)
New Revision: 2577
WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source&rev=2577&nolog=1
Log:
- I recently found out that charaters below 0x3F are guaranteed not to
occur as secondary bytes in any multi-byte character set. This
allows for a very simple optimisation in strchr_m() and
strrchr_m(). It might be a good idea to pick this up for Samba3.
- the horrible toktocliplist() is only used in clitar.c, so move it
there, to prevent anyone else from being tempted to use it.
Modified:
branches/SAMBA_4_0/source/client/clitar.c
branches/SAMBA_4_0/source/lib/util_str.c
Changeset:
Modified: branches/SAMBA_4_0/source/client/clitar.c
===================================================================
--- branches/SAMBA_4_0/source/client/clitar.c 2004-09-24 01:20:30 UTC (rev 2576)
+++ branches/SAMBA_4_0/source/client/clitar.c 2004-09-24 01:21:21 UTC (rev 2577)
@@ -38,6 +38,52 @@
#include "includes.h"
#include "clitar.h"
+/**
+ Convert list of tokens to array; dependent on above routine.
+ Uses last_ptr from above - bit of a hack.
+**/
+
+static char **toktocliplist(const char *ptr, int *ctok, const char *sep)
+{
+ char *s = ptr;
+ int ictok=0;
+ char **ret, **iret;
+
+ if (!sep)
+ sep = " \t\n\r";
+
+ while(*s && strchr_m(sep,*s))
+ s++;
+
+ /* nothing left? */
+ if (!*s)
+ return(NULL);
+
+ do {
+ ictok++;
+ while(*s && (!strchr_m(sep,*s)))
+ s++;
+ while(*s && strchr_m(sep,*s))
+ *s++=0;
+ } while(*s);
+
+ *ctok=ictok;
+ s = ptr;
+
+ if (!(ret=iret=malloc(ictok*sizeof(char *))))
+ return NULL;
+
+ while(ictok--) {
+ *iret++=s;
+ while(*s++)
+ ;
+ while(!*s)
+ s++;
+ }
+
+ return ret;
+}
+
static int clipfind(char **aret, int ret, char *tok);
void dos_clean_name(char *s);
Modified: branches/SAMBA_4_0/source/lib/util_str.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util_str.c 2004-09-24 01:20:30 UTC (rev 2576)
+++ branches/SAMBA_4_0/source/lib/util_str.c 2004-09-24 01:21:21 UTC (rev 2577)
@@ -76,52 +76,7 @@
static uint16_t tmpbuf[sizeof(pstring)];
-/**
- Convert list of tokens to array; dependent on above routine.
- Uses last_ptr from above - bit of a hack.
-**/
-char **toktocliplist(const char *ptr, int *ctok, const char *sep)
-{
- char *s = ptr;
- int ictok=0;
- char **ret, **iret;
-
- if (!sep)
- sep = " \t\n\r";
-
- while(*s && strchr_m(sep,*s))
- s++;
-
- /* nothing left? */
- if (!*s)
- return(NULL);
-
- do {
- ictok++;
- while(*s && (!strchr_m(sep,*s)))
- s++;
- while(*s && strchr_m(sep,*s))
- *s++=0;
- } while(*s);
-
- *ctok=ictok;
- s = ptr;
-
- if (!(ret=iret=malloc(ictok*sizeof(char *))))
- return NULL;
-
- while(ictok--) {
- *iret++=s;
- while(*s++)
- ;
- while(!*s)
- s++;
- }
-
- return ret;
-}
-
/**
Case insensitive string compararison.
**/
@@ -736,6 +691,12 @@
pstring s2;
smb_ucs2_t *p;
+ /* characters below 0x3F are guaranteed to not appear in
+ non-initial position in multi-byte charsets */
+ if ((c & 0xC0) == 0) {
+ return strchr(s, c);
+ }
+
push_ucs2(ws, s, sizeof(ws), STR_TERMINATE);
p = strchr_w(ws, UCS2_CHAR(c));
if (!p)
@@ -751,6 +712,12 @@
pstring s2;
smb_ucs2_t *p;
+ /* characters below 0x3F are guaranteed to not appear in
+ non-initial position in multi-byte charsets */
+ if ((c & 0xC0) == 0) {
+ return strrchr(s, c);
+ }
+
push_ucs2(ws, s, sizeof(ws), STR_TERMINATE);
p = strrchr_w(ws, UCS2_CHAR(c));
if (!p)
More information about the samba-cvs
mailing list