diff options
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | main.c | 8 | ||||
-rw-r--r-- | numbers.c | 9 | ||||
-rw-r--r-- | pile.c | 2 | ||||
-rw-r--r-- | polynom.c | 15 |
5 files changed, 26 insertions, 18 deletions
@@ -1,4 +1,10 @@ all: polynom -polynom: exceptions.c hash.c interface.c main.c numbers.c pile.c polynom.c scalaires.c - gcc -o polynom exceptions.c hash.c interface.c main.c numbers.c pile.c polynom.c scalaires.c -lm
\ No newline at end of file +clean: + rm -f *.o polynom + +CC=gcc +LDFLAGS=-lm +CFLAGS=-Wall -O3 + +polynom: exceptions.o hash.o parse.o main.o numbers.o pile.o polynom.o scalaires.o @@ -4,9 +4,10 @@ * */ +#include <stdio.h> #include "main.h" #include "hash.h" -#include "interface.h" +#include "parse.h" #include "polynom.h" #include "pile.h" #ifdef HAVE_CONFIG_H @@ -15,10 +16,11 @@ #define _(x) x #endif +_TableauVariable variables; +char mute; + int main(void) { - _TableauVariable variables; - char mute; Initialise(&variables); mute = 'x'; /* nom de la variable utilisee pour la saisie des polynomes, a recuperer en argv eventuellt */ @@ -72,7 +72,7 @@ int char_to_number(char *st, int *valid) } - +/* TODO: Rajouter la precision dans les valeurs retournees */ double char_to_double(char *st, int *valid) /* cette fonction tente de traduire une chaine en flottant */ { unsigned int dotnum = 0; @@ -93,9 +93,8 @@ double char_to_double(char *st, int *valid) /* cette fonction tente de traduire deci *= 10; } } - result = result / deci; - *valid = 1; - return result; - } + result = result / deci; + *valid = 1; + return result; } @@ -8,7 +8,7 @@ #include "exceptions.h" #include "numbers.h" #include "main.h" -#include "interface.h" +#include "parse.h" #ifdef HAVE_CONFIG_H #include "config.h" #else @@ -10,6 +10,8 @@ #include "main.h" #include <stdio.h> #include <math.h> +#include <stdlib.h> +#include <string.h> #ifdef HAVE_CONFIG_H #include "config.h" #else @@ -51,7 +53,7 @@ void ply_destruct(polynome poly) polynome ply_copy(polynome poly) { /* recopie */ - polynome result = NULL, temp, t; + polynome result = NULL, temp = NULL, t; while (poly) { t = ply_constr(poly->coef, poly->degre); @@ -72,7 +74,7 @@ polynome ply_copy(polynome poly) polynome ply_addition(polynome poly1, polynome poly2) { /* addition de deux polynomes */ - polynome resultat = NULL, temp, t; + polynome resultat = NULL, temp = NULL, t; rationnel newrat; int degre; @@ -131,7 +133,7 @@ polynome ply_addition(polynome poly1, polynome poly2) polynome ply_soustraction(polynome poly1, polynome poly2) { /* soustraction de deux polynomes */ - polynome resultat = NULL, temp, t; + polynome resultat = NULL, temp = NULL, t; rationnel newrat; int degre; @@ -190,7 +192,7 @@ polynome ply_soustraction(polynome poly1, polynome poly2) polynome ply_multiplication(polynome poly1, polynome poly2) { /* multiplication de deux polynomes */ - polynome temp, t, resultat = NULL; + polynome temp = NULL, t, resultat = NULL; while (poly1) { while (poly2) { @@ -261,8 +263,7 @@ double ply_valuation(polynome poly, double point) char *ply_affichage(polynome poly) { /* routine d'affichage d'un polynome */ - char buf[512], temp[32]; /* FIXME: pas glop comme routine, malloquer tout ca ? */ - char debut = 1; + char buf[BUFSIZ], temp[BUFSIZ]; /* FIXME: pas glop comme routine, malloquer tout ca ? */ while (poly) { if (poly->degre != 0) { @@ -271,6 +272,6 @@ char *ply_affichage(polynome poly) sprintf(temp, "%+f", rat_to_double(poly->coef)); } strcat(buf, temp); /* FIXME: gerer le depassement de buf si po malloc */ - return Estrdup(buf); } + return Estrdup(buf); } |