*** ../CIFFOLD_0.5.2/menus.cpp	Mon Jul 25 21:18:49 2005
--- menus.cpp	Sat Oct  1 08:55:14 2005
***************
*** 1,5 ****
  /*
! CIFFOLD 0.5.1 Pre-Release
  by Kostadin Mitev, Georgi Todorov and Herbert J. Bernstein
  
  Copyright (C) Kostadin Mitev 2005
--- 1,5 ----
  /*
! CIFFOLD 0.5.3 Pre-Release
  by Kostadin Mitev, Georgi Todorov and Herbert J. Bernstein
  
  Copyright (C) Kostadin Mitev 2005
***************
*** 97,105 ****
  	OPTIONS[11]; 		//Output the warning messages as a special comment at the bottom of the file(0-no, 1-yes)
  	OPTIONS[12];    	//Output the error messages as a spcial comment at the bottom of the file(0-no , 1- yes)
  	OPTIONS[13];		//if folding generate a map to recover the file in unfolding, if unfolding recover the file using 
! */				//the generated map	
  	
! 	for (i = 0; i < 14; i++) OPTIONS[i] = -1;
  	
  	if( argc > 1 ) {
  	   startGUI =  parseOpt(argc, argv, &pinfile); 
--- 97,107 ----
  	OPTIONS[11]; 		//Output the warning messages as a special comment at the bottom of the file(0-no, 1-yes)
  	OPTIONS[12];    	//Output the error messages as a spcial comment at the bottom of the file(0-no , 1- yes)
  	OPTIONS[13];		//if folding generate a map to recover the file in unfolding, if unfolding recover the file using 
! 				//the generated map
! 	OPTIONS[14];		//minimal folding (0 - do reorganize loops, 1 - do not reorganize loops)
!  */	
  	
! 	for (i = 0; i < 15; i++) OPTIONS[i] = -1;
  	
  	if( argc > 1 ) {
  	   startGUI =  parseOpt(argc, argv, &pinfile); 
***************
*** 166,189 ****
  		OPTIONS[0] = print_menu(my_menu, 1, 0, 40,"File version",COLOR_PAIR(0));
  		
  		while(OPTIONS[1]== -1){
! 			OPTIONS[1]=print_yesno_question(1, 0, 40, "Folding(Yes) or Unfolding(No)", COLOR_PAIR(0),"");
  		}
  		if (OPTIONS[1]==1){
  			while(OPTIONS[13]==-1){
! 				OPTIONS[13]=print_yesno_question(1, 0, 40, "Create a MAP?", COLOR_PAIR(0),"Some coments on MAPs");
  			}
  			int tmp = -1;
  			while(tmp == -1){
! 				tmp =atoi(ask_win("Enter maximum line length", COLOR_PAIR(0),"Valid input is an integer in the range 60-2048"));
  				if((tmp < 60) || (tmp > 2048) || (tmp < 0)){
! 					printError(1, 0, 40, "ERROR! Invalid input", COLOR_PAIR(0), "Input must be an integer in the range 60-2048");
  					tmp = -1;
  				}
  			}
  			MAXLENGTH = tmp;
  		}else{
  			while(OPTIONS[13]==-1)
! 			OPTIONS[13]=print_yesno_question(1, 0, 40, "Read from a MAP?", COLOR_PAIR(0),"Some coments on MAPs");
  		}
  		if (OPTIONS[1]==0&&OPTIONS[13]==1){
  			while (OPTIONS[6]==-1){
--- 168,199 ----
  		OPTIONS[0] = print_menu(my_menu, 1, 0, 40,"File version",COLOR_PAIR(0));
  		
  		while(OPTIONS[1]== -1){
! 			OPTIONS[1]=print_yesno_question(1, 0, 40, "Folding (Yes) or Unfolding (No)", COLOR_PAIR(0),"");
  		}
  		if (OPTIONS[1]==1){
+ 			while(OPTIONS[14]==-1){
+ 				OPTIONS[14]=print_yesno_question(1, 0, 40, "Minimal Folding? (Yes or No)", COLOR_PAIR(0),
+ 				"Suppressed loop reorganization");
+ 			}
  			while(OPTIONS[13]==-1){
! 				OPTIONS[13]=print_yesno_question(1, 0, 40, "Create a MAP?", COLOR_PAIR(0),
! 				"Needed for full recovery on unfolding");
  			}
  			int tmp = -1;
  			while(tmp == -1){
! 				tmp =atoi(ask_win("Enter maximum line length", COLOR_PAIR(0),
! 				"Valid input is an integer in the range 60-2048"));
  				if((tmp < 60) || (tmp > 2048) || (tmp < 0)){
! 					printError(1, 0, 40, "ERROR! Invalid input", COLOR_PAIR(0), 
! 					"Input must be an integer in the range 60-2048");
  					tmp = -1;
  				}
  			}
  			MAXLENGTH = tmp;
  		}else{
  			while(OPTIONS[13]==-1)
! 			OPTIONS[13]=print_yesno_question(1, 0, 40, "Read from a MAP?", COLOR_PAIR(0),
! 			"Will recover original spacing.");
  		}
  		if (OPTIONS[1]==0&&OPTIONS[13]==1){
  			while (OPTIONS[6]==-1){
***************
*** 195,206 ****
  				unsigned long end = 0;
  				strcpy(filechunks, "n");
  				while(true){
! 					filechunks=ask_win("Enter chunk pairs or END to continue", COLOR_PAIR(0),"Example: 1-4 or 234-345 or end or End or END");
  					if (!strcasecmp(filechunks,"END")){
  						break;
  					}
  				    if(strstr(filechunks, "-") == NULL){
! 					    printError(1, 0, 40, "ERROR! Input must be in pairs", COLOR_PAIR(0),"Example: 1-4 or 234-345 or end or End or END");
  					    clear();
  				    	continue;
  				    }	
--- 205,218 ----
  				unsigned long end = 0;
  				strcpy(filechunks, "n");
  				while(true){
! 					filechunks=ask_win("Enter chunk pairs or END to continue", COLOR_PAIR(0),
! 					"Example: 1-4 or 234-345 or end or End or END");
  					if (!strcasecmp(filechunks,"END")){
  						break;
  					}
  				    if(strstr(filechunks, "-") == NULL){
! 					    printError(1, 0, 40, "ERROR! Input must be in pairs", COLOR_PAIR(0),
! 						"Example: 1-4 or 234-345 or end or End or END");
  					    clear();
  				    	continue;
  				    }	
***************
*** 212,224 ****
  						token = strtok( NULL,"-" );
  						if (start < end){
  							if(!FileChunks.empty() && start <= FileChunks.back()){
! 								printError(1, 0, 40, "ERROR! First value problem", COLOR_PAIR(0),"Your first value must be greater than the largest value you've entered so far!");
  								break;
  							}
  						  FileChunks.push_back(start);
  						  FileChunks.push_back(end);
  						}else
! 						printError(1, 0, 40, "ERROR! Second value problem", COLOR_PAIR(0),"Your second value should be greater than the first one!");
  					}
  				}
  			}
--- 224,238 ----
  						token = strtok( NULL,"-" );
  						if (start < end){
  							if(!FileChunks.empty() && start <= FileChunks.back()){
! 								printError(1, 0, 40, "ERROR! First value problem", COLOR_PAIR(0),
! 									"Your first value must be greater than the largest value you've entered so far!");
  								break;
  							}
  						  FileChunks.push_back(start);
  						  FileChunks.push_back(end);
  						}else
! 						printError(1, 0, 40, "ERROR! Second value problem", COLOR_PAIR(0),
! 								"Your second value should be greater than the first one!");
  					}
  				}
  			}
***************
*** 273,285 ****
  						token = strtok( NULL,"-" );
  						if (start < end){
  							if(!FileChunks.empty() && start <= FileChunks.back()){
! 								printError(1, 0, 40, "ERROR! First value problem", COLOR_PAIR(0),"Your first value must be greater than the largest value you've entered so far!");
  								break;
  							}
  						  FileChunks.push_back(start);
  						  FileChunks.push_back(end);
  						}else
! 						printError(1, 0, 40, "ERROR! Second value problem", COLOR_PAIR(0),"Your second value should be greater than the first one!");
  					}
  				}
  			}
--- 287,301 ----
  						token = strtok( NULL,"-" );
  						if (start < end){
  							if(!FileChunks.empty() && start <= FileChunks.back()){
! 								printError(1, 0, 40, "ERROR! First value problem", COLOR_PAIR(0),
! 									"Your first value must be greater than the largest value you've entered so far!");
  								break;
  							}
  						  FileChunks.push_back(start);
  						  FileChunks.push_back(end);
  						}else
! 						printError(1, 0, 40, "ERROR! Second value problem", COLOR_PAIR(0),
! 									"Your second value should be greater than the first one!");
  					}
  				}
  			}
***************
*** 292,301 ****
  				}
  			}
  			if (OPTIONS[1]==0){
! 				column_align = ask_win("The column with respect to which the data should be aligned", COLOR_PAIR(0),"Default is Not Specified(0) or enter a number between 5 and 2039");
  				while (atoi(column_align)!=0 && (atoi(column_align)<5||atoi(column_align)>(LMAXLEN -10) )){
! 					printError(1, 0, 40, "ERROR! The number is invalid", COLOR_PAIR(0),"Enter a number between 5 and 2000 or leave blank for none");
! 					column_align = ask_win("The column with respect to which the data should be aligned", COLOR_PAIR(0),"Default is 0 or enter a number between 5 and 2000");
  				}
  				OPTIONS[9]=atoi(column_align);
  			}
--- 308,320 ----
  				}
  			}
  			if (OPTIONS[1]==0){
! 				column_align = ask_win("The column with respect to which the data should be aligned", COLOR_PAIR(0),
! 					"Default is Not Specified(0) or enter a number between 5 and 2039");
  				while (atoi(column_align)!=0 && (atoi(column_align)<5||atoi(column_align)>(LMAXLEN -10) )){
! 					printError(1, 0, 40, "ERROR! The number is invalid", COLOR_PAIR(0),
! 						"Enter a number between 5 and 2000 or leave blank for none");
! 					column_align = ask_win("The column with respect to which the data should be aligned", COLOR_PAIR(0),
! 						"Default is 0 or enter a number between 5 and 2000");
  				}
  				OPTIONS[9]=atoi(column_align);
  			}
***************
*** 306,315 ****
  			OPTIONS[10]=print_yesno_question(1, 0, 40, "Is this a dictionary file?",COLOR_PAIR(0),"");
  		}
  		while (OPTIONS[11]==-1){
! 			OPTIONS[11]=print_yesno_question(1, 0, 40, "Output the warning messages?",COLOR_PAIR(0),"Warning messages will be as a special comment at the bottom of the file");
  		}
  		while (OPTIONS[12]==-1){
! 			OPTIONS[12]=print_yesno_question(1, 0, 40, "Output the error messages?",COLOR_PAIR(0),"Error messages will be as a special comment at the bottom of the file");
  		}
  		/* Free memory? */
  		unpost_menu(my_menu);
--- 325,336 ----
  			OPTIONS[10]=print_yesno_question(1, 0, 40, "Is this a dictionary file?",COLOR_PAIR(0),"");
  		}
  		while (OPTIONS[11]==-1){
! 			OPTIONS[11]=print_yesno_question(1, 0, 40, "Output the warning messages?",COLOR_PAIR(0),
! 				"Warning messages will be as a special comment at the bottom of the file");
  		}
  		while (OPTIONS[12]==-1){
! 			OPTIONS[12]=print_yesno_question(1, 0, 40, "Output the error messages?",COLOR_PAIR(0),
! 				"Error messages will be as a special comment at the bottom of the file");
  		}
  		/* Free memory? */
  		unpost_menu(my_menu);
***************
*** 375,380 ****
--- 396,404 ----
  		 OPTIONS[13] = 0;       //if folding do not generate a map to recover the file in unfolding, if unfolding do not recover the file using
  		                        //the generated map
  	}
+ 	if(OPTIONS[14] == -1){
+ 		 OPTIONS[14] = 0;       //minimal folding (no reorganization of loops) (0-no , 1- yes)
+ 	}
  /////////////////////////////FORCE MAXLENGTH TO BE 2048 if UNFOLDING//////////////////
  	if(!OPTIONS[1]){
  		MAXLENGTH = 2048;
***************
*** 478,484 ****
  	mvwhline(my_menu_win, 2, 1, ACS_HLINE, 58);
  	mvwaddch(my_menu_win, 2, 59, ACS_RTEE);
  	mvprintw(LINES - 2, 0, "Up and Down arrow keys to navigate (F1 to Exit)");
! 	mvprintw(LINES - 7, 0, "CIFFOLD 0.4 Copyright (C) K. Mitev 2005");
  	mvprintw(LINES - 6, 0, "CIFFOLD comes with ABSOLUTELY NO WARRANTY"); 
  	mvprintw(LINES - 5, 0, "This is free software, and you are welcome to redistribute it");
  	mvprintw(LINES - 4, 0, "under certain conditions; see the GPL in file COPYING.");
--- 502,508 ----
  	mvwhline(my_menu_win, 2, 1, ACS_HLINE, 58);
  	mvwaddch(my_menu_win, 2, 59, ACS_RTEE);
  	mvprintw(LINES - 2, 0, "Up and Down arrow keys to navigate (F1 to Exit)");
! 	mvprintw(LINES - 7, 0, "CIFFOLD 0.5 Copyright (C) K. Mitev 2005");
  	mvprintw(LINES - 6, 0, "CIFFOLD comes with ABSOLUTELY NO WARRANTY"); 
  	mvprintw(LINES - 5, 0, "This is free software, and you are welcome to redistribute it");
  	mvprintw(LINES - 4, 0, "under certain conditions; see the GPL in file COPYING.");
***************
*** 559,565 ****
  	mvwhline(my_menu_win, 2, 1, ACS_HLINE, 58);
  	mvwaddch(my_menu_win, 2, 59, ACS_RTEE);
  	mvprintw(LINES - 2, 0, "Up and Down arrow keys to navigate (F1 to Exit)");
!  	mvprintw(LINES - 7, 0, "CIFFOLD 0.4 Copyright (C) K. Mitev 2005");
  	mvprintw(LINES - 6, 0, "CIFFOLD comes with ABSOLUTELY NO WARRANTY"); 
  	mvprintw(LINES - 5, 0, "This is free software, and you are welcome to redistribute it");
  	mvprintw(LINES - 4, 0, "under certain conditions; see the GPL in file COPYING.");
--- 583,589 ----
  	mvwhline(my_menu_win, 2, 1, ACS_HLINE, 58);
  	mvwaddch(my_menu_win, 2, 59, ACS_RTEE);
  	mvprintw(LINES - 2, 0, "Up and Down arrow keys to navigate (F1 to Exit)");
!  	mvprintw(LINES - 7, 0, "CIFFOLD 0.5 Copyright (C) K. Mitev 2005");
  	mvprintw(LINES - 6, 0, "CIFFOLD comes with ABSOLUTELY NO WARRANTY"); 
  	mvprintw(LINES - 5, 0, "This is free software, and you are welcome to redistribute it");
  	mvprintw(LINES - 4, 0, "under certain conditions; see the GPL in file COPYING.");
***************
*** 620,626 ****
  	mvwhline(win, 2, 1, ACS_HLINE, 58);
  	mvwaddch(win, 2, 59, ACS_RTEE);
  	wrefresh(win);
! 	mvprintw(LINES - 7, 0, "CIFFOLD 0.4 Copyright (C) K. Mitev 2005");
  	mvprintw(LINES - 6, 0, "CIFFOLD comes with ABSOLUTELY NO WARRANTY"); 
  	mvprintw(LINES - 5, 0, "This is free software, and you are welcome to redistribute it");
  	mvprintw(LINES - 4, 0, "under certain conditions; see the GPL in file COPYING.");
--- 644,650 ----
  	mvwhline(win, 2, 1, ACS_HLINE, 58);
  	mvwaddch(win, 2, 59, ACS_RTEE);
  	wrefresh(win);
! 	mvprintw(LINES - 7, 0, "CIFFOLD 0.5 Copyright (C) K. Mitev 2005");
  	mvprintw(LINES - 6, 0, "CIFFOLD comes with ABSOLUTELY NO WARRANTY"); 
  	mvprintw(LINES - 5, 0, "This is free software, and you are welcome to redistribute it");
  	mvprintw(LINES - 4, 0, "under certain conditions; see the GPL in file COPYING.");
***************
*** 680,686 ****
  	mvwhline(my_err_win, 2, 1, ACS_HLINE, 58);
  	mvwaddch(my_err_win, 2, 59, ACS_RTEE);
  	mvprintw(LINES - 2, 0, "Up and Down arrow keys to navigate (F1 to Exit)");
! 	mvprintw(LINES - 7, 0, "CIFFOLD 0.4 Copyright (C) K. Mitev 2005");
  	mvprintw(LINES - 6, 0, "CIFFOLD comes with ABSOLUTELY NO WARRANTY"); 
  	mvprintw(LINES - 5, 0, "This is free software, and you are welcome to redistribute it");
  	mvprintw(LINES - 4, 0, "under certain conditions; see the GPL in file COPYING.");
--- 704,710 ----
  	mvwhline(my_err_win, 2, 1, ACS_HLINE, 58);
  	mvwaddch(my_err_win, 2, 59, ACS_RTEE);
  	mvprintw(LINES - 2, 0, "Up and Down arrow keys to navigate (F1 to Exit)");
! 	mvprintw(LINES - 7, 0, "CIFFOLD 0.5 Copyright (C) K. Mitev 2005");
  	mvprintw(LINES - 6, 0, "CIFFOLD comes with ABSOLUTELY NO WARRANTY"); 
  	mvprintw(LINES - 5, 0, "This is free software, and you are welcome to redistribute it");
  	mvprintw(LINES - 4, 0, "under certain conditions; see the GPL in file COPYING.");
