Changeset 1986
- Timestamp:
- Oct 6, 2004, 12:51:31 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 6 edited
-
src/astronomy/psMetadataIO.c (modified) (13 diffs)
-
src/collections/psMetadataIO.c (modified) (13 diffs)
-
src/types/psMetadataConfig.c (modified) (13 diffs)
-
src/xml/psXML.c (modified) (13 diffs)
-
test/astronomy/tst_psMetadataIO.c (modified) (4 diffs)
-
test/collections/tst_psMetadataIO.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astronomy/psMetadataIO.c
r1973 r1986 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10-06 01:17:39$11 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-06 22:51:15 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 101 101 102 102 103 /** Determines if a line is blank (whitespace only) or a comment , if so returns true. The input string must104 * be null terminated. */103 /** Determines if a line is blank (whitespace only) or a commentline. It returns true if so. The input string 104 * must * be null terminated. */ 105 105 bool ignoreLine(char *inString) 106 106 { … … 116 116 117 117 118 /** Removes leading and trailing space from a line, as well as the leading comment # character. The cleaned119 * line is a new null terminated copy of the original input string. The input string must be null terminated.118 /** Removes leading and trailing whitespace and # characters from a string. The cleaned string is a new null 119 * terminated copy of the original input string. 120 120 */ 121 char *clean Line(char *inString)121 char *cleanString(char *inString, int sLen) 122 122 { 123 123 char *ptrB = NULL; 124 124 char *ptrE = NULL; 125 125 char *cleaned = NULL; 126 int sLen = 0; 127 128 129 sLen = strlen(inString); 126 127 130 128 ptrB = inString; 131 129 132 /* Skip over # and leadingwhitespace */130 /* Skip over leading # or whitespace */ 133 131 while (isspace(*ptrB) || *ptrB=='#') { 134 132 ptrB++; 135 133 } 136 134 137 /* Skip over trailing whitespace */135 /* Skip over trailing whitespace, null terminators, and # characters */ 138 136 ptrE = inString + sLen; 139 while(isspace(*ptrE) || *ptrE=='\0' ) {137 while(isspace(*ptrE) || *ptrE=='\0' || *ptrE=='#') { 140 138 ptrE--; 141 139 } … … 150 148 } 151 149 152 /** Count repeat edoccurances of a single character within a line. The input string must be null terminated. */150 /** Count repeat occurances of a single character within a line. The input string must be null terminated. */ 153 151 int repeatedChars(char *inString, char ch) 154 152 { … … 166 164 } 167 165 168 /** Returns individual tokens within a line of text based on delimiter. Tokens are new null terminated copies 169 * of the original input string. */ 170 char* getToken(char **inString, char *delimiter, bool clean) 171 { 172 char *token = NULL; 166 /** Returns cleaned token based on delimiter, but not including delimiter. Also changes the pointer location 167 * the beginning of the string. Tokens are newly allocated null terminated strings. */ 168 char* getToken(char **inString, char *delimiter, int *status) 169 { 173 170 char *cleanToken = NULL; 174 171 int sLen = 0; 175 172 176 173 177 // Skip over leading blanks174 // Skip over leading whitespace 178 175 while(isspace(**inString)) { 179 176 (*inString)++; 180 177 } 181 178 182 // Length of next token179 // Length of token, not including delimiter 183 180 sLen = strcspn(*inString, delimiter); 184 181 if(sLen) { 185 182 186 // Create null terminated token 187 token = psStringNCopy(*inString, sLen); 188 if(clean) { 189 190 // Remove excess from token 191 cleanToken = cleanLine(token); 192 psFree(token); 193 token = cleanToken; 194 } 195 196 // Skip to end of token 183 // Create new, cleaned, and null terminated token 184 cleanToken = cleanString(*inString, sLen); 185 186 // Move to end of token 197 187 (*inString) += sLen; 198 } 199 200 return token; 188 } else if(**inString!='\0' && sLen==0) { 189 *status = 1; 190 } 191 192 return cleanToken; 201 193 } 202 194 … … 212 204 if(*end != '\0') { 213 205 *status = 1; 206 } else if(inString==end) { 207 *status = 1; 214 208 } 215 209 … … 217 211 } 218 212 219 /** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are parsable variations. */213 /** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are acceptable, parsable variations. */ 220 214 bool parseBool(char *inString, int *status) 221 215 { … … 268 262 while(*inString!='\0') { 269 263 value = strtod(inString, &end); 264 if(inString==end) { 265 *status = 1; 266 return vec; 267 } 270 268 switch(elemType) { 271 269 case PS_TYPE_U8: … … 493 491 // While loop to parse the file 494 492 while(fgets(line, MAX_STRING_LENGTH, fp) != NULL) { 493 494 // Initialize variables for new line 495 495 linePtr = line; 496 496 lineCount++; … … 509 509 psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line); 510 510 continue; 511 } 511 } else if(repeatedChars(linePtr, '~') > 0) { 512 failedLines++; 513 psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line); 514 continue; 515 } 516 512 517 513 518 // Get metadata item name 514 strName = getToken(&linePtr, " ", true); 515 if(strName==NULL) { 516 failedLines++; 519 strName = getToken(&linePtr, " ", &status); 520 if(strName==NULL || status) { 521 failedLines++; 522 status = 0; 517 523 psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line); 518 524 continue; … … 520 526 521 527 // Get the metadata item type 522 strType = getToken(&linePtr, " ", true);528 strType = getToken(&linePtr, " ", &status); 523 529 if(strType==NULL) { 524 530 failedLines++; 531 status = 0; 525 532 psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line); 526 533 continue; … … 554 561 // Get the metadata item value if there is one. Lines with * don't have values. 555 562 if(mdType != PS_META_ITEM_SET) { 556 strValue = getToken(&linePtr, "#", true);563 strValue = getToken(&linePtr, "#", &status); 557 564 if(strValue==NULL) { 558 565 failedLines++; 566 status = 0; 559 567 psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line); 560 568 continue; … … 563 571 564 572 // Get the metadata item value if there is one. Not all lines will have comments, so NULL is ok. 565 strComment = getToken(&linePtr,"!!!!", true); 573 strComment = getToken(&linePtr,"~", &status); 574 if(status) { 575 failedLines++; 576 status = 0; 577 psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line); 578 continue; 579 } 566 580 567 581 /* If metadata item is found, is not a folder node, and overwrite is allowed, then remove existing -
trunk/psLib/src/collections/psMetadataIO.c
r1973 r1986 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10-06 01:17:39$11 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-06 22:51:15 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 101 101 102 102 103 /** Determines if a line is blank (whitespace only) or a comment , if so returns true. The input string must104 * be null terminated. */103 /** Determines if a line is blank (whitespace only) or a commentline. It returns true if so. The input string 104 * must * be null terminated. */ 105 105 bool ignoreLine(char *inString) 106 106 { … … 116 116 117 117 118 /** Removes leading and trailing space from a line, as well as the leading comment # character. The cleaned119 * line is a new null terminated copy of the original input string. The input string must be null terminated.118 /** Removes leading and trailing whitespace and # characters from a string. The cleaned string is a new null 119 * terminated copy of the original input string. 120 120 */ 121 char *clean Line(char *inString)121 char *cleanString(char *inString, int sLen) 122 122 { 123 123 char *ptrB = NULL; 124 124 char *ptrE = NULL; 125 125 char *cleaned = NULL; 126 int sLen = 0; 127 128 129 sLen = strlen(inString); 126 127 130 128 ptrB = inString; 131 129 132 /* Skip over # and leadingwhitespace */130 /* Skip over leading # or whitespace */ 133 131 while (isspace(*ptrB) || *ptrB=='#') { 134 132 ptrB++; 135 133 } 136 134 137 /* Skip over trailing whitespace */135 /* Skip over trailing whitespace, null terminators, and # characters */ 138 136 ptrE = inString + sLen; 139 while(isspace(*ptrE) || *ptrE=='\0' ) {137 while(isspace(*ptrE) || *ptrE=='\0' || *ptrE=='#') { 140 138 ptrE--; 141 139 } … … 150 148 } 151 149 152 /** Count repeat edoccurances of a single character within a line. The input string must be null terminated. */150 /** Count repeat occurances of a single character within a line. The input string must be null terminated. */ 153 151 int repeatedChars(char *inString, char ch) 154 152 { … … 166 164 } 167 165 168 /** Returns individual tokens within a line of text based on delimiter. Tokens are new null terminated copies 169 * of the original input string. */ 170 char* getToken(char **inString, char *delimiter, bool clean) 171 { 172 char *token = NULL; 166 /** Returns cleaned token based on delimiter, but not including delimiter. Also changes the pointer location 167 * the beginning of the string. Tokens are newly allocated null terminated strings. */ 168 char* getToken(char **inString, char *delimiter, int *status) 169 { 173 170 char *cleanToken = NULL; 174 171 int sLen = 0; 175 172 176 173 177 // Skip over leading blanks174 // Skip over leading whitespace 178 175 while(isspace(**inString)) { 179 176 (*inString)++; 180 177 } 181 178 182 // Length of next token179 // Length of token, not including delimiter 183 180 sLen = strcspn(*inString, delimiter); 184 181 if(sLen) { 185 182 186 // Create null terminated token 187 token = psStringNCopy(*inString, sLen); 188 if(clean) { 189 190 // Remove excess from token 191 cleanToken = cleanLine(token); 192 psFree(token); 193 token = cleanToken; 194 } 195 196 // Skip to end of token 183 // Create new, cleaned, and null terminated token 184 cleanToken = cleanString(*inString, sLen); 185 186 // Move to end of token 197 187 (*inString) += sLen; 198 } 199 200 return token; 188 } else if(**inString!='\0' && sLen==0) { 189 *status = 1; 190 } 191 192 return cleanToken; 201 193 } 202 194 … … 212 204 if(*end != '\0') { 213 205 *status = 1; 206 } else if(inString==end) { 207 *status = 1; 214 208 } 215 209 … … 217 211 } 218 212 219 /** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are parsable variations. */213 /** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are acceptable, parsable variations. */ 220 214 bool parseBool(char *inString, int *status) 221 215 { … … 268 262 while(*inString!='\0') { 269 263 value = strtod(inString, &end); 264 if(inString==end) { 265 *status = 1; 266 return vec; 267 } 270 268 switch(elemType) { 271 269 case PS_TYPE_U8: … … 493 491 // While loop to parse the file 494 492 while(fgets(line, MAX_STRING_LENGTH, fp) != NULL) { 493 494 // Initialize variables for new line 495 495 linePtr = line; 496 496 lineCount++; … … 509 509 psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line); 510 510 continue; 511 } 511 } else if(repeatedChars(linePtr, '~') > 0) { 512 failedLines++; 513 psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line); 514 continue; 515 } 516 512 517 513 518 // Get metadata item name 514 strName = getToken(&linePtr, " ", true); 515 if(strName==NULL) { 516 failedLines++; 519 strName = getToken(&linePtr, " ", &status); 520 if(strName==NULL || status) { 521 failedLines++; 522 status = 0; 517 523 psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line); 518 524 continue; … … 520 526 521 527 // Get the metadata item type 522 strType = getToken(&linePtr, " ", true);528 strType = getToken(&linePtr, " ", &status); 523 529 if(strType==NULL) { 524 530 failedLines++; 531 status = 0; 525 532 psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line); 526 533 continue; … … 554 561 // Get the metadata item value if there is one. Lines with * don't have values. 555 562 if(mdType != PS_META_ITEM_SET) { 556 strValue = getToken(&linePtr, "#", true);563 strValue = getToken(&linePtr, "#", &status); 557 564 if(strValue==NULL) { 558 565 failedLines++; 566 status = 0; 559 567 psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line); 560 568 continue; … … 563 571 564 572 // Get the metadata item value if there is one. Not all lines will have comments, so NULL is ok. 565 strComment = getToken(&linePtr,"!!!!", true); 573 strComment = getToken(&linePtr,"~", &status); 574 if(status) { 575 failedLines++; 576 status = 0; 577 psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line); 578 continue; 579 } 566 580 567 581 /* If metadata item is found, is not a folder node, and overwrite is allowed, then remove existing -
trunk/psLib/src/types/psMetadataConfig.c
r1973 r1986 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10-06 01:17:39$11 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-06 22:51:15 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 101 101 102 102 103 /** Determines if a line is blank (whitespace only) or a comment , if so returns true. The input string must104 * be null terminated. */103 /** Determines if a line is blank (whitespace only) or a commentline. It returns true if so. The input string 104 * must * be null terminated. */ 105 105 bool ignoreLine(char *inString) 106 106 { … … 116 116 117 117 118 /** Removes leading and trailing space from a line, as well as the leading comment # character. The cleaned119 * line is a new null terminated copy of the original input string. The input string must be null terminated.118 /** Removes leading and trailing whitespace and # characters from a string. The cleaned string is a new null 119 * terminated copy of the original input string. 120 120 */ 121 char *clean Line(char *inString)121 char *cleanString(char *inString, int sLen) 122 122 { 123 123 char *ptrB = NULL; 124 124 char *ptrE = NULL; 125 125 char *cleaned = NULL; 126 int sLen = 0; 127 128 129 sLen = strlen(inString); 126 127 130 128 ptrB = inString; 131 129 132 /* Skip over # and leadingwhitespace */130 /* Skip over leading # or whitespace */ 133 131 while (isspace(*ptrB) || *ptrB=='#') { 134 132 ptrB++; 135 133 } 136 134 137 /* Skip over trailing whitespace */135 /* Skip over trailing whitespace, null terminators, and # characters */ 138 136 ptrE = inString + sLen; 139 while(isspace(*ptrE) || *ptrE=='\0' ) {137 while(isspace(*ptrE) || *ptrE=='\0' || *ptrE=='#') { 140 138 ptrE--; 141 139 } … … 150 148 } 151 149 152 /** Count repeat edoccurances of a single character within a line. The input string must be null terminated. */150 /** Count repeat occurances of a single character within a line. The input string must be null terminated. */ 153 151 int repeatedChars(char *inString, char ch) 154 152 { … … 166 164 } 167 165 168 /** Returns individual tokens within a line of text based on delimiter. Tokens are new null terminated copies 169 * of the original input string. */ 170 char* getToken(char **inString, char *delimiter, bool clean) 171 { 172 char *token = NULL; 166 /** Returns cleaned token based on delimiter, but not including delimiter. Also changes the pointer location 167 * the beginning of the string. Tokens are newly allocated null terminated strings. */ 168 char* getToken(char **inString, char *delimiter, int *status) 169 { 173 170 char *cleanToken = NULL; 174 171 int sLen = 0; 175 172 176 173 177 // Skip over leading blanks174 // Skip over leading whitespace 178 175 while(isspace(**inString)) { 179 176 (*inString)++; 180 177 } 181 178 182 // Length of next token179 // Length of token, not including delimiter 183 180 sLen = strcspn(*inString, delimiter); 184 181 if(sLen) { 185 182 186 // Create null terminated token 187 token = psStringNCopy(*inString, sLen); 188 if(clean) { 189 190 // Remove excess from token 191 cleanToken = cleanLine(token); 192 psFree(token); 193 token = cleanToken; 194 } 195 196 // Skip to end of token 183 // Create new, cleaned, and null terminated token 184 cleanToken = cleanString(*inString, sLen); 185 186 // Move to end of token 197 187 (*inString) += sLen; 198 } 199 200 return token; 188 } else if(**inString!='\0' && sLen==0) { 189 *status = 1; 190 } 191 192 return cleanToken; 201 193 } 202 194 … … 212 204 if(*end != '\0') { 213 205 *status = 1; 206 } else if(inString==end) { 207 *status = 1; 214 208 } 215 209 … … 217 211 } 218 212 219 /** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are parsable variations. */213 /** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are acceptable, parsable variations. */ 220 214 bool parseBool(char *inString, int *status) 221 215 { … … 268 262 while(*inString!='\0') { 269 263 value = strtod(inString, &end); 264 if(inString==end) { 265 *status = 1; 266 return vec; 267 } 270 268 switch(elemType) { 271 269 case PS_TYPE_U8: … … 493 491 // While loop to parse the file 494 492 while(fgets(line, MAX_STRING_LENGTH, fp) != NULL) { 493 494 // Initialize variables for new line 495 495 linePtr = line; 496 496 lineCount++; … … 509 509 psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line); 510 510 continue; 511 } 511 } else if(repeatedChars(linePtr, '~') > 0) { 512 failedLines++; 513 psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line); 514 continue; 515 } 516 512 517 513 518 // Get metadata item name 514 strName = getToken(&linePtr, " ", true); 515 if(strName==NULL) { 516 failedLines++; 519 strName = getToken(&linePtr, " ", &status); 520 if(strName==NULL || status) { 521 failedLines++; 522 status = 0; 517 523 psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line); 518 524 continue; … … 520 526 521 527 // Get the metadata item type 522 strType = getToken(&linePtr, " ", true);528 strType = getToken(&linePtr, " ", &status); 523 529 if(strType==NULL) { 524 530 failedLines++; 531 status = 0; 525 532 psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line); 526 533 continue; … … 554 561 // Get the metadata item value if there is one. Lines with * don't have values. 555 562 if(mdType != PS_META_ITEM_SET) { 556 strValue = getToken(&linePtr, "#", true);563 strValue = getToken(&linePtr, "#", &status); 557 564 if(strValue==NULL) { 558 565 failedLines++; 566 status = 0; 559 567 psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line); 560 568 continue; … … 563 571 564 572 // Get the metadata item value if there is one. Not all lines will have comments, so NULL is ok. 565 strComment = getToken(&linePtr,"!!!!", true); 573 strComment = getToken(&linePtr,"~", &status); 574 if(status) { 575 failedLines++; 576 status = 0; 577 psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line); 578 continue; 579 } 566 580 567 581 /* If metadata item is found, is not a folder node, and overwrite is allowed, then remove existing -
trunk/psLib/src/xml/psXML.c
r1973 r1986 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10-06 01:17:39$11 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-06 22:51:15 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 101 101 102 102 103 /** Determines if a line is blank (whitespace only) or a comment , if so returns true. The input string must104 * be null terminated. */103 /** Determines if a line is blank (whitespace only) or a commentline. It returns true if so. The input string 104 * must * be null terminated. */ 105 105 bool ignoreLine(char *inString) 106 106 { … … 116 116 117 117 118 /** Removes leading and trailing space from a line, as well as the leading comment # character. The cleaned119 * line is a new null terminated copy of the original input string. The input string must be null terminated.118 /** Removes leading and trailing whitespace and # characters from a string. The cleaned string is a new null 119 * terminated copy of the original input string. 120 120 */ 121 char *clean Line(char *inString)121 char *cleanString(char *inString, int sLen) 122 122 { 123 123 char *ptrB = NULL; 124 124 char *ptrE = NULL; 125 125 char *cleaned = NULL; 126 int sLen = 0; 127 128 129 sLen = strlen(inString); 126 127 130 128 ptrB = inString; 131 129 132 /* Skip over # and leadingwhitespace */130 /* Skip over leading # or whitespace */ 133 131 while (isspace(*ptrB) || *ptrB=='#') { 134 132 ptrB++; 135 133 } 136 134 137 /* Skip over trailing whitespace */135 /* Skip over trailing whitespace, null terminators, and # characters */ 138 136 ptrE = inString + sLen; 139 while(isspace(*ptrE) || *ptrE=='\0' ) {137 while(isspace(*ptrE) || *ptrE=='\0' || *ptrE=='#') { 140 138 ptrE--; 141 139 } … … 150 148 } 151 149 152 /** Count repeat edoccurances of a single character within a line. The input string must be null terminated. */150 /** Count repeat occurances of a single character within a line. The input string must be null terminated. */ 153 151 int repeatedChars(char *inString, char ch) 154 152 { … … 166 164 } 167 165 168 /** Returns individual tokens within a line of text based on delimiter. Tokens are new null terminated copies 169 * of the original input string. */ 170 char* getToken(char **inString, char *delimiter, bool clean) 171 { 172 char *token = NULL; 166 /** Returns cleaned token based on delimiter, but not including delimiter. Also changes the pointer location 167 * the beginning of the string. Tokens are newly allocated null terminated strings. */ 168 char* getToken(char **inString, char *delimiter, int *status) 169 { 173 170 char *cleanToken = NULL; 174 171 int sLen = 0; 175 172 176 173 177 // Skip over leading blanks174 // Skip over leading whitespace 178 175 while(isspace(**inString)) { 179 176 (*inString)++; 180 177 } 181 178 182 // Length of next token179 // Length of token, not including delimiter 183 180 sLen = strcspn(*inString, delimiter); 184 181 if(sLen) { 185 182 186 // Create null terminated token 187 token = psStringNCopy(*inString, sLen); 188 if(clean) { 189 190 // Remove excess from token 191 cleanToken = cleanLine(token); 192 psFree(token); 193 token = cleanToken; 194 } 195 196 // Skip to end of token 183 // Create new, cleaned, and null terminated token 184 cleanToken = cleanString(*inString, sLen); 185 186 // Move to end of token 197 187 (*inString) += sLen; 198 } 199 200 return token; 188 } else if(**inString!='\0' && sLen==0) { 189 *status = 1; 190 } 191 192 return cleanToken; 201 193 } 202 194 … … 212 204 if(*end != '\0') { 213 205 *status = 1; 206 } else if(inString==end) { 207 *status = 1; 214 208 } 215 209 … … 217 211 } 218 212 219 /** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are parsable variations. */213 /** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are acceptable, parsable variations. */ 220 214 bool parseBool(char *inString, int *status) 221 215 { … … 268 262 while(*inString!='\0') { 269 263 value = strtod(inString, &end); 264 if(inString==end) { 265 *status = 1; 266 return vec; 267 } 270 268 switch(elemType) { 271 269 case PS_TYPE_U8: … … 493 491 // While loop to parse the file 494 492 while(fgets(line, MAX_STRING_LENGTH, fp) != NULL) { 493 494 // Initialize variables for new line 495 495 linePtr = line; 496 496 lineCount++; … … 509 509 psError(__func__, "More than one @ charecter not allowed. Line %d: %s", lineCount, line); 510 510 continue; 511 } 511 } else if(repeatedChars(linePtr, '~') > 0) { 512 failedLines++; 513 psError(__func__, "Illegal character. Character:~ Line %d: %s", lineCount, line); 514 continue; 515 } 516 512 517 513 518 // Get metadata item name 514 strName = getToken(&linePtr, " ", true); 515 if(strName==NULL) { 516 failedLines++; 519 strName = getToken(&linePtr, " ", &status); 520 if(strName==NULL || status) { 521 failedLines++; 522 status = 0; 517 523 psError(__func__, "Null name not allowed. Line %d: %s", lineCount, line); 518 524 continue; … … 520 526 521 527 // Get the metadata item type 522 strType = getToken(&linePtr, " ", true);528 strType = getToken(&linePtr, " ", &status); 523 529 if(strType==NULL) { 524 530 failedLines++; 531 status = 0; 525 532 psError(__func__, "Null type not allowed. Line %d: %s", lineCount, line); 526 533 continue; … … 554 561 // Get the metadata item value if there is one. Lines with * don't have values. 555 562 if(mdType != PS_META_ITEM_SET) { 556 strValue = getToken(&linePtr, "#", true);563 strValue = getToken(&linePtr, "#", &status); 557 564 if(strValue==NULL) { 558 565 failedLines++; 566 status = 0; 559 567 psError(__func__, "Null value not allowed. Line %d: %s", lineCount, line); 560 568 continue; … … 563 571 564 572 // Get the metadata item value if there is one. Not all lines will have comments, so NULL is ok. 565 strComment = getToken(&linePtr,"!!!!", true); 573 strComment = getToken(&linePtr,"~", &status); 574 if(status) { 575 failedLines++; 576 status = 0; 577 psError(__func__, "Failed to parse comment. Line %d: %s", lineCount, line); 578 continue; 579 } 566 580 567 581 /* If metadata item is found, is not a folder node, and overwrite is allowed, then remove existing -
trunk/psLib/test/astronomy/tst_psMetadataIO.c
r1972 r1986 13 13 * @author Ross Harman, MHPCC 14 14 * 15 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $16 * @date $Date: 2004-10-06 01:08:17$15 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2004-10-06 22:51:31 $ 17 17 * 18 18 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 130 130 int failedLines1 = 0; 131 131 failedLines1 = psMetadataParseConfig(&metadata1, "test.config", true); 132 printf("Failed lines: %d Expected: 5\n", failedLines1);132 printf("Failed lines: %d Expected: 6\n", failedLines1); 133 133 printMetadata(metadata1); 134 134 printFooter(stdout, "psMetadata", "Test A - Read config file with overwrite set true", true); … … 140 140 int failedLines2 = 0; 141 141 failedLines2 = psMetadataParseConfig(&metadata2, "test.config", false); 142 printf("Failed lines: %d Expected: 6\n", failedLines2);142 printf("Failed lines: %d Expected: 7", failedLines2); 143 143 printMetadata(metadata2); 144 144 printFooter(stdout, "psMetadata", "Test B - Read config file with overwrite set false", true); … … 150 150 int failedLines3 = 0; 151 151 failedLines3 = psMetadataParseConfig(&metadata3, "test.config", false); 152 printf("Failed lines: %d \n Expected: 6", failedLines3);152 printf("Failed lines: %d Expected: 7", failedLines3); 153 153 printMetadata(metadata3); 154 154 printFooter(stdout, "psMetadata", "Test C - Read config file without auto-allocation of metadata", true); -
trunk/psLib/test/collections/tst_psMetadataIO.c
r1972 r1986 13 13 * @author Ross Harman, MHPCC 14 14 * 15 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $16 * @date $Date: 2004-10-06 01:08:17$15 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2004-10-06 22:51:31 $ 17 17 * 18 18 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 130 130 int failedLines1 = 0; 131 131 failedLines1 = psMetadataParseConfig(&metadata1, "test.config", true); 132 printf("Failed lines: %d Expected: 5\n", failedLines1);132 printf("Failed lines: %d Expected: 6\n", failedLines1); 133 133 printMetadata(metadata1); 134 134 printFooter(stdout, "psMetadata", "Test A - Read config file with overwrite set true", true); … … 140 140 int failedLines2 = 0; 141 141 failedLines2 = psMetadataParseConfig(&metadata2, "test.config", false); 142 printf("Failed lines: %d Expected: 6\n", failedLines2);142 printf("Failed lines: %d Expected: 7", failedLines2); 143 143 printMetadata(metadata2); 144 144 printFooter(stdout, "psMetadata", "Test B - Read config file with overwrite set false", true); … … 150 150 int failedLines3 = 0; 151 151 failedLines3 = psMetadataParseConfig(&metadata3, "test.config", false); 152 printf("Failed lines: %d \n Expected: 6", failedLines3);152 printf("Failed lines: %d Expected: 7", failedLines3); 153 153 printMetadata(metadata3); 154 154 printFooter(stdout, "psMetadata", "Test C - Read config file without auto-allocation of metadata", true);
Note:
See TracChangeset
for help on using the changeset viewer.
