[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.2-75-gfe1336
From: |
Andy Wingo |
Subject: |
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.2-75-gfe13364 |
Date: |
Sat, 10 Sep 2011 18:38:33 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=fe1336405062c69ff08fd7ad0d98c3f2aca7766f
The branch, stable-2.0 has been updated
via fe1336405062c69ff08fd7ad0d98c3f2aca7766f (commit)
via cb7bcfca3520a147881e4b7f052b68b88a740bf1 (commit)
from 86b4309b7166fe5ec4f55f0cc64501d07b0852f9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit fe1336405062c69ff08fd7ad0d98c3f2aca7766f
Author: Andy Wingo <address@hidden>
Date: Sat Sep 10 11:38:25 2011 -0700
fix scm_to_latin1_stringn for substrings
* libguile/strings.c (scm_to_latin1_stringn): Fix for substrings.
* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-scm-to-latin1-string.c: Add test case.
Thanks to David Hansen for the bug report and test case, and Stefan
Israelsson Tampe for the fix.
commit cb7bcfca3520a147881e4b7f052b68b88a740bf1
Author: Ian Price <address@hidden>
Date: Fri Sep 9 20:02:34 2011 +0100
RFC 822 allows single digit days of the month
* module/web/http.scm (parse-rfc-822-date): Add single digit day
conditional.
* test-suite/tests/web-http.test("general headers"): Add test.
-----------------------------------------------------------------------
Summary of changes:
libguile/strings.c | 8 ++-
module/web/http.scm | 28 +++++---
test-suite/standalone/Makefile.am | 7 ++
test-suite/standalone/test-scm-to-latin1-string.c | 78 +++++++++++++++++++++
test-suite/tests/web-http.test | 3 +
5 files changed, 112 insertions(+), 12 deletions(-)
create mode 100644 test-suite/standalone/test-scm-to-latin1-string.c
diff --git a/libguile/strings.c b/libguile/strings.c
index 5b15ddc..666a951 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -1779,14 +1779,16 @@ scm_to_latin1_stringn (SCM str, size_t *lenp)
if (scm_i_is_narrow_string (str))
{
+ size_t len = scm_i_string_length (str);
+
if (lenp)
- *lenp = scm_i_string_length (str);
+ *lenp = len;
- result = scm_strdup (scm_i_string_data (str));
+ result = scm_strndup (scm_i_string_data (str), len);
}
else
result = scm_to_stringn (str, lenp, NULL,
- SCM_FAILED_CONVERSION_ERROR);
+ SCM_FAILED_CONVERSION_ERROR);
return result;
}
diff --git a/module/web/http.scm b/module/web/http.scm
index 21874ee..70db813 100644
--- a/module/web/http.scm
+++ b/module/web/http.scm
@@ -702,15 +702,25 @@ ordered alist."
;; 0 1 2
(define (parse-rfc-822-date str)
;; We could verify the day of the week but we don't.
- (if (not (string-match? str "aaa, dd aaa dddd dd:dd:dd GMT"))
- (bad-header 'date str))
- (let ((date (parse-non-negative-integer str 5 7))
- (month (parse-month str 8 11))
- (year (parse-non-negative-integer str 12 16))
- (hour (parse-non-negative-integer str 17 19))
- (minute (parse-non-negative-integer str 20 22))
- (second (parse-non-negative-integer str 23 25)))
- (make-date 0 second minute hour date month year 0)))
+ (cond ((string-match? str "aaa, dd aaa dddd dd:dd:dd GMT")
+ (let ((date (parse-non-negative-integer str 5 7))
+ (month (parse-month str 8 11))
+ (year (parse-non-negative-integer str 12 16))
+ (hour (parse-non-negative-integer str 17 19))
+ (minute (parse-non-negative-integer str 20 22))
+ (second (parse-non-negative-integer str 23 25)))
+ (make-date 0 second minute hour date month year 0)))
+ ((string-match? str "aaa, d aaa dddd dd:dd:dd GMT")
+ (let ((date (parse-non-negative-integer str 5 6))
+ (month (parse-month str 7 10))
+ (year (parse-non-negative-integer str 11 15))
+ (hour (parse-non-negative-integer str 16 18))
+ (minute (parse-non-negative-integer str 19 21))
+ (second (parse-non-negative-integer str 22 24)))
+ (make-date 0 second minute hour date month year 0)))
+ (else
+ (bad-header 'date str) ; prevent tail call
+ #f)))
;; RFC 850, updated by RFC 1036
;; Sunday, 06-Nov-94 08:49:37 GMT
diff --git a/test-suite/standalone/Makefile.am
b/test-suite/standalone/Makefile.am
index 00655bd..76c47c4 100644
--- a/test-suite/standalone/Makefile.am
+++ b/test-suite/standalone/Makefile.am
@@ -178,6 +178,13 @@ test_scm_take_u8vector_LDADD = $(LIBGUILE_LDADD)
check_PROGRAMS += test-scm-take-u8vector
TESTS += test-scm-take-u8vector
+# test-scm-take-u8vector
+test_scm_to_latin1_string_SOURCES = test-scm-to-latin1-string.c
+test_scm_to_latin1_string_CFLAGS = ${test_cflags}
+test_scm_to_latin1_string_LDADD = $(LIBGUILE_LDADD)
+check_PROGRAMS += test-scm-to-latin1-string
+TESTS += test-scm-to-latin1-string
+
if HAVE_SHARED_LIBRARIES
# test-extensions
diff --git a/test-suite/standalone/test-scm-to-latin1-string.c
b/test-suite/standalone/test-scm-to-latin1-string.c
new file mode 100644
index 0000000..b8f0120
--- /dev/null
+++ b/test-suite/standalone/test-scm-to-latin1-string.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <libguile.h>
+#include <stdlib.h>
+
+/*
+ This outputs:
+
+ address@hidden ~/tmp $ ./a.out
+ foo,bar
+ bar
+
+*/
+
+#define TEST(x) \
+ if (!(x)) abort()
+
+static void
+inner_main (void *data, int argc, char **argv)
+{
+ char *cstr;
+
+ SCM string, tokens, tok;
+
+ string = scm_from_latin1_string ("foo,bar");
+ tokens = scm_string_split (string, SCM_MAKE_CHAR (','));
+
+ TEST (scm_is_pair (tokens));
+ tok = scm_car (tokens);
+ TEST (scm_is_string (tok));
+ cstr = scm_to_latin1_string (tok);
+ TEST (strcmp (cstr, "foo") == 0);
+ free (cstr);
+ tokens = scm_cdr (tokens);
+
+ TEST (scm_is_pair (tokens));
+ tok = scm_car (tokens);
+ TEST (scm_is_string (tok));
+ cstr = scm_to_latin1_string (tok);
+ TEST (strcmp (cstr, "bar") == 0);
+ free (cstr);
+ tokens = scm_cdr (tokens);
+
+ TEST (scm_is_null (tokens));
+}
+
+int
+main (int argc, char **argv)
+{
+ scm_boot_guile (argc, argv, inner_main, NULL);
+
+ return EXIT_SUCCESS;
+}
+
+/* Local Variables: */
+/* compile-command: "gcc `pkg-config --cflags --libs guile-2.0` main.c" */
+/* End: */
diff --git a/test-suite/tests/web-http.test b/test-suite/tests/web-http.test
index c191c6e..e4d6efb 100644
--- a/test-suite/tests/web-http.test
+++ b/test-suite/tests/web-http.test
@@ -89,6 +89,9 @@
(pass-if-parse date "Tue, 15 Nov 1994 08:12:31 GMT"
(string->date "Tue, 15 Nov 1994 08:12:31 +0000"
"~a, ~d ~b ~Y ~H:~M:~S ~z"))
+ (pass-if-parse date "Wed, 7 Sep 2011 11:25:00 GMT"
+ (string->date "Wed, 7 Sep 2011 11:25:00 +0000"
+ "~a,~e ~b ~Y ~H:~M:~S ~z"))
(pass-if-parse-error date "Tue, 15 Nov 1994 08:12:31 EST" date)
(pass-if-any-error date "Tue, 15 Qux 1994 08:12:31 EST")
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.2-75-gfe13364,
Andy Wingo <=