42School / norminette

Official 42 norminette
MIT License
972 stars 141 forks source link

[LINE_TOO_LONG] no error reporting on 81 columns wide line #289

Closed mjy9088 closed 1 year ago

mjy9088 commented 2 years ago

Describe the bug no error reporting on 81 column wide line in multiline comment (works fine on 82+ columns, or single line comment)

Erroneous code

/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   fake_file_name (file name is useless too)          :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: 42header-remover <whatever@example.com>    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 1970/01/01 00:00:00 by Git handles       #+#    #+#             */
/*   Updated: 1970/01/01 00:00:00 by file history     ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

/*
 * This line is longer than 80 columns wide, so it will considered as norm error!
 */
int main(int argc, char **argv)
{
    return (argv[argc - argc]);
}

Additional infos

mjy9088 commented 2 years ago

there's 3 lines with 80+ column wide, but only 1 line was caught

/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ps_stream_print.c                                  :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: Juyeong Maing <jmaing@student.42seoul.kr>  +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2022/07/18 00:15:55 by Juyeong Maing     #+#    #+#             */
/*   Updated: 2022/07/20 20:36:36 by Juyeong Maing    ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "ps_stream.h"

#include <stdlib.h>

#include "ft_io.h"
#include "ft_primitive_const_pointer.h"

static t_err    ps_stream_print_separator(
    t_ps_stream_node_separator *node,
    int fd
)
{
    size_t  i;

    i = -1;
    while (++i < node->pa)
        if (ft_puts(fd, "pa\n"))
            return (true);
    i = -1;
    while (++i < node->pb)
        if (ft_puts(fd, "pb\n"))
            return (true);
    return (false);
}

static t_err    ps_stream_print_parallel_list(
    t_ps_stream_node_parallel_list *list,
    int fd,
    bool b
)
{
    t_ps_stream_node_parallel_list_node *current;
    size_t                              i;

    current = list->head;
    while (current)
    {
        i = -1;
        if (current->type == PS_STREAM_NODE_PARALLEL_OPERATION_SWAP)
            while (++i < current->count)
                if (ft_puts(fd, ft_primitive_const_pointer_if(b, "sb\n", "sa\n")))
                    return (true);
        if (current->type == PS_STREAM_NODE_PARALLEL_OPERATION_ROTATE)
            while (++i < current->count)
                if (ft_puts(fd, ft_primitive_const_pointer_if(b, "rb\n", "ra\n")))
                    return (true);
        if (current->type == PS_STREAM_NODE_PARALLEL_OPERATION_REVERSE_ROTATE)
            while (++i < current->count)
                if (ft_puts(fd, ft_primitive_const_pointer_if(b, "rrb\n", "rra\n")))
                    return (true);
        current = current->next;
    }
    return (false);
}

static t_err    ps_stream_print_node(
    t_ps_stream_node *node,
    int fd
)
{
    return (
        (
            *node->value.type == PS_STREAM_NODE_TYPE_SEPARATOR
            && (ps_stream_print_separator(node->value.separator, fd))
        )
        || (
            *node->value.type == PS_STREAM_NODE_TYPE_PARALLEL
            && (
                ps_stream_print_parallel_list(
                    &node->value.parallel->a,
                    fd,
                    false
                )
                || ps_stream_print_parallel_list(
                    &node->value.parallel->b,
                    fd,
                    true
                )
            )
        )
    );
}

t_err   ps_stream_print(
    t_ps_stream *self,
    int fd
)
{
    t_ps_stream_node    *current;

    current = self->head;
    while (current)
    {
        if (ps_stream_print_node(current, fd))
            return (true);
        current = current->next;
    }
    return (false);
}
matthieu42Network commented 1 year ago

duplicate #283