mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
bug 153, 1066: Add codepage parameter to update_bookmark().
This also makes the bookmark-update event carry strings in UTF-8. The only current consumer of that event is bookmark_change_hook(), which ignores the strings, so no changes are needed there.
This commit is contained in:
parent
73f925ce21
commit
03b112796d
@ -85,8 +85,8 @@ Triggered When:
|
|||||||
Arguments:
|
Arguments:
|
||||||
|
|
||||||
struct bookmark *bookmark
|
struct bookmark *bookmark
|
||||||
unsigned char *new_title
|
unsigned char *new_title /* UTF-8 */
|
||||||
unsigned char *new_url
|
unsigned char *new_url /* UTF-8 */
|
||||||
|
|
||||||
Description:
|
Description:
|
||||||
|
|
||||||
|
@ -465,21 +465,31 @@ add_bookmark_cp(struct bookmark *root, int place, int codepage,
|
|||||||
*
|
*
|
||||||
* If any of the fields are NULL, the value is left unchanged. */
|
* If any of the fields are NULL, the value is left unchanged. */
|
||||||
int
|
int
|
||||||
update_bookmark(struct bookmark *bm, unsigned char *title,
|
update_bookmark(struct bookmark *bm, int codepage,
|
||||||
unsigned char *url)
|
unsigned char *title, unsigned char *url)
|
||||||
{
|
{
|
||||||
static int update_bookmark_event_id = EVENT_NONE;
|
static int update_bookmark_event_id = EVENT_NONE;
|
||||||
|
const int utf8_cp = get_cp_index("UTF-8");
|
||||||
|
struct conv_table *table;
|
||||||
unsigned char *title2 = NULL;
|
unsigned char *title2 = NULL;
|
||||||
unsigned char *url2 = NULL;
|
unsigned char *url2 = NULL;
|
||||||
|
|
||||||
|
table = get_translation_table(codepage, utf8_cp);
|
||||||
|
if (!table)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
url2 = stracpy(url);
|
url2 = convert_string(table, url, strlen(url),
|
||||||
|
utf8_cp, CSM_NONE,
|
||||||
|
NULL, NULL, NULL);
|
||||||
if (!url2) return 0;
|
if (!url2) return 0;
|
||||||
sanitize_url(url2);
|
sanitize_url(url2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title) {
|
if (title) {
|
||||||
title2 = stracpy(title);
|
title2 = convert_string(table, title, strlen(title),
|
||||||
|
utf8_cp, CSM_NONE,
|
||||||
|
NULL, NULL, NULL);
|
||||||
if (!title2) {
|
if (!title2) {
|
||||||
mem_free_if(url2);
|
mem_free_if(url2);
|
||||||
return 0;
|
return 0;
|
||||||
@ -491,7 +501,6 @@ update_bookmark(struct bookmark *bm, unsigned char *title,
|
|||||||
trigger_event(update_bookmark_event_id, bm, title2, url2);
|
trigger_event(update_bookmark_event_id, bm, title2, url2);
|
||||||
|
|
||||||
if (title2) {
|
if (title2) {
|
||||||
/** @todo Bug 153: bm->title should be UTF-8 */
|
|
||||||
mem_free_set(&bm->title, title2);
|
mem_free_set(&bm->title, title2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,7 +513,6 @@ update_bookmark(struct bookmark *bm, unsigned char *title,
|
|||||||
if (item) del_hash_item(bookmark_cache, item);
|
if (item) del_hash_item(bookmark_cache, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @todo Bug 1066: bm->url should be UTF-8 */
|
|
||||||
if (check_bookmark_cache(url2)) {
|
if (check_bookmark_cache(url2)) {
|
||||||
add_hash_item(bookmark_cache, url2, strlen(url2), bm);
|
add_hash_item(bookmark_cache, url2, strlen(url2), bm);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,8 @@ struct bookmark *get_bookmark_by_name(struct bookmark *folder,
|
|||||||
struct bookmark *get_bookmark(unsigned char *url);
|
struct bookmark *get_bookmark(unsigned char *url);
|
||||||
void bookmark_terminal_tabs(struct terminal *term, unsigned char *foldername);
|
void bookmark_terminal_tabs(struct terminal *term, unsigned char *foldername);
|
||||||
void bookmark_auto_save_tabs(struct terminal *term);
|
void bookmark_auto_save_tabs(struct terminal *term);
|
||||||
int update_bookmark(struct bookmark *, unsigned char *, unsigned char *);
|
int update_bookmark(struct bookmark *, int,
|
||||||
|
unsigned char *, unsigned char *);
|
||||||
void open_bookmark_folder(struct session *ses, unsigned char *foldername);
|
void open_bookmark_folder(struct session *ses, unsigned char *foldername);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -283,8 +283,11 @@ static void
|
|||||||
bookmark_edit_done(void *data) {
|
bookmark_edit_done(void *data) {
|
||||||
struct dialog *dlg = data;
|
struct dialog *dlg = data;
|
||||||
struct bookmark *bm = (struct bookmark *) dlg->udata2;
|
struct bookmark *bm = (struct bookmark *) dlg->udata2;
|
||||||
|
struct dialog_data *parent_dlg_data = dlg->udata;
|
||||||
|
int term_cp = get_terminal_codepage(parent_dlg_data->win->term);
|
||||||
|
|
||||||
update_bookmark(bm, dlg->widgets[0].data, dlg->widgets[1].data);
|
update_bookmark(bm, term_cp,
|
||||||
|
dlg->widgets[0].data, dlg->widgets[1].data);
|
||||||
object_unlock(bm);
|
object_unlock(bm);
|
||||||
|
|
||||||
#ifdef BOOKMARKS_RESAVE
|
#ifdef BOOKMARKS_RESAVE
|
||||||
|
@ -492,7 +492,10 @@ clr_spaces(unsigned char *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Replace invalid chars in @a title with ' ' and trim all starting/ending
|
/** Replace invalid chars in @a title with ' ' and trim all starting/ending
|
||||||
* spaces. */
|
* spaces.
|
||||||
|
*
|
||||||
|
* update_bookmark() assumes this function does not switch translation
|
||||||
|
* tables. */
|
||||||
void
|
void
|
||||||
sanitize_title(unsigned char *title)
|
sanitize_title(unsigned char *title)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user