Merge branch 'Numeromancer-master' into xft-port
* Numeromancer-master:
  Avoid compiler warning about ignore return from write.
  On input, ignore % w/o a { after.
  Allow colors in the form #RRGGBB (ie w/o alpha).
			
			
This commit is contained in:
		
							
								
								
									
										22
									
								
								bar.c
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								bar.c
									
									
									
									
									
								
							| @@ -1,4 +1,5 @@ | |||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
|  | #include <stddef.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| @@ -289,7 +290,11 @@ parse_color (const char *str, char **end, const uint32_t def) | |||||||
|         unsigned int g = (tmp&0x0000ff00) >> 8; |         unsigned int g = (tmp&0x0000ff00) >> 8; | ||||||
|         unsigned int b = (tmp&0x000000ff); |         unsigned int b = (tmp&0x000000ff); | ||||||
|  |  | ||||||
|         if (a) { |         ptrdiff_t len = *end - str; | ||||||
|  |         if (len == 8) { | ||||||
|  |             if (a == 0) { | ||||||
|  |                 r = g = b = 0; | ||||||
|  |             } else { | ||||||
|                 r = (r * 255) / a; |                 r = (r * 255) / a; | ||||||
|                 g = (g * 255) / a; |                 g = (g * 255) / a; | ||||||
|                 b = (b * 255) / a; |                 b = (b * 255) / a; | ||||||
| @@ -298,11 +303,11 @@ parse_color (const char *str, char **end, const uint32_t def) | |||||||
|                 if (r > 255) r = 255; |                 if (r > 255) r = 255; | ||||||
|                 if (g > 255) g = 255; |                 if (g > 255) g = 255; | ||||||
|                 if (b > 255) b = 255; |                 if (b > 255) b = 255; | ||||||
|         } else { |             } | ||||||
| 			 |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return a << 24 | r << 16 | g << 8 | b; |         uint32_t c = a << 24 | r << 16 | g << 8 | b; | ||||||
|  |         return c; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* Actual color name, resolve it */ |     /* Actual color name, resolve it */ | ||||||
| @@ -490,7 +495,8 @@ parse (char *text) | |||||||
|         if (*p == '\0' || *p == '\n') |         if (*p == '\0' || *p == '\n') | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
|         if (*p == '%' && p++ && *p == '{' && (end = strchr(p++, '}'))) { |         if (*p == '%' && *(p+1) == '{' && (end = strchr(p+2, '}'))) { | ||||||
|  |             p += 2; | ||||||
|             while (p < end) { |             while (p < end) { | ||||||
|                 while (isspace(*p)) |                 while (isspace(*p)) | ||||||
|                     p++; |                     p++; | ||||||
| @@ -1328,8 +1334,10 @@ main (int argc, char **argv) | |||||||
|                                 area_t *area = area_get(press_ev->event, press_ev->event_x); |                                 area_t *area = area_get(press_ev->event, press_ev->event_x); | ||||||
|                                 /* Respond to the click */ |                                 /* Respond to the click */ | ||||||
|                                 if (area && area->button == press_ev->detail) { |                                 if (area && area->button == press_ev->detail) { | ||||||
|                                 write(STDOUT_FILENO, area->cmd, strlen(area->cmd)); |                                     ssize_t n; | ||||||
|                                 write(STDOUT_FILENO, "\n", 1); |                                     n = write(STDOUT_FILENO, area->cmd, strlen(area->cmd));  | ||||||
|  |                                     n = write(STDOUT_FILENO, "\n", 1);  | ||||||
|  |                                 } | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                         break; |                         break; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user