@@ -295,7 +295,7 @@ exec_create_table(struct in_cmd* cmd)
295295 return ;
296296 }
297297
298- if (( pos = name_list_pos ( name , table_register -> names )) > -1 ) {
298+ if (table_exists ( name ) ) {
299299 warning ("table already exists: " , "ignored" );
300300 return ;
301301 }
@@ -385,12 +385,12 @@ exec_dump(struct in_cmd* cmd)
385385 strcpy (filename ,f );
386386
387387 // get table from registered tables
388- if ((pos = name_list_pos (name , table_register -> names )) < 0 ) {
388+ struct table * t = find_table (name );
389+ if (!t ) {
389390 warning ("table not found:" , "ignored" );
390391 return ;
391392 }
392393
393- struct table * t = table_register -> tables [pos ];
394394 out_table (name , t , filename );
395395
396396 return ;
@@ -417,12 +417,12 @@ exec_shrink_table(struct in_cmd* cmd)
417417 return ;
418418 }
419419
420- if ((pos = name_list_pos (name , table_register -> names )) < 0 ) {
420+ t = find_table (name );
421+ if (!t ) {
421422 warning ("table name not found:" , "ignored" );
422423 return ;
423424 }
424425
425- t = table_register -> tables [pos ];
426426 pos = name_list_pos ("row" , nl );
427427 row = pos >= 0 ? pl -> parameters [pos ]-> double_value : t -> curr - 1 ;
428428
@@ -450,12 +450,12 @@ exec_fill_table(struct in_cmd* cmd)
450450 return ;
451451 }
452452
453- if ((pos = name_list_pos (name , table_register -> names )) < 0 ) {
453+ struct table * t = find_table (name );
454+ if (!t ) {
454455 warning ("table not found:" , "ignored" );
455456 return ;
456457 }
457458
458- struct table * t = table_register -> tables [pos ];
459459
460460 if ((pos = name_list_pos ("row" , nl )) < 0 )
461461 row = t -> curr + 1 ;
@@ -497,13 +497,12 @@ exec_fill_knob_table(struct in_cmd* cmd)
497497 return ;
498498 }
499499
500- if ((pos = name_list_pos (name , table_register -> names )) < 0 ) {
500+ struct table * t = find_table (name );
501+ if (!t ) {
501502 warning ("table not found:" , "ignored" );
502503 return ;
503504 }
504505
505- struct table * t = table_register -> tables [pos ];
506-
507506 if ((pos = name_list_pos ("row" , nl )) < 0 )
508507 row = t -> curr + 1 ;
509508 else {
@@ -570,13 +569,12 @@ exec_setvars_table(struct in_cmd* cmd)
570569 return ;
571570 }
572571
573- if ((pos = name_list_pos (name , table_register -> names )) < 0 ) {
572+ struct table * t = find_table (name );
573+ if (!t ) {
574574 warning ("table not found:" , "ignored" );
575575 return ;
576576 }
577577
578- struct table * t = table_register -> tables [pos ];
579-
580578 if ((pos = name_list_pos ("row" , nl )) < 0 )
581579 row = t -> curr ;
582580 else {
@@ -612,13 +610,12 @@ exec_setvars_lin_table(struct in_cmd* cmd)
612610 return ;
613611 }
614612
615- if ((pos = name_list_pos (name , table_register -> names )) < 0 ) {
613+ struct table * t = find_table (name );
614+ if (!t ) {
616615 warning ("table not found:" , "ignored" );
617616 return ;
618617 }
619618
620- struct table * t = table_register -> tables [pos ];
621-
622619 pos = name_list_pos ("row1" , nl );
623620 row1 = pos >= 0 ? (int ) pl -> parameters [pos ]-> double_value : t -> curr ;
624621 pos = name_list_pos ("row2" , nl );
@@ -678,13 +675,12 @@ exec_setvars_knob_table(struct in_cmd* cmd)
678675 return ;
679676 }
680677
681- if ((pos = name_list_pos (name , table_register -> names )) < 0 ) {
678+ struct table * t = find_table (name );
679+ if (!t ) {
682680 warning ("table not found:" , "ignored" );
683681 return ;
684682 }
685683
686- struct table * t = table_register -> tables [pos ];
687-
688684 pos = name_list_pos ("row" , nl );
689685 row = pos >= 0 ? (int ) pl -> parameters [pos ]-> double_value : t -> curr ;
690686 pos = name_list_pos ("knob" , nl );
@@ -745,13 +741,12 @@ exec_setvars_const_table(struct in_cmd* cmd)
745741 return ;
746742 }
747743
748- if ((pos = name_list_pos (name , table_register -> names )) < 0 ) {
744+ struct table * t = find_table (name );
745+ if (!t ) {
749746 warning ("table not found:" , "ignored" );
750747 return ;
751748 }
752749
753- struct table * t = table_register -> tables [pos ];
754-
755750 pos = name_list_pos ("const" , nl );
756751 double constant = pl -> parameters [pos ]-> double_value ;
757752
0 commit comments