rectif printf

This commit is contained in:
william 2017-03-23 16:41:53 +01:00
parent 7b690e7e4c
commit d2d63089e2
4 changed files with 41 additions and 20 deletions

View file

@ -14,7 +14,7 @@
char *ft_strcatf(char *s1, const char *s2) char *ft_strcatf(char *s1, const char *s2)
{ {
char buf[ft_strlen(s2)]; char buf[ft_strlen(s1) + 1];
ft_strcpy(buf, s1); ft_strcpy(buf, s1);
ft_strcpy(s1, s2); ft_strcpy(s1, s2);

View file

@ -1,10 +1,16 @@
#!/bin/sh #!/bin/sh
function elem_in_array() word=$(git status -s | sed 's/.* //')
red="\033[38;5;1m"
gre="\033[38;5;2m"
cya="\033[38;5;6m"
res="\033[0m"
elem_in_array ()
{ {
for cur in $2 for cur in $2
do do
if [ "$1" == "$cur" ] if [ "$1" = "$cur" ]
then then
echo "1" echo "1"
return 1 return 1
@ -14,7 +20,7 @@ function elem_in_array()
return 0 return 0
} }
function array_in_array() array_in_array ()
{ {
for cur in $1 for cur in $1
do do
@ -29,11 +35,29 @@ function array_in_array()
return 1 return 1
} }
word=$(git status -s | sed 's/.* //') confirm ()
red="\033[38;5;1m" {
gre="\033[38;5;2m" # call with a prompt string or use a default
cya="\033[38;5;6m" echo "$cya${1:-Are you sure? [y/N]}$res"
res="\033[0m" read -r -p " " response
case "$response" in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
do_checkout ()
{
i_tmp=$(echo $i | sed 's/\//_/g')
cp $i "$HOME/Documents/.$i_tmp.back"
git checkout $i
echo "$gre D - O - N - E $res"
echo "$cya $i was checked out. A copy still exist in $HOME/Documents/.$i_tmp.back$res\n"
}
for i in $word for i in $word
do do
@ -52,15 +76,10 @@ do
then then
echo "\n$cya CHANGES on $i :$res" echo "\n$cya CHANGES on $i :$res"
echo "$diff" echo "$diff"
echo "$cya Are you sure?$res" confirm
read -r -p " [y/N]" response if [ $? -eq 0 ]
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then then
i_tmp=$(echo $i | sed 's/\//_/g') do_checkout
cp $i "$HOME/Documents/.$i_tmp.back"
git checkout $i
echo "$gre D - O - N - E $res"
echo "$cya $i was checked out. A copy still exist in $HOME/Documents/.$i_tmp.back$res\n"
else else
echo "$cya Nothing done for $i$res\n" echo "$cya Nothing done for $i$res\n"
fi fi

View file

@ -25,8 +25,8 @@ static char *do_math(char *value, char operator, char *operand)
ope1 = ft_atoi(value); ope1 = ft_atoi(value);
ope2 = ft_atoi(operand); ope2 = ft_atoi(operand);
DG("value %s -> %i", value, ope1); DG("value %s -> %li", value, ope1);
DG("operand %s -> %i", operand, ope2); DG("operand %s -> %li", operand, ope2);
if ((operator == '/') && ope2 == 0) if ((operator == '/') && ope2 == 0)
return (SH_ERR(MATHERR_4) ? NULL : NULL); return (SH_ERR(MATHERR_4) ? NULL : NULL);
if ((operator == '%') && ope2 == 0) if ((operator == '%') && ope2 == 0)
@ -36,7 +36,7 @@ static char *do_math(char *value, char operator, char *operand)
ope1 = (operator == '/') ? ope1 / ope2 : ope1; ope1 = (operator == '/') ? ope1 / ope2 : ope1;
ope1 = (operator == '*') ? ope1 * ope2 : ope1; ope1 = (operator == '*') ? ope1 * ope2 : ope1;
ope1 = (operator == '%') ? ope1 % ope2 : ope1; ope1 = (operator == '%') ? ope1 % ope2 : ope1;
DG("output=%s (%i)", ft_itoa(ope1), ope1); DG("output=%s (%li)", ft_itoa(ope1), ope1);
return (ft_itoa(ope1)); return (ft_itoa(ope1));
} }

View file

@ -34,6 +34,8 @@ t_lexstate get_state_global(t_lexer *lexer)
|| (((c == '{' && cn == ' ') || (c == '}' && cl == ' ')) || (((c == '{' && cn == ' ') || (c == '}' && cl == ' '))
&& (ret = CURLY_BRACKETS)) && (ret = CURLY_BRACKETS))
|| ((c == 0) && (ret = END))) || ((c == 0) && (ret = END)))
{
; ;
}
return (ret); return (ret);
} }