Skip to content

Iz1#3

Open
paulnopaul wants to merge 51 commits intomainfrom
iz1
Open

Iz1#3
paulnopaul wants to merge 51 commits intomainfrom
iz1

Conversation

@paulnopaul
Copy link
Owner

Вариант #23
Создать структуру для хранения информации об HTML-теге: его имени, признаке «открывающий/закрывающий» и атрибутах тега. Составить с ее использованием программу, включающую в себя функцию, принимающую на вход текстовую строку с одним тегом. На выход функция должна возвращать указатель на инициализированную структуру.

Copy link
Collaborator

@IlyaSaneev IlyaSaneev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хорошая работа!

Comment on lines 1 to 4
//
// Created by Pavel Cheklin on 11/10/2020.
//

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

такие шапки лишние

{
char *name;
char *value;
} tag_attr;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

опционально: иногда для typedef struct используют постфикс _t. tag_attr_t

char *value;
} tag_attr;

bool check_attr_format(const char *str, size_t *attr_end);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

поясни сигнатуру. речь о проверке формата, но при этом есть второй аргумент.
кажется, что для проверки формата достаточно сигнатуры:
bool check_attr_format(const char* ftm);
либо проблема в дизайне, либо явно стоит указать комментарием назначение второго аргумента

Comment on lines 38 to 40



Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем столько пустых строк?

iz1/src/alg.c Outdated
int i = 0;
while (str[i] != c && str[i] != '\0')
++i;
return i; // str[i] == c ? i : -1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

закомменченнй код нужно убирать


#include <string.h>

int str_find(const char *str, char c)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проверка на nullptr

iz1/src/attr.c Outdated
Comment on lines 16 to 17
if (str[i] == ' ')
ok = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в фигурные скобки

iz1/src/attr.c Outdated
size_t eq_pos = str_find(str, '=');
bool ok = true;
if (str[eq_pos] == '\0')
ok = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сразу return false;

iz1/src/attr.c Outdated

for (int i = 0; ok && i < eq_pos; ++i)
if (str[i] == ' ')
ok = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return false;

iz1/src/attr.c Outdated
if (str[i] == ' ')
ok = false;

if (ok)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

этот иф в этом случае будет не нужен

@IlyaSaneev IlyaSaneev assigned paulnopaul and unassigned IlyaSaneev Oct 15, 2020
@paulnopaul
Copy link
Owner Author

@IlyaSaneev, все подправил

iz1/src/attr.c Outdated
Comment on lines 14 to 18
for (int i = 0; i < eq_pos; ++i)
if (str[i] == ' ')
{
return false;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тело фор в {}, а тело if - нет

#include "my_str/mem.h"
#include "my_str/alg.h"

bool check_attr_format(const char *str, size_t *attr_end)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проверка str на нуль

@IlyaSaneev IlyaSaneev removed their assignment Oct 15, 2020
@paulnopaul
Copy link
Owner Author

@IlyaSaneev, готово, добавил еще проверок на nullptr в функции с обработкой строк

@IlyaSaneev IlyaSaneev removed their assignment Oct 16, 2020
@paulnopaul paulnopaul removed their assignment Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants