Skip to content

Commit

Permalink
update usage to common conventions for indicating args
Browse files Browse the repository at this point in the history
  • Loading branch information
alx-sch committed Oct 13, 2024
1 parent 5cf55c1 commit 595a08f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions philo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: aschenk <aschenk@student.42berlin.de> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/09/03 14:29:17 by aschenk #+# #+# #
# Updated: 2024/10/11 22:16:06 by aschenk ### ########.fr #
# Updated: 2024/10/13 18:26:58 by aschenk ### ########.fr #
# #
# **************************************************************************** #

Expand Down Expand Up @@ -107,7 +107,7 @@ $(NAME): $(OBJS)
@echo "$(GREEN) \`----'$(L_RED)(____________)"
@echo -n "$(RESET)"

@echo "\n$(BOLD)$(YELLOW)Usage: './philo nr_philo t_die t_eat t_sleep (nr_meals)'$(RESET)"
@echo "\n$(BOLD)$(YELLOW)Usage: './$(NAME) <nr_philo> <t_die> <t_eat> <t_sleep> [<nr_meals>]'$(RESET)"
@echo "$(BOLD)\n- nr_philo:$(RESET) The number of philosophers and also the number of forks."
@echo "$(BOLD)- t_die [ms]:$(RESET) If a philosopher did not start eating in 't_die' since the beginning of their last meal, they die."
@echo "$(BOLD)- t_eat [ms]:$(RESET) The time it takes for a philosopher to eat. During that time, they will need to hold two forks."
Expand Down
16 changes: 8 additions & 8 deletions philo/src/1_check_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: aschenk <aschenk@student.42berlin.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/10 16:27:51 by aschenk #+# #+# */
/* Updated: 2024/10/12 15:24:43 by aschenk ### ########.fr */
/* Updated: 2024/10/13 18:31:35 by aschenk ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -63,17 +63,17 @@ static int check_arg_count(int argc)
/**
Checks if the number of philosophers is valid (>= 1).
@param arg The first command-line argument (argv[1]) -> number of philos
@param nr_philos The first command-line argument (argv[1]) -> number of philos
@return `0` if the nr of philos is valid;
`1` if the nr of philos is < 1;
`2` if argv[1] contains no digits.
@return `0` if the nr of philos is valid;
`1` if the nr of philos is < 1;
`2` if argv[1] contains no digits.
*/
static int check_phil_nr(char *arg)
static int check_phil_nr(char *nr_philos)
{
if (contains_digit(arg))
if (contains_digit(nr_philos))
return (2);
if (ft_atoi(arg) < 1)
if (ft_atoi(nr_philos) < 1)
{
print_err_msg(ERR_ARGS_MIN_P, NULL);
print_usage();
Expand Down
6 changes: 3 additions & 3 deletions philo/src/utils/1_print_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: aschenk <aschenk@student.42berlin.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/19 22:05:49 by aschenk #+# #+# */
/* Updated: 2024/10/12 15:22:40 by aschenk ### ########.fr */
/* Updated: 2024/10/13 18:32:14 by aschenk ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -45,8 +45,8 @@ Prints the correct usage information for the program.
*/
void print_usage(void)
{
print_msg("Usage: './philo nr_philo t_die t_eat t_sleep (nr_meals)'\n",
YELLOW, 1);
print_msg("Usage: './philo <nr_philo> <t_die> <t_eat> <t_sleep> \
[<nr_meals>]'\n", YELLOW, 1);
print_msg("- nr_philo: ", BOLD, 0);
print_msg("The number of philosophers and also the number of forks.",
NULL, 1);
Expand Down

0 comments on commit 595a08f

Please sign in to comment.