diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-24 13:15:00 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-24 13:15:00 +0300 |
commit | 455a635080a1c1c4b164af3060836f0d8c1b3c1c (patch) | |
tree | bc77c492e9b7187d8b277d2a1cd024902c8ae3eb /src | |
parent | fbf36dfbf77701d647f0133f1532ebc42eb05e32 (diff) |
Updated for the_Foundation API changes
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 6 | ||||
-rw-r--r-- | src/bookmarks.c | 6 | ||||
-rw-r--r-- | src/gmcerts.c | 2 | ||||
-rw-r--r-- | src/gmdocument.c | 40 | ||||
-rw-r--r-- | src/gmrequest.c | 34 | ||||
-rw-r--r-- | src/gmutil.c | 18 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 16 | ||||
-rw-r--r-- | src/ui/sidebarwidget.c | 2 | ||||
-rw-r--r-- | src/visited.c | 2 |
9 files changed, 63 insertions, 63 deletions
@@ -154,7 +154,7 @@ static void loadPrefs_App_(iApp *d) { | |||
154 | iString *str = readString_File(f); | 154 | iString *str = readString_File(f); |
155 | const iRangecc src = range_String(str); | 155 | const iRangecc src = range_String(str); |
156 | iRangecc line = iNullRange; | 156 | iRangecc line = iNullRange; |
157 | while (nextSplit_Rangecc(&src, "\n", &line)) { | 157 | while (nextSplit_Rangecc(src, "\n", &line)) { |
158 | iString cmdStr; | 158 | iString cmdStr; |
159 | initRange_String(&cmdStr, line); | 159 | initRange_String(&cmdStr, line); |
160 | const char *cmd = cstr_String(&cmdStr); | 160 | const char *cmd = cstr_String(&cmdStr); |
@@ -602,8 +602,8 @@ iBool handleCommand_App(const char *cmd) { | |||
602 | const iString *url = collect_String(newCStr_String(suffixPtr_Command(cmd, "url"))); | 602 | const iString *url = collect_String(newCStr_String(suffixPtr_Command(cmd, "url"))); |
603 | iUrl parts; | 603 | iUrl parts; |
604 | init_Url(&parts, url); | 604 | init_Url(&parts, url); |
605 | if (equalCase_Rangecc(&parts.protocol, "http") || | 605 | if (equalCase_Rangecc(parts.protocol, "http") || |
606 | equalCase_Rangecc(&parts.protocol, "https")) { | 606 | equalCase_Rangecc(parts.protocol, "https")) { |
607 | openInDefaultBrowser_App(url); | 607 | openInDefaultBrowser_App(url); |
608 | return iTrue; | 608 | return iTrue; |
609 | } | 609 | } |
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) { | |||
85 | if (open_File(f, readOnly_FileMode | text_FileMode)) { | 85 | if (open_File(f, readOnly_FileMode | text_FileMode)) { |
86 | const iRangecc src = range_Block(collect_Block(readAll_File(f))); | 86 | const iRangecc src = range_Block(collect_Block(readAll_File(f))); |
87 | iRangecc line = iNullRange; | 87 | iRangecc line = iNullRange; |
88 | while (nextSplit_Rangecc(&src, "\n", &line)) { | 88 | while (nextSplit_Rangecc(src, "\n", &line)) { |
89 | /* Skip empty lines. */ { | 89 | /* Skip empty lines. */ { |
90 | iRangecc ln = line; | 90 | iRangecc ln = line; |
91 | trim_Rangecc(&ln); | 91 | trim_Rangecc(&ln); |
@@ -100,9 +100,9 @@ void load_Bookmarks(iBookmarks *d, const char *dirPath) { | |||
100 | initSeconds_Time(&bm->when, strtod(line.start, &endPos)); | 100 | initSeconds_Time(&bm->when, strtod(line.start, &endPos)); |
101 | line.start = skipSpace_CStr(endPos); | 101 | line.start = skipSpace_CStr(endPos); |
102 | setRange_String(&bm->url, line); | 102 | setRange_String(&bm->url, line); |
103 | nextSplit_Rangecc(&src, "\n", &line); | 103 | nextSplit_Rangecc(src, "\n", &line); |
104 | setRange_String(&bm->title, line); | 104 | setRange_String(&bm->title, line); |
105 | nextSplit_Rangecc(&src, "\n", &line); | 105 | nextSplit_Rangecc(src, "\n", &line); |
106 | setRange_String(&bm->tags, line); | 106 | setRange_String(&bm->tags, line); |
107 | insert_Bookmarks_(d, bm); | 107 | insert_Bookmarks_(d, bm); |
108 | } | 108 | } |
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) { | |||
264 | iRegExp * pattern = new_RegExp("([^\\s]+) ([0-9]+) ([a-z0-9]+)", 0); | 264 | iRegExp * pattern = new_RegExp("([^\\s]+) ([0-9]+) ([a-z0-9]+)", 0); |
265 | const iRangecc src = range_Block(collect_Block(readAll_File(f))); | 265 | const iRangecc src = range_Block(collect_Block(readAll_File(f))); |
266 | iRangecc line = iNullRange; | 266 | iRangecc line = iNullRange; |
267 | while (nextSplit_Rangecc(&src, "\n", &line)) { | 267 | while (nextSplit_Rangecc(src, "\n", &line)) { |
268 | iRegExpMatch m; | 268 | iRegExpMatch m; |
269 | init_RegExpMatch(&m); | 269 | init_RegExpMatch(&m); |
270 | if (matchRange_RegExp(pattern, line, &m)) { | 270 | 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 { | |||
128 | max_GmLineType, | 128 | max_GmLineType, |
129 | }; | 129 | }; |
130 | 130 | ||
131 | static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangecc *line) { | 131 | static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangecc line) { |
132 | if (d->format == plainText_GmDocumentFormat) { | 132 | if (d->format == plainText_GmDocumentFormat) { |
133 | return text_GmLineType; | 133 | return text_GmLineType; |
134 | } | 134 | } |
135 | if (isEmpty_Range(line)) { | 135 | if (isEmpty_Range(&line)) { |
136 | return text_GmLineType; | 136 | return text_GmLineType; |
137 | } | 137 | } |
138 | if (startsWith_Rangecc(line, "=>")) { | 138 | if (startsWith_Rangecc(line, "=>")) { |
@@ -150,10 +150,10 @@ static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangec | |||
150 | if (startsWith_Rangecc(line, "```")) { | 150 | if (startsWith_Rangecc(line, "```")) { |
151 | return preformatted_GmLineType; | 151 | return preformatted_GmLineType; |
152 | } | 152 | } |
153 | if (*line->start == '>') { | 153 | if (*line.start == '>') { |
154 | return quote_GmLineType; | 154 | return quote_GmLineType; |
155 | } | 155 | } |
156 | if (size_Range(line) >= 2 && line->start[0] == '*' && isspace(line->start[1])) { | 156 | if (size_Range(&line) >= 2 && line.start[0] == '*' && isspace(line.start[1])) { |
157 | return bullet_GmLineType; | 157 | return bullet_GmLineType; |
158 | } | 158 | } |
159 | return text_GmLineType; | 159 | return text_GmLineType; |
@@ -179,11 +179,11 @@ static int lastVisibleRunBottom_GmDocument_(const iGmDocument *d) { | |||
179 | iInt2 measurePreformattedBlock_GmDocument_(const iGmDocument *d, const char *start, int font) { | 179 | iInt2 measurePreformattedBlock_GmDocument_(const iGmDocument *d, const char *start, int font) { |
180 | const iRangecc content = { start, constEnd_String(&d->source) }; | 180 | const iRangecc content = { start, constEnd_String(&d->source) }; |
181 | iRangecc line = iNullRange; | 181 | iRangecc line = iNullRange; |
182 | nextSplit_Rangecc(&content, "\n", &line); | 182 | nextSplit_Rangecc(content, "\n", &line); |
183 | iAssert(startsWith_Rangecc(&line, "```")); | 183 | iAssert(startsWith_Rangecc(line, "```")); |
184 | iRangecc preBlock = { line.end + 1, line.end + 1 }; | 184 | iRangecc preBlock = { line.end + 1, line.end + 1 }; |
185 | while (nextSplit_Rangecc(&content, "\n", &line)) { | 185 | while (nextSplit_Rangecc(content, "\n", &line)) { |
186 | if (startsWith_Rangecc(&line, "```")) { | 186 | if (startsWith_Rangecc(line, "```")) { |
187 | break; | 187 | break; |
188 | } | 188 | } |
189 | preBlock.end = line.end; | 189 | preBlock.end = line.end; |
@@ -205,22 +205,22 @@ static iRangecc addLink_GmDocument_(iGmDocument *d, iRangecc line, iGmLinkId *li | |||
205 | /* Check the URL. */ { | 205 | /* Check the URL. */ { |
206 | iUrl parts; | 206 | iUrl parts; |
207 | init_Url(&parts, &link->url); | 207 | init_Url(&parts, &link->url); |
208 | if (!equalCase_Rangecc(&parts.host, cstr_String(&d->localHost))) { | 208 | if (!equalCase_Rangecc(parts.host, cstr_String(&d->localHost))) { |
209 | link->flags |= remote_GmLinkFlag; | 209 | link->flags |= remote_GmLinkFlag; |
210 | } | 210 | } |
211 | if (startsWithCase_Rangecc(&parts.protocol, "gemini")) { | 211 | if (startsWithCase_Rangecc(parts.protocol, "gemini")) { |
212 | link->flags |= gemini_GmLinkFlag; | 212 | link->flags |= gemini_GmLinkFlag; |
213 | } | 213 | } |
214 | else if (startsWithCase_Rangecc(&parts.protocol, "http")) { | 214 | else if (startsWithCase_Rangecc(parts.protocol, "http")) { |
215 | link->flags |= http_GmLinkFlag; | 215 | link->flags |= http_GmLinkFlag; |
216 | } | 216 | } |
217 | else if (equalCase_Rangecc(&parts.protocol, "gopher")) { | 217 | else if (equalCase_Rangecc(parts.protocol, "gopher")) { |
218 | link->flags |= gopher_GmLinkFlag; | 218 | link->flags |= gopher_GmLinkFlag; |
219 | } | 219 | } |
220 | else if (equalCase_Rangecc(&parts.protocol, "file")) { | 220 | else if (equalCase_Rangecc(parts.protocol, "file")) { |
221 | link->flags |= file_GmLinkFlag; | 221 | link->flags |= file_GmLinkFlag; |
222 | } | 222 | } |
223 | else if (equalCase_Rangecc(&parts.protocol, "data")) { | 223 | else if (equalCase_Rangecc(parts.protocol, "data")) { |
224 | link->flags |= data_GmLinkFlag; | 224 | link->flags |= data_GmLinkFlag; |
225 | } | 225 | } |
226 | /* Check the file name extension, if present. */ | 226 | /* Check the file name extension, if present. */ |
@@ -336,7 +336,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
336 | isPreformat = iTrue; | 336 | isPreformat = iTrue; |
337 | isFirstText = iFalse; | 337 | isFirstText = iFalse; |
338 | } | 338 | } |
339 | while (nextSplit_Rangecc(&content, "\n", &line)) { | 339 | while (nextSplit_Rangecc(content, "\n", &line)) { |
340 | iGmRun run; | 340 | iGmRun run; |
341 | run.flags = 0; | 341 | run.flags = 0; |
342 | run.color = white_ColorId; | 342 | run.color = white_ColorId; |
@@ -345,7 +345,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
345 | enum iGmLineType type; | 345 | enum iGmLineType type; |
346 | int indent = 0; | 346 | int indent = 0; |
347 | if (!isPreformat) { | 347 | if (!isPreformat) { |
348 | type = lineType_GmDocument_(d, &line); | 348 | type = lineType_GmDocument_(d, line); |
349 | if (line.start == content.start) { | 349 | if (line.start == content.start) { |
350 | prevType = type; | 350 | prevType = type; |
351 | } | 351 | } |
@@ -383,7 +383,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
383 | /* Preformatted line. */ | 383 | /* Preformatted line. */ |
384 | type = preformatted_GmLineType; | 384 | type = preformatted_GmLineType; |
385 | if (d->format == gemini_GmDocumentFormat && | 385 | if (d->format == gemini_GmDocumentFormat && |
386 | startsWithSc_Rangecc(&line, "```", &iCaseSensitive)) { | 386 | startsWithSc_Rangecc(line, "```", &iCaseSensitive)) { |
387 | isPreformat = iFalse; | 387 | isPreformat = iFalse; |
388 | preAltText = iNullRange; | 388 | preAltText = iNullRange; |
389 | addSiteBanner = iFalse; /* overrides the banner */ | 389 | addSiteBanner = iFalse; /* overrides the banner */ |
@@ -851,7 +851,7 @@ static void normalize_GmDocument(iGmDocument *d) { | |||
851 | isPreformat = iTrue; /* Cannot be turned off. */ | 851 | isPreformat = iTrue; /* Cannot be turned off. */ |
852 | } | 852 | } |
853 | const int preTabWidth = 8; /* TODO: user-configurable parameter */ | 853 | const int preTabWidth = 8; /* TODO: user-configurable parameter */ |
854 | while (nextSplit_Rangecc(&src, "\n", &line)) { | 854 | while (nextSplit_Rangecc(src, "\n", &line)) { |
855 | if (isPreformat) { | 855 | if (isPreformat) { |
856 | /* Replace any tab characters with spaces for visualization. */ | 856 | /* Replace any tab characters with spaces for visualization. */ |
857 | for (const char *ch = line.start; ch != line.end; ch++) { | 857 | for (const char *ch = line.start; ch != line.end; ch++) { |
@@ -867,12 +867,12 @@ static void normalize_GmDocument(iGmDocument *d) { | |||
867 | } | 867 | } |
868 | } | 868 | } |
869 | appendCStr_String(normalized, "\n"); | 869 | appendCStr_String(normalized, "\n"); |
870 | if (lineType_GmDocument_(d, &line) == preformatted_GmLineType) { | 870 | if (lineType_GmDocument_(d, line) == preformatted_GmLineType) { |
871 | isPreformat = iFalse; | 871 | isPreformat = iFalse; |
872 | } | 872 | } |
873 | continue; | 873 | continue; |
874 | } | 874 | } |
875 | if (lineType_GmDocument_(d, &line) == preformatted_GmLineType) { | 875 | if (lineType_GmDocument_(d, line) == preformatted_GmLineType) { |
876 | isPreformat = iTrue; | 876 | isPreformat = iTrue; |
877 | appendRange_String(normalized, line); | 877 | appendRange_String(normalized, line); |
878 | appendCStr_String(normalized, "\n"); | 878 | 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) { | |||
299 | 299 | ||
300 | static const iBlock *aboutPageSource_(iRangecc path) { | 300 | static const iBlock *aboutPageSource_(iRangecc path) { |
301 | const iBlock *src = NULL; | 301 | const iBlock *src = NULL; |
302 | if (equalCase_Rangecc(&path, "lagrange")) { | 302 | if (equalCase_Rangecc(path, "lagrange")) { |
303 | return &blobLagrange_Embedded; | 303 | return &blobLagrange_Embedded; |
304 | } | 304 | } |
305 | if (equalCase_Rangecc(&path, "help")) { | 305 | if (equalCase_Rangecc(path, "help")) { |
306 | return &blobHelp_Embedded; | 306 | return &blobHelp_Embedded; |
307 | } | 307 | } |
308 | if (equalCase_Rangecc(&path, "version")) { | 308 | if (equalCase_Rangecc(path, "version")) { |
309 | return &blobVersion_Embedded; | 309 | return &blobVersion_Embedded; |
310 | } | 310 | } |
311 | return src; | 311 | return src; |
@@ -321,10 +321,10 @@ static const iBlock *replaceVariables_(const iBlock *block) { | |||
321 | const iRangei span = m.range; | 321 | const iRangei span = m.range; |
322 | const iRangecc name = capturedRange_RegExpMatch(&m, 1); | 322 | const iRangecc name = capturedRange_RegExpMatch(&m, 1); |
323 | iRangecc repl = iNullRange; | 323 | iRangecc repl = iNullRange; |
324 | if (equal_Rangecc(&name, "APP_VERSION")) { | 324 | if (equal_Rangecc(name, "APP_VERSION")) { |
325 | repl = range_CStr(LAGRANGE_APP_VERSION); | 325 | repl = range_CStr(LAGRANGE_APP_VERSION); |
326 | } | 326 | } |
327 | else if (startsWith_Rangecc(&name, "BT:")) { /* block text */ | 327 | else if (startsWith_Rangecc(name, "BT:")) { /* block text */ |
328 | repl = range_String(collect_String(renderBlockChars_Text( | 328 | repl = range_String(collect_String(renderBlockChars_Text( |
329 | &fontFiraSansRegular_Embedded, | 329 | &fontFiraSansRegular_Embedded, |
330 | 11, /* should be larger if shaded */ | 330 | 11, /* should be larger if shaded */ |
@@ -332,7 +332,7 @@ static const iBlock *replaceVariables_(const iBlock *block) { | |||
332 | &(iString){ iBlockLiteral( | 332 | &(iString){ iBlockLiteral( |
333 | name.start + 3, size_Range(&name) - 3, size_Range(&name) - 3) }))); | 333 | name.start + 3, size_Range(&name) - 3, size_Range(&name) - 3) }))); |
334 | } | 334 | } |
335 | else if (startsWith_Rangecc(&name, "ST:")) { /* shaded text */ | 335 | else if (startsWith_Rangecc(name, "ST:")) { /* shaded text */ |
336 | repl = range_String(collect_String(renderBlockChars_Text( | 336 | repl = range_String(collect_String(renderBlockChars_Text( |
337 | &fontSymbola_Embedded, | 337 | &fontSymbola_Embedded, |
338 | 20, | 338 | 20, |
@@ -340,42 +340,42 @@ static const iBlock *replaceVariables_(const iBlock *block) { | |||
340 | &(iString){ iBlockLiteral( | 340 | &(iString){ iBlockLiteral( |
341 | name.start + 3, size_Range(&name) - 3, size_Range(&name) - 3) }))); | 341 | name.start + 3, size_Range(&name) - 3, size_Range(&name) - 3) }))); |
342 | } | 342 | } |
343 | else if (equal_Rangecc(&name, "ALT")) { | 343 | else if (equal_Rangecc(name, "ALT")) { |
344 | #if defined (iPlatformApple) | 344 | #if defined (iPlatformApple) |
345 | repl = range_CStr("\u2325"); | 345 | repl = range_CStr("\u2325"); |
346 | #else | 346 | #else |
347 | repl = range_CStr("Alt"); | 347 | repl = range_CStr("Alt"); |
348 | #endif | 348 | #endif |
349 | } | 349 | } |
350 | else if (equal_Rangecc(&name, "ALT+")) { | 350 | else if (equal_Rangecc(name, "ALT+")) { |
351 | #if defined (iPlatformApple) | 351 | #if defined (iPlatformApple) |
352 | repl = range_CStr("\u2325"); | 352 | repl = range_CStr("\u2325"); |
353 | #else | 353 | #else |
354 | repl = range_CStr("Alt+"); | 354 | repl = range_CStr("Alt+"); |
355 | #endif | 355 | #endif |
356 | } | 356 | } |
357 | else if (equal_Rangecc(&name, "CTRL")) { | 357 | else if (equal_Rangecc(name, "CTRL")) { |
358 | #if defined (iPlatformApple) | 358 | #if defined (iPlatformApple) |
359 | repl = range_CStr("\u2318"); | 359 | repl = range_CStr("\u2318"); |
360 | #else | 360 | #else |
361 | repl = range_CStr("Ctrl"); | 361 | repl = range_CStr("Ctrl"); |
362 | #endif | 362 | #endif |
363 | } | 363 | } |
364 | else if (equal_Rangecc(&name, "CTRL+")) { | 364 | else if (equal_Rangecc(name, "CTRL+")) { |
365 | #if defined (iPlatformApple) | 365 | #if defined (iPlatformApple) |
366 | repl = range_CStr("\u2318"); | 366 | repl = range_CStr("\u2318"); |
367 | #else | 367 | #else |
368 | repl = range_CStr("Ctrl+"); | 368 | repl = range_CStr("Ctrl+"); |
369 | #endif | 369 | #endif |
370 | } | 370 | } |
371 | else if (equal_Rangecc(&name, "SHIFT")) { | 371 | else if (equal_Rangecc(name, "SHIFT")) { |
372 | #if defined (iPlatformApple) | 372 | #if defined (iPlatformApple) |
373 | repl = range_CStr("\u21e7"); | 373 | repl = range_CStr("\u21e7"); |
374 | #else | 374 | #else |
375 | repl = range_CStr("Shift"); | 375 | repl = range_CStr("Shift"); |
376 | #endif | 376 | #endif |
377 | } | 377 | } |
378 | else if (equal_Rangecc(&name, "SHIFT+")) { | 378 | else if (equal_Rangecc(name, "SHIFT+")) { |
379 | #if defined (iPlatformApple) | 379 | #if defined (iPlatformApple) |
380 | repl = range_CStr("\u21e7"); | 380 | repl = range_CStr("\u21e7"); |
381 | #else | 381 | #else |
@@ -403,7 +403,7 @@ void submit_GmRequest(iGmRequest *d) { | |||
403 | init_Url(&url, &d->url); | 403 | init_Url(&url, &d->url); |
404 | /* Check for special protocols. */ | 404 | /* Check for special protocols. */ |
405 | /* TODO: If this were a library, these could be handled via callbacks. */ | 405 | /* TODO: If this were a library, these could be handled via callbacks. */ |
406 | if (equalCase_Rangecc(&url.protocol, "about")) { | 406 | if (equalCase_Rangecc(url.protocol, "about")) { |
407 | const iBlock *src = aboutPageSource_(url.path); | 407 | const iBlock *src = aboutPageSource_(url.path); |
408 | if (src) { | 408 | if (src) { |
409 | d->resp.statusCode = success_GmStatusCode; | 409 | d->resp.statusCode = success_GmStatusCode; |
@@ -419,7 +419,7 @@ void submit_GmRequest(iGmRequest *d) { | |||
419 | iNotifyAudience(d, finished, GmRequestFinished); | 419 | iNotifyAudience(d, finished, GmRequestFinished); |
420 | return; | 420 | return; |
421 | } | 421 | } |
422 | else if (equalCase_Rangecc(&url.protocol, "file")) { | 422 | else if (equalCase_Rangecc(url.protocol, "file")) { |
423 | iString *path = collect_String(urlDecode_String(collect_String(newRange_String(url.path)))); | 423 | iString *path = collect_String(urlDecode_String(collect_String(newRange_String(url.path)))); |
424 | iFile * f = new_File(path); | 424 | iFile * f = new_File(path); |
425 | if (open_File(f, readOnly_FileMode)) { | 425 | if (open_File(f, readOnly_FileMode)) { |
@@ -457,7 +457,7 @@ void submit_GmRequest(iGmRequest *d) { | |||
457 | iNotifyAudience(d, finished, GmRequestFinished); | 457 | iNotifyAudience(d, finished, GmRequestFinished); |
458 | return; | 458 | return; |
459 | } | 459 | } |
460 | else if (equalCase_Rangecc(&url.protocol, "data")) { | 460 | else if (equalCase_Rangecc(url.protocol, "data")) { |
461 | d->resp.statusCode = success_GmStatusCode; | 461 | d->resp.statusCode = success_GmStatusCode; |
462 | iString *src = collectNewCStr_String(url.protocol.start + 5); | 462 | iString *src = collectNewCStr_String(url.protocol.start + 5); |
463 | iRangecc header = { constBegin_String(src), constBegin_String(src) }; | 463 | iRangecc header = { constBegin_String(src), constBegin_String(src) }; |
@@ -468,8 +468,8 @@ void submit_GmRequest(iGmRequest *d) { | |||
468 | setRange_String(&d->resp.meta, header); | 468 | setRange_String(&d->resp.meta, header); |
469 | /* Check what's in the header. */ { | 469 | /* Check what's in the header. */ { |
470 | iRangecc entry = iNullRange; | 470 | iRangecc entry = iNullRange; |
471 | while (nextSplit_Rangecc(&header, ";", &entry)) { | 471 | while (nextSplit_Rangecc(header, ";", &entry)) { |
472 | if (equal_Rangecc(&entry, "base64")) { | 472 | if (equal_Rangecc(entry, "base64")) { |
473 | isBase64 = iTrue; | 473 | isBase64 = iTrue; |
474 | } | 474 | } |
475 | } | 475 | } |
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) { | |||
66 | } | 66 | } |
67 | 67 | ||
68 | static iRangecc dirPath_(iRangecc path) { | 68 | static iRangecc dirPath_(iRangecc path) { |
69 | const size_t pos = lastIndexOfCStr_Rangecc(&path, "/"); | 69 | const size_t pos = lastIndexOfCStr_Rangecc(path, "/"); |
70 | if (pos == iInvalidPos) return path; | 70 | if (pos == iInvalidPos) return path; |
71 | return (iRangecc){ path.start, path.start + pos }; | 71 | return (iRangecc){ path.start, path.start + pos }; |
72 | } | 72 | } |
@@ -89,13 +89,13 @@ void cleanUrlPath_String(iString *d) { | |||
89 | iUrl parts; | 89 | iUrl parts; |
90 | init_Url(&parts, d); | 90 | init_Url(&parts, d); |
91 | iRangecc seg = iNullRange; | 91 | iRangecc seg = iNullRange; |
92 | while (nextSplit_Rangecc(&parts.path, "/", &seg)) { | 92 | while (nextSplit_Rangecc(parts.path, "/", &seg)) { |
93 | if (equal_Rangecc(&seg, "..")) { | 93 | if (equal_Rangecc(seg, "..")) { |
94 | /* Back up one segment. */ | 94 | /* Back up one segment. */ |
95 | iRangecc last = prevPathSeg_(constEnd_String(&clean), constBegin_String(&clean)); | 95 | iRangecc last = prevPathSeg_(constEnd_String(&clean), constBegin_String(&clean)); |
96 | truncate_Block(&clean.chars, last.start - constBegin_String(&clean)); | 96 | truncate_Block(&clean.chars, last.start - constBegin_String(&clean)); |
97 | } | 97 | } |
98 | else if (equal_Rangecc(&seg, ".")) { | 98 | else if (equal_Rangecc(seg, ".")) { |
99 | /* Skip it. */ | 99 | /* Skip it. */ |
100 | } | 100 | } |
101 | else { | 101 | else { |
@@ -103,11 +103,11 @@ void cleanUrlPath_String(iString *d) { | |||
103 | appendRange_String(&clean, seg); | 103 | appendRange_String(&clean, seg); |
104 | } | 104 | } |
105 | } | 105 | } |
106 | if (endsWith_Rangecc(&parts.path, "/")) { | 106 | if (endsWith_Rangecc(parts.path, "/")) { |
107 | appendCStr_String(&clean, "/"); | 107 | appendCStr_String(&clean, "/"); |
108 | } | 108 | } |
109 | /* Replace with the new path. */ | 109 | /* Replace with the new path. */ |
110 | if (cmpCStrNSc_Rangecc(&parts.path, cstr_String(&clean), size_String(&clean), &iCaseSensitive)) { | 110 | if (cmpCStrNSc_Rangecc(parts.path, cstr_String(&clean), size_String(&clean), &iCaseSensitive)) { |
111 | const size_t pos = parts.path.start - constBegin_String(d); | 111 | const size_t pos = parts.path.start - constBegin_String(d); |
112 | remove_Block(&d->chars, pos, size_Range(&parts.path)); | 112 | remove_Block(&d->chars, pos, size_Range(&parts.path)); |
113 | insertData_Block(&d->chars, pos, cstr_String(&clean), size_String(&clean)); | 113 | 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 | |||
132 | iUrl rel; | 132 | iUrl rel; |
133 | init_Url(&orig, d); | 133 | init_Url(&orig, d); |
134 | init_Url(&rel, urlMaybeRelative); | 134 | init_Url(&rel, urlMaybeRelative); |
135 | if (equalCase_Rangecc(&rel.protocol, "data") || equalCase_Rangecc(&rel.protocol, "about")) { | 135 | if (equalCase_Rangecc(rel.protocol, "data") || equalCase_Rangecc(rel.protocol, "about")) { |
136 | /* Special case, the contents should be left unparsed. */ | 136 | /* Special case, the contents should be left unparsed. */ |
137 | return urlMaybeRelative; | 137 | return urlMaybeRelative; |
138 | } | 138 | } |
@@ -154,11 +154,11 @@ const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelat | |||
154 | appendRange_String(absolute, selHost->port); | 154 | appendRange_String(absolute, selHost->port); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | if (isDef_(rel.protocol) || isDef_(rel.host) || startsWith_Rangecc(&rel.path, "/")) { | 157 | if (isDef_(rel.protocol) || isDef_(rel.host) || startsWith_Rangecc(rel.path, "/")) { |
158 | appendRange_String(absolute, rel.path); /* absolute path */ | 158 | appendRange_String(absolute, rel.path); /* absolute path */ |
159 | } | 159 | } |
160 | else { | 160 | else { |
161 | if (!endsWith_Rangecc(&orig.path, "/")) { | 161 | if (!endsWith_Rangecc(orig.path, "/")) { |
162 | /* Referencing a file. */ | 162 | /* Referencing a file. */ |
163 | appendRange_String(absolute, dirPath_(orig.path)); | 163 | appendRange_String(absolute, dirPath_(orig.path)); |
164 | } | 164 | } |
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 | |||
540 | const iString *mimeStr = collect_String(lower_String(&response->meta)); /* for convenience */ | 540 | const iString *mimeStr = collect_String(lower_String(&response->meta)); /* for convenience */ |
541 | iRangecc mime = range_String(mimeStr); | 541 | iRangecc mime = range_String(mimeStr); |
542 | iRangecc seg = iNullRange; | 542 | iRangecc seg = iNullRange; |
543 | while (nextSplit_Rangecc(&mime, ";", &seg)) { | 543 | while (nextSplit_Rangecc(mime, ";", &seg)) { |
544 | iRangecc param = seg; | 544 | iRangecc param = seg; |
545 | trim_Rangecc(¶m); | 545 | trim_Rangecc(¶m); |
546 | if (equal_Rangecc(¶m, "text/plain")) { | 546 | if (equal_Rangecc(param, "text/plain")) { |
547 | docFormat = plainText_GmDocumentFormat; | 547 | docFormat = plainText_GmDocumentFormat; |
548 | } | 548 | } |
549 | else if (equal_Rangecc(¶m, "text/gemini")) { | 549 | else if (equal_Rangecc(param, "text/gemini")) { |
550 | docFormat = gemini_GmDocumentFormat; | 550 | docFormat = gemini_GmDocumentFormat; |
551 | } | 551 | } |
552 | else if (startsWith_Rangecc(¶m, "image/")) { | 552 | else if (startsWith_Rangecc(param, "image/")) { |
553 | docFormat = gemini_GmDocumentFormat; | 553 | docFormat = gemini_GmDocumentFormat; |
554 | if (!d->request || isFinished_GmRequest(d->request)) { | 554 | if (!d->request || isFinished_GmRequest(d->request)) { |
555 | /* Make a simple document with an image. */ | 555 | /* Make a simple document with an image. */ |
@@ -568,7 +568,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse | |||
568 | clear_String(&str); | 568 | clear_String(&str); |
569 | } | 569 | } |
570 | } | 570 | } |
571 | else if (startsWith_Rangecc(¶m, "charset=")) { | 571 | else if (startsWith_Rangecc(param, "charset=")) { |
572 | charset = (iRangecc){ param.start + 8, param.end }; | 572 | charset = (iRangecc){ param.start + 8, param.end }; |
573 | /* Remove whitespace and quotes. */ | 573 | /* Remove whitespace and quotes. */ |
574 | trim_Rangecc(&charset); | 574 | trim_Rangecc(&charset); |
@@ -584,7 +584,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse | |||
584 | return; | 584 | return; |
585 | } | 585 | } |
586 | /* Convert the source to UTF-8 if needed. */ | 586 | /* Convert the source to UTF-8 if needed. */ |
587 | if (!equalCase_Rangecc(&charset, "utf-8")) { | 587 | if (!equalCase_Rangecc(charset, "utf-8")) { |
588 | set_String(&str, | 588 | set_String(&str, |
589 | collect_String(decode_Block(&str.chars, cstr_Rangecc(charset)))); | 589 | collect_String(decode_Block(&str.chars, cstr_Rangecc(charset)))); |
590 | } | 590 | } |
@@ -1083,7 +1083,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1083 | d->state = ready_RequestState; | 1083 | d->state = ready_RequestState; |
1084 | /* The response may be cached. */ { | 1084 | /* The response may be cached. */ { |
1085 | const iRangecc proto = urlProtocol_String(d->mod.url); | 1085 | const iRangecc proto = urlProtocol_String(d->mod.url); |
1086 | if (!equal_Rangecc(&proto, "about")) { | 1086 | if (!equal_Rangecc(proto, "about")) { |
1087 | setCachedResponse_History(d->mod.history, response_GmRequest(d->request)); | 1087 | setCachedResponse_History(d->mod.history, response_GmRequest(d->request)); |
1088 | } | 1088 | } |
1089 | } | 1089 | } |
@@ -1607,7 +1607,7 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
1607 | &str, | 1607 | &str, |
1608 | " \u2014%s%s%s\r%c%s", | 1608 | " \u2014%s%s%s\r%c%s", |
1609 | showHost ? " " : "", | 1609 | showHost ? " " : "", |
1610 | showHost ? (!equalCase_Rangecc(&parts.protocol, "gemini") | 1610 | showHost ? (!equalCase_Rangecc(parts.protocol, "gemini") |
1611 | ? format_CStr("%s://%s", | 1611 | ? format_CStr("%s://%s", |
1612 | cstr_Rangecc(parts.protocol), | 1612 | cstr_Rangecc(parts.protocol), |
1613 | cstr_Rangecc(parts.host)) | 1613 | 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) { | |||
719 | else { | 719 | else { |
720 | iUrl parts; | 720 | iUrl parts; |
721 | init_Url(&parts, &item->url); | 721 | init_Url(&parts, &item->url); |
722 | const iBool isGemini = equalCase_Rangecc(&parts.protocol, "gemini"); | 722 | const iBool isGemini = equalCase_Rangecc(parts.protocol, "gemini"); |
723 | draw_Text( | 723 | draw_Text( |
724 | font, | 724 | font, |
725 | add_I2(topLeft_Rect(itemRect), | 725 | 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) { | |||
96 | iRangecc line = iNullRange; | 96 | iRangecc line = iNullRange; |
97 | iTime now; | 97 | iTime now; |
98 | initCurrent_Time(&now); | 98 | initCurrent_Time(&now); |
99 | while (nextSplit_Rangecc(&src, "\n", &line)) { | 99 | while (nextSplit_Rangecc(src, "\n", &line)) { |
100 | int y, m, D, H, M, S; | 100 | int y, m, D, H, M, S; |
101 | sscanf(line.start, "%04d-%02d-%02dT%02d:%02d:%02d ", &y, &m, &D, &H, &M, &S); | 101 | sscanf(line.start, "%04d-%02d-%02dT%02d:%02d:%02d ", &y, &m, &D, &H, &M, &S); |
102 | if (!y) break; | 102 | if (!y) break; |