From f655191659c9c8bd3648ad49d9a8115f91229712 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Sat, 5 Jan 2013 12:32:49 -0300 Subject: Remove redundant check in cache.c [by p37sitdu] --- src/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cache.c b/src/cache.c index 9636d0d8..04c8d356 100644 --- a/src/cache.c +++ b/src/cache.c @@ -233,7 +233,7 @@ static CacheEntry_t *Cache_entry_search_with_redirect(const DilloUrl *Url) break; } /* Test for a working redirection */ - if (entry && entry->Flags & CA_Redirect && entry->Location) { + if (entry->Flags & CA_Redirect && entry->Location) { Url = entry->Location; } else break; -- cgit v1.2.3 From 44a8af5732ee316dfccf2f6c10d0b17bb3f4a633 Mon Sep 17 00:00:00 2001 From: Sebastian Geerken Date: Mon, 7 Jan 2013 12:53:16 +0100 Subject: Fixing a bug (and another glitch) in Pointer. --- lout/object.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lout/object.cc b/lout/object.cc index 08ea0452..a081f023 100644 --- a/lout/object.cc +++ b/lout/object.cc @@ -124,16 +124,22 @@ int Pointer::hashValue() * return ((int*)value)[0] ^ ((int*)value)[1]; */ #if SIZEOF_VOID_P == 4 + // Assuming that sizeof(void*) == sizeof(int); on 32 bit systems. return (int)value; #else - return ((int*)value)[0] ^ ((int*)value)[1]; + // Assuming that sizeof(void*) == 2 * sizeof(int); on 64 bit + // systems (int is still 32 bit). + // Combine both parts of the pointer value *itself*, not what it + // points to, by first referencing it (operator "&"), then + // dereferencing it again (operator "[]"). + return ((int*)&value)[0] ^ ((int*)&value)[1]; #endif } void Pointer::intoStringBuffer(misc::StringBuffer *sb) { char buf[64]; - snprintf(buf, sizeof(buf), "0x%p", value); + snprintf(buf, sizeof(buf), "%p", value); sb->append(buf); } -- cgit v1.2.3 From f4a7d5759a0910e30aa01d1baa40532081a687f8 Mon Sep 17 00:00:00 2001 From: Sebastian Geerken Date: Mon, 7 Jan 2013 18:46:51 +0100 Subject: Also fixed comment in Pointer::hashValue(). --- lout/object.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lout/object.cc b/lout/object.cc index a081f023..843c0ae4 100644 --- a/lout/object.cc +++ b/lout/object.cc @@ -121,7 +121,7 @@ int Pointer::hashValue() * if (sizeof (int) == sizeof (void*)) * return (int)value; * else - * return ((int*)value)[0] ^ ((int*)value)[1]; + * return ((int*)&value)[0] ^ ((int*)&value)[1]; */ #if SIZEOF_VOID_P == 4 // Assuming that sizeof(void*) == sizeof(int); on 32 bit systems. -- cgit v1.2.3 From 26e3a0620138db70376c65e77ba897701f195b32 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 7 Jan 2013 21:39:19 +0100 Subject: remove weird comment lines These lines were a left-over from a previous merge. noticed-by: corvid --- src/html.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/html.cc b/src/html.cc index aaca6d10..41ccf95f 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1959,8 +1959,6 @@ static void Html_tag_open_abbr(DilloHtml *html, const char *tag, int tagsize) } /* - html->styleEngine->inheritBackgroundColor (); - html->styleEngine->inheritBackgroundColor (); * Read image-associated tag attributes and create new image. */ void a_Html_image_attrs(DilloHtml *html, const char *tag, int tagsize) -- cgit v1.2.3 From e8c6204b4e737bd61945d1e622933f68099873fd Mon Sep 17 00:00:00 2001 From: Jeremy Henty Date: Tue, 8 Jan 2013 02:00:03 +0000 Subject: downloads.cc: do not test whether the file exists or prompt to overwrite. --- dpi/downloads.cc | 105 +++++-------------------------------------------------- 1 file changed, 9 insertions(+), 96 deletions(-) diff --git a/dpi/downloads.cc b/dpi/downloads.cc index 8e560d35..6f36afe9 100644 --- a/dpi/downloads.cc +++ b/dpi/downloads.cc @@ -50,17 +50,6 @@ #define _MSG(...) #define MSG(...) printf("[downloads dpi]: " __VA_ARGS__) -/* - * Internal types - */ -typedef enum { - DL_NEWFILE, - DL_CONTINUE, - DL_RENAME, - DL_OVERWRITE, - DL_ABORT -} DLAction; - /* * Class declarations */ @@ -127,7 +116,7 @@ class DLItem { Fl_Widget *prTitle, *prGot, *prSize, *prRate, *pr_Rate, *prETA, *prETAt; public: - DLItem(const char *full_filename, const char *url, DLAction action); + DLItem(const char *full_filename, const char *url); ~DLItem(); void child_init(); void father_init(); @@ -181,7 +170,7 @@ class DLWin { public: DLWin(int ww, int wh); - void add(const char *full_filename, const char *url, DLAction action); + void add(const char *full_filename, const char *url); void del(int n_item); int num(); int num_running(); @@ -189,7 +178,6 @@ public: void show() { mWin->show(); } void hide() { mWin->hide(); } void abort_all(); - DLAction check_filename(char **p_dl_dest); }; /* @@ -292,7 +280,7 @@ static void prButton_scb(Fl_Widget *, void *cb_data) i->prButton_cb(); } -DLItem::DLItem(const char *full_filename, const char *url, DLAction action) +DLItem::DLItem(const char *full_filename, const char *url) { struct stat ss; const char *p; @@ -333,11 +321,9 @@ DLItem::DLItem(const char *full_filename, const char *url, DLAction action) dl_argv = new char*[8]; int i = 0; dl_argv[i++] = (char*)"wget"; - if (action == DL_CONTINUE) { - if (stat(fullname, &ss) == 0) - init_bytesize = (int)ss.st_size; - dl_argv[i++] = (char*)"-c"; - } + if (stat(fullname, &ss) == 0) + init_bytesize = (int)ss.st_size; + dl_argv[i++] = (char*)"-c"; dl_argv[i++] = (char*)"--load-cookies"; dl_argv[i++] = dStrconcat(dGethomedir(), "/.dillo/cookies.txt", NULL); dl_argv[i++] = (char*)"-O"; @@ -841,31 +827,6 @@ static void update_cb(void *data) // DLWin --------------------------------------------------------------------- -/* - * Make a new name and place it in 'dl_dest'. - */ -static void make_new_name(char **dl_dest, const char *url) -{ - Dstr *gstr = dStr_new(*dl_dest); - int idx = gstr->len; - - if (gstr->str[idx - 1] != '/'){ - dStr_append_c(gstr, '/'); - ++idx; - } - - /* Use a mangled url as name */ - dStr_append(gstr, url); - for ( ; idx < gstr->len; ++idx) - if (!isalnum(gstr->str[idx])) - gstr->str[idx] = '_'; - - /* free memory */ - dFree(*dl_dest); - *dl_dest = gstr->str; - dStr_free(gstr, FALSE); -} - /* * Callback function for the request socket. * Read the request, parse and start a new download. @@ -875,10 +836,8 @@ static void read_req_cb(int req_fd, void *) struct sockaddr_un clnt_addr; int sock_fd; socklen_t csz; - struct stat sb; Dsh *sh = NULL; char *dpip_tag = NULL, *cmd = NULL, *url = NULL, *dl_dest = NULL; - DLAction action = DL_ABORT; /* compiler happiness */ /* Initialize the value-result parameter */ csz = sizeof(struct sockaddr_un); @@ -932,17 +891,7 @@ static void read_req_cb(int req_fd, void *) MSG("Failed to parse 'destination' in {%s}\n", dpip_tag); goto end; } - /* 'dl_dest' may be a directory */ - if (stat(dl_dest, &sb) == 0 && S_ISDIR(sb.st_mode)) { - make_new_name(&dl_dest, url); - } - action = dl_win->check_filename(&dl_dest); - if (action != DL_ABORT) { - // Start the whole thing within FLTK. - dl_win->add(dl_dest, url, action); - } else if (dl_win->num() == 0) { - exit(0); - } + dl_win->add(dl_dest, url); end: dFree(cmd); @@ -975,9 +924,9 @@ static void dlwin_esc_cb(Fl_Widget *, void *) * Add a new download request to the main window and * fork a child to do the job. */ -void DLWin::add(const char *full_filename, const char *url, DLAction action) +void DLWin::add(const char *full_filename, const char *url) { - DLItem *dl_item = new DLItem(full_filename, url, action); + DLItem *dl_item = new DLItem(full_filename, url); mDList->add(dl_item); mPG->insert(*dl_item->get_widget(), 0); @@ -1001,42 +950,6 @@ void DLWin::add(const char *full_filename, const char *url, DLAction action) } } -/* - * Decide what to do when the filename already exists. - * (renaming takes place here when necessary) - */ -DLAction DLWin::check_filename(char **p_fullname) -{ - struct stat ss; - Dstr *ds; - int ch; - DLAction ret = DL_ABORT; - - if (stat(*p_fullname, &ss) == -1) - return DL_NEWFILE; - - ds = dStr_sized_new(128); - dStr_sprintf(ds, - "The file:\n %s (%d Bytes)\nalready exists. What do we do?", - *p_fullname, (int)ss.st_size); - fl_message_title("Dillo Downloads: File exists!"); - ch = fl_choice("%s", "Abort", "Continue", "Rename", ds->str); - dStr_free(ds, 1); - MSG("Choice %d\n", ch); - if (ch == 2) { - const char *p; - p = fl_file_chooser("Enter a new name:", NULL, *p_fullname); - if (p) { - dFree(*p_fullname); - *p_fullname = dStrdup(p); - ret = check_filename(p_fullname); - } - } else if (ch == 1) { - ret = DL_CONTINUE; - } - return ret; -} - /* * Delete a download request from the main window. */ -- cgit v1.2.3 From 93559749353b0611fcd591461ae547b9fb8a35e1 Mon Sep 17 00:00:00 2001 From: Jeremy Henty Date: Tue, 8 Jan 2013 02:00:03 +0000 Subject: uicmd.cc: when saving, test whether the file exists and prompt before overwriting. --- src/uicmd.cc | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/src/uicmd.cc b/src/uicmd.cc index 54efa7a4..a0c5760c 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -18,6 +18,7 @@ #include /* for qsort */ #include /* for rint */ #include /* for UINT_MAX */ +#include #include #include @@ -855,20 +856,65 @@ void a_UIcmd_init(void) } } +/* + * Check a file to save to. + */ +static int UIcmd_save_file_check(const char *name) +{ + struct stat ss; + if (stat(name, &ss) == 0) { + Dstr *ds; + int ch; + ds = dStr_sized_new(128); + dStr_sprintf(ds, + "The file:\n %s (%d Bytes)\nalready exists. What do we do?", + name, (int)ss.st_size); + ch = a_Dialog_choice5("Dillo Save: File exists!", ds->str, + "Abort", "Continue", "Rename", NULL, NULL); + dStr_free(ds, 1); + return ch; + } else { + return 2; /* assume the file does not exist, so Continue */ + } +} + /* * Save a URL */ static void UIcmd_save(BrowserWindow *bw, const DilloUrl *url, const char *title, const char *url_str) { - char *SuggestedName; const char *name; - SuggestedName = UIcmd_make_save_filename(url_str); - name = a_Dialog_save_file(title, NULL, SuggestedName); - dFree(SuggestedName); - if (name) { - MSG("UIcmd_save: %s\n", name); - a_Nav_save_url(bw, url, name); + bool_t first_prompt = 1; + while (1) { + char *SuggestedName; + + SuggestedName = + first_prompt + ? UIcmd_make_save_filename(url_str) + : dStrdup(name); + first_prompt = 0; + name = a_Dialog_save_file(title, NULL, SuggestedName); + dFree(SuggestedName); + + if (name) { + switch (UIcmd_save_file_check(name)) { + case 0: + case 1: + /* Abort */ + return; + case 2: + /* Continue */ + MSG("UIcmd_save: %s\n", name); + a_Nav_save_url(bw, url, name); + return; + default: + /* Rename */ + break; /* prompt again */ + } + } else { + return; /* no name, so Abort */ + } } } -- cgit v1.2.3 From 70c06ae5da2ef3f8ad61f3ab5e468055d5e07c2c Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 8 Jan 2013 22:36:53 +0000 Subject: make test/cookies somewhat usable by others --- test/cookies.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/test/cookies.c b/test/cookies.c index 1036779f..40661650 100644 --- a/test/cookies.c +++ b/test/cookies.c @@ -44,6 +44,7 @@ } D_STMT_END #define MSG(...) MSG_INNARDS("", __VA_ARGS__) +#define MSG_WARN(...) MSG_INNARDS("** WARNING **: ", __VA_ARGS__) #define MSG_ERR(...) MSG_INNARDS("** ERROR **: ", __VA_ARGS__) @@ -778,8 +779,87 @@ static void path() expect(__LINE__, "Cookie: name=val\r\n", "http", "p6.com", "/dir/subdir/s"); } +int Cookies_rc_check() +{ + const int line_maxlen = 4096; + FILE *stream; + char *filename; + char line[line_maxlen]; + bool_t default_deny = TRUE; + + /* Get a file pointer */ + filename = dStrconcat(dGethomedir(), "/.dillo/cookiesrc", NULL); + stream = fopen(filename, "r"); + dFree(filename); + + if (!stream) { + MSG_ERR("Cannot run test; cannot open cookiesrc.\n"); + return 1; + } + + /* Get all lines in the file */ + while (!feof(stream)) { + char *rc; + + line[0] = '\0'; + rc = fgets(line, line_maxlen, stream); + if (!rc && ferror(stream)) { + MSG_ERR("Error while reading rule from cookiesrc: %s\n", + dStrerror(errno)); + fclose(stream); + return 2; + } + + /* Remove leading and trailing whitespaces */ + dStrstrip(line); + + if (line[0] != '\0' && line[0] != '#') { + int domain_end, i = 0; + const char *rule; + + /* Get the domain */ + while (line[i] != '\0' && !dIsspace(line[i])) + i++; + domain_end = i; + + /* Skip past whitespace */ + while (dIsspace(line[i])) + i++; + line[domain_end] = '\0'; + + /* Get the rule */ + rule = line + i; + while (line[i] != '\0' && !dIsspace(line[i])) + i++; + line[i] = '\0'; + + if (!dStrAsciiCasecmp(line, "DEFAULT")) { + if (!dStrAsciiCasecmp(rule, "ACCEPT") || + !dStrAsciiCasecmp(rule, "ACCEPT_SESSION")) + default_deny = FALSE; + } else { + if (!dStrAsciiCasecmp(rule, "DENY")) + MSG_WARN("DENY rules in cookiesrc can interfere with test.\n"); + } + } + } + fclose(stream); + + if (default_deny) { + MSG_ERR("Cannot run test with cookiesrc default of deny.\n"); + return 1; + } else { + return 0; + } +} + int main() { + if (Cookies_rc_check()) { + MSG("If you change cookiesrc, remember to stop the DPIs via dpidc.\n"); + return 1; + } + a_Cookies_set("name=val", "ordinary.com", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "ordinary.com", "/"); @@ -959,5 +1039,9 @@ MSG("org should fail: %s\n", #endif MSG("TESTS: passed: %u failed: %u\n", passed, failed); + + MSG("Now that everything is full of fake cookies, you should run " + "'dpidc stop', plus delete cookies.txt if necessary.\n"); + return 0; } -- cgit v1.2.3 From 35b754a7c3baa28b29885395ab0a3bbc188fb236 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 8 Jan 2013 22:56:43 +0000 Subject: fix an at-least-conceivable fd leak with cookiesrc on error You can trigger ferror() by putting in a fputc() or the like, but I'm not immediately sure of any good way to trigger it without changing the code... --- src/cookies.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cookies.c b/src/cookies.c index 0a1e94ff..e43a74a2 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -260,6 +260,7 @@ static int Cookie_control_init(void) if (!rc && ferror(stream)) { MSG("Cookies1: Error while reading rule from cookiesrc: %s\n", dStrerror(errno)); + fclose(stream); return 2; /* bail out */ } -- cgit v1.2.3 From 2c7f080f5507694698c4aa2870fa66cb2bd9533d Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 8 Jan 2013 23:22:53 +0000 Subject: don't draw scrollbars unnecessarily --- dw/fltkviewport.cc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc index c062cf71..de4c8f94 100644 --- a/dw/fltkviewport.cc +++ b/dw/fltkviewport.cc @@ -208,19 +208,14 @@ void FltkViewport::draw () if (d) { draw_area(this, x(), y(), w () - hdiff, h () - vdiff); - if (d == FL_DAMAGE_CHILD) { - if (hscrollbar->damage ()) - draw_child (*hscrollbar); - if (vscrollbar->damage ()) - draw_child (*vscrollbar); - } else { + if (d == FL_DAMAGE_ALL || hscrollbar->damage ()) draw_child (*hscrollbar); + if (d == FL_DAMAGE_ALL || vscrollbar->damage ()) draw_child (*vscrollbar); - if (d == FL_DAMAGE_ALL && hdiff && vdiff) { - fl_color(FL_BACKGROUND_COLOR); - fl_rectf(x()+w()-hdiff, y()+h()-vdiff, hdiff, vdiff); - } + if (d == FL_DAMAGE_ALL && hdiff && vdiff) { + fl_color(FL_BACKGROUND_COLOR); + fl_rectf(x()+w()-hdiff, y()+h()-vdiff, hdiff, vdiff); } } -- cgit v1.2.3 From e3ce71b187518f85a07211e0452de5aca543b0e5 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 8 Jan 2013 23:43:55 +0000 Subject: ChangeLog --- ChangeLog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7fec637e..4bf50f4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -44,9 +44,12 @@ dillo-3.0.3 [not released yet] - Fixed a bug in dpip when dillo aborts a running dpi connection. Patches: Jorge Arellano Cid +- Better window titles. - Patch: Jeremy Henty + - Show dialog if saved file would overwrite an existing one. + Patches: Jeremy Henty +- Remove hardcoded UI colors. Patch: Benjamin Johnson, corvid ++- Fix fd leak in dpi write failure case. + Patch: p37sitdu, Jorge Arellano Cid ----------------------------------------------------------------------------- -- cgit v1.2.3 From d236210c1608952b7910123fbede108317a80444 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 9 Jan 2013 14:04:59 +0100 Subject: Reduced number of redraws when selecting text. --- dw/textblock_iterator.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dw/textblock_iterator.cc b/dw/textblock_iterator.cc index b5d28885..cfd27941 100644 --- a/dw/textblock_iterator.cc +++ b/dw/textblock_iterator.cc @@ -106,6 +106,11 @@ void Textblock::TextblockIterator::highlight (int start, int end, Textblock *textblock = (Textblock*)getWidget(); int index1 = index, index2 = index; + int oldStartIndex = textblock->hlStart[layer].index; + int oldStartChar = textblock->hlStart[layer].nChar; + int oldEndIndex = textblock->hlEnd[layer].index; + int oldEndChar = textblock->hlEnd[layer].nChar; + if (textblock->hlStart[layer].index > textblock->hlEnd[layer].index) { /* nothing is highlighted */ textblock->hlStart[layer].index = index; @@ -124,7 +129,11 @@ void Textblock::TextblockIterator::highlight (int start, int end, textblock->hlEnd[layer].nChar = end; } - textblock->queueDrawRange (index1, index2); + if (oldStartIndex != textblock->hlStart[layer].index || + oldStartChar != textblock->hlStart[layer].nChar || + oldEndIndex != textblock->hlEnd[layer].index || + oldEndChar != textblock->hlEnd[layer].nChar) + textblock->queueDrawRange (index1, index2); } void Textblock::TextblockIterator::unhighlight (int direction, -- cgit v1.2.3 From cbba835b154ba31e7a07ba1b15a06b8953eb7e72 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 9 Jan 2013 12:47:23 -0300 Subject: Refactored FD close calls into a single new dClose() dlib function [p37sitdu] --- dlib/dlib.c | 12 ++++++++++++ dlib/dlib.h | 8 ++++---- dpi/downloads.cc | 12 ++++++------ dpi/https.c | 4 ++-- dpid/dpid.c | 4 ++-- dpid/dpidc.c | 3 ++- dpid/main.c | 12 +++++++----- dpid/misc_new.c | 14 -------------- dpid/misc_new.h | 2 -- dpip/dpip.c | 4 ++-- src/IO/IO.c | 5 +---- src/IO/dpi.c | 34 ++++++++++------------------------ src/IO/http.c | 13 +------------ src/cookies.c | 2 +- src/dns.c | 9 ++++----- 15 files changed, 54 insertions(+), 84 deletions(-) diff --git a/dlib/dlib.c b/dlib/dlib.c index ebdaf0cd..d60f1bc6 100644 --- a/dlib/dlib.c +++ b/dlib/dlib.c @@ -931,3 +931,15 @@ char *dGetline (FILE *stream) return line; } +/* + * Close a FD handling EINTR. + */ +int dClose(int fd) +{ + int st; + + do + st = close(fd); + while (st == -1 && errno == EINTR); + return st; +} diff --git a/dlib/dlib.h b/dlib/dlib.h index 8dc324a7..0d194dbe 100644 --- a/dlib/dlib.h +++ b/dlib/dlib.h @@ -175,10 +175,10 @@ void dLib_show_messages(bool_t show); /* *- Misc utility functions ---------------------------------------------------- */ -char *dGetcwd (); -char *dGethomedir (); -char *dGetline (FILE *stream); - +char *dGetcwd(); +char *dGethomedir(); +char *dGetline(FILE *stream); +int dClose(int fd); #ifdef __cplusplus } diff --git a/dpi/downloads.cc b/dpi/downloads.cc index 6f36afe9..70acaa8a 100644 --- a/dpi/downloads.cc +++ b/dpi/downloads.cc @@ -441,7 +441,7 @@ DLItem::~DLItem() void DLItem::abort_dl() { if (!log_done()) { - close(LogPipe[0]); + dClose(LogPipe[0]); Fl::remove_fd(LogPipe[0]); log_done(1); // Stop wget @@ -459,9 +459,9 @@ void DLItem::prButton_cb() void DLItem::child_init() { - close(0); // stdin - close(1); // stdout - close(LogPipe[0]); + dClose(0); // stdin + dClose(1); // stdout + dClose(LogPipe[0]); dup2(LogPipe[1], 2); // stderr // set the locale to C for log parsing setenv("LC_ALL", "C", 1); @@ -618,7 +618,7 @@ static void read_log_cb(int fd_in, void *data) perror("read, "); break; } else if (st == 0) { - close(fd_in); + dClose(fd_in); Fl::remove_fd(fd_in, 1); dl_item->log_done(1); break; @@ -630,7 +630,7 @@ static void read_log_cb(int fd_in, void *data) void DLItem::father_init() { - close(LogPipe[1]); + dClose(LogPipe[1]); Fl::add_fd(LogPipe[0], 1, read_log_cb, this); // Read // Start the timer after the child is running. diff --git a/dpi/https.c b/dpi/https.c index 389c608d..9aea31e5 100644 --- a/dpi/https.c +++ b/dpi/https.c @@ -330,7 +330,7 @@ static void yes_ssl_support(void) dFree(check_cert); if (network_socket != -1){ - close(network_socket); + dClose(network_socket); network_socket = -1; } if (ssl_connection != NULL){ @@ -402,7 +402,7 @@ static int get_network_connection(char * url) s = socket(hp->h_addrtype, SOCK_STREAM, 0); if (connect(s, (struct sockaddr *)&address, sizeof(address)) != 0){ - close(s); + dClose(s); s = -1; MSG("errno: %i\n", errno); } diff --git a/dpid/dpid.c b/dpid/dpid.c index 28cfabba..ebabb9a2 100644 --- a/dpid/dpid.c +++ b/dpid/dpid.c @@ -762,7 +762,7 @@ void stop_active_dpis(struct dp *dpi_attr_list, int numdpis) } else if (CKD_WRITE(sock_fd, bye_cmd) == -1) { ERRMSG("stop_active_dpis", "write", errno); } - a_Misc_close_fd(sock_fd); + dClose(sock_fd); } dFree(auth_cmd); @@ -782,7 +782,7 @@ void ignore_dpi_sockets(struct dp *dpi_attr_list, int numdpis) for (i = 0; i < numdpis; i++) { FD_CLR(dpi_attr_list[i].sock_fd, &sock_set); - a_Misc_close_fd(dpi_attr_list[i].sock_fd); + dClose(dpi_attr_list[i].sock_fd); } } diff --git a/dpid/dpidc.c b/dpid/dpidc.c index 61a91275..58db9c3c 100644 --- a/dpid/dpidc.c +++ b/dpid/dpidc.c @@ -9,6 +9,7 @@ #include #include +#include "../dlib/dlib.h" #include "../dpip/dpip.h" #define MSG_ERR(...) printf("** ERROR **: " __VA_ARGS__); @@ -116,6 +117,6 @@ int main(int argc, char *argv[]) error("ERROR reading from socket"); printf("%s\n",buffer); */ - close(sockfd); + dClose(sockfd); return 0; } diff --git a/dpid/main.c b/dpid/main.c index 5f512245..6350a2b6 100644 --- a/dpid/main.c +++ b/dpid/main.c @@ -26,6 +26,8 @@ #include "dpi.h" #include "dpi_socket_dir.h" #include "misc_new.h" + +#include "../dlib/dlib.h" #include "../dpip/dpip.h" sigset_t mask_sigchld; @@ -76,13 +78,13 @@ static int start_filter_plugin(struct dp dpi_attr) } /* Parent, Close sockets fix stdio and return pid */ - if (a_Misc_close_fd(newsock) == -1) { + if (dClose(newsock) == -1) { ERRMSG("start_plugin", "close", errno); MSG_ERR("ERROR in child proc for %s\n", dpi_attr.path); exit(1); } - a_Misc_close_fd(STDIN_FILENO); - a_Misc_close_fd(STDOUT_FILENO); + dClose(STDIN_FILENO); + dClose(STDOUT_FILENO); dup2(old_stdin, STDIN_FILENO); dup2(old_stdout, STDOUT_FILENO); return pid; @@ -95,7 +97,7 @@ static void start_server_plugin(struct dp dpi_attr) MSG_ERR("ERROR in child proc for %s\n", dpi_attr.path); exit(1); } - if (a_Misc_close_fd(dpi_attr.sock_fd) == -1) { + if (dClose(dpi_attr.sock_fd) == -1) { ERRMSG("start_plugin", "close", errno); MSG_ERR("ERROR in child proc for %s\n", dpi_attr.path); exit(1); @@ -224,7 +226,7 @@ int main(void) /* close inherited file descriptors */ open_max = get_open_max(); for (i = 3; i < open_max; i++) - a_Misc_close_fd(i); + dClose(i); /* this sleep used to unmask a race condition */ // sleep(2); diff --git a/dpid/misc_new.c b/dpid/misc_new.c index 8c07a4eb..50867bc3 100644 --- a/dpid/misc_new.c +++ b/dpid/misc_new.c @@ -19,20 +19,6 @@ #include "dpid_common.h" #include "misc_new.h" /* for function prototypes */ - -/* - * Close a FD handling EINTR. - */ -int a_Misc_close_fd(int fd) -{ - int st; - - do { - st = close(fd); - } while (st < 0 && errno == EINTR); - return st; -} - /*! Reads a dpi tag from a socket * \li Continues after a signal interrupt * \Return diff --git a/dpid/misc_new.h b/dpid/misc_new.h index 325451a1..b015a77a 100644 --- a/dpid/misc_new.h +++ b/dpid/misc_new.h @@ -1,8 +1,6 @@ #ifndef MISC_NEW_H #define MISC_NEW_H - -int a_Misc_close_fd(int fd); Dstr *a_Misc_rdtag(int socket); char *a_Misc_readtag(int sock); char *a_Misc_mkdtemp(char *template); diff --git a/dpip/dpip.c b/dpip/dpip.c index dd97ec4a..e1908317 100644 --- a/dpip/dpip.c +++ b/dpip/dpip.c @@ -489,11 +489,11 @@ void a_Dpip_dsh_close(Dsh *dsh) a_Dpip_dsh_write(dsh, 1, "", 0); /* close fds */ - while((st = close(dsh->fd_in)) < 0 && errno == EINTR) ; + st = dClose(dsh->fd_in); if (st < 0) MSG_ERR("[a_Dpip_dsh_close] close: %s\n", dStrerror(errno)); if (dsh->fd_out != dsh->fd_in) { - while((st = close(dsh->fd_out)) < 0 && errno == EINTR) ; + st = dClose(dsh->fd_out); if (st < 0) MSG_ERR("[a_Dpip_dsh_close] close: %s\n", dStrerror(errno)); } diff --git a/src/IO/IO.c b/src/IO/IO.c index 1243c70a..a0a8bba5 100644 --- a/src/IO/IO.c +++ b/src/IO/IO.c @@ -125,7 +125,6 @@ static void IO_free(IOData_t *io) */ static void IO_close_fd(IOData_t *io, int CloseCode) { - int st; int events = 0; _MSG("====> begin IO_close_fd (%d) Key=%d CloseCode=%d Flags=%d ", @@ -135,9 +134,7 @@ static void IO_close_fd(IOData_t *io, int CloseCode) * closed! (other clients may set 'IOFlag_ForceClose') */ if (((io->Flags & IOFlag_ForceClose) || (CloseCode == IO_StopRdWr)) && io->FD != -1) { - do - st = close(io->FD); - while (st < 0 && errno == EINTR); + dClose(io->FD); } else { _MSG(" NOT CLOSING "); } diff --git a/src/IO/dpi.c b/src/IO/dpi.c index 24f1fce8..8e71f8ca 100644 --- a/src/IO/dpi.c +++ b/src/IO/dpi.c @@ -85,19 +85,6 @@ void a_Dpi_init(void) /* empty */ } -/* - * Close a FD handling EINTR - */ -static void Dpi_close_fd(int fd) -{ - int st; - - dReturn_if (fd < 0); - do - st = close(fd); - while (st < 0 && errno == EINTR); -} - /* * Create a new connection data structure */ @@ -362,7 +349,7 @@ static int Dpi_start_dpid(void) if (pid == 0) { /* This is the child process. Execute the command. */ char *path1 = dStrconcat(dGethomedir(), "/.dillo/dpid", NULL); - Dpi_close_fd(st_pipe[0]); + dClose(st_pipe[0]); if (execl(path1, "dpid", (char*)NULL) == -1) { dFree(path1); path1 = dStrconcat(DILLO_BINDIR, "dpid", NULL); @@ -373,7 +360,7 @@ static int Dpi_start_dpid(void) if (Dpi_blocking_write(st_pipe[1], "ERROR", 5) == -1) { MSG("Dpi_start_dpid (child): can't write to pipe.\n"); } - Dpi_close_fd(st_pipe[1]); + dClose(st_pipe[1]); _exit (EXIT_FAILURE); } } @@ -382,19 +369,18 @@ static int Dpi_start_dpid(void) /* The fork failed. Report failure. */ MSG("Dpi_start_dpid: %s\n", dStrerror(errno)); /* close the unused pipe */ - Dpi_close_fd(st_pipe[0]); - Dpi_close_fd(st_pipe[1]); - + dClose(st_pipe[0]); + dClose(st_pipe[1]); } else { /* This is the parent process, check our child status... */ - Dpi_close_fd(st_pipe[1]); + dClose(st_pipe[1]); if ((answer = Dpi_blocking_read(st_pipe[0])) != NULL) { MSG("Dpi_start_dpid: can't start dpid\n"); dFree(answer); } else { ret = 0; } - Dpi_close_fd(st_pipe[0]); + dClose(st_pipe[0]); } return ret; @@ -467,7 +453,7 @@ static int Dpi_check_dpid_ids() } else if (connect(sock_fd, (struct sockaddr *)&sin, sin_sz) == -1) { MSG("Dpi_check_dpid_ids: %s\n", dStrerror(errno)); } else { - Dpi_close_fd(sock_fd); + dClose(sock_fd); ret = 1; } } @@ -603,7 +589,7 @@ static int Dpi_get_server_port(const char *server_name) dFree(cmd); } dFree(rply); - Dpi_close_fd(sock_fd); + dClose(sock_fd); return ok ? dpi_port : -1; } @@ -648,7 +634,7 @@ static int Dpi_connect_socket(const char *server_name) } dFree(cmd); if (sock_fd != -1 && ret == -1) /* can't send cmd? */ - Dpi_close_fd(sock_fd); + dClose(sock_fd); return ret; } @@ -797,7 +783,7 @@ char *a_Dpi_send_blocking_cmd(const char *server_name, const char *cmd) } if ((ret = Dpi_blocking_read(sock_fd)) == NULL) { MSG_ERR("[a_Dpi_send_blocking_cmd] Can't read message.\n"); } - Dpi_close_fd(sock_fd); + dClose(sock_fd); return ret; } diff --git a/src/IO/http.c b/src/IO/http.c index 3e87f912..bb4bca15 100644 --- a/src/IO/http.c +++ b/src/IO/http.c @@ -209,17 +209,6 @@ static void Http_socket_free(int SKey) } } -/* - * Close the socket's FD - */ -static void Http_socket_close(SocketData_t *S) -{ - int st; - do - st = close(S->SockFD); - while (st < 0 && errno == EINTR); -} - /* * Make the HTTP header's Referer line according to preferences * (default is "host" i.e. "scheme://hostname/" ) @@ -448,7 +437,7 @@ static int Http_connect_socket(ChainLink *Info) status = connect(S->SockFD, (struct sockaddr *)&name, socket_len); if (status == -1 && errno != EINPROGRESS) { S->Err = errno; - Http_socket_close(S); + dClose(S->SockFD); MSG("Http_connect_socket ERROR: %s\n", dStrerror(S->Err)); } else { a_Chain_bcb(OpSend, Info, &S->SockFD, "FD"); diff --git a/src/cookies.c b/src/cookies.c index e43a74a2..deaae2ab 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -90,7 +90,7 @@ static FILE *Cookies_fopen(const char *filename, char *init_str) filename, dStrerror(errno)); } } - close(fd); + dClose(fd); MSG("Cookies: Created file: %s\n", filename); F_in = fopen(filename, "r"); diff --git a/src/dns.c b/src/dns.c index 7ae19fe4..e288e8cc 100644 --- a/src/dns.c +++ b/src/dns.c @@ -217,9 +217,8 @@ void a_Dns_init(void) /* If the IPv6 address family is not available there is no point wasting time trying to connect to v6 addresses. */ int fd = socket(AF_INET6, SOCK_STREAM, 0); - if (fd >= 0) { - close(fd); - } + if (fd >= 0) + dClose(fd); } #endif } @@ -510,8 +509,8 @@ void a_Dns_freeall(void) dList_free(dns_cache[i].addr_list); } a_IOwatch_remove_fd(dns_notify_pipe[0], DIO_READ); - close(dns_notify_pipe[0]); - close(dns_notify_pipe[1]); + dClose(dns_notify_pipe[0]); + dClose(dns_notify_pipe[1]); dFree(dns_cache); } -- cgit v1.2.3 From 31476aea0c774e18c408abd10dc263fc63cd4e6c Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 9 Jan 2013 16:40:25 +0000 Subject: Reduced number of redraws when selecting text: unhighlight --- dw/textblock_iterator.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dw/textblock_iterator.cc b/dw/textblock_iterator.cc index cfd27941..245df374 100644 --- a/dw/textblock_iterator.cc +++ b/dw/textblock_iterator.cc @@ -145,6 +145,11 @@ void Textblock::TextblockIterator::unhighlight (int direction, if (textblock->hlStart[layer].index > textblock->hlEnd[layer].index) return; + int oldStartIndex = textblock->hlStart[layer].index; + int oldStartChar = textblock->hlStart[layer].nChar; + int oldEndIndex = textblock->hlEnd[layer].index; + int oldEndChar = textblock->hlEnd[layer].nChar; + if (direction == 0) { index1 = textblock->hlStart[layer].index; index2 = textblock->hlEnd[layer].index; @@ -160,7 +165,11 @@ void Textblock::TextblockIterator::unhighlight (int direction, textblock->hlEnd[layer].nChar = INT_MAX; } - textblock->queueDrawRange (index1, index2); + if (oldStartIndex != textblock->hlStart[layer].index || + oldStartChar != textblock->hlStart[layer].nChar || + oldEndIndex != textblock->hlEnd[layer].index || + oldEndChar != textblock->hlEnd[layer].nChar) + textblock->queueDrawRange (index1, index2); } void Textblock::TextblockIterator::getAllocation (int start, int end, -- cgit v1.2.3 From 1a1ec320522a49d0634e4d4293f1273b393d1e93 Mon Sep 17 00:00:00 2001 From: Jeremy Henty Date: Thu, 10 Jan 2013 08:07:01 +0000 Subject: uicmd.cc: consistent suggestions for save files 1: Suggest the same save file for "Save page" and "Save link". 2: Create the save file from the path and the query, ignoring the fragment. 3: Truncate the path and the query as necessary. --- src/uicmd.cc | 65 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/src/uicmd.cc b/src/uicmd.cc index a0c5760c..2d4134d1 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -814,30 +814,51 @@ void a_UIcmd_redirection0(void *vbw, const DilloUrl *url) /* * Return a suitable filename for a given URL path. */ -static char *UIcmd_make_save_filename(const char *pathstr) +static char *UIcmd_make_save_filename(const DilloUrl *url) { size_t MaxLen = 64; - char *FileName, *newname, *o, *n; - const char *name, *dir = save_dir; + const char *dir = save_dir, *path, *path2, *query; + char *name, *free1, *free2, *n1, *n2; - if ((name = strrchr(pathstr, '/'))) { - if (strlen(++name) > MaxLen) { - name = name + strlen(name) - MaxLen; - } - /* Replace %20 and ' ' with '_' in Filename */ - o = n = newname = dStrdup(name); - for (int i = 0; o[i]; i++) { - *n++ = (o[i] == ' ') ? '_' : - (o[i] == '%' && o[i+1] == '2' && o[i+2] == '0') ? - i+=2, '_' : o[i]; + free1 = free2 = NULL; + + /* get the last component of the path */ + path = URL_PATH(url); + path2 = strrchr(path, '/'); + path = path2 ? path2 + 1 : path; + + /* truncate the path if necessary */ + if (strlen(path) > MaxLen) { + path = free1 = dStrndup(path, MaxLen); + } + + /* is there a query? */ + query = URL_QUERY(url); + if (*query) { + /* truncate the query if necessary */ + if (strlen(query) > MaxLen) { + query = free2 = dStrndup(query, MaxLen); } - *n = 0; - FileName = dStrconcat(dir, newname, NULL); - dFree(newname); + name = dStrconcat(dir, path, "?", query, NULL); } else { - FileName = dStrconcat(dir, pathstr, NULL); + name = dStrconcat(dir, path, NULL); + } + + dFree(free1); + dFree(free2); + + /* Replace %20 and ' ' with '_' */ + for (n1 = n2 = name; *n1; n1++) { + *n2++ = + (n1[0] == ' ') + ? '_' : + (n1[0] == '%' && n1[1] == '2' && n1[2] == '0') + ? (n1 += 2, '_') : + n1[0]; } - return FileName; + *n2 = 0; + + return name; } /* @@ -882,7 +903,7 @@ static int UIcmd_save_file_check(const char *name) * Save a URL */ static void UIcmd_save(BrowserWindow *bw, const DilloUrl *url, - const char *title, const char *url_str) + const char *title) { const char *name; bool_t first_prompt = 1; @@ -891,7 +912,7 @@ static void UIcmd_save(BrowserWindow *bw, const DilloUrl *url, SuggestedName = first_prompt - ? UIcmd_make_save_filename(url_str) + ? UIcmd_make_save_filename(url) : dStrdup(name); first_prompt = 0; name = a_Dialog_save_file(title, NULL, SuggestedName); @@ -927,7 +948,7 @@ void a_UIcmd_save(void *vbw) const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw)); if (url) { - UIcmd_save(bw, url, "Save Page as File", URL_PATH(url)); + UIcmd_save(bw, url, "Save Page as File"); } } @@ -1048,7 +1069,7 @@ const char *a_UIcmd_get_passwd(const char *user) */ void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url) { - UIcmd_save(bw, url, "Dillo: Save Link as File", URL_STR(url)); + UIcmd_save(bw, url, "Dillo: Save Link as File"); } /* -- cgit v1.2.3 From bb5ecc4708a095cbcb29b8feeda2200a88fba3a0 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 10 Jan 2013 20:06:34 +0000 Subject: fix tab foreground color defaults I'll have to think of a way to make the mechanisms more consistent... --- src/dillo.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dillo.cc b/src/dillo.cc index 80d0c949..5ad34e78 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -272,8 +272,8 @@ static void setColors() fl_lighter(FL_BACKGROUND_COLOR)); setColorPrefWdef(prefs.ui_tab_active_bg_color, FL_BACKGROUND2_COLOR); setColorPrefWdef(prefs.ui_tab_bg_color, FL_BACKGROUND_COLOR); - setColorPrefWdef(prefs.ui_tab_active_fg_color, prefs.ui_fg_color); - setColorPrefWdef(prefs.ui_tab_fg_color, prefs.ui_fg_color); + setColorPrefWdef(prefs.ui_tab_active_fg_color, FL_FOREGROUND_COLOR); + setColorPrefWdef(prefs.ui_tab_fg_color, FL_FOREGROUND_COLOR); } /* -- cgit v1.2.3 From 2679808d70e4defa68cfeb3cdc9783e09fd58676 Mon Sep 17 00:00:00 2001 From: Jeremy Henty Date: Thu, 10 Jan 2013 21:10:21 +0000 Subject: uicmd.cc: *UIcmd_make_save_filename(): clarify the loop logic --- src/uicmd.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uicmd.cc b/src/uicmd.cc index 2d4134d1..0a1510d2 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -848,8 +848,8 @@ static char *UIcmd_make_save_filename(const DilloUrl *url) dFree(free2); /* Replace %20 and ' ' with '_' */ - for (n1 = n2 = name; *n1; n1++) { - *n2++ = + for (n1 = n2 = name; *n1; n1++, n2++) { + *n2 = (n1[0] == ' ') ? '_' : (n1[0] == '%' && n1[1] == '2' && n1[2] == '0') -- cgit v1.2.3 From b9f1468f7c49981b3c01e6308b25941aba4e4d94 Mon Sep 17 00:00:00 2001 From: p37sitdu Date: Fri, 11 Jan 2013 17:57:03 +0000 Subject: fix up dw namespace comments --- dw/core.hh | 4 +--- dw/events.hh | 2 +- dw/findtext.cc | 2 +- dw/findtext.hh | 2 +- dw/fltkcore.hh | 2 +- dw/fltkimgbuf.cc | 2 +- dw/fltkimgbuf.hh | 2 +- dw/imgbuf.hh | 2 +- dw/iterator.cc | 2 +- dw/iterator.hh | 2 +- dw/layout.cc | 3 +-- dw/layout.hh | 2 +- dw/platform.hh | 2 +- dw/selection.cc | 2 +- dw/selection.hh | 2 +- dw/style.cc | 2 +- dw/style.hh | 2 +- dw/types.cc | 2 +- dw/types.hh | 2 +- dw/ui.cc | 2 +- dw/view.hh | 2 +- dw/widget.cc | 4 +--- dw/widget.hh | 2 +- 23 files changed, 23 insertions(+), 28 deletions(-) diff --git a/dw/core.hh b/dw/core.hh index b6e18c10..13545bfe 100644 --- a/dw/core.hh +++ b/dw/core.hh @@ -31,10 +31,8 @@ namespace ui { class ResourceFactory; } // namespace ui - - -} // namespace dw } // namespace core +} // namespace dw #include "../lout/object.hh" #include "../lout/container.hh" diff --git a/dw/events.hh b/dw/events.hh index c29cb7f4..5309186e 100644 --- a/dw/events.hh +++ b/dw/events.hh @@ -77,7 +77,7 @@ public: Widget *lastWidget, *currentWidget; }; -} // namespace dw } // namespace core +} // namespace dw #endif // __DW_EVENTS_HH__ diff --git a/dw/findtext.cc b/dw/findtext.cc index 9793db91..05896ebd 100644 --- a/dw/findtext.cc +++ b/dw/findtext.cc @@ -288,5 +288,5 @@ bool FindtextState::search0 (bool backwards, bool firstTrial) return ret; } -} // namespace dw } // namespace core +} // namespace dw diff --git a/dw/findtext.hh b/dw/findtext.hh index 14789878..c6803485 100644 --- a/dw/findtext.hh +++ b/dw/findtext.hh @@ -78,7 +78,7 @@ public: void resetSearch (); }; -} // namespace dw } // namespace core +} // namespace dw #endif // __DW_FINDTEXT_STATE_H__ diff --git a/dw/fltkcore.hh b/dw/fltkcore.hh index 376f588e..2a20a610 100644 --- a/dw/fltkcore.hh +++ b/dw/fltkcore.hh @@ -11,7 +11,7 @@ class FltkResource; } // namespace ui } // namespace fltk -} // namespace core +} // namespace dw #include diff --git a/dw/fltkimgbuf.cc b/dw/fltkimgbuf.cc index 4ede6c5b..3c3c9236 100644 --- a/dw/fltkimgbuf.cc +++ b/dw/fltkimgbuf.cc @@ -326,5 +326,5 @@ void FltkImgbuf::draw (Fl_Widget *target, int xRoot, int yRoot, } -} // namespace dw } // namespace fltk +} // namespace dw diff --git a/dw/fltkimgbuf.hh b/dw/fltkimgbuf.hh index 30e0cc37..34c6bfd8 100644 --- a/dw/fltkimgbuf.hh +++ b/dw/fltkimgbuf.hh @@ -59,7 +59,7 @@ public: int x, int y, int width, int height); }; -} // namespace dw } // namespace fltk +} // namespace dw #endif // __DW_FLTK_IMGBUF_HH__ diff --git a/dw/imgbuf.hh b/dw/imgbuf.hh index d6f41d21..02ba9087 100644 --- a/dw/imgbuf.hh +++ b/dw/imgbuf.hh @@ -202,7 +202,7 @@ public: virtual bool isReferred () = 0; }; -} // namespace dw } // namespace core +} // namespace dw #endif // __DW_IMGBUF_HH__ diff --git a/dw/iterator.cc b/dw/iterator.cc index e9431e9b..5f46cbdb 100644 --- a/dw/iterator.cc +++ b/dw/iterator.cc @@ -794,5 +794,5 @@ void CharIterator::unhighlight (CharIterator *it1, CharIterator *it2, } } -} // namespace dw } // namespace core +} // namespace dw diff --git a/dw/iterator.hh b/dw/iterator.hh index 838d66a1..c5cfd72b 100644 --- a/dw/iterator.hh +++ b/dw/iterator.hh @@ -252,7 +252,7 @@ public: hpos, vpos); } }; -} // namespace dw } // namespace core +} // namespace dw #endif // __ITERATOR_HH__ diff --git a/dw/layout.cc b/dw/layout.cc index be7a44ce..a974378f 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -1050,6 +1050,5 @@ void Layout::viewportSizeChanged (View *view, int width, int height) setSizeHints (); } -} // namespace dw } // namespace core - +} // namespace dw diff --git a/dw/layout.hh b/dw/layout.hh index 7f33594b..d3ace03a 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -389,8 +389,8 @@ public: inline style::Color* getBgColor () { return bgColor; } }; -} // namespace dw } // namespace core +} // namespace dw #endif // __DW_LAYOUT_HH__ diff --git a/dw/platform.hh b/dw/platform.hh index c7eb37ee..1e16dcfe 100644 --- a/dw/platform.hh +++ b/dw/platform.hh @@ -164,7 +164,7 @@ public: virtual ui::ResourceFactory *getResourceFactory () = 0; }; -} // namespace dw } // namespace core +} // namespace dw #endif // __DW_PLATFORM_HH__ diff --git a/dw/selection.cc b/dw/selection.cc index 64a0b526..8b4cf318 100644 --- a/dw/selection.cc +++ b/dw/selection.cc @@ -476,5 +476,5 @@ void SelectionState::copy() } } -} // namespace dw } // namespace core +} // namespace dw diff --git a/dw/selection.hh b/dw/selection.hh index 7f6b1a58..ef9df0e0 100644 --- a/dw/selection.hh +++ b/dw/selection.hh @@ -235,7 +235,7 @@ public: int linkNo, MousePositionEvent *event); }; -} // namespace dw } // namespace core +} // namespace dw #endif // __DW_SELECTION_H__ diff --git a/dw/style.cc b/dw/style.cc index c14f3123..6c0abda2 100644 --- a/dw/style.cc +++ b/dw/style.cc @@ -958,5 +958,5 @@ void numtostr (int num, char *buf, int buflen, ListStyleType listStyleType) } } // namespace style -} // namespace dw } // namespace core +} // namespace dw diff --git a/dw/style.hh b/dw/style.hh index cd9012c5..7c00ac1f 100644 --- a/dw/style.hh +++ b/dw/style.hh @@ -686,8 +686,8 @@ void drawBackground (View *view, Rectangle *area, void numtostr (int num, char *buf, int buflen, ListStyleType listStyleType); } // namespace style -} // namespace dw } // namespace core +} // namespace dw #endif // __DW_STYLE_HH__ diff --git a/dw/types.cc b/dw/types.cc index 074cb352..86836bc1 100644 --- a/dw/types.cc +++ b/dw/types.cc @@ -268,5 +268,5 @@ void Region::addRectangle (Rectangle *rPointer) rectangleList->append (r); } -} // namespace dw } // namespace core +} // namespace dw diff --git a/dw/types.hh b/dw/types.hh index 65983fad..f04fc138 100644 --- a/dw/types.hh +++ b/dw/types.hh @@ -207,7 +207,7 @@ struct Content }; }; -} // namespace dw } // namespace core +} // namespace dw #endif // __DW_TYPES_HH__ diff --git a/dw/ui.cc b/dw/ui.cc index 35d63f6c..dd98b2e9 100644 --- a/dw/ui.cc +++ b/dw/ui.cc @@ -381,5 +381,5 @@ Iterator *RadioButtonResource::iterator (Content::Type mask, bool atEnd) } // namespace ui } // namespace core -} // namespace core +} // namespace dw diff --git a/dw/view.hh b/dw/view.hh index da9bdce4..8037dc62 100644 --- a/dw/view.hh +++ b/dw/view.hh @@ -205,7 +205,7 @@ public: virtual void mergeClippingView (View *clippingView) = 0; }; -} // namespace dw } // namespace core +} // namespace dw #endif // __DW_VIEW_HH__ diff --git a/dw/widget.cc b/dw/widget.cc index 3c788565..1d9f96e4 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -617,7 +617,5 @@ void Widget::removeChild (Widget *child) misc::assertNotReached (); } - - -} // namespace dw } // namespace core +} // namespace dw diff --git a/dw/widget.hh b/dw/widget.hh index 02a20f44..6942221b 100644 --- a/dw/widget.hh +++ b/dw/widget.hh @@ -306,7 +306,7 @@ public: virtual void removeChild (Widget *child); }; -} // namespace dw } // namespace core +} // namespace dw #endif // __DW_WIDGET_HH__ -- cgit v1.2.3 From 62ad3098f33f42dcf10d6eaff63c726bece9497e Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 11 Jan 2013 17:07:45 -0300 Subject: Modified a_Dialog_choice5() to accept any number of alternatives [p37sitdu] --- src/dialog.cc | 96 ++++++++++++++++++++++++++++------------------------------- src/dialog.hh | 4 +-- src/dpiapi.c | 4 +-- src/nav.c | 6 ++-- src/uicmd.cc | 16 +++++----- 5 files changed, 60 insertions(+), 66 deletions(-) diff --git a/src/dialog.cc b/src/dialog.cc index 83b9ed8b..484eebc4 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -36,7 +36,7 @@ */ static int input_answer; static char *input_str = NULL; -static int choice5_answer; +static int choice_answer; /* @@ -321,54 +321,50 @@ void a_Dialog_text_window(const char *title, const char *txt) /*--------------------------------------------------------------------------*/ -static void choice5_cb(Fl_Widget *button, void *number) +static void choice_cb(Fl_Widget *button, void *number) { - choice5_answer = VOIDP2INT(number); - _MSG("choice5_cb: %d\n", choice5_answer); + choice_answer = VOIDP2INT(number); + _MSG("choice_cb: %d\n", choice_answer); button->window()->hide(); } /* - * Make a question-dialog with a question and up to five alternatives. - * (if less alternatives, non used parameters must be NULL). + * Make a question-dialog with a question and alternatives. + * Last parameter must be NULL. * - * Return value: 0 = dialog was cancelled, 1-5 = selected alternative. + * Return value: 0 = dialog was cancelled, >0 = selected alternative. */ -int a_Dialog_choice5(const char *title, const char *msg, - const char *alt1, const char *alt2, const char *alt3, - const char *alt4, const char *alt5) +int a_Dialog_choice(const char *title, const char *msg, ...) { - choice5_answer = 0; + va_list ap; + int i, n; - int ww = 440, wh = 120, bw = 50, bh = 45, ih = 50, nb = 0; - const char *txt[7]; - - if (!(title && *title)) + if (title == NULL || *title == '\0') title = "Dillo: Choice"; - if (!msg) - msg = ""; - - txt[0] = txt[6] = NULL; - txt[1] = alt1; txt[2] = alt2; txt[3] = alt3; - txt[4] = alt4; txt[5] = alt5; - for (int i=1; txt[i]; ++i, ++nb) - ; - - if (!nb) { - MSG_ERR("a_Dialog_choice5: No choices.\n"); - return choice5_answer; + + va_start(ap, msg); + for (n = 0; va_arg(ap, char *) != NULL; n++); + va_end(ap); + + if (n == 0) { + MSG_ERR("Dialog_choice: no alternatives.\n"); + return 0; } - ww = 140 + nb*(bw+10); - Fl_Window *window = new Fl_Window(ww,wh,title); + int gap = 8; + int ww = 140 + n * 60, wh = 120; + int bw = (ww - gap) / n - gap, bh = 45; + int ih = 50; + + Fl_Window *window = new Fl_Window(ww, wh, title); window->set_modal(); window->begin(); - Fl_Group* ib = new Fl_Group(0,0,window->w(),window->h()); + Fl_Group *ib = new Fl_Group(0, 0, window->w(), window->h()); ib->begin(); window->resizable(ib); - + /* '?' Icon */ - Fl_Box* o = new Fl_Box(10, (wh-bh-ih)/2, ih, ih); + Fl_Box *o = new Fl_Box(10, (wh - bh - ih) / 2, ih, ih); o->box(FL_THIN_UP_BOX); o->labelfont(FL_TIMES_BOLD); o->labelsize(34); @@ -376,36 +372,36 @@ int a_Dialog_choice5(const char *title, const char *msg, o->labelcolor(FL_BLUE); o->label("?"); o->show(); - - Fl_Box *box = new Fl_Box(60,0,ww-60,wh-bh, msg); - box->labelfont(FL_HELVETICA); - box->labelsize(14); - box->align(FL_ALIGN_WRAP); - - Fl_Button *b; - int xpos = 0, gap = 8; - bw = (ww - gap)/nb - gap; - xpos += gap; - for (int i=1; i <= nb; ++i) { - b = new EnterButton(xpos, wh-bh, bw, bh, txt[i]); - b->align(FL_ALIGN_WRAP|FL_ALIGN_CLIP); + + if (msg != NULL){ + Fl_Box *box = new Fl_Box(60, 0, ww - 60, wh - bh, msg); + box->labelfont(FL_HELVETICA); + box->labelsize(14); + box->align(FL_ALIGN_WRAP); + } + + int xpos = gap; + va_start(ap, msg); + for (i = 1; i <= n; i++) { + Fl_Button *b = new EnterButton(xpos, wh-bh, bw, bh, va_arg(ap, char *)); + b->align(FL_ALIGN_WRAP | FL_ALIGN_CLIP); b->box(FL_UP_BOX); - b->callback(choice5_cb, INT2VOIDP(i)); + b->callback(choice_cb, INT2VOIDP(i)); xpos += bw + gap; /* TODO: set focus to the *-prefixed alternative */ } + va_end(ap); window->end(); window->show(); while (window->shown()) Fl::wait(); - _MSG("a_Dialog_choice5 answer = %d\n", choice5_answer); + _MSG("Dialog_choice answer = %d\n", answer); delete window; - return choice5_answer; + return choice_answer; } - /*--------------------------------------------------------------------------*/ static void Dialog_user_password_cb(Fl_Widget *button, void *) { @@ -443,7 +439,7 @@ int a_Dialog_user_password(const char *title, const char *msg, fl_font(msg_box->labelfont(), msg_box->labelsize()); msg_w -= 6; /* The label doesn't fill the entire box. */ - fl_measure(msg_box->label(), msg_w, msg_h, 0); /* fl_measure wraps at msg_w */ + fl_measure(msg_box->label(), msg_w, msg_h, 0); // fl_measure wraps at msg_w msg_box->size(msg_box->w(), msg_h); window->add(msg_box); diff --git a/src/dialog.hh b/src/dialog.hh index 8b3bc1b7..0a489590 100644 --- a/src/dialog.hh +++ b/src/dialog.hh @@ -9,9 +9,7 @@ typedef void (*UserPasswordCB)(const char *user, const char *password, void *vp); void a_Dialog_msg(const char *title, const char *msg); -int a_Dialog_choice5(const char *title, const char *msg, - const char *alt1, const char *alt2, const char *alt3, - const char *alt4, const char *alt5); +int a_Dialog_choice(const char *title, const char *msg, ...); int a_Dialog_user_password(const char *title, const char *msg, UserPasswordCB cb, void *vp); const char *a_Dialog_input(const char *title, const char *msg); diff --git a/src/dpiapi.c b/src/dpiapi.c index d8980a17..4cdde96e 100644 --- a/src/dpiapi.c +++ b/src/dpiapi.c @@ -69,8 +69,8 @@ void a_Dpiapi_dialog(BrowserWindow *bw, char *server, char *dpip_tag) alt4 = a_Dpip_get_attr_l(dpip_tag, dpip_tag_len, "alt4"); alt5 = a_Dpip_get_attr_l(dpip_tag, dpip_tag_len, "alt5"); - ret = a_Dialog_choice5(title, msg, alt1, alt2, alt3, alt4, alt5); - /* As choice5 is modal, call the callback function directly. */ + ret = a_Dialog_choice(title, msg, alt1, alt2, alt3, alt4, alt5, NULL); + /* As choice is modal, call the callback function directly. */ Dpiapi_dialog_answer_cb(bw, ret); dFree(alt1); dFree(alt2); dFree(alt3); dFree(alt4); dFree(alt5); diff --git a/src/nav.c b/src/nav.c index 2cf51c23..2e4f2233 100644 --- a/src/nav.c +++ b/src/nav.c @@ -487,9 +487,9 @@ static void Nav_reload_callback(void *data) confirmed = 1; } else if (URL_FLAGS(h_url) & URL_Post) { /* Attempt to repost data, let's confirm... */ - choice = a_Dialog_choice5("Dillo: Repost form?", - "Repost form data?", - "No", "Yes", "Cancel", NULL, NULL); + choice = a_Dialog_choice("Dillo: Repost form?", + "Repost form data?", + "No", "Yes", "Cancel", NULL); confirmed = (choice == 2); /* "Yes" */ } diff --git a/src/uicmd.cc b/src/uicmd.cc index 0a1510d2..be2359da 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -503,9 +503,9 @@ static void win_cb (Fl_Widget *w, void *cb_data) { } if (prefs.show_quit_dialog && ntabs > 1) - choice = a_Dialog_choice5("Dillo: Close window?", - "Window contains more than one tab.", - "Close", "Cancel", NULL, NULL, NULL); + choice = a_Dialog_choice("Dillo: Close window?", + "Window contains more than one tab.", + "Close", "Cancel", NULL); if (choice == 1) while (ntabs-- > 0) a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(tabs->wizard()->value())); @@ -644,9 +644,9 @@ void a_UIcmd_close_all_bw(void *) int choice = 1; if (prefs.show_quit_dialog && a_Bw_num() > 1) - choice = a_Dialog_choice5("Dillo: Quit?", - "More than one open tab or window.", - "Quit", "Cancel", NULL, NULL, NULL); + choice = a_Dialog_choice("Dillo: Quit?", + "More than one open tab or window.", + "Quit", "Cancel", NULL); if (choice == 1) while ((bw = a_Bw_get(0))) a_UIcmd_close_bw((void*)bw); @@ -890,8 +890,8 @@ static int UIcmd_save_file_check(const char *name) dStr_sprintf(ds, "The file:\n %s (%d Bytes)\nalready exists. What do we do?", name, (int)ss.st_size); - ch = a_Dialog_choice5("Dillo Save: File exists!", ds->str, - "Abort", "Continue", "Rename", NULL, NULL); + ch = a_Dialog_choice("Dillo Save: File exists!", ds->str, + "Abort", "Continue", "Rename", NULL); dStr_free(ds, 1); return ch; } else { -- cgit v1.2.3 From e0d4ebb62c7fba10aeb4490ead349c71aa1cee14 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 11 Jan 2013 17:08:01 -0300 Subject: Changed color average from 0.1f to 0.14f --- src/ui.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui.cc b/src/ui.cc index a0ec32a2..9ff4a0a4 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -409,17 +409,17 @@ void UI::make_toolbar(int tw, int th) if (!icons->ImgLeftIn) { icons->ImgLeftIn = icons->ImgLeft->copy(); icons->ImgLeftIn->desaturate(); - icons->ImgLeftIn->color_average(FL_BACKGROUND_COLOR, .1f); + icons->ImgLeftIn->color_average(FL_BACKGROUND_COLOR, .14f); } if (!icons->ImgRightIn) { icons->ImgRightIn = icons->ImgRight->copy(); icons->ImgRightIn->desaturate(); - icons->ImgRightIn->color_average(FL_BACKGROUND_COLOR, .1f); + icons->ImgRightIn->color_average(FL_BACKGROUND_COLOR, .14f); } if (!icons->ImgStopIn) { icons->ImgStopIn = icons->ImgStop->copy(); icons->ImgStopIn->desaturate(); - icons->ImgStopIn->color_average(FL_BACKGROUND_COLOR, .1f); + icons->ImgStopIn->color_average(FL_BACKGROUND_COLOR, .14f); } Back = make_button("Back", icons->ImgLeft, icons->ImgLeftIn, UI_BACK, 1); Forw = make_button("Forw", icons->ImgRight, icons->ImgRightIn, UI_FORW); -- cgit v1.2.3 From 69666a2dafc8a00e5029f4b671ed94d5be38e109 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 12 Jan 2013 19:14:49 +0100 Subject: compute stretchability and shrinkability dynamically Together with the removal of another unused field this reduces the size of struct Word by 8 bytes. --- dw/textblock.cc | 8 +------- dw/textblock.hh | 4 ++-- dw/textblock_linebreaking.cc | 29 +++++++++++++++++++++-------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/dw/textblock.cc b/dw/textblock.cc index 8d0e0bcb..068a7c0d 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -1325,8 +1325,7 @@ void Textblock::fillWord (Word *word, int width, int ascent, int descent, word->size.width = width; word->size.ascent = ascent; word->size.descent = descent; - word->origSpace = word->effSpace = word->stretchability = - word->shrinkability = 0; + word->origSpace = word->effSpace = 0; word->hyphenWidth = 0; word->badnessAndPenalty.setPenalty (PENALTY_PROHIBIT_BREAK); word->content.space = false; @@ -1817,11 +1816,6 @@ void Textblock::fillSpace (Word *word, core::style::Style *style) word->content.space = true; word->effSpace = word->origSpace = style->font->spaceWidth + style->wordSpacing; - word->stretchability = word->origSpace / 2; - if(style->textAlign == core::style::TEXT_ALIGN_JUSTIFY) - word->shrinkability = word->origSpace / 3; - else - word->shrinkability = 0; //DBG_OBJ_ARRSET_NUM (this, "words.%d.origSpace", wordIndex, // word->origSpace); diff --git a/dw/textblock.hh b/dw/textblock.hh index 39088da6..d5b64e42 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -315,7 +315,6 @@ protected: core::Requisition size; /* Space after the word, only if it's not a break: */ short origSpace; /* from font, set by addSpace */ - short stretchability, shrinkability; short effSpace; /* effective space, set by wordWrap, * used for drawing etc. */ short hyphenWidth; /* Additional width, when a word is part @@ -325,7 +324,6 @@ protected: * "hyphenWidth > 0" is also used to decide * whether to draw a hyphen. */ short flags; - short penaltyIndex; core::Content content; // accumulated values, relative to the beginning of the line @@ -561,6 +559,8 @@ protected: void handleWordExtremes (int wordIndex); void correctLastWordExtremes (); + static int getShrinkability(struct Word *word); + static int getStretchability(struct Word *word); int hyphenateWord (int wordIndex); void accumulateWordForLine (int lineIndex, int wordIndex); void accumulateWordData (int wordIndex); diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 47c7fa00..35273565 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -250,8 +250,8 @@ void Textblock::printWord (Word *word) printWordWithFlags (word); printf (" [%d / %d + %d - %d => %d + %d - %d] => ", - word->size.width, word->origSpace, word->stretchability, - word->shrinkability, word->totalWidth, word->totalStretchability, + word->size.width, word->origSpace, getStretchability(word), + getShrinkability(word), word->totalWidth, word->totalStretchability, word->totalShrinkability); word->badnessAndPenalty.print (); } @@ -269,14 +269,14 @@ void Textblock::justifyLine (Line *line, int diff) if (diff > 0) { int stretchabilitySum = 0; for (int i = line->firstWord; i < line->lastWord; i++) - stretchabilitySum += words->getRef(i)->stretchability; + stretchabilitySum += getStretchability(words->getRef(i)); if (stretchabilitySum > 0) { int stretchabilityCum = 0; int spaceDiffCum = 0; for (int i = line->firstWord; i < line->lastWord; i++) { Word *word = words->getRef (i); - stretchabilityCum += word->stretchability; + stretchabilityCum += getStretchability(word); int spaceDiff = stretchabilityCum * diff / stretchabilitySum - spaceDiffCum; spaceDiffCum += spaceDiff; @@ -290,14 +290,14 @@ void Textblock::justifyLine (Line *line, int diff) } else if (diff < 0) { int shrinkabilitySum = 0; for (int i = line->firstWord; i < line->lastWord; i++) - shrinkabilitySum += words->getRef(i)->shrinkability; + shrinkabilitySum += getShrinkability(words->getRef(i)); if (shrinkabilitySum > 0) { int shrinkabilityCum = 0; int spaceDiffCum = 0; for (int i = line->firstWord; i < line->lastWord; i++) { Word *word = words->getRef (i); - shrinkabilityCum += word->shrinkability; + shrinkabilityCum += getShrinkability(word); int spaceDiff = shrinkabilityCum * diff / shrinkabilitySum - spaceDiffCum; spaceDiffCum += spaceDiff; @@ -929,9 +929,9 @@ void Textblock::accumulateWordData (int wordIndex) + prevWord->origSpace - prevWord->hyphenWidth + word->size.width + word->hyphenWidth; word->totalStretchability = - prevWord->totalStretchability + prevWord->stretchability; + prevWord->totalStretchability + getStretchability(prevWord); word->totalShrinkability = - prevWord->totalShrinkability + prevWord->shrinkability; + prevWord->totalShrinkability + getShrinkability(prevWord); } word->badnessAndPenalty.calcBadness (word->totalWidth, availWidth, @@ -1147,4 +1147,17 @@ void Textblock::removeTemporaryLines () lines->setSize (nonTemporaryLines); } +int Textblock::getShrinkability(struct Word *word) +{ + if (word->spaceStyle->textAlign == core::style::TEXT_ALIGN_JUSTIFY) + return word->origSpace / 3; + else + return 0; +} + +int Textblock::getStretchability(struct Word *word) +{ + return word->origSpace / 2; +} + } // namespace dw -- cgit v1.2.3 From 0f0e7cc54aecab1647bdcd222c84d17275b92313 Mon Sep 17 00:00:00 2001 From: "p37sitdu, corvid" Date: Sat, 12 Jan 2013 20:13:36 +0000 Subject: clean up struct typedefs --- dlib/dlib.h | 8 +++----- dpi/ftp.c | 2 +- dpip/dpip.h | 5 ++--- src/bitvec.h | 6 ++---- src/bw.h | 8 ++------ src/cache.h | 5 +++-- src/chain.h | 10 ++++------ src/decode.h | 10 ++++------ src/dicache.c | 5 ++--- src/dicache.h | 8 +++----- src/dns.h | 4 ++-- src/domain.c | 2 +- src/gif.c | 2 +- src/html_common.hh | 11 ++++------- src/jpeg.c | 10 ++++++---- src/klist.h | 11 ++++------- src/misc.c | 2 +- src/nav.c | 6 ++---- src/png.c | 3 +-- src/prefs.h | 6 ++---- src/prefsparser.cc | 2 +- src/url.h | 6 ++---- 22 files changed, 53 insertions(+), 79 deletions(-) diff --git a/dlib/dlib.h b/dlib/dlib.h index 0d194dbe..87335e00 100644 --- a/dlib/dlib.h +++ b/dlib/dlib.h @@ -99,7 +99,7 @@ int dStrnAsciiCasecmp(const char *s1, const char *s2, size_t n); */ #define Dstr_char_t char -typedef struct _dstr { +typedef struct { int sz; /* allocated size (private) */ int len; Dstr_char_t *str; @@ -128,13 +128,11 @@ const char *dStr_printable(Dstr *in, int maxlen); /* *-- dList -------------------------------------------------------------------- */ -struct Dlist_ { +typedef struct { int sz; /* allocated size (private) */ int len; void **list; -}; - -typedef struct Dlist_ Dlist; +} Dlist; /* dCompareFunc: * Return: 0 if parameters are equal (for dList_find_custom). diff --git a/dpi/ftp.c b/dpi/ftp.c index 288f993c..fa64eb6e 100644 --- a/dpi/ftp.c +++ b/dpi/ftp.c @@ -62,7 +62,7 @@ static char **dl_argv = NULL; /*---------------------------------------------------------------------------*/ /* TODO: could use dStr ADT! */ -typedef struct ContentType_ { +typedef struct { const char *str; int len; } ContentType_t; diff --git a/dpip/dpip.h b/dpip/dpip.h index 083732ff..1a1846df 100644 --- a/dpip/dpip.h +++ b/dpip/dpip.h @@ -28,8 +28,7 @@ typedef enum { /* * Dpip socket handler type. */ -typedef struct _DpipSocketHandler Dsh; -struct _DpipSocketHandler { +typedef struct { int fd_in; int fd_out; /* FILE *in; --Unused. The stream functions block when reading. */ @@ -41,7 +40,7 @@ struct _DpipSocketHandler { int mode; /* mode flags: DPIP_TAG | DPIP_LAST_TAG | DPIP_RAW */ int status; /* status code: DPIP_EAGAIN | DPIP_ERROR | DPIP_EOF */ -}; +} Dsh; /* diff --git a/src/bitvec.h b/src/bitvec.h index f9063070..d2f6d9e1 100644 --- a/src/bitvec.h +++ b/src/bitvec.h @@ -6,12 +6,10 @@ #define BVEC_TYPE uchar_t #define BVEC_SIZE sizeof(BVEC_TYPE) -typedef struct _bitvec bitvec_t; - -struct _bitvec { +typedef struct { BVEC_TYPE *vec; int len; /* number of bits [1 based] */ -}; +} bitvec_t; /* diff --git a/src/bw.h b/src/bw.h index 590af4fb..e07c9c34 100644 --- a/src/bw.h +++ b/src/bw.h @@ -11,12 +11,8 @@ #define BW_Force (4) /* Stop connection too */ -typedef struct _BrowserWindow BrowserWindow; - - /* browser_window contains the specific data for a single window */ -struct _BrowserWindow -{ +typedef struct { /* Pointer to the UI object this bw belongs to */ void *ui; @@ -61,7 +57,7 @@ struct _BrowserWindow /* HTML-bugs detected at parse time */ int num_page_bugs; Dstr *page_bugs; -}; +} BrowserWindow; #ifdef __cplusplus diff --git a/src/cache.h b/src/cache.h index c01bec55..c39e4600 100644 --- a/src/cache.h +++ b/src/cache.h @@ -34,16 +34,17 @@ extern "C" { #define CA_HugeFile 0x1000 /* URL content is too big */ #define CA_IsEmpty 0x2000 /* True until a byte of content arrives */ +typedef struct CacheClient CacheClient_t; + /* * Callback type for cache clients */ -typedef struct _CacheClient CacheClient_t; typedef void (*CA_Callback_t)(int Op, CacheClient_t *Client); /* * Data structure for cache clients. */ -struct _CacheClient { +struct CacheClient { int Key; /* Primary Key for this client */ const DilloUrl *Url; /* Pointer to a cache entry Url */ int Version; /* Dicache version of this Url (0 if not used) */ diff --git a/src/chain.h b/src/chain.h index fd86557c..10957dc3 100644 --- a/src/chain.h +++ b/src/chain.h @@ -29,14 +29,12 @@ #define FWD 1 #define BCK 2 - -typedef struct _ChainLink ChainLink; -typedef struct _DataBuf DataBuf; +typedef struct ChainLink ChainLink; typedef void (*ChainFunction_t)(int Op, int Branch, int Dir, ChainLink *Info, void *Data1, void *Data2); /* This is the main data structure for CCC nodes */ -struct _ChainLink { +struct ChainLink { void *LocalKey; int Flags; @@ -51,11 +49,11 @@ struct _ChainLink { }; /* A convenience data structure for passing data chunks between nodes */ -struct _DataBuf { +typedef struct { char *Buf; int Size; int Code; -}; +} DataBuf; diff --git a/src/decode.h b/src/decode.h index 064177eb..279807a6 100644 --- a/src/decode.h +++ b/src/decode.h @@ -7,15 +7,13 @@ extern "C" { #endif /* __cplusplus */ -typedef struct _Decode Decode; - -struct _Decode { +typedef struct Decode { char *buffer; Dstr *leftover; void *state; - Dstr *(*decode) (Decode *dc, const char *instr, int inlen); - void (*free) (Decode *dc); -}; + Dstr *(*decode) (struct Decode *dc, const char *instr, int inlen); + void (*free) (struct Decode *dc); +} Decode; Decode *a_Decode_transfer_init(const char *format); Decode *a_Decode_content_init(const char *format); diff --git a/src/dicache.c b/src/dicache.c index e700f000..23721685 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -21,7 +21,6 @@ #include "dgif.h" #include "djpeg.h" -typedef struct _DICacheNode DICacheNode; enum { DIC_Gif, @@ -29,11 +28,11 @@ enum { DIC_Jpeg }; -struct _DICacheNode { +typedef struct { int valid; /* flag */ DilloUrl *url; /* primary "Key" for this dicache entry */ DICacheEntry *first; /* pointer to the first dicache entry in this list */ -}; +} DICacheNode; /* * List of DICacheNode. One node per URL. Each node may have several diff --git a/src/dicache.h b/src/dicache.h index 70adb6c0..76fdba92 100644 --- a/src/dicache.h +++ b/src/dicache.h @@ -24,9 +24,7 @@ typedef enum { DIC_Abort /* Image transfer aborted */ } DicEntryState; -typedef struct _DICacheEntry DICacheEntry; - -struct _DICacheEntry { +typedef struct DICacheEntry { DilloUrl *url; /* Image URL for this entry */ uint_t width, height; /* As taken from image data */ DilloImgType type; /* Image type */ @@ -44,8 +42,8 @@ struct _DICacheEntry { void *DecoderData; /* Client function data */ uint_t DecodedSize; /* Size of already decoded data */ - DICacheEntry *next; /* Link to the next "newer" version */ -}; + struct DICacheEntry *next; /* Link to the next "newer" version */ +} DICacheEntry; void a_Dicache_init (void); diff --git a/src/dns.h b/src/dns.h index 70c0b8dc..61ae6410 100644 --- a/src/dns.h +++ b/src/dns.h @@ -20,12 +20,12 @@ void a_Dns_resolve(const char *hostname, DnsCallback_t cb_func, void *cb_data); # define DILLO_ADDR_MAX sizeof(struct in_addr) #endif -typedef struct _DilloHost -{ +typedef struct { int af; int alen; char data[DILLO_ADDR_MAX]; } DilloHost; + void a_Dns_dillohost_to_string(DilloHost *host, char *dst, size_t size); #ifdef __cplusplus diff --git a/src/domain.c b/src/domain.c index 90d6b414..be5d2221 100644 --- a/src/domain.c +++ b/src/domain.c @@ -14,7 +14,7 @@ #include "list.h" #include "domain.h" -typedef struct Rule { +typedef struct { char *origin; char *destination; } Rule; diff --git a/src/gif.c b/src/gif.c index 61407982..554ffa83 100644 --- a/src/gif.c +++ b/src/gif.c @@ -79,7 +79,7 @@ #define MAX_LWZ_BITS 12 -typedef struct _DilloGif { +typedef struct { DilloImage *Image; DilloUrl *url; int version; diff --git a/src/html_common.hh b/src/html_common.hh index a89e1cb5..cdb856db 100644 --- a/src/html_common.hh +++ b/src/html_common.hh @@ -39,9 +39,6 @@ * Typedefs */ -typedef struct _DilloHtmlImage DilloHtmlImage; -typedef struct _DilloHtmlState DilloHtmlState; - typedef enum { DT_NONE, DT_HTML, @@ -94,12 +91,12 @@ typedef enum { * Data Structures */ -struct _DilloHtmlImage { +typedef struct { DilloUrl *url; DilloImage *image; -}; +} DilloHtmlImage; -struct _DilloHtmlState { +typedef struct { DilloHtmlParseMode parse_mode; DilloHtmlTableMode table_mode; DilloHtmlTableBorderMode table_border_mode; @@ -120,7 +117,7 @@ struct _DilloHtmlState { have to be "handed over" (see Html_add_indented and Html_eventually_pop_dw). */ bool hand_over_break; -}; +} DilloHtmlState; /* * Classes diff --git a/src/jpeg.c b/src/jpeg.c index b99d0bc7..c81afe1d 100644 --- a/src/jpeg.c +++ b/src/jpeg.c @@ -46,20 +46,22 @@ typedef enum { DILLO_JPEG_ERROR } DilloJpegState; +typedef struct DilloJpeg DilloJpeg; + /* An implementation of a suspending source manager */ typedef struct { struct jpeg_source_mgr pub; /* public fields */ - struct DilloJpeg *jpeg; /* a pointer back to the jpeg object */ + DilloJpeg *jpeg; /* a pointer back to the jpeg object */ } my_source_mgr; struct my_error_mgr { struct jpeg_error_mgr pub; /* "public" fields */ jmp_buf setjmp_buffer; /* for return to caller */ }; -typedef struct my_error_mgr * my_error_ptr; +typedef struct my_error_mgr *my_error_ptr; -typedef struct DilloJpeg { +struct DilloJpeg { DilloImage *Image; DilloUrl *url; int version; @@ -74,7 +76,7 @@ typedef struct DilloJpeg { struct jpeg_decompress_struct cinfo; struct my_error_mgr jerr; -} DilloJpeg; +}; /* * Forward declarations diff --git a/src/klist.h b/src/klist.h index 53b2bc31..04e14d33 100644 --- a/src/klist.h +++ b/src/klist.h @@ -8,19 +8,16 @@ extern "C" { #endif /* __cplusplus */ -typedef struct _KlistNode KlistNode_t; -typedef struct _Klist Klist_t; - -struct _KlistNode { +typedef struct { int Key; /* primary key */ void *Data; /* data reference */ -}; +} KlistNode_t; -struct _Klist { +typedef struct { Dlist *List; int Clean; /* check flag */ int Counter; /* counter (for making keys) */ -}; +} Klist_t; /* diff --git a/src/misc.c b/src/misc.c index 0181a125..3e8496e5 100644 --- a/src/misc.c +++ b/src/misc.c @@ -97,7 +97,7 @@ a_Misc_expand_tabs(char **start, char *end, char *buf, int buflen) } /* TODO: could use dStr ADT! */ -typedef struct ContentType_ { +typedef struct { const char *str; int len; } ContentType_t; diff --git a/src/nav.c b/src/nav.c index 2e4f2233..4ccb28be 100644 --- a/src/nav.c +++ b/src/nav.c @@ -27,12 +27,10 @@ * For back and forward navigation, each bw keeps an url index, * and its scroll position. */ -typedef struct _nav_stack_item nav_stack_item; -struct _nav_stack_item -{ +typedef struct { int url_idx; int posx, posy; -}; +} nav_stack_item; diff --git a/src/png.c b/src/png.c index 3bf79db7..995725cd 100644 --- a/src/png.c +++ b/src/png.c @@ -58,8 +58,7 @@ static char *prog_state_name[] = * ones for XBM and PNM are. */ -typedef -struct _DilloPng { +typedef struct { DilloImage *Image; /* Image meta data */ DilloUrl *url; /* Primary Key for the dicache */ int version; /* Secondary Key for the dicache */ diff --git a/src/prefs.h b/src/prefs.h index 68bf773a..2b0f15e4 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -26,9 +26,7 @@ extern "C" { /* Panel sizes */ enum { P_tiny = 0, P_small, P_medium }; -typedef struct _DilloPrefs DilloPrefs; - -struct _DilloPrefs { +typedef struct { int width; int height; int xpos; @@ -99,7 +97,7 @@ struct _DilloPrefs { bool_t middle_click_drags_page; int penalty_hyphen, penalty_hyphen_2; int penalty_em_dash_left, penalty_em_dash_right, penalty_em_dash_right_2; -}; +} DilloPrefs; /* Global Data */ extern DilloPrefs prefs; diff --git a/src/prefsparser.cc b/src/prefsparser.cc index 55c5b5e4..74444bd8 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -35,7 +35,7 @@ typedef enum { PREFS_PANEL_SIZE } PrefType_t; -typedef struct SymNode_ { +typedef struct { const char *name; void *pref; PrefType_t type; diff --git a/src/url.h b/src/url.h index c5f70615..bb20d789 100644 --- a/src/url.h +++ b/src/url.h @@ -84,13 +84,11 @@ #define URL_ILLEGAL_CHARS_SPC(u) URL_ILLEGAL_CHARS_SPC_(u) -typedef struct _DilloUrl DilloUrl; - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -struct _DilloUrl { +typedef struct { Dstr *url_string; const char *buffer; const char *scheme; /**/ @@ -106,7 +104,7 @@ struct _DilloUrl { int ismap_url_len; /* Used by server side image maps */ int illegal_chars; /* number of illegal chars */ int illegal_chars_spc; /* number of illegal space chars */ -}; +} DilloUrl; DilloUrl* a_Url_new(const char *url_str, const char *base_url); -- cgit v1.2.3 From 927887827f2a440f1f1b39e58d87b12154098d4a Mon Sep 17 00:00:00 2001 From: p37sitdu Date: Sat, 12 Jan 2013 20:35:54 +0000 Subject: AC_ERROR -> AC_MSG_ERROR I see that Jeremy eradicated the other ones in Jan 2011, and I introduced some AC_ERRORs again for the 1.3 port -- corvid --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 5b7cf273..88b7cfc2 100644 --- a/configure.ac +++ b/configure.ac @@ -119,9 +119,9 @@ case $fltk_version in LIBFLTK_CFLAGS=`fltk-config --cflags` LIBFLTK_LIBS=`fltk-config --ldflags`;; ?*) AC_MSG_RESULT(no) - AC_ERROR(FLTK 1.3 required; version found: $fltk_version);; + AC_MSG_ERROR(FLTK 1.3 required; version found: $fltk_version);; *) AC_MSG_RESULT(no) - AC_ERROR(FLTK 1.3 required; fltk-config not found) + AC_MSG_ERROR(FLTK 1.3 required; fltk-config not found) esac -- cgit v1.2.3