rectif printf
This commit is contained in:
parent
7b690e7e4c
commit
d2d63089e2
4 changed files with 41 additions and 20 deletions
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
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(s1, s2);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
#!/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
|
||||
do
|
||||
if [ "$1" == "$cur" ]
|
||||
if [ "$1" = "$cur" ]
|
||||
then
|
||||
echo "1"
|
||||
return 1
|
||||
|
|
@ -14,7 +20,7 @@ function elem_in_array()
|
|||
return 0
|
||||
}
|
||||
|
||||
function array_in_array()
|
||||
array_in_array ()
|
||||
{
|
||||
for cur in $1
|
||||
do
|
||||
|
|
@ -29,11 +35,29 @@ function array_in_array()
|
|||
return 1
|
||||
}
|
||||
|
||||
word=$(git status -s | sed 's/.* //')
|
||||
red="\033[38;5;1m"
|
||||
gre="\033[38;5;2m"
|
||||
cya="\033[38;5;6m"
|
||||
res="\033[0m"
|
||||
confirm ()
|
||||
{
|
||||
# call with a prompt string or use a default
|
||||
echo "$cya${1:-Are you sure? [y/N]}$res"
|
||||
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
|
||||
do
|
||||
|
|
@ -52,15 +76,10 @@ do
|
|||
then
|
||||
echo "\n$cya CHANGES on $i :$res"
|
||||
echo "$diff"
|
||||
echo "$cya Are you sure?$res"
|
||||
read -r -p " [y/N]" response
|
||||
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
|
||||
confirm
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
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"
|
||||
do_checkout
|
||||
else
|
||||
echo "$cya Nothing done for $i$res\n"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ static char *do_math(char *value, char operator, char *operand)
|
|||
|
||||
ope1 = ft_atoi(value);
|
||||
ope2 = ft_atoi(operand);
|
||||
DG("value %s -> %i", value, ope1);
|
||||
DG("operand %s -> %i", operand, ope2);
|
||||
DG("value %s -> %li", value, ope1);
|
||||
DG("operand %s -> %li", operand, ope2);
|
||||
if ((operator == '/') && ope2 == 0)
|
||||
return (SH_ERR(MATHERR_4) ? NULL : NULL);
|
||||
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;
|
||||
DG("output=%s (%i)", ft_itoa(ope1), ope1);
|
||||
DG("output=%s (%li)", ft_itoa(ope1), ope1);
|
||||
return (ft_itoa(ope1));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ t_lexstate get_state_global(t_lexer *lexer)
|
|||
|| (((c == '{' && cn == ' ') || (c == '}' && cl == ' '))
|
||||
&& (ret = CURLY_BRACKETS))
|
||||
|| ((c == 0) && (ret = END)))
|
||||
{
|
||||
;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue