summaryrefslogtreecommitdiff
path: root/Source/Swig/error.c
diff options
context:
space:
mode:
authorDerrick <a11426@users.sourceforge.net>2011-02-14 20:11:58 +0000
committerDerrick <a11426@users.sourceforge.net>2011-02-14 20:11:58 +0000
commit5815f7ec289e067e765fb8e893a2f337d8b48303 (patch)
treeebe9e0534a089fe431cedc6fdbc1a53ac523d70c /Source/Swig/error.c
parent3e1af1f698d5d02d7905431bcb3549c0f7bc9aa7 (diff)
parent1fab53b2046b97702e1de4cfab06cb8fa8fc129d (diff)
downloadswig-a11426-fortran.tar.gz
update fortran branch. merge of 12160:12460a11426-fortran
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/a11426-fortran@12461 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Source/Swig/error.c')
-rw-r--r--Source/Swig/error.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/Source/Swig/error.c b/Source/Swig/error.c
index fa82ad8d9..5dfcf605b 100644
--- a/Source/Swig/error.c
+++ b/Source/Swig/error.c
@@ -285,6 +285,41 @@ static String *format_filename(const_String_or_char_ptr filename) {
}
/* -----------------------------------------------------------------------------
+ * Swig_stringify_with_location()
+ *
+ * Return a string representation of any DOH object with line and file location
+ * information in the appropriate error message format. The string representation
+ * is enclosed within [] brackets after the line and file information.
+ * ----------------------------------------------------------------------------- */
+
+String *Swig_stringify_with_location(DOH *object) {
+ String *str = NewStringEmpty();
+
+ if (!init_fmt)
+ Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
+
+ if (object) {
+ int line = Getline(object);
+ String *formatted_filename = format_filename(Getfile(object));
+ if (line > 0) {
+ Printf(str, diag_line_fmt, formatted_filename, line);
+ } else {
+ Printf(str, diag_eof_fmt, formatted_filename);
+ }
+ if (Len(object) == 0) {
+ Printf(str, "[EMPTY]");
+ } else {
+ Printf(str, "[%s]", object);
+ }
+ Delete(formatted_filename);
+ } else {
+ Printf(str, "[NULL]");
+ }
+
+ return str;
+}
+
+/* -----------------------------------------------------------------------------
* Swig_diagnostic()
*
* Issue a diagnostic message on stdout.