diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 13 | ||||
-rw-r--r-- | test/cookies.c | 15 | ||||
-rw-r--r-- | test/fltk_browser.cc | 43 | ||||
-rw-r--r-- | test/liang.cc | 4 | ||||
-rw-r--r-- | test/trie.cc | 5 | ||||
-rw-r--r-- | test/unicode_test.cc | 39 |
6 files changed, 53 insertions, 66 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index ab4c98b0..53e3d4ed 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -20,12 +20,12 @@ noinst_PROGRAMS = \ dw-imgbuf-mem-test \ dw-resource-test \ dw-ui-test \ - fltk-browser \ shapes \ cookies \ liang \ trie \ - notsosimplevector + notsosimplevector \ + unicode-test dw_anchors_test_SOURCES = dw_anchors_test.cc dw_anchors_test_LDADD = \ @@ -159,9 +159,6 @@ dw_ui_test_LDADD = \ $(top_builddir)/lout/liblout.a \ @LIBFLTK_LIBS@ -fltk_browser_SOURCES = fltk_browser.cc -fltk_browser_LDADD = @LIBFLTK_LIBS@ - shapes_SOURCES = shapes.cc shapes_LDADD = \ $(top_builddir)/dw/libDw-core.a \ @@ -193,3 +190,9 @@ trie_LDADD = \ notsosimplevector_SOURCES = notsosimplevector.cc notsosimplevector_LDADD = $(top_builddir)/lout/liblout.a + +unicode_test_SOURCES = unicode_test.cc + +unicode_test_LDADD = \ + $(top_builddir)/lout/liblout.a \ + @LIBFLTK_LIBS@ diff --git a/test/cookies.c b/test/cookies.c index 1468c248..5461e77e 100644 --- a/test/cookies.c +++ b/test/cookies.c @@ -368,10 +368,10 @@ static int Dpi_get_server_port(const char *server_name) } -static int Dpi_connect_socket(const char *server_name, int retry) +static int Dpi_connect_socket(const char *server_name) { struct sockaddr_in sin; - int sock_fd, err, dpi_port, ret=-1; + int sock_fd, dpi_port, ret = -1; char *cmd = NULL; /* Query dpid for the port number for this server */ @@ -390,16 +390,7 @@ static int Dpi_connect_socket(const char *server_name, int retry) if ((sock_fd = Dpi_make_socket_fd()) == -1) { perror("[dpi::socket]"); } else if (connect(sock_fd, (void*)&sin, sizeof(sin)) == -1) { - err = errno; - sock_fd = -1; MSG("[dpi::connect] errno:%d %s\n", errno, dStrerror(errno)); - if (retry) { - switch (err) { - case ECONNREFUSED: case EBADF: case ENOTSOCK: case EADDRNOTAVAIL: - sock_fd = Dpi_connect_socket(server_name, FALSE); - break; - } - } /* send authentication Key (the server closes sock_fd on error) */ } else if (!(cmd = a_Dpip_build_cmd("cmd=%s msg=%s", "auth", SharedKey))) { @@ -425,7 +416,7 @@ char *a_Dpi_send_blocking_cmd(const char *server_name, const char *cmd) return ret; } - if ((sock_fd = Dpi_connect_socket(server_name, TRUE)) == -1) { + if ((sock_fd = Dpi_connect_socket(server_name)) == -1) { MSG_ERR("[a_Dpi_send_blocking_cmd] Can't connect to server.\n"); } else if (Dpi_blocking_write(sock_fd, cmd, strlen(cmd)) == -1) { MSG_ERR("[a_Dpi_send_blocking_cmd] Can't send message.\n"); diff --git a/test/fltk_browser.cc b/test/fltk_browser.cc deleted file mode 100644 index bdbec72c..00000000 --- a/test/fltk_browser.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Dillo Widget - * - * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - - - -#include <FL/Fl_Window.H> -#include <FL/Fl_Multi_Browser.H> -#include <FL/Fl.H> - -int main (int argc, char *argv[]) -{ - Fl_Window *window = new Fl_Window (300, 300, "FLTK Browser"); - window->box(FL_NO_BOX); - window->begin (); - Fl_Multi_Browser *browser = new Fl_Multi_Browser (0, 0, 300, 300); - browser->begin (); - - for (int i = 0; i < 10; i++) { - browser->add("first"); - browser->add("second"); - browser->add("third"); - } - - window->resizable(browser); - window->show(); - return Fl::run(); -} diff --git a/test/liang.cc b/test/liang.cc index b1161d9f..a1bc2442 100644 --- a/test/liang.cc +++ b/test/liang.cc @@ -4,10 +4,10 @@ void hyphenateWord (dw::core::Platform *p, const char *word) { - dw::Hyphenator *h = dw::Hyphenator::getHyphenator (p, "de"); + dw::Hyphenator *h = dw::Hyphenator::getHyphenator ("de"); int numBreaks; - int *breakPos = h->hyphenateWord (word, &numBreaks); + int *breakPos = h->hyphenateWord (p, word, &numBreaks); for (int i = 0; i < numBreaks + 1; i++) { if (i != 0) printf (" \xc2\xad "); diff --git a/test/trie.cc b/test/trie.cc index 628daabf..41b56c70 100644 --- a/test/trie.cc +++ b/test/trie.cc @@ -1,10 +1,7 @@ -#include "../dw/fltkcore.hh" #include "../dw/hyphenator.hh" int main (int argc, char *argv[]) { - dw::fltk::FltkPlatform p; - if (argc < 2) { fprintf(stderr, "Usage: trie <pattern file>\n"); exit (1); @@ -12,6 +9,6 @@ int main (int argc, char *argv[]) /* Use pack = 1024 to create a really small trie - can take a while. */ - dw::Hyphenator hyphenator (&p, argv[1], NULL, 1024); + dw::Hyphenator hyphenator (argv[1], NULL, 1024); hyphenator.saveTrie (stdout); } diff --git a/test/unicode_test.cc b/test/unicode_test.cc new file mode 100644 index 00000000..31ede6ba --- /dev/null +++ b/test/unicode_test.cc @@ -0,0 +1,39 @@ +#include <string.h> +#include <stdio.h> +#include <FL/fl_utf8.h> +#include "../lout/unicode.hh" + +using namespace lout::unicode; + +int main (int argc, char *argv[]) +{ + // 0-terminated string + const char *t1 = "abcäöüабв−‐"; + + // not 0-terminated; copy from 0-terminated + int t2len = strlen (t1); + char t2[t2len]; + for (int i = 0; i < t2len; i++) + t2[i] = t1[i]; + + puts ("===== misc::unicode, 0-terminated ====="); + for (const char *s = t1; s; s = nextUtf8Char (s)) + printf ("%3d -> U+%04x ('%s')\n", (int)(s - t1), decodeUtf8(s), s); + + puts ("===== Fltk, 0-terminated ====="); + for (const char *s = t1; *s; s = fl_utf8fwd (s + 1, t1, t1 + strlen (t1))) + printf ("%3d -> U+%04x ('%s')\n", (int)(s - t1), decodeUtf8(s), s); + + puts ("===== misc::unicode, not 0-terminated ====="); + for (const char *s = t2; s; s = nextUtf8Char (s, t2len - (s - t2))) + printf ("%3d -> U+%04x\n", (int)(s - t2), + decodeUtf8(s, t2len - (s - t2))); + + puts ("===== Fltk, not 0-terminated ====="); + for (const char *s = t2; *s; + s - t2 < t2len && (s = fl_utf8fwd (s + 1, t2, t2 + t2len))) + printf ("%3d -> U+%04x\n", (int)(s - t2), + decodeUtf8(s, t2len - (s - t2))); + + return 0; +} |