22 Commits 1374d7ec0e ... 2208034818

Author SHA1 Message Date
  Moul 2208034818 [mod] update delivery procedure. 2 years ago
  Moul 9e4dedcdef [enh] add script which add 42 headers and clean the repo for delivery. 2 years ago
  Moul 45cdb210f9 [norm] remove itoa_base which is now on 'itoa_base' branch. 2 years ago
  Moul f25ce931d1 [norm] remove itoa_base which is now on 'itoa_base' branch. 2 years ago
  Moul f7d8d3749c [fix] libft: tabdel: prevent segfault if tab null. 2 years ago
  Moul 3071439e11 [enh] libft: better handling. 2 years ago
  Moul c210383567 [fix] strsplit: double malloc: mleaks. 2 years ago
  Moul cfe3b5f62e [enh] strjoinf: rework: 2 years ago
  Moul 79d632d882 [mod] libft: add '-g' option at compilation. 2 years ago
  Moul 1dfe3783f9 [fix] correct compilation errors. 2 years ago
  Moul 4726ff2de8 [enh] free memory for 'pwd' call. 2 years ago
  Moul 636a7d6c81 [enh] strjoinf: free two strings at char insertion. 2 years ago
  Moul 0872d413d3 [enh] libft: add tabdel f(). free env. 2 years ago
  Moul b8c1c97136 [fix] libft: strsub: fix return value type. 2 years ago
  Moul e5eafe5c5c [enh] new f() to free str when asigning on same var. 2 years ago
  Moul c266f19b38 [fix] libft: ft_strtrim: do not malloc return value. 2 years ago
  Moul 185a274a15 [enh] libft: ft_(d)printf: handle char, use else if. 3 years ago
  Moul 923c42fb47 [enh] env: if good format is not respected display the error message… 3 years ago
  Moul 5e1c546d47 [enh] libft: add function which search pos of a char in a string. 3 years ago
  Moul d38eebacbf [fix] libft: ft_str(n)cmp: check string are not NULL to avoid segfault. 3 years ago
  Moul 86832ab06c [norm] minor fixes: 3 years ago
  Moul 30e9061459 [mod] remove execution rights on files. 3 years ago
6 changed files with 116 additions and 113 deletions
  1. 60 0
      deliver.sh
  2. 2 4
      doc/TODO.md
  3. 0 1
      libft/Makefile
  4. 0 1
      libft/libft.h
  5. 54 61
      libft/src/ft_itoa.c
  6. 0 46
      libft/src/ft_itoa_base.c

+ 60 - 0
deliver.sh

@@ -0,0 +1,60 @@
+#!/bin/zsh
+
+makefile_header="# **************************************************************************** #
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: mazimi <mazimi@student.42.fr>              +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2017/03/04 15:35:21 by mazimi            #+#    #+#              #
+#    Updated: 2017/03/04 15:35:21 by mazimi           ###   ########.fr        #
+#                                                                              #
+# **************************************************************************** #\n"       
+
+c_header="/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   file.c                                             :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: mazimi <mazimi@student.42.fr>              +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/03/04 15:35:21 by mazimi            #+#    #+#             */
+/*   Updated: 2017/03/04 15:35:21 by mazimi           ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */\n" 
+
+# Add 42 headers on top of source files
+add_42_headers() {
+    for file in "src"/*; do
+        add_42_header "$file"
+    done
+    add_42_header "Makefile"
+    git st
+    git diff
+    git add src Makefile
+    git commit -m "[mod] add 42 headers on top of files."
+}
+
+add_42_header() {
+    src_file=$1
+    tmp="/tmp/42_header"
+    if [ $src_file = "Makefile" ]; then
+        echo $makefile_header > $tmp
+    else
+        echo $c_header > $tmp
+    fi
+    cat $src_file >> $tmp
+    mv $tmp $src_file
+}
+
+clean_repository() {
+    make fclean
+    git rm -rf doc non_use_src leaks.sh deliver.sh
+    rm -f toto
+    git commit -m "[mod] remove non used elements."
+}
+
+git checkout -b deliver
+add_42_headers
+clean_repository

+ 2 - 4
doc/TODO.md

@@ -90,8 +90,6 @@ X [x] Placer, par ordre d’exécution, les pipes avant les redirections.
 - [x] gérer le remplacement des variables d’environnement: 'echo $HOME'
 
 ### Rendu
-- [ ] Dépôt git de la Vogosphère
-- [ ] Shell: ajout des en-têtes
-- [ ] Libft: retrait ft_itoa_base, retrait des commentaires de ft_itoa
+- [ ] lancer ./deliver.sh
 - [ ] Norminette manuelle
-- [ ] Retrait dossiers 'doc' et 'non_use_src'
+- [ ] Dépôt git de la Vogosphère

+ 0 - 1
libft/Makefile

@@ -63,7 +63,6 @@ ft_strsplit.c \
 ft_tabsize.c \
 ft_tabdel.c \
 ft_itoa.c \
-ft_itoa_base.c \
 ft_strtrim.c \
 ft_putchar.c \
 ft_putstr.c \

+ 0 - 1
libft/libft.h

@@ -79,7 +79,6 @@ char				**ft_strsplit(char const *s, char c);
 int					ft_tabsize(char **tab);
 void				ft_tabdel(char **tabe);
 char				*ft_itoa(int n);
-char				*ft_itoa_base(int value, int base);
 void				ft_putchar(char c);
 void				ft_putstr(char const *s);
 void				ft_putendl(char const *s);

+ 54 - 61
libft/src/ft_itoa.c

@@ -12,67 +12,60 @@
 
 #include "../libft.h"
 
-char	*ft_itoa(int c)
+static char		*ft_turn(char *src, int lon)
 {
-	return (ft_itoa_base(c, 10));
+	char	*dest;
+	int		i;
+	int		j;
+
+	dest = ft_strnew(lon);
+	j = lon;
+	i = -1;
+	while (++i < lon)
+		dest[i] = src[--j];
+	return (dest);
+}
+
+static int		intlen(int c)
+{
+	int		i;
+	int		lon;
+
+	i = 1;
+	if (c < 0)
+		i++;
+	lon = c;
+	while (lon >= 10 || lon <= -10)
+	{
+		lon = lon / 10;
+		i++;
+	}
+	return (i);
 }
 
-/*
-**static char		*ft_turn(char *src, int lon)
-**{
-**	char	*dest;
-**	int		i;
-**	int		j;
-**
-**	dest = ft_strnew(lon);
-**	j = lon;
-**	i = -1;
-**	while (++i < lon)
-**		dest[i] = src[--j];
-**	return (dest);
-**}
-**
-**static int		intlen(int c)
-**{
-**	int		i;
-**	int		lon;
-**
-**	i = 1;
-**	if (c < 0)
-**		i++;
-**	lon = c;
-**	while (lon >= 10 || lon <= -10)
-**	{
-**		lon = lon / 10;
-**		i++;
-**	}
-**	return (i);
-**}
-**
-**char			*ft_itoa(int c)
-**{
-**	int		lon;
-**	char	*str;
-**	char	*dst;
-**	int		cc;
-**	int		i;
-**
-**	if (c == -2147483648)
-**		return (ft_strdup("-2147483648"));
-**	cc = c;
-**	lon = intlen(c);
-**	str = ft_strnew(lon);
-**	if (c < 0)
-**		c = -c;
-**	i = -1;
-**	while (++i < lon)
-**	{
-**		str[i] = (c % 10) + 48;
-**		c = c / 10;
-**	}
-**	if (cc < 0)
-**		str[i - 1] = '-';
-**	dst = ft_turn(str, lon);
-**	return (dst);
-**}
-*/
+char			*ft_itoa(int c)
+{
+	int		lon;
+	char	*str;
+	char	*dst;
+	int		cc;
+	int		i;
+
+	if (c == -2147483648)
+		return (ft_strdup("-2147483648"));
+	cc = c;
+	lon = intlen(c);
+	str = ft_strnew(lon);
+	if (c < 0)
+		c = -c;
+	i = -1;
+	while (++i < lon)
+	{
+		str[i] = (c % 10) + 48;
+		c = c / 10;
+	}
+	if (cc < 0)
+		str[i - 1] = '-';
+	dst = ft_turn(str, lon);
+	return (dst);
+}

+ 0 - 46
libft/src/ft_itoa_base.c

@@ -1,46 +0,0 @@
-/* ************************************************************************** */
-/*                                                                            */
-/*                                                        :::      ::::::::   */
-/*   ft_itoa_base.c                                     :+:      :+:    :+:   */
-/*                                                    +:+ +:+         +:+     */
-/*   By: mazimi <marvin@42.fr>                      +#+  +:+       +#+        */
-/*                                                +#+#+#+#+#+   +#+           */
-/*   Created: 2015/12/17 15:24:28 by mazimi            #+#    #+#             */
-/*   Updated: 2015/12/17 15:56:31 by mazimi           ###   ########.fr       */
-/*                                                                            */
-/* ************************************************************************** */
-
-#include "../libft.h"
-
-char	*ft_itoa_base(int value, int base)
-{
-	char	*str;
-	int		mult;
-	int		len;
-	int		i;
-	long	nbr;
-	char	c;
-
-	nbr = value;
-	mult = 1;
-	len = 1;
-	while (nbr / mult >= base || nbr / mult <= -base)
-	{
-		mult = mult * base;
-		len++;
-	}
-	len = (nbr < 0) ? len + 1 : len;
-	str = ft_strnew(len);
-	str[0] = '-';
-	i = (nbr < 0) ? 0 : -1;
-	nbr = (nbr < 0) ? -nbr : nbr;
-	while (++i < len)
-	{
-		c = nbr / mult;
-		str[i] = (0 <= c && c <= 9) ? c + 48 : c + 55;
-		nbr = nbr - c * mult;
-		mult = mult / base;
-	}
-	str[i] = '\0';
-	return (str);
-}