Index: pobysoC-4.0/src/pobyso.c
===================================================================
--- pobysoC-4.0/src/pobyso.c	(revision 135)
+++ pobysoC-4.0/src/pobyso.c	(revision 136)
@@ -136,7 +136,7 @@
 {
   int expressionLength, i;
   char *expressionWithSemiCo;
-  sollya_obj_t expressionSa;
+  sollya_obj_t expressionSo;
 
   /* Arguments check. */
   if (expression == NULL)
@@ -166,8 +166,16 @@
     if (expression[i] == ';') /* Nothing special to do:
                                  try to parse the string*/
     {
-      expressionSa = sollya_lib_parse_string(expression);
-      return expressionSa;
+      expressionSo = sollya_lib_parse_string(expression);
+      if (sollya_lib_obj_is_error(expressionSo))
+      {
+        sollya_lib_clear_obj(expressionSo);
+        return NULL;
+      }
+      else
+      {
+        return expressionSo;
+      }
     }
     else
     {
@@ -191,9 +199,17 @@
         strncpy(expressionWithSemiCo, expression, i+1);
         expressionWithSemiCo[i + 1] = ';';
         expressionWithSemiCo[i + 2] = '\0';
-        expressionSa = sollya_lib_parse_string(expressionWithSemiCo);
+        expressionSo = sollya_lib_parse_string(expressionWithSemiCo);
         free(expressionWithSemiCo);
-        return expressionSa;
+        if (sollya_lib_obj_is_error(expressionSo))
+        {
+          sollya_lib_clear_obj(expressionSo);
+          return NULL;
+        }
+        else
+        {
+          return expressionSo;
+        }
       } /* End character != ';' and from a blank. */
     /* Create a new string for the expression, add the ";" and
      * and call sollya_lib_parse_string. */
@@ -206,7 +222,6 @@
                        "ONLY_BLANK_ARGUMENT",
                         "The expression is only made of blanks");
   return NULL;
-
 } /* pobyso_parse_string */
 
 pobyso_func_exp_t
@@ -295,56 +310,58 @@
  * @see pobyso.h#pobyso_subpoly
  */
 pobyso_func_exp_t
-pobyso_subpoly(pobyso_func_exp_t polynomialSo, long expsNum,...)
+pobyso_subpoly(pobyso_func_exp_t polynomialSo, long expsNum, long int* expsList)
 {
-  sollya_obj_t expsListSo = NULL;
-  sollya_obj_t* expsList  = NULL;
-  sollya_obj_t subpoly    = NULL;
+  sollya_obj_t  expsListSo    = NULL;
+  sollya_obj_t* expsList_pso  = NULL;
+  sollya_obj_t subpoly        = NULL;
+  int i, j;
 
-  va_list vaExpsList;
-  int currentExp;
-  int i;
-
   /* Arguments check. */
   if (polynomialSo == NULL) return NULL;
   if (expsNum < 0) return NULL;
   if (expsNum == 0) return sollya_lib_copy_obj(polynomialSo);
-
-  va_start(vaExpsList, expsNum);
-  expsList = (sollya_obj_t*) malloc(expsNum * sizeof(sollya_obj_t));
-  if (expsList == NULL)
+  if (expsList == 0) return NULL;
+  /* Create a list of Sollya constants. */
+  expsList_pso = (sollya_obj_t*) malloc(expsNum * sizeof(sollya_obj_t));
+  if (expsList_pso == NULL)
   {
     pobyso_error_message("pobyso_subpoly",
                           "MEMORY_ALLOCATION_ERROR",
-                          "Could not allocate the expression string");
+                          "Could not allocate the Sollya exponents list");
     return NULL;
   }
+  /* Fill up the list. */
   for (i = 0 ; i < expsNum ; i++)
   {
-    currentExp = va_arg(vaExpsList, long);
-    expsList[i] = sollya_lib_constant_from_int64(currentExp);
+    /* Abort if an exponent is negative. */
+    if (expsList[i] < 0 )
+    {
+      for (j = 0 ; j < i ; j++)
+      {
+        sollya_lib_clear_obj(expsList_pso[j]);
+      }
+      free(expsList_pso);
+      return NULL;
+    }
+    expsList_pso[i] = sollya_lib_constant_from_int64(expsList[i]);
   } /* End for */
-  va_end(vaExpsList);
-  expsListSo = sollya_lib_list(expsList, expsNum);
-  if (expsList == NULL)
+  expsListSo = sollya_lib_list(expsList_pso, expsNum);
+  for (i = 0 ; i < expsNum ; i++)
   {
+    sollya_lib_clear_obj(expsList_pso[i]);
+  }
+  free(expsList_pso);
+  if (expsListSo == NULL)
+  {
     pobyso_error_message("pobyso_subpoly",
                           "LIST_CREATIONERROR",
                           "Could not create the exponents list");
-    for (i = 0 ; i < expsNum ; i++)
-    {
-      sollya_lib_clear_obj(expsList[i]);
-    }
-    free(expsList);
     return NULL;
   }
   subpoly = sollya_lib_subpoly(polynomialSo, expsListSo);
+  pobyso_autoprint(expsListSo);
   sollya_lib_clear_obj(expsListSo);
-  for (i = 0 ; i < expsNum ; i++)
-  {
-    sollya_lib_clear_obj(expsList[i]);
-  }
-  free(expsList);
   return subpoly;
 } /* pobyso_subpoly. */
 
Index: pobysoC-4.0/src/test-pobyso-subpoly.sh
===================================================================
--- pobysoC-4.0/src/test-pobyso-subpoly.sh	(revision 0)
+++ pobysoC-4.0/src/test-pobyso-subpoly.sh	(revision 136)
@@ -0,0 +1,28 @@
+#! /bin/sh
+#
+#
+TEST_BIN=./test-pobyso-subpoly
+
+echo
+
+bla() {
+  echo "$@"
+  eval "$TEST_BIN $ARGUMENTS"
+if [ $? -ne 0 ] ; then echo "Failed for $ARGUMENTS" ; exit 1 ; fi
+echo
+}
+##
+ARGUMENTS="\"4*x^2\" 2"
+bla "Testing: $ARGUMENTS"
+
+##
+ARGUMENTS="\"4-2*x+4*x^2\" 0 2"
+bla "Testing: $ARGUMENTS"
+
+##
+ARGUMENTS="\"4-2*x+4*x^2\" 0 -1 2"
+bla "Testing: $ARGUMENTS"
+
+##
+echo "Tests terminated without error."
+echo

Property changes on: pobysoC-4.0/src/test-pobyso-subpoly.sh
___________________________________________________________________
Added: svn:executable
   + *

Index: pobysoC-4.0/src/Makefile
===================================================================
--- pobysoC-4.0/src/Makefile	(revision 135)
+++ pobysoC-4.0/src/Makefile	(revision 136)
@@ -14,7 +14,8 @@
 
 ALL_TARGETS = test-pobyso-01 test-pobyso-02 \
               test-pobyso-constant-expression \
-              test-pobyso-new-monomial
+              test-pobyso-new-monomial \
+              test-pobyso-subpoly
 
 SCRATCH_PRG := $(patsubst %.c,%,$(wildcard *.c))
 SCRATCH_ALL := $(SCRATCH_PRG)

Property changes on: pobysoC-4.0/src/test-pobyso-constant-expression.c
___________________________________________________________________
Deleted: svn:mime-type
   - text/plain

Index: pobysoC-4.0/src/pobyso.h
===================================================================
--- pobysoC-4.0/src/pobyso.h	(revision 135)
+++ pobysoC-4.0/src/pobyso.h	(revision 136)
@@ -26,7 +26,6 @@
 typedef sollya_obj_t pobyso_on_off_t;
 typedef sollya_obj_t pobyso_precision_t;
 typedef sollya_obj_t pobyso_range_t;
-typedef sollya_obj_t pobyso_sollya_verbosity_t;
 
 #define POBYSO_ABSOLUTE (1)
 #define POBYSO_RELATIVE (2)
@@ -52,7 +51,7 @@
 {return(sollya_lib_obj_is_function(functionCandidate));}
 
 /**
- * Print object(s) to stdout.
+ * Print an object to stdout.
  * A very thin wrapper around the lib_sollya_autoprint() function.
  */
 void
@@ -162,7 +161,7 @@
  */
 
 pobyso_func_exp_t
-pobyso_subpoly(pobyso_func_exp_t polynomial, long expsNum,...);
+pobyso_subpoly(pobyso_func_exp_t polynomial, long expsNum, long* expsList);
 
 #if 0
 /**
Index: pobysoC-4.0/src/test-pobyso-subpoly.c
===================================================================
--- pobysoC-4.0/src/test-pobyso-subpoly.c	(revision 0)
+++ pobysoC-4.0/src/test-pobyso-subpoly.c	(revision 136)
@@ -0,0 +1,135 @@
+/** @file test-pobyso-subpoly.c
+ * Name & purpose
+ *
+ * @author
+ * @date
+ *
+ * @details Verbosity manipulation are performed  to make sur  that verbosity
+ *  suppression is correctly managed in pobyso_is_constant_expression()
+ *  function.
+ */
+/******************************************************************************/
+/* Headers, applying the "particular to general" convention.*/
+
+#include "pobyso.h"
+
+/* includes of local headers */
+
+/* includes of project headers */
+
+/* includes of system headers */
+#include <stdlib.h>
+/* Other declarations */
+
+/* Internal prototypes */
+long int
+read_long_decimal(long int* value, char* string);
+long int
+read_unsigned_long_decimal(long int* value, char* string);
+
+/* Types, constants and macros definitions */
+
+/* Global variables */
+
+/* Functions */
+long int
+read_long_decimal(long int* returnValue, char* string)
+{
+  char* endptr[1];
+  long int convertedValue = 0;
+
+  convertedValue = strtoul(string, endptr, 10);
+  /* For a completely safe conversion *endptr must point to 0 value char. */
+  if (**endptr != '\0')
+  {
+    return 1;
+  }
+  else
+  {
+    *returnValue = convertedValue;
+    return 0;
+  }
+  return 0;
+} /* End read_long_decimal. */
+
+long int
+read_unsigned_long_decimal(long int* returnValue, char* string)
+{
+  char* endptr[1];
+  long int convertedValue = 0;
+
+  /* Negative sign -> failure. */
+  if (*string == '-')
+  {
+    return 1;
+  }
+  convertedValue = strtoul(string, endptr, 10);
+  /* For a completely safe conversion *endptr must point to 0 value char. */
+  if (**endptr != '\0')
+  {
+    return 1;
+  }
+  else
+  {
+    *returnValue = convertedValue;
+    return 0;
+  }
+  return 0;
+} /* End read_unsigned_long_decimal. */
+
+int
+main(int argc, char** argv)
+{
+  long int* expsArray   = NULL;
+  int i;
+  pobyso_func_exp_t polynomial;
+  pobyso_func_exp_t subpoly;
+
+  if (argc < 3)
+  {
+    fprintf(stderr,
+            "Usage: %s polynomialAsString power1 [power2 [...[powern]..]\n",
+            argv[0]);
+    return 1;
+  }
+
+  pobyso_set_canonical_on();
+  polynomial = pobyso_parse_string(argv[1]);
+  if (polynomial == NULL)
+  {
+    fprintf(stderr,
+            "%s: can't create the polynomial.\n",
+            argv[0]);
+    return 1;
+  }
+  pobyso_autoprint(polynomial);
+  expsArray = (long int*) malloc((argc - 2) * sizeof(long int));
+  if (expsArray == NULL)
+  {
+    fprintf(stderr,
+            "%s: can't create the exponents array.\n",
+            argv[0]);
+    return 1;
+  }
+  for (i = 2 ; i < argc ; i++)
+  {
+    if (read_long_decimal(&(expsArray[i - 2]), argv[i]))
+    {
+      fprintf(stderr,
+              "%s: can't read exponent \"%s\".\n",
+              argv[0],
+              argv[i]);
+      return 1;
+    }
+  }
+  subpoly = pobyso_subpoly(polynomial, argc - 2, expsArray);
+  if (subpoly == NULL)
+  {
+    return 1;
+  }
+  else
+  {
+    pobyso_autoprint(subpoly);
+    return 0;
+  }
+} /* End main */

Property changes on: pobysoC-4.0/src/test-pobyso-subpoly.c
___________________________________________________________________
Added: svn:mime-type
   + text/plain


Property changes on: pobysoC-4.0/src
___________________________________________________________________
Modified: svn:ignore
   - lastArch.txt

doxygen

test-pobyso-01

test-pobyso-constant-expression

test-pobyso-02

test-pobyso-new-monomial

   + lastArch.txt

doxygen

test-pobyso-01

test-pobyso-constant-expression

test-pobyso-02

test-pobyso-new-monomial

test-pobyso-subpoly


