[glyphy] push by behdad@google.com - Minor adjustment to work on Windows... on 2014-06-03 18:26 GMT

21 views
Skip to first unread message

gly...@googlecode.com

unread,
Jun 3, 2014, 2:27:22 PM6/3/14
to gly...@googlegroups.com
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 ();
Reply all
Reply to author
Forward
0 new messages