You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2013/05/03 01:30:03 UTC
svn commit: r1478606 - in /subversion/trunk: build/generator/gen_base.py
subversion/libsvn_subr/error.c tools/dev/which-error.py
Author: danielsh
Date: Thu May 2 23:30:02 2013
New Revision: 1478606
URL: http://svn.apache.org/r1478606
Log:
Support symbolic names for APR error codes, too.
* build/generator/gen_base.py
(GeneratorBase.write_errno_codes): Parse aprerr.txt into errorcode.inc.
* subversion/libsvn_subr/error.c
(svn_error_symbolic_name): Use svn__apr_errno (from errorcode.inc).
* tools/dev/which-error.py
(get_errors): Add a cross-reference comment.
Modified:
subversion/trunk/build/generator/gen_base.py
subversion/trunk/subversion/libsvn_subr/error.c
subversion/trunk/tools/dev/which-error.py
Modified: subversion/trunk/build/generator/gen_base.py
URL: http://svn.apache.org/viewvc/subversion/trunk/build/generator/gen_base.py?rev=1478606&r1=1478605&r2=1478606&view=diff
==============================================================================
--- subversion/trunk/build/generator/gen_base.py (original)
+++ subversion/trunk/build/generator/gen_base.py Thu May 2 23:30:02 2013
@@ -251,6 +251,8 @@ class GeneratorBase:
import errno
fd = open('subversion/libsvn_subr/errorcode.inc', 'w')
fd.write('/* This file was generated by build/generator/gen_base.py */\n\n')
+
+ ## write errno codes.
fd.write('static struct {\n'
' int errcode;\n'
' const char *errname;\n'
@@ -260,6 +262,29 @@ class GeneratorBase:
# fd.seek(-2, os.SEEK_CUR); fd.write('\n');
fd.write('};\n')
+ fd.write('\n')
+
+ ## write apr error codes.
+ fd.write('static struct {\n'
+ ' int errcode;\n'
+ ' const char *errname;\n'
+ '} svn__apr_errno[] = {\n');
+ aprerr = []
+ for line in open(os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])),
+ 'tools', 'dev', 'aprerr.txt')):
+ # aprerr.txt parsing duplicated in which-error.py
+ if line.startswith('#'):
+ continue
+ key, _, val = line.split()
+ aprerr += [(int(val), key)]
+ for num, val in sorted(aprerr):
+ fd.write(' { %d, "%s" },\n' % (num, val))
+ # fd.seek(-2, os.SEEK_CUR); fd.write('\n');
+ fd.write('};\n')
+
+ ## sanity check
+ assert set() == set(errno.errorcode.keys()) & set(dict(aprerr).keys())
+
class DependencyGraph:
"""Record dependencies between build items.
Modified: subversion/trunk/subversion/libsvn_subr/error.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/error.c?rev=1478606&r1=1478605&r2=1478606&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/error.c (original)
+++ subversion/trunk/subversion/libsvn_subr/error.c Thu May 2 23:30:02 2013
@@ -679,7 +679,7 @@ svn_strerror(apr_status_t statcode, char
}
#ifdef SVN_DEBUG
-/* Defines svn__errno */
+/* Defines svn__errno and svn__apr_errno */
#include "errorcode.inc"
#endif
@@ -705,6 +705,12 @@ svn_error_symbolic_name(apr_status_t sta
for (i = 0; i < sizeof(svn__errno) / sizeof(svn__errno[0]); i++)
if (svn__errno[i].errcode == (int)statcode)
return svn__errno[i].errname;
+
+ /* Try APR errors. */
+ /* Linear search through a sorted array */
+ for (i = 0; i < sizeof(svn__apr_errno) / sizeof(svn__apr_errno[0]); i++)
+ if (svn__apr_errno[i].errcode == (int)statcode)
+ return svn__apr_errno[i].errname;
#endif /* SVN_DEBUG */
/* ### TODO: do we need APR_* error macros? What about APR_TO_OS_ERROR()? */
Modified: subversion/trunk/tools/dev/which-error.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/which-error.py?rev=1478606&r1=1478605&r2=1478606&view=diff
==============================================================================
--- subversion/trunk/tools/dev/which-error.py (original)
+++ subversion/trunk/tools/dev/which-error.py Thu May 2 23:30:02 2013
@@ -73,6 +73,7 @@ def get_errors():
errs.update(errno.errorcode)
## APR-defined errors, from apr_errno.h.
for line in open(os.path.join(os.path.dirname(sys.argv[0]), 'aprerr.txt')):
+ # aprerr.txt parsing duplicated in gen_base.py:write_errno_table()
if line.startswith('#'):
continue
key, _, val = line.split()