[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RP] select patch
From: |
Johannes Altmanninger |
Subject: |
Re: [RP] select patch |
Date: |
Thu, 19 Jun 2014 19:07:12 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
Hi Jeff, Bernhard,
I rewrote find_window_name() trying to incorporate your suggestions:
The second argument to find_window_name() is a bitmask that defines the
match_type
By setting the cmplen beforehand I can fit everything in a single loop
Here is what I came up with (It compiled without warnings but I did not
test it)
What do you think, is something like this feasible?
(the case conversion looks a bit awkwark)
// MATCH means exact match
#define MATCH 0x0000
#define MATCH_PREFIX 0x0001
#define MATCH_IGNORECASE 0x0002
#define MATCH_PREFIX_IGNORECASE 0x0004
#define MAX_WINDOW_NAME_LENGTH 42
#include <ctype.h>
rp_window *
find_window_name (char *name, int match_type)
{
int cmplen, i;
if (MATCH_PREFIX & match_type)
cmplen = strnlen(name, MAX_WINDOW_NAME_LENGTH);
else
cmplen = MAX_WINDOW_NAME_LENGTH;
if(MATCH_IGNORECASE & match_type)
for(i=0; i<strlen(name); i++)
name[i] = toupper (name[i]);
rp_window_elem *cur;
char *curname;
list_for_each_entry (cur, &rp_current_group->mapped_windows, node)
{
curname = window_name(cur->win);
if(MATCH_IGNORECASE & match_type)
for(i=0; i<strlen(curname); i++)
curname[i] = toupper (curname[i]);
if (!strncmp (name, curname, cmplen))
{
return cur->win;
}
}
/* didn't find it */
return NULL;
}
- Re: [RP] select patch, (continued)
- Re: [RP] select patch, Johannes Altmanninger, 2014/06/20
- Re: [RP] select patch, Peter Pentchev, 2014/06/20
- Re: [RP] select patch, Johannes Altmanninger, 2014/06/20
- Re: [RP] select patch, Jeff Abrahamson, 2014/06/23
- Re: [RP] select patch, Johannes Altmanninger, 2014/06/24
- Re: [RP] select patch, Jeff Abrahamson, 2014/06/25
- Re: [RP] select patch, Jeff Abrahamson, 2014/06/25
- Re: [RP] select patch, Johannes Altmanninger, 2014/06/26
Re: [RP] select patch, Bernhard R. Link, 2014/06/19