From 79c16878be96d9d58bee76721a05ded980578ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Mon, 23 Apr 2012 16:02:35 +0000 Subject: [PATCH] [INTERPRETER] * NEW: Do not raise an error when a file path cannot be converted to the local charset. Just do not make the conversion. * BUG: Freeing any Stream object now automatically closes it. * BUG: Stream.ReadLine() with no second argument does not crash anymore. git-svn-id: svn://localhost/gambas/trunk@4664 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/gbx/gbx_archive.c | 2 ++ main/gbx/gbx_c_file.c | 10 ++++++++-- main/gbx/gbx_component.c | 2 +- main/gbx/gbx_string.c | 8 ++++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/main/gbx/gbx_archive.c b/main/gbx/gbx_archive.c index fe1c3d011..e08ee8ed5 100644 --- a/main/gbx/gbx_archive.c +++ b/main/gbx/gbx_archive.c @@ -141,6 +141,7 @@ static void load_exported_class(ARCHIVE *arch) FREE(&buffer, "load_exported_class"); } +#if 0 static void load_component(char *name) { COMPONENT *comp; @@ -148,6 +149,7 @@ static void load_component(char *name) comp = COMPONENT_create(name); COMPONENT_load(comp); } +#endif /*static void load_dependencies(ARCHIVE *arch) { diff --git a/main/gbx/gbx_c_file.c b/main/gbx/gbx_c_file.c index 65d7aa3ef..1c4071417 100644 --- a/main/gbx/gbx_c_file.c +++ b/main/gbx/gbx_c_file.c @@ -731,6 +731,7 @@ END_METHOD BEGIN_METHOD_VOID(Stream_free) + STREAM_close(CSTREAM_stream(THIS_STREAM)); GB_StoreVariant(NULL, POINTER(&(THIS_STREAM->tag))); END_METHOD @@ -740,9 +741,14 @@ BEGIN_METHOD(Stream_ReadLine, GB_STRING escape) char *escape; char *str; - escape = GB_ToZeroString(ARG(escape)); - if (!*escape) + if (MISSING(escape)) escape = NULL; + else + { + escape = GB_ToZeroString(ARG(escape)); + if (!*escape) + escape = NULL; + } str = STREAM_line_input(CSTREAM_stream(THIS_STREAM), escape); STRING_free_later(str); diff --git a/main/gbx/gbx_component.c b/main/gbx/gbx_component.c index 08f6204d8..2684a06bc 100644 --- a/main/gbx/gbx_component.c +++ b/main/gbx/gbx_component.c @@ -191,7 +191,7 @@ COMPONENT *COMPONENT_create(const char *name) can_archive = !same_name_as_project; - // System wide component, located in /usr/local/lib/gambas2 (by default) + // System wide component path = FILE_buffer(); sprintf(path, LIB_PATTERN, COMPONENT_path, name); diff --git a/main/gbx/gbx_string.c b/main/gbx/gbx_string.c index 44964aad6..35d0ca4d0 100644 --- a/main/gbx/gbx_string.c +++ b/main/gbx/gbx_string.c @@ -1186,6 +1186,7 @@ char *STRING_conv_file_name(const char *name, int len) struct passwd *info; char *dir; char *user; + int err; if (!name) return ""; @@ -1227,8 +1228,11 @@ char *STRING_conv_file_name(const char *name, int len) if (LOCAL_is_UTF8) result = STRING_new_temp(name, len); else - STRING_conv(&result, name, len, SC_UTF8, LOCAL_encoding, TRUE); - + { + err = STRING_conv(&result, name, len, SC_UTF8, LOCAL_encoding, FALSE); + if (err) + result = STRING_new_temp(name, len); + } //fprintf(stderr, "STRING_conv_file_name: %s\n", result); if (result)