From 455a635080a1c1c4b164af3060836f0d8c1b3c1c Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Mon, 24 Aug 2020 13:15:00 +0300 Subject: Updated for the_Foundation API changes --- src/app.c | 6 +++--- src/bookmarks.c | 6 +++--- src/gmcerts.c | 2 +- src/gmdocument.c | 40 ++++++++++++++++++++-------------------- src/gmrequest.c | 34 +++++++++++++++++----------------- src/gmutil.c | 18 +++++++++--------- src/ui/documentwidget.c | 16 ++++++++-------- src/ui/sidebarwidget.c | 2 +- src/visited.c | 2 +- 9 files changed, 63 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/app.c b/src/app.c index 3ffb1c94..31be06fd 100644 --- a/src/app.c +++ b/src/app.c @@ -154,7 +154,7 @@ static void loadPrefs_App_(iApp *d) { iString *str = readString_File(f); const iRangecc src = range_String(str); iRangecc line = iNullRange; - while (nextSplit_Rangecc(&src, "\n", &line)) { + while (nextSplit_Rangecc(src, "\n", &line)) { iString cmdStr; initRange_String(&cmdStr, line); const char *cmd = cstr_String(&cmdStr); @@ -602,8 +602,8 @@ iBool handleCommand_App(const char *cmd) { const iString *url = collect_String(newCStr_String(suffixPtr_Command(cmd, "url"))); iUrl parts; init_Url(&parts, url); - if (equalCase_Rangecc(&parts.protocol, "http") || - equalCase_Rangecc(&parts.protocol, "https")) { + if (equalCase_Rangecc(parts.protocol, "http") || + equalCase_Rangecc(parts.protocol, "https")) { openInDefaultBrowser_App(url); return iTrue; } diff --git a/src/bookmarks.c b/src/bookmarks.c index 6600ee4d..eff0146d 100644 --- a/src/bookmarks.c +++ b/src/bookmarks.c @@ -85,7 +85,7 @@ void load_Bookmarks(iBookmarks *d, const char *dirPath) { if (open_File(f, readOnly_FileMode | text_FileMode)) { const iRangecc src = range_Block(collect_Block(readAll_File(f))); iRangecc line = iNullRange; - while (nextSplit_Rangecc(&src, "\n", &line)) { + while (nextSplit_Rangecc(src, "\n", &line)) { /* Skip empty lines. */ { iRangecc ln = line; trim_Rangecc(&ln); @@ -100,9 +100,9 @@ void load_Bookmarks(iBookmarks *d, const char *dirPath) { initSeconds_Time(&bm->when, strtod(line.start, &endPos)); line.start = skipSpace_CStr(endPos); setRange_String(&bm->url, line); - nextSplit_Rangecc(&src, "\n", &line); + nextSplit_Rangecc(src, "\n", &line); setRange_String(&bm->title, line); - nextSplit_Rangecc(&src, "\n", &line); + nextSplit_Rangecc(src, "\n", &line); setRange_String(&bm->tags, line); insert_Bookmarks_(d, bm); } diff --git a/src/gmcerts.c b/src/gmcerts.c index b8fb6a7f..e13e9a8d 100644 --- a/src/gmcerts.c +++ b/src/gmcerts.c @@ -264,7 +264,7 @@ static void load_GmCerts_(iGmCerts *d) { iRegExp * pattern = new_RegExp("([^\\s]+) ([0-9]+) ([a-z0-9]+)", 0); const iRangecc src = range_Block(collect_Block(readAll_File(f))); iRangecc line = iNullRange; - while (nextSplit_Rangecc(&src, "\n", &line)) { + while (nextSplit_Rangecc(src, "\n", &line)) { iRegExpMatch m; init_RegExpMatch(&m); if (matchRange_RegExp(pattern, line, &m)) { diff --git a/src/gmdocument.c b/src/gmdocument.c index 5bc16fda..4cba5adf 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c @@ -128,11 +128,11 @@ enum iGmLineType { max_GmLineType, }; -static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangecc *line) { +static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangecc line) { if (d->format == plainText_GmDocumentFormat) { return text_GmLineType; } - if (isEmpty_Range(line)) { + if (isEmpty_Range(&line)) { return text_GmLineType; } if (startsWith_Rangecc(line, "=>")) { @@ -150,10 +150,10 @@ static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangec if (startsWith_Rangecc(line, "```")) { return preformatted_GmLineType; } - if (*line->start == '>') { + if (*line.start == '>') { return quote_GmLineType; } - if (size_Range(line) >= 2 && line->start[0] == '*' && isspace(line->start[1])) { + if (size_Range(&line) >= 2 && line.start[0] == '*' && isspace(line.start[1])) { return bullet_GmLineType; } return text_GmLineType; @@ -179,11 +179,11 @@ static int lastVisibleRunBottom_GmDocument_(const iGmDocument *d) { iInt2 measurePreformattedBlock_GmDocument_(const iGmDocument *d, const char *start, int font) { const iRangecc content = { start, constEnd_String(&d->source) }; iRangecc line = iNullRange; - nextSplit_Rangecc(&content, "\n", &line); - iAssert(startsWith_Rangecc(&line, "```")); + nextSplit_Rangecc(content, "\n", &line); + iAssert(startsWith_Rangecc(line, "```")); iRangecc preBlock = { line.end + 1, line.end + 1 }; - while (nextSplit_Rangecc(&content, "\n", &line)) { - if (startsWith_Rangecc(&line, "```")) { + while (nextSplit_Rangecc(content, "\n", &line)) { + if (startsWith_Rangecc(line, "```")) { break; } preBlock.end = line.end; @@ -205,22 +205,22 @@ static iRangecc addLink_GmDocument_(iGmDocument *d, iRangecc line, iGmLinkId *li /* Check the URL. */ { iUrl parts; init_Url(&parts, &link->url); - if (!equalCase_Rangecc(&parts.host, cstr_String(&d->localHost))) { + if (!equalCase_Rangecc(parts.host, cstr_String(&d->localHost))) { link->flags |= remote_GmLinkFlag; } - if (startsWithCase_Rangecc(&parts.protocol, "gemini")) { + if (startsWithCase_Rangecc(parts.protocol, "gemini")) { link->flags |= gemini_GmLinkFlag; } - else if (startsWithCase_Rangecc(&parts.protocol, "http")) { + else if (startsWithCase_Rangecc(parts.protocol, "http")) { link->flags |= http_GmLinkFlag; } - else if (equalCase_Rangecc(&parts.protocol, "gopher")) { + else if (equalCase_Rangecc(parts.protocol, "gopher")) { link->flags |= gopher_GmLinkFlag; } - else if (equalCase_Rangecc(&parts.protocol, "file")) { + else if (equalCase_Rangecc(parts.protocol, "file")) { link->flags |= file_GmLinkFlag; } - else if (equalCase_Rangecc(&parts.protocol, "data")) { + else if (equalCase_Rangecc(parts.protocol, "data")) { link->flags |= data_GmLinkFlag; } /* Check the file name extension, if present. */ @@ -336,7 +336,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { isPreformat = iTrue; isFirstText = iFalse; } - while (nextSplit_Rangecc(&content, "\n", &line)) { + while (nextSplit_Rangecc(content, "\n", &line)) { iGmRun run; run.flags = 0; run.color = white_ColorId; @@ -345,7 +345,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { enum iGmLineType type; int indent = 0; if (!isPreformat) { - type = lineType_GmDocument_(d, &line); + type = lineType_GmDocument_(d, line); if (line.start == content.start) { prevType = type; } @@ -383,7 +383,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { /* Preformatted line. */ type = preformatted_GmLineType; if (d->format == gemini_GmDocumentFormat && - startsWithSc_Rangecc(&line, "```", &iCaseSensitive)) { + startsWithSc_Rangecc(line, "```", &iCaseSensitive)) { isPreformat = iFalse; preAltText = iNullRange; addSiteBanner = iFalse; /* overrides the banner */ @@ -851,7 +851,7 @@ static void normalize_GmDocument(iGmDocument *d) { isPreformat = iTrue; /* Cannot be turned off. */ } const int preTabWidth = 8; /* TODO: user-configurable parameter */ - while (nextSplit_Rangecc(&src, "\n", &line)) { + while (nextSplit_Rangecc(src, "\n", &line)) { if (isPreformat) { /* Replace any tab characters with spaces for visualization. */ for (const char *ch = line.start; ch != line.end; ch++) { @@ -867,12 +867,12 @@ static void normalize_GmDocument(iGmDocument *d) { } } appendCStr_String(normalized, "\n"); - if (lineType_GmDocument_(d, &line) == preformatted_GmLineType) { + if (lineType_GmDocument_(d, line) == preformatted_GmLineType) { isPreformat = iFalse; } continue; } - if (lineType_GmDocument_(d, &line) == preformatted_GmLineType) { + if (lineType_GmDocument_(d, line) == preformatted_GmLineType) { isPreformat = iTrue; appendRange_String(normalized, line); appendCStr_String(normalized, "\n"); diff --git a/src/gmrequest.c b/src/gmrequest.c index c231e1f3..ebb66a84 100644 --- a/src/gmrequest.c +++ b/src/gmrequest.c @@ -299,13 +299,13 @@ static void requestFinished_GmRequest_(iAnyObject *obj) { static const iBlock *aboutPageSource_(iRangecc path) { const iBlock *src = NULL; - if (equalCase_Rangecc(&path, "lagrange")) { + if (equalCase_Rangecc(path, "lagrange")) { return &blobLagrange_Embedded; } - if (equalCase_Rangecc(&path, "help")) { + if (equalCase_Rangecc(path, "help")) { return &blobHelp_Embedded; } - if (equalCase_Rangecc(&path, "version")) { + if (equalCase_Rangecc(path, "version")) { return &blobVersion_Embedded; } return src; @@ -321,10 +321,10 @@ static const iBlock *replaceVariables_(const iBlock *block) { const iRangei span = m.range; const iRangecc name = capturedRange_RegExpMatch(&m, 1); iRangecc repl = iNullRange; - if (equal_Rangecc(&name, "APP_VERSION")) { + if (equal_Rangecc(name, "APP_VERSION")) { repl = range_CStr(LAGRANGE_APP_VERSION); } - else if (startsWith_Rangecc(&name, "BT:")) { /* block text */ + else if (startsWith_Rangecc(name, "BT:")) { /* block text */ repl = range_String(collect_String(renderBlockChars_Text( &fontFiraSansRegular_Embedded, 11, /* should be larger if shaded */ @@ -332,7 +332,7 @@ static const iBlock *replaceVariables_(const iBlock *block) { &(iString){ iBlockLiteral( name.start + 3, size_Range(&name) - 3, size_Range(&name) - 3) }))); } - else if (startsWith_Rangecc(&name, "ST:")) { /* shaded text */ + else if (startsWith_Rangecc(name, "ST:")) { /* shaded text */ repl = range_String(collect_String(renderBlockChars_Text( &fontSymbola_Embedded, 20, @@ -340,42 +340,42 @@ static const iBlock *replaceVariables_(const iBlock *block) { &(iString){ iBlockLiteral( name.start + 3, size_Range(&name) - 3, size_Range(&name) - 3) }))); } - else if (equal_Rangecc(&name, "ALT")) { + else if (equal_Rangecc(name, "ALT")) { #if defined (iPlatformApple) repl = range_CStr("\u2325"); #else repl = range_CStr("Alt"); #endif } - else if (equal_Rangecc(&name, "ALT+")) { + else if (equal_Rangecc(name, "ALT+")) { #if defined (iPlatformApple) repl = range_CStr("\u2325"); #else repl = range_CStr("Alt+"); #endif } - else if (equal_Rangecc(&name, "CTRL")) { + else if (equal_Rangecc(name, "CTRL")) { #if defined (iPlatformApple) repl = range_CStr("\u2318"); #else repl = range_CStr("Ctrl"); #endif } - else if (equal_Rangecc(&name, "CTRL+")) { + else if (equal_Rangecc(name, "CTRL+")) { #if defined (iPlatformApple) repl = range_CStr("\u2318"); #else repl = range_CStr("Ctrl+"); #endif } - else if (equal_Rangecc(&name, "SHIFT")) { + else if (equal_Rangecc(name, "SHIFT")) { #if defined (iPlatformApple) repl = range_CStr("\u21e7"); #else repl = range_CStr("Shift"); #endif } - else if (equal_Rangecc(&name, "SHIFT+")) { + else if (equal_Rangecc(name, "SHIFT+")) { #if defined (iPlatformApple) repl = range_CStr("\u21e7"); #else @@ -403,7 +403,7 @@ void submit_GmRequest(iGmRequest *d) { init_Url(&url, &d->url); /* Check for special protocols. */ /* TODO: If this were a library, these could be handled via callbacks. */ - if (equalCase_Rangecc(&url.protocol, "about")) { + if (equalCase_Rangecc(url.protocol, "about")) { const iBlock *src = aboutPageSource_(url.path); if (src) { d->resp.statusCode = success_GmStatusCode; @@ -419,7 +419,7 @@ void submit_GmRequest(iGmRequest *d) { iNotifyAudience(d, finished, GmRequestFinished); return; } - else if (equalCase_Rangecc(&url.protocol, "file")) { + else if (equalCase_Rangecc(url.protocol, "file")) { iString *path = collect_String(urlDecode_String(collect_String(newRange_String(url.path)))); iFile * f = new_File(path); if (open_File(f, readOnly_FileMode)) { @@ -457,7 +457,7 @@ void submit_GmRequest(iGmRequest *d) { iNotifyAudience(d, finished, GmRequestFinished); return; } - else if (equalCase_Rangecc(&url.protocol, "data")) { + else if (equalCase_Rangecc(url.protocol, "data")) { d->resp.statusCode = success_GmStatusCode; iString *src = collectNewCStr_String(url.protocol.start + 5); iRangecc header = { constBegin_String(src), constBegin_String(src) }; @@ -468,8 +468,8 @@ void submit_GmRequest(iGmRequest *d) { setRange_String(&d->resp.meta, header); /* Check what's in the header. */ { iRangecc entry = iNullRange; - while (nextSplit_Rangecc(&header, ";", &entry)) { - if (equal_Rangecc(&entry, "base64")) { + while (nextSplit_Rangecc(header, ";", &entry)) { + if (equal_Rangecc(entry, "base64")) { isBase64 = iTrue; } } diff --git a/src/gmutil.c b/src/gmutil.c index 2927953d..3af42cd1 100644 --- a/src/gmutil.c +++ b/src/gmutil.c @@ -66,7 +66,7 @@ void init_Url(iUrl *d, const iString *text) { } static iRangecc dirPath_(iRangecc path) { - const size_t pos = lastIndexOfCStr_Rangecc(&path, "/"); + const size_t pos = lastIndexOfCStr_Rangecc(path, "/"); if (pos == iInvalidPos) return path; return (iRangecc){ path.start, path.start + pos }; } @@ -89,13 +89,13 @@ void cleanUrlPath_String(iString *d) { iUrl parts; init_Url(&parts, d); iRangecc seg = iNullRange; - while (nextSplit_Rangecc(&parts.path, "/", &seg)) { - if (equal_Rangecc(&seg, "..")) { + while (nextSplit_Rangecc(parts.path, "/", &seg)) { + if (equal_Rangecc(seg, "..")) { /* Back up one segment. */ iRangecc last = prevPathSeg_(constEnd_String(&clean), constBegin_String(&clean)); truncate_Block(&clean.chars, last.start - constBegin_String(&clean)); } - else if (equal_Rangecc(&seg, ".")) { + else if (equal_Rangecc(seg, ".")) { /* Skip it. */ } else { @@ -103,11 +103,11 @@ void cleanUrlPath_String(iString *d) { appendRange_String(&clean, seg); } } - if (endsWith_Rangecc(&parts.path, "/")) { + if (endsWith_Rangecc(parts.path, "/")) { appendCStr_String(&clean, "/"); } /* Replace with the new path. */ - if (cmpCStrNSc_Rangecc(&parts.path, cstr_String(&clean), size_String(&clean), &iCaseSensitive)) { + if (cmpCStrNSc_Rangecc(parts.path, cstr_String(&clean), size_String(&clean), &iCaseSensitive)) { const size_t pos = parts.path.start - constBegin_String(d); remove_Block(&d->chars, pos, size_Range(&parts.path)); insertData_Block(&d->chars, pos, cstr_String(&clean), size_String(&clean)); @@ -132,7 +132,7 @@ const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelat iUrl rel; init_Url(&orig, d); init_Url(&rel, urlMaybeRelative); - if (equalCase_Rangecc(&rel.protocol, "data") || equalCase_Rangecc(&rel.protocol, "about")) { + if (equalCase_Rangecc(rel.protocol, "data") || equalCase_Rangecc(rel.protocol, "about")) { /* Special case, the contents should be left unparsed. */ return urlMaybeRelative; } @@ -154,11 +154,11 @@ const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelat appendRange_String(absolute, selHost->port); } } - if (isDef_(rel.protocol) || isDef_(rel.host) || startsWith_Rangecc(&rel.path, "/")) { + if (isDef_(rel.protocol) || isDef_(rel.host) || startsWith_Rangecc(rel.path, "/")) { appendRange_String(absolute, rel.path); /* absolute path */ } else { - if (!endsWith_Rangecc(&orig.path, "/")) { + if (!endsWith_Rangecc(orig.path, "/")) { /* Referencing a file. */ appendRange_String(absolute, dirPath_(orig.path)); } diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 6c0337a0..8f31c690 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -540,16 +540,16 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse const iString *mimeStr = collect_String(lower_String(&response->meta)); /* for convenience */ iRangecc mime = range_String(mimeStr); iRangecc seg = iNullRange; - while (nextSplit_Rangecc(&mime, ";", &seg)) { + while (nextSplit_Rangecc(mime, ";", &seg)) { iRangecc param = seg; trim_Rangecc(¶m); - if (equal_Rangecc(¶m, "text/plain")) { + if (equal_Rangecc(param, "text/plain")) { docFormat = plainText_GmDocumentFormat; } - else if (equal_Rangecc(¶m, "text/gemini")) { + else if (equal_Rangecc(param, "text/gemini")) { docFormat = gemini_GmDocumentFormat; } - else if (startsWith_Rangecc(¶m, "image/")) { + else if (startsWith_Rangecc(param, "image/")) { docFormat = gemini_GmDocumentFormat; if (!d->request || isFinished_GmRequest(d->request)) { /* Make a simple document with an image. */ @@ -568,7 +568,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse clear_String(&str); } } - else if (startsWith_Rangecc(¶m, "charset=")) { + else if (startsWith_Rangecc(param, "charset=")) { charset = (iRangecc){ param.start + 8, param.end }; /* Remove whitespace and quotes. */ trim_Rangecc(&charset); @@ -584,7 +584,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse return; } /* Convert the source to UTF-8 if needed. */ - if (!equalCase_Rangecc(&charset, "utf-8")) { + if (!equalCase_Rangecc(charset, "utf-8")) { set_String(&str, collect_String(decode_Block(&str.chars, cstr_Rangecc(charset)))); } @@ -1083,7 +1083,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) d->state = ready_RequestState; /* The response may be cached. */ { const iRangecc proto = urlProtocol_String(d->mod.url); - if (!equal_Rangecc(&proto, "about")) { + if (!equal_Rangecc(proto, "about")) { setCachedResponse_History(d->mod.history, response_GmRequest(d->request)); } } @@ -1607,7 +1607,7 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { &str, " \u2014%s%s%s\r%c%s", showHost ? " " : "", - showHost ? (!equalCase_Rangecc(&parts.protocol, "gemini") + showHost ? (!equalCase_Rangecc(parts.protocol, "gemini") ? format_CStr("%s://%s", cstr_Rangecc(parts.protocol), cstr_Rangecc(parts.host)) diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 066386cb..82efb04e 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c @@ -719,7 +719,7 @@ static void draw_SidebarWidget_(const iSidebarWidget *d) { else { iUrl parts; init_Url(&parts, &item->url); - const iBool isGemini = equalCase_Rangecc(&parts.protocol, "gemini"); + const iBool isGemini = equalCase_Rangecc(parts.protocol, "gemini"); draw_Text( font, add_I2(topLeft_Rect(itemRect), diff --git a/src/visited.c b/src/visited.c index 60b86aa5..912a6318 100644 --- a/src/visited.c +++ b/src/visited.c @@ -96,7 +96,7 @@ void load_Visited(iVisited *d, const char *dirPath) { iRangecc line = iNullRange; iTime now; initCurrent_Time(&now); - while (nextSplit_Rangecc(&src, "\n", &line)) { + while (nextSplit_Rangecc(src, "\n", &line)) { int y, m, D, H, M, S; sscanf(line.start, "%04d-%02d-%02dT%02d:%02d:%02d ", &y, &m, &D, &H, &M, &S); if (!y) break; -- cgit v1.2.3