summaryrefslogtreecommitdiff
path: root/src/gmutil.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-23 22:40:31 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-23 22:40:31 +0300
commitd797bdbc82e3770a3a0c0bbbf50a0174436fa798 (patch)
treeb26793474322274ca891ad1410cad874ccc0c3cc /src/gmutil.c
parent91167bd9d49ac52587da382351a009e2465c3bdd (diff)
Build option to disable kerning; other optimizations
Diffstat (limited to 'src/gmutil.c')
-rw-r--r--src/gmutil.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/gmutil.c b/src/gmutil.c
index d278669d..cd00eb1d 100644
--- a/src/gmutil.c
+++ b/src/gmutil.c
@@ -27,12 +27,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
27#include <the_Foundation/path.h> 27#include <the_Foundation/path.h>
28 28
29void init_Url(iUrl *d, const iString *text) { 29void init_Url(iUrl *d, const iString *text) {
30 iRegExp *absPat = 30 static iRegExp *absoluteUrlPattern_;
31 new_RegExp("([a-z]+:)?(//[^/:?]*)(:[0-9]+)?([^?]*)(\\?.*)?", caseInsensitive_RegExpOption); 31 static iRegExp *relativeUrlPattern_;
32 if (!absoluteUrlPattern_) {
33 absoluteUrlPattern_ = new_RegExp("([a-z]+:)?(//[^/:?]*)(:[0-9]+)?([^?]*)(\\?.*)?",
34 caseInsensitive_RegExpOption);
35 }
32 iRegExpMatch m; 36 iRegExpMatch m;
33 if (matchString_RegExp(absPat, text, &m)) { 37 if (matchString_RegExp(absoluteUrlPattern_, text, &m)) {
34 d->protocol = capturedRange_RegExpMatch(&m, 1); 38 d->protocol = capturedRange_RegExpMatch(&m, 1);
35 d->host = capturedRange_RegExpMatch(&m, 2); 39 d->host = capturedRange_RegExpMatch(&m, 2);
36 if (!isEmpty_Range(&d->host)) { 40 if (!isEmpty_Range(&d->host)) {
37 d->host.start += 2; /* skip the double slash */ 41 d->host.start += 2; /* skip the double slash */
38 } 42 }
@@ -40,21 +44,21 @@ void init_Url(iUrl *d, const iString *text) {
40 if (!isEmpty_Range(&d->port)) { 44 if (!isEmpty_Range(&d->port)) {
41 d->port.start++; /* omit the colon */ 45 d->port.start++; /* omit the colon */
42 } 46 }
43 d->path = capturedRange_RegExpMatch(&m, 4); 47 d->path = capturedRange_RegExpMatch(&m, 4);
44 d->query = capturedRange_RegExpMatch(&m, 5); 48 d->query = capturedRange_RegExpMatch(&m, 5);
45 } 49 }
46 else { 50 else {
47 /* Must be a relative path. */ 51 /* Must be a relative path. */
48 iZap(*d); 52 iZap(*d);
49 iRegExp *relPat = new_RegExp("([a-z]+:)?([^?]*)(\\?.*)?", 0); 53 if (!relativeUrlPattern_) {
50 if (matchString_RegExp(relPat, text, &m)) { 54 relativeUrlPattern_ = new_RegExp("([a-z]+:)?([^?]*)(\\?.*)?", 0);
55 }
56 if (matchString_RegExp(relativeUrlPattern_, text, &m)) {
51 d->protocol = capturedRange_RegExpMatch(&m, 1); 57 d->protocol = capturedRange_RegExpMatch(&m, 1);
52 d->path = capturedRange_RegExpMatch(&m, 2); 58 d->path = capturedRange_RegExpMatch(&m, 2);
53 d->query = capturedRange_RegExpMatch(&m, 3); 59 d->query = capturedRange_RegExpMatch(&m, 3);
54 } 60 }
55 iRelease(relPat);
56 } 61 }
57 iRelease(absPat);
58 if (!isEmpty_Range(&d->protocol)) { 62 if (!isEmpty_Range(&d->protocol)) {
59 d->protocol.end--; /* omit the colon */ 63 d->protocol.end--; /* omit the colon */
60 } 64 }