summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2014-04-09 00:00:13 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2014-04-09 00:00:13 +0200
commit87f6ee55fc14327321e9d606ac9683c112fefaa9 (patch)
tree48b13ff430fa710e9a6417ed7173439643bf389e /util.c
parentb8b24fe4131e7e7fb46eb330b14ce340844b601a (diff)
cleanup, remove javascript hotkey
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
Diffstat (limited to 'util.c')
-rw-r--r--util.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/util.c b/util.c
index ceb6478..b501cd0 100644
--- a/util.c
+++ b/util.c
@@ -72,15 +72,17 @@ afgets(char **p, size_t *size, FILE *fp) {
return NULL;
}
-void /* print link; if link is relative use baseurl to make it absolute */
+/* print link; if link is relative use baseurl to make it absolute */
+void
printlink(const char *link, const char *baseurl, FILE *fp) {
const char *ebaseproto, *ebasedomain, *p;
int isrelative;
/* protocol part */
for(p = link; *p && (isalpha((int)*p) || isdigit((int)*p) || *p == '+' || *p == '-' || *p == '.'); p++);
+ /* relative link (baseurl is used). */
isrelative = strncmp(p, "://", strlen("://"));
- if(isrelative) { /* relative link (baseurl is used). */
+ if(isrelative) {
if((ebaseproto = strstr(baseurl, "://"))) {
ebaseproto += strlen("://");
fwrite(baseurl, 1, ebaseproto - baseurl, fp);
@@ -92,13 +94,15 @@ printlink(const char *link, const char *baseurl, FILE *fp) {
if(link[0] == '/') { /* relative to baseurl domain (not path). */
if(link[1] == '/') /* absolute url but with protocol from baseurl. */
link += 2;
- else if((ebasedomain = strchr(ebaseproto, '/'))) /* relative to baseurl and baseurl path. */
+ else if((ebasedomain = strchr(ebaseproto, '/')))
+ /* relative to baseurl and baseurl path. */
fwrite(ebaseproto, 1, ebasedomain - ebaseproto, fp);
else
fputs(ebaseproto, stdout);
- } else if((ebasedomain = strrchr(ebaseproto, '/'))) /* relative to baseurl and baseurl path. */
+ } else if((ebasedomain = strrchr(ebaseproto, '/'))) {
+ /* relative to baseurl and baseurl path. */
fwrite(ebaseproto, 1, ebasedomain - ebaseproto + 1, fp);
- else {
+ } else {
fputs(ebaseproto, fp);
if(*baseurl && *link)
fputc('/', fp);
@@ -108,13 +112,15 @@ printlink(const char *link, const char *baseurl, FILE *fp) {
}
unsigned int
-parseline(char **line, size_t *size, char **fields, unsigned int maxfields, int separator, FILE *fp) {
+parseline(char **line, size_t *size, char **fields,
+ unsigned int maxfields, int separator, FILE *fp)
+{
unsigned int i = 0;
char *prev, *s;
if(afgets(line, size, fp)) {
for(prev = *line; (s = strchr(prev, separator)) && i <= maxfields; i++) {
- *s = '\0'; /* null terminate string. */
+ *s = '\0';
fields[i] = prev;
prev = s + 1;
}