X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=OSX%2Fiostextclient.m;h=3cbddea0a9b68bcc071c8900e41b5c214a677224;hb=8afc01a67be4fbf3f1cc0fce9adf01b5289a21c6;hp=646436c323fcbcb1bb026353b0225e0ca4558291;hpb=f8cf5ac7b2f53510f80a0eaf286a25298be17bfe;p=xscreensaver diff --git a/OSX/iostextclient.m b/OSX/iostextclient.m index 646436c3..3cbddea0 100644 --- a/OSX/iostextclient.m +++ b/OSX/iostextclient.m @@ -38,15 +38,6 @@ struct text_data { }; -void -textclient_reshape (text_data *d, - int pix_w, int pix_h, - int char_w, int char_h) -{ - d->columns = char_w; -} - - text_data * textclient_open (Display *dpy) { @@ -289,7 +280,7 @@ copy_rss_field (const char *s) s += 9; char *e = strstr (s, "]]"); if (e) *e = 0; - int L = strlen (s); + unsigned long L = strlen (s); char *s2 = (char *) malloc (L+1); memcpy (s2, s, L+1); return s2; @@ -316,10 +307,10 @@ pick_rss_field (const char *a, const char *b, const char *c, const char *d) char *b2 = copy_rss_field (b); char *c2 = copy_rss_field (c); char *d2 = copy_rss_field (d); - int al = a2 ? strlen(a2) : 0; - int bl = b2 ? strlen(b2) : 0; - int cl = c2 ? strlen(c2) : 0; - int dl = d2 ? strlen(d2) : 0; + unsigned long al = a2 ? strlen(a2) : 0; + unsigned long bl = b2 ? strlen(b2) : 0; + unsigned long cl = c2 ? strlen(c2) : 0; + unsigned long dl = d2 ? strlen(d2) : 0; char *ret = 0; if (al > bl && al > cl && al > dl) ret = a2; @@ -405,6 +396,7 @@ wrap_text (char *body, int columns) { int col = 0, last_col = 0; char *last_space = 0; + if (! body) return; for (char *p = body; *p; p++) { if (*p == '\r' || *p == '\n' || *p == ' ' || *p == '\t') { if (col > columns && last_space) { @@ -425,6 +417,23 @@ wrap_text (char *body, int columns) } +static void +rewrap_text (char *body, int columns) +{ + if (! body) return; + for (char *p = body; *p; p++) { + if (*p == '\n') { + if (p[1] == '\n') + p++; + else + *p = ' '; + } + } + wrap_text (body, columns); +} + + + static void strip_backslashes (char *s) { @@ -462,7 +471,7 @@ url_string (const char *url) // Only search the first 1/2 K of the document while determining type. - int L = [body length]; + unsigned long L = [body length]; if (L > 512) L = 512; NSString *head = [[[body substringToIndex: L] stringByTrimmingCharactersInSet: @@ -553,4 +562,14 @@ textclient_putc (text_data *d, XKeyEvent *k) return False; } + +void +textclient_reshape (text_data *d, + int pix_w, int pix_h, + int char_w, int char_h) +{ + d->columns = char_w; + rewrap_text (d->buf, d->columns); +} + #endif /* USE_IPHONE -- whole file */