about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--dwm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/dwm.c b/dwm.c
index c7fd99b..29c7b64 100644
--- a/dwm.c
+++ b/dwm.c
@@ -874,7 +874,7 @@ getmon(Window w) {
 			return m;
 	if((c = getclient(w)))
 		return c->mon;
-	return selmon;
+	return mons;
 }
 
 Monitor *
@@ -893,7 +893,7 @@ getmonxy(int x, int y) {
 	for(m = mons; m; m = m->next)
 		if(INRECT(x, y, m->wx, m->wy, m->ww, m->wh))
 			return m;
-	return selmon;
+	return mons;
 }
 
 Bool
E. Dickey <dickey@invisible-island.net> 2018-03-03 15:23:54 +0000 committer Thomas E. Dickey <dickey@invisible-island.net> 2018-03-03 15:23:54 +0000 snapshot of project "lynx", label v2-8-9dev_16m' href='/ingrix/lynx-snapshots/commit/src/LYHash.c?id=f9d18278c5e94ae35d232412351f23de45d5c9c4'>f9d18278 ^
f06f1fc3 ^


f06f1fc3 ^
82107ab8 ^

f06f1fc3 ^
8cffae83 ^
f9d18278 ^

f06f1fc3 ^
f9d18278 ^



f06f1fc3 ^
f9d18278 ^




f06f1fc3 ^

82107ab8 ^




f06f1fc3 ^
82107ab8 ^



f06f1fc3 ^
82107ab8 ^

f9d18278 ^
82107ab8 ^





f06f1fc3 ^
82107ab8 ^





8cffae83 ^
82107ab8 ^







f9d18278 ^
82107ab8 ^
f9d18278 ^
82107ab8 ^

f06f1fc3 ^


82107ab8 ^
f9d18278 ^
2c91be61 ^


82107ab8 ^
f9d18278 ^

82107ab8 ^
f06f1fc3 ^
f9d18278 ^




82107ab8 ^
f06f1fc3 ^

8cffae83 ^




























f06f1fc3 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  
                                                         



                                                     
                     


                    
                    
                      


                      
                            

                                                                 
 
                      

                    
 



                                                               
 




                                         

 




                                                                             
 



                       
 

                                 
 





                                                                             
 





                                                             
                     







                                                                                    
            
                                         
     

                                                            


                
                                     
 


                               
                           

 
                                                              
 




                                                  
                           

 




























                                                       
                            
/*
 * $LynxId: LYHash.c,v 1.38 2018/03/10 01:50:19 tom Exp $
 *
 * A hash table for the (fake) CSS support in Lynx-rp
 * (c) 1996 Rob Partington
 * rewritten 1997 by Klaus Weide.
 * rewritten 2018 -TD
 */
#include <LYHash.h>
#include <LYUtils.h>
#include <LYLeaks.h>
#include <LYStrings.h>

#ifdef USE_COLOR_STYLE

#define HASH_SIZE CSHASHSIZE
#define HASH_TYPE     int
#define HASH_OF(h, v) ((HASH_TYPE)((h) * 3 + UCH(v)) % HASH_SIZE)

static int count_bump;
static size_t limit;
static char *buffer;

static char *get_buffer(size_t need)
{
    if (++need > limit) {
	char *test = realloc(buffer, (limit = (1 + need) * 2));

	if (test == 0)
	    outofmem(__FILE__, "LYHash");
	buffer = test;
    }
    return buffer;
}

/*
 * This is the same algorithm as the private anchor_hash() in HTAnchor.c, but
 * with a different value for HASH_SIZE.
 */
static HASH_TYPE cs_hash(const char *string)
{
    HASH_TYPE hash = 0;
    HASH_TYPE best, n;
    bucket *data;
    const char *p;

    for (p = string; *p; p++)
	hash = HASH_OF(hash, *p);

    /*
     * The computed hash-code is only a starting point.  Check for collision.
     */
    best = hash;
    for (n = 0; n < HASH_SIZE; n++) {
	int nn = (n + hash) % HASH_SIZE;

	data = &hashStyles[nn];
	if (data->name == 0 || !strcmp(string, data->name)) {
	    best = nn;
	    hash = nn;
	    break;
	}
	++count_bump;
    }
    data = &hashStyles[best];
    if (data->name != 0) {
	if (strcmp(string, data->name)) {
	    CTRACE_STYLE((tfp, "cs_hash(%s) overwriting %d\n", string, data->name));
	    FREE(data->name);
	    StrAllocCopy(data->name, string);
	}
    } else {
	StrAllocCopy(data->name, string);
    }

    CTRACE_STYLE((tfp, "cs_hash(%s) = %d\n", string, hash));
    return hash;
}

int color_style_1(const char *string)
{
    get_buffer(strlen(string));
    strcpy(buffer, string);
    LYLowerCase(buffer);
    return cs_hash(buffer);
}

int color_style_3(const char *p, const char *q, const char *r)
{
    get_buffer(strlen(p) + strlen(q) + strlen(r));
    strcpy(buffer, p);
    strcat(buffer, q);
    strcat(buffer, r);
    LYLowerCase(buffer);
    return cs_hash(buffer);
}

void report_hashStyles(void)
{
    int i;
    int count_name = 0;
    int count_used = 0;

    for (i = 0; i < CSHASHSIZE; i++) {
	count_name += (hashStyles[i].name != 0);
	count_used += (hashStyles[i].used != 0);
    }
    CTRACE((tfp, "Style hash:\n"));
    CTRACE((tfp, "%5d names allocated\n", count_name));
    CTRACE((tfp, "%5d buckets used\n", count_used));
    CTRACE((tfp, "%5d hash collisions\n", count_bump));
}

void free_hashStyles(void)
{
    int i;

    for (i = 0; i < CSHASHSIZE; i++) {
	FREE(hashStyles[i].name);
	hashStyles[i].used = FALSE;
    }
    FREE(buffer);
    limit = 0;
    count_bump = 0;
}

#endif /* USE_COLOR_STYLE */