diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2011-05-19 17:35:59 +0200 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2011-05-19 17:35:59 +0200 |
commit | 6b908263abc2552ef97711680ec420b509492349 (patch) | |
tree | 877c65b67ec470f36ef333c929c8a357008f7209 | |
parent | 4d1a684b22d55bc0025115cd6ee21a24f4fe31c7 (diff) | |
parent | f3b32f8cb94bc83ded97bec478e666be6a07bf0d (diff) | |
download | abrt-6b908263abc2552ef97711680ec420b509492349.tar.gz abrt-6b908263abc2552ef97711680ec420b509492349.tar.xz abrt-6b908263abc2552ef97711680ec420b509492349.zip |
Merge branch 'master' of git://git.fedorahosted.org/git/abrt
-rw-r--r-- | src/gui-wizard-gtk/wizard.c | 25 | ||||
-rw-r--r-- | src/lib/dump_dir.c | 30 |
2 files changed, 39 insertions, 16 deletions
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c index 76c5035d..bd5d28c4 100644 --- a/src/gui-wizard-gtk/wizard.c +++ b/src/gui-wizard-gtk/wizard.c @@ -106,6 +106,7 @@ enum { PAGENO_REPORT_PROGRESS, PAGENO_REPORT_DONE, PAGENO_NOT_SHOWN, + NUM_PAGES }; /* Use of arrays (instead of, say, #defines to C strings) @@ -150,9 +151,10 @@ static page_obj_t pages[] = { /* Page types: * INTRO: only [Fwd] button is shown - * CONTENT: normal page + * CONTENT: normal page (has all btns: [Cancel] [Last] [Back] [Fwd]) + * (note that we suppress [Cancel] and [Prev] using gtk_assistant_commit) * CONFIRM: has [Apply] instead of [Fwd] and emits "apply" signal - * PROGRESS: skipped on backward navigation + * PROGRESS: skipped on [Back] navigation * SUMMARY: has only [Close] button */ /* glade element name , on-screen text , type */ @@ -166,17 +168,18 @@ static page_obj_t pages[] = { PAGE_REPORTER_SELECTOR , "Select reporter" , GTK_ASSISTANT_PAGE_CONTENT }, { PAGE_BACKTRACE_APPROVAL , "Review the backtrace" , GTK_ASSISTANT_PAGE_CONTENT }, { PAGE_REPORT , "Confirm data to report", GTK_ASSISTANT_PAGE_CONFIRM }, - /* Was GTK_ASSISTANT_PAGE_PROGRESS */ + /* Was GTK_ASSISTANT_PAGE_PROGRESS, but we want to allow returning to it */ { PAGE_REPORT_PROGRESS , "Reporting" , GTK_ASSISTANT_PAGE_CONTENT }, - { PAGE_REPORT_DONE , "Reporting done" , GTK_ASSISTANT_PAGE_CONTENT }, - /* We prevent user from reaching this page, as it can't be navigated away, - * and we don't want that */ + { PAGE_REPORT_DONE , "Reporting done" , GTK_ASSISTANT_PAGE_INTRO }, + /* We prevent user from reaching this page, as SUMMARY can't be navigated away + * (must be always closed) and we don't want that + */ { PAGE_NOT_SHOWN , "" , GTK_ASSISTANT_PAGE_SUMMARY }, { NULL } }; -/* hardcoded 10 pages limit */ -page_obj_t *added_pages[10]; +static page_obj_t *added_pages[NUM_PAGES]; + /* Utility functions */ @@ -204,10 +207,14 @@ struct dump_dir *steal_if_needed(struct dump_dir *dd) dd_close(dd); char *HOME = getenv("HOME"); + if (!HOME || !HOME[0]) + { + struct passwd *pw = getpwuid(getuid()); + HOME = pw ? pw->pw_dir : NULL; + } if (HOME && HOME[0]) HOME = concat_path_file(HOME, ".abrt/spool"); else -//TODO: try to find homedir in password db? HOME = xstrdup("/tmp"); GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(g_assistant), diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c index 0c6467f4..03097ce1 100644 --- a/src/lib/dump_dir.c +++ b/src/lib/dump_dir.c @@ -651,21 +651,37 @@ static char *load_text_file(const char *path, unsigned flags) int ch; while ((ch = fgetc(fp)) != EOF) { +//TODO? \r -> \n? +//TODO? strip trailing spaces/tabs? if (ch == '\n') oneline = (oneline << 1) | 1; if (ch == '\0') ch = ' '; - if (isspace(ch) || (isascii(ch) && !iscntrl(ch))) + if (isspace(ch) || ch >= ' ') /* used !iscntrl, but it failed on unicode */ strbuf_append_char(buf_content, ch); } fclose(fp); - /* If file contains exactly one '\n' and it is at the end, remove it. - * This enables users to use simple "echo blah >file" in order to create - * short string items in dump dirs. - */ - if (oneline == 1 && buf_content->buf[buf_content->len - 1] == '\n') - buf_content->buf[--buf_content->len] = '\0'; + char last = oneline != 0 ? buf_content->buf[buf_content->len - 1] : 0; + if (last == '\n') + { + /* If file contains exactly one '\n' and it is at the end, remove it. + * This enables users to use simple "echo blah >file" in order to create + * short string items in dump dirs. + */ + if (oneline == 1) + buf_content->buf[--buf_content->len] = '\0'; + } + else /* last != '\n' */ + { + /* Last line is unterminated, fix it */ + /* Cases: */ + /* oneline=0: "qwe" - DONT fix this! */ + /* oneline=1: "qwe\nrty" - two lines in fact */ + /* oneline>1: "qwe\nrty\uio" */ + if (oneline >= 1) + strbuf_append_char(buf_content, '\n'); + } return strbuf_free_nobuf(buf_content); } |