Show n/a when dimensions are equal to 0 in the variable browser + comment 65/4365/2
Sylvestre Ledru [Wed, 29 Jun 2011 22:22:55 +0000 (00:22 +0200)]
Change-Id: I10aa5807e62027afb69812a38d184069c3bce5d3

scilab/modules/ui_data/src/cpp/UpdateBrowseVar.cpp
scilab/modules/ui_data/src/java/org/scilab/modules/ui_data/BrowseVar.java

index c4e32e4..a5d51d1 100644 (file)
@@ -84,10 +84,17 @@ void UpdateBrowseVar(BOOL update)
         // Sizes of the variable
         getNamedVarDimension(pvApiCtx, pstAllVariableNames[i], &nbRows, &nbCols);
 
-        sizeStr = (char *)MALLOC((sizeof(nbRows) + sizeof(nbCols) + strlen("x") + 1) * sizeof(char));
-        sprintf(sizeStr, "%dx%d", nbRows, nbCols);
-        pstAllVariableSizes[i] = strdup(sizeStr);
-        FREE(sizeStr);
+        if (nbRows*nbCols == 0) {
+#define N_A "N/A"
+            pstAllVariableSizes[i] = (char *)MALLOC((sizeof(N_A) + 1) * sizeof(char));
+            strcpy(pstAllVariableSizes[i],N_A);
+        } else {
+            sizeStr = (char *)MALLOC((sizeof(nbRows) + sizeof(nbCols) + strlen("x") + 1) * sizeof(char));
+            sprintf(sizeStr, "%dx%d", nbRows, nbCols);
+            pstAllVariableSizes[i] = strdup(sizeStr);
+            FREE(sizeStr);
+        }
+
 
         // global / local ??
         pstAllVariableVisibility[i] = strdup("local");
index fb134cd..547212b 100644 (file)
@@ -36,7 +36,7 @@ public class BrowseVar {
 
     public static final String[] COLUMNNAMES = new String[]{"", /* Icon */
                                                             Messages.gettext("Name"),
-                                                            Messages.gettext("Size"),
+                                                            Messages.gettext("Dimension"),
                                                             Messages.gettext("Type"),
                                                             Messages.gettext("Visibility"),
                                                             Messages.gettext("Bytes"),