aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-04-17 02:44:22 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-04-17 02:44:22 +0000
commit21669558a0f86626f0cbcf378e652b2b4bad0c89 (patch)
treeed1507961c9d8a6dac057f107f6fe5f3bc1c9fb6
parentfix indent (diff)
downloadw3m-21669558a0f86626f0cbcf378e652b2b4bad0c89.tar.gz
w3m-21669558a0f86626f0cbcf378e652b2b4bad0c89.zip
[w3m-dev 03178] Parser of ``cols'' and ``rows''
* frame.c (parseFrameSetLength): added (newFrameSet): use parseFrameSetLength() From: Kiyokazu SUTO <suto@ks-and-ks.ne.jp>
Diffstat (limited to '')
-rw-r--r--ChangeLog8
-rw-r--r--frame.c118
2 files changed, 53 insertions, 73 deletions
diff --git a/ChangeLog b/ChangeLog
index 4f3187a..2a3d0dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2002-04-17 Kiyokazu SUTO <suto@ks-and-ks.ne.jp>
+ * [w3m-dev 03178] Parser of ``cols'' and ``rows''
+ * frame.c (parseFrameSetLength): added
+ (newFrameSet): use parseFrameSetLength()
+
+2002-04-17 Kiyokazu SUTO <suto@ks-and-ks.ne.jp>
+
* [w3m-dev 03177] SIGUSR1 --> W3M_SIGIMG in image.c
* image.c (W3M_SIGIMG): added
(load_image_handler): s/SIGUSR1/W3M_SIGIMG/
@@ -3353,4 +3359,4 @@
* release-0-2-1
* import w3m-0.2.1
-$Id: ChangeLog,v 1.371 2002/04/17 02:36:45 ukai Exp $
+$Id: ChangeLog,v 1.372 2002/04/17 02:44:22 ukai Exp $
diff --git a/frame.c b/frame.c
index 9ec9201..a3e2e51 100644
--- a/frame.c
+++ b/frame.c
@@ -1,4 +1,4 @@
-/* $Id: frame.c,v 1.14 2002/03/15 19:02:40 ukai Exp $ */
+/* $Id: frame.c,v 1.15 2002/04/17 02:44:22 ukai Exp $ */
#include "fm.h"
#include "parsetagx.h"
#include "myctype.h"
@@ -20,13 +20,52 @@ KeyAbort(SIGNAL_ARG)
LONGJMP(AbortLoading, 1);
}
+static int
+parseFrameSetLength(char *s, char ***ret)
+{
+ int i, len;
+ char *p, *q, **lv;
+
+ i = 1;
+
+ if (s)
+ for (p = s; (p = strchr(p, ',')); ++p)
+ ++i;
+ else
+ s = "*";
+
+ lv = New_N(char *, i);
+
+ for (i = 0, p = s;; ++p) {
+ SKIP_BLANKS(p);
+ len = strtoul(p, &q, 10);
+
+ switch (*q) {
+ case '%':
+ lv[i++] = Sprintf("%d%%", len)->ptr;
+ break;
+ case '*':
+ lv[i++] = "*";
+ break;
+ default:
+ lv[i++] = Sprintf("%d", len)->ptr;
+ break;
+ }
+
+ if (!(p = strchr(q, ',')))
+ break;
+ }
+
+ *ret = lv;
+ return i;
+}
+
struct frameset *
newFrameSet(struct parsed_tag *tag)
{
struct frameset *f;
int i;
- char *cols = NULL, *rows = NULL, *p, *q;
- char *length[100];
+ char *cols = NULL, *rows = NULL;
f = New(struct frameset);
f->attr = F_FRAMESET;
@@ -34,78 +73,13 @@ newFrameSet(struct parsed_tag *tag)
f->currentURL = NULL;
parsedtag_get_value(tag, ATTR_COLS, &cols);
parsedtag_get_value(tag, ATTR_ROWS, &rows);
- i = 0;
- if (cols) {
- length[i] = p = cols;
- while (*p != '\0')
- if (*p++ == ',') {
- length[++i] = p;
- if (i >= sizeof(length) / sizeof(length[0]) - 2)
- break;
- }
- length[++i] = p + 1;
- }
- if (i > 1) {
- f->col = i;
- f->width = New_N(char *, i);
- p = length[i];
- do {
- i--;
- q = p - 2;
- p = length[i];
- switch (*q) {
- Str tmp;
- case '%':
- f->width[i] = allocStr(p, q - p + 1);
- break;
- case '*':
- f->width[i] = "*";
- break;
- default:
- tmp = Sprintf("%d", atoi(p));
- f->width[i] = tmp->ptr;
- break;
- }
- } while (i);
- }
- else {
- f->col = 1;
- f->width = New_N(char *, 1);
- f->width[0] = "*";
- }
- i = 0;
- if (rows) {
- length[i] = p = rows;
- while (*p != '\0')
- if (*p++ == ',') {
- length[++i] = p;
- if (i >= sizeof(length) / sizeof(length[0]) - 2)
- break;
- }
- length[++i] = p + 1;
- }
- if (i > 1) {
- f->row = i;
- f->height = New_N(char *, i);
- p = length[i];
- do {
- i--;
- q = p - 2;
- p = length[i];
- f->height[i] = allocStr(p, q - p + 1);
- } while (i);
- }
- else {
- f->row = 1;
- f->height = New_N(char *, 1);
- f->height[0] = "*";
- }
- i = f->row * f->col;
+ f->col = parseFrameSetLength(cols, &f->width);
+ f->row = parseFrameSetLength(rows, &f->height);
f->i = 0;
+ i = f->row * f->col;
f->frame = New_N(union frameset_element, i);
do {
- i--;
- f->frame[i].element = NULL;
+ f->frame[--i].element = NULL;
} while (i);
return f;
}