Skip to content
Browse files

Bug 7463: Removed the "convenience" methods for regex-* that would co…

…nvert

<string> to <regex>.  These just cause user confusion and remove the
possibility for the compiler to give useful warnings when the argument
order is incorrect.  It's probably good to have to call compile-regex
explicitly anyway since you probably really want to do it only once
and store the regex in a constant.

I updated callers throughout trunk/libraries but it's difficult to
know whether I caused any regressions.  I compiled all changed
libraries and checked for regex-related warnings, and ran the test
suites, but did not compare to results prior to this change.

Minor changes also included here:

* updated testworks to call force-output(*standard-output*)
* deleted regular-expressions-test-suite-app library and made
  regular-expressions-test-suite work as exe or dll
* fixed koala-related imports for turboblog
  • Loading branch information...
1 parent 9907fa1 commit d378c23e0a6b0e68e5e7f7276907b185aafa3283 @cgay cgay committed
Showing with 15 additions and 14 deletions.
  1. +1 −1 blog.dylan
  2. +1 −1 feed.dylan
  3. +3 −2 library.dylan
  4. +10 −10 pingback.dylan
View
2 blog.dylan
@@ -489,7 +489,7 @@ define method archive-responder (blog :: <blog>)
authenticate();
let (year, month, day, title) = apply(values,
- split(request.request-url-tail, separator: "/"));
+ split(request.request-url-suffix, separator: "/"));
let (year, month, day) = validate-dates(year, month, day);
let add? :: <boolean> = (get-query-value("add") = #t);
View
2 feed.dylan
@@ -44,7 +44,7 @@ define method serve-feed (blog :: <blog>, type == #"atom", #key feed-entries ::
feed.links["self"] := make(<blog-link>, rel: "self", href: requested-url());
set-content-type(current-response(), "application/atom+xml");
- format(output-stream(current-response()), "%s", generate-atom(feed, entries: feed-entries));
+ output("%s", generate-atom(feed, entries: feed-entries));
end;
define method generate-atom (entry :: <blog-entry>, #key)
View
5 library.dylan
@@ -11,8 +11,8 @@ define library turboblog
use network;
use string-extensions;
use regular-expressions;
- use koala,
- import: { dsp };
+ use dsp;
+ use koala;
use web-framework;
use xml-parser;
use xml-rpc-client;
@@ -36,6 +36,7 @@ define module turboblog
use substring-search;
use regular-expressions;
use dsp, exclude: { join };
+ use koala;
use web-framework, exclude: { slot-type };
use users;
use permission;
View
20 pingback.dylan
@@ -54,11 +54,11 @@ define method ping (source, target)
let (content-type, content-length) = values(#f, #f);
let current = #f;
while ((current := read-line(socket)) ~= "")
- let (header, content-type-value) = regex-search-strings("Content-Type: (.*)", current);
+ let (header, content-type-value) = regex-search-strings(compile-regex("Content-Type: (.*)"), current);
if (content-type-value)
content-type := remove!(content-type-value, '\r', test: \=);
else
- let (header, content-length-value) = regex-search-strings("Content-Length: (\\d+)", current);
+ let (header, content-length-value) = regex-search-strings(compile-regex("Content-Length: (\\d+)"), current);
if (content-length-value)
content-length := remove!(content-length-value, '\r', test: \=);
end if;
@@ -80,12 +80,12 @@ define method ping (source, target)
end while;
end if;
- let link = regex-search-strings(concatenate("<a(.*) href=\"", target,"\"(.*)>"), content);
+ let link = regex-search-strings(compile-regex(concatenate("<a(.*) href=\"", target,"\"(.*)>")), content);
unless (link)
xml-rpc-fault(17, "The source URI does not contain a link to the target URI, and so cannot be used as a source.");
end unless;
- let (title, title-value) = regex-search-strings("<title>((.|\n)*)</title>", content);
+ let (title, title-value) = regex-search-strings(compile-regex("<title>((.|\n)*)</title>"), content);
unless (title-value)
xml-rpc-fault(0, "The source URI does not contain a title.");
end unless;
@@ -97,9 +97,9 @@ define method ping (source, target)
start: link-position - 100,
end: link-position + size(link) + 100);
- let plain-text = regex-replace(text, "<[a-zA-Z\\/][^>]*>", "");
- plain-text := regex-replace(plain-text, "(.*)>", "");
- plain-text := regex-replace(plain-text, "<(.*)", "");
+ let plain-text = regex-replace(text, compile-regex("<[a-zA-Z\\/][^>]*>"), "");
+ plain-text := regex-replace(plain-text, compile-regex("(.*)>"), "");
+ plain-text := regex-replace(plain-text, compile-regex("<(.*)"), "");
plain-text := concatenate("[...] ", plain-text," [...]");
let pingback = make(<blog-pingback>, source: source,
@@ -134,7 +134,7 @@ end;
define method do-pingbacks (entry :: <blog-entry>)
let source = build-uri(permanent-link(entry, full?: #t, escaped?: #t));
let content = entry.content.content;
- let regex = "<a([^>]+)href=\"([^>\"]+)\"([^>]*)>";
+ let regex = compile-regex("<a([^>]+)href=\"([^>\"]+)\"([^>]*)>");
let start = 0;
while (regex-position(regex, content, start: start))
let (#rest matches) = regex-search-strings(regex, copy-sequence(content, start: start));
@@ -152,10 +152,10 @@ define method discover-pingback (source :: <string>, target :: <string>)
if (~empty?(url.uri-host))
let response = read(http-request(target), 5*1024);
let (header, pingback-url) =
- regex-search-strings("X-Pingback: (.*)\r", response);
+ regex-search-strings(compile-regex("X-Pingback: (.*)\r"), response);
unless (pingback-url)
let (link, pingback-url) =
- regex-search-strings("<link rel=\"pingback\" href=\"([^\"]+)\" ?/?>", response);
+ regex-search-strings(compile-regex("<link rel=\"pingback\" href=\"([^\"]+)\" ?/?>"), response);
end;
if (pingback-url)
let url = parse-uri(pingback-url, as: <url>);

0 comments on commit d378c23

Please sign in to comment.
Something went wrong with that request. Please try again.