summaryrefslogtreecommitdiff
path: root/atari
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2014-01-28 21:40:13 +0000
committerVincent Sanders <vince@netsurf-browser.org>2014-01-28 21:40:13 +0000
commit654da2ffb5abf2afe9532f1d0cb77ed88f8a97cc (patch)
treeefbc3d97a8650b682b7181e748698de9c555d80d /atari
parent4b760c7e499e2f5cb1d06242d5f186e14e94496a (diff)
downloadnetsurf-654da2ffb5abf2afe9532f1d0cb77ed88f8a97cc.tar.gz
netsurf-654da2ffb5abf2afe9532f1d0cb77ed88f8a97cc.tar.bz2
move utf8 conversion routines to use nserror instead of their own error enum
Diffstat (limited to 'atari')
-rw-r--r--atari/encoding.c12
-rw-r--r--atari/gui.c14
-rw-r--r--atari/plot/font_internal.c2
-rwxr-xr-xatari/plot/font_vdi.c2
-rwxr-xr-xatari/rootwin.c6
-rw-r--r--atari/toolbar.c4
6 files changed, 19 insertions, 21 deletions
diff --git a/atari/encoding.c b/atari/encoding.c
index 0212d51c4..626f57ae8 100644
--- a/atari/encoding.c
+++ b/atari/encoding.c
@@ -21,23 +21,21 @@
/* TODO: this need a rework..., encoding to atari st doesn|t always work.
( gui_add_to_clipboard...) */
-utf8_convert_ret utf8_to_local_encoding(const char *string,
+nserror utf8_to_local_encoding(const char *string,
size_t len,
char **result)
{
- utf8_convert_ret r;
+ nserror r;
r = utf8_to_enc(string, "ATARIST", len, result);
- if(r != UTF8_CONVERT_OK) {
+ if(r != NSERROR_OK) {
r = utf8_to_enc(string, "UTF-8", len, result);
- assert( r == UTF8_CONVERT_OK );
+ assert( r == NSERROR_OK );
}
return r;
}
-utf8_convert_ret utf8_from_local_encoding(const char *string,
- size_t len,
- char **result)
+nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
{
return utf8_from_enc(string, "ATARIST", len, result, NULL);
}
diff --git a/atari/gui.c b/atari/gui.c
index f1f557e2e..af5e1f8ba 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -326,7 +326,7 @@ static void gui_window_set_title(struct gui_window *gw, const char *title)
int l;
char * conv;
l = strlen(title)+1;
- if (utf8_to_local_encoding(title, l-1, &conv) == UTF8_CONVERT_OK ) {
+ if (utf8_to_local_encoding(title, l-1, &conv) == NSERROR_OK ) {
l = MIN((uint32_t)atari_sysinfo.aes_max_win_title_len, strlen(conv));
if(gw->title == NULL)
gw->title = malloc(l);
@@ -699,16 +699,16 @@ static void gui_get_clipboard(char **buffer, size_t *length)
// clipboard is in atari encoding, convert it to utf8:
char *utf8 = NULL;
- utf8_convert_ret ret;
+ nserror ret;
clip_len = strlen(clip);
if (clip_len > 0) {
ret = utf8_to_local_encoding(clip, clip_len, &utf8);
- if (ret == UTF8_CONVERT_OK && utf8 != NULL) {
+ if (ret == NSERROR_OK && utf8 != NULL) {
*buffer = utf8;
*length = strlen(utf8);
} else {
- assert(ret == UTF8_CONVERT_OK && utf8 != NULL);
+ assert(ret == NSERROR_OK && utf8 != NULL);
}
}
@@ -731,14 +731,14 @@ static void gui_set_clipboard(const char *buffer, size_t length,
// convert utf8 input to atari encoding:
- utf8_convert_ret ret;
+ nserror ret;
char *clip = NULL;
ret = utf8_to_local_encoding(buffer,length, &clip);
- if (ret == UTF8_CONVERT_OK) {
+ if (ret == NSERROR_OK) {
scrap_txt_write(clip);
} else {
- assert(ret == UTF8_CONVERT_OK);
+ assert(ret == NSERROR_OK);
}
free(clip);
}
diff --git a/atari/plot/font_internal.c b/atari/plot/font_internal.c
index 2b0025a71..e3c806cfe 100644
--- a/atari/plot/font_internal.c
+++ b/atari/plot/font_internal.c
@@ -72,7 +72,7 @@ fb_get_font(const plot_font_style_t *fstyle)
}
}
-static utf8_convert_ret utf8_to_font_encoding(const struct fb_font_desc* font,
+static nserror utf8_to_font_encoding(const struct fb_font_desc* font,
const char *string,
size_t len,
char **result)
diff --git a/atari/plot/font_vdi.c b/atari/plot/font_vdi.c
index 340759f02..0c914b82b 100755
--- a/atari/plot/font_vdi.c
+++ b/atari/plot/font_vdi.c
@@ -267,7 +267,7 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t leng
short fx=0;
GRECT canvas;
char *lstr = NULL;
- assert( utf8_to_local_encoding(text, length, &lstr) == UTF8_CONVERT_OK);
+ assert( utf8_to_local_encoding(text, length, &lstr) == NSERROR_OK);
assert( lstr != NULL );
int slen = strlen(lstr);
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 0f3413c3d..8942263ad 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -1510,15 +1510,15 @@ static void on_file_dropped(ROOTWIN *rootwin, short msg[8])
mx+sx, my+sy,
NULL);
if(processed == true) {
- utf8_convert_ret ret;
+ nserror ret;
char *utf8_fn;
ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
- if (ret != UTF8_CONVERT_OK) {
+ if (ret != NSERROR_OK) {
free(buff);
/* A bad encoding should never happen */
LOG(("utf8_from_local_encoding failed"));
- assert(ret != UTF8_CONVERT_BADENC);
+ assert(ret != NSERROR_BAD_ENCODING);
/* no memory */
goto error;
}
diff --git a/atari/toolbar.c b/atari/toolbar.c
index fd9051dd9..8044d160d 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -740,11 +740,11 @@ bool toolbar_key_input(struct s_toolbar *tb, short nkc)
int clip_length = strlen( clip );
if ( clip_length > 0 ) {
char *utf8;
- utf8_convert_ret res;
+ nserror res;
/* Clipboard is in local encoding so
* convert to UTF8 */
res = utf8_from_local_encoding( clip, clip_length, &utf8 );
- if ( res == UTF8_CONVERT_OK ) {
+ if ( res == NSERROR_OK ) {
toolbar_set_url(tb, utf8);
free(utf8);
ret = true;