r5431 takkaria - in /trunk/hubbub: include/hubbub/errors.h src/hubbub.c src/utils/errors.c src/utils/parserutilserror.h

netsurf at semichrome.net netsurf at semichrome.net
Wed Sep 24 14:57:28 BST 2008


Author: takkaria
Date: Wed Sep 24 08:57:27 2008
New Revision: 5431

URL: http://source.netsurf-browser.org?rev=5431&view=rev
Log:
Report errors from libparserutils better.

Added:
    trunk/hubbub/src/utils/parserutilserror.h   (with props)
Modified:
    trunk/hubbub/include/hubbub/errors.h
    trunk/hubbub/src/hubbub.c
    trunk/hubbub/src/utils/errors.c

Modified: trunk/hubbub/include/hubbub/errors.h
URL: http://source.netsurf-browser.org/trunk/hubbub/include/hubbub/errors.h?rev=5431&r1=5430&r2=5431&view=diff
==============================================================================
--- trunk/hubbub/include/hubbub/errors.h (original)
+++ trunk/hubbub/include/hubbub/errors.h Wed Sep 24 08:57:27 2008
@@ -21,6 +21,8 @@
 	HUBBUB_INVALID          = 7,
 	HUBBUB_FILENOTFOUND     = 8,
 	HUBBUB_NEEDDATA         = 9,
+
+	HUBBUB_UNKNOWN		= 10
 } hubbub_error;
 
 /* Convert a hubbub error value to a string */

Modified: trunk/hubbub/src/hubbub.c
URL: http://source.netsurf-browser.org/trunk/hubbub/src/hubbub.c?rev=5431&r1=5430&r2=5431&view=diff
==============================================================================
--- trunk/hubbub/src/hubbub.c (original)
+++ trunk/hubbub/src/hubbub.c Wed Sep 24 08:57:27 2008
@@ -9,6 +9,7 @@
 
 #include <hubbub/hubbub.h>
 
+#include "utils/parserutilserror.h"
 #include "tokeniser/entities.h"
 
 /**
@@ -29,8 +30,10 @@
 	if (aliases_file == NULL || alloc == NULL)
 		return HUBBUB_BADPARM;
 
-	if (parserutils_initialise(aliases_file, alloc, pw) != PARSERUTILS_OK)
-		return !HUBBUB_OK;
+	error = hubbub_error_from_parserutils_error(
+			parserutils_initialise(aliases_file, alloc, pw));
+	if (error != HUBBUB_OK)
+		return error;
 
 	error = hubbub_entities_create(alloc, pw);
 	if (error != HUBBUB_OK) {
@@ -60,4 +63,3 @@
 	return HUBBUB_OK;
 }
 
-

Modified: trunk/hubbub/src/utils/errors.c
URL: http://source.netsurf-browser.org/trunk/hubbub/src/utils/errors.c?rev=5431&r1=5430&r2=5431&view=diff
==============================================================================
--- trunk/hubbub/src/utils/errors.c (original)
+++ trunk/hubbub/src/utils/errors.c Wed Sep 24 08:57:27 2008
@@ -47,6 +47,9 @@
 	case HUBBUB_NEEDDATA:
 		result = "Insufficient data";
 		break;
+	case HUBBUB_UNKNOWN:
+		result = "Unknown error";
+		break;
 	}
 
 	return result;

Added: trunk/hubbub/src/utils/parserutilserror.h
URL: http://source.netsurf-browser.org/trunk/hubbub/src/utils/parserutilserror.h?rev=5431&view=auto
==============================================================================
--- trunk/hubbub/src/utils/parserutilserror.h (added)
+++ trunk/hubbub/src/utils/parserutilserror.h Wed Sep 24 08:57:27 2008
@@ -1,0 +1,41 @@
+/*
+ * This file is part of Hubbub.
+ * Licensed under the MIT License,
+ *                http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb at netsurf-browser.org>
+ */
+
+#ifndef hubbub_utils_parserutilserror_h_
+#define hubbub_utils_parserutilserror_h_
+
+#include <parserutils/errors.h>
+
+#include <hubbub/errors.h>
+
+/**
+ * Convert a ParserUtils error into a LibCSS error
+ *
+ * \param error  The ParserUtils error to convert
+ * \return The corresponding LibCSS error
+ */
+static inline hubbub_error hubbub_error_from_parserutils_error(
+		parserutils_error error)
+{
+	if (error == PARSERUTILS_OK)
+		return HUBBUB_OK;
+	else if (error == PARSERUTILS_NOMEM)
+		return HUBBUB_NOMEM;
+	else if (error == PARSERUTILS_BADPARM)
+		return HUBBUB_BADPARM;
+	else if (error == PARSERUTILS_INVALID)
+		return HUBBUB_INVALID;
+	else if (error == PARSERUTILS_FILENOTFOUND)
+		return HUBBUB_FILENOTFOUND;
+	else if (error == PARSERUTILS_NEEDDATA)
+		return HUBBUB_NEEDDATA;
+
+	return HUBBUB_UNKNOWN;
+}
+
+#endif
+

Propchange: trunk/hubbub/src/utils/parserutilserror.h
------------------------------------------------------------------------------
    svn:eol-style = native




More information about the netsurf-commits mailing list