- last = VEC_last (osdata_item_s, osdata->items);
- if (last && last->columns)
- ncols = VEC_length (osdata_column_s, last->columns);
- else
- ncols = 0;
+ if (*type == '\0' && nrows == 0)
+ error (_("Available types of OS data not reported."));
+
+ if (!osdata->items.empty ())
+ {
+ last = &osdata->items.back ();
+ ncols = last->columns.size ();
+
+ /* As a special case, scan the listing of available data types
+ for a column named "Title", and only include it with MI
+ output; this column's normal use is for titles for interface
+ elements like menus, and it clutters up CLI output. */
+ if (*type == '\0' && !uiout->is_mi_like_p ())
+ {
+ for (int ix = 0; ix < last->columns.size (); ix++)
+ {
+ if (last->columns[ix].name == "Title")
+ col_to_skip = ix;
+ }
+ /* Be sure to reduce the total column count, otherwise
+ internal errors ensue. */
+ if (col_to_skip >= 0)
+ --ncols;
+ }
+ }
+
+ ui_out_emit_table table_emitter (uiout, ncols, nrows, "OSDataTable");