More tuning from cachegrind. Change most trim_string() calls to trim_char(0,
authorJeremy Allison <jra@samba.org>
Fri, 5 Sep 2003 19:59:55 +0000 (19:59 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 5 Sep 2003 19:59:55 +0000 (19:59 +0000)
as that's what they do. Fix string_replace() to fast-path ascii.
Jeremy.
(This used to be commit f35e9a8b909d3c74be47083ccc4a4e91a14938db)

26 files changed:
source3/auth/auth.c
source3/auth/auth_rhosts.c
source3/auth/pampass.c
source3/client/client.c
source3/intl/lang_tdb.c
source3/lib/charcnv.c
source3/lib/substitute.c
source3/lib/util.c
source3/lib/util_str.c
source3/libsmb/clifile.c
source3/libsmb/namequery.c
source3/modules/vfs_recycle.c
source3/msdfs/msdfs.c
source3/nmbd/nmbd_browsesync.c
source3/nmbd/nmbd_serverlistdb.c
source3/param/loadparm.c
source3/passdb/pdb_interface.c
source3/passdb/pdb_plugin.c
source3/printing/lpq_parse.c
source3/printing/nt_printing.c
source3/rpc_server/srv_dfs_nt.c
source3/smbd/chgpasswd.c
source3/smbd/filename.c
source3/smbd/statcache.c
source3/smbd/utmp.c
source3/smbd/vfs.c

index 668bba0d64168fd1d1396f7537b16a5e1f7b449c..553d9a686e31b82a6d52b4c5088d1aa67bd12d01 100644 (file)
@@ -373,10 +373,10 @@ BOOL load_auth_module(struct auth_context *auth_context,
        if (p) {
                *p = 0;
                module_params = p+1;
-               trim_string(module_params, " ", " ");
+               trim_char(module_params, ' ', ' ');
        }
        
-       trim_string(module_name, " ", " ");
+       trim_char(module_name, ' ', ' ');
        
        entry = auth_find_backend_entry(module_name);
        
index fab2d551f29c4e43f66dd41a9e09e97418d7a92c..b295df9328f2be655242bdb4695fec72f3e9dede 100644 (file)
@@ -40,7 +40,7 @@ static BOOL check_user_equiv(const char *user, const char *remote, const char *e
   if (! lines) return False;
   for (i=0; lines[i]; i++) {
     char *buf = lines[i];
-    trim_string(buf," "," ");
+    trim_char(buf,' ',' ');
 
     if (buf[0] != '#' && buf[0] != '\n') 
     {
index d666e439b0dc1c742bafdf1d2ff29600c9785e56..3239686a20d49629e42c89fec95d4ae9622d47b5 100644 (file)
@@ -230,7 +230,7 @@ static struct chat_struct *make_pw_chat(char *p)
                special_char_sub(prompt);
                fstrcpy(t->prompt, prompt);
                strlower_m(t->prompt);
-               trim_string(t->prompt, " ", " ");
+               trim_char(t->prompt, ' ', ' ');
 
                if (!next_token(&p, reply, NULL, sizeof(fstring)))
                        break;
@@ -241,7 +241,7 @@ static struct chat_struct *make_pw_chat(char *p)
                special_char_sub(reply);
                fstrcpy(t->reply, reply);
                strlower_m(t->reply);
-               trim_string(t->reply, " ", " ");
+               trim_char(t->reply, ' ', ' ');
 
        }
        return list;
@@ -304,7 +304,7 @@ static int smb_pam_passchange_conv(int num_msg,
                case PAM_PROMPT_ECHO_ON:
                        DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_ON: PAM said: %s\n", msg[replies]->msg));
                        fstrcpy(current_prompt, msg[replies]->msg);
-                       trim_string(current_prompt, " ", " ");
+                       trim_char(current_prompt, ' ', ' ');
                        for (t=pw_chat; t; t=t->next) {
 
                                DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_ON: trying to match |%s| to |%s|\n",
@@ -335,7 +335,7 @@ static int smb_pam_passchange_conv(int num_msg,
                case PAM_PROMPT_ECHO_OFF:
                        DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: PAM said: %s\n", msg[replies]->msg));
                        fstrcpy(current_prompt, msg[replies]->msg);
-                       trim_string(current_prompt, " ", " ");
+                       trim_char(current_prompt, ' ', ' ');
                        for (t=pw_chat; t; t=t->next) {
 
                                DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: trying to match |%s| to |%s|\n",
index 67931b00b4d4e0ebfa4937f299ac737b07cf4794..ecece8942ec74e5ff9cac2ce8ee62cf8c09e5226 100644 (file)
@@ -1006,7 +1006,7 @@ static int cmd_mkdir(void)
                *ddir2 = 0;
                
                pstrcpy(ddir,mask);
-               trim_string(ddir,".",NULL);
+               trim_char(ddir,'.','\0');
                p = strtok(ddir,"/\\");
                while (p) {
                        pstrcat(ddir2,p);
index 87ef4e39c7bb1cd15a2b936b2001ae0877e60886..f12b9b6f1511797a8a972698e9db160f7b5855b4 100644 (file)
@@ -53,8 +53,8 @@ static BOOL load_msg(const char *msg_file)
                }
                if (msgid && strncmp(lines[i], "msgstr \"", 8) == 0) {
                        msgstr = lines[i] + 8;
-                       trim_string(msgid, NULL, "\"");
-                       trim_string(msgstr, NULL, "\"");
+                       trim_char(msgid, '\0', '\"');
+                       trim_char(msgstr, '\0', '\"');
                        if (*msgstr == 0) {
                                msgstr = msgid;
                        }
index a07ff7399d95f2f0724d3eb89dc15cff3c867a18..ceb9d57fc71a92d5d854227c2dd05b20e4ce7501 100644 (file)
@@ -879,9 +879,8 @@ size_t pull_ucs2(const void *base_ptr, char *dest, const void *src, size_t dest_
        }
 
        if (flags & STR_TERMINATE) {
-               if (src_len == (size_t)-1) {
-                       src_len = strlen_w(src)*2 + 2;
-               } else {
+               /* src_len -1 is the default for null terminated strings. */
+               if (src_len != (size_t)-1) {
                        size_t len = strnlen_w(src, src_len/2);
                        if (len < src_len/2)
                                len++;
@@ -1051,4 +1050,3 @@ size_t align_string(const void *base_ptr, const char *p, int flags)
        }
        return 0;
 }
-
index a73f9d85dabb8c3a6220df3beaa74443d4e7d511..28466e43f29172b0586cae3ad0756b98eb78549e 100644 (file)
@@ -57,7 +57,7 @@ void set_local_machine_name(const char* local_name, BOOL perm)
        already_perm = perm;
 
        fstrcpy(tmp_local_machine,local_name);
-       trim_string(tmp_local_machine," "," ");
+       trim_char(tmp_local_machine,' ',' ');
        alpha_strcpy(local_machine,tmp_local_machine,SAFE_NETBIOS_CHARS,sizeof(local_machine)-1);
        strlower_m(local_machine);
 }
@@ -79,7 +79,7 @@ void set_remote_machine_name(const char* remote_name, BOOL perm)
        already_perm = perm;
 
        fstrcpy(tmp_remote_machine,remote_name);
-       trim_string(tmp_remote_machine," "," ");
+       trim_char(tmp_remote_machine,' ',' ');
        alpha_strcpy(remote_machine,tmp_remote_machine,SAFE_NETBIOS_CHARS,sizeof(remote_machine)-1);
        strlower_m(remote_machine);
 }
@@ -111,7 +111,7 @@ void sub_set_smb_name(const char *name)
                return;
 
        fstrcpy(tmp,name);
-       trim_string(tmp," "," ");
+       trim_char(tmp,' ',' ');
        strlower_m(tmp);
        alpha_strcpy(smb_user_name,tmp,SAFE_NETBIOS_CHARS,sizeof(smb_user_name)-1);
 }
index 5f4fae9baa2b62b3c0801ebd68dc62d13cb3c84b..766c5041b4e13ff241fa9c3cbc85aa996de9e7d3 100644 (file)
@@ -261,7 +261,7 @@ BOOL init_names(void)
        }                       
 
        fstrcpy( local_machine, global_myname() );
-       trim_string( local_machine, " ", " " );
+       trim_char( local_machine, ' ', ' ' );
        p = strchr( local_machine, ' ' );
        if (p)
                *p = 0;
@@ -605,68 +605,6 @@ void unix_clean_name(char *s)
        trim_string(s,NULL,"/..");
 }
 
-/*******************************************************************
- Convert '\' to '/'.
- Reduce a file name, removing or reducing /../ , /./ , // elements.
- Remove also any trailing . and /
- Return a new allocated string.
-********************************************************************/
-
-smb_ucs2_t *unix_clean_path(const smb_ucs2_t *s)
-{
-       smb_ucs2_t *ns;
-       smb_ucs2_t *p, *r, *t;
-
-       DEBUG(3, ("unix_clean_path\n")); /*  [%unicode]\n")); */
-       if(!s)
-               return NULL;
-
-       /* convert '\' to '/' */
-       ns = strdup_w(s);
-       if (!ns)
-               return NULL;
-       unix_format_w(ns);
-
-       /* remove all double slashes */
-       p = ns;
-       ns = all_string_sub_wa(p, "//", "/");
-       SAFE_FREE(p);
-       if (!ns)
-               return NULL;
-
-       /* remove any /./ */
-       p = ns;
-       ns = all_string_sub_wa(p, "/./", "/");
-       SAFE_FREE(p);
-       if (!ns)
-               return NULL;
-
-       /* reduce any /../ */
-       t = ns;
-       while (*t && (r = strstr_wa(t, "/.."))) {
-               t = &(r[3]);
-               if (*t == UCS2_CHAR('/') || *t == 0) {
-                       *r = 0;
-                       p = strrchr_w(ns, UCS2_CHAR('/'));
-                       if (!p)
-                               p = ns;
-                       if (*t == 0)
-                               *p = 0;
-                       else
-                               memmove(p, t, (strlen_w(t) + 1) * sizeof(smb_ucs2_t));
-                       t = p;
-               }
-       }
-
-       /* remove any leading ./ trailing /. */
-       trim_string_wa(ns, "./", "/.");
-
-       /* remove any leading and trailing / */
-       trim_string_wa(ns, "/", "/");
-
-       return ns;
-}
-
 /****************************************************************************
  Make a dir struct.
 ****************************************************************************/
@@ -2205,7 +2143,7 @@ char *lock_path(const char *name)
        static pstring fname;
 
        pstrcpy(fname,lp_lockdir());
-       trim_string(fname,"","/");
+       trim_char(fname,'\0','/');
        
        if (!directory_exist(fname,NULL))
                mkdir(fname,0755);
@@ -2225,7 +2163,7 @@ char *pid_path(const char *name)
        static pstring fname;
 
        pstrcpy(fname,lp_piddir());
-       trim_string(fname,"","/");
+       trim_char(fname,'\0','/');
 
        if (!directory_exist(fname,NULL))
                mkdir(fname,0755);
index 70567f88afd1ca99e002397b3e67f453ef0cf60a..82b312e24150f1562d73dd001927609f68b56845 100644 (file)
@@ -364,9 +364,27 @@ BOOL strisnormal(const char *s)
 
 void string_replace(pstring s,char oldc,char newc)
 {
-       push_ucs2(NULL, tmpbuf,s, sizeof(tmpbuf), STR_TERMINATE);
+       unsigned char *p;
+
+       /* this is quite a common operation, so we want it to be
+          fast. We optimise for the ascii case, knowing that all our
+          supported multi-byte character sets are ascii-compatible
+          (ie. they match for the first 128 chars) */
+
+       for (p = (unsigned char *)s; *p; p++) {
+               if (*p & 0x80) /* mb string - slow path. */
+                       break;
+               if (*p == oldc)
+                       *p = newc;
+       }
+
+       if (!*p)
+               return;
+
+       /* Slow (mb) path. */
+       push_ucs2(NULL, tmpbuf, p, sizeof(tmpbuf), STR_TERMINATE);
        string_replace_w(tmpbuf, UCS2_CHAR(oldc), UCS2_CHAR(newc));
-       pull_ucs2(NULL, s, tmpbuf, -1, sizeof(tmpbuf), STR_TERMINATE);
+       pull_ucs2(NULL, p, tmpbuf, -1, sizeof(tmpbuf), STR_TERMINATE);
 }
 
 /**
@@ -406,6 +424,59 @@ size_t str_ascii_charnum(const char *s)
        return strlen(tmpbuf2);
 }
 
+BOOL trim_char(char *s,char cfront,char cback)
+{
+       BOOL ret = False;
+       char *ep;
+       char *fp = s;
+
+       /* Ignore null or empty strings. */
+       if (!s || (s[0] == '\0'))
+               return False;
+
+       if (cfront) {
+               while (*fp && *fp == cfront)
+                       fp++;
+               if (!*fp) {
+                       /* We ate the string. */
+                       s[0] = '\0';
+                       return True;
+               }
+               if (fp != s)
+                       ret = True;
+       }
+
+       ep = fp + strlen(fp) - 1;
+       if (cback) {
+               /* Attempt ascii only. Bail for mb strings. */
+               while ((ep >= fp) && (*ep == cback)) {
+                       ret = True;
+                       if ((ep > fp) && (((unsigned char)ep[-1]) & 0x80)) {
+                               /* Could be mb... bail back to tim_string. */
+                               char fs[2], bs[2];
+                               if (cfront) {
+                                       fs[0] = cfront;
+                                       fs[1] = '\0';
+                               }
+                               bs[0] = cback;
+                               bs[1] = '\0';
+                               return trim_string(s, cfront ? fs : NULL, bs);
+                       } else {
+                               ep--;
+                       }
+               }
+               if (ep < fp) {
+                       /* We ate the string. */
+                       s[0] = '\0';
+                       return True;
+               }
+       }
+
+       ep[1] = '\0';
+       memmove(s, fp, ep-fp+2);
+       return ret;
+}
+
 /**
  Trim the specified elements off the front and back of a string.
 **/
index f021076a46cdc9339de59c8cf9c1e01da4b9a671..c7f0cdb84b587325a916686f7e90b5dd3040e539 100644 (file)
@@ -951,8 +951,9 @@ BOOL cli_chkpath(struct cli_state *cli, const char *path)
        char *p;
        
        pstrcpy(path2,path);
-       trim_string(path2,NULL,"\\");
-       if (!*path2) *path2 = '\\';
+       trim_char(path2,'\0','\\');
+       if (!*path2)
+               *path2 = '\\';
        
        memset(cli->outbuf,'\0',smb_size);
        set_message(cli->outbuf,0,0,True);
index 9875f77c72e43adb5bcfdda4beb92b0d05f85cd3..1de74137117191840af849b2eb02b47074eff443 100644 (file)
@@ -61,7 +61,7 @@ static struct node_status *parse_node_status(char *p, int *num_names)
        p++;
        for (i=0;i< *num_names;i++) {
                StrnCpy(ret[i].name,p,15);
-               trim_string(ret[i].name,NULL," ");
+               trim_char(ret[i].name,'\0',' ');
                ret[i].type = CVAL(p,15);
                ret[i].flags = p[16];
                p += 18;
index c0b331b8621accb390aed60f23e087c53e586413..b1b2ac03538f798511ca444a31b5780a4d065c8d 100644 (file)
@@ -336,7 +336,7 @@ static int recycle_unlink(vfs_handle_struct *handle, connection_struct *conn, co
        repository = alloc_sub_conn(conn, recycle_repository(handle));
        ALLOC_CHECK(repository, done);
        /* shouldn't we allow absolute path names here? --metze */
-       trim_string(repository, "/", "/");
+       trim_char(repository, '/', '/');
        
        if(!repository || *(repository) == '\0') {
                DEBUG(3, ("recycle: repository path not set, purging %s...\n", file_name));
index dc326f2eee87981bd10416152874f81aebf1f113..afe523bf19b778aa8c9eda6cce0e5fbb3e41003e 100644 (file)
@@ -40,7 +40,7 @@ static BOOL parse_dfs_path(char* pathname, struct dfs_path* pdp)
 
        ZERO_STRUCTP(pdp);
 
-       trim_string(temp,"\\","\\");
+       trim_char(temp,'\\','\\');
        DEBUG(10,("temp in parse_dfs_path: .%s. after trimming \\'s\n",temp));
 
        /* now tokenize */
@@ -275,7 +275,7 @@ static BOOL resolve_dfs_path(char* dfspath, struct dfs_path* dp,
                                char *q;
                                pstring buf;
                                pstrcpy(buf, dfspath);
-                               trim_string(buf, NULL, "\\");
+                               trim_char(buf, '\0', '\\');
                                for (; consumed_level; consumed_level--) {
                                        q = strrchr(buf, '\\');
                                        if (q) *q = 0;
@@ -780,7 +780,7 @@ BOOL create_msdfs_link(struct junction_map* jn, BOOL exists)
        for(i=0; i<jn->referral_count; i++) {
                char* refpath = jn->referral_list[i].alternate_path;
       
-               trim_string(refpath, "\\", "\\");
+               trim_char(refpath, '\\', '\\');
                if(*refpath == '\0') {
                        if (i == 0)
                                insert_comma = False;
index 96e8fd1b8151b57e9e2f5c0a535dfd39ee3e9657..6cde88651f9cbd3f9877bf02242b674f08d0a79f 100644 (file)
@@ -204,7 +204,7 @@ static void domain_master_node_status_success(struct subnet_record *subrec,
                        pull_ascii_nstring(qname, p);
                        name_type = CVAL(p,15);
                        nb_flags = get_nb_flags(&p[16]);
-                       trim_string(qname,NULL," ");
+                       trim_char(qname,'\0',' ');
 
                        p += 18;
 
@@ -427,7 +427,7 @@ static void get_domain_master_name_node_status_success(struct subnet_record *sub
                        pull_ascii_nstring(qname, p);
                        name_type = CVAL(p,15);
                        nb_flags = get_nb_flags(&p[16]);
-                       trim_string(qname,NULL," ");
+                       trim_char(qname,'\0',' ');
 
                        p += 18;
 
index a5008f803b48f28f353d28d0bec726587d67d8af..cdb1089a54faa57ede1d80c56cd70b07b34e75ea 100644 (file)
@@ -328,7 +328,7 @@ void write_browse_list(time_t t, BOOL force_write)
        updatecount++;
     
        pstrcpy(fname,lp_lockdir());
-       trim_string(fname,NULL,"/");
+       trim_char(fname,'\0' ,'/');
        pstrcat(fname,"/");
        pstrcat(fname,SERVER_LIST);
        pstrcpy(fnamenew,fname);
index 3d0aebf230be91ed7912c96c6dc35b1a49820f3a..c801c4c522fd5d125cbf84af3ffa0ea497deaf77 100644 (file)
@@ -1558,8 +1558,8 @@ static char *lp_string(const char *s)
                lp_talloc = talloc_init("lp_talloc");
 
        tmpstr = alloc_sub_basic(current_user_info.smb_name, s);
-       if (trim_string(tmpstr, "\"", "\"")) {
-               if (strchr(tmpstr,'"') != NULL) {
+       if (trim_char(tmpstr, '\"', '\"')) {
+               if (strchr(tmpstr,'\"') != NULL) {
                        SAFE_FREE(tmpstr);
                        tmpstr = alloc_sub_basic(current_user_info.smb_name,s);
                }
@@ -3112,7 +3112,7 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
                        pstr_sprintf(param_key, "%s:", pszParmName);
                        slen = strlen(param_key);
                        pstrcat(param_key, sep+1);
-                       trim_string(param_key+slen, " ", " ");
+                       trim_char(param_key+slen, ' ', ' ');
                        not_added = True;
                        data = (snum < 0) ? Globals.param_opt : 
                                ServicePtrs[snum]->param_opt;
index 5ebc14030f06cf9e2fed55f5526ae53d654780f3..d548081e78b71af1ed6291886cd7f9909db6a6cc 100644 (file)
@@ -422,10 +422,10 @@ static NTSTATUS make_pdb_methods_name(struct pdb_methods **methods, struct pdb_c
        if (p) {
                *p = 0;
                module_location = p+1;
-               trim_string(module_location, " ", " ");
+               trim_char(module_location, ' ', ' ');
        }
 
-       trim_string(module_name, " ", " ");
+       trim_char(module_name, ' ', ' ');
 
 
        DEBUG(5,("Attempting to find an passdb backend to match %s (%s)\n", selected, module_name));
index ea67da23a552a04de4a76a6dab9dc7bc69991e04..027cd0b5d3353fa44f64f8d6562ece8aa3ea74c1 100644 (file)
@@ -41,9 +41,11 @@ NTSTATUS pdb_init_plugin(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, con
        if (p) {
                *p = 0;
                plugin_location = p+1;
-               trim_string(plugin_location, " ", " ");
-       } else plugin_location = NULL;
-       trim_string(plugin_name, " ", " ");
+               trim_char(plugin_location, ' ', ' ');
+       } else {
+               plugin_location = NULL;
+       }
+       trim_char(plugin_name, ' ', ' ');
 
        DEBUG(5, ("Trying to load sam plugin %s\n", plugin_name));
        dl_handle = sys_dlopen(plugin_name, RTLD_NOW );
index 0acca67b7044aa470a2ec32b1b0c82db65313f20..111617e3aed5ced8ddf870fc458a6e8987bf9be1 100644 (file)
@@ -766,14 +766,14 @@ static BOOL parse_lpq_nt(char *line,print_queue_struct *buf,BOOL first)
 
   /* Make sure the status is valid */
   parse_line.space2 = '\0';
-  trim_string(parse_line.status, NULL, " ");
+  trim_char(parse_line.status, '\0', ' ');
   if (!strequal(parse_line.status, LPRNT_PRINTING) &&
       !strequal(parse_line.status, LPRNT_PAUSED) &&
       !strequal(parse_line.status, LPRNT_WAITING))
     return(False);
   
   parse_line.space3 = '\0';
-  trim_string(parse_line.jobname, NULL, " ");
+  trim_char(parse_line.jobname, '\0', ' ');
 
   buf->job = atoi(parse_line.jobid);
   buf->priority = 0;
@@ -837,7 +837,7 @@ static BOOL parse_lpq_os2(char *line,print_queue_struct *buf,BOOL first)
 
   /* Get the job name */
   parse_line.space2[0] = '\0';
-  trim_string(parse_line.jobname, NULL, " ");
+  trim_char(parse_line.jobname, '\0', ' ');
   fstrcpy(buf->fs_file, parse_line.jobname);
 
   buf->priority = 0;
@@ -850,7 +850,7 @@ static BOOL parse_lpq_os2(char *line,print_queue_struct *buf,BOOL first)
 
   /* Make sure we have a valid status */
   parse_line.space4[0] = '\0';
-  trim_string(parse_line.status, NULL, " ");
+  trim_char(parse_line.status, '\0', ' ');
   if (!strequal(parse_line.status, LPROS2_PRINTING) &&
       !strequal(parse_line.status, LPROS2_PAUSED) &&
       !strequal(parse_line.status, LPROS2_WAITING))
index b4a551c1612905e38b71c1a7a8b0064c4fa257cb..4859d785be68deb0967505f07b10234d6d0eab51 100644 (file)
@@ -2026,7 +2026,7 @@ static WERROR update_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
 
        if (info->servername[0]!='\0') {
                trim_string(info->printername, info->servername, NULL);
-               trim_string(info->printername, "\\", NULL);
+               trim_char(info->printername, '\\', '\0');
                info->servername[0]='\0';
        }
 
index eba4eaec756f9bc4761ef8bb43189c456fe7b4bd..3470ad99b458d51829375f704ef9019e9899a312 100644 (file)
@@ -159,7 +159,7 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u,
        {
          pstring refpath;
          pstrcpy(refpath,jn.referral_list[i].alternate_path);
-         trim_string(refpath, "\\", "\\");
+         trim_char(refpath, '\\', '\\');
          DEBUG(10,("_dfs_remove:  refpath: .%s.\n", refpath));
          if(strequal(refpath, altpath))
            {
@@ -257,7 +257,7 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I
          struct referral* ref = &(j[i].referral_list[ii]);
          
          pstrcpy(path, ref->alternate_path);
-         trim_string(path,"\\","");
+         trim_char(path,'\\','\0');
          p = strrchr_m(path,'\\');
          if(p==NULL)
            {
index 0009f09028dc303029e6555ef517d62be257cef7..d99570ff7c0125acbdf5b3c26f3018f4300a2b59 100644 (file)
@@ -259,7 +259,7 @@ static int expect(int master, char *issue, char *expected)
                                /* Eat leading/trailing whitespace before match. */
                                pstring str;
                                pstrcpy( str, buffer);
-                               trim_string( str, " ", " ");
+                               trim_char( str, ' ', ' ');
 
                                if ((match = (unix_wild_match(expected, str) == 0)))
                                        timeout = 200;
index ad107f9c3e13b814c7cde4f38819819a4cd6d346..643e315c0694f2890c8cbe86dfc354ce494f027d 100644 (file)
@@ -125,7 +125,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
         * also trim trailing /'s.
         */
 
-       trim_string(name,"/","/");
+       trim_char(name,'/','/');
 
        /*
         * If we trimmed down to a single '\0' character
@@ -164,7 +164,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
                return(True);
 
        start = name;
-       while (strncmp(start,"./",2) == 0)
+       while (start[0] == '.' && start[1] == '/')
                start += 2;
 
        pstrcpy(orig_path, name);
index fbebdb240f4b2eef659acf38acfd1c3b91622ada..28915a30a081972fd918f1a7379812e4432a1398 100644 (file)
@@ -66,11 +66,12 @@ void stat_cache_add( const char *full_orig_name, const char *orig_translated_pat
                return;
 
        /*
-        * Don't cache trivial valid directory entries.
+        * Don't cache trivial valid directory entries such as . and ..
         */
 
-       if((*full_orig_name == '\0') || (strcmp(full_orig_name, ".") == 0) ||
-                       (strcmp(full_orig_name, "..") == 0))
+       if((*full_orig_name == '\0') || (full_orig_name[0] == '.' && 
+                               ((full_orig_name[1] == '\0') ||
+                                (full_orig_name[1] == '.' && full_orig_name[1] == '\0'))))
                return;
 
        /*
index d57e475ce266e5a4b159d89bb57d48c4f32d8beb..a521d0113d469501d3fbe11c2efa763e35dbbbb7 100644 (file)
@@ -217,13 +217,13 @@ static void uw_pathname(pstring fname, const char *uw_name, const char *uw_defau
        /* For w-files, first look for explicit "wtmp dir" */
        if (uw_name[0] == 'w') {
                pstrcpy(dirname,lp_wtmpdir());
-               trim_string(dirname,"","/");
+               trim_char(dirname,'\0','/');
        }
 
        /* For u-files and non-explicit w-dir, look for "utmp dir" */
        if (dirname == 0 || strlen(dirname) == 0) {
                pstrcpy(dirname,lp_utmpdir());
-               trim_string(dirname,"","/");
+               trim_char(dirname,'\0','/');
        }
 
        /* If explicit directory above, use it */
index 58a8a387925b808e5da1548b91a73468d9d2e23e..753db4cece385e28ec9647c080fdde3ee968ee9f 100644 (file)
@@ -233,10 +233,10 @@ BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object)
        if (p) {
                *p = 0;
                module_param = p+1;
-               trim_string(module_param, " ", " ");
+               trim_char(module_param, ' ', ' ');
        }
 
-       trim_string(module_name, " ", " ");
+       trim_char(module_name, ' ', ' ');
 
        /* First, try to load the module with the new module system */
        if((entry = vfs_find_backend_entry(module_name)) ||