# HG changeset patch # User Matti Hamalainen # Date 1337824832 -10800 # Node ID c345a8efb1d4287891b662b7489ca3144fe23afc # Parent 932829a556c79ec677ff157cd69ce4cccc5fdbb1 Rename another function. diff -r 932829a556c7 -r c345a8efb1d4 nnchat.c --- a/nnchat.c Thu May 24 04:59:49 2012 +0300 +++ b/nnchat.c Thu May 24 05:00:32 2012 +0300 @@ -221,6 +221,17 @@ } +char * str_trim_left(char *buf) +{ + while (*buf != 0 && th_isspace(*buf)) buf++; + return buf; +} + +int compareUsername(const void *s1, const void *s2) +{ + return th_strcasecmp((char *) s1, (char *) s2); +} + nn_window_t *findWindow(const char *id) { int i; @@ -915,7 +926,7 @@ { /* Change color */ int tmpInt; - if ((tmpInt = th_get_hex_triplet(trimLeft(buf + 7))) < 0) + if ((tmpInt = th_get_hex_triplet(str_trim_left(buf + 7))) < 0) { printMsgQ(currWin, "Invalid color value '%s'\n", buf+7); return 1; @@ -927,7 +938,7 @@ } else if (!th_strncasecmp(buf, "/ignore", 7)) { - char *name = trimLeft(buf + 7); + char *name = str_trim_left(buf + 7); if (strlen(name) > 0) { /* Add or remove someone to/from ignore */ @@ -966,7 +977,7 @@ } else if (!th_strncasecmp(buf, "/query", 6)) { - char *name = trimLeft(buf + 6); + char *name = str_trim_left(buf + 6); if (strlen(name) > 0) { nn_user_t *user = nn_user_find(nnUsers, nn_username_encode(name)); @@ -990,7 +1001,7 @@ else if (!th_strncasecmp(buf, "/win", 4)) { /* Change color */ - char *tmp = trimLeft(buf + 4); + char *tmp = str_trim_left(buf + 4); if (strlen(tmp) > 0) { int val = atoi(tmp); @@ -1014,7 +1025,7 @@ } else if (!th_strncasecmp(buf, "/close", 6)) { - char *name = trimLeft(buf + 6); + char *name = str_trim_left(buf + 6); if (strlen(name) > 0) { nn_window_t *win = findWindow(name); @@ -1058,7 +1069,7 @@ else if (!th_strncasecmp(buf, "/w ", 3)) { /* Open given username's profile via firefox in a new tab */ - char *name = trimLeft(buf + 3); + char *name = str_trim_left(buf + 3); printMsg(currWin, "Opening profile for: '%s'\n", name); @@ -1383,7 +1394,7 @@ for (pos = strlen(tmpBuf) - 1; pos > 0 && (tmpBuf[pos] == '\n' || tmpBuf[pos] == '\r' || th_isspace(tmpBuf[pos])); pos--) tmpBuf[pos] = 0; - ptr = trimLeft(tmpBuf); + ptr = str_trim_left(tmpBuf); if (allowEmpty || strlen(ptr) > 0) return th_strdup(ptr);