diff -Naur CIFFOLD_0.3/ERROR.cpp CIFFOLD_0.4/ERROR.cpp --- CIFFOLD_0.3/ERROR.cpp 2005-04-23 10:40:51.000000000 -0400 +++ CIFFOLD_0.4/ERROR.cpp 2005-04-27 17:09:41.000000000 -0400 @@ -1,5 +1,5 @@ /* -CIFFOLD 0.3 Pre-Release +CIFFOLD 0.4 Pre-Release by Kostadin Mitev, Georgi Todorov and Herbert J. Bernstein Copyright (C) Kostadin Mitev 2005 diff -Naur CIFFOLD_0.3/ERROR.h CIFFOLD_0.4/ERROR.h --- CIFFOLD_0.3/ERROR.h 2005-04-23 10:38:52.000000000 -0400 +++ CIFFOLD_0.4/ERROR.h 2005-04-27 17:09:51.000000000 -0400 @@ -1,5 +1,5 @@ /* -CIFFOLD 0.3 Pre-Release +CIFFOLD 0.4 Pre-Release by Kostadin Mitev, Georgi Todorov and Herbert J. Bernstein Copyright (C) Kostadin Mitev 2005 diff -Naur CIFFOLD_0.3/FUCIF.c CIFFOLD_0.4/FUCIF.c --- CIFFOLD_0.3/FUCIF.c 2005-04-22 18:44:53.000000000 -0400 +++ CIFFOLD_0.4/FUCIF.c 2005-04-27 17:10:04.000000000 -0400 @@ -1,5 +1,5 @@ /* -CIFFOLD 0.2 Pre-Release +CIFFOLD 0.4 Pre-Release by Kostadin Mitev, Georgi Todorov and Herbert J. Bernstein Copyright (C) Kostadin Mitev 2005 @@ -58,7 +58,7 @@ long END = 0; //used only when parts of the file should be processed bool PRESERVE; FILE *MAPFILE; -char *LINEMAP = new char [BUFSIZE]; //holds the map of the current line the map consists +char *LINEMAP = new char [BUFSIZE + 1]; //holds the map of the current line the map consists //of the following: /tn where n indicates //the number of tabs to be inserted /d means that //there should be data /n where n is a digid @@ -70,7 +70,7 @@ void reader() { - char * curLine = new char[BUFSIZE]; + char * curLine = new char[BUFSIZE + 1]; //(char *)malloc(2052*sizeof(char)); char state = 0; //2-for a comment 1- for a textfield, 3 for converted text field(long strings), 4 for egular data that needs to //be converted. int pos = 0, ii = 0; @@ -114,9 +114,9 @@ } ch = OPTIONS[4]; //if 0 do not keep leading blanks - fgets(curLine, LMAXLEN, INF); + fgets(curLine, BUFSIZE, INF); if( (MAPON) && (!OPTIONS[1]) ){ - fgets(LINEMAP, LMAXLEN, MAPFILE); + fgets(LINEMAP, BUFSIZE, MAPFILE); rmtblanks(LINEMAP); LMCOUNT = 0; } @@ -130,12 +130,12 @@ if( (!LINEMAP[LMCOUNT]) && (!OPTIONS[1]) ){ fputc('\n', OUTF); left = MAXLENGTH; - fgets(LINEMAP, LMAXLEN, MAPFILE); + fgets(LINEMAP, BUFSIZE, MAPFILE); rmtblanks(LINEMAP); LMCOUNT = 0; } } - fgets(curLine, LMAXLEN, INF); + fgets(curLine, BUFSIZE, INF); pos = 0; } } @@ -189,7 +189,7 @@ unfoldline(curLine, pos, left); } pos = 0; - }while(fgets(curLine, LMAXLEN, INF)); + }while(fgets(curLine, BUFSIZE, INF)); //if the errormessages or the warnings should be printed if((OPTIONS[11]) ||(OPTIONS[12])){ R.printErr(OUTF, OPTIONS[11], OPTIONS[12]); @@ -208,13 +208,13 @@ //if was something after the fileversion inentifyer and was put on a new line insert indecate so on the mapfile else if(afterversion){ //read one line which will hold the map of the version - fgets(curLine, LMAXLEN, MAPFILE); + fgets(curLine, BUFSIZE, MAPFILE); //the version has to always be at the beginning of the file so ignore the maping which may be wrong! fputs("#_M#d\n", OUTF); fputs("#_M#d\n", OUTF); } - while(fgets(curLine, LMAXLEN, MAPFILE)) + while(fgets(curLine, BUFSIZE, MAPFILE)) { fputs("#_M#", OUTF); fputs(curLine, OUTF); @@ -266,7 +266,7 @@ else if(insert == 2){ insert = 1; //make it one so if there is another new line to be inserted it is not being skiped } - if(fgets(LINEMAP, LMAXLEN, MAPFILE)){ + if(fgets(LINEMAP, BUFSIZE, MAPFILE)){ rmtblanks(LINEMAP); LMCOUNT = 0; } @@ -381,7 +381,7 @@ } else{ (state == 3)?terminator = '\'':terminator = '"'; - while(curLine[pos]) + while(curLine[tmp]) { if( (curLine[tmp] == terminator) && ((!curLine[tmp + 1]) ||(isspace(curLine[tmp + 1]))) ){ tmp++; @@ -404,18 +404,18 @@ } fputs(curLine, OUTF); LINECOUNT ++; - fgets(curLine, LMAXLEN, INF); + fgets(curLine, BUFSIZE, INF); while(curLine[0] != ';') { fputs(curLine, OUTF); LINECOUNT++; - fgets(curLine, LMAXLEN, INF); + fgets(curLine, BUFSIZE, INF); } if(curLine[pos] == ';'){ rmtblanks(curLine); fputc(';', OUTF); pos = 1; - left = 79; //there is only a semicolon on the line + left = MAXLENGTH -1; //there is only a semicolon on the line } if(DEBUG){ fputs("-----STARToutputTextField------", OUTF); @@ -560,6 +560,10 @@ FRTEXTCNT++; if((!FORMATTEXT[FRTEXTCNT]) || (OPTIONS[7]) || (!formatline) ){ outputTextField(curLine, pos, left); + if(left < MAXLENGTH){ + fputc('\n', OUTF); + left = MAXLENGTH; + } } else{ folding(state, 0, curLine, left, pos); @@ -797,7 +801,7 @@ int nTags = (R.getLoop(NLOOP)) ->ntags; //the number of tags in the loop int nData = (R.getLoop(NLOOP)) -> ndata; int nItems = nTags + nData; //the number of items(tags + data) in the loop - int valid = (R.getLoop(NLOOP)) -> colsize[nTags]; //is the attemted(default) formating valid + int valid = 0; //is the attemted(default) formating valid int curCol = -1; //the current column countig from zero int curBlanks = 0; //the blanks between tokens int brk = 0; //a loop controller @@ -806,7 +810,9 @@ int freesp = 0; //the freespace on the output line int isFolding = OPTIONS[1]; //indicates whether the loop should be folded or unfolded - + if(nTags != 0){ + valid = (R.getLoop(NLOOP)) -> colsize[nTags]; + } //output the loop word-delimeter outputToken(curLine, pos, pos + 5); left -= 5; @@ -820,7 +826,7 @@ if(!curLine[curBlanks + pos]){ //if there is something fputc('\n', OUTF); left = MAXLENGTH; - fgets(curLine, LMAXLEN, INF); + fgets(curLine, BUFSIZE, INF); LINECOUNT++; pos = 0; formatline = formatLine(); @@ -907,8 +913,10 @@ } else{ outputTextField(curLine, pos, left); - fputc('\n', OUTF); - left = MAXLENGTH; + if(!MAPON){ + fputc('\n', OUTF); + left = MAXLENGTH; + } } formatline = formatLine(); } @@ -1200,7 +1208,7 @@ fputc('\n', OUTF); left = MAXLENGTH; } - }while(fgets(curLine, LMAXLEN, INF)); + }while(fgets(curLine, BUFSIZE, INF)); if(DEBUG){ fputs("-ENDformatLoop-", OUTF); } @@ -1283,7 +1291,7 @@ //pass formatline to the method as well also insert the balnk characters outputTextField(curLine, pos, left); } - if(left < MAXLENGTH){ + if((left < MAXLENGTH)&&(!MAPON)){ fputc('\n', OUTF); left = MAXLENGTH; } @@ -1534,7 +1542,7 @@ //put the openning delimeter in the buffer strcpy(buffer, "#"); LINECOUNT++; - fgets(curLine, LMAXLEN, INF); + fgets(curLine, BUFSIZE, INF); do{ rmtblanks(curLine); if(curLine[0] == '#'){ @@ -1571,7 +1579,7 @@ break; } LINECOUNT++; - }while(fgets(curLine, LMAXLEN, INF)); + }while(fgets(curLine, BUFSIZE, INF)); if(DEBUG){ fputs("-outunfoldComment-", OUTF); } delete [] buffer; @@ -1642,7 +1650,7 @@ newLine = false; } LINECOUNT++; - } while(fgets(curLine, LMAXLEN, INF)); + } while(fgets(curLine, BUFSIZE, INF)); if(DEBUG){ fputs("-outunfoldTextField-", OUTF); } return 0; } @@ -1718,7 +1726,7 @@ pos = 0; left = MAXLENGTH; LINECOUNT++; - }while(fgets(curLine, LMAXLEN, INF)); + }while(fgets(curLine, BUFSIZE, INF)); } //if a comment else if(state == 2){ @@ -1868,5 +1876,5 @@ } fputs((curLine + pos), OUTF); LINECOUNT++; - }while(fgets(curLine, LMAXLEN, INF)); + }while(fgets(curLine, BUFSIZE, INF)); } diff -Naur CIFFOLD_0.3/FUCIF.h CIFFOLD_0.4/FUCIF.h --- CIFFOLD_0.3/FUCIF.h 2005-04-23 10:38:39.000000000 -0400 +++ CIFFOLD_0.4/FUCIF.h 2005-04-27 17:10:14.000000000 -0400 @@ -1,5 +1,5 @@ /* -CIFFOLD 0.3 Pre-Release +CIFFOLD 0.4 Pre-Release by Kostadin Mitev, Georgi Todorov and Herbert J. Bernstein Copyright (C) Kostadin Mitev 2005 diff -Naur CIFFOLD_0.3/Globals.h CIFFOLD_0.4/Globals.h --- CIFFOLD_0.3/Globals.h 2005-04-23 10:39:20.000000000 -0400 +++ CIFFOLD_0.4/Globals.h 2005-04-27 17:10:24.000000000 -0400 @@ -1,5 +1,5 @@ /* -CIFFOLD 0.3 Pre-Release +CIFFOLD 0.4 Pre-Release by Kostadin Mitev, Georgi Todorov and Herbert J. Bernstein Copyright (C) Kostadin Mitev 2005 diff -Naur CIFFOLD_0.3/Makefile CIFFOLD_0.4/Makefile --- CIFFOLD_0.3/Makefile 2005-04-23 14:33:13.000000000 -0400 +++ CIFFOLD_0.4/Makefile 2005-04-27 17:10:35.000000000 -0400 @@ -1,4 +1,4 @@ -# CIFFOLD 0.3 Pre-Release +# CIFFOLD 0.4 Pre-Release # by Kostadin Mitev, Georgi Todorov and Herbert J. Bernstein # # Copyright (C) Kostadin Mitev 2005 diff -Naur CIFFOLD_0.3/README.CIFFOLD.html CIFFOLD_0.4/README.CIFFOLD.html --- CIFFOLD_0.3/README.CIFFOLD.html 2005-04-27 12:02:51.000000000 -0400 +++ CIFFOLD_0.4/README.CIFFOLD.html 2005-04-27 17:27:33.000000000 -0400 @@ -1,10 +1,10 @@
-
- +
Written by K. Mitev, 15 April 2005, revised, H. J. Bernstein, 16 April 2005, 19 April 2005, K. Mitev, 22 April 2005, H. J. Bernstein, 27 April 2005. +
diff -Naur CIFFOLD_0.3/README.CIFFOLD.txt CIFFOLD_0.4/README.CIFFOLD.txt --- CIFFOLD_0.3/README.CIFFOLD.txt 2005-04-27 12:03:04.000000000 -0400 +++ CIFFOLD_0.4/README.CIFFOLD.txt 2005-04-27 17:27:56.000000000 -0400 @@ -1,5 +1,5 @@ - CIFFOLD 0.3 Pre-Release + CIFFOLD 0.4 Pre-Release by Kostadin Mitev, Georgi Todorov and Herbert J. Bernstein @@ -421,8 +421,13 @@ http://www.iucr.org/iucr-top/lists/cif-developers/msg00147.html 13. Change Log - - * *Release 0.3, 23 Aptil 2005 KM + * Release 0.4, 27 April 2005 KM, GT + -fixed concatenation of closing text delimiter with the next token + -fixed some segmentation fault problems occuring when the input file is incorrect + -in menus I updated the version of the program and fixed a bug that sets + -the maxlength of a line in folding using -g after the user's input(overwrites the user input making the option useless) + -in getOpts made the program exit upon invalid input, -V or -h(basically every argument except the valid ones will print the help and exit) + * Release 0.3, 23 April 2005 KM Changes in the command line options: -x to be used instead of -h. -h used to print a help message @@ -463,9 +468,8 @@ formatted CIFS, but, in some cases, invalid CIFs cause segmentation faults instead of providing validation messages. - There are some problems with the handling of maps to recover - original formatting. - + Some combinations of the options -M -x -e -c will format the file incorrectly + which does not necessarily result in invalid cif. Written by K. Mitev, 15 April 2005, revised, H. J. Bernstein, 16 April 2005, 19 April 2005, K. Mitev, 22 April 2005, , H. J. Bernstein, 27 diff -Naur CIFFOLD_0.3/ReadFile.cpp CIFFOLD_0.4/ReadFile.cpp --- CIFFOLD_0.3/ReadFile.cpp 2005-04-22 16:26:29.000000000 -0400 +++ CIFFOLD_0.4/ReadFile.cpp 2005-04-27 17:10:56.000000000 -0400 @@ -1,5 +1,5 @@ /* -CIFFOLD 0.2 Pre-Release +CIFFOLD 0.4 Pre-Release by Kostadin Mitev, Georgi Todorov and Herbert J. Bernstein Copyright (C) Kostadin Mitev 2005 @@ -156,6 +156,7 @@ lpinfo[nloop].ndata = 0; lpinfo[nloop].ntags = 0; lpinfo[nloop].format = false; + lpinfo[nloop].colsize = NULL; STATE[2] = true; //If this loop marks the termination of a previous one check the previous for logical integrity if(countitems){ @@ -479,6 +480,12 @@ { size = lpinfo[g].ntags; element = 0; + //if the loop was incorrect and colsize was not initialized then initialize it + if(lpinfo[g].colsize == NULL){ + lpinfo[g].colsize = new unsigned long int[size + 1]; + lpinfo[g].colsize[size] = 0; + continue; + } lpinfo[g].colsize[size] = 0; // used as a boolean 0-the formating is not valid, 1-it is valid //if the loops are considered large and the oprtion format tersly large loops is set then set format to true if((lpformat) && ((getLoop(g)->ndata + size) >= Nitems)) diff -Naur CIFFOLD_0.3/ReadFile.h CIFFOLD_0.4/ReadFile.h --- CIFFOLD_0.3/ReadFile.h 2005-04-23 10:39:36.000000000 -0400 +++ CIFFOLD_0.4/ReadFile.h 2005-04-27 17:11:07.000000000 -0400 @@ -1,5 +1,5 @@ /* -CIFFOLD 0.3 Pre-Release +CIFFOLD 0.4 Pre-Release by Kostadin Mitev, Georgi Todorov and Herbert J. Bernstein Copyright (C) Kostadin Mitev 2005 diff -Naur CIFFOLD_0.3/RevisionLog.abw CIFFOLD_0.4/RevisionLog.abw --- CIFFOLD_0.3/RevisionLog.abw 2005-04-22 18:28:13.000000000 -0400 +++ CIFFOLD_0.4/RevisionLog.abw 1969-12-31 19:00:00.000000000 -0500 @@ -1,51 +0,0 @@ - - -Log to CIFFOLD_0.2 chages:
-04/20/05
-change command line option -g to invoke the GUI and to use/create a map use M.
--x instead -h for filechuncks
--h for help
--V for the version
--C column with respect to which the data should be aligned
--L preserve leading blanks
--p used to print the error messages, warnings or both
--m to range from 75-2048
-Made the following change in menus.cpp
-int startGUI is to have values 0, 1 or 2 only if the value is 2 the curses menu will be started
-startGUI is made 0 by default so it is invoked by the command line argument -g
-added a method printHelp in getOpt.cpp
-made the form of the arguments after -x for the filechunks to be n-n,n-n instead
-made getOpt to output from stdin to stdout if given no arguments
-04/22/05
-Prints the warnings and the error messages to stderr always. If the user is alowed to control through the options only whether to print the error messages and/or warnnings in the file.
-Fixed the problem with the map so it generates or uses a map only if the option -M is selected.
-Disabled the warning "#_#WARNING: AMBIGUOUS STRING DELIMETER CHANGED TO AN ALTERNATIVE ONE(\' to \" or \" to \')" but left it so it can be enabled gain if necessary.
-Changed the values that -m takes again to be in the range 60-2048 and report an error message when a tag or a data block name is longer than the maximum.
-Modified formatLoop to output a new line after outputting a text field also foldline to output new line if curLine [0] == '\0' or the left is less than MAXLENGTH.
-This is supposed to solve an inconsistency with the outputting new lines.
-For the current release the -m option will not be used for unfolding if it is used and its value is different from 2048 it will be adjusted to be 2048.
- - -
- +
Written by K. Mitev, 15 April 2005, revised, H. J. Bernstein, 16 April 2005, 19 April 2005, K. Mitev, 22 April 2005, H. J. Bernstein, 27 April 2005. +