+/* Sets cell (C,R) in TABLE, with options OPT, to have value VAL as
+ formatted by FMT.
+ If FMT is null, then the default print format will be used.
+*/
+void
+tab_double (struct tab_table *table, int c, int r, unsigned char opt,
+ double val, const struct fmt_spec *fmt)
+{
+ int w;
+ char *contents;
+ char buf[40], *cp;
+
+ union value double_value;
+
+ assert (table != NULL);
+
+ assert (c >= 0);
+ assert (c < table->nc);
+ assert (r >= 0);
+ assert (r < table->nr);
+
+ if ( fmt == NULL)
+ fmt = settings_get_format ();
+
+ fmt_check_output (fmt);
+
+#if DEBUGGING
+ if (c + table->col_ofs < 0 || r + table->row_ofs < 0
+ || c + table->col_ofs >= table->nc
+ || r + table->row_ofs >= table->nr)
+ {
+ printf ("tab_double(): bad cell (%d+%d=%d,%d+%d=%d) in table size "
+ "(%d,%d)\n",
+ c, table->col_ofs, c + table->col_ofs,
+ r, table->row_ofs, r + table->row_ofs,
+ table->nc, table->nr);
+ return;
+ }
+#endif
+
+ double_value.f = val;
+ data_out (&double_value, fmt, buf);
+
+ cp = buf;
+ while (isspace ((unsigned char) *cp) && cp < &buf[fmt->w])
+ cp++;
+ w = fmt->w - (cp - buf);
+
+ contents = pool_alloc (table->container, w);
+ table->cc[c + r * table->cf] = ss_buffer (contents, w);
+ table->ct[c + r * table->cf] = opt;
+ memcpy (contents, cp, w);
+}
+
+