commit e441bbf79edf00407f7c62d98abcf121869e46ed
parent 22f9810cf6be496bcac7b14a8fe535c6e42465d1
Author: ukai <ukai>
Date: Wed, 27 Mar 2002 15:35:06 +0000
[w3m-dev 03146] Re: header option
* main.c (make_optional_header_string): cleanups
From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
Diffstat:
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,8 @@
+2002-03-28 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
+
+ * [w3m-dev 03146] Re: header option
+ * main.c (make_optional_header_string): cleanups
+
2002-03-28 Yuuichi Teranishi <teranisi@gohome.org>
* [w3m-dev 03145] header option
diff --git a/main.c b/main.c
@@ -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])) {