fix int_to_string_map bug; allow blank lines and comments in output_spec.cfg 52/4452/2
authorvlad shkapenyuk <vshkap@research.att.com>
Fri, 24 Jul 2020 15:37:25 +0000 (11:37 -0400)
committerVlad Shkapenyuk <vshkap@research.att.com>
Fri, 24 Jul 2020 15:39:37 +0000 (15:39 +0000)
Signed-off-by: vlad shkapenyuk <vshkap@research.att.com>
Change-Id: I628decb5837b216c3585d6729be5f64edcbe15e5

src/ftacmp/translate_fta.cc
src/lib/gscphftaaux/hfta_runtime_library.cc

index 2176d2f..4ee0bb4 100644 (file)
@@ -397,24 +397,26 @@ int main(int argc, char **argv){
                while(fgets(tmpstr,TMPSTRLEN,osp_in)){
                        o_lineno++;
                        int nflds = split_string(tmpstr,',',flds,MAXFLDS);
-                       if(nflds == 7){
+                       if(tmpstr[0]!='\n' && tmpstr[0]!='\r' && tmpstr[0]!='\0' && tmpstr[0]!='#'){
+                               if(nflds == 7){
 //             make operator type lowercase
-                               char *tmpc;
-                               for(tmpc=flds[1];*tmpc!='\0';++tmpc)
-                                       *tmpc = tolower(*tmpc);
-
-                               ospec_str *tmp_ospec = new ospec_str();
-                               tmp_ospec->query = flds[0];
-                               tmp_ospec->operator_type = flds[1];
-                               tmp_ospec->operator_param = flds[2];
-                               tmp_ospec->output_directory = flds[3];
-                               tmp_ospec->bucketwidth = atoi(flds[4]);
-                               tmp_ospec->partitioning_flds = flds[5];
-                               tmp_ospec->n_partitions = atoi(flds[6]);
-                               qname_to_ospec.insert(pair<string,int>(tmp_ospec->query,output_specs.size()));
-                               output_specs.push_back(tmp_ospec);
-                       }else{
-                               fprintf(stderr,"Warning, line %d corrupted in output_spec.cfg, has %d fields.\n",o_lineno,nflds);
+                                       char *tmpc;
+                                       for(tmpc=flds[1];*tmpc!='\0';++tmpc)
+                                               *tmpc = tolower(*tmpc);
+       
+                                       ospec_str *tmp_ospec = new ospec_str();
+                                       tmp_ospec->query = flds[0];
+                                       tmp_ospec->operator_type = flds[1];
+                                       tmp_ospec->operator_param = flds[2];
+                                       tmp_ospec->output_directory = flds[3];
+                                       tmp_ospec->bucketwidth = atoi(flds[4]);
+                                       tmp_ospec->partitioning_flds = flds[5];
+                                       tmp_ospec->n_partitions = atoi(flds[6]);
+                                       qname_to_ospec.insert(pair<string,int>(tmp_ospec->query,output_specs.size()));
+                                       output_specs.push_back(tmp_ospec);
+                               }else{
+                                       fprintf(stderr,"Warning, line %d corrupted in output_spec.cfg, has %d fields.\n",o_lineno,nflds);
+                               }
                        }
                }
                fclose(osp_in);
index 5cabb20..8396e4d 100644 (file)
@@ -591,10 +591,12 @@ gs_param_handle_t register_handle_for_int_to_string_map_slot_1(vstring *filename
                return 0;
        }
        
-       char buf[10000], buf_str[10000];
-       gs_int32_t buflen;
+       gs_int32_t buflen = 10000;
+       char buf[buflen], buf_str[buflen];
        gs_int64_t val;
-       while(fgets(buf, buflen, fl) > 0){
+       char *fret;
+       fret = fgets(buf, buflen, fl);
+       while(fret != NULL){
                int nvals = sscanf(buf, "%lld,%s", &val, buf_str);
                if(nvals >= 2){
                        vstring new_str;
@@ -604,6 +606,7 @@ gs_param_handle_t register_handle_for_int_to_string_map_slot_1(vstring *filename
                        memcpy((char *)new_str.offset, buf_str, new_str.length);
                        map_struct->i2s_map[val] = new_str;
                }
+               fret = fgets(buf, buflen, fl);
        }
 
        fclose(fl);