Skip to content

Commit

Permalink
Merge Fix #19
Browse files Browse the repository at this point in the history
  • Loading branch information
rizky committed Apr 24, 2018
2 parents dce0945 + afe7e5b commit b0b34cc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/ft_vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: rnugroho <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/19 21:39:11 by rnugroho #+# #+# */
/* Updated: 2018/04/24 23:14:52 by rnugroho ### ########.fr */
/* Updated: 2018/04/25 00:49:42 by rnugroho ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -111,6 +111,7 @@ void vm_and_print(t_process p);
void vm_live_print(t_process p);
void vm_zjump_print(t_process p);

int vm_valid_arg(char *arg);
int vm_valid_verbosity_lvl(int lvl);
int vm_lvl_to_index(int index);
int ft_isnumber(char *str);
Expand Down
17 changes: 16 additions & 1 deletion src/ft_vm/vm_helper_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,27 @@
/* By: rnugroho <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/20 14:58:02 by fpetras #+# #+# */
/* Updated: 2018/04/24 17:21:17 by rnugroho ### ########.fr */
/* Updated: 2018/04/24 22:43:11 by fpetras ### ########.fr */
/* */
/* ************************************************************************** */

#include "ft_vm.h"

int vm_valid_arg(char *arg)
{
if (!ft_strcmp(arg, "-dump") || !ft_strcmp(arg, "-v") || !ft_strcmp(arg, "-n"))
return (1);
else if ((!ft_strncmp(arg, "-v", 2) || !ft_strncmp(arg, "-n", 2)) &&
ft_isnumber(&arg[2]))
return (1);
else if (ft_isnumber(arg))
return (1);
else if (!ft_strcmp(&arg[ft_strlen(arg) - 4], ".cor"))
return (1);
else
return (0);
}

int vm_valid_verbosity_lvl(int v)
{
return (v == 0 || v == 1 || v == 2 || v == 4 || v == 8 || v == 16);
Expand Down
4 changes: 3 additions & 1 deletion src/ft_vm/vm_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: rnugroho <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/20 15:11:44 by fpetras #+# #+# */
/* Updated: 2018/04/25 00:46:54 by rnugroho ### ########.fr */
/* Updated: 2018/04/25 00:50:04 by rnugroho ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -129,6 +129,8 @@ int vm_options(char **av, t_vm *vm)
return (-1);
else if (vm_option_v(i, av, vm) == -1)
return (-1);
if (!vm_valid_arg(av[i]))
return (-1);
}
return (0);
}

0 comments on commit b0b34cc

Please sign in to comment.