Skip to content

Commit 5c08c08

Browse files
committed
Update attribute_reader
1 parent 44f5bd8 commit 5c08c08

3 files changed

Lines changed: 26 additions & 25 deletions

File tree

include/html_parser_attribute_reader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern "C" {
88
#include "html_parser_text.h"
99
#include "html_parser_attribute_list.h"
1010

11-
extern Attr_list_T attribute_reader(Text_T *tag);
11+
extern Attr_list_T Attribute_reader(Text_T *tag_chunk);
1212

1313
#ifdef __cplusplus
1414
}

src/html_parser_attribute_reader.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@
66

77
/* static function prototypes */
88
static Text_T strip(Text_T *txt);
9-
static Attr_rep_T attribute(Text_T *tag);
10-
static char *attribute_name(Text_T *tag);
11-
static char *attribute_value(Text_T *tag);
9+
static Attr_rep_T attribute(Text_T *tag_chunk);
10+
static char *attribute_name(Text_T *tag_chunk);
11+
static char *attribute_value(Text_T *tag_chunk);
1212

13-
Attr_list_T attribute_reader(Text_T *tag)
13+
Attr_list_T Attribute_reader(Text_T *tag_chunk)
1414
{
1515
Attr_list_T attr_list;
1616

1717
Fmt_register('T', Text_fmt);
1818

1919
attr_list = Attr_list_list();
20-
while (tag->len > 0)
21-
attr_list = Attr_list_enqueue(attr_list, attribute(tag));
20+
while (tag_chunk->len > 0)
21+
attr_list = Attr_list_enqueue(attr_list, attribute(tag_chunk));
2222

2323
return attr_list;
2424
}
2525

26-
static Attr_rep_T attribute(Text_T *tag)
26+
static Attr_rep_T attribute(Text_T *tag_chunk)
2727
{
2828
char *name, *value;
2929
Attr_rep_T new;
3030

31-
name = attribute_name(tag);
32-
value = attribute_value(tag);
31+
name = attribute_name(tag_chunk);
32+
value = attribute_value(tag_chunk);
3333

3434
new =Attr_rep_new(name, value);
3535

@@ -39,44 +39,45 @@ static Attr_rep_T attribute(Text_T *tag)
3939
return new;
4040
}
4141

42-
static char *attribute_name(Text_T *tag)
42+
static char *attribute_name(Text_T *tag_chunk)
4343
{
4444
int end;
4545
Text_T name;
4646

47-
end = Text_chr(*tag, 1, 0, '=');
48-
name = Text_sub(*tag, 1, end);
47+
end = Text_chr(*tag_chunk, 1, 0, '=');
48+
name = Text_sub(*tag_chunk, 1, end);
4949

5050
strip(&name);
5151

52-
/* progress tag */
53-
*tag = Text_sub(*tag, end + 1, 0);
52+
/* progress tag_chunk */
53+
*tag_chunk = Text_sub(*tag_chunk, end + 1, 0);
5454

5555
return Text_get(NULL, -1, name);
5656
}
5757

58-
static char *attribute_value(Text_T *tag)
58+
static char *attribute_value(Text_T *tag_chunk)
5959
{
6060
int start, end;
6161
Text_T value;
6262

63-
start = Text_upto(*tag, 1, 0, Text_nonwhite);
63+
start = Text_upto(*tag_chunk, 1, 0, Text_nonwhite);
6464

6565
/* Is the value enclosed by quotes? */
66-
if (Text_chr(*tag, start, start + 1, '"')) {
66+
if (Text_chr(*tag_chunk, start, start + 1, '"')) {
6767
start++;
68-
end = Text_chr(*tag, start + 1, 0, '"');
68+
end = Text_chr(*tag_chunk, start + 1, 0, '"');
6969
} else {
70-
end = Text_chr(*tag, start, 0, ' ');
70+
end = Text_chr(*tag_chunk, start, 0, ' ');
7171
}
7272

73-
value = Text_sub(*tag, start, end);
73+
value = Text_sub(*tag_chunk, start, end);
7474

75-
/* progress tag */
75+
/* progress tag_chunk */
7676
if (end == 0)
77-
*tag = Text_sub(*tag, 0, 0);
77+
*tag_chunk = Text_sub(*tag_chunk, 0, 0);
7878
else
79-
*tag = Text_sub(*tag, Text_upto(*tag, end + 1, 0, Text_nonwhite), 0);
79+
*tag_chunk = Text_sub(*tag_chunk, Text_upto(*tag_chunk, end + 1, 0,
80+
Text_nonwhite), 0);
8081

8182
return Text_get(NULL, -1, value);
8283
}

tests/html_parser_attribute_reader_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static int Test_attribute_list_reader(T t, void *s, const void *chk)
5050
Attr_list_T head = Attr_list_list();
5151
Text_T tmp = Text_put(attrs[i]);
5252

53-
head = attribute_reader(&tmp);
53+
head = Attribute_reader(&tmp);
5454

5555
lr = (char *) Attr_list_print(head);
5656

0 commit comments

Comments
 (0)