aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-03-27 15:35:06 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-03-27 15:35:06 +0000
commitf63662d3301927e7b579a3512f3484cfd127ee14 (patch)
tree600b912ec982c57fe57bb6db614eec48e203446b /main.c
parent[w3m-dev 03145] header option (diff)
downloadw3m-f63662d3301927e7b579a3512f3484cfd127ee14.tar.gz
w3m-f63662d3301927e7b579a3512f3484cfd127ee14.zip
[w3m-dev 03146] Re: header option
* main.c (make_optional_header_string): cleanups From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to 'main.c')
-rw-r--r--main.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/main.c b/main.c
index 4c9dc09..e85867d 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.93 2002/03/27 15:26:09 ukai Exp $ */
+/* $Id: main.c,v 1.94 2002/03/27 15:35:06 ukai Exp $ */
#define MAINPROGRAM
#include "fm.h"
#include <signal.h>
@@ -323,21 +323,18 @@ make_optional_header_string(char *s)
char *p;
Str hs;
+ if (strchr(s, '\n') || strchr(s, '\r'))
+ return NULL;
for (p = s; *p && *p != ':'; p++) ;
if (*p != ':' || p == s)
return NULL;
- if (strchr(s, '\n')) {
- return NULL;
- }
- hs = Strnew_size(p - s);
- strncpy(hs->ptr, s, p - s);
- hs->length = p - s;
- if (!Strcasecmp_charp(hs, "content-type")) {
+ hs = Strnew_size(strlen(s) + 3);
+ Strcopy_charp_n(hs, s, p - s);
+ if (!Strcasecmp_charp(hs, "content-type"))
override_content_type = TRUE;
- }
Strcat_charp(hs, ": ");
- if (*(p + 1)) { /* not null header */
- for (p = p + 1; isspace(*p); p++) ; /* skip white spaces */
+ if (*(++p)) { /* not null header */
+ SKIP_BLANKS(p); /* skip white spaces */
Strcat_charp(hs, p);
}
Strcat_charp(hs, "\r\n");
@@ -627,9 +624,9 @@ MAIN(int argc, char **argv, char **envp)
Strcat(header_string, hs);
}
while (argv[i][0]) {
- argv[i][0] = '\0';
- argv[i]++;
- }
+ argv[i][0] = '\0';
+ argv[i]++;
+ }
}
#ifdef USE_MOUSE
else if (!strcmp("-no-mouse", argv[i])) {