* strlen holy war: loops. in loops it's very evil. the easy ones go away now.
authorWilfried Göesgens <willi@citadel.org>
Thu, 9 Aug 2007 21:35:28 +0000 (21:35 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 9 Aug 2007 21:35:28 +0000 (21:35 +0000)
23 files changed:
citadel/citserver.c
citadel/client_chat.c
citadel/commands.c
citadel/file_ops.c
citadel/html.c
citadel/internet_addressing.c
citadel/modules/calendar/serv_calendar.c
citadel/modules/imap/imap_fetch.c
citadel/modules/imap/imap_list.c
citadel/modules/imap/imap_misc.c
citadel/modules/imap/imap_tools.c
citadel/modules/ldap/serv_ldap.c
citadel/modules/network/serv_network.c
citadel/modules/notes/serv_notes.c
citadel/modules/smtp/serv_smtp.c
citadel/modules/vandelay/serv_vandelay.c
citadel/modules/vcard/serv_vcard.c
citadel/msgbase.c
citadel/room_ops.c
citadel/rooms.c
citadel/routines.c
citadel/routines2.c
citadel/support.c

index c221d6aafbf6949fd9bfa939f283999bcdee13ff..6032caeaadcc712e13f83e0a8803120d1341af67 100644 (file)
@@ -334,8 +334,11 @@ int is_public_client(void)
 
                fp = fopen(public_clients_file, "r");
                if (fp != NULL) while (fgets(buf, sizeof buf, fp)!=NULL) {
-                       for (i=0; i<strlen(buf); ++i) {
+                       char *ptr;
+                       ptr = buf;
+                       while (!IsEmptyStr(*ptr)) {
                                if (buf[i] == '#') buf[i] = 0;
+                               else ptr++;
                        }
                        while (isspace((buf[strlen(buf)-1]))) {
                                buf[strlen(buf)-1] = 0;
@@ -534,7 +537,7 @@ void cmd_emsg(char *mname)
        if (CtdlAccessCheck(ac_aide)) return;
 
        extract_token(buf, mname, 0, '|', sizeof buf);
-       for (a=0; a<strlen(buf); ++a) {         /* security measure */
+       for (a=0; !IsEmptyStr(&buf[a]); ++a) {          /* security measure */
                if (buf[a] == '/') buf[a] = '.';
        }
 
index 1cdb958f9dcd037f2fa1a5406cb58250e7fe6327..535055fc9d40f7e8add4c2d70d57e1fcf3da4711 100644 (file)
@@ -135,7 +135,7 @@ RCL:                if (send_complete_line) {
                /* if it's time to word wrap, send a partial line */
                if (strlen(wbuf) >= (77 - strlen(fullname))) {
                        pos = 0;
-                       for (a = 0; a < strlen(wbuf); ++a) {
+                       for (a = 0; !IsEmptyStr(&wbuf[a]); ++a) {
                                if (wbuf[a] == 32)
                                        pos = a;
                        }
index 0a2042e3ad1efcc773f8a05a020f48a613c882dd..7ee8d5d2ddce8dfc16635c4ee5a2d18d74170229 100644 (file)
@@ -186,7 +186,7 @@ void pprintf(const char *format, ...) {
         vsnprintf(buf, sizeof(buf), format, arg_ptr);   
         va_end(arg_ptr);   
 
-       for (i=0; i<strlen(buf); ++i) {
+       for (i=0; !IsEmptyStr(&buf[i]); ++i) {
                scr_putc(buf[i]);
                if (buf[i]==10) {
                        ++lines_printed;
@@ -636,7 +636,7 @@ void strprompt(char *prompt, char *str, int len)
                scr_printf("%s", str);
        }
        else {
-               for (i=0; i<strlen(str); ++i) {
+               for (i=0; !IsEmptyStr(&str[i]); ++i) {
                        scr_printf("*");
                }
        }
@@ -689,7 +689,7 @@ int intprompt(char *prompt, int ival, int imin, int imax)
                snprintf(buf, sizeof buf, "%d", i);
                strprompt(prompt, buf, 15);
                i = atoi(buf);
-               for (p=0; p<strlen(buf); ++p) {
+               for (p=0; !IsEmptyStr(&buf[p]); ++p) {
                        if ( (!isdigit(buf[p]))
                           && ( (buf[p]!='-') || (p!=0) )  )
                                i = imin - 1;
@@ -963,7 +963,7 @@ char keycmd(char *cmdstr)
 {
        int a;
 
-       for (a = 0; a < strlen(cmdstr); ++a)
+       for (a = 0; !IsEmptyStr(&cmdstr[a]); ++a)
                if (cmdstr[a] == '&')
                        return (tolower(cmdstr[a + 1]));
        return (0);
@@ -979,34 +979,37 @@ char *cmd_expand(char *strbuf, int mode)
        int a;
        static char exp[64];
        char buf[1024];
+       char *ptr;
 
        strcpy(exp, strbuf);
 
-       for (a = 0; a < strlen(exp); ++a) {
-               if (strbuf[a] == '&') {
+       ptr = exp;
+       while (!IsEmptyStr(ptr)){
+               if (*ptr == '&') {
 
                        /* dont echo these non mnemonic command keys */
-                       int noecho = strbuf[a+1] == '<' || strbuf[a+1] == '>' || strbuf[a+1] == '+' || strbuf[a+1] == '-';
+                       int noecho = *(ptr+1) == '<' || *(ptr+1) == '>' || 
+                               *(ptr+1) == '+' || *(ptr+1) == '-';
 
                        if (mode == 0) {
-                               strcpy(&exp[a], &exp[a + 1 + noecho]);
+                               strcpy(ptr, ptr + 1 + noecho);
                        }
                        if (mode == 1) {
-                               exp[a] = '<';
-                               strcpy(buf, &exp[a + 2]);
-                               exp[a + 2] = '>';
-                               exp[a + 3] = 0;
+                               *ptr = '<';
+                               strcpy(buf, ptr + 2);
+                               *(ptr + 2) = '>';
+                               *(ptr+ 3) = 0;
                                strcat(exp, buf);
                        }
                }
-               if (!strncmp(&exp[a], "^r", 2)) {
+               if (!strncmp(ptr, "^r", 2)) {
                        strcpy(buf, exp);
-                       strcpy(&exp[a], room_name);
-                       strcat(exp, &buf[a + 2]);
+                       strcpy(ptr, room_name);
+                       strcat(exp, &buf[ptr - exp + 2]);
                }
-               if (!strncmp(&exp[a], "^c", 2)) {
-                       exp[a] = ',';
-                       strcpy(&exp[a + 1], &exp[a + 2]);
+               if (!strncmp(ptr, "^c", 2)) {
+                       *ptr = ',';
+                       strcpy(ptr + 1], ptr + 2]);
                }
        }
 
@@ -1048,7 +1051,7 @@ int requires_string(struct citcmd *cptr, int ncomp)
        char buf[64];
 
        strcpy(buf, cptr->c_keys[ncomp - 1]);
-       for (a = 0; a < strlen(buf); ++a) {
+       for (a = 0; !IsEmptyStr(&buf[a]); ++a) {
                if (buf[a] == ':')
                        return (1);
        }
@@ -1579,7 +1582,7 @@ void look_for_ansi(void)
                        }
                } while (FD_ISSET(0, &rfds));
 
-               for (a = 0; a < strlen(abuf); ++a) {
+               for (a = 0; !IsEmptyStr(&abuf[a]); ++a) {
                        if ((abuf[a] == 27) && (abuf[a + 1] == '[')
                            && (abuf[a + 2] == '?')) {
                                enable_color = 1;
@@ -1596,7 +1599,7 @@ void keyopt(char *buf) {
        int i;
 
        color(DIM_WHITE);
-       for (i=0; i<strlen(buf); ++i) {
+       for (i=0; !IsEmptyStr(&buf[i]); ++i) {
                if (buf[i]=='<') {
                        pprintf("%c", buf[i]);
                        color(BRIGHT_MAGENTA);
@@ -1626,7 +1629,7 @@ char keymenu(char *menuprompt, char *menustring) {
        choices = num_tokens(menustring, '|');
 
        if (menuprompt != NULL) do_prompt = 1;
-       if (menuprompt != NULL) if (strlen(menuprompt)==0) do_prompt = 0;
+       if (menuprompt != NULL) if (IsEmptyStr(menuprompt)) do_prompt = 0;
 
        while (1) {
                if (display_prompt) {
@@ -1660,11 +1663,11 @@ char keymenu(char *menuprompt, char *menustring) {
 
                for (i=0; i<choices; ++i) {
                        extract_token(buf, menustring, i, '|', sizeof buf);
-                       for (c=1; c<strlen(buf); ++c) {
+                       for (c=1; !IsEmptyStr(&buf[c]); ++c) {
                                if ( (ch == tolower(buf[c]))
                                   && (buf[c-1]=='<')
                                   && (buf[c+1]=='>') ) {
-                                       for (a=0; a<strlen(buf); ++a) {
+                                       for (a=0; !IsEmptyStr(&buf[a]); ++a) {
                                                if ( (a!=(c-1)) && (a!=(c+1))) {
                                                        scr_putc(buf[a]);
                                                }
index 10c066a4802f85174f6addda74492f28a08c44b3..1ef2b979cfdcb00c39a2c25871fc118e1de8ae94 100644 (file)
@@ -126,7 +126,7 @@ void cmd_delf(char *filename)
                        ERROR + FILE_NOT_FOUND);
                return;
        }
-       for (a = 0; a < strlen(filename); ++a) {
+       for (a = 0; !IsEmptyStr(&filename[a]); ++a) {
                if (filename[a] == '/') {
                        filename[a] = '_';
                }
@@ -178,7 +178,7 @@ void cmd_movf(char *cmdbuf)
                return;
        }
 
-       for (a = 0; a < strlen(filename); ++a) {
+       for (a = 0; !IsEmptyStr(&filename[a]); ++a) {
                if (filename[a] == '/') {
                        filename[a] = '_';
                }
@@ -247,7 +247,7 @@ void cmd_netf(char *cmdbuf)
                return;
        }
 
-       for (a = 0; a < strlen(filename); ++a) {
+       for (a = 0; !IsEmptyStr(&filename[a]); ++a) {
                if (filename[a] == '/') {
                        filename[a] = '_';
                }
@@ -367,7 +367,7 @@ void cmd_open(char *cmdbuf)
                return;
        }
 
-       for (a = 0; a < strlen(filename); ++a) {
+       for (a = 0; !IsEmptyStr(&filename[a]); ++a) {
                if (filename[a] == '/') {
                        filename[a] = '_';
                }
@@ -433,7 +433,7 @@ void cmd_oimg(char *cmdbuf)
        } else if (!strcasecmp(filename, "_roompic_")) {
                assoc_file_name(pathname, sizeof pathname, &CC->room, ctdl_image_dir);
        } else {
-               for (a = 0; a < strlen(filename); ++a) {
+               for (a = 0; !IsEmptyStr(&filename[0]); ++a) {
                        filename[a] = tolower(filename[a]);
                        if (filename[a] == '/') {
                                filename[a] = '_';
@@ -485,7 +485,7 @@ void cmd_uopn(char *cmdbuf)
                return;
        }
 
-       for (a = 0; a < strlen(CC->upl_file); ++a) {
+       for (a = 0; !IsEmptyStr(&CC->upl_file[a]); ++a) {
                if (CC->upl_file[a] == '/') {
                        CC->upl_file[a] = '_';
                }
@@ -544,7 +544,7 @@ void cmd_uimg(char *cmdbuf)
 
        strcpy(CC->upl_path, "");
 
-       for (a = 0; a < strlen(basenm); ++a) {
+       for (a = 0; !IsEmptyStr(&basenm[a]); ++a) {
                basenm[a] = tolower(basenm[a]);
                if (basenm[a] == '/') {
                        basenm[a] = '_';
index 1bb6cd4e2bb8c29dc8a54b0c0076815291ba982e..afc97e964a37a8d0570d40380330f7ef112f6dd5 100644 (file)
@@ -100,7 +100,7 @@ char *html_to_ascii(char *inputmsg, int msglen, int screenwidth, int do_citaform
                if (!IsEmptyStr(inbuf)) {
 
                    /* Fold in all the spacing */
-                   for (i=0; i<strlen(inbuf); ++i) {
+                   for (i=0; !IsEmptyStr(&inbuf[i]); ++i) {
                        if (inbuf[i]==10) inbuf[i]=32;
                        if (inbuf[i]==13) inbuf[i]=32;
                        if (inbuf[i]==9) inbuf[i]=32;
@@ -109,12 +109,12 @@ char *html_to_ascii(char *inputmsg, int msglen, int screenwidth, int do_citaform
                                inbuf[i] = '?';
                        } */
                    }
-                   for (i=0; i<strlen(inbuf); ++i) {
+                   for (i=0; !IsEmptyStr(&inbuf[i]); ++i) {
                        while ((inbuf[i]==32)&&(inbuf[i+1]==32))
                                strcpy(&inbuf[i], &inbuf[i+1]);
                    }
 
-                   for (i=0; i<strlen(inbuf); ++i) {
+                   for (i=0; !IsEmptyStr(&inbuf[i]); ++i) {
 
                        ch = inbuf[i];
 
@@ -252,7 +252,7 @@ char *html_to_ascii(char *inputmsg, int msglen, int screenwidth, int do_citaform
                }
 
                /* Convert &; tags to the forbidden characters */
-               if (!IsEmptyStr(outbuf)) for (i=0; i<strlen(outbuf); ++i) {
+               if (!IsEmptyStr(outbuf)) for (i=0; !IsEmptyStr(&outbuf[i]); ++i) {
 
                        /* Character entity references */
                        if (!strncasecmp(&outbuf[i], "&nbsp;", 6)) {
@@ -458,7 +458,7 @@ char *html_to_ascii(char *inputmsg, int msglen, int screenwidth, int do_citaform
                do {
                        did_out = 0;
                        if (!IsEmptyStr(outbuf)) {
-                           for (i = 0; i<strlen(outbuf); ++i) {
+                           for (i = 0; !IsEmptyStr(&outbuf[i]); ++i) {
                                if ( (i<(screenwidth-2)) && (outbuf[i]=='\n')) {
 
                                        strncpy(&outptr[output_len],
index c4bfc9b51210b9ceeccec77037f3f304bc680883..ae8a6ceed7c0c31f1d170bff6492c4eadad2208c 100644 (file)
@@ -115,16 +115,17 @@ int CtdlHostAlias(char *fqdn) {
  */
 int fuzzy_match(struct ctdluser *us, char *matchstring) {
        int a;
+       long len;
 
        if ( (!strncasecmp(matchstring, "cit", 3)) 
           && (atol(&matchstring[3]) == us->usernum)) {
                return 0;
        }
 
-
-       for (a=0; a<strlen(us->fullname); ++a) {
+       len = strlen(matchstring);
+       for (a=0; !IsEmptyStr(&us->fullname[a]); ++a) {
                if (!strncasecmp(&us->fullname[a],
-                  matchstring, strlen(matchstring))) {
+                  matchstring, len)) {
                        return 0;
                }
        }
@@ -552,7 +553,7 @@ void directory_key(char *key, char *addr) {
        int i;
        int keylen = 0;
 
-       for (i=0; i<strlen(addr); ++i) {
+       for (i=0; !IsEmptyStr(&addr[i]); ++i) {
                if (!isspace(addr[i])) {
                        key[keylen++] = tolower(addr[i]);
                }
index 619194cf0e28c676339f559074bb0045a9c0591e..ac8d6e9c5431c0ede002bf8ac0885bb5eaefa5fc 100644 (file)
@@ -1274,7 +1274,7 @@ void ical_freebusy(char *who) {
                strcat(buf, "@");
                strcat(buf, config.c_fqdn);
        }
-       for (i=0; i<strlen(buf); ++i) {
+       for (i=0; !IsEmptyStr(&buf[i]); ++i) {
                if (buf[i]==' ') buf[i] = '_';
        }
        icalcomponent_add_property(fb, icalproperty_new_organizer(buf));
index d13c84277fa3d1f215005e3a5da595404c0bd448..0897c0beaa4f78ccf525e52c7acf18425352a32b 100644 (file)
@@ -510,13 +510,15 @@ void imap_strip_headers(char *section) {
        if (!strncasecmp(which_fields, "HEADER.FIELDS.NOT", 17))
                headers_not = 1;
 
-       for (i=0; i<strlen(which_fields); ++i) {
+       for (i=0; !IsEmptyStr(&which_fields[i]); ++i) {
                if (which_fields[i]=='(')
                        strcpy(which_fields, &which_fields[i+1]);
        }
-       for (i=0; i<strlen(which_fields); ++i) {
-               if (which_fields[i]==')')
+       for (i=0; !IsEmptyStr(&which_fields[i]); ++i) {
+               if (which_fields[i]==')') {
                        which_fields[i] = 0;
+                       break;
+               }
        }
        num_parms = imap_parameterize(parms, which_fields);
 
@@ -1084,7 +1086,7 @@ void imap_handle_macros(char *str) {
        int i;
        int nest = 0;
 
-       for (i=0; i<strlen(str); ++i) {
+       for (i=0; !IsEmptyStr(&str[i]); ++i) {
                if (str[i]=='(') ++nest;
                if (str[i]=='[') ++nest;
                if (str[i]=='<') ++nest;
@@ -1125,11 +1127,11 @@ void imap_handle_macros(char *str) {
 int imap_extract_data_items(char **argv, char *items) {
        int num_items = 0;
        int nest = 0;
-       int i, initial_len;
+       int i;
        char *start;
 
        /* Convert all whitespace to ordinary space characters. */
-       for (i=0; i<strlen(items); ++i) {
+       for (i=0; !IsEmptyStr(&items[i]); ++i) {
                if (isspace(items[i])) items[i]=' ';
        }
 
index e7b52710eee88ae5aaec167fb41e18c265d456c3..4c78076cf45fc93abb5cc0e2069eca5f1fb0483c 100644 (file)
@@ -250,7 +250,7 @@ void imap_list(int num_parms, char *parms[])
                selection_left = 2;
                paren_nest = 0;
                for (i=2; i<num_parms; ++i) {
-                       for (j=0; j<strlen(parms[i]); ++j) {
+                       for (j=0; !IsEmptyStr(&parms[i][j]); ++j) {
                                if (parms[i][j] == '(') ++paren_nest;
                                if (parms[i][j] == ')') --paren_nest;
                        }
@@ -314,7 +314,7 @@ void imap_list(int num_parms, char *parms[])
                extended_list_in_use = 1;
                paren_nest = 0;
                for (i=patterns_left; i<num_parms; ++i) {
-                       for (j=0; j<strlen(parms[i]); ++j) {
+                       for (j=0; !IsEmptyStr(&parms[i][j]); ++j) {
                                if (parms[i][j] == '(') ++paren_nest;
                                if (parms[i][j] == ')') --paren_nest;
                        }
@@ -351,7 +351,7 @@ void imap_list(int num_parms, char *parms[])
                extended_list_in_use = 1;
                paren_nest = 0;
                for (i=return_left; i<num_parms; ++i) {
-                       for (j=0; j<strlen(parms[i]); ++j) {
+                       for (j=0; !IsEmptyStr(&parms[i][j]); ++j) {
                                if (parms[i][j] == '(') ++paren_nest;
                                if (parms[i][j] == ')') --paren_nest;
                        }
index 54babbf205018ef25149e0228e7107a1a4103df0..b51cc7ee1d7f5b42639f7ab203514d10ed37c046 100644 (file)
@@ -258,7 +258,7 @@ void imap_print_instant_messages(void) {
                free(ptr);
                ptr = holdptr;
 
-               for (i=0; i<strlen(dumpomatic); ++i) {
+               for (i=0; !IsEmptyStr(&dumpomatic[i]); ++i) {
                        if (!isprint(dumpomatic[i])) dumpomatic[i] = ' ';
                        if (dumpomatic[i]=='\\') dumpomatic[i]='/';
                        if (dumpomatic[i]=='\"') dumpomatic[i]='\'';
index 4298610f1b19353e06fb86ecd3f99707ab8accff..b73bb8b8e47bea5490b6f5908c12c9b3ac957bc9 100644 (file)
@@ -125,7 +125,7 @@ int utf8_getc(char** ptr)
        loop:
                if (r < 0x80)
                {
-                       *ptr = p;
+                       *ptr = (char*) p;
                        v = r;
                        break;
                }
@@ -146,7 +146,7 @@ int utf8_getc(char** ptr)
                                m<<=5;
                        } while (r & 0x40);
                        
-                       *ptr = p;
+                       *ptr = (char*)p;
 
                        v &= ~m;
                        break;
@@ -376,7 +376,7 @@ void imap_strout(char *buf)
 {
        int i;
        int is_literal = 0;
-       int len;
+       long len;
 
        if (buf == NULL) {      /* yeah, we handle this */
                cprintf("NIL");
@@ -390,7 +390,7 @@ void imap_strout(char *buf)
        }
 
        if (is_literal) {
-               cprintf("{%ld}\r\n%s", (long)strlen(buf), buf);
+               cprintf("{%ld}\r\n%s", len, buf);
        } else {
                cprintf("\"%s\"", buf);
        }
@@ -632,7 +632,7 @@ int imap_is_message_set(char *buf)
        if (!strcasecmp(buf, "ALL"))
                return (1);     /* macro?  why?  */
 
-       for (i = 0; i < strlen(buf); ++i) {     /* now start the scan */
+       for (i = 0; !IsEmptyStr(&buf[i]); ++i) {        /* now start the scan */
                if (
                           (!isdigit(buf[i]))
                           && (buf[i] != ':')
index 41c57f9d9f5dc315cbc763efb587e45db56df3d7..06cf124e1d284e4aeaf89623dc8a74001e8189b1 100644 (file)
@@ -82,10 +82,13 @@ void CtdlCreateLdapRoot(void) {
 
        /* We just want the top-level dc, not the whole hierarchy */
        strcpy(topdc, config.c_ldap_base_dn);
-       for (i=0; i<strlen(topdc); ++i) {
-               if (topdc[i] == ',') topdc[i] = 0;
+       for (i=0; !IsEmptyStr(&topdc[i]); ++i) {
+               if (topdc[i] == ',') {
+                       topdc[i] = 0;
+                       break;
+               }
        }
-       for (i=0; i<strlen(topdc); ++i) {
+       for (i=0; !IsEmptyStr(&topdc[i]); ++i) {
                if (topdc[i] == '=') strcpy(topdc, &topdc[i+1]);
        }
 
index 8885e5d812360db07701ea09186de91735f830e5..d2ffaed84436582ffd5d9afecfaecfae086ab855 100644 (file)
@@ -454,7 +454,7 @@ void network_deliver_digest(struct SpoolControl *sc) {
        snprintf(buf, sizeof buf, "[%s]", CC->room.QRname);
        msg->cm_fields['U'] = strdup(buf);
        sprintf(buf, "room_%s@%s", CC->room.QRname, config.c_fqdn);
-       for (i=0; i<strlen(buf); ++i) {
+       for (i=0; !IsEmptyStr(&buf[i]); ++i) {
                if (isspace(buf[i])) buf[i]='_';
                buf[i] = tolower(buf[i]);
        }
@@ -612,7 +612,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                        snprintf(msg->cm_fields['R'], 256,
                                "room_%s@%s", CC->room.QRname,
                                config.c_fqdn);
-                       for (i=0; i<strlen(msg->cm_fields['R']); ++i) {
+                       for (i=0; !IsEmptyStr(&msg->cm_fields['R'][i]); ++i) {
                                if (isspace(msg->cm_fields['R'][i])) {
                                        msg->cm_fields['R'][i] = '_';
                                }
@@ -702,7 +702,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                                snprintf(msg->cm_fields['F'], SIZ,
                                        "room_%s@%s", CC->room.QRname,
                                        config.c_fqdn);
-                               for (i=0; i<strlen(msg->cm_fields['F']); ++i) {
+                               for (i=0; !IsEmptyStr(&msg->cm_fields['F'][i]); ++i) {
                                        if (isspace(msg->cm_fields['F'][i])) {
                                                msg->cm_fields['F'][i] = '_';
                                        }
@@ -973,7 +973,7 @@ void network_spoolout_room(char *room_to_spool) {
        /* If we wrote a digest, deliver it and then close it */
        snprintf(buf, sizeof buf, "room_%s@%s",
                CC->room.QRname, config.c_fqdn);
-       for (i=0; i<strlen(buf); ++i) {
+       for (i=0; !IsEmptyStr(&buf[i]); ++i) {
                buf[i] = tolower(buf[i]);
                if (isspace(buf[i])) buf[i] = '_';
        }
index 374cb57eba25b7cc5a25005011898b8706bfe237..242fa3e5a358cf794e73247a321a7e8cff2194de 100644 (file)
@@ -76,9 +76,10 @@ int serv_notes_beforesave(struct CtdlMessage *msg)
        while (--a > 0) {
                if (!strncasecmp(p, "X-KOrg-Note-Id: ", 16)) {  /* Found it */
                        safestrncpy(uuid, p + 16, sizeof(uuid));
-                       for (i = 0; i<strlen(uuid); ++i) {
+                       for (i = 0; !IsEmptyStr(&uuid[i]); ++i) {
                                if ( (uuid[i] == '\r') || (uuid[i] == '\n') ) {
                                        uuid[i] = 0;
+                                       break;
                                }
                        }
 
index 304344694bdc16b4e96604453f4993d12293f821..b7da263ec3c1d5992beabebe0cbdff2d2b85f6b7 100644 (file)
@@ -958,7 +958,7 @@ void smtp_try(const char *key, const char *addr, int *status,
                if (!strncasecmp(buf, "From:", 5)) {
                        safestrncpy(mailfrom, &buf[5], sizeof mailfrom);
                        striplt(mailfrom);
-                       for (i=0; i<strlen(mailfrom); ++i) {
+                       for (i=0; !IsEmptyStr(&mailfrom[i]); ++i) {
                                if (!isprint(mailfrom[i])) {
                                        strcpy(&mailfrom[i], &mailfrom[i+1]);
                                        i=0;
@@ -968,7 +968,7 @@ void smtp_try(const char *key, const char *addr, int *status,
                        /* Strip out parenthesized names */
                        lp = (-1);
                        rp = (-1);
-                       for (i=0; i<strlen(mailfrom); ++i) {
+                       for (i=0; !IsEmptyStr(&mailfrom[i]); ++i) {
                                if (mailfrom[i] == '(') lp = i;
                                if (mailfrom[i] == ')') rp = i;
                        }
@@ -979,7 +979,7 @@ void smtp_try(const char *key, const char *addr, int *status,
                        /* Prefer brokketized names */
                        lp = (-1);
                        rp = (-1);
-                       for (i=0; i<strlen(mailfrom); ++i) {
+                       for (i=0; !IsEmptyStr(&mailfrom[i]); ++i) {
                                if (mailfrom[i] == '<') lp = i;
                                if (mailfrom[i] == '>') rp = i;
                        }
index 8380cec4d017b995c2d2b337a8d826d2fcd2b0a6..a77eb49208288ee52fc6af46eb4cbe3c5bad6e5b 100644 (file)
@@ -587,7 +587,7 @@ void artv_import_visit(void) {
 
        client_getln(buf, sizeof buf);
        vbuf.v_lastseen = atol(buf);
-       for (i=0; i<strlen(buf); ++i) if (!isdigit(buf[i])) is_textual_seen = 1;
+       for (i=0; !IsEmptyStr(&buf[i]); ++i) if (!isdigit(buf[i])) is_textual_seen = 1;
        if (is_textual_seen)    strcpy(vbuf.v_seen, buf);
 
        client_getln(vbuf.v_answered, sizeof vbuf.v_answered);
index 311b73dfeb347df9e3cfa1ae24608cf78071def1..99ed9026a6db0f55a5228aca77cdcbc93e95aaa6 100644 (file)
@@ -404,7 +404,7 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) {
                sprintf(buf, "http://%s/%s.vfb",
                        config.c_fqdn,
                        usbuf.fullname);
-               for (i=0; i<strlen(buf); ++i) {
+               for (i=0; !IsEmptyStr(&buf[i]); ++i) {
                        if (buf[i] == ' ') buf[i] = '_';
                }
                vcard_set_prop(v, "FBURL;PREF", buf, 0);
@@ -675,7 +675,7 @@ void cmd_regi(char *argbuf) {
                if (a==2) strcpy(tmpcity, buf);
                if (a==3) strcpy(tmpstate, buf);
                if (a==4) {
-                       for (c=0; c<strlen(buf); ++c) {
+                       for (c=0; !IsEmptyStr(&buf[c]); ++c) {
                                if ((buf[c]>='0') && (buf[c]<='9')) {
                                        b = strlen(tmpzip);
                                        tmpzip[b] = buf[c];
@@ -789,7 +789,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
        v = vcard_new();
        if (v == NULL) return;
        sprintf(buf, "%s@%s", usbuf->fullname, config.c_fqdn);
-       for (i=0; i<strlen(buf); ++i) {
+       for (i=0; !IsEmptyStr(&buf[i]); ++i) {
                if (buf[i] == ' ') buf[i] = '_';
        }
        vcard_add_prop(v, "fn", usbuf->fullname);
@@ -1178,7 +1178,7 @@ struct vCard *vcard_new_from_rfc822_addr(char *addr) {
        vcard_set_prop(v, "email;internet", email, 0);
 
        snprintf(uid, sizeof uid, "collected: %s %s@%s", name, user, node);
-       for (i=0; i<strlen(uid); ++i) {
+       for (i=0; !IsEmptyStr(&uid[i]); ++i) {
                if (isspace(uid[i])) uid[i] = '_';
                uid[i] = tolower(uid[i]);
        }
index 961e9acb8f111cb8591193079d00f767593555f8..95fe5396d57d82c18fcd88e5134c4ce7a9107d29 100644 (file)
@@ -1692,7 +1692,7 @@ int CtdlOutputPreLoadedMsg(
                }
        }
 
-       for (i=0; i<strlen(suser); ++i) {
+       for (i=0; !IsEmptyStr(&suser[i]); ++i) {
                suser[i] = tolower(suser[i]);
                if (!isalnum(suser[i])) suser[i]='_';
        }
@@ -1715,7 +1715,7 @@ int CtdlOutputPreLoadedMsg(
                else if (!is_room_aide() && (TheMessage->cm_anon_type == MES_ANONOPT)) {
                        cprintf("From: \"anonymous\" <x@x.org>%s", nl);
                }
-               else if (strlen(fuser) > 0) {
+               else if (!IsEmptyStr(fuser)) {
                        cprintf("From: \"%s\" <%s>%s", luser, fuser, nl);
                }
                else {
@@ -2385,7 +2385,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        if (msg->cm_fields['P'] == NULL) {
                if (msg->cm_fields['A'] != NULL) {
                        msg->cm_fields['P'] = strdup(msg->cm_fields['A']);
-                       for (a=0; a<strlen(msg->cm_fields['P']); ++a) {
+                       for (a=0; !IsEmptyStr(&msg->cm_fields['P'][a]); ++a) {
                                if (isspace(msg->cm_fields['P'][a])) {
                                        msg->cm_fields['P'][a] = ' ';
                                }
@@ -3140,7 +3140,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) {
        ret->recptypes_magic = RECPTYPES_MAGIC;
 
        /* Change all valid separator characters to commas */
-       for (i=0; i<strlen(recipients); ++i) {
+       for (i=0; !IsEmptyStr(&recipients[i]); ++i) {
                if ((recipients[i] == ';') || (recipients[i] == '|')) {
                        recipients[i] = ',';
                }
@@ -3171,7 +3171,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) {
                mailtype = alias(this_recp);
                mailtype = alias(this_recp);
                mailtype = alias(this_recp);
-               for (j=0; j<=strlen(this_recp); ++j) {
+               for (j=0; !IsEmptyStr(&this_recp[j]); ++j) {
                        if (this_recp[j]=='_') {
                                this_recp_cooked[j] = ' ';
                        }
index 159488e1e0add3f0766d6cadb5afbad7578e5ea2..fb3229a347cd08ec265cc8d7569532c0d532bc6a 100644 (file)
@@ -282,7 +282,6 @@ void b_putroom(struct ctdlroom *qrbuf, char *room_name)
        char lowercase_name[ROOMNAMELEN];
        char *aptr, *bptr;
        long len;
-       int a;
 
        aptr = room_name;
        bptr = lowercase_name;
index 1226455c3afd25202991f9f98060dbba4870e8f4..649b21a9909479b86d210feb2c5030b49c7fac87 100644 (file)
@@ -1057,7 +1057,7 @@ void entroom(CtdlIPC *ipc)
        if (IsEmptyStr(new_room_name)) {
                return;
        }
-       for (a = 0; a < strlen(new_room_name); ++a) {
+       for (a = 0; !IsEmptyStr(&new_room_name[a]); ++a) {
                if (new_room_name[a] == '|') {
                        new_room_name[a] = '_';
                }
@@ -1084,7 +1084,7 @@ void entroom(CtdlIPC *ipc)
        new_room_type = b - 1;
        if (new_room_type == 2) {
                newprompt("Enter a room password: ", new_room_pass, 9);
-               for (a = 0; a < strlen(new_room_pass); ++a)
+               for (a = 0; !IsEmptyStr(&new_room_pass[a]); ++a)
                        if (new_room_pass[a] == '|')
                                new_room_pass[a] = '_';
        } else {
index cf627a5294335d4aaa5bd544ef7f681d23ea8d5b..6e509e3350c8d95602aec2095eeb12b3755fcbd4 100644 (file)
@@ -84,7 +84,7 @@ void hit_any_key(CtdlIPC *ipc) {      /* hit any key to continue */
        color(COLOR_POP);
        stty_ctdl(0);
        b=inkey();
-       for (a=0; a<strlen(ipc->ServInfo.moreprompt); ++a)
+       for (a=0; !IsEmptyStr(&ipc->ServInfo.moreprompt[0]); ++a)
                scr_putc(' ');
        scr_putc(13);
        stty_ctdl(1);
@@ -345,10 +345,11 @@ int getstring(FILE *fp, char *string)
 
 /* Searches for patn in search string */
 int pattern(char *search, char *patn) {
-       int a,b;
-
-       for (a=0; a<strlen(search); ++a) {
-               b=strncasecmp(&search[a],patn,strlen(patn));
+       int a,b,len;
+       
+       len = strlen(patn);
+       for (a=0; !IsEmptyStr(&search[a]); ++a) {
+               b=strncasecmp(&search[a],patn,len);
                if (b==0) return(b);
        }
        return(-1);
@@ -362,7 +363,7 @@ void strproc(char *string)
        if (IsEmptyStr(string)) return;
 
        /* Convert non-printable characters to blanks */
-       for (a=0; a<strlen(string); ++a) {
+       for (a=0; !IsEmptyStr(&string[a]); ++a) {
                if (string[a]<32) string[a]=32;
                if (string[a]>126) string[a]=32;
        }
@@ -451,7 +452,7 @@ void locate_host(CtdlIPC* ipc, char *hbuf)
        pclose(who);
 
        b = 0;
-       for (a=0; a<strlen(buf); ++a) {
+       for (a=0; !IsEmptyStr(&buf[a]); ++a) {
                if ((buf[a]=='(')||(buf[a]==')')) ++b;
        }
        if (b<2) {
index fca08555df05aad015f6f277386fdecf4c610d2c..349c4e35017df53b528e260969c500aa04c53056 100644 (file)
@@ -327,7 +327,7 @@ void upload(CtdlIPC *ipc, int c)
        else
                newprompt("Enter filename: ", flnm, 15);
 
-       for (a = 0; a < strlen(flnm); ++a)
+       for (a = 0; !IsEmptyStr(&flnm[0]); ++a)
                if ((flnm[a] == '/') || (flnm[a] == '\\') || (flnm[a] == '>')
                    || (flnm[a] == '?') || (flnm[a] == '*')
                    || (flnm[a] == ';') || (flnm[a] == '&'))
@@ -592,7 +592,7 @@ void list_bio(CtdlIPC *ipc)
                pprintf("%s\n", buf);
                return;
        }
-       while (resp && strlen(resp)) {
+       while (resp && !IsEmptyStr(resp)) {
                extract_token(buf, resp, 0, '\n', sizeof buf);
                remove_token(resp, 0, '\n');
                if ((pos + strlen(buf) + 5) > screenwidth) {
index b88ee9913348548835477a6ed4048b19172ba058..a3ebffc19142e7bb6d52288160b0011f25df099d 100644 (file)
@@ -29,7 +29,7 @@ void strproc(char *string)
        if (IsEmptyStr(string)) return;
 
        /* Convert non-printable characters to blanks */
-       for (a=0; a<strlen(string); ++a) {
+       for (a=0; !IsEmptyStr(&string[a]); ++a) {
                if (string[a]<32) string[a]=32;
                if (string[a]>126) string[a]=32;
        }
@@ -41,7 +41,7 @@ void strproc(char *string)
                string[strlen(string)-1]=0;
 
        /* Remove double blanks */
-       for (a=0; a<strlen(string); ++a) {
+       for (a=0; !IsEmptyStr(&string[a]); ++a) {
                if ((string[a]==32)&&(string[a+1]==32)) {
                        strcpy(&string[a],&string[a+1]);
                        a=0;
@@ -49,7 +49,7 @@ void strproc(char *string)
        }
 
        /* remove characters which would interfere with the network */
-       for (a=0; a<strlen(string); ++a) {
+       for (a=0; !IsEmptyStr(&string[a]); ++a) {
                while (string[a]=='!') strcpy(&string[a],&string[a+1]);
                while (string[a]=='@') strcpy(&string[a],&string[a+1]);
                while (string[a]=='_') strcpy(&string[a],&string[a+1]);
@@ -83,7 +83,7 @@ int getstring(FILE *fp, char *string)
                        string[a-1]=0;
                } while(string[0]=='#');
        return(strlen(string));
-       }
+}
 
 
 /*
@@ -91,9 +91,11 @@ int getstring(FILE *fp, char *string)
  */ 
 int pattern2(char *search, char *patn)
 {
-       int a;
-       for (a=0; a<strlen(search); ++a) {
-               if (!strncasecmp(&search[a],patn,strlen(patn))) return(a);
+       int a, len;
+       
+       len = strlen(patn);
+       for (a=0; !IsEmptyStr(&search[a]); ++a) {
+               if (!strncasecmp(&search[a],patn, len)) return(a);
                }
        return(-1);
        }