]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/table.c
Xtype docs: Fixed a typo
[libucw.git] / ucw / table.c
index a787d587e838118b5af4e955cc6d492fba57737a..1324839a7c371fd59e1097e09e7724faae437b1e 100644 (file)
@@ -49,7 +49,8 @@ struct table *table_init(const struct table_template *tbl_template)
 
   // initialize column_order
   if(tbl_template->column_order) {
-    for(int cols_to_output = 0; ; cols_to_output++) {
+    int cols_to_output = 0;
+    for(; ; cols_to_output++) {
       if(tbl_template->column_order[cols_to_output].idx == ~0U) break;
     }
 
@@ -188,11 +189,11 @@ void table_set_col_order(struct table *tbl, const struct table_col_instance *col
   tbl->column_order = mp_alloc(tbl->pool, sizeof(struct table_col_instance) * cols_to_output);
   memcpy(tbl->column_order, col_order, sizeof(struct table_col_instance) * cols_to_output);
   for(uint i = 0; i < cols_to_output; i++) {
-    int col_def_idx = tbl->column_order[i].idx; // this is given in col_order
+    int col_def_idx = tbl->column_order[i].idx; // this is given in arg @col_order
     tbl->column_order[i].col_def = tbl->columns + col_def_idx;
-    tbl->column_order[i].cell_content = NULL; // cell_content is copied from @col_order, so make sure that it is NULL
+    tbl->column_order[i].cell_content = NULL; // cell_content is copied from arg @col_order, so make sure that it is NULL
     tbl->column_order[i].next_column = -1;
-    // tbl->column_order[i].fmt should be untouched (copied from col_order)
+    // tbl->column_order[i].fmt should be untouched (copied from arg @col_order)
   }
 }
 
@@ -214,10 +215,10 @@ const char *table_set_col_opt(struct table *tbl, uint col_inst_idx, const char *
     return col_def->set_col_opt(tbl, col_inst_idx, col_opt);
   }
 
-  if(col_def && col_def->type_def && col_def->type_def->parse_fmt) {
-    uint fmt = 0;
-    const char *tmp_err = col_def->type_def->parse_fmt(col_opt, &fmt, tbl->pool);
-    if(tmp_err) return tmp_err;
+  if(col_def && col_def->type_def) {
+    u32 fmt = 0;
+    const char *tmp_err = xtype_parse_fmt(col_def->type_def, col_opt, &fmt, tbl->pool);
+    if(tmp_err) return mp_printf(tbl->pool, "Invalid column format; xtypes error: '%s'.", tmp_err);
     tbl->column_order[col_inst_idx].fmt = fmt;
     return NULL;
   }
@@ -249,11 +250,13 @@ static char **table_parse_col_arg2(char *col_def)
     if(*next == 0) break;
     *next = 0;
     next++;
-    *GARY_PUSH(result) = col_opt;
+    if(*col_opt)
+      *GARY_PUSH(result) = col_opt;
 
     col_opt = next;
   }
-  *GARY_PUSH(result) = col_opt;
+  if(*col_opt)
+    *GARY_PUSH(result) = col_opt;
 
   return result;
 }