diff options
author | Sebastian Pipping <sebastian@pipping.org> | 2008-09-10 21:38:09 +0000 |
---|---|---|
committer | Sebastian Pipping <sebastian@pipping.org> | 2008-09-10 21:38:09 +0000 |
commit | b4f3e780d181d19409daf42c8eb3598b25de9fbe (patch) | |
tree | 9563110233bc1e6febbfe4ee467aa6c9a147f1e5 | |
parent | 77cf5b9a1fbaddcc0598345b62bd414a3033ee53 (diff) | |
download | uriparser-b4f3e780d181d19409daf42c8eb3598b25de9fbe.tar.gz |
Make it build on Cygwin through resolving need for swprintf
git-svn-id: https://uriparser.svn.sourceforge.net/svnroot/uriparser/uriparser/trunk@369 119732b9-2324-0410-a8a5-815c10060bbe
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | TODO.txt | 3 | ||||
-rw-r--r-- | configure.ac | 17 | ||||
-rw-r--r-- | include/uriparser/UriDefsAnsi.h | 1 | ||||
-rw-r--r-- | include/uriparser/UriDefsUnicode.h | 4 | ||||
-rw-r--r-- | lib/UriCommon.c | 22 | ||||
-rw-r--r-- | lib/UriCommon.h | 1 | ||||
-rw-r--r-- | lib/UriRecompose.c | 16 |
9 files changed, 36 insertions, 32 deletions
@@ -1,5 +1,7 @@ ??? + * Fixed: uriparser now builds on Cygwin + * Changed: swprintf requirement resolved * Changed: Build system changes: - configure option --enable-doc added - renamed configure.in to configure.ac diff --git a/Makefile.am b/Makefile.am index 22246fe..f51eef5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -61,7 +61,7 @@ test_uriparser_test_SOURCES = \ EXTRA_DIST = \ - doc/ac*.m4 \ + doc/aclocal.m4 \ doc/configure \ doc/Makefile.in \ \ @@ -1,6 +1,7 @@ == BEFORE NEXT RELEASE ==
+ * Test HexToLetterEx in UriRecompose.c
+ * Fix acinclude.m4 inclusion thing
* Look for more bad cleanup logic
- * Bump version to non-beta 0.7.2
== SOON ==
* try to remove need for free after parser fail?
diff --git a/configure.ac b/configure.ac index f5f427b..7101611 100644 --- a/configure.ac +++ b/configure.ac @@ -11,23 +11,6 @@ AC_PROG_LIBTOOL AC_HEADER_STDC -## Check for swprintf -AC_MSG_CHECKING(for swprintf) -AC_LINK_IFELSE([ - #include <stdio.h> - #include <wchar.h> - int main() { - swprintf((wchar_t *)0, (size_t)0, (wchar_t *)0, 0); - return 0; - } -],[ - AC_DEFINE([HAVE_SWPRINTF],, [Define if your CRT provides the swprintf function.]) - AC_MSG_RESULT(yes) -],[ - AC_MSG_RESULT(no) -]) - - ## Check for wprintf AC_MSG_CHECKING(for wprintf) AC_LINK_IFELSE([ diff --git a/include/uriparser/UriDefsAnsi.h b/include/uriparser/UriDefsAnsi.h index f48f20d..deaefaa 100644 --- a/include/uriparser/UriDefsAnsi.h +++ b/include/uriparser/UriDefsAnsi.h @@ -73,6 +73,7 @@ #undef URI_STRNCMP #define URI_STRNCMP strncmp +/* TODO Remove on next source-compatibility break */ #undef URI_SNPRINTF #if (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) # define URI_SNPRINTF _snprintf diff --git a/include/uriparser/UriDefsUnicode.h b/include/uriparser/UriDefsUnicode.h index 879dba5..fa4befc 100644 --- a/include/uriparser/UriDefsUnicode.h +++ b/include/uriparser/UriDefsUnicode.h @@ -73,12 +73,10 @@ #undef URI_STRNCMP #define URI_STRNCMP wcsncmp +/* TODO Remove on next source-compatibility break */ #undef URI_SNPRINTF #if (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) # define URI_SNPRINTF _snwprintf #else -# ifndef HAVE_SWPRINTF -# error Function swprintf required but missing. -# endif # define URI_SNPRINTF swprintf #endif diff --git a/lib/UriCommon.c b/lib/UriCommon.c index 36806ad..977aa9c 100644 --- a/lib/UriCommon.c +++ b/lib/UriCommon.c @@ -334,6 +334,14 @@ unsigned char URI_FUNC(HexdigToInt)(URI_CHAR hexdig) { URI_CHAR URI_FUNC(HexToLetter)(unsigned int value) { + /* Uppercase recommended in section 2.1. of RFC 3986 * + * http://tools.ietf.org/html/rfc3986#section-2.1 */ + return URI_FUNC(HexToLetterEx)(value, URI_TRUE); +} + + + +URI_CHAR URI_FUNC(HexToLetterEx)(unsigned int value, UriBool uppercase) { switch (value) { case 0: return _UT('0'); case 1: return _UT('1'); @@ -346,14 +354,12 @@ URI_CHAR URI_FUNC(HexToLetter)(unsigned int value) { case 8: return _UT('8'); case 9: return _UT('9'); - /* Uppercase recommended in section 2.1. of RFC 3986 * - * http://tools.ietf.org/html/rfc3986#section-2.1 */ - case 10: return _UT('A'); - case 11: return _UT('B'); - case 12: return _UT('C'); - case 13: return _UT('D'); - case 14: return _UT('E'); - default: return _UT('F'); + case 10: return (uppercase == URI_TRUE) ? _UT('A') : _UT('a'); + case 11: return (uppercase == URI_TRUE) ? _UT('B') : _UT('b'); + case 12: return (uppercase == URI_TRUE) ? _UT('C') : _UT('c'); + case 13: return (uppercase == URI_TRUE) ? _UT('D') : _UT('d'); + case 14: return (uppercase == URI_TRUE) ? _UT('E') : _UT('e'); + default: return (uppercase == URI_TRUE) ? _UT('F') : _UT('f'); } } diff --git a/lib/UriCommon.h b/lib/UriCommon.h index fc95940..5f5c3e2 100644 --- a/lib/UriCommon.h +++ b/lib/UriCommon.h @@ -79,6 +79,7 @@ UriBool URI_FUNC(RemoveDotSegments)(URI_TYPE(Uri) * uri, UriBool relative); unsigned char URI_FUNC(HexdigToInt)(URI_CHAR hexdig); URI_CHAR URI_FUNC(HexToLetter)(unsigned int value); +URI_CHAR URI_FUNC(HexToLetterEx)(unsigned int value, UriBool uppercase); UriBool URI_FUNC(IsHostSet)(const URI_TYPE(Uri) * uri); diff --git a/lib/UriRecompose.c b/lib/UriRecompose.c index dfe69a6..2fe9bdb 100644 --- a/lib/UriRecompose.c +++ b/lib/UriRecompose.c @@ -208,7 +208,17 @@ static URI_INLINE int URI_FUNC(ToStringEngine)(URI_CHAR * dest, if (dest != NULL) { if (written + charsToWrite <= maxChars) { URI_CHAR text[4]; - URI_SNPRINTF(text, charsToWrite + 1, _UT("%i"), value); + if (value > 99) { + text[0] = _UT('0') + (value / 100); + text[1] = _UT('0') + ((value % 100) / 10); + text[2] = _UT('0') + (value % 10); + } else if (value > 9) { + text[0] = _UT('0') + (value / 10); + text[1] = _UT('0') + (value % 10); + } else { + text[0] = _UT('0') + value; + } + text[charsToWrite] = _UT('\0'); memcpy(dest + written, text, charsToWrite * sizeof(URI_CHAR)); written += charsToWrite; } else { @@ -259,7 +269,9 @@ static URI_INLINE int URI_FUNC(ToStringEngine)(URI_CHAR * dest, if (dest != NULL) { if (written + 2 <= maxChars) { URI_CHAR text[3]; - URI_SNPRINTF(text, 2 + 1, _UT("%x"), value); + text[0] = URI_FUNC(HexToLetterEx)(value / 16, URI_FALSE); + text[1] = URI_FUNC(HexToLetterEx)(value % 16, URI_FALSE); + text[2] = _UT('\0'); memcpy(dest + written, text, 2 * sizeof(URI_CHAR)); written += 2; } else { |