Revision: a98d9ca08a83
Author: Behdad Esfahbod <
beh...@behdad.org>
Date: Tue Jun 3 18:25:14 2014 UTC
Log: Minor adjustment to work on Windows
According to at least one report, with some compilers on Windows
(no idea what language / mode), the following line:
const glyphy_rgba_t *needle = &tex_data[offset];
generates a runtime "vector subscript out of range" if offset is
equal to the length of the vector, even though getting a pointer
to the end of an array is a valid operation in C. Anyway, work
around it.
http://code.google.com/p/glyphy/source/detail?r=a98d9ca08a83
Modified:
/src/glyphy-blob.cc
=======================================
--- /src/glyphy-blob.cc Tue Aug 20 18:56:47 2013 UTC
+++ /src/glyphy-blob.cc Tue Jun 3 18:25:14 2014 UTC
@@ -273,14 +273,15 @@
unsigned int current_endpoints = tex_data.size () - offset;
- /* See if we can fulfill this cell by using already-encoded arcs */
- const glyphy_rgba_t *needle = &tex_data[offset];
- unsigned int needle_len = current_endpoints;
- const glyphy_rgba_t *haystack = &tex_data[header_length];
- unsigned int haystack_len = offset - header_length;
+ if (current_endpoints)
+ {
+ /* See if we can fulfill this cell by using already-encoded arcs */
+ const glyphy_rgba_t *needle = &tex_data[offset];
+ unsigned int needle_len = current_endpoints;
+ const glyphy_rgba_t *haystack = &tex_data[header_length];
+ unsigned int haystack_len = offset - header_length;
- bool found = false;
- if (needle_len)
+ bool found = false;
while (haystack_len >= needle_len) {
/* Trick: we don't care about first endpoint's d value, so skip one
* byte in comparison. This works because arc_encode() packs the
@@ -294,10 +295,13 @@
haystack++;
haystack_len--;
}
- if (found) {
- tex_data.resize (offset);
- offset = haystack - &tex_data[0];
+ if (found) {
+ tex_data.resize (offset);
+ offset = haystack - &tex_data[0];
+ }
}
+ else
+ offset = 0;
tex_data[row * grid_w + col] = arc_list_encode (offset,
current_endpoints, side);
offset = tex_data.size ();